Skip to content

Instantly share code, notes, and snippets.

View robyurkowski's full-sized avatar

Rob Yurkowski robyurkowski

View GitHub Profile
http://jobs.37signals.com/jobs
http://jobs.rubyinside.com/a/jbb/find-jobs
http://www.workingwithrails.com/browse/jobs/recent
http://jobs.rubynow.com/
http://freelanceswitch.com
## helpers/layout_helper.rb
module LayoutHelper
def title(page_title, show_title = true)
@content_for_title = page_title.to_s
@show_title = show_title
end
def show_title?
@show_title

Essential

  • rails
  • passenger
  • mysql
  • sqlite3-ruby
  • haml
  • compass
  • bluecloth
  • nifty_generators
desc "Fetch product prices"
task :updatepayouts => :environment do
require 'mechanize'
agent = WWW::Mechanize.new
Offer.find_all_by_payout(nil).each do |offer|
escaped_offer_name = CGI.escape("\"#{offer.name}\"")
agent.get("http://odigger.com/?&q=#{escaped_offer_name}&network_id=")
agent.page.search(".payout").each do |offer2|
offer.update_attribute(:payout, offer2.text.strip)
end
## Cucumber Scenario
@wip
Scenario: Login with correct details
Given a user named "brent" exists
When I go to login
And I fill in "Username" with "brent"
And I fill in "Password" with "screech"
And I press "Log In"
And show me the page
class UserSessionsController < ApplicationController
def new
@user_session = UserSession.new
end
def create
@user_session = UserSession.new(params[:user_session])
if @user_session.save
flash[:notice] = "Logged in successfully."
redirect_to_target_or_default(root_url)
So I have a model named Droplet. A droplet is essentially a catch-all status update. It looks like this:
Droplet
-------
- id
- title:varchar(255)
- body:varchar(255)
- user_id:int(11)
@robyurkowski
robyurkowski / posts_controller.rb
Created November 9, 2010 06:03
Weird routing error.
class PostsController < ApplicationController
def results
params[:search] = params[:search].blank? ? '%' : "%#{params[:search]}%"
@posts = Post.where("body LIKE ? OR title LIKE ?", params[:search], params[:search]).published(true).paginate(:per_page => 5, :page => params[:page])
render :action => :index
end
end
@robyurkowski
robyurkowski / robox.rb
Created December 2, 2010 15:50
Lines for checking if symlinked, setting appropriate load path, and `chdir`ing for file reads
#!/usr/bin/env ruby
THIS_FILE = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
$LOAD_PATH.unshift File.expand_path(File.dirname(THIS_FILE))
Dir.chdir(File.expand_path(File.dirname(THIS_FILE)))
I disagree strongly with the notion that emotion and tone must be left up to the imagination in written communication. It's often repeated, I think, because we don't have the full range of subtext provided by the body when communicating in person, but I'd argue that there is a whole host of metadata that accompanies the written statement, anyway. Semiological constructions have evolved over time to provide these visual cues—perhaps not in the same way, but certainly in a way that is respectible and replete with its own intricacies of meaning.
Credo: I believe that it is entirely possible to communicate without ambiguity in writing. Most importantly, I believe it is possible to do so in a concise manner. Correspondingly, I tend to get upset when I see prohibitions of parts of written speech. There's a difference between guarding against overuse and the often deontological imperative implied with such prohibitions. The occasional adverb adds spice, and the occasional exclamation point will clarify a sentence j