Skip to content

Instantly share code, notes, and snippets.

@chadmiko
chadmiko / opposite_of_array_intersection.rb
Created June 9, 2017 21:46 — forked from awesome/opposite_of_array_intersection.rb
Ruby opposite of array intersection
# Ruby opposite of array intersection... or maybe the method is missing from my brain bc not enough coffee
# http://twitter.com/soawesomeman/status/8035087261
def awesome(ar_1, ar_2)
(ar_1 + ar_2) - (ar_1 & ar_2)
end
awesome([1,2,3,4], [3,4,5,6]) # => [1, 2, 5, 6]
@chadmiko
chadmiko / gist:85d7d68f88b326522b03d9f2ca17c856
Created April 15, 2016 00:23
Git: Delete all merged branches
git branch --merged | grep -v "\*" | grep -v master | grep -v dev | xargs -n 1 git branch -d
@chadmiko
chadmiko / StandaloneActiveRecordMigrations.rb
Last active August 29, 2015 14:19
Put this in your Rakefile to use migration rake tasks with AR in non-Rails app
require 'bundler/setup'
# From: https://gist.github.com/drogus/6087979
require 'active_record'
include ActiveRecord::Tasks
db_dir = File.expand_path('../db', __FILE__)
config_dir = File.expand_path('../config', __FILE__)
@chadmiko
chadmiko / HOWTO_zcta_shapefile_to_Postgres
Created August 16, 2014 19:00
How to import US ZCTA shapefile into PostGIS-enabled Postgresql db
1. Download US Tigerline ZCTA shapefiles (I pulled entire US, 2013 version at time of this gist)
2. Ensure GDAL is installed w/ postgresql flags
// see http://gis.stackexchange.com/questions/33346/how-can-i-update-ogr2ogr-to-include-the-postgresql-driver
brew uninstall gdal (if installed)
brew install gdal --with-postgresql
3. Convert and import ogr2ogr (my db name is gis_data)
// -nlt MULTIPOLYGON needed b/c it will try to import as regular POLYGON and fail
// NOTE: this will fail if table already exists w/same name (use --append or delete the table to start over)
@chadmiko
chadmiko / .rspec
Created February 5, 2013 06:59 — forked from coreyhaines/.rspec
--colour
-I app

Get Mountain Lion and Homebrew to Be Happy

1) Install XCode 4.4 into /Applications

Get it from the App Store.

2) Install Command Line Tools

In XCode's Preferences > Downloads you can install command line tools.

For those of you who get this error after upgrading to mountain lion:
Installing rmagick (2.13.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/user/.rvm/rubies/ruby-1.9.3-rc1/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
extconf.rb:128: Use RbConfig instead of obsolete and deprecated Config.
checking for /usr/bin/gcc-4.2... no