Skip to content

Instantly share code, notes, and snippets.

@dombarnes
dombarnes / invoice.rb
Created October 19, 2011 10:11
Invoices App
class Invoice < ActiveRecord::Base
attr_accessible :invoice_date, :company_id, :purchase_order, :vat_rate, :date_sent, :paid, :date_paid;
validate :invoice_date, :company_id, :vat_rate, :date_sent, :presence => true
validate :status, :inclusion => { :in => ['draft', 'sent', 'paid'] }
belongs_to :company
has_many :invoice_items, :dependent => :destroy
accepts_nested_attributes_for :invoice_items, :allow_destroy => true
scope :outstanding, where(:paid => "false")
@dombarnes
dombarnes / gist:1848577
Created February 16, 2012 23:01
brew install postgresql errors
==> Downloading http://ftp.postgresql.org/pub/source/v9.1.2/postgresql-9.1.2.tar.bz2
File already downloaded in /Users/domster83/Library/Caches/Homebrew
/usr/bin/tar xf /Users/domster83/Library/Caches/Homebrew/postgresql-9.1.2.tar.bz2
==> ./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.1.2 --datadir=/usr/local/Cellar/postgresql/9.1.2/share/postgresql --docdir=/usr/local/Cellar/postgresql/9.1.2/share/doc/postgresql --enable-thread-safety --with-bonjour --with-gssapi --with-krb5 --with-openssl --with-libxml --with-libxslt --with-ossp-uuid --with-python --with-perl ARCHFLAGS='-arch x86_64'
./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.1.2 --datadir=/usr/local/Cellar/postgresql/9.1.2/share/postgresql --docdir=/usr/local/Cellar/postgresql/9.1.2/share/doc/postgresql --enable-thread-safety --with-bonjour --with-gssapi --with-krb5 --with-openssl --with-libxml --with-libxslt --with-ossp-uuid --with-python --with-perl ARCHFLAGS='-arch x86_64'
checking build system type... x86_6
@dombarnes
dombarnes / gist:1892164
Created February 23, 2012 10:31
iTunes Gift URL
https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/com.apple.jingle.app.finance.DirectAction/freeProductCodeWizard?code=VOUCHERCODE&mt=8
@dombarnes
dombarnes / gist:3296608
Created August 8, 2012 16:50
Slogger_image.rb output
ruby ~/Projects/Slogger/slogger_image.rb /Users/domster83/Dropbox/ifttt/instagram/f7f9c2aae15e11e193de22000a1d011e_7.jpg
<CGColor 0x7ff19b418b50> [<CGColorSpace 0x7ff19b415130> (kCGColorSpaceDeviceRGB)] ( 0 0 0 1 )
@dombarnes
dombarnes / gist:3296669
Created August 8, 2012 17:02
DayOne console error
08/08/2012 18:01:02.679 Day One[3122]: Could not find image named 'navitem-background-standard'.
08/08/2012 18:01:02.796 Day One[3122]: *** WARNING: -[NSImage compositeToPoint:operation:] is deprecated in MacOSX 10.8 and later. Please use -[NSImage drawAtPoint:fromRect:operation:fraction:] instead.
@dombarnes
dombarnes / .bash_profile
Created March 15, 2013 09:43
Bash alias to switch Software Update Servers
# Switch to Work SUS
alias suwiki="sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate CatalogURL 'http://server.domain.tld:8088/index-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog'"
alias suapple="sudo defaults delete /Library/Preferences/com.apple.SoftwareUpdate CatalogURL"
#!/bin/bash
red='\033[0;32m'
NC='\033[0m'
for D in `find . -type d -maxdepth 1 -mindepth 1`
do
cd $(basename "$D")
echo -e "${red}$(basename "$D"${NC})"
git pull
@dombarnes
dombarnes / 0_reuse_code.js
Last active August 29, 2015 14:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@dombarnes
dombarnes / rails_resources.md
Last active August 29, 2015 14:16 — forked from jookyboi/rails_resources.md
Rails-related Gems and guides to accelerate your web project.

Gems

  • Bundler - Bundler maintains a consistent environment for ruby applications. It tracks an application's code and the rubygems it needs to run, so that an application will always have the exact gems (and versions) that it needs to run.
  • rabl - General ruby templating with json, bson, xml, plist and msgpack support
  • Thin - Very fast and lightweight Ruby web server
  • Unicorn - Unicorn is an HTTP server for Rack applications designed to only serve fast clients on low-latency, high-bandwidth connections and take advantage of features in Unix/Unix-like kernels.
  • SimpleCov - SimpleCov is a code coverage analysis tool for Ruby 1.9.
  • Zeus - Zeus preloads your Rails app so that your normal development tasks such as console, server, generate, and specs/tests take less than one second.
  • [factory_girl](h
@dombarnes
dombarnes / css_resources.md
Last active August 29, 2015 14:16 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides