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
# './gc_test.rb' | |
@m = 1000000 | |
@b = 2 * 5 * (4**3) + 1 | |
@a = 100001 | |
def make_fragmentation(h, seed) | |
i = seed | |
10000.times {|m| h << Object.new} | |
10000.times do |m| |
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
# In a rails app | |
pry(main)>.ls | |
Capfile Gemfile.lock Rakefile config db lib public test vendor | |
Gemfile README.md app config.ru doc log script tmp |
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
# ~/.irbrc | |
def clear | |
system 'clear' | |
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
command "caller_method" do |depth| | |
depth = depth.to_i || 1 | |
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ caller(depth+1).first | |
file = Regexp.last_match[1] | |
line = Regexp.last_match[2].to_i | |
method = Regexp.last_match[3] | |
output.puts [file, line, method] | |
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
<a href="https://twitter.com/share" class="twitter-share-button" | |
data-count="vertical" | |
data-via="rondale_sc">Tweet</a> | |
<script type="text/javascript" src="//platform.twitter.com/widgets.js"></script> |
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
$ gem install logging | |
# Successfully installed logging-1.6.1 | |
# 1 gem installed | |
# Building YARD (yri) index for logging-1.6.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
# ./test_single_or_double.rb | |
require './stats.rb' | |
test_strings = {:double => 'ruby -e "start_time = Time.now; 100_000.times { \"a\" }; puts Time.now - start_time"', | |
:single => "ruby -e \"start_time = Time.now; 100_000.times { 'a' }; puts Time.now - start_time\""} | |
sr = 1000.times.inject([]) {|memo, result| memo << `#{test_strings[:single]}`.strip } | |
dr = 1000.times.inject([]) {|memo, result| memo << `#{test_strings[:double]}`.strip } |
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
# for zsh | |
# echo 'alias man="gem man -s"' >> ~/.zshrc | |
# source ~/.zshrc | |
echo 'alias man="gem man -s"' >> ~/.bashrc | |
source ~/.bashrc | |
man gem-man |
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
#config/initializers/omniauth.rb | |
provider :LDAP, | |
:host => '0.0.0.0', | |
:port => 389, | |
:method => :plain, | |
:base => 'dc=example,dc=com', | |
:uid => 'samaccountname', | |
:bind_dn => 'Authorized User', | |
:password => 'Password', | |
:name_proc => Proc.new {|name| name.gsub(/@.*$/,'') } |
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
# If cell is alive then it continues to stay alive if it has | |
# 2 or 3 alive neighbors. If the cell is dead then it comes | |
# back to life only if it has exactly 3 alive neighbors. | |
@alive ? [2,3].include?(alive_neighbors) : alive_neighbors == 3 |