Someone has way too much free time, but I applaud them for their creativity!
Saturday, February 1, 2014
Star Wars Imperial March with Floppy and Arduino
Someone has way too much free time, but I applaud them for their creativity!
Friday, January 31, 2014
Rolled Car on I-215
Friday, January 24, 2014
Lego: Lord of the Rings - 100% Completed
![]() |
| Lego: Lord of the Rings - 100% completion |
PLUG - Regular Expressions
![]() |
| PLUG - 1/21/2014 - David Oswald - "Regular Expressions" |
"What is backtracking? How do character classes work? What is the "Little Engine that Could(n't)"?"
Notes
Definitions:
- Literal Characters: abcd... ABC... 123...
- Operators: m// (match), s/// (substitute), =~ or !~ (bind)
- Meta-characters: \ | ( ) [ { ^ $ * + ? .
- Meta symbols: \b \D \t \3 etc...
Example:
$string = "hello world"; say "Match" if $string =~ m/hello/;
Syntactic Shortcuts:
$_ = "hello world"; say "match" if /hello/;
DFA / NFA / Hybrid Engines - (Deterministic Finite Automata) DFAs and (Non-deterministic Finite Automata) NFAs have exactly the same capabilities and limitations. The only difference is notation convenience.
- DFA: simpler, text-directed match, no backtracking, more limited, awk/egrep
- NFA: regex-directed match, backtracking, more flexible semantics, grep/less/sed/more/Perl/PHP/Python
Two big NFA rules:
- The match that begins earliest wins.
- The standard quantifiers are greedy.
- rxrx - command-line REPL and wrapper for Regexp::Debugger
Quick rxrx overview:
Install:
cpan Regexp::Debugger
Usage:
rxrx
perl -MRegexp::Debugger -E 'Regexp::Debugger::rxrx(@ARGV)'
To set the regex:
/[SOMETHING]/
To set the string:
'[SOMETHING]'
To start match engine: 'm'
To quit: 'q'
Commands:
/ : Enter a pattern
' : Enter a new literal string
" : Enter a new double-quoted string
m : Match current string against current pattern
q or x : quit debugger and exit
h : help
Match Commands:
- : back step
[enter] : forward step
c : proceed visually quickly to the end
Example of large backtracking out of control:
# fails in 218 steps /(a*)*[^Bb]$/ 'aaaaaab'
Backtracking can be put under control by using "possessive quantifiers": (*+, ++, ?+, {n,m}+)
# fails in 79 steps /(a*)*+[^Bb]$/
Possessive quantifiers - change the "greedy" quantifiers to "lazy" quantifiers that attempt to match the minimal amount. Greedy quantifiers attempt to match the greatest left most match. Lazy quantifiers attempt to match the least left most match.
/.*foo/ # Greedy ; backtrack backwards. /.*?foo/ # Lazy; backtrack forward.
More NFA rules:
- Matches occur as far left as possible.
- Alternation has left-to-right precedence.
- Alternative matches if every item listed in the alternative matches sequentially.
- Backtracking occurs to try higher-pecking-order assertions.
- Quantifiers must be satisfied within their permissible range.
- Each atom matches according to its designated semantics.
Shorter segments are often easier:
if( /Brian/ && /John/ ) { ... }
# vs
if( /Brian.*John|John.*Brian/ ) { ... }
Progressive matching - starting where the previous pattern starts off
When to use RegExes:
RegExes are for matching patters, not for things that have a parser, like HTML and JSON. Should also not be used for Email Addresses.
"Regexes optimal for small HTML parsing problems, pessimal for large ones" -- Tom Christiansesn
Appropriate Alternatives:
- Complex grammars - use parsing classes
- Fixed-width fields - use unpack, substr
- Comma Separated Values - use CSV libraries
- Uncomplicated, predictable data - Regular Expressions!
What to Watch on Netflix
Netflix Change Account - Konami Code
![]() |
| Samsung Smart TV |
"We're having trouble playing these titles for you right now. Please try again later or select a different title"
After a bit of research I found a suggestion to deactivate and reactivate the device, from within the Netflix application. This is the same procedure you would use if you needed to change which Netflix account, the application uses. At first I thought it was a joke, as it uses an old Nintendo gaming cheat code (Konami Code), but it turned out to be legit:
"While logged into the old account and with the app showing the list of movies, hit the following sequence of buttons on the TV remote: up, up, down, down, left, right, left, right, up, up, up, up."
After following this sequence, we were prompted to deactivate the device. We then logged back into Netflix and were prompted to reenter our account information. This time it worked. Not sure why it was broken in the first place, but glad we found a workaround.
Later, I found another method of deactivating the device, from within the online Netflix account. I have not had a chance to try this, as our TV's Netflix App is back to functioning, but if it happens again, we will be sure to try this first.
![]() |
| Netflix |
Wednesday, January 1, 2014
365 Photo Project
Happy New Year 2014
As part of my New Year's resolution, I am going to do the:
The purpose of the 365 Day Photo Challenge is to "document a year of your life by taking a photo a day."
Subscribe to:
Posts (Atom)









