Skip to content

Instantly share code, notes, and snippets.

View MatthewRDodds's full-sized avatar

Matthew Russell Dodds MatthewRDodds

View GitHub Profile
@MatthewRDodds
MatthewRDodds / gist:316e0c34994bc76e07d2
Last active August 29, 2015 14:20
Helpful Postgres Commands Cheat Sheet

Helpful Psql Commands Cheat Sheet

Compiling a list of helpful postgres commands as I use them

See schemas with permissions

\dn+
@MatthewRDodds
MatthewRDodds / gist:e943dc40753a080842f1
Last active August 29, 2015 14:20
Retry Sidekiq Job Synchronously
require 'active_support'
job = Sidekiq::RetrySet.new.to_a[0]
job.item['class'].constantize.new.perform(*job.args)
@MatthewRDodds
MatthewRDodds / gist:b6f7dbc01b4b23d87565
Last active August 29, 2015 14:19
Ruby Converting From String to BSON::ObjectId and From BSON::ObjectId to String
pry(main)> id
=> BSON::ObjectId('5537c5a93338660008010000')
pry(main)> id.to_s # Converting to string
=> "5537c5a93338660008010000"
pry(main)> BSON::ObjectId.from_string id.to_s # Converting from String
=> BSON::ObjectId('5537c5a93338660008010000')
@MatthewRDodds
MatthewRDodds / real-estate-transactions-sample.csv
Last active August 29, 2015 14:17
real-estate-transactions-sample.csv
We can make this file beautiful and searchable if this error is corrected: It looks like row 10 should actually have 12 columns, instead of 2 in line 9.
street,city,zip,state,beds,baths,sq__ft,type,sale_date,price,latitude,longitude
3526 HIGH ST,SACRAMENTO,95838,CA,2,1,836,Residential,Wed May 21 00:00:00 EDT 2008,59222,38.631913,-121.434879
51 OMAHA CT,SACRAMENTO,95823,CA,3,1,1167,Residential,Wed May 21 00:00:00 EDT 2008,68212,38.478902,-121.431028
2796 BRANCH ST,SACRAMENTO,95815,CA,2,1,796,Residential,Wed May 21 00:00:00 EDT 2008,68880,38.618305,-121.443839
2805 JANETTE WAY,SACRAMENTO,95815,CA,2,1,852,Residential,Wed May 21 00:00:00 EDT 2008,69307,38.616835,-121.439146
6001 MCMAHON DR,SACRAMENTO,95824,CA,2,1,797,Residential,Wed May 21 00:00:00 EDT 2008,81900,38.51947,-121.435768
5828 PEPPERMILL CT,SACRAMENTO,95841,CA,3,1,1122,Condo,Wed May 21 00:00:00 EDT 2008,89921,38.662595,-121.327813
6048 OGDEN NASH WAY,SACRAMENTO,95842,CA,3,2,1104,Residential,Wed May 21 00:00:00 EDT 2008,90895,38.681659,-121.351705
2561 19TH AVE,SACRAMENTO,95820,CA,3,1,1177,Residential,Wed May 21 00:00:00 EDT 2008,91002,38.535092,-121.481367
11150 TRINITY RIVER DR Unit 114,RANCHO CORDOV
@MatthewRDodds
MatthewRDodds / gist:04e955bd1bbc77650f6e
Created March 4, 2015 20:04
Restart Dnsmasq on OSX (Homebrew)
sudo launchctl stop homebrew.mxcl.dnsmasq
sudo launchctl start homebrew.mxcl.dnsmasq
@MatthewRDodds
MatthewRDodds / gist:578542d7fbbfada5fe60
Last active August 29, 2015 14:15
Nginx request forwarding problem

I have:

location /some/path {
	proxy_pass http://other_server/;
}

works as expected:

curl http://server.com/some/path
@MatthewRDodds
MatthewRDodds / gist:671d517776422a399d77
Last active August 29, 2015 14:14
Ember Build for dist
docker run --rm -v=$PWD:/usr/src/app visualjeff/ember-cli:0.1.12 bash -c "cd /usr/src/app; npm install; bower install --allow-root; ember build"
docker run --rm -v=`pwd`:/usr/src/app -t visualjeff/ember-cli:0.1.12 /bin/bash -c "cd /usr/src/app; npm install; bower install --allow-root; ember build"
docker run --rm -e "EMBER_ENV=$RAILS_ENV" -v=`pwd`:/usr/src/app visualjeff/ember-cli:0.1.12 bash -c "cd /usr/src/app; npm install; bower install --allow-root; ember build --environment $EMBER_ENV"
docker run --rm -e "EMBER_ENV=qa" -v=`pwd`:/usr/src/app visualjeff/ember-cli:0.1.12 bash -c "cd /usr/src/app; npm install --force; bower install --force --allow-root; ember build --environment $EMBER_ENV"
module FooBar
def foo_bar(arg)
puts arg
super
end
end
module Foo
class Bar
include FooBar
@MatthewRDodds
MatthewRDodds / gist:df0d7b2cec10db7d7714
Last active August 29, 2015 14:14
docker exploration
cd /builds
docker build --tag=tag .
docker run -d tag
docker exec -it container bash
@MatthewRDodds
MatthewRDodds / gist:105b7f55db1ba144343d
Created January 6, 2015 19:10
Super Simple Active Record Example
require 'active_record'
require 'sqlite3'
ActiveRecord::Base.establish_connection( adapter: 'sqlite3', database: ":memory:" )
ActiveRecord::Schema.define(version: 1) do
create_table :articles do |t|
t.string :title
t.date :published_at
t.timestamps