Skip to content

Instantly share code, notes, and snippets.

View andrewmp1's full-sized avatar

Drew Purdy andrewmp1

View GitHub Profile
@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
@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 / 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 / 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 / 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;
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
var callMethod = function(target, method, args) {
if (Ember.typeOf(method) === 'string') {
method = target[method];
}
return method.apply(target, args);
};
/**
Returns a function, that, when invoked, will only be triggered at most once during a given window of time.
*/
@andrewmp1
andrewmp1 / test_helper.js
Last active December 15, 2015 06:49
Ember testing helper
var testing = function(app){
var container = app.__container__,
appController = container.lookup('controller:application'),
router = container.lookup("router:main");
var helper = {
path: function(){
return appController.get('currentPath');
},
routeName: function(){
@andrewmp1
andrewmp1 / ember_model.js
Last active July 2, 2016 17:36
Ember-data has existed for quite a while and seems to actually have a very good api for interfacing w/ a model. Maybe we should include it in ember.js as a public interface. See introduction.md for more thoughts.
// Ember.Model has slowly developed a stable API. Lets make it an interface.
Ember.Model = Ember.Object.extend(Ember.Evented, {
/**
Reference the original json that created the record.
@method data
@returns {Object} of data used to create the record
*/
data: Ember.K,
@andrewmp1
andrewmp1 / ember_helpers.js
Last active December 17, 2015 21:29
create an object of helper functions for use w/ ember
helpers = function EmberHelpers(App){
var app = App,
container = app.__container__;
var helper = {
routes: function(){
return app.Router.router.recognizer.names;
},
lookup = function(path){
return container.lookup(path);
},