Skip to content

Instantly share code, notes, and snippets.

View alexzhang2015's full-sized avatar
🎯
Focusing

alex alexzhang2015

🎯
Focusing
View GitHub Profile
/*
12306 Auto Login => A javascript snippet to help you auto login 12306.com.
Copyright (C) 2011 Kevintop
Includes jQuery
Copyright 2011, John Resig
Dual licensed under the MIT or GPL Version 2 licenses.
http://jquery.org/license
Includes 12306.user.js
@alexzhang2015
alexzhang2015 / LICENSE.txt
Created February 21, 2012 02:10 — forked from aemkei/LICENSE.txt
Binary Tetris - 140byt.es
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# /etc/security/limits.conf
* soft nofile 999999
* hard nofile 999999
root soft nofile 999999
root hard nofile 999999
===========================================================
# /etc/sysctl.conf
# sysctl for maximum tuning
import time
from werkzeug.serving import BaseRequestHandler
class MyFancyRequestHandler(BaseRequestHandler):
"""Extend werkzeug request handler to suit our needs."""
def handle(self):
self.fancyStarted = time.time()
rv = super(MyFancyRequestHandler, self).handle()
return rv
import redis
import threading
class Listener(threading.Thread):
def __init__(self, r, channels):
threading.Thread.__init__(self)
self.redis = r
self.pubsub = self.redis.pubsub()
self.pubsub.subscribe(channels)
@alexzhang2015
alexzhang2015 / gist:7c57e69ceee4d5d13297
Last active August 29, 2015 14:26 — forked from cyx/gist:3690597
Monit Redis
check process redis-server
with pidfile "/var/run/redis.pid"
start program = "/etc/init.d/redis-server start"
stop program = "/etc/init.d/redis-server stop"
if 2 restarts within 3 cycles then timeout
if totalmem > 100 Mb then alert
if children > 255 for 5 cycles then stop
if cpu usage > 95% for 3 cycles then restart
if failed host 127.0.0.1 port 6379 then restart
if 5 restarts within 5 cycles then timeout
@alexzhang2015
alexzhang2015 / gist:3a0c9a16da4d9c04ee85
Created January 20, 2016 08:08 — forked from alinpopa/gist:1281448
elasticsearch analyzer example - Test Queries
# Index
---------------------------------------------------------------------
curl -XPUT http://localhost:9200/pictures/ -d '
{
"settings": {
"analysis": {
"analyzer": {
"index_analyzer": {
"tokenizer": "standard",
@alexzhang2015
alexzhang2015 / docker-1.12.ubuntu.aws.md
Last active August 2, 2016 03:38 — forked from diegopacheco/docker-1.11.ubuntu.aws.md
How to install Docker 1.12 on Ubuntu 14.04 LTS / AWS Ubuntu?
sudo apt-get update -y
sudo apt-get upgrade -y
wget -qO- https://get.docker.com/ | sh
sudo docker run hello-world
dokcer version
@alexzhang2015
alexzhang2015 / happybase_test_put_counter.py
Created August 16, 2016 17:32 — forked from srs81/happybase_test_put_counter.py
Python code to test HappyBase library (HBase), and counter and put speeds
import happybase
import time, random
# Number of test iterations
ITERATIONS = 10000
# Make the HBase connection
connection = happybase.Connection()
# Create the test table, with a column family
@alexzhang2015
alexzhang2015 / supervisord.service
Created March 25, 2017 07:58 — forked from mozillazg/supervisord.service
install and configure supervisord on centos 7.
[Unit]
Description=supervisord - Supervisor process control system for UNIX
Documentation=http://supervisord.org
After=network.target
[Service]
Type=forking
ExecStart=/bin/supervisord -c /etc/supervisord/supervisord.conf
ExecReload=/bin/supervisorctl reload
ExecStop=/bin/supervisorctl shutdown