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 FloatRange | |
def each | |
if Float === self.begin | |
current = self.begin | |
if exclude_end? | |
while current < self.end | |
yield current | |
current = current.next_float | |
end | |
else |
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
# vim: ts=2 sw=2 et ft=ruby | |
# Call with two strings of ones on the tape: | |
# $ turing.rb ones_difference.stm 1111 11 | |
1. right goto: 2 | |
2. cond if: '1', then: 1, else: 3 | |
3. right goto: 4 | |
4. cond if: '1', then: 5, else: 17 | |
5. right goto: 6 | |
6. cond if: '1', then: 5, else: 7 |
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
# vim: ts=2 sw=2 et ft=ruby | |
# Call with two strings of ones on the tape: | |
# $ turing.rb ones_difference.stm 1111 11 | |
1. right :goto => 2 | |
2. cond :if => '1', :then => 1, :else => 3 | |
3. right :goto => 4 | |
4. cond :if => '1', :then => 5, :else => 17 | |
5. right :goto => 6 | |
6. cond :if => '1', :then => 5, :else => 7 |
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 'permutation' # gem install permutation | |
>> Permutation.for((1..4).to_a.reverse).map(&:project).map(&:reverse) | |
# => [[1, 2, 3, 4], [2, 1, 3, 4], [1, 3, 2, 4], [3, 1, 2, 4], [2, 3, 1, 4], [3, 2, 1, 4], [1, 2, 4, 3], [2, 1, 4, 3], [1, 4, 2, 3], [4, 1, 2, 3], [2, 4, 1, 3], [4, 2, 1, 3], [1, 3, 4, 2], [3, 1, 4, 2], [1, 4, 3, 2], [4, 1, 3, 2], [3, 4, 1, 2], [4, 3, 1, 2], [2, 3, 4, 1], [3, 2, 4, 1], [2, 4, 3, 1], [4, 2, 3, 1], [3, 4, 2, 1], [4, 3, 2, 1]] |
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 'benchmark' | |
require 'json' | |
A = (0..1_000).map { rand } | |
org_array = [] | |
json_array = [] | |
0.upto(20000) do |i| |
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
Y = -> f { -> g { g[g] }[ -> h { -> *x { f[h[h]][*x] } } ] } | |
Y[ -> f { -> n { n < 1 ? 1 : n * f[n-1] } } ][23] |
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
def list_migrations | |
Dir['db/migrate/[0-9]*.rb'].sort_by { |f| File.basename(f).to_i } | |
end | |
namespace :db do | |
namespace :migrate do | |
namespace :list do | |
desc 'List all paths to migration files starting with the last one' | |
task :paths do | |
puts list_migrations |
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
def foo | |
some_function_computing_integer_value | |
+ some_other_function_computing_integer_value | |
+ the_last_function_computing_integer_value | |
end |
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
class ::JSON::GenericObject | |
def self.load(source, proc = nil, opts = {}) | |
result = ::JSON.load(source, proc, opts.merge(:object_class => ::JSON::GenericObject)) | |
result.nil? ? ::JSON::GenericObject[] : result | |
end | |
def self.dump(obj, *args) | |
::JSON.dump(obj, *args) | |
end | |
end |
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
diff --git a/Library/Formula/vim.rb b/Library/Formula/vim.rb | |
index d3f5ff2..ccc8cdc 100644 | |
--- a/Library/Formula/vim.rb | |
+++ b/Library/Formula/vim.rb | |
@@ -5,6 +5,7 @@ class Vim < Formula | |
# This package tracks debian-unstable: http://packages.debian.org/unstable/vim | |
url 'http://ftp.de.debian.org/debian/pool/main/v/vim/vim_7.3.923.orig.tar.gz' | |
sha1 'f308d219dd9c6b56e84109ace4e7487a101088f5' | |
+ depends_on 'gtk+' | |
head 'https://vim.googlecode.com/hg/' |
OlderNewer