Batch minimize js with python and Closure

There maybe much better ways of  batch minimizing Javascript files. But this is my way and sharing it just in case someone else finds it useful.

 

March 1, 2013, 12:38 a.m. » Tagged: javascript , Python

Finishing up Jekyll migration - this time for real

Yesterday's goal was to finish off the migration from Wordpress to Jekyll (a destination that was arrived at after a long journey), however there still was a couple of sticking points including paginated categories and tags. Thankfully I found a really well documented plugin which someone with only very elementary Ruby knowledge such as myself could understand at realjenius.com

The Realjuenius plugin is a Swiss army knife. It does categories, tags , RSS and includes pagination to boot. By the way do people still use RSS and atom? I see precious few requests for the feed in my log files but the saying is that you shouldn't look a gift horse in the mouth. The rss feed comes at no extra cost, so keep it. Only a few teeny weeny mods were needed to make this plugin behave the way I wanted it to. One is that category names need to be downcaseD and special characters in category and tag names need to be escaped, but these are things that can be managed with my elementary ruby knowledge.

Now comes the most boring bit, working with the design. I am not too keen on preserving the existing design and I am not bothered about changing it either. So I am going to put myself firmly on the fence; adapt Twitter Bootstrap with a UI that looks pretty much like the existing design (which is based on the now unmaintained Wordpress Magallen theme)

Feb. 23, 2013, 1:49 p.m. » Tagged: jekyll , Wordpress

Jekyll finishing up

So it's been an eventful journey; after deciding to do away with wordpress (this time for real), I started looking at static blog generators with Jekyll being the very first. Thereafter I investigated Hyde, Mynt, Punch, Pelican and a few other as well. All of them had their pros and cons but in the end, I settled on Jekyll.

Jekyll and wordpress do have something in common;  they are both completely useless without plugins. So far I have installed plugins to paginate the home page and create category and archives (yes, even making category pages needs a plugin). Now I need to paginate the category pages and also create pages for tags. So let's look at the options available.

The first thing I tried was to modify Recursive Design's category plugin based on Ben Curtiss archive generator plugin, after all the latter is based on category plugin. But it didn't quite work out,  for some strange reason categories seem to get mixed up and doesn't seem to be displaying in the reverse chronological order. Then I looked at couple of other category plugins including one on marran.com which didn't produce anything at all for categories!. This lead me to the conclusion that these plugins expect the directory structure to be organized along category lines - ie subfolder for each category and blog posts placed inside. Simply having the category name in markdown may not be enough.

At this point, I must add that though I have learned and forgotten quite a few languages Ruby doesn't happen to be in that list. I do have the ability to read and understand ruby code, thanks to a 'learn ruby in 24 hours' adventure I undertook last year. At this point time, I don't have the energy or the proficiency to wade through Ruby code and figure out what needs to be changed. But then, laziness is a virtue. If I install a tags plugin, this will be quite easy to figure out.

 

Feb. 22, 2013, 11:23 a.m. » Tagged: jekyll , Ruby , Wordpress

Leveling up the traffic alerts system

Road.lk's traffic alert system now get's a fair bit of use, and proved it's worth whenever the congestion level in Colombo went through the roof. For example when that infamous traffic survey was conducted by the police, road.lk started reporting higher levels of traffic by 6:39am and over the next three hours published an additional 56 alerts. Another example was on February 6th when the main stream media started talking about massive traffic jams near Lake House. Their alerts started at around 4:30 pm but road.lk already published it's first alert for that area at 3:17. I feel it's a decent effort, but all this is level 1.

Thing would have been even better if road.lk had reached level 2. Then both the above incidences would have been reported at least 5 minutes earlier, and quite possibly a comparison would have been provided which would enable motorist to estimate how much longer they would spend on the road if they chose to brave the traffic.

In order to reach Level 2, road.lk needs more people to use their GPS tracker, which is a feature of the Android app available for download. Though quite a few people have downloaded the app, the majority seems to only use it for traffic alerts. But for better traffic alerts, the GPS tracker usage is needed.

The tracker would enable road.lk to automatically detect high congestion levels and automatically send out notifications so that the alerts can be sent out a little bit quicker and save you that extra bit of time spent on the road.

Feb. 21, 2013, 4:27 a.m. » Tagged: gps , road.lk , sri lanka

Manymo and Eclipse

Manymo calls itself "A Better Emulator", and that's a fair call. They go on to add that manymo emulators; "Start quickly. Run smoothly. Are lightweight. Match every current OS version & screen size. Are accessible from your browser." In spite of the network lag, it certainly feels more responsive than the emulator that ships with the Android SDK. [caption id="" align="aligncenter" width="450"]Some of Manymo devices These are some of manymo devices. Each of them can be started with different versions of Android.[/caption] The only catch is how do I configure it for use with eclipse? The first thing is to download and install the manymo command line client. Now launch and emulator inside the browser, then at the top of the emulator page you will see something that looks like:
Use the Manymo command line tool to work with Eclipse, IntelliJ/IDE or SDK tools (e.g., adb): manymo tunnel w3d.manymo.com:5560:59c9d3af135f3bd2194c91ee1c96853c
Copy paste that command and type it into a shell. Now just type adb devices, if a new devices shows up, you are in luck. The manymo emulator can be used with no further effort. If a new device doesn't show up try this:

