Skip to content

Instantly share code, notes, and snippets.

@supernifty
supernifty / gist:1219096
Created September 15, 2011 12:18
Python localization
import gettext
import locale
import logging
def init_localization():
'''prepare l10n'''
locale.setlocale(locale.LC_ALL, '') # use user's preferred locale
# take first two characters of country code
loc = locale.getlocale()
filename = "res/messages_%s.mo" % locale.getlocale()[0][0:2]
@supernifty
supernifty / gist:1087170
Created July 17, 2011 04:23
JavaScript task queue
var queue = function() {
var tasks;
return {
start: function( list ) {
tasks = list;
first = tasks.pop();
first();
},
@supernifty
supernifty / profile.php
Created November 9, 2010 07:19
Ultra Simple PHP Profiler
<?php
$_start = 0;
$_subdata = '';
function profile_start() {
global $profile;
if ( $profile ) {
global $_start, $_subdata;
$_start = microtime(true);
$_subdata = '';