Skip to content

Instantly share code, notes, and snippets.

class CreateBooks < ActiveRecord::Migration
def self.up
create_table :books do |t|
t.string :title, :null => false
t.text :description
t.string :isbn
t.belongs_to :authorship
t.timestamps
end
@iamjarvo
iamjarvo / gist:1394907
Created November 26, 2011 03:18
Learn to Program - Chapter 2 - Numbers
# How many hours in a year?
puts 24 * 365 # 8760
# How many minutes in a decade?
puts 660 * 24 *(365*10 + 2) # 5258880
# My age in seconds
puts (365 * 22 + 5) * 3600 * 22 # 636372000
# Author is 1,025mil seconds old. How old in years is he?
@iamjarvo
iamjarvo / ruby_skype_api_example.rb
Created June 7, 2012 14:54 — forked from ebisawa/ruby_skype_api_example.rb
Skype API example in Ruby
require 'dbus'
MYNAME = 'com.example.skype_api_client'
class SkypeAPI
def initialize(name = MYNAME)
bus = DBus.session_bus
service = bus.service("com.Skype.API")
objs = service.object("/com/Skype")
objs.introspect
@iamjarvo
iamjarvo / gist:3753815
Created September 20, 2012 03:29
Delete cookies with capybara and selenium
browser = Capybara.current_session.driver.browser
browser.manage.delete_cookie '_al_session'

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

@iamjarvo
iamjarvo / gist:3947238
Created October 24, 2012 16:43
Onboarding process
- What does your app do?
Shopping cart / blog|magazine
- What software are you using to accomplish this?
Tell us software name and version
Rails
- If its rails
- What version are you using?
rails 2.3.2
- Are you using bundler?
No
@iamjarvo
iamjarvo / Vim output to clipboard
Created November 5, 2012 19:02
Pipe vim output to clipboard
:let @* = &gfn
help
:h "* :h expr-register :h expr-option

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
if [[ $BUILD_STATUS == "success" ]]
then
export STATUS="success"
else
export STATUS="failure"
fi
curl "https://api.github.com/repos/justincampbell/my_repo/statuses/$GIT_COMMIT?access_token=abc123" \
-H "Content-Type: application/json" \
-X POST \
def stupid_return(arg)
arg == 3 ? 'stupid' : arg
end
[*1..5].each { |i| puts stupid_return(i) }
#=> 1 2 stupid 3 4 5