| Andrew Cooke | Contents | RSS | Twitter | Previous

C[omp]ute

Welcome to my blog, which was once a mailing list of the same name and is still generated by mail. Please reply via the "comment" links.

Always interested in offers/projects/new ideas. Eclectic experience in fields like: numerical computing; Python web; Java enterprise; functional languages; GPGPU; SQL databases; etc. Based in Santiago, Chile; telecommute worldwide. CV; email.

© 2006-2013 Andrew Cooke (site) / post authors (content).

ASCII Fluid Dynamics

From: andrew cooke <andrew@...>

Date: Thu, 5 Mar 2015 08:34:42 -0300

https://www.youtube.com/watch?v=QMYfkOtYYlg

http://www.ioccc.org/2012/endoh1/hint.html

Andrew

Permalink | Comment on this post

Previous Entries

For comments, see relevant pages (permalinks).

Brandalism

From: andrew cooke <andrew@...>

Date: Thu, 26 Feb 2015 11:19:55 -0300

http://www.brandalism.org.uk/

Andrew

Permalink

Table of Shifter, Cassette and Derailleur Compatability

From: andrew cooke <andrew@...>

Date: Sat, 21 Feb 2015 13:40:43 -0300

http://blog.artscyclery.com/science-behind-the-magic/science-behind-the-magic-drivetrain-compatibility/

Andrew

Permalink

Lenovo Demonstrates How Bad HTTPS Is

From: andrew cooke <andrew@...>

Date: Thu, 19 Feb 2015 15:53:16 -0300

Fully functioning MITM attack, even on Google with Crhome (ie even with pinned
certificates).  Also works on banks etc.  Key is broken and public.

http://arstechnica.com/security/2015/02/lenovo-pcs-ship-with-man-in-the-middle-adware-that-breaks-https-connections/

Andrew

Permalink

Telegraph Owned by HSBC

From: andrew cooke <andrew@...>

Date: Wed, 18 Feb 2015 18:44:28 -0300

Resignation letter showing how corrupt the Telegraph, of all things, has
become - http://order-order.com/2015/02/17/breaking-oborne-quits-telegraph/

Andrew

Permalink

Smaptop - Sunrise (Music)

From: andrew cooke <andrew@...>

Date: Mon, 16 Feb 2015 20:50:53 -0300

http://slaptopmusic.com/

Andrew

Permalink

Equation Group (NSA)

From: andrew cooke <andrew@...>

Date: Mon, 16 Feb 2015 17:46:21 -0300

http://arstechnica.com/security/2015/02/how-omnipotent-hackers-tied-to-the-nsa-hid-for-14-years-and-were-found-at-last/

Andrew

Permalink

UK Torture in NI

From: andrew cooke <andrew@...>

Date: Sat, 14 Feb 2015 19:54:48 -0300

I had no idea this happened -
http://www.independent.co.uk/voices/comment/if-amal-clooney-wins-the-hooded-man-case-the-embarrassment-for-the-uk-would-be-huge-10044980.html

Andrew

Permalink

And - A Natural Extension To Regexps

From: andrew cooke <andrew@...>

Date: Tue, 10 Feb 2015 22:33:09 -0300

I found an old book of cryptic crossword puzzles the other day.  Sitting down
to do one I found an anagram.  So I wondered how to "grep"
/usr/share/dict/words.

It turns out that regeexps for anagrams aren't that great.  If you restrict
yourself to a traditional ERE (without lookbacks / lookforwards) then it seems
like the best you can do is a tree of alternatives.

I wrote a little program to generate this:

  #!/usr/bin/python3

  from sys import argv

  assert len(argv) == 2, "usage: regexp LETTERS"

  def alternatives(letters):
      if len(letters) == 1:
	  yield letters
      else:
	  yield '('
	  for (i, letter) in enumerate(letters):
	      if i: yield '|'
	      yield letter
	      yield from alternatives(letters[:i] + letters[i+1:])
	  yield ')'

  print('^' + ''.join(alternatives(argv[1])) + '$')

Which works ok:

  andrew@...:~/bin> regexp dog
  ^(d(og|go)|o(dg|gd)|g(do|od))$

  andrew@...:~/bin> egrep -i `regexp dog` /usr/share/dict/words 
  dog
  God

except that, of course, it's O(n!).  Which makes it useless.

So then I poked around a bit and found that the standard approach is to sort
the characters in each word to give a "key", and use that to hash / lookup the
dictionary.

Which is neat, but isn't a regexp.

So I left things there until I was lying in bed just now.  And it struck me
that if regexps had &, which works much like you'd expect from |, then
anagrams would be much easier.

For example, the regexp for "poodle" would be

  ^(.*p.*&.*o.*o.*&.*d.*&.*l.*&.*e.*&.{6})$

which is way more compact than the tree of alternatives.

Before you get too carried away, however, it's worth noting that this seems to
be equivalent to lookahead.  But even so... why isn't this considered a
"natural" part of regexps?  I have no idea.

Andrew

Permalink

This Is The Future Of Religion

From: andrew cooke <andrew@...>

Date: Sun, 8 Feb 2015 12:08:52 -0300

imho.

http://blog.gaijinpot.com/japan-religious-atheist-country/

andrew

Permalink

The Shazam (Music Matching) Algorithm

From: andrew cooke <andrew@...>

Date: Fri, 6 Feb 2015 16:18:53 -0300

http://www.ee.columbia.edu/~dpwe/papers/Wang03-shazam.pdf

Andrew

Permalink

Tributes To Lesbian Community From AIDS Survivors

From: andrew cooke <andrew@...>

Date: Mon, 2 Feb 2015 19:21:28 -0300

http://www.reddit.com/r/AskReddit/comments/2ug992/serious_gay_men_who_lived_through_the_hiv/co8ebx4
http://www.reddit.com/r/AskReddit/comments/2ug992/serious_gay_men_who_lived_through_the_hiv/co8c8wh

2/3 of the top comments mention this.  I had no idea.

Andrew

Permalink