Skip to content

Instantly share code, notes, and snippets.

@toddself
toddself / beermath.py
Last active December 10, 2015 01:28
Beer maths!
# Copyright (C) 2010 Todd Kennedy <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@toddself
toddself / measures.py
Created December 22, 2012 16:28
A system for converting between measurement systems
#!/usr/bin/env python
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# -*- coding: utf-8 -*-
"""
APIBase
~~~~~~~~~~~~
Defines APIBase which provides:
:meth:`clean_html`: removes all mark up from text
:meth:`send_status_code`: sends a response object and HTTP status code
:meth:`mk_msg`: formats a message for response
:meth:`ensure_json`: makes sure dict & list are converted to json
class JSONable(object):
""" Mixin for SQLObject classes. Allows you to export the object
as a JSON or dict representation, controlling the data returned
from the call.
You can either provide a list that enumerates the fields that
are visible (meaning that all not listed are hidden) or enumerating
fields that are hidden (meaning that all not listed are visible)
ex:
function pr (){
args=("$@")
git_branch=$(git branch 2>/dev/null | sed -n '/^\*/s/^\* //p')
git pull-request ${args[0]} -b updtr:development -h updtr:$git_branch
}
@toddself
toddself / model.js
Last active December 18, 2015 18:29
/*
* barnstormer
* https://github.com/condenast/barnstormer
*
* Copyright (c) 2013 Condé Nast. All rights reserved.
*/
var sync;
if (typeof define !== 'function') {
// backbone.sync adaptor that uses mongojs to store models
// returns a q.defer().promise
'use strict';
var mongojs = require('mongojs');
var q = require('q');
module.exports = function (method, model, options) {
var app = require('../app');
var d = q.defer();
@toddself
toddself / hub-pull-request.sh
Created September 18, 2013 15:23
Command line pull-request generation with pivotal and github integration.
#/bin/sh
PIVOTAL_ACCESS=
PIVOTAL_PROJECT_ID=
GITHUB_ACCESS=
DEFAULT_BRANCH=development
TO_REPO_OWNER=CondeNast
FROM_REPO_OWNER=CondeNast
11:54:58 ~/src/.../conde/cnt-feature-slideshow:spike-all-slides-styling ☹
↳ npm ls | grep handlebars
│ ├─┬ [email protected]
├── [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
npm ERR! missing: Imager.js@git://github.com/joewillnyc/Imager.js#on-images-replaced-event, required by [email protected]
npm ERR! extraneous: [email protected] /Users/tkenned2/src/conde/cnt-feature-slideshow/node_modules/imager.js
npm ERR! not ok code 0
11:55:03 ~/src/.../conde/cnt-feature-slideshow:spike-all-slides-styling ☹
function vms(){
VMNAME=" "
if [[ -d .vagrant ]]; then
for MACHINE in `ls .vagrant/machines`; do
IDFILE=".vagrant/machines/$MACHINE/virtualbox/id";
if [ -f $IDFILE ]; then
ID=$(cat $IDFILE);
VMNAME=$(vboxmanage list runningvms| grep $ID | awk -F'["_]' '{print $2}');
fi
done