Skip to content

Instantly share code, notes, and snippets.

View jberkus's full-sized avatar
💭
Catching up and prepping for Kubecon Shanghai

Josh Berkus jberkus

💭
Catching up and prepping for Kubecon Shanghai
View GitHub Profile
@jberkus
jberkus / gist:132a2be7096b1953d72b
Created July 27, 2015 22:39
Sample script to pull a stream of San Francisco tweets and push them into PipelineDB
from TwitterAPI import TwitterAPI
import psycopg2
from psycopg2.extras import Json
CONSUMER_KEY = 'Get'
CONSUMER_SECRET = 'your'
ACCESS_TOKEN_KEY = 'own'
ACCESS_TOKEN_SECRET = 'API key'
api = TwitterAPI(CONSUMER_KEY,
@jberkus
jberkus / gist:43a74b63921aa58f90c8
Last active September 4, 2015 05:10
Simple stupid function to do python-style dict string replacement.
-- function for doing dictionary-style replacement of varaibles
-- in a SQL string. variables are marked in the text with ${var}
-- and replaced using a json dictionary
create or replace function replace_vars ( somestring text,
vars JSON )
returns text
language plpgsql
immutable
as
# docker compose file for running a 3-node PostgreSQL cluster
# with etcd as the SIS
etcd:
image: quay.io/coreos/etcd
ports:
- "2379"
- "2380"
- "4001"
@jberkus
jberkus / gist:3296689
Created August 8, 2012 17:08
Crash jump
breakpad=# select date_trunc('day', date_processed), count(*) from reports where date_processed between '2012-08-01' and '2012-08-08' group by 1 order by 1;
date_trunc | count
------------------------+--------
2012-08-01 00:00:00+00 | 481349
2012-08-02 00:00:00+00 | 483259
2012-08-03 00:00:00+00 | 480551
2012-08-04 00:00:00+00 | 423422
2012-08-05 00:00:00+00 | 429353
2012-08-06 00:00:00+00 | 508709
2012-08-07 00:00:00+00 | 909945
@jberkus
jberkus / cspace.txt
Created October 16, 2015 02:18 — forked from atman9/cspace.txt
Explain for query taking over 25mins to complete.
SELECT
h2.name AS "objectcsid",
cc.objectnumber,
h1.name AS "mediacsid",
mc.description,
bc.name,
mc.creator creatorRefname,
REGEXP_REPLACE(mc.creator, '^.*\)''(.*)''$', '\1') AS "creator",
mc.blobcsid,
mc.copyrightstatement,
root@dev-postgres:/var/lib/postgresql/pg_repack# make
make[1]: Entering directory `/var/lib/postgresql/pg_repack/bin'
gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -I/usr/include/mit-krb5 -fPIC -pie -DLINUX_OOM_SCORE_ADJ=0 -fno-omit-frame-pointer -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g pg_repack.o pgut/pgut.o pgut/pgut-fe.o -L/usr/lib/x86_64-linux-gnu -lpq -L/usr/lib/x86_64-linux-gnu -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -L/usr/lib/mit-krb5 -L/usr/lib/x86_64-linux-gnu/mit-krb5 -L/usr/lib/x86_64-linux-gnu -Wl,--as-needed -lpgport -lpgcommon -lssl -lcrypto -lkrb5 -lcom_err -lgssapi_krb5 -lz -ledit -lcrypt -ldl -lm -o pg_repack
/usr/bin/ld: cannot find -ledit
collect2: ld returned 1 exit status
make[1]: *** [pg_repack] Error 1
# This dockerfile is meant to help with setup and testing of
# patroni nodes. Unlike the prior docker setup, it relies on
# docker compose to set up multiple nodes.
FROM ubuntu:trusty
ADD . /setup/
RUN /setup/package_install.sh 9.4
@jberkus
jberkus / portlandhouselist.md
Created November 9, 2015 01:14
Looking for Portland House

What we're looking for in a rental house in Portland:

Most stuff below is negotiable; we figure we'll find a place which meets 7 out of 10 criteria.

  • 1400 to 1900 sq. ft.
  • 2 to 3 bedrooms, 1.5 to 2 baths
  • $2100/month or less
  • Near Max or major bus line
  • Unfinished basement or extra-large garage or large garden shed
  • Cats OK
relname <E2><94><82> relnamespace <E2><94><82> reltype <E2><94><82> reloftype <E2><94><82> relowner <E2><94><82> relam
<E2><94><82> relfilenode <E2><94><82> reltablespace <E2><94><82> relpages <E2><94><82> reltuples <E2><94><82> relallvisible <E2><94><82> reltoastrelid
<E2><94><82> relhasindex <E2><94><82> relisshared <E2><94><82> relpersistence <E2><94><82> relkind <E2><94><82> relnatts <E2><94><82> relchecks <E2><94>
<82> relhasoids <E2><94><82> relhaspkey <E2><94><82> relhasrules <E2><94><82> relhastriggers <E2><94><82> relhassubclass <E2><94><82> relispopulated <E2>
<94><82> relreplident <E2><94><82> relfrozenxid <E2><94><82> relminmxid <E2><94><82> relacl <E2><94><82> reloptions
<E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94>
<80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94>
@jberkus
jberkus / badge_prefs.md
Last active December 1, 2015 04:10
badge preferences

##Badge Type

Good: Badge is plastic envelope with paper inside, has cord attachments on both corners to not flip, and is printed on both sides.

Better: Badge is a preprinted, recycleable plastic card printed on both sides (ala DockerCon).

Best: Badge is a little booklet with the summary conference schedule inside. Printed/stickered on both covers with my information.

Fun Alternative: no badges, only name stickers (PyDX).