- Ruby Language site
- Try Ruby
- RubyGems – Gems are Ruby’s packages
- Bundler – Application dependency management
- RubyInstaller – Easy installation on Windows.
- You will want to check the box to add Ruby to your PATH
- You may also want to install the Development Kit so you can compile C extensions
- Rubular – Online Ruby regular expression tester
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
set background=dark | |
set guifont=Menlo\ for\ Powerline:h14 | |
colorscheme solarized | |
set guioptions=egmt | |
let &colorcolumn=join(range(80,999),",") |
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
GOOD_VERSIONS = %w[1.8.7p375 1.9.2p321 1.9.3p484 2.0.0p353] | |
apps = `heroku apps`.split("\n") | |
apps.each do |app| | |
next if app.include? "My Apps" | |
app = app.split(" ")[0] | |
output = `heroku run "ruby -v" -a #{app} 2>&1` | |
match = output.match(/ruby ([\d.p]+)/) | |
version = match ? match[1] : "unknown" | |
puts "#{app}\t#{version}\t#{GOOD_VERSIONS.include?(version) ? "OK" : "UPGRADE"}" | |
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
namespace :bundle do | |
def intersection | |
return @outdated if @outdated | |
@outdated = `bundle outdated` | |
@outdated = @outdated.split("\n").select{|line| line.include?("*")} | |
@outdated = @outdated.map{|gem| gem.match(/\* ([a-zA-Z0-9_-]+) /)[1]} | |
app_gems = File.readlines("Gemfile").select{|line| line.include?("gem ")} | |
app_gems = app_gems.map{|gem| gem.match(/gem '([a-zA-Z0-9_-]+)/)[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
2.0.0p247 :001 > a = [1, 2] | |
=> [1, 2] | |
2.0.0p247 :002 > a[1] | |
=> 2 | |
2.0.0p247 :003 > a[2] | |
=> nil | |
2.0.0p247 :004 > a[1,1] | |
=> [2] | |
2.0.0p247 :005 > a[2,1] | |
=> [] ## <- Why is this not nil? |
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
def make_one_dimensional(input = {}, output = {}, prefix = nil) | |
if input.respond_to?(:each) | |
input.each do |key, value| | |
key = [prefix, key].compact.join('.') | |
case value | |
when Hash | |
make_one_dimensional(value, output, key) | |
when Array | |
value.each_with_index do |v, index| | |
array_key = "#{key}[#{index}]" |
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 'json' | |
def replace_json(node, &replacement_action) | |
case node | |
when Hash | |
node.each_value do |item| | |
yield item | |
replace_json(item, &replacement_action) | |
end | |
when Array |
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
run_list( | |
'recipe[chef-solo-search]', | |
'recipe[rails_application]' | |
) | |
default_attributes( | |
rails: { | |
app: {name: "sample_app"}, | |
deploy: { | |
repository: "https://github.com/jgarber/sample_app_2nd_ed.git" |
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
ssh-copy-id pi@192.168.X.X | |
# on the pi | |
sudo su - | |
cat <<EOF >> /etc/wpa_supplicant/wpa_supplicant.conf | |
network={ | |
ssid="Your SSID Here" | |
proto=RSN | |
key_mgmt=WPA-PSK | |
pairwise=CCMP |
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
The original: | |
Father-Daughter Talk | |
A young woman was about to finish her first year of college. Like so many others her age, she considered herself to be a very liberal Democrat, and was very much in favor of the redistribution of wealth. She was deeply ashamed that her father was a rather staunch Republican, a feeling she openly expressed. Based on the lectures that she had participated in, and the occasional chat with a professor, she felt that her father had for years harbored an evil, selfish desire to keep what he thought should be his. | |
One day she was challenging her father on his opposition to higher taxes on the rich and the addition of more government welfare programs. The self-professed objectivity proclaimed by her professors had to be the truth and she indicated so to her father. He responded by asking how she was doing in school. Taken aback, she answered rather haughtily that she had a 4.0 GPA, and let him know that it was tough to maintain, insisting that she was taking a very difficult cours |