Skip to content

Instantly share code, notes, and snippets.

# Example Backbone.js app in CoffeeScript
# compile on each file save using the coffee bin
# coffee -b -c -w app.coffee
# BACKBONE.JS MODEL
class Blog extends Backbone.Model
sync: -> "noop"
url: ->
@jotto
jotto / download_db_backup.sh
Created December 16, 2010 18:19
scp db file, import it locally
#!/bin/bash
# get yesterdays date
datestring=`date -v"-1d" +%Y%m%d`
filename_gzipped=mydbbackup-$datestring.sql.gz
filename_gunzipped=mydbbackup-$datestring.sql
database_name=mydb
scp somegai@example.com:/home/somegai/backups/$filename_gzipped ~/backups/
gunzip ~/backups/$filename_gzipped
@jotto
jotto / how_to_make_quickbooks_qbo.txt
Created November 3, 2010 19:56
QUICKBOOKS OL-222
Quickbooks OL-222 error help
Quickbooks QBO files are based on the OFX spec.
Instead of reading the spec, here are the actual real
world rules since Intuit doesn't appear to care about documentation or helping.
This is particularly useful if you want to avoid the "OL-222" error when
trying to import your own QBO files.
<STMTTRN>
class SkinnyJeanDb < ActiveRecord::Base
self.abstract_class = true
end
SkinnyJeanDb.establish_connection(:adapter => 'sqlite3', :database => @sqlite_db_path)
class Pageview < SkinnyJeanDb; end
Pageview.count
/* CSS */
$height: 85px;
$width: 700px;
.container { position: relative }
.card {
height: $height;
width: $width;
z-index: 1;
# convert ruby hash to html table
class Hash
def to_html_table
rows=self.collect do |k,v|
"<tr><td>#{k}</td><td>#{v}</td></tr>"
end
"<table border=1 cellspacing=0 cellpadding=3>#{rows}</table>"
end
end
# used for building filtering type links/UI
# extract parameters from url so you can preserve them in new link
# example.com/?val=2&cool=yes => val=2&cool=yes
params.keys.reject{|key|key=~/action|controller/i}.collect{ |key| "#{key}=#{params[key]}" }.join("&")
# need to disable Rails.cache.fetch in test env
# and ActionController::Base.perform_caching doesnt do it
# from http://pivotallabs.com/users/spierson/blog/articles/818-standup-04-30-2009-perform-caching-and-rails-cache-w3c-dtds-and-ie-range-min-max
class BlackHoleStore
def logger
Rails.logger
end
def fetch( *args )
namespace :bundler do
task :install, :roles => :app, :except => { :no_release => true } do
run("gem install bundler --source=http://gemcutter.org")
end
task :symlink_vendor, :roles => :app, :except => { :no_release => true } do
shared_gems = File.join(shared_path, 'vendor/gems/ruby/1.8')
release_gems = "#{release_path}/vendor/gems/ruby/1.8"
# if you don't commit your cache, add cache to this list
%w(gems specifications).each do |sub_dir|
# you'd obviously have more settings somewhere
set :scm, :git
set :repository, "git@github.com:defunkt/github.git"
set :branch, "origin/master"
set :migrate_target, :current
set(:latest_release) { fetch(:current_path) }
set(:release_path) { fetch(:current_path) }
set(:current_release) { fetch(:current_path) }