Skip to content

Instantly share code, notes, and snippets.

View garbados's full-sized avatar

DFB garbados

View GitHub Profile
@garbados
garbados / start_flask_project.py
Created March 12, 2012 21:22
"startproject"-like script for Flask, to make adding view files easier.
import os, sys
class Setup:
def __init__(self, app_name):
self.app_name = app_name
self.cwd = os.path.join(os.getcwd(), app_name)
try:
print "Creating project folder..."
os.mkdir(app_name)
except OSError:
@garbados
garbados / gist:3091958
Created July 11, 2012 17:45
Nodejitsu 500 error
info: Analyzing your application dependencies in node ./server/app.js
info: Checking app availability RedBull
info: Creating app RedBull
info: Creating snapshot 0.0.1
info: Updating app RedBull
info: Activating snapshot 0.0.1 for RedBull
info: Starting app RedBull
error: Error running command deploy
error: Nodejitsu Error (500): Internal Server Error
error:
@garbados
garbados / gist:3092012
Created July 11, 2012 17:52
packages.json
{
"name": "RedBull",
"description": "Testing environment for Pusher",
"version": "0.0.1",
"dependencies": {
"express": "2.x",
"express-messages": "x",
"redis": "0.x",
"socket.io": "0.x",
"underscore": "1.x",
@garbados
garbados / gist:3092105
Created July 11, 2012 18:12
Nodejitsu dependency error
info: Creating snapshot 0.0.1-2
info: Updating app RedBull
info: Activating snapshot 0.0.1-2 for RedBull
info: Starting app RedBull
error: Error running command deploy
error: Nodejitsu Error (500): Internal Server Error
error: There was an error while attempting to deploy your application.
error:
error: NPM Install failed
error: NPM failed to install dependencies
@garbados
garbados / gist:3092138
Created July 11, 2012 18:19
nodejitsu env set error
info: Welcome to Nodejitsu signedon
info: It worked if it ends with Nodejitsu ok
info: Executing command env set PYTHON /opt/local/bin/python2.7
info: Attempting to load env variables for app /home/garbados/code/red-bull/package.json
error: Error running command env set PYTHON /opt/local/bin/python2.7
error: Nodejitsu Error (500): Internal Server Error
info: Nodejitsu not ok
@garbados
garbados / gist:3092185
Created July 11, 2012 18:27
Nodejitsu failed to install dependencies
info: Creating snapshot 0.0.1-5
info: Updating app RedBull
info: Activating snapshot 0.0.1-5 for RedBull
info: Starting app RedBull
error: Error running command deploy
error: Nodejitsu Error (500): Internal Server Error
error: There was an error while attempting to deploy your application.
error:
error: NPM Install failed
error: NPM failed to install dependencies
@garbados
garbados / gist:4218737
Created December 5, 2012 19:28
jsonize_csv(): quickly turn CSVs into arrays of dicts
"""
I hate CSVs, so this converts them into an array of dicts, with each key-value pair matching that column's header, and the row's value for that column.
"""
def jsonize_csv(fp):
with open(fp, 'r') as f:
headers = f.readline().split(',')[:-1]
lines = []
for line in f:
line = line.split(',')
@garbados
garbados / gist:4499137
Created January 10, 2013 03:17
Backbone DummyView: takes a template and an el and shoves it into the DOM upon instantiation.
var DummyView = Backbone.View.extend({
initialize: function(options) {
this.template = _.template(options.template.html());
this.render();
},
render: function() {
this.$el.html(this.template({}));
}
});
@garbados
garbados / gist:4514450
Last active May 30, 2017 01:28
A Python script providing access to FullContact's API. Requires Requests, and a FullContact API key. Run with `python -i` to make it a CLI. Or, check out `https://github.com/garbados/fullcontact.py` for a more robust interface.
import requests
import json
api_key = 'your_api_key'
url = "https://api.fullcontact.com/v2/person.json"
def whois(**kwargs):
if 'apiKey' not in kwargs:
kwargs['apiKey'] = api_key
r = requests.get(url, params=kwargs)
@garbados
garbados / gist:4591223
Created January 22, 2013 01:27
Coding help w/ Rick
import csv
from collections import Counter
class Reading(object):
def __init__(self, **kwargs):
for k,v in kwargs.iteritems():
setattr(self, k, v)
file_list = [] # list of files
readings = []