Page 1 of 1

Ayn Rand et. al, today's xkcd

PostPosted: Mon Oct 14, 2013 7:45 pm
by pumpkinpi
http://xkcd.com/1277/

The mouse roll-over is one of the best I've seen.

In a cavern deep below Earth, Any Rand, Paul Ryan, Rand Paul, Ann Druyan, Paul Rudd, Alan Alda, and Duran Duran meet together in the Secret Council of /(\b[plurandy]+\b?){2}/i


I just need to figure out what that equation means!

Re: Ayn Rand et. al, today's xkcd

PostPosted: Mon Oct 14, 2013 9:40 pm
by brite
According to this it's the Rand-all coding generator...

Re: Ayn Rand et. al, today's xkcd

PostPosted: Mon Oct 14, 2013 11:45 pm
by Cyborg Girl
It's a regular expression, not an equation. :) And it matches any two words made up exclusively of the letters P, L, U, R, A, N, D, Y, regardless of letter case. \b is a word boundary, [] denotes a character range, + means one or more, ? means something is optional, {2} means that an expression must occur twice, and () dictates order of evaluation.

I can be sysadmin now please?

Re: Ayn Rand et. al, today's xkcd

PostPosted: Tue Oct 15, 2013 12:40 am
by cid
Gullible Jones paused, thought for a minute, and then played the "I'm techier than you are" card when he wrote:
I can be sysadmin now please?


...only if you can tell us IN ENGLISH (words of two syllables or less) just what possible use that 'equation' has... :think: ... :sos: ... :shrug:..

Re: Ayn Rand et. al, today's xkcd

PostPosted: Tue Oct 15, 2013 12:41 am
by pumpkinpi
Gullible Jones wrote:It's a regular expression, not an equation. :) And it matches any two words made up exclusively of the letters P, L, U, R, A, N, D, Y, regardless of letter case. \b is a word boundary, [] denotes a character range, + means one or more, ? means something is optional, {2} means that an expression must occur twice, and () dictates order of evaluation.

I can be sysadmin now please?

Yes. That's exactly the answer I was hoping for. And I knew "equation" didn't sound right. :D
Could you tell that was what it meant just by looking at it?

Re: Ayn Rand et. al, today's xkcd

PostPosted: Tue Oct 15, 2013 2:02 am
by Cyborg Girl
cid wrote:...only if you can tell us IN ENGLISH (words of two syllables or less) just what possible use that 'equation' has... :think: ... :sos: ... :shrug:..


Searching for certain patterns in text. e.g. say you wanted to find all IP addresses in a server log file. You could use

'(([0-9]{1,3}\.){3}[0-9]{1,3}'

i.e.

( # group
([0-9]{1,3}) # 1 to 3 numeric digits
\. # a literal dot
) # end group
{3} # must occur three times
[0-9]{1,3} # 1 to 3 numeric digits (again)

That will probably turn up things other than IPs if used on a log file, but it narrows a search down considerably. And it gets better - you can combine it with some other UNIX tools. Say you have a firewall that prints "DROPPED" to the log whenever it drops a packet. You want to find out which IPs have been pounding your firewall with the most attacks. You could create a chain of commands, like this:

Code: Select all
grep DROPPED /var/log/messages | egrep -o '(([0-9]{1,3})\.){3}[0-9]{1,3}' | sort | uniq -c | sort -g


i.e.

"Find the string DROPPED in the log file"
"Find strings that look like IPs, and show only those strings"
"Sort the addresses"
"Show only unique addresses, prefixed with how many times they occur"
"Sort them again, by numeric value"

And the IPs at the bottom will be the ones with the most dropped packets... Assuming, at least, that the firewall doesn't print out some other information that throws off the search. One of the rules of regular expressions is that you have to know your data.

pumpkinpi wrote:Could you tell that was what it meant just by looking at it?


Hah, I wish... Usually I have to sound them out, so to speak.

Re: Ayn Rand et. al, today's xkcd

PostPosted: Tue Oct 15, 2013 5:26 am
by Sigma_Orionis
Can't get what the REGEX is supposed to match.

Re: Ayn Rand et. al, today's xkcd

PostPosted: Tue Oct 15, 2013 2:19 pm
by Cyborg Girl
It matches all the names he lists. I think that's all...

Re: Ayn Rand et. al, today's xkcd

PostPosted: Tue Oct 15, 2013 2:27 pm
by code monkey
Gullible Jones wrote:It's a regular expression, not an equation. :) And it matches any two words made up exclusively of the letters P, L, U, R, A, N, D, Y, regardless of letter case. \b is a word boundary, [] denotes a character range, + means one or more, ? means something is optional, {2} means that an expression must occur twice, and () dictates order of evaluation.

I can be sysadmin now please?

gj, you can be master of the universe! that was a terrific explanation! (even though a few of the words were > 2 syllables.)

so it would pull out:
Any Rand, Paul Ryan, Rand Paul, Ann Druyan, Paul Rudd, Alan Alda, and Duran Duran

as well as ayn rand. not exactly numbers but we'll let that go. some strings are more equal than other strings.

pumpkinpi, thank you for pointing out the mouse rollover. i'm relatively new to xkcd and clearly i've been missing quite a bit.