Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Sam Grönblom sgronblo

  • Reaktor Japan
  • Tokyo
View GitHub Profile
@sgronblo
sgronblo / 2017-01-captcha.hs
Last active Dec 2, 2017
Advent of Code 2017 01 Captchas in Haskell
View 2017-01-captcha.hs
#!/usr/bin/env stack
-- stack --resolver lts-9.14 script --package array
{-# LANGUAGE ScopedTypeVariables #-}
import System.Environment
import Data.Array.IArray
captchaPairs :: (IArray a e, Ix i, Num i) => a i e -> ((i, i) -> i) -> [(e, e)]
captchaPairs es getPairIndex =
@sgronblo
sgronblo / snake.elm
Created Mar 29, 2016
Snake game in Elm
View snake.elm
import Color
import Debug
import Effects exposing (..)
import Graphics.Collage exposing (..)
import Graphics.Element exposing (..)
import Html exposing (div, Html)
import Keyboard exposing (..)
import Random
import StartApp
import Text
@sgronblo
sgronblo / Roman.hs
Last active Oct 28, 2017
Roman numeral parser in Haskell using Parsec
View Roman.hs
#!/usr/bin/env stack
-- stack --resolver lts-7.9 --install-ghc script --package QuickCheck --package either --package parsec
module Roman where
import Control.Applicative hiding ((<|>))
import Data.Either.Combinators
import Text.Parsec.Prim
import Text.Parsec.Combinator
import Text.Parsec.Error
@sgronblo
sgronblo / kanji_to_number.rb
Created Jun 19, 2012 — forked from Kimtaro/kanji_to_number.rb
Convert Kanji numerical to roman numerical
View kanji_to_number.rb
# Encoding: UTF-8
module KanjiToNumber
MULTIPLIERS = {'' => 10, '' => 100, '' => 1000, '' => 10000}
NUM_FOR_NUM = {'' => 1, '' => 1, '' => 1,
'' => 2, '' => 2, '' => 2,
'' => 3, '' => 3, '' => 3,
'' => 4, '' => 4,
'' => 5, '' => 5,
'' => 6, '' => 6,
@sgronblo
sgronblo / gist:2469091
Created Apr 23, 2012
Multi column/row update with a single query for mysql
View gist:2469091
UPDATE table
SET col1 = CASE id
WHEN id1 THEN id1_v1,
WHEN id2 THEN id2_v1
END
col2 = CASE id
WHEN id1 THEN id1_v2,
WHEN id2 THEN id2_v2
END
WHERE id IN (id1, id2)
@sgronblo
sgronblo / indentation.rb
Created Feb 27, 2012
Indented puts Ruby Module, just include and go. You can also change the indentation size.
View indentation.rb
class IndentedPutser
attr_accessor :level
def initialize(size)
@level = 0
@size = size
end
def indent
self.level += 1
@sgronblo
sgronblo / rvm 1.8.6 make.log
Created Nov 15, 2011
rvm install 1.8.6 failure
View rvm 1.8.6 make.log
[2011-11-16 01:35:03] make
gcc -g -O2 -fPIC -DRUBY_EXPORT -D_GNU_SOURCE=1 -I. -I. -c array.c
gcc -g -O2 -fPIC -DRUBY_EXPORT -D_GNU_SOURCE=1 -I. -I. -c bignum.c
gcc -g -O2 -fPIC -DRUBY_EXPORT -D_GNU_SOURCE=1 -I. -I. -c class.c
gcc -g -O2 -fPIC -DRUBY_EXPORT -D_GNU_SOURCE=1 -I. -I. -c compar.c
gcc -g -O2 -fPIC -DRUBY_EXPORT -D_GNU_SOURCE=1 -I. -I. -c dir.c
gcc -g -O2 -fPIC -DRUBY_EXPORT -D_GNU_SOURCE=1 -I. -I. -c dln.c
gcc -g -O2 -fPIC -DRUBY_EXPORT -D_GNU_SOURCE=1 -I. -I. -c enum.c
gcc -g -O2 -fPIC -DRUBY_EXPORT -D_GNU_SOURCE=1 -I. -I. -c error.c
gcc -g -O2 -fPIC -DRUBY_EXPORT -D_GNU_SOURCE=1 -I. -I. -c eval.c
You can’t perform that action at this time.