Skip to content

Instantly share code, notes, and snippets.

View citizen428's full-sized avatar

Michael Kohl citizen428

View GitHub Profile
loop { print ">> " ; puts("=> %s" % eval(gets.chomp!)) }
citizen428 / fizzbuzz.ex
Last active August 29, 2015 14:10
Elixir FizzBuzz server
defmodule FizzBuzz do
def compute do
receive do
n -> IO.puts compute(n)
defp compute(n) do
case {rem(n, 3), rem(n, 5)} do
# A colorful, friendly, multiline theme with some handy features.
# Based on the 'giddie' theme by Paul Gideon Dann.
# Authors:
# Michael Kohl <>
# Paul Gideon Dann <>
# Sorin Ionescu <>
# Features:
citizen428 / safaritweet.rb
Created February 27, 2009 16:35
Tweet the currently active Safari tab
#!/usr/bin/ruby -W0
Quick and dirty way to tweet the currently active
Safari tab (title + shortened URL). Hashtags get
passed in as parameters (the hash sign gets added
by the script, so don't do it yourself)
Adapt to your needs!
OS X 10.5.6, GCC 4.0.1 (Apple Inc. build 5490)
vm/test/cxxtest/cxxtest/TestSuite.h: In function 'bool CxxTest::equals(X, Y) [with X = rubinius::Object*, Y = rubinius::MethodContext*]':
vm/test/cxxtest/cxxtest/TestSuite.h:56: instantiated from 'void CxxTest::doAssertEquals(const char*, unsigned int, const char*, X, const char*, Y, const char*) [with X = rubinius::Object*, Y = rubinius::MethodContext*]'
./vm/test/test_instructions.hpp:368: instantiated from here
vm/test/cxxtest/cxxtest/TestSuite.h:47: error: comparison between distinct pointer types 'rubinius::Object*' and 'rubinius::MethodContext*' lacks a cast
rake aborted!
Command failed with status (1): [gcc -Ivm/external_libs/libtommath -Ivm/ext...]
citizen428 / lyrics.rb
Created March 18, 2009 20:56
Googles for the lyrics of the currently playing song in a new Safari window
require 'rbosa'
song ='iTunes')\(.*\)/, '').gsub(/\s/,'%20')
system("open -a Safari{song}+lyrics")
citizen428 / rps.rb
Created March 27, 2009 17:00
Rock-paper-scissors Sinatra app
require 'rubygems'
require 'sinatra'
get '/' do
erb :index
post '/' do
erb :index
module Enumerable
# operand can be a String or a Symbol
def filter(operand, value)
raise(ArgumentError, "Invalid operator") unless %w(> < >= <= ==).include?(operand.to_s)
return self if self.class == String { |el| el.send(operand, value) }
#!/usr/bin/env ruby
src ='<', '&lt;').gsub('"', '\"')
`echo "[code ruby]\n#{src}\n[/code]\n" | pbcopy `
results =
`awk '{print $1}' ~/.bash_history`.split.each { |c| results[c] += 1 }
results.sort_by { |e| -e[1] }.each { |k, v| puts "#{k}: #{v}" }