Skip to content

Instantly share code, notes, and snippets.

View lhwork's full-sized avatar

李焕 lhwork

  • 热酷
  • http://www.gravatar.com/avatar/14cdd9dd97899e09d30ee7b012a73117.png
View GitHub Profile
@cooldaemon
cooldaemon / inproc_vs_message.erl
Created July 28, 2012 12:29
"Erlang Process Message" vs "0MQ Erlang Binding inproc (NIF)"
-module(inproc_vs_message).
-author('cooldaemon@gmail.com').
-export([run/2]).
run(TryCount, SRCount) ->
MPid = spawn_link(fun message_server/0),
RPid = self(),
C = start_zmq(),
@jamikado
jamikado / TLFSprite.as
Created July 24, 2012 03:20
TLFSprite is a Starling extension that provides an alternative to starling.text.TextField to render text from OpenType or TrueType fonts (both device and embedded CFF) using the Text Layout Framework instead of flash.text.TextField
// =================================================================================================
//
// based on starling.text.TextField
// modified to use text layout framework engine for rendering text
//
// =================================================================================================
package starling.extensions
{
import flash.display.BitmapData;
@litaocheng
litaocheng / match_zh.erl
Created May 22, 2012 12:04
从文件中提取中文
%%% 从文件中提取中文, 回答:http://erlangqa.com/382
%%% 假设src.txt内容为:
%%% hello自由 !
%%% 2012年5月22日
%%% cheng
%%%
%%% 执行:
%%% erlc match_zh.erl && erl -noinput -eval "match_zh:run(\"src.txt\"), init:stop()" && cat zh.txt
%%% L1 自由
%%% L2 日
@arantius
arantius / simple-rrd-merge.py
Created March 23, 2012 02:43
A very simple script to merge multiple RRD files, since none of those available seem to work.
#!/usr/bin/env python
"""Simple script to merge multiple RRD files together.
Accepts any number of RRD file names as arguments. Produces an "rrdtool dump"
style file on stdout. The last RRD file should have a slot for every possible
record in the resulting merged RRD.
Run something like:
$ python simple-merge-rrd.py filea.rrd fileb.rrd filec.rrd | \
@grahamking
grahamking / redis_queue.py
Created January 26, 2012 22:54
Celery alternative?
"""Task queue using redis.
Redis client:
LPUSH work "say Hello world!"
LPUSH work "log This goes into syslog"
"""
import redis
from multiprocessing import Pool
@mikeyk
mikeyk / gist:1329319
Created October 31, 2011 22:56
Testing storage of millions of keys in Redis
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
@wangyan
wangyan / sys-mon.sh
Created September 14, 2011 15:13
Monitor system mem and load, if too high, restart some service.
#! /bin/bash
#====================================================================
# sys-mon.sh
#
# Copyright (c) 2011, WangYan <webmaster@wangyan.org>
# All rights reserved.
# Distributed under the GNU General Public License, version 3.0.
#
# Monitor system mem and load, if too high, restart some service.
#
@denik
denik / gevent-multiprocess.py
Created August 25, 2011 04:24 — forked from notedit/gevent-multiprocess.py
gevent-multiprocess
import sys
from gevent import server
from gevent.baseserver import _tcp_listener
from gevent.monkey import patch_all; patch_all()
from multiprocessing import Process, current_process, cpu_count
def note(format, *args):
sys.stderr.write('[%s]\t%s\n' % (current_process().name, format%args))
@fwolf
fwolf / mt-mon.sh
Created August 24, 2011 09:04
Monitor system mem and load, if too high, restart some service.
#! /bin/bash
#====================================================================
# mt-mon.sh
#
# Copyright (c) 2011, Fwolf <fwolf.aide+fwolfbin@gmail.com>
# All rights reserved.
# Distributed under the GNU General Public License, version 3.0.
#
# Monitor system mem and load, if too high, restart some service.
@ouyangzhiping
ouyangzhiping / gist.rb
Created July 8, 2011 15:24
github库修改之后的gist.rb文件
# Copyright 2008 Chris Wanstrath
# Taken from defunkt's gist repository: http://github.com/defunkt/gist/tree/master
require 'open-uri'
require 'net/http'
require 'net/https'
module Gist
extend self