Skip to content

Instantly share code, notes, and snippets.

@house9
house9 / git-workflow.rb
Created February 4, 2012 01:54
Git Workflow - add/commit/pull --rebase/push
Always start with
# get the latest code
git checkout master
git pull --rebase
# ==============
Setup to work on new branch / feature
You are going to be doing one of two things before adding new changes:
@house9
house9 / create_fk_script_postgres.sql
Created December 2, 2011 15:00
create_fk_script_postgres.sql
select
tables.table_name,
columns.column_name,
('make_fk_unless_exists :' || tables.table_name || ', :' || columns.column_name || ', :' || REPLACE(columns.column_name, '_id', 's')) as code
from information_schema.tables
inner join information_schema.columns
on information_schema.columns.table_name = information_schema.tables.table_name
where tables.table_schema = 'public'
@house9
house9 / select_table_and_columns_from_postgres.sql
Created December 2, 2011 14:51
select_table_and_columns_from_postgres.sql
select
tables.table_name,
columns.column_name
from information_schema.tables
inner join information_schema.columns
on information_schema.columns.table_name = information_schema.tables.table_name
where tables.table_schema = 'public'
and tables.table_type = 'BASE TABLE'
@house9
house9 / routes_link_to_in_rails_console.rb
Created November 12, 2011 23:34
Sample Routes and Links with Rails 3 in the console
# http://railsforum.com/viewtopic.php?id=969
def strip_params
params.each {|key, value| params[key] = value.strip if value.respond_to?(strip)}
end
# Gemfile, run bundle install after adding
gem 'barby'
gem 'chunky_png'
# some code to generate the png file using 3 of 9 barcode style
require 'barby'
require 'barby/barcode/code_39'
require 'barby/outputter/png_outputter'
barcode_value = "099999333"
@house9
house9 / jquery-ajax-coffeescript.coffee
Created June 28, 2011 00:03
jquery-ajax-coffeescript
jQuery ->
console.log "document loaded"
$('form').submit (e) ->
console.log "form submit"
e.preventDefault()
form = this
$.ajax $(form).attr('action'),
type: "POST"
data: $(form).serialize()
@house9
house9 / robocopy_fix.bat
Created June 2, 2011 00:10
robocopy_fix.bat
rem http://weblogs.sqlteam.com/robv/archive/2010/02/17/61106.aspx
robocopy %*
rem suppress successful robocopy exit statuses, only report genuine errors (bitmask 16 and 8 settings)
set/A errlev="%ERRORLEVEL% & 24"
rem exit batch file with errorlevel so SQL job can succeed or fail appropriately
exit/B %errlev%
rem USAGE: just like regular robocopy
@house9
house9 / Simple.Data.MongoDB.openMongo.cs
Created May 3, 2011 23:31
Simple.Data with MongoDB
using Simple.Data;
using Simple.Data.MongoDB;
// connect
dynamic db = Database.Opener.OpenMongo("mongodb://localhost:27017/myDB");
// insert
dynamic user = new ExpandoObject();
user.FirstName = "Joe";
user.LastName = "Smith";
@house9
house9 / AuthorizeForAttribute-Usage.cs
Created April 22, 2011 15:22
AuthorizeForAttribute-Usage.cs
[AuthorizeFor]
public ActionResult Index()
{
// ....
[AuthorizeFor(Roles = "Create, View")]
public ActionResult Create()
{
// ....