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
irb(main):001:0> class Foo | |
irb(main):002:1> def initialize(a, b = a.to_s) | |
irb(main):003:2> puts [a, b].inspect | |
irb(main):004:2> end | |
irb(main):005:1> end | |
=> nil | |
irb(main):006:0> Foo.new 1 | |
[1, "1"] | |
=> #<Foo:0x007f973d9ca410> |
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
gpr() { | |
current_branch=`git rev-parse --abbrev-ref HEAD` | |
if [[ $1 != '' ]]; then | |
upstream=$1 | |
else | |
upstream='master' | |
fi | |
origin_username=`git remote -v | grep 'origin.\+fetch' | sed "s/^.*github.com[\/:]\(.*\)\/\(.*\)\.git.*$/\1/"` | |
origin_repository=`git remote -v | grep 'origin.\+fetch' | sed "s/^.*github.com[\/:]\(.*\)\/\(.*\)\.git.*$/\2/"` | |
if [[ `git remote | grep sikachu` != '' ]]; then |
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
Benchmark.bmbm do |x| | |
x.report('start_with?') { 10_000.times { "fooo".start_with?('foo') }} | |
x.report('regexp') { 10_000.times { "fooo" =~ /^foo/ }} | |
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 User | |
has_many :topics | |
has_many :posts, through: topics | |
end | |
class Topic | |
belongs_to :user | |
has_many :posts | |
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
window.it = (desc, func) -> | |
if func? | |
jasmine.getEnv().it(desc, func) | |
else | |
jasmine.getEnv().it desc, -> | |
throw "test is undefined" |
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 'open-uri' | |
size_hash = {"720p" => "6540", "720i" => "4540", "540p" => "2540", "540i" => "1840", "360p" => "1240", "360i" => "0640", "360is" => "0440", "224p" => "0240"} | |
if ["--help", "help", "-h"].include?(ARGV[0]) || ARGV.size < 1 | |
puts "Usage: #{File.basename __FILE__} ( #{size_hash.keys.join(' | ')} )" | |
exit 0 | |
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
http://radio1.serverradio.net:8012/ |
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 'nokogiri' | |
lines = File.open("Safari Bookmarks.html").readlines | |
urls = [] | |
output = [] | |
lines.each do |line| | |
if line =~ %r(<DT><A HREF="(.+)">.+</A>$) |
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
tar xzfO {package}.gem metadata.gz | gzcat | grep -q '\- =' && echo "Invalid" |
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 'benchmark' | |
class A0 | |
def foo | |
true | |
end | |
end | |
(1..1000).each do |n| | |
eval <<-RUBY |