Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am kevinjqiu on github.
  • I am idempotent (https://keybase.io/idempotent) on keybase.
  • I have a public key ASA8HFKJJnSqbA5jfAgQwxSs54LPFrV7ta_mERbrmX1TjQo

To claim this, I am signing this object:

from tests.integration import fixtures
server = fixtures.couch_server()
testdb = server.create('test')
testdb.save(fixtures.get_user_design_doc())
testdb.save(fixtures.get_user_doc('joe', 'hart'))
testdb.save(fixtures.get_user_doc('tim', 'cahill'))
testdb.save(fixtures.get_user_doc('chris', 'smalling'))
FROM node:0.12.2
COPY . /app
RUN npm install -g bower
RUN cd /app; npm install; bower install --allow-root;
WORKDIR /app
VOLUME ["/certs"]
#!/bin/bash
# Most of this is credited to
# https://trac.torproject.org/projects/tor/wiki/doc/TransparentProxy
# With a few minor edits
# to run iptables commands you need to be root
if [ "$EUID" -ne 0 ]; then
echo "Please run as root."
return 1
fi
version: "2"
services:
nginx:
image: nginx
ports:
- "80:80"
links:
- web
command: /bin/bash -c "echo -e 'upstream backend { server web:5000; }\nserver { listen 80; location / { proxy_pass http://backend; }}' > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
web:
import abc
import json
import re
import arrow
def read_entries():
with open('buy.json') as f:
entries = map(json.loads, (line for line in f.readlines() if line))
return entries
@kevinjqiu
kevinjqiu / Chapter2.md
Last active January 26, 2016 02:27
Fluent Python Notes

Chapter 2 An Array of Sequences

list comprehension no longer leaks variables

use * in tuple unpacking.

This can be used to facilitate car, cdr:

import datetime
x = [datetime.timedelta(1), datetime.timedelta(2)]
print(x[0] + x[1]) # datetime.timedelta(3)
print(sum(x)) # TypeError: unsupported operand type(s) for +: 'int' and 'datetime.timedelta'
@kevinjqiu
kevinjqiu / gist:50bd98c2f0c35a750895
Created October 31, 2015 18:12
sum on timedelta
>>> a=[datetime.timedelta(1), datetime.timedelta(2)]
>>> sum(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'datetime.timedelta'
>>> a[0]+a[1]
datetime.timedelta(3)
** Reason for termination ==
** {{badmatch,
{{msg_status,13,
<<247,153,167,208,33,41,98,109,106,45,132,14,79,220,50,7>>,
{basic_message,
{resource,<<"/.../trunk">>,exchange,<<"...">>},
[<<"cardapp.txnfailed">>],
{content,60,none,
<<248,0,16,97,112,112,108,105,99,97,116,105,111,110,47,106,115,111,
110,5,117,116,102,45,56,0,0,0,0,2,0>>,