Instantly share code, notes, and snippets.

Michael Shapiro koudelka

View GitHub Profile
koudelka / type_bully.exs
Created Mar 12, 2016
TypeBully is an (incomplete) toy module to force Elixir functions to respect their typespecs.
View type_bully.exs
# TypeBully forces functions to respect their typespecs by rewriting the function clauses to include proper guards.
# For example, the Wimp module below: cry/3 has typespecs, but no enforcing guards, normally, calling cry/3 would
# always match the first function clause, but TypeBully forces it to select the correct one based on its typespec.
# Without TypeBully:
# iex(1)> Wimp.cry("whaa")
koudelka / lookup.ex
Created Oct 2, 2015
Elixir Set Lookup
View lookup.ex
defmodule Lookup do
@wordfile "words.txt"
@external_resource @wordfile
@times 1_000_000
@words @wordfile |>! |>
@hash_set Enum.into(@words,
@map_set Enum.into(@words,
koudelka / silent_shell.ex
Created Jul 2, 2014
a silent Mix.Shell.Process
View silent_shell.ex
defmodule Mix.Shell.Process.Quiet do
@moduledoc """
This is a Mix shell, identical to Mix.Shell.Process, except that console output is silenced.
@behaviour Mix.Shell
defdelegate [flush(callback), cmd(command), prompt(message), yes?(message)], to: Mix.Shell.Process
def print_app, do: nil
koudelka / gist:f4d07b9d998d723e55a0
Created Jun 6, 2014
Possible http status codes module for Elixir Phoenix Web Framework
View gist:f4d07b9d998d723e55a0
# Would this be useful to Phoenix?
# In controllers, it'd be nice to be able to refer to status codes as atoms instead of integers.
defmodule Phoenix.Controller.StatusCodes do
@http_status_codes %{
koudelka / compare_sysctl.rb
Last active Aug 29, 2015
Quick n' dirty utility to compare sysctls between two machines.
View compare_sysctl.rb
#!/usr/bin/env ruby
# This utility compares `sysctl -a` on two given boxes
puts "Usage: #{$PROGRAM_NAME} hostname other_hostname" and exit unless ARGV.length == 2
koudelka / gist:383bb1362432ed320c9b
Created May 21, 2014
Compare two files on remote hosts.
View gist:383bb1362432ed320c9b
rdiff() { diff -u <(ssh $1 "cat $3") <(ssh $2 "cat $3") }
koudelka / compare_dpkg.rb
Created May 21, 2014
Quick n' dirty utility to compare the state of packages on two ubuntu/debian machines.
View compare_dpkg.rb
#!/usr/bin/env ruby
# This utility compares the state of `dpkg -l` on two given boxes
puts "Usage: #{$PROGRAM_NAME} hostname other_hostname" and exit unless ARGV.length == 2

Keybase proof

I hereby claim:

  • I am koudelka on github.
  • I am koudelka ( on keybase.
  • I have a public key whose fingerprint is 7E62 AE05 4D2C 2331 76DF F5AC 81D1 A93F 604E 49B3

To claim this, I am signing this object:

koudelka / gist:5529764
Created May 7, 2013
Why doesn't my FANN work? :(
View gist:5529764
require 'ruby-fann'
input_data = (0..20000).collect do |i|
[i * 0.0001]
output_data = input_data.collect do |i|
koudelka / gist:4322700
Created Dec 17, 2012
Deletes all Facebook friend requests, execute on
View gist:4322700
var x = document.evaluate('//input[@value="Delete Request"]', document.documentElement, null, XPathResult.ANY_TYPE, null);
// gotta build an array of the elements, iterators throw exceptions if you modify the DOM from under them
var elements = [];
var thisNode = x.iterateNext();
while (thisNode) {
thisNode = x.iterateNext();