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 'fileutils' | |
require 'open-uri' | |
class Chron | |
def initialize(symbol) | |
@symbol = symbol | |
end | |
def grab_year(year) | |
url = "http://markets.chron.com/chron/action/gethistoricaldata?Month=12&Symbol=#{@symbol}&Range=12&Year=#{year}" |
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
class ToHaml | |
def initialize(path) | |
@path = path | |
end | |
def convert! | |
Dir["#{@path}/**/*.erb"].each do |file| | |
`html2haml -rx #{file} #{file.gsub(/\.erb$/, '.haml')}` | |
end | |
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
# Git repository-specific solution | |
# Source: http://unix.stackexchange.com/questions/36233/how-to-skip-file-in-sed-if-it-contains-regex/36240#36240 | |
git grep -I --name-only -z -e '' | xargs -0 sed -i -e 's/[ \t]\+\(\r\?\)$/\1/' |
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
############################################################# | |
# Capistrano recipes | |
############################################################# | |
task :uname do | |
run "uname -a" | |
end | |
# Usage: wait_for_process_to_end('delayed_job') | |
# | |
def wait_for_process_to_end(process_name) |
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
#!/usr/bin/env ruby | |
require 'benchmark' | |
Benchmark.bm do|b| | |
b.report("+= ") do | |
a = "" | |
500_000.times { a += "." } | |
end | |
b.report("<< ") do |
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
diff --git a/load.c b/load.c | |
index b0e6f16..4c98dbb 100644 | |
--- a/load.c | |
+++ b/load.c | |
@@ -69,6 +69,17 @@ | |
return GET_VM()->loading_table; | |
} | |
+/* This searches `load_path` for a value such that | |
+ name == "#{load_path[i]}/#{feature}" |
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
# Don't subclass Struct classes | |
# instead of: | |
class Wheel < Struct.new(:rim, :tire) | |
#... | |
end | |
#use | |
Wheel2 = Struct.new(:rim, :tire) do | |
# ... |
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
GC.enable_stats if defined?(GC) && GC.respond_to?(:enable_stats) | |
GC.start # clean up heap | |
# dump it, including class names of heap objects | |
GC.dump_file_and_line_info(filename: "heap.dump", include_class_names: true) | |
stat_string = "allocated: #{GC.allocated_size/1024}K total in #{GC.num_allocations} allocations, GC calls: #{GC.collections}, GC time: #{GC.time / 1000} msec" |
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
# Download http://phantomjs.org/download.html phantomjs version | |
# extract tar file | |
tar xjvf phantomjs-1.8.1-linux-x86_64.tar.bz2 | |
# move to /opt | |
sudo mv phantomjs-1.8.1-linux-x86_64 /opt/ | |
# create simlink | |
sudo ln -s /opt/phantomjs-1.8.1-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs |
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 'rubygems' | |
require 'mechanize' | |
require 'nokogiri' | |
@linkedin_username = "username" | |
@linkedin_password = "password" | |
agent = Mechanize.new | |
agent.user_agent_alias = "Mac Safari" | |
agent.follow_meta_refresh = true |
OlderNewer