This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| # Run this file with `RAILS_ENV=production rackup -p 3000 -s thin` | |
| # Be sure to have rails and thin installed. | |
| require "rubygems" | |
| # We are not loading Active Record, nor the Assets Pipeline, etc. | |
| # This could also be in your Gemfile. | |
| gem "actionpack", "~> 3.2" | |
| gem "railties", "~> 3.2" | |
| require "rails" |
| # Pass in the name of the site you wich to create a cert for | |
| domain_name = ARGV[0] | |
| if domain_name == nil | |
| puts "Y U No give me a domain name?" | |
| else | |
| system "openssl genrsa -out #{domain_name}.key 1024" | |
| system "openssl req -new -key #{domain_name}.key -out #{domain_name}.csr -subj '/C=US/ST=NJ/L=Monroe/O=MyCompany/OU=IT/CN=#{domain_name}'" | |
| system "cp #{domain_name}.key #{domain_name}.key.bak" |
| Gem::Specification.new do |s| | |
| s.name = 'bang' | |
| s.version = '0.1.0' | |
| s.platform = Gem::Platform::RUBY | |
| s.author = 'Jeff Kreeftmeijer' | |
| s.email = '[email protected]' | |
| s.summary = 'Bang!' | |
| s.description = 'Bangs existing model methods' | |
| s.files = ['bang.rb'] |
| class GalleryImagesController < ApplicationController | |
| def rotate | |
| @image = GalleryImage.find(params[:id]) | |
| rotation = params[:deg].to_f | |
| rotation ||= 90 # Optional, otherwise, check for nil! | |
| @image.rotate!(rotation) | |
| flash[:notice] = "The image has been rotated" | |
| end |
| require 'rmagick' | |
| include Magick | |
| shredded = ImageList.new "TokyoPanoramaShredded.png" # the original source | |
| ROWS = shredded.rows # number of lines of pixes | |
| working = [] # a working array of images | |
| def strip_width | |
| 32 | |
| end |
| # Add this to your spec_helper.rb | |
| RSpec.configure do |config| | |
| config.treat_symbols_as_metadata_keys_with_true_values = true | |
| config.around(:each, :vcr => true) do |example| | |
| name = example.metadata[:full_description].downcase.gsub(/\W+/, "_").split("_", 2).join("/") | |
| VCR.use_cassette(name, :record => :new_episodes) do | |
| example.call | |
| end | |
| end | |
| end |
| # add this to your spec helper | |
| RSpec.configure do |config| | |
| config.treat_symbols_as_metadata_keys_with_true_values = true | |
| config.filter_run :focus => true | |
| config.run_all_when_everything_filtered = true | |
| end | |
| # and then use the :focus tag in your specs | |
| it "does something awesome", :focus do |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| require 'rubygems' | |
| require 'rack' | |
| class Object | |
| def webapp | |
| class << self | |
| define_method :call do |env| | |
| func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
| [200, {}, send(func, *attrs)] | |
| end |
| # Everything you need to do to get started with Rails 2.3.8 | |
| # | |
| # As of June 14th, 2010 @ 2:30 p.m. MST | |
| # | |
| # This gist now features instructions to get Rails 3 up and running with: | |
| # - Ruby 1.8.7-p174 | |
| # - Bundler 0.9.26 | |
| # - Cucumber 0.8.0 | |
| # - Rspec 1.3.0 + Rspec-Rails 1.3.2 | |
| # - RVM |