Is This Thing On?

Hello, World! (again)

I didn’t disappear, I just had to go away to figure out my career path. I don’t think I have quite figured it out yet. (i know, i know, it’s been three years and still not clear?!) But! I settled on something. I am now introducing myself as a Polyglot Programmer and an Aspiring Product Manager.

What brought me back to write again? I just found the smile on my face again when I debugged a problem! Then I thought to myself, I’ve started this blog not just for myself, but also for those who follow to be aware of the sneaky things that you’d have to watch for whilst a programmer.

I wanted to create one of those GitHub Pages for quite sometime now, but never really had the time to focus on publishing it. Until now, long story short, I have all the time in the world as a person looking for my next chapter, I decided it’s time to brush up some coding, and have fun! So I made it. *smile*

I won’t bore you with the details of how I get to the end. I’ll just share how it’s made in a few steps,

  1. Create a User Site with GitHub Pages*
  2. Link site content with your social profiles
  3. Create an API to retrieve the Photo of the Day from National Geographic**
  4. Host the API on Heroku***
  5. Link background image to call for the API
  6. Push to GitHub (plus the world)
  7. Sit back and be proud***

Voilà! You go make one, too!

Embrace the Open Source

For the longest time, I thought I could avoid C/C++ programming. I was never really into coding close to the hardware. Firmware development, and backend writing are not my preferred tasks. Due to the resources around, I could only dodge the bullets for a limited time.

Just when I thought working with a RaspberryPi was close enough, I was given an nRF51-DK. When I first got this development kit, and a handful of sensors, I was told that there is no OS to work with. I need to read the user manual and tutorials to figure this board. Say what? User Manual?? No way!! So, I put in my “how to nrf51dk” in the Google search field, and hope for the best. The great thing about the internet is, it teaches you things. The worst thing about the internet is, no body document things properly. But we struggle with that everyday, because that is our job to find out (at least mine..).

70 hours later, plus odd toilet moments, and random bedtime brainstorms. I learned how to C++ with mbed on an ARM device with different sensors. I read multiple datasheets that are over 200 pages, and adapted libraries that are for Arduino. I also found that people don’t like to share their findings. I don’t believe I’m first person to connect a LSM6DS3 to an nRF51-DK. But it’s ok, you’re lucky, I’ve shared my findings.

Ever wonder why they make you take those bit-calculation logics and theories? Because you will one day ended up firmware writing, and have to know what

((0 & ~(0x04)) | ((0x01 << 2) & 0x0C))

is. Hint, put your Windows Calculator to Programmer mode, Hex, Bit, who cares.

Last but not least, the reason why I went with mbed development is that the out-of-package software and tools from Nordic, just didn’t work nicely like I expected. If you do have it working, please share.

Keep calm and code on.

Microsoft, I Hate You, Not.

Let’s admit it, we all have a love-hate relationship with Microsoft. Most developers lean towards the hate side, simply because command prompt sucks. Among other cumbersome workarounds, I manage to make my work possible with multiple platforms. Most company are business partners of Microsoft, and the regular administrative work is based on Windows applications. I can’t just say no to Windows, Outlook on Mac will be the end of me.

For the longest time I’ve stayed away from any Microsoft related development work. I don’t even know how to program in Visual Basic (VB). I know the concept, I know how to do it, I just avoid gaining the knowledge. But life doesn’t always fly the way we wanted. I had to face C# and all it’s related Microsoft propaganda, .NET Framework, Visual Studio, and etc.. Part of my job is to research, learn, and apply. I did it. I spend a lot of time getting used to the power of auto-generate. I wouldn’t say that I’ve found a rather good tutorial to follow while learning. The community is as confused as I am. I did learn the trick of filtering my Google result to provide most recent records.

If I could do another .NET project, I would serious consider building proper UI template with T4. I’ve also got a chance to play with Composite C1 CMS, like a C# version of WordPress. Pretty neat, more explorations needed.

