Skip to content

Instantly share code, notes, and snippets.

View rondale-sc's full-sized avatar

Jonathan rondale-sc

  • Providence, Rhode Island
View GitHub Profile
@rondale-sc
rondale-sc / gist-1.rb
Created March 22, 2012 05:11
playin-with-the-ruby-gc
# './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|
@rondale-sc
rondale-sc / gist-1.sh
Created March 22, 2012 05:21
give-it-a-pry
# 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
@rondale-sc
rondale-sc / gist-1.rb
Created March 22, 2012 05:27
make-it-your-own
# ~/.irbrc
def clear
system 'clear'
end
@rondale-sc
rondale-sc / gist-1.rb
Created March 22, 2012 05:31
caller-method
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
@rondale-sc
rondale-sc / gist-1.html
Created March 22, 2012 05:34
make-the-most-of-your-tweet
<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>
@rondale-sc
rondale-sc / gist-1.sh
Created March 22, 2012 05:42
an-introduction-to-loggin
$ gem install logging
# Successfully installed logging-1.6.1
# 1 gem installed
# Building YARD (yri) index for logging-1.6.1...
@rondale-sc
rondale-sc / gist-1.rb
Created March 22, 2012 05:46
string-theory
# ./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 }
@rondale-sc
rondale-sc / gist-1.sh
Created March 22, 2012 05:50
man-and-ruby
# for zsh
# echo 'alias man="gem man -s"' >> ~/.zshrc
# source ~/.zshrc
echo 'alias man="gem man -s"' >> ~/.bashrc
source ~/.bashrc
man gem-man
@rondale-sc
rondale-sc / gist-1.rb
Created March 22, 2012 05:57
omniauth-and-other-drugs
#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(/@.*$/,'') }
@rondale-sc
rondale-sc / gist-1.rb
Created March 22, 2012 06:01
life-in-a-shade-of-ruby
# 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