Skip to content

Instantly share code, notes, and snippets.

View jwo's full-sized avatar

Jesse Wolgamott jwo

View GitHub Profile
@jwo
jwo / gist:2775692
Created May 23, 2012 14:54 — forked from johnnygoodman/gist:2772856
Vehicle Class, Make == Instance Variable Dynamic
#-------------------------------------
# this part just to run the specs
#
#
require 'rspec'
class Vehicle; end
# end
#-------------------------------------
#require_relative './vehicle'
@jwo
jwo / .rspec
Created May 24, 2012 01:38 — forked from coreyhaines/.rspec
Loading just active record
--colour
-I app
@jwo
jwo / alert_finder.sh
Created June 4, 2012 15:04
Print out any UI alerts in your app/views (and next 10 lines).
#!/bin/bash
# Useful for documentation to the client about what alert messages to users you added to the system
# For Rails, obvs, but useful to any app/views directory structure
FILES=$(grep -lr "alert" app/views)
for file_name in $FILES; do
echo "---------------------------------------";
echo $file_name;
echo "---------------------------------------";
@jwo
jwo / .profile
Created July 16, 2012 02:40
~/.profile rvm settings
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
[[ -r $rvm_path/scripts/completion ]] && . $rvm_path/scripts/completion
rvm use default
@jwo
jwo / rule.md
Created August 25, 2012 19:15
Ember + Rails (Houston Code Camp live)

Each year there is a competition… Fake Thanksgiving!

The House provides a turkey, and you enter a side or a dessert. (the entry). Then, people vote. the winner gets fame and glory!

The first year, we voted on paper. The next, I built a Rails 1.2 website that tabulated votes. (updated over time).

Let's build a voting machine with Rails as the API but use Ember to keep state and give a better user experience.

Rails Side

@jwo
jwo / post.rb
Created October 3, 2012 20:03
Dynamic strong_parameters example
class Post < ActiveRecord::Base
include ActiveModel::ForbiddenAttributesProtection
def self.attributes_for_user user
attrs = [:body, :title]
attrs << :published if user.admin?
attrs
end
end
@jwo
jwo / devise.rb
Created October 13, 2012 17:36
OmniAuth with Twitter
config.omniauth :facebook, FACEBOOK_APP_ID, FACEBOOK_APP_SECRET, { :scope => 'user_status,publish_stream' }
config.omniauth :twitter, TWITTER_KEY, TWITTER_SECRET
@jwo
jwo / 1_explanation.md
Created October 29, 2012 16:41
No Instance Variables in Specs (for @Blighte)

(this started on twitter)

The microposts spec starts out with

let(:user) { FactoryGirl.create(:user) }
  before do
    # This code is wrong!
    @micropost = Micropost.new(content: "Lorem ipsum", user_id: user.id)
 end
@jwo
jwo / the-cell-map.rb
Created November 2, 2012 13:58
Celluloid simplistic example
require 'celluloid'
module Enumerable
def pmap(&block)
futures = map { |elem| Celluloid::Future.new(elem, &block) }
futures.map { |future| future.value }
end
end
puts "let's do this without celluloid!"
@jwo
jwo / the_tests_and_specs.rb
Created November 30, 2012 19:34
message vs value expection (for @RubyoffRails)
describe Fixnum do
it "should add 2 + 2 and return 4" do
@two = 2
result = @two+ @two
result.should eq(4)
end
end
class Calculator