Skip to content

Instantly share code, notes, and snippets.

View xfguo's full-sized avatar
🎯
Focusing

Xiongfei(Alex) GUO xfguo

🎯
Focusing
View GitHub Profile
@xfguo
xfguo / print_r.lua
Last active August 29, 2015 14:01 — forked from nrk/gist:31175
A function in Lua similar to PHP's print_r
-- A function in Lua similar to PHP's print_r, from http://luanet.net/lua/function/print_r
function print_r ( t )
local print_r_cache={}
local function sub_print_r(t,indent)
if (print_r_cache[tostring(t)]) then
print(indent.."*"..tostring(t))
else
print_r_cache[tostring(t)]=true
if (type(t)=="table") then
@xfguo
xfguo / geventfd.py
Created November 4, 2012 03:32 — forked from wolever/geventfd.py
Simple wrapper around a file descriptor which will perform non-blocking reads/writes using gevent
import os
import fcntl
from gevent.socket import wait_read, wait_write
class GeventFD(object):
""" Wrap a file descriptor so it can be used for non-blocking reads and writes with gevent.
>>> stdin = GeventFD(sys.stdin.fileno())
>>> stdin.read(5)
'hello'