Skip to content

Instantly share code, notes, and snippets.

View markmeeus's full-sized avatar

Mark Meeus markmeeus

View GitHub Profile
@markmeeus
markmeeus / smallson.js
Last active May 17, 2017 11:58
smallson
//Schema bevat array met prop names
//eerste waarde van de value array is de naam van het schema
{
schemas:{
"a": ["name", "firstname", "address"],
"b": ["code", "description"]
},
values:[
["a", "Doe", "John", "meir 150"],
["b", "23321T5", "Te laat opgestaan"]
@markmeeus
markmeeus / binary_tree_maze.ex
Created April 17, 2017 18:54
Super naive maze generator
defmodule Maze do
def get_maze maze_size do
maze =
for y <- (maze_size..1),
do: build_row(y, maze_size)
end
defp build_row(y, maze_size), do: Enum.into(%{}, build_row_tuples(y, maze_size))
defp build_row_tuples(y, maze_size)do
@markmeeus
markmeeus / gist:8052351
Created December 20, 2013 09:19
Ever wish there was a symol.to_proc style way to call methods with parameters?
class Array
class ArrayProcWrapper
attr_accessor :ary
def to_proc
lambda { |obj| obj.send self.ary.first, *self.ary[1..-1]}
end
end
def to_proc_wrapper
@markmeeus
markmeeus / gist:6412088
Last active August 31, 2017 12:28
A patch to reuse Moped connections in Mongoid inside Celluliod Actors. If you use Sidekiq with loads of work, you may want reuse your connections. Do not use this toghether with kiqstand as they try to achieve opposite results.
module Celluloid
class Thread < ::Thread
def []= key, value
if key_on_thread? key
thread_vars[key] = value
else
super
end
end