Skip to content

Instantly share code, notes, and snippets.

View kaihendry's full-sized avatar

Kai Hendry kaihendry

View GitHub Profile
try:
row = list(map(int,row))
except:
print ("Skipping", row)
continue
print(row)
for i, v in enumerate(row):
if not v in [0,1]:
print ("Skipping", row, i, "not a 0 or 1", file=sys.stderr)
continue
@kaihendry
kaihendry / gist:82e22b41b9f2f08cbe53
Last active August 29, 2015 14:08
Hackerspace Internet

Stuck with M1 until 2016-02-09, since we were connected after 3+ month delay due to OpenNET 'capacity issues' on 2014-02-10.

Problems with Internet in Singapore

Using http://hackerspace.sg/ as an example.

Switching cost far too high

Locked into a recurring two year contract. We tried to switch but M1 said we renewed per contract which as a Hackerspace we were unaware of (until it was too late) and we can't get out of. To compound the issue, we are unable to upgrade from 100Mbps to 1Gbps IIUC until 1 year has elapsed of our recurring contract.

# if motion is zero for 5s, blank screen (xset dpms force off), else wake screen (xset dpms force on)
motion () {
# 0 - no motion
# 1 - motion detected
return $(gpio read 7)
}
while true
do
@kaihendry
kaihendry / gist:1708656
Created January 31, 2012 03:51
git submodule
localhost:~$ git submodule update
No submodule mapping found in .gitmodules for path '.vim/bundle/vim-html5'
localhost:~$ cat .gitmodules
[submodule "/home/hendry/.vim/bundle/vim-html5"]
path = /home/hendry/.vim/bundle/vim-html5
url = git@github.com:kaihendry/vim-html5.git
localhost:~$ git submodule init
No submodule mapping found in .gitmodules for path '.vim/bundle/vim-html5'
localhost:~$ ls .vim/bundle/vim-html5
localhost:~$
x220:/srv/www/greptweet/bootstrap$ git checkout v2.0.3
Note: checking out 'v2.0.3'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
@kaihendry
kaihendry / gist:3170423
Created July 24, 2012 14:53
This works well
x220:/srv/www/greptweet$ cat foo.cgi
#!/bin/bash
exec 2>&1
cat <<END
Cache-Control: no-cache
Content-Type: text/html
END
./foo-script.sh & disown
root@x220:/opt/firefox# apt-get remove iceape
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
iceweasel
Suggested packages:
fonts-lyx ttf-lyx latex-xft-fonts xfonts-mathml ttf-mathematica4.1
The following packages will be REMOVED:
iceape iceape-browser
root@x220:/opt/firefox# apt-get remove iceape iceweasel
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package iceweasel is not installed, so not removed
The following extra packages will be installed:
dbus dbus-x11 esound-common galeon galeon-common gconf2 gconf2-common gnome-mime-data gvfs libart-2.0-2 libatasmart4 libaudiofile0 libavahi-glib1 libbonobo2-0
libbonobo2-common libbonoboui2-0 libbonoboui2-common libeggdbus-1-0 libesd0 libgail18 libgconf2-4 libgdu0 libglade2-0 libgnome-desktop-2-17 libgnome-keyring0
libgnome2-0 libgnome2-common libgnomecanvas2-0 libgnomecanvas2-common libgnomeui-0 libgnomeui-common libgnomevfs2-0 libgnomevfs2-common libgudev-1.0-0 libhal-storage1
libhal1 libidl0 libmozjs2d liborbit2 libparted0debian1 libpolkit-backend-1-0 libpolkit-gobject-1-0 libsgutils2-2 mime-support psmisc python python-minimal python2.6
wait_for() # http://stackoverflow.com/questions/11827252
{
np=$(mktemp -u)
mkfifo $np # named pipe needed to get output out of inotifywait
inotifywait -m -e create "$(dirname $1)" > $np 2>&1 &
ipid=$!
while read output
do
if test -p "$1"
then