Skip to content

Instantly share code, notes, and snippets.

View tsujigiri's full-sized avatar
👋
I'm GitHubbing!

Helge Rausch tsujigiri

👋
I'm GitHubbing!
View GitHub Profile
@tsujigiri
tsujigiri / maybe.rb
Created April 19, 2015 09:01
Instant Maybe monads in Ruby
class NilClass
def method_missing(*_)
nil
end
end
@tsujigiri
tsujigiri / keybase.md
Last active August 14, 2016 14:22
keybase.md

Keybase proof

I hereby claim:

  • I am tsujigiri on github.
  • I am tsujigiri (https://keybase.io/tsujigiri) on keybase.
  • I have a public key ASDoZj7EcveL5TUa3vaetTsx6AoCApMZf1n24-gWdeBPugo

To claim this, I am signing this object:

@tsujigiri
tsujigiri / tail-f.rb
Created December 12, 2013 16:13
`tail -f` a file and process it line by line in Ruby
IO.popen("tail -F -n 0 #{path}") do |file|
while true
line = file.readline
# do stuff with line
end
end
@tsujigiri
tsujigiri / PKGBUILD
Last active December 16, 2015 18:19
PKGBUILD to install the Debian package from the Leap SDK on Arch Linux – https://www.leapmotion.com/
# Maintainer: Helge Rausch <helge@rausch.io>
# This script is licensed under the MIT license.
# https://gist.github.com/tsujigiri/5476281
#
## Installation
#
# To install the Leap software, you first need to download the SDK for Linux
# from https://developer.leapmotion.com/downloads/leap-motion/sdk using your
# developer account. Unpack it, place the included .deb files in the same
# directory as this PKGBUILD and run `makepkg`. If all goes well this will
@tsujigiri
tsujigiri / est.m
Last active December 12, 2015 05:28
Calculates German income tax
# Calculates the German income tax from the taxable income ("zu versteuerndes
# Einkommen"). Valid for 2010-2012.
function est (zvE)
if (zvE < 8005)
0
elseif (zvE < 13470)
y = (zvE - 8004) / 10000;
(912.17 * y + 1400) * y
elseif (zvE < 52882)
y = (zvE - 13469) / 10000;
@tsujigiri
tsujigiri / 29c3.rb
Created December 29, 2012 18:18
lists all so far released #29C3 recordings by modification date
#!/usr/bin/env ruby
# encoding: utf-8
require 'date'
require 'curb'
require 'nokogiri'
begin
curl = Curl::Easy.perform('http://mirror.fem-net.de/CCC/29C3/mp4-h264-HQ/')
html = Nokogiri::HTML.parse(curl.body_str)
@tsujigiri
tsujigiri / wombat256.vim
Created August 17, 2012 10:06
wombat256 vim color scheme with Conceal support added
" Vim color file
" Maintainer: David Liang (bmdavll at gmail dot com)
" Last Change: November 28 2008
"
" wombat256.vim - a modified version of Wombat by Lars Nielsen that also
" works on xterms with 88 or 256 colors. The algorithm for approximating the
" GUI colors with the xterm palette is from desert256.vim by Henry So Jr.
set background=dark
@tsujigiri
tsujigiri / quicksort.erl
Created May 17, 2012 07:51
Parallel quicksort in Erlang
-module(quicksort).
-export([quicksort/2]).
quicksort(List, SpawnFactor) when SpawnFactor > 0 ->
Self = self(),
Child = spawn(fun() -> quicksort(Self, List, SpawnFactor) end),
receive
{Child, SortedList} -> SortedList
end.
@tsujigiri
tsujigiri / benchmark.erl
Created March 2, 2012 12:30
benchmarking lists:foldl against a tail-recursive function
-module(benchmark).
-export([call_n_times/4]).
call_n_times(N, Module, Function, Args) ->
call_n_times([], N, Module, Function, Args).
call_n_times(Data, 0, _, _, _) ->
io:format("average: ~p us~n", [lists:sum(Data) / length(Data)]),
io:format("fastest: ~p us~n", [lists:min(Data)]),
io:format("slowest: ~p us~n", [lists:max(Data)]);
@tsujigiri
tsujigiri / each_line_backwards.rb
Created July 31, 2011 19:52
Read a file line by line beginning at the last one
file = File.open("some_file.txt", "r")
pos = file.size
file.pos = pos
while pos >= 0
if file.readchar == "\n"
line = file.readline
# do something with line
end
pos -= 2
file.pos = pos