Saturday, November 29, 2014

The new UISplitViewController, Swift and iOS 7

I was playing around with Swift today and stumbled upon the new awesome UISplitViewController in iOS 8. This enhanced version of the controller makes it work for all iOS devices (originally, it only works with iPads). With the introduction of the "phablet", Apple had to improved their SDK to make it easier for devs to build app that works across all screen sizes. That's a good thing, but a little too late IMHO.

Anyway, back to UISplitViewController, the app created by the Xcode template only works with iOS 8 so I tried to dig in and see if it is possible to support iOS 7 with the same code, same storyboard and everything. It looked like it was possible. Many people tried that, particularly this blog post, but the best solution out there still doesn't have it working smoothly in iPad portrait mode where it should show a button to open the master view in a popup... After a few hours looking around, I finally found the solution and have a demo project available at Check it out now and I hope you find it useful.

Below are some screenshots:

UISplitViewController in iPad/iOS 7: button with text
UISplitViewController in iPad/iOS 8: button with text + arrow

UISplitViewController in iPhone 5s/iOS 7: button with text + arrow
UISplitViewController in iPhone 5s/iOS 8: button with text + arrow

UISplitViewController in iPhone 6+ landscape: fullscreen button

Download demo project here.

Thursday, November 13, 2014

The Cloud

It's such a good feeling to get a new phone and within minutes you have it running exactly as you like, thanks to the Cloud. The Cloud has its up and down ("Nobody understands the Cloud. It's a fucking mystery!"), yes but what else doesn't? Even people have their freaking mood swings.

All major players are improving their offering to tie users to their Clouds because that strategy pulls in customers for them and also helps with competing in the market. And it works. The Cloud comes in many shapes and forms but in general, user experience is way better. Everyone can do whatever they want fast, securely and conveniently (given that they have a decent internet connection of course). I really think the Cloud will be the future. Everything we are going to do will be on the Cloud. The pieces of hardware we have in the house, at our workplaces or in our pockets are just terminals. They could be broken, water damaged or stolen, who cares! Insurance would just replace it with the latest shiniest gear and you are good to go.

It's funny to think how we are going back to something similar to the old days server vs. dumb terminal. At least the terminals are smart now, that's some progress.

Sunday, April 20, 2014

Happy Life it is.

TL;DR #1: Sylvie and I are getting married on July 20th.
TL;DR #2: Graphic designing is freaking hard.

We intended to design a save the date card to announce it to our friends. We searched for ideas with Google Images + Pinterest and ended up with this particular poster design. At first, Sylvie was supposed to design it but she got so busy that she missed the deadline of March 31st. I took over and came up with the very first draft using Adobe Photoshop CC.

The three photos used as the background had the best scores in our vote contest: at first we looked through photos in Picasa (the desktop application) and put everything we liked in an album. Second step, we removed unsuitable ones until five were left. Last step, Sylvie and I gave scores for the last five between 1 and 5, the final score is the sum of her score and mine.

The draft pretty much followed the original idea but the background were not very nice so Sylvie used some online tool to add effects to it. The left image below is the extracted background; the right one is the after-effect background with texts and stuff:

We liked the effect but the tool only exports low quality jpegs so I tried to recreate the effect within Photoshop. I also used Adobe Photoshop Lightroom 5 to make the photos smoother (reduce clarity, reduce noise amongst other things). It now looked much better than the first draft:

With the background in place, I used WhatTheFont service to find out which font was used in the original idea, we both love the stretched out "M" letter. I had to try a few times to learn the font name, it is "Century Gothic". After playing around a bit, I had several different designs (the left image moved the two lines of text; the center one put them down to fine print area; the last one expanded the fine print  and used contrast between light and bold font weight to give emphasis):

The design was at 3000x4500, a rather odd size, so I changed it to 3600x4800. I also make the bottom frame bigger than the others to make it less crowded:

The uneven frames looked so weird that I changed it again with all frames now having the same height. To make it less crowded, I decreased the separator thickness, changed to use light font for most of the texts and deleted one line of fine print:

I was pleased with the design but Sylvie apparently didn't think so. She edited and published it on Facebook without my consent. At least she waited until April 20th to do that though (my planned caption was "The countdown starts now, three months to go"). She changed most of the texts and made them less consistent IMHO...

I was quite pissed but no big deal though. Recently I have learnt this idiom "Happy wife makes happy life". Happy Life it is then.

