aving written myself numerous UI widgets, from simple to complex, from Windows to Linux, from 2D to 3D… but I’ve just started writing iOS widgets not too long ago. Making iOS widgets is really fun, for we have supports from the most powerful 2D graphics system ever built, that is CoreGraphics (Quartz 2D). The code, hosted on github, is released under MIT license, check it out for a demo project, I hope that these widgets would be useful somewhere, but yes, I know, don’t complain about the code quality, most is written in a rush and still have flaws in it, use at your own discretion!

1.   XFilePathHeader

This tabular header let you quickly browse a hierachy structure (like file system directories). The levels are shown as tabs, tap on a tab to jump to a parent folder, tap on the “Home” icon to jump to root folder.

2.   XSegmentedControl

The Apple’s standard UISegmentedControl only displays text, not image. This class lets you use image along with text (or image or text alone) in any orders (image then text, or text then image).

3.   XProgressTextField

This is a copy of Safari’s address textfield which shows a progress bar while the webpage is loading. Would continue to add more of these miscellaneous tiny widgets just for fun when I have time.

byzero stylus

uch an interesting device I’ve used recently, a stylus for iPad. While stylus like Wacom’s Bamboo is fine for general sketching, it’s not really suitable for fine – grained drawing. This Byzero takes a different approach as it does not use iPad’s touches, but provides its own mechanism. Image on the left: you can see that the pen is actually an ultra sound source, two microphones (and an infrared receiver) in a single piece plugged into the iPad connector port. Pen position detection is done by triangulation on the acoustic signals. This kind of setup can be found on many other things like this 3D laser scanner.

If you use the iPad seriously for taking notes and drawing, a stylus like this is a must, sometimes your thoughts, ideas can only be expressed with a pen: text, drawing and all kinds of presentations on a page. The stylus is sensitive, it can captures any glyphs you draw. However, it’s very irritating that the calibration process is not really exact: pen position is offset – ed by a small varying distance, and with a noticeable delay… This reduces the usability of the stylus much since it’s important to have immediate and correct responses on the screen for user to make micro – adjustments in his hand to produce good writing, drawing.

kindle touch

ell, having played with this “irresistible” Kindle Touch for almost two weeks. The good thing is that I can now continue with my favorite readings on e – ink display like before. The even better thing is that there’s no more clumsy buttons, only “touches”. I’m trying to keep my habit of reserving 4 ~ 6 hours a week for reading, and reading only, no email, no web surf meanwhile, just to be a little bit calm, slow and undistracted. The device now is smaller and fits into my jacket’s pocket so that I can carry it anywhere, just like a small notebook. Image on the left: Kindle Touch, next to an iPad 2 to compare the form – factors.

Updated, Jan 8th

A perfect complement for Kindle touch would be this SolarKindle, a cover and solar charger which would be available on the market next January to eliminate your need for charging a Kindle ever again!


his is part of the really fascinating broader concept of neo – analog as mentioned in a previous post. Below is my handwriting with a stylus on my iPad (click to see large version), not too bad after 10 years of solely keyboard and mouse, not pen, right? Also, I’m quite excited with the coming Kindle touch (which should be delivered at end of the month). My thought is that it’s just a matter of time before e – ink would have color and refresh rate capabilities near those of conventional displays, and serious applications would be feasible within the vintage look and feel of e – ink!

svg morphing

ector graphics has always been my fascinating topic ever since the time of DOS (and Borland C++ 3.1): path, stroke, fill functions… Never really consider JavaScript as “real programming” 😀, but today, we’ve got many of the 2D, 3D capabilities with this language, and sometime we just need to have our idea implemented quick! The little fun below tries morphing the drawing paths, hence transforming one painting into another. Vector graphics are acquired using AutoTrace, the open source tool that helps converting (tracing) bitmap image into vector form (SVG). Loading SVG and morphing paths are easily done with the Raphaël.js library.

Click on the white arrow button to begin animating, click again to reverse the transformation, move mouse over each path to get it highlighted. Click here to see the artist‘s original paintings and finer SVG tracings!

