Skip to content

Instantly share code, notes, and snippets.

@aokolish
aokolish / example.rb
Last active August 29, 2015 14:02
rails 4 argument out of range issue
# rails 3, invalid times are set to nil
> m = Model.new some_timestamp: '2010-33-22T09:30:25Z'
=> #<Model ...>
> m.some_timestamp
=> nil
# rails 4, invalid times raise an exception
> m = Model.new some_timestamp: '2010-33-22T09:30:25Z'
=> ArgumentError: argument out of range
class GeneratedPDF
def generate
# pdf stuff...
pdf_file = Tempfile.new(['something', '.pdf'])
pdf_file.binmode
pdf_file.write(pdf_string)
pdf_file
end
end
@aokolish
aokolish / _layout.html.haml
Last active August 29, 2015 14:19
Nested layout in rails
-# This file contains the 'layout' for this section of the site
%section.how-it-works-page.content-section
.container
.row
.col-md-12
%h2.section-title How It Works
.sub-nav.row
.col-sm-3
= active_link_to how_we_find_kids_path, class: 'link-wrap' do
.img.school
@aokolish
aokolish / init.js
Created November 10, 2011 04:49
Run page JS without switch statement
var LTD = {};
LTD.product = (function() {
//private functions
function somethingHandy() {
...
}
return {
//public functions...
@aokolish
aokolish / Gemfile
Created November 25, 2011 16:24
How to get tests running on an external site that uses HTTP authentication
# /Gemfile
source 'http://rubygems.org'
gem 'rspec'
gem 'capybara'
gem 'selenium-webdriver'
gem 'capybara-webkit'
@aokolish
aokolish / database.yml
Created November 27, 2011 23:26
how to get postgresql working locally with rails
development:
adapter: postgresql
database: <db_name>
encoding: utf8
username: <username>
password:
host: localhost
# ...
@aokolish
aokolish / .watchr
Created November 30, 2011 15:47
watch any file
watch(".*\..*") do |match|
puts `echo "hello"`
end
@aokolish
aokolish / .gvimrc
Created December 2, 2011 21:07
My mac vim settings
color railscasts
set guifont=Monaco:h16
set antialias
" Whitespace stuff
autocmd FileType javascript set tabstop=4
@aokolish
aokolish / Gemfile
Created January 27, 2012 02:53
testing elements that are revealed with css :hover
source 'http://rubygems.org'
gem 'rake'
gem 'rspec'
gem 'capybara'
gem 'selenium-webdriver'
gem 'capybara-webkit'
@aokolish
aokolish / gist:1695477
Created January 28, 2012 19:17
ruby one liner to return spork pid's
`ps aux | awk '/spork/&&!/awk/{print $2;}'`.split("\n").map { |pid| pid.to_i }