Saturday, November 15, 2014

Running Background Jobs in Parallel on Linux

Background jobs are very easy to execute and monitor yet very powerful, allowing you to stay focused on what needs your attention the most while still fully utilizing your Computer's resources.

Let me give an example with conversion of MP4 files to MP3 files, a simple task I have to do every once in a while since my car music player only accepts mp3 on USB (of course, I have used the feature to do more advanced stuff).

The program I use is avconv, it's straight forward to install if you don't already have it. ffmpeg also works the same and is available on Windows and Mac. These are free software for handling multimedia data.

The following commands will only execute on bash though, the default shell on Ubuntu. which is also available on other Linux flavours, and probably available on the rest of the platforms.

I am using 3 bash concepts here i.e looping, substitution and of course background jobs.

First cd into the directory containing the mp4 files.

for f in *.mp4; do avconv -i $f ${f%.mp4}.mp3 & done

The above command will start the conversion of all mp4 files in the directory; but how? let's break it down, in my next article.

To monitor the status of your background jobs, just run

jobs

The output, something like this
 
[1]+  Stopped                 avconv -i $f ${f%.mp4}.mp3
[2]   Running                 avconv -i $f ${f%.mp4}.mp3 &
[3]   Running                 avconv -i $f ${f%.mp4}.mp3 &
[4]   Running                 avconv -i $f ${f%.mp4}.mp3 &
[5]   Running                 avconv -i $f ${f%.mp4}.mp3 &
[6]   Running                 avconv -i $f ${f%.mp4}.mp3 &
[7]   Running                 avconv -i $f ${f%.mp4}.mp3 &
[8]   Running                 avconv -i $f ${f%.mp4}.mp3 &
[9]   Running                 avconv -i $f ${f%.mp4}.mp3 &
[10]-  Running                 avconv -i $f ${f%.mp4}.mp3 &




Thursday, October 23, 2014

My Name is going to Mars

I submitted my name to be included on a NASA microchip to destinations beyond low-Earth orbit, including Mars. The micro-chip will take off aboard Orion, NASA's nextgen deepspace spacecraft,  on Dec. 4 2014 on a 4.5 hour flight-test, a two-orbit mission around Earth to test Orion’s systems. At the end of this short mission, my name will have to survive cringing speeds approaching 20,000 mph and temperatures near 4,000 degrees Fahrenheit, before splashing down in the Pacific Ocean.

If all goes as planned, the  microchip will be carried aboard in future NASA exploration flights and missions to Mars in an arrangement that could see me accrue space miles as a member of a global-space-faring society, exciting stuff!

Below is my official 'boarding pass'


Wednesday, October 8, 2014

JuiceSSH: My favorite Android App

This app has helped me incredibly. Well, what does it do? It allows you to ssh into a server and do everything you can accomplish on a regular terminal,  and this is from your mobile device.
It comes with an awesome keyboard feature set such as pop up keys for ctrl, tab e.t.c As a bonus, it allows you to connect to the mobile device's localhost and violate it in so many ways.
Personally I use an android version of it. Get to know it and it could turn out to be just what you needed to provide 99.9 uptime commitment on your applications.

Sunday, September 28, 2014

Thin SIM Technology Is Welcome

Am ready to try it out. Anything that cuts market entry costs opening up the industry to more competitors is good in my books. Instead of Safaricom trying to block it, they should just embrace it and use it to avail its MPesa products to 99.9% of all Kenyan mobile phone users.

Good call by CCK to let Equity try the technology for a year.

Looking forward to accessing Equity services from my SIM toolkit. Top on my wishlist is better payment APIs to help local devs create more powerful applications, anything to keep the fire in the Nairobi tech scene burning.

Wednesday, September 17, 2014

The Rapid Prototyping Toolkit for Mobile Apps

I am working on a set of tools to help mobile developers to quickly prototype apps. The platform will consist of an online dashboard for editing and publishing prototypes, a mobile app for running the prototypes and an emulator for testing prototypes before publishing. The mobile app will initially be available for android only. The platform will communicate with 3rd party apps via a HTTP REST, with JSON formatted data. Developers will be able to develop their prototypes in their language of choice provided they host behind an HTTP server.

Wednesday, September 3, 2014

Happy Birthday President Moi

Wishing a happy birthday to our former president, Daniel Torotich Arap Moi. Yesterday he turned 90. We share a birthday and that is why he is the only politician I always remember to wish a 'happy birthday'.

I am so grateful to Moi, he kept the peace at the expense of a few individuals, my view is, overall, it was better for everyone. It's time he wrote a book exposing all, he is 90, we will let him walk. I give his presidency a B+ for the peace, we could have been Rwanda, DRC or Somalia (No offense guys) had he missed a step.

Kibaki on the other hand, resurrected the economy, created infrastructure, reduced our dependency on donors at the expense of even more widespread corruption. He gets a B-, for letting people die in 2007.

Now its up to you Mr Uhuruto, My prediction, these guys will score a A-, mainly because 2 heads are better than 1 and also because of the pressure they are facing from all directions (ICC, Referendum, Impossible promises i.e laptops) and the economic vision set by Kibaki which we must try to live up to.

Kenya is going to be an African super power if we stay on track, mend fences with the west and negotiate better terms with the East. Its time Kenya corrected the imbalance of payments.

Monday, June 9, 2014

Generating Git Stats By Author

Ever wonder how many contributors your git-versioned project has, and how much each of them has contributed to the project. If yes, then here is a simple solution for you. It is based on the git blame command. Observe the section that contains the file extensions, you can customize that to ignore some file extensions.

git ls-tree --name-only -z -r HEAD|egrep -z -Z -E '\.(php|py|html)$'   |xargs -0 -n1 git blame --line-porcelain|grep "^author "|sort|uniq -c|sort -nr


Its not ussually entirely accurate. e.g if a coder adds an if .. else block to enclose existing code, formatting shifts the whole block right by a tab/space and git attributes the authorship of the whole block to this author. Another example is an coder who uses a lot of external libraries and git assumes he is the author.

Nevertheless, its a nice trick to know.

Tuesday, March 25, 2014

New Stuff Coming Up Soon

The year 2014 has been great, my focus has remained on Mobile solutions i.e SMS, USSD and Mobile Web. Integration solutions have also interested me a lot especially when it comes to interfacing 2 or more systems without relying on a defined API (when there is none). This automates tasks that have been previously manually done improving efficiency and cutting costs (and some jobs) there by improving productivity.

I have got a lot of exciting stuff coming out soon and am looking forward to writing more about it here once its ready, tested and deployed.