View gist:9916f225a60cdb4dcbc8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loop { print ">> " ; puts("=> %s" % eval(gets.chomp!)) } |
View fizzbuzz.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule FizzBuzz do | |
def compute do | |
receive do | |
n -> IO.puts compute(n) | |
end | |
compute | |
end | |
defp compute(n) do | |
case {rem(n, 3), rem(n, 5)} do |
View gist:7316f3e11004eabbd269
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# A colorful, friendly, multiline theme with some handy features. | |
# Based on the 'giddie' theme by Paul Gideon Dann. | |
# | |
# Authors: | |
# Michael Kohl <citizen428@gmail.com> | |
# Paul Gideon Dann <pd@gmail.com> | |
# Sorin Ionescu <sorin.ionescu@gmail.com> | |
# | |
# Features: |
View safaritweet.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby -W0 | |
=begin | |
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! | |
=end |
View Rubinius build problem stackfull branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OS X 10.5.6, GCC 4.0.1 (Apple Inc. build 5490) | |
[snip] | |
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...] | |
View lyrics.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rbosa' | |
song = OSA.app('iTunes').current_track.name.gsub(/\(.*\)/, '').gsub(/\s/,'%20') | |
system("open -a Safari http://www.google.com/search?q=#{song}+lyrics") |
View rps.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sinatra' | |
get '/' do | |
erb :index | |
end | |
post '/' do | |
erb :index | |
end |
View filter.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
self.select { |el| el.send(operand, value) } | |
end | |
end |
View TextMate command for posting to the RubyLearning forums
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
src = STDIN.read.gsub('<', '<').gsub('"', '\"') | |
`echo "[code ruby]\n#{src}\n[/code]\n" | pbcopy ` |
View gist:117571
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
results = Hash.new(0) | |
`awk '{print $1}' ~/.bash_history`.split.each { |c| results[c] += 1 } | |
results.sort_by { |e| -e[1] }.each { |k, v| puts "#{k}: #{v}" } |
OlderNewer