This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Option < ActiveRecord::Base | |
attr_accessor :view_type, :comments_count, :expires_at_date, :expires_at_time | |
before_save :set_expires_at | |
after_save :set_reference, :set_default_room_allocation_name, :set_room_allocation_dates | |
private | |
def set_reference | |
self[:reference] = "OPT%05d" % id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I want to turn this: | |
array = [1, 2, 3, 4, 5, 6, 7, 8, 9] | |
# into this: | |
# [[1, 2, 3], [4, 5, 6], [7, 8, 9]] | |
arr = [] | |
array.each_slice(3) {|x| arr << x } | |
arr # => [[1, 2, 3], [4, 5, 6], [7, 8, 9]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ExtendNumericRounding | |
def roundup(nearest=10) | |
self % nearest == 0 ? self : self + nearest - (self % nearest) | |
end | |
def rounddown(nearest=10) | |
self % nearest == 0 ? self : self - (self % nearest) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SecureController < ApplicationController | |
layout 'secure' | |
def booking | |
@secure = Secure.find(:first, :conditions => { | |
:email => params[:secure][:email], | |
:reference => params[:secure][:reference] | |
}) | |
# Redirect if we have the data | |
redirect_to secure_booking2_path and return unless @secure.nil? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# rails application template for generating customized rails apps | |
# | |
# == requires == | |
# | |
# * rails 2.3+, rspec, cucumber, culerity (langalex-culerity gem), machinist | |
# | |
# == a newly generated app using this template comes with == | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Put terminal_clone_tab somewhere in | |
your path and make sure it is executable (I put it in ~/bin) | |
chmod u+x terminal_clone_tab | |
2) Then add the following alias (~/.bash_profile or something) | |
alias nt='terminal_clone_tab' | |
3) Then you can hit nt (for new tab) anywhere | |
and a new tab will open up in same directory. | |
If there is an easier way to do this, let me know [email protected]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Monitor HTTP requests being made from your machine with a one-liner.. | |
# Replace "en1" below with your network interface's name (usually en0 or en1) | |
sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*" | |
# OR.. to be able to use as "httpdump" from anywhere, drop this into ~/.bash_profile: | |
# (again replace "en1" with correct network interface name) | |
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"" | |
# All the above tested only on OS X. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: Logging in and out | |
Scenario: Log in with valid name and password | |
Given a site | |
And a global admin | |
When I try to access the overview page | |
And I log in as with valid credentials | |
Then I should see the overview page | |
And should be logged in |
NewerOlder