Bottom line is, if you’re a C#/.NET developer, I applaud you for your mouse clicking skill. I need more practice.

CoC Hackathon 2016

City of Calgary hosted the open data hackathon with Calgary Region GIS over the weekend of March 4th to the 6th.  This idea and code crunching event kept 150 brain juices going for more than 30 hours excluding the minimal sleeping time.  I had the opportunity to be involved with this event, and be among a bunch of intelligent people.  There were a mixture of attendees, including students, technology specialists, and business enthusiasts.

Hackathon is not a well known event in Calgary, even though its birth place was here in the city.  There were citizen asking, “Is this even legal?” (LOLz).  The idea of hackathon is to have a working prototype of an idea based on the theme and resources given.  The theme of this hackathon was “connectivity” with the city’s recently opened big data sets.  Each team must have at least two to six members.  Any wildest ideas are welcome.

I went into the hackathon looking to network with the industry, learn from team members, and give hackathon another try (I had a bad experience prior with another organizer).  This event allowed attendees to find team members based on ideas and interests.  With the ice-breaker activity, “Pitch Perfect”, we got a little warm up to brainstorm ideas.  I found my team members based on my ability to assist, and started off to work on YYCWalks.

Our team consists of one full stack .NET developer, one telecom engineer, and me.  From my past experience, I knew we need to keep track of time and avoid scope creep.  The team was very focus with our idea, to generate an mobile application which allows user to take a historical walk in the city.  With the Discover Historic Calgary open data set, we were able to create a custom walk based on our starting point at the City Hall.

I’m all about open source development, I suggested having a web application with Node.js with Express.Js web framework, MySQL database, and Cybera Rapid Access Cloud for deployment.  Since I’m the one with much more experience with application development, I took on the behind-the-scene tasks.  After the basic designs are set for the app, I took off to parse the data into the database.  We converted the KMZ file to KML, and I was able to successfully parse the KML file to GeoJSON via a Node module, togeojson.  We used Google Maps API to apply the GeoJSON and plot locations.

I had some struggle with the Cybera RAC instance; I couldn’t get the database accessible.  I was fighting with it at 3AM on Day 1 (considering no sleep), and a little bit more in Day 2, finally I decided, there’s no point.  We made the decision to go off a smaller set of data, and just parse the data on application load.  Since my team members are not familiar with web application development, they had hacked up a one page application.  No complaints, I can work with that.  I then Bootstrap-ed the application to make it mobile friendly.  Towards the end of Day 2, I’m fighting again with the instance, now with deployment.  I didn’t solve the external access issue earlier in the day, now I have to host the application (FML?).  The end of the day came, I smarten up this time and decided to sleep on it.

The final day started, after few hours of research and poking at NGINX setups, I had no leeway.  In the end, is the IP address forwarding made things work.  Once the web application was live, minor modifications was implemented on layouts and contents.  We added the complete walk tour distance calculation to better use the data.  We tested out our app on mobile devices, and took it out for a stroll.  The geofencing worked out great, the notification showed up when arrived on location, and all functionalities worked as expected.  We were ready on time for the qualification round judging at 1PM.

I don’t believe the event organizer expected the amount of teams generated, they were very behind on judging.  There were three pairs of judges, we did not get evaluated until almost 4PM.  At one point, I was going to judges asking, “Are you looking for K1?” (teams were randomly numbered), we were worried.  I got a chance to tour a little bit to see what other teams had done while waiting.  Most teams have mapped the open data, which was a no brainer.  There weren’t a lot of ideas on manipulating data to create meaning.  Perhaps we were too fixated on getting Google Map to work?  When it was judgement time, our judges didn’t seem to be engaged at all.  One of them was clearly distracted with phone calls, and we were asked with one question, “What is the potential profit of this app?”.  Now I’m just confused, tired, and very confused.  I thought the theme was “CONNECTIVITY”.  Maybe we missed some fine notes in the criteria?