verlet integration

little fun with gaming physic, written using Three.js, the 3D library built ontop of HTML5 and WebGL. Physics engines like ODE or PhysX support a wide range of simulation: rigid body, soft body objects… While those engines are powerful, they are somewhat weak in scalability, e.g: to simulate the flag below, we need to create an array of hundreds of objects, which may not really feasible on small devices.

This demo tries its own physical calculation called Verlet integration: numerical method to apply Newton’s second law of motion to a system of point masses. Verlet integration, despite its complicated formal description, is simple enough to be calculated and executed in real time on the low end mobile devices.

The demo works best on Chrome but it should work on any browser that supports <canvas> (try dragging the flag to add some motion).

game terrain

little technique to create terrains for use in game. Sometimes, we need to create game spaces with: mountain, plain, valley, river… the environment where our game scenes take place. It could be a labour – intensive task unless we can make use of the existing geographic data. Some games like Flight Simulator have the scenes modelled exactly after the real world.

First, we would need a topographic map, typically the height – contour map used in artillery. Nowadays, the SRTM and ASTER GDEM projects provide these data for free in digital format. They are satellite (radar) images of the earth surface with resolution upto 90m for SRTM and 30m for ASTER GDEM. I would recommend the ASTER GDEM for its higher resolution. Go to the site, follow its complicated registration process to download the data via NASA’s ftp server.

The downloaded data would be Zip packages with height info in GeoTIFF format. Next, we would use this MicroDem utility to convert it into PGM, an intermediate format that can be read by Photoshop (or GIMP). Then we save it as heightmap (PNG or TIFF format) which can be imported into most game editors. By now, the terrains are recreated exactly as they appear in our real geographical world. Just apply textures, lighting, water and other stuffs then to make it look good!

Images on the left: 1. topographic data as rendered by MicroDem, 2. heightmap (grayscale image) as viewed by Photoshop, 3. the terrain created and roughly decorated (a low – poly version), here is the Sơn Trà peninsula (or les vallées de mon coeur 😀), the shape, the silhuette that’s long been in my heart!

chẵn và lẻ – chẳng lẽ

Chuyện nó cũng tương tự như với Bám theo lề trái, lề phải là việc của con cừu của giáo sư Ngô Bảo Châu. Người ta cố tình muốn ghép ông vào một bên nào đó, nhưng ông không chọn bên nào cả, cả hai bên đều giống nhau, cùng một kiểu tư duy logic nhị phân cũ rích: không “địch” tức là “ta”, không phải “nhân dân” tức “phản cách mạng”, không tốt tức là xấu, không ngay tức là cong, blahblah… một kiểu trá hình cho cái thật sự là: không giống như tôi (nghĩ) tức là tầm bậy…

Cách suy nghĩ nông dân thiển cận và bần tiện như vậy và những hậu quả trực tiếp của nó tưởng như dễ dàng nhìn thấy, song có rất nhiều người “ngây ngô không hiểu” hoặc không muốn hiểu.

A metaphor for VN software engineering’s status quo, IMHO 😬

Below: Liliputian egg and the metaphor for endianness.

ột ví dụ kinh điển trong làng Tân nhạc để minh họa cho cái tư duy hình thức sơ đẳng và thô thiển phổ biến với người Việt. Cách đây đã lâu, một nhạc sĩ rất có tiếng và có tài sau một thời gian du học ở Liên Xô về đã nói: Văn Cao viết nhạc lẻ nhiều quá!. Thế là bắt đầu một trào lưu âm ỉ và kéo dài nhiều thập kỷ với tư tưởng chủ đạo: phê phán các nhạc sĩ “tiền chiến” sáng tác thiếu chuyên nghiệp, thiếu bài bản, tác phẩm viết ra sao toàn lẻ nhịp. Một thực tế đúng là đến 90% các sáng tác âm nhạc “tiền chiến” là lẻ nhịp.

