Skip to content

Instantly share code, notes, and snippets.

@alexch
alexch / pig_latin.rb
Created May 8, 2012 16:37
Bootcamp Share
def translate(str)
tr_words = []
words = str.split
words.each do |word|
if word =~ /^([bcdfghjklmnpqrstvwxz]+)(.*)/
p word
p $1
p $2
tr_words.push($2 + $1 + "ay")
else
@alexch
alexch / gist:2161772
Created March 22, 2012 18:52
creating a new rails app for Michael Hartl's RailsTutorial
# terminal:
rails new sample_app --skip-test-unit
cd sample_app
# add some gems to your Gemfile:
cat >> Gemfile
group :production do
@alexch
alexch / respond_to.rb
Last active October 2, 2015 03:18
unbloating Rails' respond_to scaffolding
# why does Rails generate this...
def index
@users = User.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @users }
end
end
data = <<TEXT
Lion (10.7.1)
Mac OS
Mac osx
Windows 7
Mac osx, leopard
Linux
OSX
OSX
Mac OSX (snow leopard)
@alexch
alexch / index.html
Created August 26, 2011 01:02 — forked from nfiniteset/index.html
Pages that scale to fit window size
<!DOCTYPE html>
<html>
<head>
<title>Scaling preso</title>
<style>
html {
font-size: 7.68px
}
require "performance_monitor"
require "time"
describe PerformanceMonitor do
before do
@monitor = PerformanceMonitor.new
@eleven_am = Time.parse("2011-1-2 11:00:00")
end
it "takes about 0 seconds to run an empty block" do
require "performance_monitor"
require "time"
describe PerformanceMonitor do
before do
@monitor = PerformanceMonitor.new
@eleven_am = Time.parse("2011-1-2 11:00:00")
end
it "takes about 0 seconds to run an empty block" do
@alexch
alexch / gist:1088106
Created July 17, 2011 21:45
Erector Rails 3.1 Failures
Failures:
1) Erector::Rails a named route helper can be called directly
Failure/Error: text root_path
NameError:
Erector::Widget#to_s is deprecated. Please use #to_html instead. Called from /Users/chaffee/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.6.4/lib/rspec/core/formatters/base_text_formatter.rb:163:in `inspect'
undefined local variable or method `root_path' for #<Erector::InlineWidget:0x00000102b30828>
# ./lib/erector/rails3.rb:128:in `method_missing'
# ./lib/erector/inline.rb:28:in `method_missing'
# ./spec/rails_root/spec/rails_helpers_spec.rb:77:in `block (4 levels) in <top (required)>'
class HowManyLicks < QuestionForm
def content
overview do
title_element "How many licks?"
text_element "Please tell us how many licks it takes to get to the center of these things."
formattedcontent do
rawtext "<![CDATA[\n"
p do
a :href => "http://tootsiepop.com/instructions.html" do
b "Click here to read the instructions!"
class HowManyLicks < QuestionForm
def content
overview do
title_element "How many licks?"
text_element "Please tell us how many licks it takes to get to the center of these things."
formattedcontent do
rawtext "<![CDATA[\n"
p do
a :href => "http://tootsiepop.com/instructions.html" do
b "Click here to read the instructions!"