Skip to content

Instantly share code, notes, and snippets.

View quiver's full-sized avatar

George Yoshida quiver

View GitHub Profile
@quiver
quiver / trie-autocomplete.py
Created April 4, 2013 15:47
trie-based autocomplete using redis/python
# vim: set fileencoding=utf8
'''
References
- http://stackoverflow.com/a/1966188
- http://en.wikipedia.org/wiki/Tree_(data_structure)
$ python suggest.py prefix
'''
import sys
import redis
# http://www.kutukupret.com/2011/05/10/graphing-apachebench-results-using-gnuplot/
# collect data
# $ ab -n 100 -c 4 -g imagemagick.tsv url
# $ ab -n 100 -c 4 -g gd.tsv url
# $ ab -n 100 -c 4 -g imlib2.tsv url
# plot data
# $ gnuplot template.p
# output as png image
set terminal png
@quiver
quiver / gist:8383967
Created January 12, 2014 12:23
compile nginx using same compile option as Amazon Linux
$ sudo yum install -y libunwind perl-ExtUtils-Embed gperftools gperftools-libs gperftools-devel libxslt libxslt-devel GeoIP GeoIP-devel
$ ./configure \
--add-module=./ngx_small_light \
--prefix=/usr/share/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/lib/nginx/tmp/client_body \
--http-proxy-temp-path=/var/lib/nginx/tmp/proxy \
@quiver
quiver / create_dlq.py
Last active September 10, 2018 23:41
aws sqs dead letter queue sample(w/ boto)
# vim: set fileencoding=utf8
# http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/SQSDeadLetterQueue.html
# http://aws.typepad.com/aws/2014/01/amazon-sqs-new-dead-letter-queue.html
import json
import boto
from pprint import pprint
conn = boto.connect_sqs()
q1 = conn.create_queue('test_q1')
CREATE EXTENSION cstore_fdw;
CREATE SERVER cstore_server FOREIGN DATA WRAPPER cstore_fdw;
create foreign table users(
userid integer not null,
username char(8),
firstname varchar(30),
lastname varchar(30),
city varchar(30),
create table users(
userid integer not null,
username char(8),
firstname varchar(30),
lastname varchar(30),
city varchar(30),
state char(2),
email varchar(100),
phone char(14),
likesports boolean,
copy users from '/tmp/s3/allusers_pipe.txt' with null as '' delimiter '|';
copy venue from '/tmp/s3/venue_pipe.txt' delimiter '|';
copy category from '/tmp/s3/category_pipe.txt' with null as '' delimiter '|';
copy date from '/tmp/s3/date2008_pipe.txt' with null as '' delimiter '|';
copy event from '/tmp/s3/allevents_pipe.txt' with null as '' delimiter '|';
copy listing from '/tmp/s3/listings_pipe.txt' with null as '' delimiter '|';
copy sales from '/tmp/s3/sales_tab.txt' with null as '' delimiter '\t';
@quiver
quiver / copy.sql
Created April 19, 2014 09:45
redshift_cstore_fdw
copy users from '/tmp/s3/allusers_pipe.txt' with null as '' delimiter '|';
copy venue from '/tmp/s3/venue_pipe.txt' delimiter '|';
copy category from '/tmp/s3/category_pipe.txt' with null as '' delimiter '|';
copy date from '/tmp/s3/date2008_pipe.txt' with null as '' delimiter '|';
copy event from '/tmp/s3/allevents_pipe.txt' with null as '' delimiter '|';
copy listing from '/tmp/s3/listings_pipe.txt' with null as '' delimiter '|';
copy sales from '/tmp/s3/sales_tab.txt' with null as '' delimiter '\t';
@quiver
quiver / .screenrc
Created July 5, 2014 02:33
screen conf
escape ^Z^\
vbell off
# don't show startup messages
startup_message off
# detach on hangup - if my dial-up session fails, screen will simply
# detach and let me re re-attach later.
autodetach on
@quiver
quiver / waiters-2.json
Created June 1, 2015 01:44
aws cli machinelearning waiter
{
"version": 2,
"waiters": {
"DataSourceAvailable": {
"delay": 30,
"operation": "GetDataSource",
"maxAttempts": 60,
"acceptors": [
{
"expected": "COMPLETED",