Skip to content

Instantly share code, notes, and snippets.

View andrewmp1's full-sized avatar

Drew Purdy andrewmp1

View GitHub Profile
@andrewmp1
andrewmp1 / to_json.sql
Created October 8, 2012 23:15 — forked from wolph/to_json.sql
Some functions to convert arrays/hstore to json :)
CREATE OR REPLACE FUNCTION escape_json (text) RETURNS text AS $$
SELECT replace($1, '''', '\'''); $$ LANGUAGE SQL IMMUTABLE;
CREATE OR REPLACE FUNCTION to_json(text) RETURNS text AS $$
SELECT escape_json($1) $$ LANGUAGE SQL IMMUTABLE;
CREATE OR REPLACE FUNCTION to_json(KEY text, value text) RETURNS text AS $$
SELECT '''' || to_json($1) || ''': ''' || to_json($2) || ''''; $$ LANGUAGE SQL IMMUTABLE;
@andrewmp1
andrewmp1 / config.ru
Created September 19, 2012 04:40
config.ru for ember rack app
require 'rake-pipeline'
require 'rake-pipeline/middleware'
use Rake::Pipeline::Middleware, 'Assetfile'
# require 'rack/streaming_proxy'
# use Rack::StreamingProxy do |request|
# if request.path.start_with?('/proxy')
# path = request.path
# if request.query_string
# path = "#{path}?#{request.query_string}"
@andrewmp1
andrewmp1 / bulk_bitly.rb
Created July 11, 2012 22:20
bulk_bitly
#Go to bitly.com/a/your_api_key
#Copy your bitly username and bitly api key from that page.
#Open bulk_bitly.rb and put in your username and api_key in.
#The script takes all the links in a file called input.txt and creates a file
#called output.csv. Please look at the format of input.txt and create a text file the same way.
#Running the script bulk_bitly.rb:
#You'll need to install a ruby gem called "bitly".
#$ gem install bitly
#then cd into this folder from your terminal. If the folder is on your desktop do this:
#$ cd ~/Desktop/bitly
@andrewmp1
andrewmp1 / Gemfile
Created April 13, 2012 01:28 — forked from mbleigh/Gemfile
Non-Rails Rackup with Sprockets, Compass, Handlebars, Coffeescript, and Twitter Bootstrap
source "https://rubygems.org"
gem 'sprockets'
gem 'sprockets-sass'
gem 'sass'
gem 'compass'
gem 'bootstrap-sass'
gem 'handlebars_assets'
gem 'coffee-script'
@andrewmp1
andrewmp1 / deploy.rb
Created April 5, 2012 15:31 — forked from ahawkins/deploy.rb
Deploy script for Heroku apps
#!/usr/bin/env ruby
# This is a basic deploy script for Heroku apps.
# It provides a structure you can use to expand on
# and add your own prereqs and deploy tasks.
#
# It basically ensures that:
# 1. There are no uncommited files
# 2. You can ssh to github
# 3. You can connect to heroku