Và có lẽ cũng đến 90% các tác giả “tiền chiến” là sáng tác ngẫu hứng, tài tử mà nên, chứ ít người thật sự có được huấn luyện trường lớp bài bản (nếu nói về bằng cấp, trường lớp thì e rằng không nước nào bằng Việt nam như hiện tại). Và cũng đúng theo nhạc lý cổ điển (Tây phương) thì nhạc viết ra nên theo luật cân phương, không nên lẻ: để hát nghêu ngao một mình thì không sao, chứ đưa vào ban nhạc, hòa âm, trình diễn lớn sẽ rất khó khăn. “Cái sự lẻ” ở các tác phẩm “tiền chiến” thể hiện những điểm sau:

  • Tác giả đa số là sáng tác ngẫu hứng, ít người có cơ hội tiếp xúc đầy đủ với trường lớp theo kiểu Tây phương.

  • Tuy không bài bản theo kiểu Tây phương nhưng đa số đều mang ảnh hưởng không ít thì nhiều của nền cổ nhạc VN.

  • Sự lẻ nhịp thể hiện tính chất bất ổn của thời đại, một giai đoạn có thể nói là biến động nhất trong lịch sử VN.

Bẵng đi một thời gian, tiếp xúc với âm nhạc thế giới bổng phát hiện ra rằng: âm nhạc Tây phương đương đại cũng lẻ nhịp rất nhiều, rồi quay lại nghiên cứu cổ nhạc VN thì phát hiện ra nó cũng lẻ không kém. Thế là chính những kẻ ngày xưa phê phán người khác “lẻ nhịp” giờ quay sang hô hào: Ah, tui cũng lẻ nhịp, tui đi kịp với thời đại. Đến đây thì mọi người sẽ hiểu ra cái thói tranh luận, cái cách suy nghĩ hình thức VN là như thế nào. Nói chuyện nhạc có vẻ trừu tượng xa vời, quay sang những chuyện cuộc sống hàng ngày, đâu đâu cũng thấy nhan nhản những kiểu tư duy “hình thức” như thế.

Ngay như trong ngành IT mà tôi làm việc, cả ở những dự án lớn nhất, những công ty to nhất, mọi người cũng dành đến 90% thời gian để tranh luận những thứ vô bổ: C hay C++, C++ hay Java, Java hay .Net, nào là Design Pattern hay không, nào là Waterfall model hay Iteration model, nào là Design trước hay Code trước, v.v. Những tranh luận chỉ có thể gặp trong Gulliver du ký: một quốc gia chia thành hai phe uýnh nhau vì một phe ăn trứng từ phía đầu to, phe kia ăn trứng từ phía đầu nhỏ!

Những ai hiểu vấn đề ngay từ đầu chỉ có thể cười mỉm mà thôi, và họ đã đi tới những đâu rồi, code thì vẫn tràn lan những lỗi sơ đẳng kiểu như: mảng (array) bắt đầu từ 0 hay 1 (cũng lại chẵn hay lẻ, có thể các bạn không tin nhưng những lỗi như vậy không ít). Đó là chưa kể một số người không muốn làm việc, ngồi một chỗ bàn chuyện chẵn lẻ, dậm chân cho bụi bay mù rồi tưởng tượng là mình đang chạy! Nói chuyện kỹ thuật sợ mọi người bảo là nó chuyên biệt quá, vấn đề tự lặp lại chính nó trong tất cả những chuyện khác: nhân sự, quản lý, sale… đâu cũng thấy kiểu tư duy như thế.

Có lẻ là do sức lực chỉ vừa đủ dành cho việc nắm bắt một số kỹ năng ngôn ngữ, nên sau khi có được một số danh từ, khái niệm cơ bản… thì họ mắc luôn vào trong đó, không tự vượt lên được. Nó cũng phản ánh một điều, người Việt chúng ta rất háo suy nghĩ hình thức, rất háo những chuyện: tôi là như thế này, người khác là như thế kia, ít người có suy nghĩ độc lập (“độc lập” chứ chưa nói “sáng tạo”), hoàn toàn cảm tính và “bầy đàn”, ít người muốn làm việc, ít người thật sự muốn theo đuổi kiến thức!