Saturday, March 29, 2014

Trying HHVM

So I was trying HHVM on a VPS when I encountered the error "list sub-command REMOVE_AT requires list to be present". Having no idea of what it is, I tried a Google search and ended up with a page of results (5 or something with half of them in Chinese) and no pointer at all...

The full stack is like this

CMake Error at CMake/EXTFunctions.cmake:8 (list):
  list sub-command REMOVE_AT requires list to be present.
Call Stack (most recent call first):
  hphp/runtime/ext/imagick/config.cmake:12 (HHVM_LINK_LIBRARIES)
  hphp/runtime/ext/CMakeLists.txt:24 (include)

So I went in...

vi CMake/EXTFunctions.cmake

Found some macro definitions and some function declarations. The two things that caused error are both macro so I change them to function and it works! See the edited file here.

At least CMAKE worked and now I'm running MAKE. I will update this post when I got HHVM running.

So HHVM has been compiled and ran smoothly on my box. I submitted a pull request on github, you guys should check it out.

Wednesday, March 26, 2014


I read two articles today:

One: We’re F****D, It’s Over: Coming Back from the Brink
Two: How I Fired Myself.

These paragraphs stood out:

I remember Hotmail’s CEO Sabeer calling us all in a room. “Hey, Rex (the COO), how long will it take to restore the email from the tape backups?” And I’ll never forget his answer: “Um, those got really expensive, so we stopped doing them about a month ago.” Gulp. Long … painful … silence.

I found myself on the phone to Rackspace, leaning on a desk for support, listening to their engineer patiently explain that backups for this MySQL instance had been cancelled over 2 months ago. Ah.

God, that's painful to read. It gave me chills... Note to self: Backup all the thing. Never cancel backup services. And test backups to make sure they work!

Tuesday, March 11, 2014

XenForo WordPress bridge (again)

A long long time ago, I started working on WordPress 3 Bridge for XenForo. I think it was one of the first work that I have done, the idea back then was pretty simple: find XenForo directory, load the session then find the connected WordPress user... It worked for awhile but because loading XenForo bootstrap code is slow and the two system architectures are different from each other (XenForo is MVC while WordPress is still procedure), there was a lot of bugs. It took hours to make it work nicely with other WordPress plugins. When XenForo moved to Resource Manager for add-ons, the plugin thread is locked at 37 pages. I haven't work on it since then. In the meantime, a few other solutions popped up but for some reason they died relatively quick...

Enter [bd] API, it exposes XenForo data in a systematic way and uses OAuth 2 to authenticate users. Quite powerful. I have developed a bridge solution to connect two XenForo installation and it worked well so this time I went to develop a new WordPress bridge. The result is WordPress Plugin: XenForo API Consumer with complete two way user, post and comment sync! So far, it works with other WordPress plugin without issues.

At first it only uses XenForo as the Master system but after hearing people suggestions, I expanded its scope and now it can use WordPress as Master for some tasks. I see the future is bright with this one...

The option page is freaking long though!

Thursday, February 20, 2014

Text Messaging

Many people asked me to use OTT solutions like WhatsApp, Viber, LINE but I quickly uninstall those apps after a while because of two reasons.

Firstly, there is no one-thing-fits-all solutions which means you will need to install a bunch of similar apps because different group of people use different service. God, that's tiresome and kills battery. There are decentralized protocols to fix this very issue but they are too good to be true I guess, even Google backed out from supporting XMPP by dropping their Google Talk service. I believe there are companies working on this front right now (or maybe I should?). They should make a solid server implementation AND clients using established standards, big plus if they stick some open source license in their code and publish them all. Provide good user experiences while allow user to control their data and federate between different system as needed.

The second reason is backup. No services that I know of provide a way to conveniently backup data except Google Hangouts. Don't have to worry about device lost. Being able to search for old messages without using third party solutions (I'm looking at you, Yahoo! Messenger). Google really does well with their Data Liberation Front initiative. For Skype, it is extremely frustrating if you need some piece of information from last month. People don't ever reread their messages?! I need to do a survey targeting young lover to unveil this.

On a similar note, I refuse to use anything but Android because it allows me to backup calls and messages painlessly. Not out of box but at least doable, thanks to its open (and insecure?) nature. Imagine doing backup an iPhone into some unreadable format, ew!

So, if you need to contact me, please do call or send a text message. You may want to try Hangouts or Skype too. For non-urgent matters, email should be the way to go.