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 counters ( | |
count_type INTEGER NOT NULL, | |
count_id INTEGER NOT NULL, | |
count INTEGER NOT NULL | |
); | |
-- later to fix the issue | |
ALTER TABLE counters ADD PRIMARY KEY (count_type, count_id); | |
CREATE TABLE primary_relation ( |
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 os | |
import random | |
import time | |
import psycopg2 | |
COUNTERS = 5 | |
THREADS = 10 | |
ITERATIONS = 500 | |
def increment(): |
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 os | |
import random | |
import time | |
import psycopg2 | |
COUNTERS = 5 | |
THREADS = 50 | |
ITERATIONS = 100 | |
def increment(): |
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
# negative correlation x = seq(0,10,0.5) | |
fX = function(x) { return(x) } | |
fY = function(x) { return(-x) } | |
df = data.frame(x=x, fX=fX(x), fY=fY(x)) | |
ggplot(df, aes(x=x)) + geom_line(aes(y=fX), color="green") + geom_line(aes(y=fY), color="blue") | |
cov(df$fX, df$fY) | |
cor(df$fX, df$fY) | |
fX = function(x) { return(x - 5) } |
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
# Aapproximation for the 95th % of clicks per minute given a 25k click rate per | |
# day from viglink. | |
# Assumes that the click rate follows an exponential distribution where | |
# the per-unit time we are using is 1min. | |
viglink.clickrate = 25000 # day | |
rate.min.u = viglink.clickrate/24/60 # min | |
print("rate per minute") | |
rate.min.u | |
# mean of exponential distribution is u = 1/lambda, lambda = 1/u |
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
2013-10-28 17:45:38,991 barman.server INFO: WAL retention policy for server db022: main | |
2013-10-28 17:45:39,219 barman.server INFO: Retention policy for server db018: RECOVERY WINDOW OF 3 DAYS | |
2013-10-28 17:45:39,219 barman.server INFO: WAL retention policy for server db018: main | |
2013-10-28 17:45:39,583 root ERROR: ERROR: Unhandled exception. See log file for more details. | |
Traceback (most recent call last): | |
File "/usr/lib/python2.6/site-packages/barman-1.2.0-py2.6.egg/barman/cli.py", line 453, in main | |
p.dispatch(pre_call=global_config, output_file=_output_stream) | |
File "/usr/lib/python2.6/site-packages/argh-0.23.1-py2.6.egg/argh/helpers.py", line 47, in dispatch | |
return dispatch(self, *args, **kwargs) | |
File "/usr/lib/python2.6/site-packages/argh-0.23.1-py2.6.egg/argh/dispatching.py", line 121, in dispatch |
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
require(ggplot2) | |
require(reldist) | |
require(plyr) | |
# from http://publicpay.ca.gov/Reports/RawExport.aspx | |
# mv 2012_StateDepartment.csv 2012_ca_all.csv | |
# sed '1d' 2012_HigherEd-CAStateUniversity.csv >> 2012_ca_all.csv | |
options(width=1000) | |
allca = read.csv("2012_ca_all.csv", header=T) |
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
#!/bin/bash | |
#CREATE TABLE poky ( | |
#bucket varchar(256) NOT NULL, | |
#key varchar(1024) NOT NULL, | |
#data text, | |
#created_at timestamptz NOT NULL DEFAULT NOW() CONSTRAINT created_at_utc_check CHECK (EXTRACT(TIMEZONE FROM created_at) = '0'), | |
#modified_at timestamptz NOT NULL DEFAULT NOW() CONSTRAINT modified_at_utc_ch |
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 os | |
import multiprocessing | |
import time | |
import lockfile | |
STRING = "A" * 10 | |
def parse(line): | |
a, b, s = line.split() | |
s = s.strip() |
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
SELECT | |
freez::int,age(relfrozenxid) as txns, | |
ROUND(100*(age(relfrozenxid)::bigint/freez::float)) AS perc, | |
n.nspname as "schema" | |
, relname::text as "name" | |
FROM | |
pg_class c | |
LEFT JOIN pg_namespace n on n.oid = c.relnamespace | |
JOIN (SELECT setting AS freez FROM pg_settings WHERE name = 'autovacuum_freeze_max_age') AS foo | |
ON (true) WHERE relkind='r' order by perc ; |