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 'formula' | |
class Dblatex < Formula | |
url 'http://downloads.sourceforge.net/project/dblatex/dblatex/dblatex-0.3/dblatex-0.3.tar.bz2' | |
homepage 'http://dblatex.sourceforge.net' | |
md5 '7de6bf72b8b2934169ce0ec911e966ed' | |
def install | |
system "python", "setup.py", "install", "--prefix=#{prefix}", "--install-scripts=#{bin}" | |
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
# from the top level of an extracted report tarball | |
$ find . -type d -depth 1 | xargs -I {} ./filename_fixer.sh {} |
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
# As seen in Ruby Weekly newsletter http://rubyweekly.com/archive/102.html | |
# http://www.alphasights.com/apply/ruby-developer-london | |
by_time = log.reduce(Hash.new{|hash,key| hash[key] = {}}) do |memo, val| | |
memo[val[:time]].merge!(val.reject{|k,v| k == :time}) | |
memo | |
end | |
by_time.map{|k,v| v.merge(time: k)} |
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
Process: Tweetbot [10718] | |
Path: /Applications/Tweetbot.app/Contents/MacOS/Tweetbot | |
Identifier: com.tapbots.TweetbotMacAdHoc | |
Version: 0.8.0 (758) | |
Code Type: X86-64 (Native) | |
Parent Process: launchd [261] | |
Date/Time: 2012-09-21 13:10:53.983 +0100 | |
OS Version: Mac OS X 10.7.5 (11G56) | |
Report Version: 9 |
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
# Ruby 1.9: | |
Hash[ [ "", "key:value" ].map { |v| v.split( /:/) } ] | |
# => {"key"=>"value"} | |
# Ruby 2.0+: | |
Hash[ [ "", "key:value" ].map { |v| v.split( /:/) } ] | |
# ArgumentError: invalid number of elements (0 for 1..2) | |
# from (pry):1:in `[]' |
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 | |
require 'qif' | |
if ARGV.size != 1 | |
$stderr.puts "usage: fix-credit-card-qif-and-load.rb <CC qif file>" | |
end | |
input_filename = ARGV[0] | |
output_filename = input_filename.sub(/\.qif/, "-fixed.qif") |
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
-- From http://geospatial.nomad-labs.com/2006/12/24/postgis-template-database/ | |
-- $ sudo su postgres | |
-- $ psql template1 | |
\c template1 | |
CREATE DATABASE template_postgis WITH template = template1; | |
-- set the 'datistemplate' record in the 'pg_database' table for | |
-- 'template_postgis' to TRUE indicating its a template | |
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis'; |
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
fizz = [nil, nil, "Fizz"].cycle | |
buzz = [nil, nil, nil, nil, "Buzz"].cycle | |
(1..100).zip(fizz, buzz) do |num, *fb| | |
puts fb.compact.reduce(:+) || num | |
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
require 'rubygems' | |
require 'sinatra' | |
require 'fileutils' | |
# upload with: | |
# curl -v -F "data=@/path/to/filename" http://localhost:4567/user/filename | |
post '/:name/:filename' do | |
userdir = File.join("files", params[:name]) |
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 | |
require 'rubygems' | |
require 'wukong' | |
# Given a file with the coordinate pair of a live cell on each line, | |
# generate the next iteration of Game of Life, using MapReduce | |
# | |
# The map phase takes each live cell, and outputs 9 key value pairs, 1 for | |
# each of the adjacent cells and itself. The reduce phase dedupes, detects |
OlderNewer