The top six finalists gave their presentation a bit after 5:30PM.  Most of them were doing sales pitch about their ideas without a working prototype.  The winning team was CycloConnect, which depended on crowdsourced data to make bicycle parking safe and accessible.  It’s a great idea, no doubt, but I thought we’re supposed to utilize existing data instead of creating new data.  One of the member from the finalist teams mentioned that it took him more than 12 hours to parse the existing data, thank God I didn’t fall into that rabbit hole.  He also suggested that it would be nice that the region not only collect data, but clean them.  Some consistency, would be nice.

Overall, I had a great experience.  I didn’t go in to win, I was there to learn.  I was disappointed that we didn’t get a great chance to connect with the fellow attendees.  Everyone was head down, busy.  I would like to see what every group had done.  The judges gave me the sense of bias, perhaps I just need more justification with the result given.  After all, congrats to all the winners, I got a piece of cake (literally), I will be just fine.

I learned from a hackathon, so should you.

Get the TDD

I may have found myself sticking with the benefit of a Test Driven Development (TDD) method. Yes, yes, I know you all may be screaming at me right now, “YOU JUST REALIZED IT NOW!?” I’ve been bad. I never was really good at writing unit test. Instead I just literally do my test with my keen eyes and think of all possible use cases while testing. Ok, you can waggle your finger at me. I accept all judgements.

While working away with Django, the team finally got down to utilized the built-in unit test feature. I found myself a great tutorial here, and found fun writing tests. Part of it because I could finally document my train of thoughts, and see it gives me the “OK”. At the same time, you could debug your code as well. When you thought it’s bug free, not so much. But you could pin point right away, just as stepping though compilers with a mark on every single line of code.

The bug I found also gave me a lesson, which I am documenting for you to have as a lesson. I tend to style my code to be as clean and organized as possible; therefore, I found myself declaring my variable as so

a = b = c = d = {}

Only to find out from the unit test that b is equal to c. Logically yes. But I was blinded by my post object assignments with

c['aa'] = 'aa content'
c['bb'] = 'bb content'

At this point I can print c and gives me {'aa': 'aa content', 'bb': 'bb content'}. I’m happy, BUT when I go and print b,

{'aa': 'aa content', 'bb': 'bb content'}

Huh? How? And Duh!! I guess I have to initialize my variables separately, and not easy on the eyes

a = {}
b = {}
c = {}
d = {}

So much white spaces.. I tried placing the variables in different order, but that just seems like hiding bugs which will eventually burst. If you do know some way to make my code easy to look it, please let me know.

Any how, get on the TDD practice, you. It is really good for you, and you can be the one saying “AHAH, it doesn’t work because…”

Unit tests save the day, now 527 more to go..

Python + Django + MySQL on Mac OS X Yosemite

I’ve briefly played with Django before for some frontend customizations. Now with this new project, I’m right on board to fully learn Django.

Yesterday, and the day before, and maybe the day before the day before, I was trying to get a Django environment setup on my local machine working off from an existing project. My first approach was working off my Windows 7 machine, I was stuck on getting the Virtualenv setup. It just won’t run.. (or i couldn’t figure it out..)

