Skip to content

Instantly share code, notes, and snippets.

View chiangbing's full-sized avatar

Bing Chiang chiangbing

View GitHub Profile
@chiangbing
chiangbing / battery.lua
Last active December 19, 2015 00:18
a battery widget for awesome wm.
-- {{{ Battery bar
mybatterybar = awful.widget.progressbar()
mybatterybar:set_border_color(theme.border_normal)
mybatterybar:set_background_color(theme.bg_normal)
mybatterybar:set_color(theme.bg_focus)
mybatterybar:set_width(50)
mytimer = timer({ timeout = 30 })
mytimer:connect_signal("timeout", function()
f = io.popen('acpi -b', r)
@chiangbing
chiangbing / get_bash_var.py
Last active December 18, 2015 11:59
Read variables in bash script by sourcing the file and echoing the variable.
def get_var(srcfile, *variables):
"""Get variables' values from bash shell source file.
Return a dictionary that maps from variable name to its value.
"""
cmd = ". " + srcfile + ";"
for var in variables:
cmd += "echo ${" + var + "};"
proc = subprocess.Popen([cmd], stdout=subprocess.PIPE, shell=True)
@chiangbing
chiangbing / hadoop_streaming_cmd
Created July 4, 2012 02:54
basic streaming command
hadoop jar $HADOOP_HOME/contrib/streaming/hadoop-streaming*.jar \
-input /path/to/input/data/dir \
-ouput /path/to/output/result/dir \
-mapper mapcmd \
-reducer reducecmd \