This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
logging.basicConfig(level=logging.ERROR, format='%(asctime)s %(levelname)s %(name)s %(message)s') | |
logger = logging.getLogger({"__main__":None}.get(__name__, __name__)) | |
import unittest, nose | |
def test_log(): | |
print "level", logger.getEffectiveLevel() | |
logger.debug("debug") | |
logger.info("info") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf8 -*- | |
import web | |
urls = ( | |
'/test/mío','Blah', | |
'/test/mio','Blah', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
drop table if exists a; | |
begin; | |
create table a (n int); | |
insert into a values (1); | |
analyze a; | |
/* it's there */ | |
select schemaname, relname, last_vacuum, last_autovacuum, last_analyze from | |
pg_stat_user_tables where last_analyze is null and relname = 'a'; | |
commit; | |
analyze a; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ########################### | |
set up table and populate it | |
############################# */ | |
DROP TABLE IF EXISTS t; | |
CREATE TEMP TABLE t (k varchar, v varchar); | |
INSERT INTO t VALUES ('1', 'a,b,c'); | |
INSERT INTO t VALUES ('1', 'a,d,e'); | |
INSERT INTO t VALUES ('2', 'e,f'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table t (f1 int); | |
create table t1 (CHECK (f1 < 100)) INHERITS (t); | |
select 1 into t1; | |
/* gives ERROR: relation "t1" already exists */ | |
/* is this the expected solution? */ | |
insert into t1 (select 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
simple simulation of the wire card game, version 0 | |
""" | |
import random | |
def roll(n=1,d=6): | |
return sum((random.randint(1,d) for x in xrange(n))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/**************************** | |
* Unexpected result: | |
* analyzing this empty table doesn't update last_analzye in pg_stat_all_tables | |
*****************************/ | |
drop table if exists a; | |
create table a (exists int); | |
analyze a; | |
select relname,last_analyze from pg_stat_all_tables where relname = 'a'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
description = ''' | |
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6^(th) prime is 13. | |
What is the 10001^(st) prime number? | |
''' | |
# modifying our sieve | |
from __future__ import division |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def pr(x): | |
sys.stdout.write(str(x)+"\n") | |
def gen_primes_1a(): | |
seq = count(2) | |
seq = ((x,0) for x in seq) | |
while True: | |
p,old = seq.next() | |
seq = ((x,pr("%i over %i" %(x,p))) for (x,blah) in seq if x%p) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Actor1(object): | |
def __init__(self,first,last): | |
self.first = first | |
self.last = last | |
class Actor2(Actor1): | |
def __str__(self): | |
return "%s %s %s" % (self.__class__, self.first, self.last) | |
OlderNewer