Skip to content

Instantly share code, notes, and snippets.

if options[:fast]
options[:ignorecase] ? pattern = Regexp.new(Regexp.escape(ARGV.shift), 1) : pattern = Regexp.new(Regexp.escape(ARGV.shift))
elsif options[:ignorecase]
pattern = Regexp.new(ARGV.shift, 1)
else
pattern = Regexp.new(ARGV.shift)
end
# Inserting the regular expression in to the conditional statement. line is the lambda |line|, as part of
# an iteration.
if line =~ /#{pattern}/
#!/usr/bin/env ruby -w
require 'optparse'
require 'open-uri'
class PowerGrep
def initialize
@results => "Initialized!"
end
lastfm_call = Nokogiri::XML(open("http://ws.audioscrobbler.com/2.0/?method=track.getsimilar&artist=#{artist}&track=#{track}&api_key=#{@api_key}"))
require 'test_helper'
class CartTest < ActiveSupport::TestCase
test "initialize" do
cart = Cart.new
assert_equal 0, cart.items.length
end
test "add product" do
test "should create user" do
assert_difference('User.count') do
post :create, :user => {
:name => "Bob Smith",
:password => "test",
:password_confirmation => "test"
}
end
assert_redirected_to :action => 'index'
#!/bin/sh
#
# Will append the current Lighthouse ticket number to the commit message automatically
# when you use the 1234-foo-bar branch naming convention.
#
# Drop into .git/hooks/commit-msg
# chmod +x .git/hooks/commit-msg
exec < /dev/tty
@miketierney
miketierney / gist:69768
Created February 24, 2009 20:36 — forked from loe/gist:69444
class Group < ActiveRecord::Base
belongs_to :location
validates_presence_of :name, :location_id
def self.sort(page, order)
options = {}
if order == 'location'
options[:order] = 'location_id'
#!/bin/sh
#
# Will append the current Lighthouse ticket number to the commit message automatically
# when you use the 1234-foo-bar branch naming convention.
#
# Drop into .git/hooks/commit-msg
# chmod +x .git/hooks/commit-msg
exec < /dev/tty
class Event < ActiveRecord::Base
belongs_to :group
belongs_to :location
validates_presence_of :group_id, :location_id, :start_time, :end_time
define_index do
indexes name
end
end