Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
# -*- coding: utf-8 -*-
#
#author: rex
#blog: http://iregex.org
#filename tr.py
#created: 2010-08-01 20:24
#source uri: http://iregex.org/blog/trie-in-python.html
# escape bug fix by fcicq @ 2012.8.19
@c93614
c93614 / regexp-trie.py
Last active August 29, 2015 14:12 — forked from fcicq/regexp-trie.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
#author: rex
#blog: http://iregex.org
#filename tr.py
#created: 2010-08-01 20:24
#source uri: http://iregex.org/blog/trie-in-python.html
# escape bug fix by fcicq @ 2012.8.19
# https://ruby-china.org/topics/7555
# gem 'fast_trie', :require => "trie"
# encoding: utf-8
class SegTrie
attr_accessor :trie
def initialize
self.trie = ::Trie.new
end

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@c93614
c93614 / tmux.md
Last active August 29, 2015 14:11 — forked from andreyvit/tmux.md

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@c93614
c93614 / majordomo_async.php
Last active August 29, 2015 14:10
Asynchronous client/server in PHP http://zguide.zeromq.org/php:asyncsrv
<?php
// http://zguide.zeromq.org/php:mdcliapi2
/* =====================================================================
* mdcliapi2.c
*
* Majordomo Protocol Client API (async version)
* Implements the MDP/Worker spec at http://rfc.zeromq.org/spec:7.
*
* ---------------------------------------------------------------------
* Copyright (c) 1991-2011 iMatix Corporation <www.imatix.com>
head /dev/urandom | openssl base64 | head -n -1 | cut -b1-16
@c93614
c93614 / dnspod_watcher.py
Created September 12, 2014 09:11
dnspod_watcher.py
# -*- encoding: utf-8 -*-
# Creates a task-bar icon with balloon tip. Run from Python.exe to see the
# messages printed. Right click for balloon tip. Double click to exit.
# original version of this demo available at http://www.itamarst.org/software/
import win32api, win32con, win32gui
import webbrowser
import time, urllib2, threading, re
import logging
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor())
yum remove -y pptpd ppp
iptables --flush POSTROUTING --table nat
iptables --flush FORWARD
rm -rf /etc/pptpd.conf
rm -rf /etc/ppp
arch=`uname -m`
wget http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.4.0-1.el6.x86_64.rpm
yum -y install make libpcap iptables gcc-c++ logrotate tar cpio perl pam tcp_wrappers dkms kernel_ppp_mppe ppp
<?php
function httpGet($host, $base) {
global $index;
//使用fsockopen会导致阻塞
//$fd = fsockopen($host, 80, $errno, $errstr, 3);
$fd = stream_socket_client("{$host}:80", $errno, $errstr, 3, STREAM_CLIENT_ASYNC_CONNECT | STREAM_CLIENT_CONNECT);
$index[$fd] = 0;
$event = event_new();