Skip to content

Instantly share code, notes, and snippets.

View scoiatael's full-sized avatar

Lukasz Czaplinski scoiatael

View GitHub Profile
@scoiatael
scoiatael / gist:9132219
Created February 21, 2014 10:40
Michaels github.js test
test
@scoiatael
scoiatael / 03lngvuhpgjsjor
Last active August 29, 2015 13:56
Michaels github.js test
OK
@scoiatael
scoiatael / ERB+YAML
Created June 29, 2015 14:11
ERB interpolation in YAML files made easy
require 'erb'
require 'yaml'
require 'ostruct'
class TemplateRenderer < OpenStruct
def initialize(filename, method_name: 'render')
super()
@template = File.read(filename)
@erb = ERB.new(@template)
@method_name = method_name
var fetchData = function() {
var goFetch = function(users) {
return http().then(function(data) {
users.push(data.user);
if(data.more) {
return goFetch(users);
} else {
return users;
}
});

Keybase proof

I hereby claim:

  • I am scoiatael on github.
  • I am scoiatael (https://keybase.io/scoiatael) on keybase.
  • I have a public key ASARfefczxYNM3vx-lXBMFb8uTILj57Ry2tPiiBbLqI1tQo

To claim this, I am signing this object:

@scoiatael
scoiatael / Day1.fsx
Last active December 3, 2017 16:09
2017 Advent of Code solutions in F# (because why not?)
let index (word: 'a[], ind: int) = ind % word.Length
let sumOfDoubles forwardJump (word: int[]) =
[0..word.Length-1]
|> List.map (fun ind -> if word.[ind] = word.[index(word, ind+forwardJump)] then word.[ind] else 0)
|> List.reduce (+)
let parse(word: string) = word.ToCharArray() |> Array.map (fun ch -> (int ch) - (int '0'))
let solve1(word: string) = parse word |> (sumOfDoubles 1)
let solve2(word: string) = parse word |> fun arr -> sumOfDoubles (arr.Length / 2) arr
module Dancers
type Circle = char array
type Move = Circle -> Circle
let startingPattern : Circle = Array.ofList ['a'..'p']
let spin (n : int) : Move =
fun circle ->
let len = Array.length circle in
module Dancers
type Circle = char array
type Move = Circle -> Circle
let startingPattern : Circle = Array.ofList ['a'..'p']
let spin (n : int) : Move =
fun circle ->
let len = Array.length circle in
type Circle = char array
let startingPattern : Circle = Array.ofList ['a'..'p']