一月 22, 2016


安裝 livestreamer

# pip install livestreamer

安裝 ffmpeg

請到 https://www.ffmpeg.org/ 去下載並安裝 ffmpeg

找出節目 .m3u8 鏈結

請參考 http://tylau0.blogspot.com/2014/03/download-rthk-audio-programme-archive.html 一文找出 .m3u8 鏈結,如


http 換成 hlsvariant 然後下載

$ livestreamer “hlsvariant://stmw1.rthk.hk/aod/_definst_/radio/archive/radio1/musiclover/mp3/mp3:20160118.mp3/playlist.m3u8″ best -o 20160118.ts

用 ffmpeg 將 .ts 檔轉成 .mp3

$ ffmpeg 20160118.ts -acodec copy 20160118.mp3


請參考 https://yukhei.wordpress.com/2008/10/05/record_radio_program/ 如何飛走新聞

bash script


* 用 ffmpeg -i 錄出來的會條線(過程中 ffmpeg 回報有錯誤),所以才要去找另外的方法。

Convert mp3 tag to utf8

一月 2, 2014

find . -iname "*.mp3" -execdir mid3iconv -e big5 {} \;
You can replace big5 with gbk, if so needed.

Prerequisite: sudo apt-get install python-mutagen (on Ubuntu).

Writing EXIF data for adapted lens using exiftool

八月 29, 2013

To write EXIF data for my adapted Konica Hexanon 40mm f/1.8 lens I used this command:

exiftool -FNumber="2.8" -MaxApertureValue="1.8" -FocalLength=40 -Lens="Konica Hexanon 40mm f/1.8" PHOTO.JPG

For cameras of other brand you might want to use
-ApertureValue="2.8" instead of (or in conjunction to)

A backup will be made with name PHOTO.JPG_original.

Interestingly the size of edited photo is smaller, so I wonder if some details are lost (I don’t think so, but I haven’t figured out yet).

