Skip to content

Instantly share code, notes, and snippets.

View remigijusj's full-sized avatar

Remigijus Jodelis remigijusj

View GitHub Profile
@remigijusj
remigijusj / gist:af81ab6fccbcd33e94b9
Created June 1, 2015 08:53
KonservativeDK daina apie Lietuva
STOP den lille kænguru
Tre fra Litauen på indbrud
Gemte sig bag ved en hæk
Tævede gamle fru Jensen
Tog pengene med og var væk!
Men så råbte vi:
Stop de østkriminelle
Før de røver igen
@remigijusj
remigijusj / nested_benchmark.rb
Last active August 29, 2015 14:23
comparison of deep data structures
require 'benchmark'
require 'date'
# from lib/core_ext/hash.rb
class Hash
def at(*path)
path.inject(self) do |ob, key|
ob.respond_to?(:each) ? ob[key] : nil
end
end
class Hash
def using(&block)
values = block.parameters.map do |(type, name)|
self[name]
end
block.call(*values)
end
end
@remigijusj
remigijusj / .gitconfig
Created April 18, 2016 08:23
My GIT aliases
[alias]
s = !git status
k = !gitk
br = !git branch
co = "!f() { git checkout `git locax $1`; }; f"
ff = !git reset --hard origin/`git this`
ffm = !git push . origin/master:master
new = !git checkout -b
brd = "!f() { git branch -D `git loca $1`; }; f"
grab = !git fetch origin -p
@remigijusj
remigijusj / where_is.rb
Created November 24, 2016 13:54 — forked from wtaysom/where_is.rb
A little Ruby module for finding the source location where class and methods are defined.
module Where
class <<self
attr_accessor :editor
def is_proc(proc)
source_location(proc)
end
def is_method(klass, method_name)
source_location(klass.method(method_name))
@remigijusj
remigijusj / monoids_of_size_three.rb
Created July 21, 2020 17:10
Counting all monoids with three elements
class Table
# 1 is an identity, so we know it's composition with other elements.
ELTS = [1, :a, :b].freeze
BASIC = {'11' => 1, '1a' => :a, '1b' => :b, 'a1' => :a, 'b1' => :b}.freeze
# Iterate through all possible composition tables.
def self.each
return to_enum unless block_given?
ELTS.product(ELTS, ELTS, ELTS) { |list| yield new(*list) }