Skip to content

Instantly share code, notes, and snippets.

View supaspoida's full-sized avatar

Lar Van Der Jagt supaspoida

View GitHub Profile
@supaspoida
supaspoida / package.json
Created December 1, 2021 21:55 — forked from kentcdodds/package.json
setup script for my workshops
{
"name": "workshop-setup",
"version": "1.0.0",
"description": "This is the common setup script for most of my workshops",
"bin": "./setup.js"
}
@supaspoida
supaspoida / candidate_spec.rb
Created October 11, 2011 13:41 — forked from knwang/candidate_spec.rb
Proofing_oven: Candidate Spec with search
require 'spec_helper'
describe Candidate do
subject { Fabricate(:candidate, first_name: "Joe", last_name: "Doe") }
describe "#full_name" do
its(:full_name) { should == "Joe Doe" }
end
describe "#search" do
@supaspoida
supaspoida / regext.txt
Created August 23, 2011 20:57 — forked from jt/regext.txt
Regular expression notes
- any character you use it will literally match it except special characters
^ $ ? . / \ [ ] { } ( ) + * - all the special characters that will need escaping if you don't want them to be special
// - regexp ruby class
Common Patterns (I authored)
/[\w+\.~-]+@[\w~-]+.[\w\.]+/ - match emails, conforms to RFC 3986 section 3.3
/\+?(\d)?[-|\.|\s]?\(?(\d{3})\)?[-|\.|\s]?(\d{3})[-|\.|\s]?(\d{4})/ - match phone numbers, https://gist.github.com/1009331
Strategies
#!/usr/bin/env ruby
require 'fileutils'
def fail!(msg = "Failure!")
puts(msg)
exit(1)
end
REPOSITORY_URL = 'git://github.com/mxcl/homebrew.git'
PACKAGE_URL = 'http://github.com/mxcl/homebrew/tarball/master'
# Typical way of handling the email in the controller
class UsersController < ApplicationController
def create
@user = User.new params[:user]
UserMailer.deliver_welcome(@user) if @user.save
end
end
cd ~/Library/Application\ Support/Firefox
git init
git add .
git commit -m "Saving FF3 Profile."
git checkout -b ff3.5
open /Applications/Firefox3.5
(close Firefox3.5)
git commit -m "Saving FF3.5 Profile."
git checkout master
open /Applications/Firefox
# This is a mechanism we use often in our migrations. When we have a migration
# that hits every record of a large table, this looping mechanism takes the
# bite away from the migration. This allows us to be transactional in our
# migration while avoiding aggressive locking of the table. Ultimately
# allowing us to do migratory deployments even more frequently during high
# usage areas of the day.
#
# Further, some long migrations that we'd run over a weekend may exceed the
# max transaction time set on our MySQL server. Running smaller transactions
# avoids this sensible restriction.
# haml + liquid example
#
# James MacAulay 2009
require 'rubygems'
require 'liquid'
require 'haml'
template = <<EOF
class Nav
def self.padded_selector(sel, max_len)
sel.ljust(max_len)
end
attr_accessor :id, :height, :items, :image
def initialize(attrs={})
attrs.each { |k,v| send("#{k}=", v) }
end