the world is not flat

The book title reminds me of the same stupid question: how to put an elephant into a refrigerator. I still insist that you can not put a normal elephant into a normal refrigerator, no matter how people is arguing about that! The question: how to eat an elephant (answer: one bite at a time) actually makes more sense to me!

Friedman is right that there have been dramatic changes in the global economy, in the global landscape; in some directions, the world is much flatter than it has ever been, with those in various parts of the world being more connected than they have ever been, but the world is not flat… Not only is the world not flat: in many ways it has been getting less flat. (Nobel Prize – winning economist Joseph Stiglitz)

The popular expression that a capitalist will even sell you the rope you need to hang him with seems to be becoming increasingly true. Aronica and Ramdoo’s book is an important addition to the literature of globalization and a necessary therapy for all those whose minds have been in touch with Friedman’s glib phrases. (

After reading the book, I got the feeling that Friedman would even sell you the rope to hang yourself (not him) and I’ve thought there’s quite a lot of people who would willingly buy the rope!

would tell you how I usually encounter a dialogue taken place in Vietnamese, a pattern that repeats over and over again, and people never learns a thing, neither do they actually have a little sense about real things behind it. Here’s how the dialogue would go on, taken an example to describe the pattern: A (a certain person): I’ve recently read the book “The world is flat”, and really love it! Ah ha, the world is truly flat!   Me: No, the world is not flat!   A: I would suppose you don’t mean it geographically, think about it like a metaphor to get the philosophy of the book, man!   Me: No, the world is not flat!   A: You never get a thing, you crazy!

By now, anyone with a second thought should recognise my meaning either geographically or metaphorically. After that I asked him something into the content of the book. It turned out he knows almost nothing of the book except its name, and parrots the name as if he had found a “holy truth”! Yes I would certainly understand, while everyone was reading and everyone was saying the world is flat, he wouldn’t dare saying (or even thinking) the opposite. My opinion about the book could be right, or it could be wrong, but actually I won’t argue on the surface of phrases, flat or not flat is just a matter of words, what important is the book’s content.

I’d read through the more than 300 pages of the book which takes its examples, facts… exclusively in the Information Technology contexts, either in India, China or other Asian, Latin countries. It is full of details of only the IT industries, details about out – sourcing, internet, software work flow, email, network phone… the things usually seen in outsourcing service. Obviously the author meant a similarity for other fields, other industries, which seems to be a too restrictive point of view, we all know that IT in fact is only a very small fraction of the economy (taken the VN textile industry alone for an example, its estimated yearly revenue is roughly 12 ~ 15 times bigger than the IT counterpart).

The book concentrates on globalisation: the trends of out – sourcing, the way people communicates, the way firms process information… The author propagates it as “a way to be”, a trend, a life style that is absolutely irreversible. Also Friedman considers open source software the most disruptive force of all of the trends since it allows knowledge to be freely distributed and decentralised efforts could be cooperated. Friedman also encourages young American to become scientists, engineers, mathematicians… leaving low – level labour jobs to other countries. The author also tried to relate those vast details with other profound social and political problems.

I have never read anything so “colonial” like that book. It takes a lot of facts, truths… in a small sector of the economy and tries to provide a biased and exaggerated point of view. To exactly quote the author: When the walls came down, and the windows came up, windows can not come from thin air, there’re always “invisible” walls somewhere, and most of the times, those invisibles are much more overwhelming than the visible ones. In fact the book only receives “warm appreciations” in the field it’s related with, and aiming to, that is IT, it does tremendously receive negative reviews right in the country of its author (you can easily check out the web for that).

The world has never been flat, anywhere, anytime. It’s not flat in the sense of people about their living conditions and standards. It’s not flat in everyone’s mental and psychological status. It’s not flat in different life styles, in people’s hugely diverse definitions and pursuits for happiness. It’s not flat even in the American (or any Western) societies, whose tradition has always been the supporting for personal values, think and do differently. It’s not flat as human as a physical and mental objects are bounded to geological and social constraints, and human is more a complex creature rather than, over copper wires, a piece of (possibly cleverly falsified) transmitted information.


Screenshots of the new Unity desktop. There’s certainly a harsh non – exclusive competing between Unity and GNOME Shell. A proxy war between Ubuntu and Fedora Core, which is in turn a proxy war between Canonical and Red Hat.

Eventually, it’s user experiences that would decide which desktop is best (and best for what), and that’s still a long way to come. But technically, Unity is the first huge bold break from tradition, whose real goal deep inside is replacing completely the age – old heritage of X window system by an OpenGL – based one, a problem partially addressed in my previous post.

am trying Ubuntu’s new desktop introduced lately with Natty Narwhal (11.04). After heavy development phases, Unity has reached its alpha stage, a massive move replacing the GNOME desktop environment by a completely new one written from scratch. I’ve read too many negative reviews about Unity already, but personally I think this is a good move. Developed from Ubuntu’s Netbook Remix (which I didn’t like much, you don’t have to maximize windows like that all the time), switched from Clutter to Compiz 3D windows compositing system (my last experiment with Clutter also hinted potential performance problems), the new Unity shows a huge shift toward Mac’s style desktop. Though there’s still lots of bugs and missing features, a few things can be said about this new Unity.

First, people complains about the break from the norms, some hates Unity because it stops their accustomed habits. The GNOME community (with its long development history) can feel like being betrayed. But for all I knew after some years in graphics, UI design is the job of personality, it’s the task of a small group who decides what is “nice and beautiful”, and which is the way (for other users) to follow, it’s not the task of a committee (that is “People’s Committee” I mean 😬). As a developer, I’m often in the self – conflicting state of wondering what is “nice and beautiful”, modify over and over again some simple UI widgets. It’s no strange that UI always becomes a huge diversity (and problems) for community – driven projects. Key requirements for a UI system in my opinion are: simplicity, consistency and elegance.

For consistency and simplicity, Unity is a big step forward, reasons given that GNOME has become too complex and inconsistent (then how about the much more complex KDE?). Maximized windows have the caption and menu bars all incorporated into the system bar on top, a feature clearly borrowed from Mac, yet further varied and developed. A simple dock bar is positioned on the left, and system menu button doesn’t bring up menu but a searching panel with which you can launch programs, open files… with a few key strokes. I like this much cause it offers a form of GNOME – Do: it’s harder to launch rarely – used items (especially if you don’t remember the names) but it’s more convenient for frequently – used ones. After all, lexical memory is much faster than spatial memory, if one has been trained to that.

One more apparent physical factor is that the vertical screen space is more scarce compared to horizontal space, and 16:9 screens has become quite popular. To conserve useful screen space, UI must make constraints to the caption, menu bars, especially tool bars, there’s even recommendations on eliminating the status bar and minimizing scroll bar at Mark Shuttleworth’s (Canonical’s founder) blog. For scroll bar, that’s quite sure a mimic and modified version taken from iOS. Actually with my recent experiences with Mac and iOS, there’s still a lot of lessons to be learned from these two OSes on how to use space efficiently: remove heavy windows decorations and borders, use lighter UI fonts, smaller and more symbolic icons, design simpler widgets… and in cases even sacrifice some less – used UI features.

The trend of UI becoming simpler and more consistent is quite obvious. Efficient uses of space is the key, but spatial is not all for user experiences: keyboard and mnemonic are also important parts of the learning path (UI effects can be fancy, but over time, people get to love the simplest keystrokes that do the job). The third factor: elegance is even more a topic of debate, people can largely agree to what is simplicity and consistency, but what is aesthetics remains mysterious! Unity claims that it would directly compete Mac on UI designs and user experiences, but my opinion is that its aesthetic aspect is still far behind that of Mac, e.g: Compiz’s effects are numerous, but actually not very fine – tuned compared to the smaller set of animations Mac offers… And even Mac still doesn’t satisfy my eyes in quite many cases…