Skip to content

Instantly share code, notes, and snippets.

GIT
remote: git://github.com/seyhunak/twitter-bootstrap-rails.git
revision: 9649b2c0b12a374dfece50a3ae31cc56ad778300
specs:
twitter-bootstrap-rails (2.2.0)
actionpack (>= 3.1)
execjs
railties (>= 3.1)
GEM
source 'https://rubygems.org'
gem 'rails', '3.2.11'
gem 'mysql2'
gem 'thin'
gem 'jquery-rails'
gem 'coffee-rails', '~> 3.2.1'
gem 'therubyracer'
gem 'less-rails' #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
Vertex = Struct.new(:name, :edges)
Edge = Struct.new(:v0, :v1, :weight)
a = Vertex.new("A")
b = Vertex.new("B")
c = Vertex.new("C")
d = Vertex.new("D")
e = Vertex.new("E")
f = Vertex.new("F")
g = Vertex.new("G")
@samuel02
samuel02 / gist:4020429
Created November 5, 2012 21:26
Some code
if x > 0
0.upto(y) do |z|
a.push(z)
end
else
0.upto(y-1) do |z|
a.push(z)
end
end
@samuel02
samuel02 / gist:2875441
Created June 5, 2012 14:46
CategoryConstraint
class CategoryConstraint
def matches?(request)
@categories = []
ProductCategory.all.each do |c|
@categories.push(c.slug)
end
@categories.include?(request.params[:id])
resources :products, :path => 'produkter', :as => 'products', :only => [:index, :show]
get ':id', :to => 'product_categories#show', :constraints => CategoryConstraint.new, :as => 'product_category'
@bookings.as_json [{:id=>5, :title=>"", :description=>"", :start=>"Wed, 09 May 2012 00:00:00 +0200", :end=>"Wed, 09 May 2012 00:00:00 +0200", :allDay=>true, :recurring=>false, :url=>""}, {:id=>3, :title=>"", :description=>"", :start=>"Mon, 14 May 2012 00:00:00 +0200", :end=>"Sun, 20 May 2012 00:00:00 +0200", :allDay=>true, :recurring=>false, :url=>""}, {:id=>1, :title=>"", :description=>"", :start=>"Tue, 01 May 2012 00:00:00 +0200", :end=>"Sat, 05 May 2012 00:00:00 +0200", :allDay=>true, :recurring=>false, :url=>""}]
Object
_end: null
_id: "5"
_start: Wed May 09 2012 00:00:00 GMT+0200 (CEST)
allDay: true
className: Array[0]
description: ""
end: null
id: 5
recurring: false
Booking Load (0.9ms) SELECT "bookings".* FROM "bookings" WHERE "bookings"."product_id" = 1 AND (booked_from > '2012-04-30 00:00:00') AND (booked_to < '2012-06-11 00:00:00')
@bookings.scoped: [#<Booking id: 5, product_id: 1, customer_id: 6, booked_from: "2012-05-08 22:00:00", booked_to: "2012-05-08 22:00:00", paid: nil, payment_type: nil, created_at: "2012-04-27 13:32:20", updated_at: "2012-04-27 13:32:20">, #<Booking id: 3, product_id: 1, customer_id: 4, booked_from: "2012-05-13 22:00:00", booked_to: "2012-05-19 22:00:00", paid: nil, payment_type: nil, created_at: "2012-04-26 17:27:21", updated_at: "2012-04-26 17:27:21">, #<Booking id: 1, product_id: 1, customer_id: 2, booked_from: "2012-04-30 22:00:00", booked_to: "2012-05-04 22:00:00", paid: nil, payment_type: nil, created_at: "2012-04-26 14:03:33", updated_at: "2012-04-26 14:03:33">]
Completed 200 OK in 28ms (Views: 2.3ms | ActiveRecord: 3.0ms
class Booking < ActiveRecord::Base
validate :booking_period_not_overlapped
validates :customer_id, :presence => true, :uniqueness => true
validates :product_id, :presence => true
validates_datetime :booked_to, :on_or_after => :booked_from
validates_datetime :booked_from, :on => :create, :on_or_after => :today
belongs_to :product