Skip to content

Instantly share code, notes, and snippets.

View chow1937's full-sized avatar

GuohuiZhou chow1937

View GitHub Profile
@chow1937
chow1937 / mac_os_open_files_limit.md
Created June 11, 2019 03:45 — forked from gembin/mac_os_open_files_limit.md
Mac OS Open Files Limit

Open Files Limit

Changing Limit For Current Session

Most operating systems can change the open-files limit for the current shell session using the ulimit -n command:

ulimit -n 200000

Mac OS X El Capitan

@chow1937
chow1937 / redis-server
Created August 22, 2017 03:07 — forked from nexdrew/redis-server
Example files for running Redis on CentOS 7 (after manual install)
/var/lib/redis/logs/redis.log {
daily
rotate 14
copytruncate
delaycompress
compress
notifempty
missingok
}
@chow1937
chow1937 / generate_traffic.py
Created August 3, 2017 17:48 — forked from m0n5t3r/generate_traffic.py
stats gathering with gunicorn; gstats.py should be run with one sync worker, gunicorn.conf.py should be in your config
#!/usr/bin/env python
import sys
from random import random
from time import sleep
from threading import Thread, active_count
execfile('gunicorn.conf.py')
@chow1937
chow1937 / redis_key_sizes.sh
Created July 18, 2017 07:55 — forked from epicserve/redis_key_sizes.sh
A simple script to print the size of all your Redis keys.
#!/usr/bin/env bash
# This script prints out all of your Redis keys and their size in a human readable format
# Copyright 2013 Brent O'Connor
# License: http://www.apache.org/licenses/LICENSE-2.0
human_size() {
awk -v sum="$1" ' BEGIN {hum[1024^3]="Gb"; hum[1024^2]="Mb"; hum[1024]="Kb"; for (x=1024^3; x>=1024; x/=1024) { if (sum>=x) { printf "%.2f %s\n",sum/x,hum[x]; break; } } if (sum<1024) print "1kb"; } '
}
@chow1937
chow1937 / python_gmt2timestamp.py
Last active March 28, 2017 03:31
Transform GMT time string ( like http date headers) to Unix timestamp.
import time
import calendar
import email.utils as eutils
def gmtstr2timestamp(gmtstr):
"""Transform GMT time string to Unix timestamp.
format:: '%a %d %b %Y %H:%M:%S %Z'
"""
@chow1937
chow1937 / new_task.py
Created February 6, 2017 17:46 — forked from quiver/new_task.py
rabbitmq : dead letter exchange example with python/pika
#!/usr/bin/env python
# http://www.rabbitmq.com/tutorials/tutorial-two-python.html
import pika
import sys
connection = pika.BlockingConnection(pika.ConnectionParameters(
host='localhost'))
channel = connection.channel()
message = ' '.join(sys.argv[1:]) or "Hello World!"
@chow1937
chow1937 / latency.txt
Created November 23, 2016 08:56 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@chow1937
chow1937 / Makefile
Created November 21, 2016 12:28 — forked from kwilczynski/Makefile
Makefile for my Go projects (an example).
SHELL := /bin/bash
REV := $(shell git rev-parse HEAD)
CHANGES := $(shell test -n "$$(git status --porcelain)" && echo '+CHANGES' || true)
TARGET := packer-provisioner-itamae-local
VERSION := $(shell cat VERSION)
OS := darwin freebsd linux openbsd
ARCH := 386 amd64
@chow1937
chow1937 / python_pairwise.py
Last active March 28, 2017 03:07
Generate 2-tuple from a list.
import itertools
def pairwise(seq):
"""All credit to http://stackoverflow.com/a/5389547 ."""
iter_seq = iter(seq)
return itertools.izip(iter_seq, iter_seq)