This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://railsforum.com/viewtopic.php?id=969 | |
def strip_params | |
params.each {|key, value| params[key] = value.strip if value.respond_to?(strip)} | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create new rails app | |
rails new routes_and_stuff | |
cd routes_and_stuff | |
# generate a user scaffold | |
rails generate scaffold user | |
bundle exec rake db:migrate | |
# checkout routes | |
bundle exec rake routes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# replace your_db with the name of your database | |
psql postgres -c "select pg_terminate_backend(procpid) from pg_stat_activity where datname='your_db';" |