Skip to content

Instantly share code, notes, and snippets.

View tianchaijz's full-sized avatar
🏠
Working from home

tianchaijz tianchaijz

🏠
Working from home
View GitHub Profile
function print_lua_table (lua_table, indent)
indent = indent or 0
for k, v in pairs(lua_table) do
if type(k) == "string" then
k = string.format("%q", k)
end
local szSuffix = ""
if type(v) == "table" then
szSuffix = "{"
end
#!/bin/bash
# Copyright 2010 Eric Ryan Harrison <me@ericharrison.info>
# Inspired by:
# http://daniel.haxx.se/blog/2010/12/14/add-latency-to-localhost/
if [ -n "$1" ]
then
if [ "$1" = "off" ]
then
tc qdisc del dev lo root

This started out as a fork of the progress bar class which I first hosted on ActiveState Code.

It builds a text progress bar and displays it with the draw() method.

The methods are showcased below:

from progressBar import progressBar

# Initiates the progessBar
prog = progressBar(maxValue = 50)
#!/usr/bin/perl
## 使い方: $ perl simple-fork-httpd.pl [ポート番号(デフォルト8080)]
use strict;
use warnings;
use encoding 'utf8';
use Encode;
use Socket;
@tianchaijz
tianchaijz / lz4.lua
Last active August 29, 2015 14:06 — forked from dansouza/lz4.lua
#!/usr/bin/luajit
local M = {}
local ffi = require "ffi"
ffi.cdef[[
/*
LZ4_compress() :
isize : is the input size. Max supported value is ~1.9GB
return : the number of bytes written in buffer dest
# 2013-03-17 刚才不小心更新了一下 curl
sudo pacman -S curl
# 结果 curl 跪了,所有的 pacman 命令也是
curl: /usr/lib/libc.so.6: version `GLIBC_2.17' not found (required by curl)
curl: /usr/lib/libc.so.6: version `GLIBC_2.17' not found (required by /usr/lib/libcurl.so.4)
# 于是很悲剧地连回滚 curl 都不行,幸好找到了不通过 pacman 命令回滚软件的方式
# https://bbs.archlinux.org/viewtopic.php?pid=1148260#p1148260
zcat /var/cache/pacman/pkg/curl-7.26.0-1-<arch>.pkg.tar.xz | tar xv -C /
@tianchaijz
tianchaijz / example.lua
Last active August 29, 2015 14:06 — forked from mebens/example.lua
require("list")
local a = { 3 }
local b = { 4 }
local l = list({ 2 }, a, b, { 5 })
l:pop()
l:shift()
l:push({ 6 })
l:unshift({ 7 })
### emerge package management (need root access) ###
### "emerge" is a tool manipulating Gentoo's package management tool "Portage" ###
# update portage tree
emerge --sync
# search package
emerge --search pdf
emerge --searchdesc pdf
# Reference: http://www.gentoo.org/doc/zh_cn/gentoo-x86-quickinstall.xml
##########################################################################
##### part 1: boot with gentoo minimal #####
# boot
gentoo
# config network
net-setup eth0
ifconfig
# -*- coding: utf-8 -*-
import os,time
import threading
rlock = threading.RLock()
curPosition = 0
class Reader(threading.Thread):
def __init__(self, res):
self.res = res