Protected: Let’s begin!

This content is password protected. To view it please enter your password below:

Grabbing website snapshots from the waybackmachine and save as pdf

I’m recently working on a Critical Discourse Analysis assignment. I’ve chosen a website and trying to compare the different versions of the same site over time using the waybackmachine.

In order to have a better overview I’m trying to convert and capture the site as pdf file, and I’ve found this useful gem app (wkhtmltopdf) which converts a site to pdf.

To convert a single webpage the syntax is quite simple. In Terminal, just type

wkhtmltopdf --zoom 2.8 --page-size A4 <url> <filename>

However I’m trying to download multiple snapshots so I found another tool. “Wayback Machine Downloader”

I then save all the urls in one text file and the corresponding filenames in another text file. Wrote a simple bash script

for i in {0..12}
 wkhtmltopdf --zoom 2.8 --page-size A4 ${arr[$i]} ${pdfName[$i]}
 #echo ${arr[$i]}

Then simply run the script and the sites are being downloaded as pdf file. Lots of fun 🙂

Took me an hour because of some bash syntax for “:” (colon) in an array…

Another little project- RFID Python

In Introduction to Programming course, students are required to complete a project that solve a problem they investigated. One of the tool/gadget we provided is an RFID reader.

A year ago when we ran the course a group of student found out keeping the track running time is a huge challenge for the PE department. An RFID reader was purchased for students to solve this problem.

One critical challenge was the communication between the RFID reader and python. In order to solve it the serial connection has to be established and the data has to be interpreted.

As this is still an introductory level course, students are asked to focus on the data processing part and assume that there will be a function acquiring the RFID and they need to handle the logic. In other words, the hardware and serial communication part has to be written for them.

After weeks we finally have a solution!

Library used: pySerial, codec
Python version: 3.5 or up

Here’s the code, more information to come

import serial, sys, time
import codecs

ard = None

def getCardId(rawCode):
    headerStr = "1b390100110010603000"
    returnId = -1
        decodestr = codecs.encode(rawCode, 'hex')
        returnId = str(decodestr).split(headerStr)[1]
        return returnId
        return -1

def initReader():
    global ard
    port = '/dev/tty.SLAB_USBtoUART'
    ard = serial.Serial(port, baudrate=115200,timeout=5)

def readRfid():
    global ard
    rawCode =
    return getCardId(rawCode)


#an infinite loop that reads the rfids
while True:

Fun problem solving for LightLogo

It has been a while since I post anything here and it feels great when I have something to share :)- Geeky content warning~

So Brian and I are both very much into playful invention and we’ve been working together on various projects. Recently I helped him ordered 30 Arduinos and some neopixel ring from mainland China. The Arduino board is a clone so it is not using the USB-Serial chip (FDTI compatible) comes with the original Arduino. It uses something called CH340 and the driver could be found here.

Brian is using LightLogo  as the platform for students to apply their logo code on some tangible hardwares. The package from the site doesn’t work with the clone, so what’s wrong?


  1. When using the assembler.jar in the lightlogo-vm directory, the TX/RX light on the clone arduino doesn’t work, which suggests that the code cannot be loaded to the board.
  2. When running the LightLogo.jar in the lightlogo directory, an error message “device not found” was shown.
  3. I tried to open the sourcecode using Eclipse (as it is java based), gave me a lot of insight on how LightLogo was written (a bunch of LContext/Function and parameters…), the file that I spent most time on was, which extends the with a function called “usbInit”, but it is an empty method!


  1. In Arduino/Processing when I tried to access the serial port I need to specify which port I’m using, in Linux/Mac this is done by referring to a file/device path.
  2. For the original Arduino UNO, according to the Arduino environment (Tools-Ports), the original board has a port name called (cu.usbserial1411), and the “clone” has a port name called “cu.wchusbserial1410”. There are few other ports that we can find in the directory /dev/cu.*
  3. Where in the LightLogo code does it specify the port???

After looking through all the .java file with no luck, I started looking at the assembler.logo file, which is the script written in the logo language, and bingo!

to find-mac-port

dolist [i files "/dev][if member? "cu.usbmodem :i [output :i]]

dolist [i files "/dev][if member? "cu.usbserial :i [output :i]]

output "


Obviously these few lines of code are they key! It is trying to find a port called “cu.usbserial” instead of “cu.wchusbserial”, so “naturally” I modified the code to

to find-mac-port

dolist [i files "/dev][if member? "cu.wchusberial :i [output :i]]

dolist [i files "/dev][if member? "cu.usbmodem :i [output :i]]

dolist [i files "/dev][if member? "cu.usbserial :i [output :i]]

output "


And it worked!

So in order for the LightLogo.jar to run, modify the same code (*Update [11/21/2016]: I should have mentioned the compiler.logo has be changed as well in order for it to work, thanks @briansmith and @tylerbeatty!) and you can download the logo script to Arduino 🙂

Happy problem solving!

*Brian if you read this message can you send me some screen capture/picture of the ring so this post won’t be that dry? Thanks!

Livestreaming with BM TV Studio

We have an ATEM TV Studio Switcher ( in the shop, which allows us to connect up to 9 cameras at the same time with a neat IP based control interface. It sounds like perfect solution for live streaming and event (HDMIs->ATEM TV Studio->Youtube), but challenges surfaced quickly.

The ATEM TV Studio has a USB connector which sends the mixed feed as an H.264 stream, in order to stream a video feed to youtube, we can choose from Wirsecast/FlashMediaLiveEncode (FMLE). Unfortunately, none of them works with the BM ATEM TV Studio Switcher.

Luckily, provide a free livestreaming software called Procaster (, which supports the BM interface out of the box!

We ended up stream the feed through and use OBS (, an opensource broadcasting program as the ultimate solution.

Because the unverified channel can only serve up to 50 people, we use the screen/window capturing function of OBS to capture and re-broadcast the stream to youtube to work around this. Soundflower is being used for redirecting sound from the programme to OBS.

Connection map

Primary stream
Cameras —HDMI/SDI—>BM ATEM TV Studio—USB—>iMac—->Livestream Procaster—> channel

Mirrored stream (through another computer)
Chrome (Opening as a popup)–>OBS–>Youtube

Sound mixing
Another challenge we had was to mix the sound from the sound panel with the SDI video feed supplied by the video company. As the sound panel only provides XLR output and we didn’t have any USB sound capturing device, we used the Sony HDV camera as a XLR->HDMI convertor to the BM ATEM interface. Which worked pretty well.

The cost to go backward…

In this article (The Four Horsemen of the Cyber Apocalypse) , it talks about the possible scenarios that will paralyse digital system. They are certainly valid but I can’t stop thinking of a this question, what is the tipping point for people start to move back to paper-based system?

Given the current database and networking technology, there’s almost no real “safe” system that can be created and left alone without being upgraded. Let alone the attach to cloud based service, for institutes that efficiency is not the top priority, paper based system could be a better solution in terms of security.

In the Silo series written by Hugh Howey, it described a post-apocalypse scenario that the whole human kind lives underground. The “history” of the earth is being modified and changed in the database so no one really know what happened, except for the managements of the silos. This top administrator of the silo has access to physical books, which document the “real history” of the past.

Let alone whether there’s a “real history/reality“, just by thinking about this digital history rewriting scenario is scary enough. There are legal requirements for some institute to keep paper-based record, but is there any company/institute that want to move back to paper-based record/database from a digital system? What is the cost of it? Is there any formula for that?

To boil it down to one question, how much does it cost to convert a database (e.g. MySQL/Postgresql) to a paper-based system?