portmaster irc/irssi
portmaster irc/irssi-xmpp
brew install irssi
| class CharFieldNoEmptyString(CharField): | |
| def get_prep_value(self, value): | |
| # Cast empty strings to null before saving to the DB. | |
| value = ( | |
| super(CharFieldNoEmptyString, self) | |
| .get_prep_value(value) | |
| ) | |
| return value or None |
| """ | |
| A demo of creating a new database via SQL Alchemy. | |
| Under MIT License from sprin (https://gist.github.com/sprin/5846464/) | |
| This module takes the form of a nosetest with three steps: | |
| - Set up the new database. | |
| - Create a table in the new database. | |
| - Teardown the new database. | |
| """ |
| """ | |
| Functions for pretty-printing dictionary differences, including an | |
| assert function for testing purposes. | |
| Under MIT License from sprin. (https://gist.github.com/sprin/6034947/) | |
| Example: | |
| a = { | |
| 'key1': 'val1', |
| """ | |
| Unroll a nested dictionary into flat lists. | |
| This might come in handy if you have on your hands a massive, hardcoded, | |
| vertical- and horizontal-screen-spanning lookup map, and you would like to get | |
| it into a tabular format, so you can, for example, load it into a relational | |
| database table. | |
| """ | |
| import sys | |
| import csv |
| """ | |
| A template tag for Django templates which does not allow | |
| non-existent variable errors to fail silently. | |
| Only works for simple lookups, where the variable is | |
| a key in the context. | |
| """ | |
| from django import template | |
| register = template.Library() |
| var VisEventsView = Backbone.View.extend({ | |
| // A Backbone.View extension that allows a View to trigger events when | |
| // it's visibility changes. The view may also listen to its own visibility | |
| // events. | |
| setup_visibility_observer: function() { | |
| // Check if view element is visible when attributes of el change. | |
| var t = this; | |
| _.bindAll(t, 'check_visibility'); | |
| t.visibility_observer = new MutationObserver(t.check_visibility); |
| from threading import local | |
| threadlocal = local() | |
| # foo takes a as an arg, but we can also see it is dependent on x from | |
| # threadlocal if we look in the body. | |
| def foo(a): | |
| return a + threadlocal.x | |
| # bar takes a as an arg, and calls foo on it. Unless we read through the |
| from flask import Flask | |
| app = Flask(__name__) | |
| import datetime | |
| from threading import local | |
| threadlocal = local() | |
| @app.route('/') |
| """ | |
| A demonstration of safe and unsafe ways to write and call Python functions that | |
| take required and optional arguments that are likely to change over time. | |
| Try performing common refactoring operations on the functions such | |
| as adding/removing required/optional args and changing args to and from | |
| required to optional. Also consider combinations of these operations. | |
| The calling patterns marked dangerous are likely to break in some of these | |
| situations, whereas the safe pattern of always calling with keywords |