• Javascript iOS and Android app under 3 minutes

    The reason“Write code once in one language for an app, and run it on both iOS and Android.” If I could have one mediocre super power, I would want that. Imagine how wonderful it would be if you could build a phone app that can run on iOS or Android without learning any of the gimmicks of either app enviorment. The engineers working on Apache’s Cordova must have had the same thought.

    Cordova is an open source framework from Apache that enables you to use Javascript, HTML and simple CSS to build your app, and compile it into any of these mobile platforms, and immediately start running the app. It is not perfect, it does not have all the bells and whistles of both platforms. However, it does a wonderful job for most of the part.

    Cordova is a fantastic tool to quickly prototype apps. We can build a simple app for both platforms in less than 3 minutes.

    Keep reading...
  • 1-minute Jekyll on GitHub Pages setup

    The reason I have one of the “fastest” recipes for setting up on a Jekyll blog on GitHub pages from command-line. And I hereby give this recipe to you. If you have Jekyll installed on your computer, it will take you less than 1 minute to set up your own website which you can manage with Jekyll. And of course, you can skip all this and fork the template I created in this post which lives at gh-pages-orphan-branch-template.

    The birdview process is this: we will first create a new Jekyll project using jekyll new command. This will create a bunch of files. To these files, we will add a file named “Gemfile” instructing Jekyll to install a few packages necessary for GitHub integration, and run an install command. Then we will initialize this directory for git, add a remote, and checkout the “gh-pages” branch.. Once we commit all the files and push to “gh-pages” branch, your website will be live on the internet hosted by GitHub.

    Keep reading...
  • Master and gh-pages in Github: keep your code and website in the same repo

    The reason Code and website in one repository : 2015 did not give us “Back to the Future” hoverboards, but it gave us the ability to put our websites next to our code on GitHub. However, it still is easier said than done. In theory, this should be a one-click operation. But in practice, you need to be a little patient, understand a few git concepts and type in a small booklet of commands on the command-line. And of course, you can skip all this and fork the template I created in this post which lives at gh-pages-orphan-branch-template.

    Creating a repo

    As of June 2015, you still cannot do this on the command line for GitHub. You can do it on the website or if you are over zealous, you can use the API with a RESTful client. Let’s take the simpler approach: first login to your account, and then click on this link and create your repository:


    Let’s call your username <user>,and your repository name <repo>. In the commands below, replace <user> with your actual username, and actual repository with <repo>.

    Keep reading...
  • Emacs on steroids for Python: elpy.el

    The reason You may have no problem programming Python in naked Emacs out of the box. But you may also know that with Emacs, there is always more. Just like the way Popeye would pop a can of spinach down his stomach to boost his act into a super human being’s, you can install a few tiny packages to transform Emacs into a super Python IDE. You won’t regret feeding these supplements to your Emacs, because once you set them up, you will never go back.

    Elpy.el mode is the lead actor here, with jedi and rope are in the supporting roles. After installing these three packages, you get everything you wish for from a nice Python IDE: auto-complete, snippet expansion, syntax error highlighting, lint-like pep8 highlighting, indentation highlighting, simultaneous editing, easy code block shifting.

    Elpy.el mode itself is a conglomerate of many other packages each of which brings yet another greatness onto the table.


    Emacs will complete the commands you started typing when you hit TAB. If there are multiple possible completion patterns, it will show the choices as well as the descriptions.

    TAB becomes a powerful key with elpy.el mode. For example, type “whi” and hit TAB, elpy completes it to “while”. Type “ope”, hit TAB, elpy mode completes it to “open” and shows you the definition of open() method. Auto-complete is brought in by jedi and rope. s

    Keep reading...
  • iMovie Fail: Very slow importing, iMovie'11 and h264

    The reason iMovie sometimes takes a really really long time to import a relatively small clip encoded in “h264”. For example, a 50 second clip can take up to 10 minutes to import, while a similar clip of the same duration with an ”mpeg4” encoding would take only seconds. If you are going to import a medium size movie, you are ultimately out of luck. For a 20 minute clip, iMovie can take up to 6 hours.

    After a little experimentation, the source of the problem materialized itself on my computer screen like a dew drop on a lotus leaf. “h264” is a interframe codec. It can use information from other frames to encode a certain frame. This potentially decreases the size of encoded of video while maintaining the quality. However, iMovie’11 cannot edit a file encoded in an interframe encoding: in order to edit a frame, there should be no inter dependency across other frames. iMovie should be able to manipulate a frame independent of others in a clip. Hence, iMovie reencodes the movie in “iCod” (a Quicktime format), and this takes a really long time while requiring a great deal of free drive space.

    There is a neat solution to all this mess. You can re-encode your video in “h264” with exactly the same settings but by only turning off inter frame lookups. This process will create a video with visually no quality degradation and very little increase in the size. And, iMovie will be able to import your movie quickly.

    “ffmpeg” command line tool enables you to use “h264” with no inter frame lookups. You need to use “-preset ultrafast” to accomplish this. In my example,

    Keep reading...
  • iMovie Fail: "This clip cannot be optimized. Error -50"

    The reason iMovie sometimes simply cannot implement “fast forward” or “slow motion” on movie clips. This happens when you have a project in which you want to edit part of a movie to play at higher speeds such as 2x, 4x, etc (or at lower speeds for that matter). iMovie will tell you that it will need to optimize the clip before you can fast forward it, and then it will fail with a cryptic message: “This clip cannot be optimized. Error: -50”

    It turns out that the problem is unambiguous, you just don’t have enough space on your drive for the optimization. If you have multiple drives, this would be the drive on which you created the “Event” when importing your clip.

    Evidently, the remedy is simple, just create more space on your drive. But, what if you cannot do that? There is an alternative, you can decrease the size of your clip by reducing the “bitrate” using a command line tool called “ffmpeg”. Of course, you will have to do this before importing your movie to iMovie.

    Here are the steps:

    Keep reading...
  • Real-time Html Development on Emacs with Impatient Mode

    The reason With the rise of jsfiddle.net and jsbin.com, the power of seeing how your html, css and javascript look together on a browser instantly just as you type is now available to the masses. Their popularity is already proving the point: it is much faster and more robust to develop in this manner. However, they both fall short of being the preferred tool for large projects with multiple files.

    Would it not be great if you can use Emacs in a similar fashion to jsfiddle, i.e. just as you type into Emacs, you would be able to see it on the browser how the website renders real-time.

    As it turns out, Emacs already supports this, and it is called the “impatient plugin”. In order to get it working though, you have to set it up. The plugin will start a local web server, and will serve the document you are editing to the browsers on your computer continuously. And once you taste the feel of immediate feedback, I can tell you that you will never go back.

    Here are the steps to get the impatient mode on Emacs:

    Keep reading...
  • How to download multiple files from your phone over wifi (Android)

    The reason You might be one of those who just loves doing everything over the air, or you might be like me who owns an Android phone with a broken usb port. Whatever your reason is, you already are aware that it is a pain in your gut to download a bunch of photos at once over a wireless connection. You might choose to send yourself an email with your photos attached by manually selecting one at a time, or you might try bluetooth. I will guarantee you that both of these methods will only help to turn your hair grey faster. In fact, try sending a video, you will turn into an old human being very quickly.

    Behold, there is a solution. There indeed exists a super fast way to download (or upload) whatever you want over a wireless connection. Simply put, you can install a light-weight FTP server on your phone and then, transfer any file at the speed of your wireless router. For me, it took about 2’ 33” for a 69Mb file. This corresponds to less than a second transfer rate per second of movie I shot with my settings for mp4 videos.

    Keep reading...