This file contains hidden or 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_relative 'local_in_procs' | |
f = lambda { message } | |
a = {:message => "Hello, world!"} | |
# Test the speed when using normal proc params | |
f_control = lambda {|a| a[:message] } | |
def rand_letters(n, l) | |
r = [] |
This file contains hidden or 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
# Usage: | |
# | |
# puts green("I'm green") | |
# puts red("I'm red") | |
# puts bold("I'm bold") | |
# | |
def colour(text, code) | |
"#{code}#{text}\e[0m" | |
end |
This file contains hidden or 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
# Matches an Array (of trues and falses) to a given Array. Fills itself | |
# with preference to fill where true first, then any spare items are put | |
# in place of false, then nils are used for remaining falses. | |
# | |
# input = ["a", "b", "c"] | |
# match = [true, false, false, true] | |
# | |
# match.optimise_fill(input) | |
# #=> ["a", "b", nil, "c"] | |
# |
This file contains hidden or 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 Test | |
class String < ::String; end | |
p String.new("Test::String").class | |
#=> Test::String | |
p ::String.new("::String").class | |
#=> String | |
p "::String".class | |
#=> String -> Would be better as Test::String | |
end |
This file contains hidden or 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
# Gets the genres for tracks in a playlist called 'Genres'in iTunes | |
# and sets them using data from wikipedia. | |
# | |
# Uses the album name for the search, but won't try anything fancy | |
# if it can't find the labum it will just ignore it. | |
# | |
# ref: http://www.apeth.com/rbappscript/05propel.html | |
require 'appscript' | |
require 'nokogiri' |
This file contains hidden or 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
desc "minify js and put into one file" | |
task :minify do | |
require 'jsmin' | |
out = 'min.js' | |
glb = '*.js' | |
res = '' | |
Dir[glb].each do |path| | |
res << File.read(path) << "\n" |
NewerOlder