adb connect localhost:5554

adb kill-server

Now a new device really should show up when you type in adb devices at the command line and it will show up in the DDMS perspective of eclipse.  But if you are still having trouble, it could possibly be that the  manymo tunnel is tied to a different port. Try this:

netstat -anp --tcp | grep ssh

Look for a line similiar to the following.

tcp        0      0 127.0.0.1:5555         0.0.0.0:*               LISTEN      30060/ssh

This output shows that the port number you should listen to is actually 5555, so user that instead (eg adb connect localhost:5555 ) and this really ought to work and you can launch apps on it with eclipse.  
Feb. 20, 2013, 3:28 a.m. » Tagged: Android , eclipse , emulator , manymo

Back to jekyll

So here I am, back on Jekyll but with a fresh start. Yep, started off by deleting the old stuff and making a clone of Jekyll-Base to lay the foundation. Next ran the wordpress to jekyll exporter plugin and downloaded the markdown. After that I remembered to start jekyll with the --auto option (eg jekyll --auto --server ) . If you don't do it that way, jekyll will not detect changes in your templates or markdown.

Jekyll was abandoned the last time  because it wanted plugins, yes dreaded plugins need to be installed to make jekyll behave the way I want it to. This plugin phobia is a direct result of suffering the Wordpress plugin system for many years. I wasn't keen for a repeat of that experience with Jekyll. Now after a full circle, it doesn't look as if I have any other choice, so here I am taking the plunge by choosing the category sidebar plugin by  Nikolay Sturmas as the first one to install.

I would have been very surprised if the first plugin worked as expected, it didn't (Liquid Exception: Unknown tag 'category_list' in post). It took a bit of head scratching  to figure out why something as simple as that wouldn't work. In the end the reason turns out to be that even though jekyll with the --auto param recognizes changes to templates or markdown, it will not detect  changes to plugin code. So when working with plugins, always remember to kill and restart the server for each change.

Next step was to generate the category pages. For that I initially used the example on the jekyll plugins wiki, and later switched to the one provided by the folks at Recursive design. Neither of these provide pagination, which is going to be addressed next, because even the home page isn't paginated by default.

Simple pagination can be enabled by adding paginate: <n> to the config.yml file. This uses the built in paginator. The result while usefull wasn't what I was looking for. It produces links like page2/, page3/ etc while permalink structure on the current blog is page/2/ , page/3/ etc . In other words, each page needs to be in it's own folder. There was a suggestion at bencurtis.com that one should just copy over the default pagination.rb file into the _plugins directory and edit line 32 to create a directory instead of a file. Since that post was written the pagination code has changed a bit and the line to be edited is now #40.

Modding the plugin ensures that the archives are correctly placed into separate sub directories but the link is still using the old page2/, page3/, page4/ ... format. To fix it, I needed to edit the template (which was borrowed from the jekyll wiki on pagination). The diff looks like this:

Feb. 19, 2013, 10:09 a.m. » Tagged: jekyll

Tizen install

The previous attempt to install Tizen was abandoned because of all the errors that kept popping up. It turns out I had made an elementary mistake; a mix up of 32 and 64 bit binaries. Sorted out that mess and gave it another go. These are the steps installed. Install Oracle JDK

Why on earth Tizen insist on using Oracle JDK is a mystery why not use Open JDK. Let us not forget that Oracle is the company that files a law suite against the use of Java on the Android platform for god's sake

Install an ancient version of Eclipse.

Downloaded the latest and hottest version of Eclipse direct from the site because distro's repositories only have ancient versions. Well buddy you are going to have to go back to apt or yum or  whatever it is that you prefer to use and install that ancient version because Tizen refuses to work with Eclipse Juno.

You know that Tizen development is going to suck because Juno sucks and Eclipse 3.7 sucks even more (what the hell did they call that anyway? I have already forgotten)

Get the tizen installer

Having downloaded a 100 Mb JDK and a 300 Mb over your lousy over priced internet connection, you will no doubt heave a sigh of relief when you realize that the tizen downloader is just 3.5 Mb. Sorry to disapoint you my friend that's just an online installer the real download is 1.6Gb

[caption id="" align="aligncenter" width="628"]Tizen's loooong download Installing Tizen, a right royal pain[/caption]  
Feb. 18, 2013, 1:16 p.m. » Tagged: eclipse , tizen

Pelican or back to Jekyll?

Pelican, looked really promising. I made more progress with Pelican than any of the other static blog generators with the possible exception of mynt. I even found a Bootstrap template which can be used as a starting point, but still there is that little something missing.

The trouble here is that the article template, which is used to display individual blog posts  seems to combine the post content and the tags all into one. The Article class isn't documented, I looked at the source but it doesn't seem to provide methods to separate  the post body from the tags. Pelican also appears to have limitations on the structure of the permalink.

The obvious thing to do is to fork the project and try to change it so that it behaves the way I want it to behave.  But then, I can do the same with mynt as well. So which one is going to be easier to modify? Perhaps it's better to dump them both and return to Jekyll or punch? Decisions. Decisions.

 

Feb. 18, 2013, 3:36 a.m. » Tagged: jekyll , mynt , Pelican