Skip to content

Instantly share code, notes, and snippets.

View mengzhuo's full-sized avatar

Meng Zhuo mengzhuo

View GitHub Profile
@mengzhuo
mengzhuo / INSTALL.md
Created February 22, 2014 05:32 — forked from sztupy/INSTALL.md

rage-quit plugin for oh-my-zsh

based on rage-quit support for bash

HOW TO INSTALL

Put the files below inside ~/.oh-my-zsh/custom/plugins/fuck

Also chmod a+x the flip command.

import socket,asyncore
class forwarder(asyncore.dispatcher):
def __init__(self, ip, port, remoteip,remoteport,backlog=5):
asyncore.dispatcher.__init__(self)
self.remoteip=remoteip
self.remoteport=remoteport
self.create_socket(socket.AF_INET,socket.SOCK_STREAM)
self.set_reuse_addr()
self.bind((ip,port))
import asyncore
import socket
class EchoHandler(asyncore.dispatcher_with_send):
def handle_read(self):
data = self.recv(8192)
if data:
self.send(data)
@mengzhuo
mengzhuo / queue_client.py
Created April 10, 2014 10:04
ZeroMQ Queue Devices Tutorial
import zmq
import sys
import random
port = "5559"
context = zmq.Context()
print "Connecting to server..."
socket = context.socket(zmq.REQ)
socket.connect ("tcp://localhost:%s" % port)
client_id = random.randrange(1,10005)
@mengzhuo
mengzhuo / forwarder_device.py
Created April 10, 2014 10:07
forwarder_device.py
import zmq
def main():
try:
context = zmq.Context(1)
# Socket facing clients
frontend = context.socket(zmq.SUB)
frontend.bind("tcp://*:5559")
import zmq
def main():
try:
context = zmq.Context(1)
# Socket facing clients
frontend = context.socket(zmq.PULL)
frontend.bind("tcp://*:5559")
@mengzhuo
mengzhuo / .zshrc
Created April 15, 2014 02:24
My ZSH settings
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="agnoster"
# Example aliases
@mengzhuo
mengzhuo / fib.py
Created May 23, 2014 02:30
Fib generator
def fib():
x, y = 0,1
while True:
yield x
x, y = y,x+y
fibgen=fib()
print [fibgen.next() for x in xrange(40)]
#!/usr/bin/env python
# encoding: utf-8
"""
Base57 Module For Encode and Decode
{A..Z} {a..z} {1..9} without
'O o 0 1 l I'which chars easily mistype
"""
# WARNING DON'T CHANGE the BASE
@mengzhuo
mengzhuo / test_sendmail.py
Created July 8, 2014 10:11
Async Task Queue like base on greenlets
from gevent import monkey
monkey.patch_all()
from dns import resolver
from tuck import tuck
def get_mail_server(receiver=''):
user, domain = receiver.split('@')
dest_list = sorted([x.to_text().strip('.').split(' ')