Skip to content

Instantly share code, notes, and snippets.

Ups.planController = SC.TreeController.create(
SC.CollectionViewDelegate,
/** @scope Ups.planController.prototype */ {
content: null,
treeItemChildrenKey: 'actions',
treeItemIsGrouped: YES,
collectionViewShouldBeginDrag: function(view) {
alert("HELLO!");
return NO;
},
Ups.mainPage = SC.Page.design({
// The main pane is made visible on screen as soon as your app is loaded.
// Add childViews to this pane for views to display immediately on page
// load.
mainPane: SC.MainPane.design({
childViews: 'middleView topView bottomView'.w(),
topView: SC.ToolbarView.design({
layout: { top: 0, left: 0, right: 0, height: 36 },
childViews: 'labelView addButton'.w(),
Ups.GridLayout = SC.View.extend({
init: function() {
sc_super();
var childViews = this.get('childViews'), idx, height, width, x, y, top, left, view, heightpct, widthpct;
// calculate height / width percentages
height = this.get('gridlayout').height;
heightpct = 1 / height;
width = this.get('gridlayout').width;
widthpct = 1 / width;
@hexsprite
hexsprite / gist:5789517
Last active December 18, 2015 13:19 — forked from rob-b/gist:3906313
Django Logsna example
from .settings import *
LOGGING['formatters']['logsna'] = {'()': 'logsna.Formatter'}
db_handler = {'level': 'INFO',
'class': 'logging.handlers.RotatingFileHandler',
'filename': here('logs', 'db.log'),
'maxBytes': 4194304,
'formatter': 'logsna',
@hexsprite
hexsprite / gist:5897452
Created June 30, 2013 23:29
lowercase all dictionary keys recursively
def lowerdictkeys(d):
new = {}
for k, v in d.iteritems():
if type(v) == type({}):
v = lowerdictkeys(v)
k = k.lower()
new[k] = v
return new
@hexsprite
hexsprite / gist:8460256
Last active January 3, 2016 11:59
Use OSX Notification to notify when CloudFormation stack is ready to use
while aws cloudformation describe-stacks | grep CREATE_IN_PROGRESS >/dev/null;
do
sleep 1;
done
terminal-notifier -message "Environment Ready"
@hexsprite
hexsprite / gist:8460894
Created January 16, 2014 18:46
SSH Config to login to EC2 hosts using ubuntu user automatically
Host ec2*.compute.amazonaws.com
User ubuntu
def shell_lines(s):
return " ".join([ l.strip() for l in s.splitlines() ])
def local_env(**additional):
return dict(*env.values(), *additional.values())
def choose_from(choices, prompt="Which do you choose?"):
while True:
for index, choice in enumerate(choices):
print "%2d. %s" % (index, choice)
choice = raw_input("\n%s " % prompt)
try:
choice = int(choice)
if choice < 0:
raise ValueError
return choices[choice]
grep -v "==" requirements.txt | grep -v "^#" | awk 'NF > 0' | sort