My Recent Pastes (95 and counting)

Recent Pasties by brough (95 and counting)

Pages: 1 3 4 5 6 7

Below are summaries of the 15 most recent pasties by brough.

July 22, 2008
2:48PM EDT
by brough

1
2
3
4
5
params ={
        "NumRounds"=>"2.0",
         "Notes"=>"TEST - Saturday night",
         "commit"=>"Update",

June 03, 2008
6:14PM EDT
by brough

1
2
3
4
5
  Need to return 1 if the target_geom is covered by any combination of "available" geoms.

  options?

May 16, 2008
5:59AM EDT
by brough

1
2
3
4
5
class PlacesTsearch < ActiveRecord::Migration
  def self.up
    execute("ALTER TABLE places ADD COLUMN tsearchable tsvector;
             UPDATE places SET tsearchable=to_tsvector('english',coalesce(title_ascii,''));
             CREATE INDEX tsearchable_idx ON places USING gin(tsearchable);")

May 15, 2008
7:27PM EDT
by brough

1
2
3
4
5
[1,2,3,4,5,6,7,8,9,10]

paginate three to a page... so limit the results set to 3.

"LIMIT 3"

May 15, 2008
6:11PM EDT
by brough

1
2
3
4
5
## orders_controller.rb (snippet)
  def new
    @user = current_user
    @order = Order.new(:user_id => @user.id, :order_status => "initial", 
                       :checkout_at => Time.now, :apples => ???)

May 13, 2008
8:03PM EDT
by brough

1
2
3
4
5
  session[:cart] << inventory_item << inventory_item << inventory_item

  customer adds inventory to cart. Calculate total price taking into account volume discounts on the fly. When they checkout, formalize this on the order and line item tables:

May 10, 2008
3:37PM EDT
by brough

1
2
3
4
5
   if params[:answer] && params[:answer][:other].empty?
     # error message
   elsif !params[:answer]
     #error
   else

May 10, 2008
2:43PM EDT
by brough

1
2
3
4
5
#mod_rails_keygen.rb
require 'rubygems'
require 'digest/md5'

key = Digest::MD5.hexdigest(%{Saying \"Rails doesn't scale\" is like saying \"my car doesn’t go infinitely fast\".})

May 05, 2008
1:47PM EDT
by brough

1
2
3
4
5
class PlacesIndex < ActiveRecord::Migration
  def self.up
    execute("CREATE INDEX place_country_id_idx ON places(country_id);")
    execute("CREATE INDEX place_country_place_idx ON places(country_id,id);")
    execute("CREATE INDEX place_id_idx ON places(id);")

April 30, 2008
9:44PM EDT
by brough

1
2
3
4
5
window.addEvent("domready",function(){
  observe_forms();
});

function observe_forms(){

April 30, 2008
3:23PM EDT
by brough

1
2
3
4
5
 def self.tsearch(query,country)
    query = query.gsub(/\(.*|'/){}.split.join('&')
    find_by_sql("SELECT * from places WHERE country_id = #{country}
      AND tsearchable @@ to_tsquery('#{query}');")
  end

April 30, 2008
12:20AM EDT
by brough

1
2
3
4
5
## sass.rb

template = %q{
  body
    :background url(/images/<%= @file %>.jpg)

April 29, 2008
11:06PM EDT
by brough

1
2
3
4
5
window.addEvent("domready",function(){
  observe_forms();
});

function observe_forms(){

April 27, 2008
9:38PM EDT
by brough

1
2
3
4
5
  def add_space_to_cart
    @cart = find_cart
    @space = Space.find(params[:id])
    if verify_amca_user && !space.reserved
      @current_item = @cart.add_space(space)

April 27, 2008
9:12PM EDT
by brough

1
2
3
4
5
window.addEvent("domready",function(){
  observe_forms();
});

function observe_forms(){

Next page