Skip to content

Instantly share code, notes, and snippets.

@jsl
jsl / gist:6870230
Created October 7, 2013 15:54
Project Euler Problem 11 Grid
board = [[08, 02, 22, 97, 38, 15, 00, 40, 00, 75, 04, 05, 07, 78, 52, 12, 50, 77, 91, 08],
[49, 49, 99, 40, 17, 81, 18, 57, 60, 87, 17, 40, 98, 43, 69, 48, 04, 56, 62, 00],
[81, 49, 31, 73, 55, 79, 14, 29, 93, 71, 40, 67, 53, 88, 30, 03, 49, 13, 36, 65],
[52, 70, 95, 23, 04, 60, 11, 42, 69, 24, 68, 56, 01, 32, 56, 71, 37, 02, 36, 91],
[22, 31, 16, 71, 51, 67, 63, 89, 41, 92, 36, 54, 22, 40, 40, 28, 66, 33, 13, 80],
[24, 47, 32, 60, 99, 03, 45, 02, 44, 75, 33, 53, 78, 36, 84, 20, 35, 17, 12, 50],
[32, 98, 81, 28, 64, 23, 67, 10, 26, 38, 40, 67, 59, 54, 70, 66, 18, 38, 64, 70],
[67, 26, 20, 68, 02, 62, 12, 20, 95, 63, 94, 39, 63, 08, 40, 91, 66, 49, 94, 21],
[24, 55, 58, 05, 66, 73, 99, 26, 97, 17, 78, 78, 96, 83, 14, 88, 34, 89, 63, 72],
[21, 36, 23, 09, 75, 00, 76, 44, 20, 45, 35, 14, 00, 61, 33, 97, 34, 31, 33, 95],
var update = F2(function (i,state)
{
return function ()
{
switch (i.ctor)
{case
"Click" :
switch (i._0.ctor)
{case
"_Tuple2" :
@jsl
jsl / gist:6629210
Created September 19, 2013 20:15
FizzBuzz Haskell Version
toFizzBuzz :: Integer -> String
toFizzBuzz n
| n `mod` 3 == 0 = "Fizz"
| n `mod` 5 == 0 = "Buzz"
| otherwise = show n
fizzBuzzSeries :: [String]
fizzBuzzSeries = map toFizzBuzz [1..]
{
"auto_complete_commit_on_tab": true,
"color_scheme": "Packages/Color Scheme - Default/Pastels on Dark.tmTheme",
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"font_size": 17.0,
"hot_exit": false,
"ignored_packages":
[
"Vintage"
@jsl
jsl / gist:6323978
Created August 23, 2013 21:01
Tests for a simple logo interpreter in Ruby
# clearscreen
# forward INTEGER
# TO funcname
# do something
# END
# rt INTEGER ; right turn
# lt INTEGER ; left turn
{
"auto_complete_commit_on_tab": true,
"color_scheme": "Packages/Color Scheme - Default/Pastels on Dark.tmTheme",
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"font_size": 17.0,
"hot_exit": false,
"ignored_packages":
[
"Vintage"
@jsl
jsl / gist:6186375
Last active December 20, 2015 19:49
Rails date subtraction different on Mac OS and Linux
# Using ruby-2.0.0-p247, Rails console
# On Mac:
2.0.0p247 :006 > Date.today - Date.yesterday
=> 1
2.0.0p247 :007 > (Date.today - Date.yesterday).class
=> Fixnum
# On Ubuntu 12.04
2.0.0p247 :009 > Date.today - Date.yesterday
{
"auto_complete_commit_on_tab": true,
"color_scheme": "Packages/Color Scheme - Default/Blackboard.tmTheme",
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"font_size": 23.0,
"hot_exit": false,
"remember_open_files": false,
"rulers":
[
@jsl
jsl / gist:6123252
Created July 31, 2013 15:52
Zerigo DDNS update script in Haskell
import Text.XML.Light
import Network.Curl
import System.IO
import System.Environment
import System.Exit
extractIP :: String -> String
extractIP xmlString =
let
element = parseXMLDoc xmlString >>= findElement (QName "ipv4" Nothing Nothing)
@jsl
jsl / gist:5166174
Created March 14, 2013 23:24
Debugging with jruby

JRuby debugging with 'step' and 'next'

If you run without the --debug flag, jruby steps into functions rather than skipping them. Perhaps that is related to this warning when starting with -rdebug and omitting the --debug flag:

warning: tracing (e.g. set_trace_func) will not capture all events without --debug flag

Running 'next' does seem to work properly when I run the jruby debugger as follows: