Skip to content

Instantly share code, notes, and snippets.

View ygmpkk's full-sized avatar
😬
No more monkeys jumping on the bed

Timothy ygmpkk

😬
No more monkeys jumping on the bed
  • didi
  • Hangzhou
View GitHub Profile
@ygmpkk
ygmpkk / client.py
Created October 5, 2015 14:51 — forked from mattbennett/client.py
Greenthread worker
import eventlet
eventlet.monkey_patch()
from eventlet.greenpool import GreenPile
from kombu.pools import producers
from kombu import Exchange, Queue
exchange = Exchange('exchange', type='direct')
queue = Queue('queue', exchange, routing_key='queue')
export VIRTUAL_ENV_DISABLE_PROMPT=1
ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX="("
ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX=")"
function virtualenv_prompt_info() {
if [ -n "$VIRTUAL_ENV" ]; then
if [ -f "$VIRTUAL_ENV/__name__" ]; then
@ygmpkk
ygmpkk / ElasticSearch.sh
Last active September 4, 2015 09:47 — forked from ricardo-rossi/ElasticSearch.sh
Installing ElasticSearch on Ubuntu 14.04
#!/bin/bash
### USAGE
###
### ./ElasticSearch.sh 1.7 will install Elasticsearch 1.7
### ./ElasticSearch.sh will fail because no version was specified (exit code 1)
###
### CLI options Contributed by @janpieper
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch
@ygmpkk
ygmpkk / Dockerfile
Created February 23, 2015 09:55
dockerfile source list
FROM ubuntu:14.04
ENV DEBIAN_FRONTEND noninteractive
##///*******************************************************/
##//------------------------
## append apt mirror for ubuntu, update & install
##//------------------------
## RUN sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list
RUN echo "deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse" > /etc/apt/sources.list
RUN echo "deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse" >> /etc/apt/sources.list
RUN echo "deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse" >> /etc/apt/sources.list
@ygmpkk
ygmpkk / sslocal.service
Created February 22, 2015 08:16
ShadowSocks Client Systemd Service
[Unit]
Description=Daemon to start Shadowsocks Client
Wants=network-online.target
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/sslocal -c /etc/shadowsocks/client.json --pid-file /var/run/sslocal.pid --log-file /var/log/sslocal.log
[Install]
@ygmpkk
ygmpkk / Makefile
Created January 28, 2015 01:38
批量编译gitbook和hg pull & update
all:
find . -name '[sS]_[mM]_*' -depth 1 -exec gitbook build {} -o dist/{} \;
dirs = $(shell for file in `find . -name '[sS]_[mM]_*' -depth 1`;do echo $$file; done)
one:
@$(foreach i, $(dirs), cd $(i) && hg pull -u && cd ..;)
clean:
rm -rf ./dist/*
@ygmpkk
ygmpkk / master.vim
Created February 17, 2014 05:13 — forked from gmccreight/master.vim
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)
@ygmpkk
ygmpkk / server.py
Created November 22, 2013 05:20
RABBIRMQ
#连接rabbitmq服务器
connection = pika.BlockingConnection(pika.ConnectionParameters(
host='host'))
channel = connection.channel()
#定义队列
channel.queue_declare(queue='test_queue')
channel.queue_bind(exchange='test_exchange',
queue='test_queue',
routing_key='test_route_key')
var ids = document.querySelectorAll(".member_id");
var names = document.querySelectorAll(".member_name");
var output = "", length = ids.length;
for(var i=0; i<length; i++){
output += ids[i].innerHTML.slice(1,-1) + ":" + names[i].innerHTML + "\n";
}
console.log(output);
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
def crc16(data):
if type(data) is tuple:
data = list(data)
crc_polynom = 0x8408
crc_preset = 0xFFFF