Tuesday, November 2, 2010

My favorite android apps

I have been using android for a month, and I do think it a great OS, from a geek perspective, of cause ;) Since Google does not provide paid app in Chinese market, I got only free apps, however some of them are already great, let me name some of them:

  • AndFTP is a powerful yet easy to use FTP client.
  • Android Terminal Emulator is definitely essential on rooted box (oops, can I call a mobile phone as box just like a PC?) Without it customizing your system would be much tougher.
  • Barcode Scannner by ZXing Team is the fastest scanner I found in market, and recognizing URI with camera is such a great invention!
  • Batteryminder tells me in percentage how much battery left, which is a must on a phone with a power-hungry large screen just like my milestone...
  • diviClock is a cute desktop clock widget offering shortcuts to your alarm clock and calendar
  • NetCounter is used to track how much traffic is spend in a day/week/month because CMCC's traffice is so expensive - 7MB for 1 USD!!!
  • Jorte provides various widget and calendar view, and connects to both Google calendar and a Japanese(?) calendar service.
  • TaskOS To Do List: writing TODO list in voice is great, hopefully web syn feature will be available soon.
  • Vplayer, though still in alpha stage, plays a great range of format of video.

At last I would be very happy if Google brings paid games, though I can get robo defense free and Angry Birds from Chinese market, and they are very interesting (and very time-consuming, too).

Monday, August 2, 2010

web is a mess…where is the hope?

Recently I am helping designing and coding a web site, which I thought would be a small project… I did know about the difference between old IE and other “standard” browsers and some hacks and work-arounds, but I failed to realize it would be so painful to do all things “right”.

In stead of insisting everything should look exactly the same in all browsers, I think it is natual that some design details could degrade in older browsers, like round corners and text shadow. The real troublemaker turns form elements, each browser (depending on the operating system and even system theme) displays them differently – an awful nightmare :( There aren’t any standard to style them, the only solution is to employ JavaScript to hide the original form and render a fake one with div and spans. Thus select element becomes an unsorted list with a CSS’s and scripts, which seems very bizarre…

Maybe it is time to re-invent the web. People have been talking about this for decades, but I see little progress. I don’t believen HTML5 is a solution, though it’s really hot. Semantics is important, but I don’t believe it the key issue. Web pages are no longer simply documents, but applications, and we are distributing service instead of content. JavaScript has many bad parts but is blessed as well, devil or angel, it should be the core of web. HTML should be fundamentally changed to be a better present layer of JavaScript. A lot of functions carried out by browser natively should be given to JavaScript or other future client-side code. With more power and freedom of client code, coding for web could certainly bring more good things to users.

Monday, May 31, 2010

Serving static file in nginx with a some check

Recently I developed  a small web site for my lab, and we are hosting it on Google App Engine (GAE), as Google provides quite enough resources for a site of several pages ;)

However we also need to provide download of huge files, which can not be store in GAE, thus we had to host it in one of our severs. Initially we do not want our content directly accessible, so we want to use dynamic URL but we don’t want to loose the performance of nginx.

My final solution is use rsa module by Sybren A. Stuvel (which is pure python) to encrypt the real url (with fixed private key) in GAE, and give the encrypted url to user. In the file host, I use nginx’s X-Accel-Redirect feature and a tiny cherrypy server to decrypt the url (with corresponding pub key), and simply set the X-Accel-Redirect header to the real internal path of nginx.

This solution works well in my case :)

Wednesday, May 12, 2010

Mount qemu harddisk image in host system

Recently I got to copy a lot of files from a qemu guest, and I think using network is too slow, so I googled for solutions to mount qemu image in host system (when guest is shutdown). And it turns out that only raw images are supported, therefore the first step is to convert the image format:

qemu-img convert –f qcow2 origin.qcow –O raw temp.raw

Then I fount in archlinux wiki that I should mount with –loop,offset=32256 option, but I fail to figure out where 32256 comes. Luckily I remenbered how I delt with dd images. Just get the offset with fdisk:

fdisk –u –l temp.raw

Then I have the sector size (512 in my case) and the offset (2048, start sector of my partation), so the offset should be 512*2048=1048576. (btw, you can calculate with bc: echo ‘512*2048’ | bc)

mount –t ext4 –o loop,offset=1048576 temp.raw /mnt/some-path

That’s it :)

Monday, April 12, 2010

Thursday, April 8, 2010

Link for X, HAL & udev

It seems we could thank HAL for all these years of great work and say goodbye in a short period of time (source below).

To be honest I still feel confused now and then about what (fill this blank) is doing for me. My understanding is:

linux kernel ─>─ udev ─>─ HAL ─>─ X server
                   │                │

So I just try to find more about X/Hal/udev thing, and keep some links here. (Remember the best source of information is always the official web sites and the mailing list).

(Not) blaming HAL by Keith Packard (explains what X.org X server needs from HAL before 1.8)

Manage Linux Hardware with udev by Carla Schroder (tells a little history of udev and HAL, and how /dev, /sys works.)

* source: Free X.org Server 1.8.0 with udev to replace HAL

Friday, April 2, 2010

How to delete last 10 lines in a file with script

I find this question asked very frequently... So here is the present of day(not for the April 1st, it's already 2nd in China now ;)

$ tac file.in | sed '1,10d' | tac > file.out

Obviously, you could replace 10 with any number you like, Cheers!