Switched to Mac OS X Yosemite (10.10.5), the closest/almost the same environment from the existing project. I was having the greatest struggle with MySQL OperationalError: (1044, "Access denied for user.. on setting up my local database with python syncdb.

Key things to remember for database setting,

  • create database before creating user
    • grant all privileges to user

    CREATE DATABASE IF NOT EXIST `database_name`;
    GRANT ALL ON * TO 'username'@'localhost' IDENTIFIED BY 'your_password';

    • log in to check credential
  • DATABASES settings in when using localhost
    • no HOST
    • no PORT


    'default': {

    'ENGINE': 'django.db.backends.mysql',
    'NAME': ‘database_name',
    'USER': 'username',
    'PASSWORD': 'your_password',
    'HOST': '',
    'PORT': '',



With all luck, the database creation will be completed by running python syncdb.

If not, Google some more..

Node.js – Combo Meal

This draft was in queue for far too long.  I guess Christmas got me and was trying to wrap everything up, literally and figuratively.

What I meant to write back in December 2014 was Node.js with Express framework and Jade template engine.  Along with this fantastic combo, use npm package manager to combine everything.

Express is very self explanatory, there are lots of tutorials on this framework.  It took me very little time to pick up, the walk-through from the website, provides instant setup.  Jade on the other hand, may be simply confusing if you’re superglued to basic HTML.  It will need some brain twisting.  Very well worth it, you will find frontend coding not as award.

I’m not going too deep with this combo, but I am going to talk about LoopBack in the near future.  Fast API development, I meant real FAST.

I will keep you posted.

Must-Have JavaScript Tools

After exploration on mobile development with my previous post, I’m taking on new challenges with JavaScript, Underscore.js.  Underscore

“is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.” – by tuts+.

I found Underscore has all the right tools for JavaScript and more.  Evaluation in JavaScript has never been so easy.  The more you’re familiar with Underscore, you’re be expecting to you it everywhere, like the time you’ve first learned jQuery.

Learning to adapt to Underscore took me no time, I was literally using it every possible places I could.  I found, iteratee, [context]) extremely helpful.  You get to work with values within both objects and arrays.  The template function takes a little to get used to, but once you’ve got it down, you can create HTML context on the fly.  I guess I got used to templates from Ember.js and am expecting everything to be done with templates. This is good practice for modular programming.

Having the time to explore tools for JavaScript, I also was experimenting code testing with QUnit and Jasmine.  They both have their pros and cons.  QUnit has a great community of support and the output style is detailed and clear.  Jamine has great features like Spies and Clocks, and uses BDD – behaviour-driven development style which is much easy to read.

At the end of the day, JavaScript is fun!!


I’ve been a little MIA for the past few months, or should I say almost a year..

Obviously, I’ve fell off the Appcelerator – Titanium  track.  Instead, I’ve been choo’ing away on Ember.js lane.  A project came and has come to a holt due to a connection issue to the server from internal network security.  I liberally am taking this idle time to update my outdated blog.

I’ve gained knowledge to work with Ember.js, Ember Data, handlebars.js, as well as good old jQuery.

The new lightweight approach is to go with bare bone HTML, CSS, and JavaScript, then covert into a cross-platform mobile application via Apache Cordova (Used to be Adobe PhoneGap).  This approach is suitable for simple mobile applications that use very minimal feature of the mobile hardware.

While learning Ember.js, Grunt became my best friend.  I’ve got a mockup up server setup, and auto reload based on file changes.  If any of you remember Opera 12’s auto reload feature, Grunt triggers exactly that but smarter!!

For styling, Twitter Bootstrap 3 works like a charm.  Embrace it, please.  (Oh, watch out for Bootstrap’s approach of tabs, it is tricky to get used to if you know jQuery tabs.)

Not going into too much details here, since this is just an update of my status.  Anyways, here it is, I’ll be as active as I can on blogging about my learning.

Carry on, kids!!

Titanium Bible – Kitchen Sink

I’ve been playing with Titanium modules and debating if my design is best suitable for the cross platform mobile application.  It turns out, my decision of going WebView base is not a bad idea.  First, it’s completely cross platform and this way keeps the mobile application consistent.  Second, many modules are not flexible, instead of using them, it’s much faster just route to the external site.  Third, customization.

For those of you who are experimenting with Titanium, I highly suggest to look at their Kitchen Sink application.  It is a cross platform application including iOS, Android and mobile web/hand held devices.  In this example application, you can get a clear idea on how to design your application and how the transition will react on different platforms.

If you have problem getting the application to run on Android, make sure you look at the TiApp Editor and change the <tool-api-level> to the current Android version you have. (mine’s currently at 19)  The application is iOS 7 friendly and Android KitKat friendly.

There are many things in this sample application, flip through it as much as a bible.