Skip to content

Instantly share code, notes, and snippets.

View skmetz's full-sized avatar

Sandi Metz skmetz

View GitHub Profile
# If model Thing has fields name, description and photo ...
require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb')
describe "resource(:things)" do
describe "a successful POST" do
before(:each) do
Thing.all.destroy!
file = File.new(File.join('path_to_test_photos',"thing_photo.jpg"))
#!/bin/bash # test change
DATE=`date +%m-%e-%y`
OUTPUT="versions_as_of_$DATE.txt"
rm "$OUTPUT"
for d in `ls -d */` # get a list of all directories
do
DIR=${d/\//} # replace trailing / with nothing as in ${stringZ/replacethis/withthis}
GITDIR_ARG="--git-dir=$DIR/.git"
#!/bin/bash
PROJ="/Users/skm/Projects/test"
for d in `ls -d */` # get a list of all directories
do
DIR=${d/\//} # replace trailing / with nothing as in ${stringZ/replacethis/withthis}
TARGET_DIR="$PROJ/vendor"
# dep_inj_1.rb
def this
end
# coderay formatting
# once you paste this into blogger, you MAY have to surround the block with a
# div class='hscroll' to get a horizontal scrollbar.
# Usage:
# Copy your ruby code into the paste buffer,
# run this ruby code to format it
# paste the newly formatted code into your blog.
require 'rubygems'
@skmetz
skmetz / remove case statement
Created June 17, 2009 13:35
remove case statement from form_for, etc
From 164f12ca299a407d9d31f32e400daaef12ab736a Mon Sep 17 00:00:00 2001
From: Sandi Metz <[email protected]>
Date: Mon, 15 Jun 2009 08:01:48 -0400
Subject: [PATCH] remove case statements, use double dispatch
---
actionpack/lib/action_view/helpers.rb | 2 +
actionpack/lib/action_view/helpers/form_helper.rb | 43 ++++++--------
.../helpers/form_helper_core_extensions.rb | 59 ++++++++++++++++++++
.../lib/action_view/helpers/prototype_helper.rb | 19 +------
From 164f12ca299a407d9d31f32e400daaef12ab736a Mon Sep 17 00:00:00 2001
From: Sandi Metz <[email protected]>
Date: Mon, 15 Jun 2009 08:01:48 -0400
Subject: [PATCH] remove case statements, use double dispatch
---
actionpack/lib/action_view/helpers.rb | 2 +
actionpack/lib/action_view/helpers/form_helper.rb | 43 ++++++--------
.../helpers/form_helper_core_extensions.rb | 59 ++++++++++++++++++++
.../lib/action_view/helpers/prototype_helper.rb | 19 +------
class Bag < Hash
def add(obj)
increment_count(obj)
end
def increment_count(obj)
self[obj] = (cnt = self[obj]).nil? ? 1 : cnt + 1
end
@skmetz
skmetz / careerbuilder_class_links.md
Last active November 27, 2022 01:29
CareerBuilder class links
@skmetz
skmetz / gilded_rose_test.rb
Last active May 30, 2017 18:42
Gilded Rose Test
# This simplest thing is to clone Jim's repo (https://github.com/jimweirich/gilded_rose_kata) and then
# put this file in the root directory.
gem 'minitest', '~> 4.7'
require "minitest/autorun"
require "minitest/reporters"
MiniTest::Reporters.use! MiniTest::Reporters::SpecReporter.new
require_relative './gilded_rose'