Skip to content

Instantly share code, notes, and snippets.

[[{"X":78,"Y":202},{"X":108,"Y":146},{"X":135,"Y":109},{"X":139,"Y":101},{"X":133,"Y":95},{"X":128,"Y":85},{"X":125,"Y":75},{"X":126,"Y":57},{"X":134,"Y":53},{"X":147,"Y":50},{"X":177,"Y":49},{"X":185,"Y":50},{"X":194,"Y":56},{"X":201,"Y":63},{"X":207,"Y":73},{"X":211,"Y":90},{"X":211,"Y":114},{"X":206,"Y":127},{"X":200,"Y":138},{"X":194,"Y":142},{"X":188,"Y":143},{"X":185,"Y":142},{"X":179,"Y":136},{"X":167,"Y":130},{"X":162,"Y":133},{"X":127,"Y":166},{"X":126,"Y":169},{"X":124,"Y":170},{"X":123,"Y":175},{"X":110,"Y":192},{"X":107,"Y":201},{"X":104,"Y":204}],[{"X":76,"Y":204},{"X":69,"Y":197},{"X":55,"Y":198},{"X":45,"Y":203},{"X":34,"Y":216},{"X":29,"Y":228},{"X":30,"Y":239},{"X":37,"Y":248},{"X":42,"Y":251},{"X":46,"Y":253},{"X":59,"Y":253},{"X":62,"Y":251},{"X":69,"Y":239},{"X":71,"Y":233},{"X":71,"Y":220},{"X":74,"Y":200}],[{"X":81,"Y":205},{"X":119,"Y":206},{"X":134,"Y":209},{"X":137,"Y":211},{"X":140,"Y":214},{"X":142,"Y":228},{"X":143,"Y":256},{"X":140,"Y":270},{"X":136,"Y":278},{"X":127,"Y":286},{"X"
@harukizaemon
harukizaemon / KataBankOCR.hs
Created December 30, 2011 01:38
Parse an OCR'd bank account number
chunk _ [] = []
chunk n xs
| n < 1 = []
| otherwise = first:chunk n remainder
where (first, remainder) = splitAt n xs
parseAccountNumber line1 line2 line3 = map match (chunk 3 columns)
where columns = zip3 line1 line2 line3
match xs = case xs of [(' ', '|', '|'), ('_', ' ', '_'), (' ', '|', '|')] -> '0'
[(' ', ' ', ' '), (' ', ' ', ' '), (' ', '|', '|')] -> '1'
@harukizaemon
harukizaemon / chunk.hs
Created December 29, 2011 13:28
Take n elements of a list at a time
chunk _ [] = []
chunk n xs
| n < 1 = []
| otherwise = first:chunk n remainder
where (first, remainder) = splitAt n xs
-- ghci> chunk 3 [1,2,3,4,5,6,7,8,9,0]
-- [[1,2,3],[4,5,6],[7,8,9],[0]
@harukizaemon
harukizaemon / gist:1285939
Created October 14, 2011 00:42
A reminder to myself 30 years hence
Hi Simon,
If you're reading this then you've made it to being a grandparent. Congratulations! It's a wonderfully
rewarding experience, and you should treasure every moment.
As you have probably realised, parenting nowdays isn't the same as when you had kids. At least
that's what it seems like, right? Well, I wanted to just remind you about a few things from when
you had your kids. Yes, your kids were (and still are) amazing, however:
* Parenting was actually stupidly hard and took everything you had, every day
@harukizaemon
harukizaemon / psych_is_borked.rb
Created May 20, 2011 20:18
Demonstrate that psych/libyaml is borked
require 'rubygems'
# Switch the following two lines to see the bug in the psych that ships with Ruby
# Comment out both to see the default YAML parsing behaviour
gem 'psych'
# require 'psych'
require 'yaml'
require 'erb'
@harukizaemon
harukizaemon / gist:974320
Created May 16, 2011 11:56
UNIX search PATH and other environment variables
The way Carbon or Cocoa applications are launched in Aqua is different from the way in other UNIX windows environments. There they inherit their environment variables from the login shell. In Mac OS X it is different, and so Carbon Emacs and other applications do not run in the same process environment as a programme launched in Terminal. Since the times of NeXTStep and the NeXT a mechanism exists that can correct this difference: in Mac OS X it is the file ~/.MacOSX/environment.plist.
In a freshly installed Mac OS X system neither the (invisible) ~/.MacOSX directory nor the file environment.plist in it exist. Its – their! – creation is simple:
defaults write ${HOME}/.MacOSX/environment PATH "${HOME}/bin:/usr/bin:/bin:/usr/local/bin:${TeXbin}"
${TeXbin} is here a proxy that stands for the bin directory of your TeX installation, if you have one. Instead of it, or in addition to it, you can provide the path to your Fink or MacPorts binaries or to X11 installed, /usr/X11R6/bin. The same mechanism can be used
@harukizaemon
harukizaemon / gist:958778
Created May 6, 2011 11:23
THE SENSITIVITY OF SENIORS …
This letter was sent to the Lions Bay School Principal's Office in
West Geelong after the school had sponsored a luncheon for seniors.
An elderly lady received a new radio at the lunch as a door raffle prize
and was writing to say thank you. This story is a credit to all humankind.
I am forwarding to someone who might need a lift today!
Dear Lions Bay School,
def retry
@tpl = Template.find(params[:template_id])
check_permission
begin
if params[:image_id]
image = Image.find(params[:image_id])
if image
errors = {}
warnings = []
image.rebuild!
@harukizaemon
harukizaemon / gist:954741
Created May 4, 2011 04:07
Fix Psych/libyaml parsing
# lib/ruby/1.9.1/psych.rb, line 1
raise LoadError