When I copied the modified JPG back to the card, the camera read the focal length correctly, but f/2.8 appeared as f/2.4… (edit: MaxApertureValue uses APEX values not F-Stops. c.f. http://photo.stackexchange.com/questions/19143/how-can-the-aperture-value-written-in-exif-be-larger-than-the-nominal-limit-of-t)

(Added Feb 15, 2016: To copy tags from one photo to another — http://thomer.com/howtos/copy_exif.html)

Rokkor lens

八月 21, 2013


Some of them can focus at 30 cm (12 inch).

Konica Hexanon lens

八月 19, 2013


These could be found for less than $50, for use with an adapter on m4/3 systems.

Diffraction is the reason we don’t stop down too much

八月 19, 2013



Basic way of backing up Xanga

六月 13, 2013

(Please share if you have a better way) The basic way to archive your Xanga:
1. Sign in (or click forget my “password") and go tohttp://www.xanga.com/private/archives.aspx
2. Generate an archive by clicking the button “Update Your Archives"
3. Wait until they are generated, the time it takes depends on how large is your blog. (Mine is mostly text so it’s done in a few minutes; if you have lots of photos then it will take longer.)
4. Download the zip file(s). That would give you the plain blog, black on white. No # views, but comments will be there.
5. Copy the CSS script from any of your page to see your blog in colour. That is, open up your_name.xanga.com and check out the source code. Copy the block that starts with <style type="text/css"> and ends with </style>, then paste it into your page.

Meanwhile I’m looking for better ways to make it look and feel the same.

Nook HD+ cover

十一月 17, 2012

As opposed to a Google Nexus 7 or Kindle Fire or Apple iPad, the choices for a cover is limited and Barnes and Nobles wants $40 to $45 for one. I’m not paying that, so I decided to make one.

Since my 1st edition Nook is out of order the cover that I bought with it is essentially useless, so my plan is to rip it off and turn it into a new cover for my Nook HD+. Of course the new Nook has more than double the screen estate that means the material from the old cover is good enough for the front, like the smart cover (except it is not smart 😉 ).

Turns out the whole cover is glued not stitched together the two layers (synthetic leather and felt) can be separated easily. However the foam padding hold on to the plastic backing too tightly that I cannot separate it. This means the backings cannot be reused. So I had to use cardboards to make that up. Tools used are box cutter, scissors, Elmer’s glue, super glue, restickable tabs, permenant marker and clips. Elmer’s glue is applied whenever a large area needs to be glued together and super glue comes in when glueing up the corners. The restickable tabs are for mounting the finished cover to the back of the Nook.

I’ve also put some leftover synthetic leather on the right side of the Nook so the power button will not be depressed so easily, and to provide friction when the cover is used as a stand. It holds up the Nook at an angle of 15 degrees or less from vertical, and for anything more you need something heavy at the back (say water bottle) to keep it from sliding. Permenant markers are there to make the strip on the side inconspicuous.

I hope this thing will hold up against use. 🙂

P.S. I wrote something about the Nook HD+ here.

Nook HD+

十一月 11, 2012

(Note: Not everything written here is accurate. I’ll update this post as I find errors. Last updated: Dec 14, 11:30 EST)

This post is just a dump of what I want to say about the Nook HD+ at hand (so it is not organized and not a comprehensive review). For specs look up the web.

Firmware: 2.0.2, automatically updated from 2.0.0 during initial setup after connecting wifi.

No auto brightness; lowest brightness setting pretty easy on eyes for bed time reading.

Bluetooth keyboard does pair but doesn’t work without apps like BlueKeyboard JP (which is only available in Google Play but not Amazon app store nor Nook app store—maybe this is a reason to root it?) Bluetooth mouse works fine with it.

Keyboard (horizontal) as wide as my 12″ laptop

Rooting of Nook HD and HD+ are currently in progress—keep fingers crossed. Thrilled to know Cyanogenmod is coming! (http://www.engadget.com/2012/11/09/barnes-and-noble-nook-hd-tenatively-rooted-for-the-paper-ui-phobic/) (See also http://forum.xda-developers.com/showthread.php?t=1981617)

For PDF reading there are two (free) choices: OfficeSuite and Reader. For some reason the full screen on OfficeSuite is missing 1/16 of the screen. Both don’t offer scroll lock (maybe that’s less of a problem given the large screen. Or maybe not) and both can’t quite handle the NY subway map. After zoom and a few pans both crashes.
(edit Nov 12) Full screen (portrait) in Reader is even worse, with about 2cm total on top and bottom of screen. Landscape mode in Reader is real full screen, showing two pages at a time (OfficeSuite is still 1 page at a time).

You have to pay for ezPDF reader and RepliGo PDF reader; the free mupdf which works on Nook Color and Nook Tablet doesn’t work on the HD variants currently.

Web browser: Portrait

Upper half of the screen

Close-up (portrait):


Close-up (landscape):

Video: mp4 clips downloaded from youtube played well. Youtube videos also played well, and can go full screen but the bottom most 1/16 of the screen is not utilized (landscape). JW Player (a flash player) doesn’t work. Vimeo works (uses Moogaloop player).

Transfer rate (from laptop to Nook) using Camera (PTP) mode is slower (about 3 MBytes/sec). Haven’t tried Media device mode (MTP) on Ubuntu because that involves installing app on laptop but what was provided is a dmg file (for Mac). On Windows (MTP) transfer rate is about 9 MBytes/sec.

Email, calendar and contacts are setup in one shot if you use Google.

Key pitch is close to 19mm in landscape mode—almost the same as the keyboard on my 12″ laptop. (pic)

No CJK keyboard support.

Nook store sucks for many of its apps haven’t updated to support Nook HD and Nook HD+ (i.e. they say they have 10K apps but only a fraction of them is good for the new ones, until the apps are updated). We’ll see how that will improve over the coming month or two. Their search functionality sucks hard too. Searching for “pdf" only returned 1 app whereas there are at least 3 pdf readers out there—I had to search for “reader" instead.

Speaking of the store, you need an account and a credit card to use with it. This maybe annoying to some. Plus you can’t delete your card info like that with iTunes (at least not on the web—maybe you have to call them).

Charger that comes with it has 2A output. When the Nook HD+ is plugged into a laptop, it doesn’t show charging but the orange charging light next to the connector lights up, much like the 1st edition Nook (the e-ink reader with a colour screen). So my guess is it will still charge with computers albeit at a slower rate.

As I owned a refurb 1st edition Nook before and it died after 14 months of use I’m paranoid about warranty. Squaretrade asks $79.99 for a 3-year warranty with accidents like spills and drop (theft not included). Warranty can be purchased within 30 days of purchase of the device. I think this is better than the 2 year protection from either Target or B&N, that costs roughly the same. (edit: Nov 15) Just learned that if you pay by Mastercard you can have warranty extension to 2 years for free. No accident coverage but you don’t have to pay extra. (I believe there’s something similar for Visa card too, but I haven’t checked that out.)

(edit Nov 12) There doesn’t seem like an oleophobic coating like those in cell phones so fingerprints and grease don’t come off easily.

(edit Nov 14) Sideloading apps (no root required) is not that hard once you have the Android sdk setup. Follow (make appropriate changes accordingly) https://nookdeveloper.zendesk.com/entries/21846516-quick-start-for-android-developers and that’s pretty painless, even though that takes a while. Only SDK needs to be downloaded, not the ADT bundle which is 400+MB. Everything else is downloaded through the Android SDK manager. I find it easier to work with Ubuntu as my Windows connects and disconnect my Nook when it’s put in debug mode. I don’t know why.

After sideloading keyboards that type Chinese, I feel better now. I have yet to get BlueKeyboard JP to work, namely I don’t have the .apk files and I can’t find it on my phone that I can copy it to the Nook.

(edit Nov 15) Got bluetooth keyboard to work! BluIME is the key (need rooting). BlueInput doesn’t quite work: it eats up a lot of CPU.

(edit Nov 17) Sideloaded Google Maps and Skitch (from makers of Evernote). Google maps work with offline so you get a gorgeous HD map! Map setting cause it to crash probably because I haven’t rooted it. Evernote is available in Nook App store so you can access it (and Skitch from within Evernote) from the home screen. Not so for Google Maps. If you don’t want to install a launcher, the trick is to open the “Apps" from home screen, then tap and hold the bar with the word “App" on the top and meanwhile pressing volume button. Both volume up and down works, so I prefer volume down because it won’t make noise even if it fails (if it fails you’ll be adjusting your volume). Maybe I should root it and use Amazon App store and then I don’t have to get the .apk files and sideload them from my laptop… (I added this update with the Bluetooth keyboard!) The DIY cover is also done. Together with a Bluetooth keyboard you can edit WordPress posts.

(edit Nov 19) Got (sort of) root using the method described at http://forum.xda-developers.com/showpost.php?p=34129527&postcount=65. Now I can install apps from Amazon App Store! No more side loading.
In more detail, you first go to the first post of the thread and root it. Then follow that post #65 (I’m putting in more details and links here),
<Warning you should backup everything first!>
1. get a file manager that supports root, e.g. ES file manager and sideload it.
2. using the file manager copy NookColor Tools (e.g. here) to /system/app (for this you need to enable write on /system using the file manager)
3. sideload a launcher, e.g. ADW Launcher, so you can see and launch the NookColor Tools from it. Check and uncheck several times the “install non market apps" box. Leave that checked before you move on.
4. Try downloading a test .apk of your choice and see if it installs.
5. Delete the NookColor Tools from /system/app and quit the file manager.
6. Reboot your device (you can just do a “adb reboot")
7. If it doesn’t fall into a reboot loop, then you should be able to install Amazon app store and get it running.

(edit Nov 22) I’m trying to copy some free apps from my phone to the nook, but looks like google now uses encryption so the .apk file is not directly there at /data/app (need root privilege). I can find those apps at /mnt/asec but it’s not a single .apk but a directory. Fortunately for the one app that I want the .apk file is in there. Not sure if that’s true for other apps as well. I can install the .apk found there.

(edit Dec 14) A month into using my Nook HD+ there were two occasions when it just won’t turn on, until you plug it into the charger and give it a zap (it’s not completely discharged, it just went into a coma). Bad luck for me, or other owners have the same issue? Last time I was on firmware ver 2.0.2 and this time 2.0.4… Looks like I have to have my charger with me all the time (good that it’s not bulky).

P.S. As I went to Target and get my Nook HD+, I also see the e-ink one (Simple Touch) with the GlowLight—the one on display looked terrible.

On Moral and National Education (MNE) in Hong Kong

九月 8, 2012

To my friends who want to know why I’m posting (spamming?) a lot of messages on facebook these days, here’s an article by NY times:


News coverage of the hunger strike all over the world can be found in this google map (pins in cyan; pink and yellow for protests again the patriotism class on 1st July and 29th July, resp.): http://plasticnews.wf/2012/09/hunger-strike-coverage/

When we say this is going to brainwash our students, the government says it won’t. After some thoughts, it probably won’t brainwash them. But does that mean it’s okay? No. If government says it won’t, the hidden message could be what it’s teaching is not true, as witnessed in the teaching materials.* Why would we teach something that’s not true to our kids?

Now the government backed down and revoked the 2015 deadline for every school to start teaching the subject. This looks like a small victory for HK people, but I hope that they will not be fooled. Think about it. Till now only a few school stood up and say they are not going to implement it. What about others, especially those pro-Beijing or pro-government schools? How many of our kids will study in those schools?

The back down, which appeared a day before the legislative elections (on Sunday, 9 Sep 2012) is thought by many a way to mitigate the public animosity toward the education plan could hurt pro-Beijing candidates at the polls. Parents concern group recorded the LegCo candidates’ stance on Moral and National Education curriculum. From the list you can see not many say firmly that they support the curriculum. It’s understandable why that is the case. That would mean losing votes. More of the pro-government candidates are vague on their stance. The group also organized a map of the stance of different schools in Hong Kong, for parents’ and alumni’s information. Another student organization Scholarism also ask people to protest against the curriculum, the leader of which is only a 15-year-old high school student.

Arguments I have heard over these weeks also include: if we are teaching something that’s not true to our kids (and government say they are not brainwashed), what would happen is that we teach them how to live with lies, that you would write something in your exam that you do not believe. They will learn to cope with lies, and this is something that will seriously hinders the advancement of our country and our people.

There are also report saying the school management system (a computer system for managing info) has list for students who did not attend the MNE mainland learning trip (which, according to those who attended, covers achievements in mainland like the high speed trains and none of the things on the dark side like the accidents caused by the signal system). How can one say there’s no hidden agenda here?

Another thing I find it crazy is to ask students to assess their peers about their affection towards the country. You can assess me on whether I did the math correctly or not, but affection towards the country? No way. The curriculum guideline suggests that students should feel agitated when they see the national flag. What? One doesn’t need to be taught to love one’s country, right? This is to ask student to fake their feelings.

Oh, one incident that made many HK people furious is the words from our secretary for education Mr. Eddie Ng Hak-kim, who said “the majority of those who remained silent is supportive of the curriculum."  in a TV interview. What a distorted logic! We can’t remain silent any more.

What people attended the protest and hunger strike wanted is government to retract the subject, for we already have moral education, as well as Chinese history (which the education bureau made it a non-core class at the beginning of the millennium** and now not many study and I think it’s a pity). I hope people in HK will not be fooled.

There are more arguments than what I listed here (I’m sure I missed a lot more) and honestly I feel tired of having to read all those news about this MNE every day. This remotely reminds me a comment someone pointed out regarding the June 4th massacre in 1989: “I don’t want my kids to go to the candlelight vigils every year. Rather, I want the government to recognize what happened in 1989 was wrong and make it a holiday for memorial, and my kids can do whatever they want on that day instead of hanging on to it for years to come." I just hope there be fewer incidents like this that we Hong Kong people can focus on what we want to do (obviously going out there on the streets protesting in this hot weather is not fun).

* examples of which can be seen in one of the teaching handbooks, where it says (pardon my translation) “Content (essence?) of the Beijing Consensus – 4. Advanced, selfless and united ruling party" (original, as appeared in the handbook, p.10): “中國模式的內涵 – 四。進步,無私與團結的執政集團"). That’s a blatant lie. At the bottom of the same page, a panel titled “political parties fight against each other and the people suffer" (政黨惡鬥,人民受災) is referring to the US, where democrats and republicans rivaled against each other to be the ruling party, and as a means to canvassing reject the budget proposed by the other party which leads to closure of government and directly affecting daily lives of people. But the problem is, showing the “advantage" of the democratic centralism by giving this example is partial and biased. On the whole the handbook covered mostly the bright side of things, and the dark side like the internet censoring, harmful powdered milk and the crash between two high speed trains are left as an extended reading. (More controversial incidents like the Tiananmen massacre is not even mentioned.)

The handbook I was talking about can be obtained from (sorry, Chinese only): http://nesc.org.hk/main/newsinfo_219.html or

Even this handbook is to be ditched and not used in schools, the millions of taxpayer’s money has already been spent and the (allegedly pro-Beijing) organization who prepared this handbook has benefited from it.

** This is probably why our chief executive say this MNE is the result of 10 years of preparation (國教科是經過十年的蘊釀才推出的).

P.S. This is probably the lengthiest blog I’ve written in English so far. It’s pretty disorganized, I know.