Skip to content

Instantly share code, notes, and snippets.

View plukevdh's full-sized avatar
🔥

Luke van der Hoeven plukevdh

🔥
View GitHub Profile
@plukevdh
plukevdh / hash.rb
Created September 29, 2016 20:33
simple md5 hash digetsing
require 'digest'
require 'fileutils'
EXCLUDES = %w{.rb .md}
def exclude?(path)
EXCLUDES.any? {|pattern| path.end_with? pattern }
end
def md5_name(path)
@plukevdh
plukevdh / groupByKey.js
Created September 21, 2016 21:49
Ramda - Group two objects' values by keys
const groupByKey = R.compose(
R.groupBy(R.head),
R.apply(R.concat),
R.map(R.toPairs)
)
@plukevdh
plukevdh / levenshtein.erl
Created November 7, 2012 05:15
memoized levenshtein
-module(levenshtein).
-export([distance/2]).
store_result(Key, Value, Cache) ->
{Value, dict:store(Key, Value, Cache)}.
distance(String1, String2) ->
{List,_} = distance(String1, String2, dict:new()),
List.
@plukevdh
plukevdh / levenshtein.erl
Created November 7, 2012 03:13
Implementations of the levenshtein algorithm
-module(levenshtein).
-export([distance/2]).
first_letter_check(OneLetter, TwoLetter) ->
if OneLetter =:= TwoLetter -> 0
; true -> 1
end.
distance(String1, String1) -> 0;
distance(String, "") -> string:len(String);
@plukevdh
plukevdh / block_cray_spec.rb
Last active January 3, 2016 06:29
Blocks Be Cray
require 'rspec'
def meth1(order, &block)
order << 1
block.call order if block_given?
order
end
def meth2(order, &block)
order << 2
@plukevdh
plukevdh / dist-bin
Last active January 2, 2016 12:39
Klondike grunt build log
Mode LastWriteTime Length Name
---- ------------- ------ ----
----- 1/7/2014 11:34 AM 103424 Antlr3.Runtime.dll
----- 1/7/2014 11:34 AM 435712 Antlr3.Runtime.pdb
----- 1/7/2014 11:34 AM 56320 AspNet.WebApi.HtmlMicrodataFormatter.dll
----- 1/7/2014 11:34 AM 39424 Common.Logging.dll
----- 1/7/2014 11:34 AM 14336 Common.Logging.Log4Net1211.dll
----- 1/7/2014 11:34 AM 34304 Common.Logging.Log4Net1211.pdb
----- 1/7/2014 11:34 AM 14100 Common.Logging.Log4Net1211.xml
----- 1/7/2014 11:34 AM 142848 Common.Logging.pdb
@plukevdh
plukevdh / log.bash
Created December 6, 2013 22:01
Something seems odd here...
16:48:56 sidekiq.1 | 2013-12-06T21:48:56Z 26781 TID-owwutrfec RebuildCache JID-8c0f5e76547cd8f47c07d423 INFO: start
16:49:05 sidekiq.1 | [deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
16:49:54 web.1 | Thin web server (v1.6.1 codename Death Proof)
16:49:54 web.1 | Maximum connections set to 1024
16:49:54 web.1 | Listening on 0.0.0.0:9393, CTRL+C to stop
16:49:54 web.1 | 2013-12-06T21:48:56Z 26780 TID-ovwg76bik INFO: Sidekiq client with redis options {:url=>"redis://localhost:6379", :namespace=>"TrainWreck"}
17:00:00 sidekiq.1 | 2013-12-06T22:00:00Z 26781 TID-owwut0mtc INFO: [Sidetiq] Enqueue: UpdateCache (at: 1386369000.0) (last: -1.0)
@plukevdh
plukevdh / collection.coffee
Last active December 26, 2015 19:19
simple model with properties and delegation
class Collection
constructor: (items) ->
@all = if _.any(items, (item) => item instanceof @modelType)
items
else
(new @modelType(item) for item in items)
add: (item) ->
@all.push(item)
@plukevdh
plukevdh / pipes.rb
Created October 4, 2013 20:05
hax0r workflows. WARNING: DO NOT USE IN PRODUCTION OR ANYWHERE ELSE FOR THAT MATTER KTHXBYE
class Tokenize; end
class CountWords; end
class TotalSum; end
class MovingAverage; end
class Class
def |(other_class)
{self => other_class}
end
end
@plukevdh
plukevdh / branch_cache_spec.rb
Created September 3, 2013 15:24
RSpec-Given wishlist: Shared Examples
require 'spec_helper'
require 'branch_cache'
require 'changeset_cache'
shared_examples "cached data" do
Given(:cache) { described_class.new }
context "can store and retreive changeset data by branch as a set" do
Given(:changeset_data) { %w(data fake some) }
When { cache.store("Big Branch", data) }