Skip to content

Instantly share code, notes, and snippets.

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
}
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:
# -*- 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
@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.
@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 / wxlayout.py
Created December 22, 2012 15:58
a layout manager for wxwidgets
#!/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
@toddself
toddself / regions.js
Created December 6, 2012 03:51
region manager
(function($, _){
var Region = function(el){
this.el = el;
this.$el = $(el);
};
_.extend(Region.prototype, {
show: function(view){
// clean up...
this.clear();
@toddself
toddself / gist:4198793
Created December 3, 2012 22:40
lame html body
<div id="header"></div>
<div class="background vert_spacer">
<div id="main">
<div id="nav"></div>
<div id="workflow">
<lift:bind name="page_title"><h1 id="page_title"></h1></lift:bind>
<div id="flash_message"></div>
<div id="verify_message"></div>
<div id="user_data"></div>
<div id="section"></div>
@toddself
toddself / gist:4194920
Created December 3, 2012 13:03
default render method
MyBaseView = Backbone.View.extend({
tpl_name: '',
render: function(){
var dfd = $.Deferred();
var template_context = this.model;
if(_.isUndefined(template_context) || _.isFunction(template_context)){
template_context = new (Backbone.Model.extend({}));
}
@toddself
toddself / gist:4072579
Created November 14, 2012 14:58
dummy js app
$(document).ready(function(){
// get info about this page somehow
// this is, by the way, a dumb way to do this
$('head').append($(document.createElement('og:description'))
.html('This page kicks some major butt'));
});