1
2
3
4
# This is what an application build with our framework would look like.
# Run with:
#   rackup app.ru
...

Ruby Very Simple Rack framework

by macournoyer, September 14, 2008 18:11, 1 refactoring, tagged with rack

I'll be presenting http://r...

Bfec5f7d1a4aaafc5a2451be8c42d26a Talk
1
2
3
4
class AccountsController < ApplicationController

  layout 'application'
...

Ruby Password update code

by danielharan, July 16, 2008 16:59, 4 refactorings, tagged with rails, restful, authentication

Mostly straight from a tuto...

880cbab435f00197613c9cc2065b4f5a Talk
1
2
3
4
class JobBoard < ActiveRecord::Base
  has_many :job_board_postings
  
...

Ruby Ruby has_finder on has_many ?

by danielharan, April 01, 2008 16:10, 1 refactoring, tagged with has_finder rails

This smells... one of the m...

880cbab435f00197613c9cc2065b4f5a Talk
1
2
3
4
require 'rubygems'
require 'data_mapper'
require 'benchmark'
...

Ruby DataMapper threaded benchmark

by Kevin Williams, February 20, 2008 04:38, 1 refactoring, tagged with orm, datamapper, benchmark

third of three - slowest of...

267942571862781dd912de6482a35f46 Talk
1
2
3
4
require 'rubygems'
require 'sequel'
require 'benchmark'
...

Ruby Sequel threaded benchmark

by Kevin Williams, February 20, 2008 04:35, No refactoring, tagged with orm, sequel, benchmark

second of three, not as fas...

267942571862781dd912de6482a35f46 Talk
1
2
3
4
require 'rubygems'
require 'active_record'
require 'benchmark'
...

Ruby ActiveRecord threaded bench...

by Kevin Williams, February 20, 2008 04:33, No refactoring, tagged with orm, activerecord, benchmark

first of three benchmarks, ...

267942571862781dd912de6482a35f46 Talk
1
<%= (@post.category ? @post.category.name : '') + ' ' + link_to(@post.title, post_path(@post)) %>

Ruby Handling nil object

by macournoyer, November 14, 2007 02:07, 13 refactorings, tagged with rails, html

@post.category can be nil, ...

Bfec5f7d1a4aaafc5a2451be8c42d26a Talk
1
2
3
4
namespace :migrations do
  
  desc 'reverts, renames and re-executes uncommitted migrations that conflict with already committed migrations'
...

Ruby Rails migration conflict re...

by danielharan, October 26, 2007 18:25, 1 refactoring, tagged with rails

Explained here: http://www....

880cbab435f00197613c9cc2065b4f5a Talk
1
2
3
4
require 'erb'
class ClientMigrator
  def self.create(fields)
...

Ruby Dynamic migrations for rails

by danielharan, October 12, 2007 04:27, 1 refactoring

How do you create a rails p...

880cbab435f00197613c9cc2065b4f5a Talk
1
2
3
4
tab() # new tab from current dir
{
osascript -e "
...

Bash Open a new tab in current d...

by macournoyer, October 04, 2007 18:07, 2 refactorings

Here's a small script I wro...

Bfec5f7d1a4aaafc5a2451be8c42d26a Talk
1
2
3
4
var Rating = Class.create();
Rating.prototype = {
  initialize: function(element, rating, options) {
...

JavaScript Rating system for this site

by macournoyer, September 29, 2007 14:09, 3 refactorings

Here's the code of the rati...

Bfec5f7d1a4aaafc5a2451be8c42d26a Talk
1
puts chars[51000000000] == 's' # => false

Ruby On Integer puzzle

by macournoyer, September 27, 2007 17:52

wrong! see my proof

Bfec5f7d1a4aaafc5a2451be8c42d26a Talk

Ruby On Ruby simple loop

by macournoyer, September 27, 2007 15:51 Star_fullStar_full

Right! Forgot about that on...

Bfec5f7d1a4aaafc5a2451be8c42d26a Talk

Ruby On restful_authentication role...

by macournoyer, September 27, 2007 12:30

I don't think you need the ...

Bfec5f7d1a4aaafc5a2451be8c42d26a Talk
1
2
3
4
def self.requires_role(role, options={})
  before_filter(options) { logged_in? && current_user.send("#{role}?") ? true : access_denied }
end
...

Ruby On restful_authentication role...

by macournoyer, September 27, 2007 11:43 Star_fullStar_fullStar_fullStar_full

What about this:

Bfec5f7d1a4aaafc5a2451be8c42d26a Talk

Ruby On restful_authentication role...

by macournoyer, September 27, 2007 10:45

Really good idea James, but...

Bfec5f7d1a4aaafc5a2451be8c42d26a Talk
1
2
3
4
class Line
  def parse
    skip_line
...

Ruby On Arrow Code

by macournoyer, September 26, 2007 17:18 Star_full

Why not restructure everyth...

Bfec5f7d1a4aaafc5a2451be8c42d26a Talk
1
2
3
4
task :extract_style do
  css = File.read 'public/stylesheets/code.css'
  css.gsub! "{\n", '{'
...

Ruby Extracting style from a CSS...

by macournoyer, September 25, 2007 21:18, 2 refactorings

Here's a Rake task I use to...

Bfec5f7d1a4aaafc5a2451be8c42d26a Talk
1
2
3
def code
  puts 'cool'
...

JavaScript On Is this year a leap year?

by macournoyer, September 23, 2007 13:13 Star_fullStar_fullStar_fullStar_fullStar_full

Nice tip Gary! I didn't kno...

Bfec5f7d1a4aaafc5a2451be8c42d26a Talk
1
2
3
4
class CodeFormatter
  cattr_reader :syntaxes
  @@syntaxes = Uv.syntaxes.sort
...

Ruby [FEATURE] Sections in code!

by macournoyer, September 22, 2007 08:44, No refactoring

Introducing a new feature: ...

Bfec5f7d1a4aaafc5a2451be8c42d26a Talk
1
2
3
4
units = %w{ one two three four five six seven eight nine }

File.open('counter.txt', 'w') do |f|
...

Ruby On Sum string sizes

by macournoyer, September 21, 2007 10:13 Star_fullStar_fullStar_fullStar_fullStar_full

Welcome to the site Hampton...

Bfec5f7d1a4aaafc5a2451be8c42d26a Talk

JavaScript On Is this year a leap year?

by macournoyer, September 21, 2007 08:20

I'll try to add sections wi...

Bfec5f7d1a4aaafc5a2451be8c42d26a Talk
1
2
3
4
def link_to_remote_with_spinner(title, options)
  element_id = options.delete(:id) || ('link_to_' + title.underscore.tr(' ', '_'))
  container_id = options.delete(:container_id) || element_id
...

Ruby On link_to_remote_with_spinner

by macournoyer, September 21, 2007 07:42

With the above code you cou...

Bfec5f7d1a4aaafc5a2451be8c42d26a Talk
1
Dir["test/**/*_test.rb"].size.to_f / Dir["app/**/*.rb"].size.to_f 

Ruby On Test file to code file ratio

by macournoyer, September 21, 2007 07:34

Nice! Or even shorter, with...

Bfec5f7d1a4aaafc5a2451be8c42d26a Talk
1
2
3
4
Object.extend(Date.prototype, {
  isLeap: function(){
    var year = this.getFullYear();
...

JavaScript On Is this year a leap year?

by macournoyer, September 21, 2007 07:30

I'm pretty sure the last ye...

Bfec5f7d1a4aaafc5a2451be8c42d26a Talk