Skip to content

Instantly share code, notes, and snippets.

@arsatiki
arsatiki / abtest.py
Created November 26, 2011 09:16
A/B test result computation. Simulation and exact versions.
from __future__ import division
import math
import sys
def gamma(n):
return math.factorial(n - 1)
def h(a, b, c, d):
num = gamma(a + c) * gamma(b + d) * gamma(a + b) * gamma(c + d)
den = gamma(a) * gamma(b) * gamma(c) * gamma(d) * gamma(a + b + c + d)
= /Expenses:Commuting/
(Funds:Commutes) 1 e
@arsatiki
arsatiki / gist:834063
Created February 18, 2011 17:44
jgc's google script
# Script to perform Google searches and extract the domain names of
# the returned results. The order in which the domain names are
# returned is used to determine a ranking between different companies.
# This is the list of domains to look for in Google searches. To
# search for more or different domains simply alter this list. The
# order of this list determines the order in which the results are
# saved.
domains = [ 'foo.com', 'bar.com', 'baz.com' ]
function FindProxyForURL(url, host) {
var socked = ["*.wikipedia.org", "twitter.com"];
var proxied = ["*simpletext.ws", "api.twitter.com"];
var i;
for (i = 0; i < socked.length; i++) {
if shExpMatch(url, socked[i])
return "SOCKS 10.0.2.3:9999";
}
100430 15:25:17 mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
100430 15:25:17 [Warning] '--default-character-set' is deprecated and will be removed in a future release. Please use '--character-set-server' instead.
100430 15:25:17 [Warning] '--default-collation' is deprecated and will be removed in a future release. Please use '--collation-server' instead.
100430 15:25:17 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
100430 15:25:17 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name /var/db/mysql/ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| MyISAM | DEFAULT | Default engine as of MySQL 3.23 with great performance | NO | NO | NO |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| FEDERATED | NO |
def make_array(n, first=True):
return map(make_array, range(n), ()) if first else lambda: n
From be4b3a6b8c59c0a5ca291d40a187f970ccc4084d Mon Sep 17 00:00:00 2001
From: Antti Rasinen <[email protected]>
Date: Fri, 23 Oct 2009 08:21:30 +0000
Subject: [PATCH] Fixed latitude/longitude parsing.
"I assume that you worked out that whole
longitude-latitude thing. I know you get confused
sometimes."
"You're right, you're right. I keep mixing them
from itertools import groupby
from operator import itemgetter
data = [dict(name="Tyler Bennett", id="E10297", salary=32000, department="D101"), ...]
department = itemgetter('department')
for dep, persons in groupby(sorted(data, key=department), department):
print "\nDepartment", dep
print " Employee Name Employee ID Salary Department"
for person in sorted(persons, key=itemgetter('salary'):
from django.core.urlresolvers import get_resolver, RegexURLResolver
root = get_resolver(None)
def print_indented(level, s):
indent = 4 * level * ' '
print indent + s
def print_include_tree(resolver=root, indent_level=0):
name = resolver.urlconf_name