Skip to content

Instantly share code, notes, and snippets.

View quiver's full-sized avatar

George Yoshida quiver

View GitHub Profile
@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')
@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 \
# 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 / 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
@quiver
quiver / gist:5264557
Created March 28, 2013 16:18
Redis+trie auto complete Ruby program is a copy from http://stackoverflow.com/questions/1958005/redis-autocomplete, authored by Alex. http://en.wikipedia.org/wiki/Trie
require 'rubygems'
require 'redis'
class RedisTrie
TERMINAL = '+'
def initialize(prefix)
@prefix = prefix
@r = Redis.new
end
# vim: set fileencoding=utf8
from tornado import ioloop
import functools
import os
import sys
def start(io_loop, check_time=500):
modify_times = {} # watch list
callback = functools.partial(_reload_on_update, modify_times)
@quiver
quiver / copy_csv
Last active December 15, 2015 04:19
copy null data(tsv/csv) into postgresql
postgres=# copy t(id, name) from '/tmp/data.csv' (format csv) ;
COPY 5
postgres=# select id , name, length(name) from t;
id | name | length
----+--------+--------
1 | food | 4
2 | energy | 6
3 | '' | 2
4 | | 0
5 | |
@quiver
quiver / redis-string-or-hash-insert.py
Last active July 29, 2022 08:39 — forked from mikeyk/gist:1329319
Testing storage of millions of keys in Redis http://instagram-engineering.tumblr.com/post/12202313862/storing-hundreds-of-millions-of-simple-key-value-pairs # major changes - removed pylibmc dependency
#! /usr/bin/env python
import redis
import random
import sys
r = redis.Redis(host = 'localhost', port = 6379)
REDIS_SETGET = False
REDIS_HSET = False
@quiver
quiver / zabbix_api.py
Created February 10, 2013 06:52
Python script to demonstrate usage of Zabbix 1.8 API. Depends on requests module. (http://docs.python-requests.org/) API spec : https://www.zabbix.com/documentation/1.8/api
# vim: set fileencoding=utf8
#
# authenticate with zabbix api server, and retrieve monitored hosts
# specification : https://www.zabbix.com/documentation/1.8/api
#
# $ python zabbix_api.py
import requests
from pprint import pprint
import json
@quiver
quiver / README.md
Created December 16, 2012 09:06
pub-sub based simple message push system. DB : Redis, program : Python

README

pub-sub based simple message push system.

programs

pub.py

  • pub-sub #admin publisher
  • pub-sub #channel_name publisher

sub_admin.py