Thameera's MicroBlog

Just another WordPress.com blog. There's nothing special here.

Action.io, django and poya days

with 3 comments

Last week I got an early access invite to the private beta of Action.io. Coincidentally, I wanted to learn some Django. Hence Next Poya When? was born and it only took a few hours to start coding from scratch to deploying successfully in the Google App Engine.

Action.io is a place to start your projects without worrying about all the mundane setup tasks. Once you sign up, you can create boxes. There are cardboard boxes, plastic boxes, and.., oh wait, wrong kind of boxes. The boxes in action.io are comparable to VPSs. You can choose from Ruby on Rails, Django, Node.js and Go boxes to start with. If you get a Django box it’s already pre-installed with python, django and all other utilities required for a typical Django project. All the boxes come with a Web IDE, Emacs and everyone’s favorite Vim as editors. There is PostgreSQL and MongoDB integration as well.

Action.io interface

Action.io interface (click to enlarge)

To set up, all I needed to do was copying my .bashrc and .vimrc files, install some Vim plugins with Pathogen and add the SSH key of my box to Github. All this takes less than 10 minutes. (But don’t tell that to your Project Manager, give him 2 hours effort and he wouldn’t know!)

Now create a project and start coding right away!

django-admin.py startproject poya

Once you build stuff to some extent and want to test how it’s doing, the site can be previewed easily. For example, start the server with

python manage.py runserver 0.0.0.0:3000

and click on Preview -> Port 3000. You can choose from a range of ports from 1024 to 9999.

Previewing the site

Previewing the site

Once done, deploying was a piece of cake. Action.io has Heroku and Google App Engine integration. Deploying the site in GAE took only a single command:

appcfg.py --oauth2 --noauth_local_webserver update nextpoyawhen

Then I pointed my domain to GAE and, voila, we have nextpoyawhen.com moving like jagger!

It’s really amazing how fast you can get everything done with action.io. If I did all this in my laptop it’d have taken ages. It goes without saying how mundane and time-consuming it is to install all libraries, dependencies and get the environment set up in your machine. More often than not, we get tired of the project even before we really start it. We spend 80% of time setting the things up, and much less time coding.

Also, since action.io lives in the web, it’s accessible from anywhere. If someone reports you a bug when you’re at office or travelling, you can just log into your box from the browser, do a hotfix and deploy within minutes. No effort spent for syncing files. You get your favorite environment setup anywhere in the world.

Action.io doesn’t work offline though, at least yet. It doesn’t require a fast connection, but if yours gets disconnected often, be wary. I hope they would implement the offline capability soon.

As for Django, I’m impressed by the framework. It’s quite easy to catch up with, and it’s Python. You can host Django sites in most web hosting providers (unlike node.js), including Google App Engine and Heroku both of which have free plans to serve small sites. I’m studying with The Django Book, recommended by Raditha. Of course, nextpoyawhen could’ve been done with some client-side javascript, but that’d have defeated the purpose. I wanted to do something with django and try out action.io, so it’s like catching two stones with one angry bird, or whatever that is. The source code is hosted in github.

So, the next time you are tired of working all week and want to know when the next Poya holiday is on, you know where to look. 🙂

Written by thameera

March 2, 2013 at 2:37 pm

Posted in Uncategorized

Tagged with , , , , ,

Louie gives me hope

with 3 comments

Louie is a good show. It’s the kind of show I’ve always wanted to watch. Not many shows interest me. TBBT was good for its humor, Two and a Half Men was equally good and Spartacus is good with all its blood. For the record, I’m not watching Spartacus for its sex. Of course you don’t believe.

louie

I wasn’t aware of Louie till @mdsoysa mentioned it on Twitter about a week back. Almost finished the first season and it’s hooked me up. For one, the episodes are just 20-25 minutes long, which is the right length for a TV episode. The black humor, when done right, is tempting, as in the case with Louie. But the best thing about Louie is, well, Louie. He’s the kind of washed up guy, single father, doesn’t really have much hope, but despite all of this, he’s cool and not complaining. He’s like myself, but done right. I ain’t no single father, but you get the idea. Even the opening credits scene cheers me up. And the music isn’t half bad.

I’ve decided to do stuff that cheers me up. Like watching Louie. And coding. Get immersed in a sea of Python or Javascript and watch your worries get washed away! I like my job; it may not be exactly what I want to be doing, but it’s hell of a lot better than what most people do for jobs out there. I don’t think Louie loves his job anyway. He’s a comedian. Comedians comede because they have to make a living. Not exactly the reason I code.

Being away from places like Facebook lessens your chances of depression. Even Twitter can be depressing at times. It used to be fun and lively some time back. Nothing is what they used to be anymore. I even registered at app.net looking for solace, but that ain’t the place.

Just sitting in your room with a lot of tic tac and a mug of Coke can cheer you up. Do you know what’s cool about tic tac and Coke? There’s this tiny little chance that you might die when you stuff yourself with a handful of tic tacs and a big gulp of Coke. That shit explodes when mixed right. Death by tic tac! Awesome!

Not sure if there’s anything that makes any sense in this post. Just ignore for good. It’s just that I like Louie coz it cheers me up.

Written by thameera

February 12, 2013 at 9:08 pm

Posted in Uncategorized

Tagged with

Typing.lk beta released

with 9 comments

The day before the christmas Thilanka said, ‘how about we build a Sinhala typing tutor?’. I said, ‘why not?’. We finally ended up building an English one. Its beta version is now live at http://typing.lk.

Typing.lk is basically a place to learn and practice touch typing. The site has three modes at the moment: Learn, Practice and Code. The first needs no explanation, it’s where you can learn to touch type. The Practice mode gives you stuff to practice typing with, like common English words, quotes from books, etc. The Code mode is for, well, coders. You can choose code snippets from you favorite programming language and practice typing them.

The three modes at typing.lk

The three modes at typing.lk

One thing we wanted to make sure was that the site should be hassle-free. You can start typing from the moment you visit typing.lk. No sign ups or any such crap. We _might_ bring an option to sign-up and keep track of your typing in the future, but that would be an _option_. And we tried to keep the design minimal.

And about the Code mode. Currently typing.lk has code from four major programming languages: C++, Java, PHP and Python. More languages will follow in the coming days. All the code snippets were extracted from popular repositories at github. Some snippets have been modified to suit the purpose and fit in the site.

Typing.lk is by no means perfect yet. The site may get effed up on some small screens. It’s recommended that you use Google Chrome. Works well in Firefox as well. Not on IE though. Who uses IE anyway?

It’s just a small start; we are hoping to keep adding cool features in the days to come. These include a better lesson structure, a more engaging experience, more languages for the Code mode and, of course, typing games. We might even implement a separate section to learn typing in Sinhala.

We’d love to hear your thoughts and suggestions of the app. Do mail us or send in a tweet. You can follow us on Twitter for updates and Like Typing.lk on Facebook. Happy typing! 🙂

Written by thameera

January 29, 2013 at 9:11 pm

Posted in Uncategorized

Tagged with

So much for housing NDT inside UoM

with 5 comments

I’m writing this with tears in my eyes. Just witnessed the damage the NDT has done to the University of Moratuwa premises yesternight. The rooms we used to stay in have been ruined. The doors axed and the windows shattered. They have raided the girls’ hostel as well. Several students from the Engineering Faculty are now being treated, and it’s said that the condition of one is critical.

This is history repeating. The damage NDT has done to the name of University of Moratuwa through the years is huge. In 1999, after considering the circumstances, the (then) vice chancellor had filed the Jayantha Wijesekare Report stressing that the resources allocated to the NDT and the head count of that institute should NEVER be increased. The NDT was not abolished to cater to the need of technical officers in the country. Despite this, the violence has continued.

In 2007 (as I remember), they were allocated a block of land in Diyagama to shift the institute from the UoM premises. The administration agreed that having them here at Moratuwa would cause only more trouble. The land thus allocated is lying without notice now. The last time we inquired, no money had been yet allocated from the budget to continue with the constructions.

As you may know, the NDT is not even a faculty of UoM, but just an institute offering a technical diploma. Their close connection with that notorious political party is well known. The infamous ‘NDT Api’ (we, the NDT) slogan is used to force-feed their power inside the university.

Someone who doesn’t really know the circumstances might not see the gravity of the situation. All they can see is one group of students firing petrol bombs at others. The only solution for this problem is banishing the NDT from UoM premises. Despite the being harsh, in reality, no other solution would work.

They have never worked.

(Pictures are from Dailymirror)

Written by thameera

January 17, 2013 at 7:51 pm

Posted in Uncategorized

Tagged with

Spaced repetition like a boss

with 2 comments

Derek Sivers has a post about spaced repetition. If you are new to Spaced Repetition or even if you are not, I highly recommend reading his article or googling about this cool technique a bit. Derek’s article is focused on memorizing a programming language, which is a cool use of SR. However, the way he does it has a weakness: he’s using Anki.

I came across SR while I was learning Spanish. This technique is widely used among language learners to remember new words and phrases they are learning. Most of them use Anki, which is an app built for remembering stuff using flash cards and spaced repetition. But unless you are the really persistent type, it’s not an easy task remembering to load up Anki every day and reviewing the day’s cards.

I used Revunote for some time. It’s an Android app that integrates with Evernote. It gets the notes that you tag as ‘Revunote’ from Evernote and shows them up in increasing intervals (1, 3, 7, 14, 30 and 60 days). Revunote is simple and does exactly what it says, and I still use it; but is there a better solution?

A possible candidate is email. We don’t ‘forget’ to check mail and we check them every day, no exceptions. If we could plug in SR to our email, that would be perfect. And how do we do that? FollowupThen.

Email followups

FollowupThen is a free email service (with optional premium service) that lets you make email reminders. For example, if you send an email to 3feb@followupthen.com, the mail will be sent back to you in the 3rd of February. If you send it to 10h@followupthen.com, it would bounce back in 10 hours. If you want to reply to an email and if you can’t do it till tomorrow, you can forward it to tomorrow@followupthen.com and you can guess the rest. Pretty cool, huh? It’s can be a life-savior to most of us. There’s a comprehensive how-to on using FollowupThen here.

Now think about this: what will happen if you send a mail to both tomorrow@followupthen.com and 3days@followupthen.com? You will get the mail both tomorrow and in three days. Can you see where I’m getting at? Spaced repetition coming into play!

So here you go:

  • Open up your email client and create a new contacts group.
  • Add the following contacts to that group (with each followed by @followupthen.com):
    3h, 24h, 3days, 7days, 2weeks, 1month, 3months, 6months.
  • Compose a mail with what you want to remember.
  • Send it to your new group of contacts.

Voila! FollowupThen will make sure you remember whatever crap you put into that mail! You can add/remove the times you’d like to review as you wish. YMMV. Just make sure you read each email that followupthen sends; no skipping, please. If you can stick to this simple rule, I’m telling you, this simple system can work miracles.

What do I want to remember?

Fair question. What, indeed? Here are some suggestions.

  • Some new words or phrases in a language you are learning
  • An interesting code snippet or a design pattern
  • Lyrics of a song or a poem
  • A Linux/Git/Vim/whatever command
  • Facts for general knowledge
  • Some telephone/credit card/whatever numbers
  • Anything that you wish you could remember

This is no rocket science. There’s little effort required to set it up. And there’s no reason why you shouldn’t give spaced repetition a try. Go!

Written by thameera

January 6, 2013 at 8:30 pm

Kichibichiya

with one comment

It’s been just a day since Kichibichiya was released. Here are some thoughts on the new app.

For those who heard the name for the first time, Kichibichiya is a Twitter client for Android written by the Sri Lankan developer Pahan. Kichi-bichi is Sinhala for the chirping of birds; hence the name. It has extracted all the goodness of the open-source client Twidere and added loads of useful features into it. The chief motivation for the app has been coming up with a Twiiter client with seamless Sinhala unicode support.

I was skeptic at first. Pahan was posting screenshots of his not-yet-released prototype since a few weeks and they mostly included tweets with Sinhala rendered beautifully. But would you use a Twitter app if all it did right was rendering a language properly? Well, I wouldn’t.

Timeline

Timeline

Sinhala tweets

Sinhala tweets

The first impression I got after installing Kichibichiya was, “Oh man, this is slick”. And it indeed is. Smooth scrolling between timelines, holo theme and less messy interface. Most common actions a regular tweep would need are easily accessible. Username auto-completion can improve, though. The customizability is impressive. Custom tabs, day and night themes, custom notifications, multiple accounts, ability to set DNS servers, host mapping, hardware acceleration are only a few of them. You can even set your own retweet format.

My favorite feature is the content filter. Kichibichiya lets you mute users (eg: @NisansaDdS), keywords (eg: changumee) and sources (eg: foursqure) hassle-free. Not every good client out there supports tweet filtering well, but Kichibichiya does it like a boss. It feels good when the timeline is not cluttered with foursquare and getglue tweets anymore.

Apparently there’s support for extensions as well. Not quite sure if it would allow third-party extensions or not, but it’s good to know that the app is extensible.

Composing tweets

Composing tweets

Some of the settings

Some of the settings

Kichibichiya is awesome. I say awesome and I mean it. Not saying that it’s the best Twitter client out there. It’s hard to beat powerful clients like Falcon Pro, but then, Kichibichiya boasts of several features the former doesn’t offer. Of course, it was just launched. You’d find an obscure bug now and then. Some setting might not work perfectly. But let’s hope the developer keeps up with the good work and continue to come up with updates. And more cool features. This is one app with great potential.

Written by thameera

January 3, 2013 at 10:47 pm

Posted in Uncategorized

Tagged with ,

Diving into Haskell

with 4 comments

As mentioned in the previous post, I started a ‘Learn Haskell in a Day’ project yesterday evening. As of this writing, I’ve finished the 5th of the 14 chapters in the tutorial.

Yeah, it’s a bit disappointing. Well, my uncle and his daughter came to stay yesternight, so I couldn’t focus on Haskell while they were here, could I? Could have made a better excuse out of that, but to whom am I cheating?

Even the tutorial I’m following is quite

Anyway, here are some interesting stuff I came across after yesterday’s post:

Types and Typefaces
Types are much like the types of variables you can use. Those include Int, Integer (which is an unbounded int), Char, Bool, Float, etc etc. A string is a list of Chars. Talking about lists, they play a central role in Haskell. Much more powerful than the lists in the languages we are used to.

Typefaces are sort of like interfaces in OOP. Types implement typefaces. (At least that’s what happens as far as my current understanding goes). A type that implements the Eq typeface can be checked for equality. One that implements Show can be presented as a string. For example, you can make a function that takes types that implements both Eq and Show.

No loops for you, baby!
Haskell has no for or while loops. Like, seriously. But you can use recursion elegantly to achieve what you’d have done with loops in an imperative language. This can be tricky at first; how does one do _anything_ without a loop?

Suppose we want to write a function to get the maximum value in a list. Of course there’s an in-built function, but say we wanted our own. How we do it is create a recursive function that would return the maximum of the current element and the maximum of the rest of the list, which, as you can see, is a recursive call.

maximum' :: (Ord a) => [a] -> a
maximum' [] = error "maximum of empty list"
maximum' [x] = x
maximum' (x:xs) = max x (maximum' xs)

This uses the in-built max function to get the maximum of two values.

Tabs are evil
The GHC compiler does not get on well with tabs. Spent nearly 20 minutes one time to find a bug which had been caused by using tabs. The solution is to ask your editor to use spaces for tabs. If you use Vim, this can be done using :set expandtab.

I tried implementing stuff like the fibonacci series and some math problems, which, IMO, is one of the best ways to learn a language. There’s always a better implementation with more elegant code, though.

So.. I’m hoping to finish at least 3 more chapters by 6pm today. Guess it’d be as easy as it sounds.

Also, funny story, the internet connection here sucks so much that I wasn’t able to clone a 6MB repo from BitBucket. And I tried 6 times. Yeah, not easy to imagine.

Await another update later today.

Written by thameera

December 24, 2012 at 1:07 pm

Posted in Uncategorized

Tagged with , ,

Learn Haskell in a Day

with 4 comments

I was intrigued by Raditha‘s posts on learning Ruby and Python in a day (though they were dragged to 48 hours). Now I’m going to make that inspiration into action by trying to learn Haskell in a day.

Why Haskell?
I’ve always wanted to learn a functional programming language. Have never even written a Hello World with one. Heck, I even don’t know what functional programming is. My first choice was Clojure, but then, after spending some time on the web, decided it would be Haskell. So the main reasons were:
1. Haskell is purely functional
2. There’s a strong, near-fanatical community. Smaller ones are frustrating to work with (that’s what she said).
3. I had heard of ppl solving problems with Haskell in numerous forums
4. When asked what languages I’m proficient in, it’s always nice to add “and, of course, Haskell” at the end.

As the tutorial, I chose LYAH (Learn You A Haskell), which is the ‘funkiest way to learn Haskell’. It’s aimed at those who already know how to programme, so, yeah.

And this will be just a crash course. I very well know you can’t become a master in a language within 24 hours. What I’m trying to achieve is being able to write code to solve basic problems and being able to read Haskell code when I see some.

And here we go:
Language: Haskell
Compiler: GHC (This gets installed when you install the haskell-platform)
Editor: Vim
Tutorial: LearnYouAHaskell
Motivation level: High

Was going to start in the morning, but started just an hour ago coz of the darn slow connection which is a luxury in this wilderness. It took more than half-an-hour to download the 70MB of packages for haskell-platform, just imagine. Hoping to finish by this time tomorrow if the connection keeps up till then.

As of this writing, I’m in the section “I’m a list comprehension”. Here are a few interesting stuff I came across so far:

Functions
As you may have guessed, functional programming languages are all about, well, functions. So is Haskell. Declaring a function is as easy as declaring a variable.

squareMe x = x * x

Functions and parameters are separated by spaces and not parentheses, just like in Bash. Also, if the function takes exactly two parameters, you can call it as if it were an infix function. For example, the ‘elem’ function takes two parameters. If we wanted to pass 2 and someVar to it, both of the following will work:

elem 2 someVar
2 `elem` someVar

Using infix functions can be less confusing in many circumstances.

Error messages
Ugh. The error messages Haskell gives are almost incomprehensible. If you tried to add a string to an integer it would be,

<interactive>:39:3:
No instance for (Num Char)
arising from a use of `+’
Possible fix: add an instance declaration for (Num Char)
In the expression: 2 + ‘c’
In an equation for `it’: it = 2 + ‘c’

An if statement is an expression
You can do cool stuff like this:

coolFunc x = (if x > 10 then x else x*2) + 1

So if we passed 4 to coolFunc it would return 9 (= 4*2 + 1) and if the argument happened to be 15 it would return 16 (= 15 + 1).

Haskell is lazy
Haskell is a ‘lazy‘ programming language. By lazy, it means that it won’t compute anything until its result is specifically asked for. For example, we can use the following to obtain the first 20 multiples of 7:

take 20 [7,14..]

[7,14..] denotes the infinite array 7,14,21,28 and so on. The above statement asks for the first 20 elements of this infinite array. In another language, the interpreter would try to calculate the infinite array first before taking the first 20. But since Haskell’s lazy, it doesn’t do anything until the function ‘take‘ asks for the first 20 elements. It will only calculate the first 20 elements.

Written by thameera

December 23, 2012 at 7:13 pm

Posted in Uncategorized

Tagged with , ,

Quantum particles are like boos

with 3 comments

If there’s one single subreddit that’s worth subscribing to, it’s /r/explainlikeimfive. The subreddit aims at answering to questions like you’re explaining to a 5 year old, i.e. in a language that everyone can understand.

When I come across a good explanation I clip them to my evernote. I was going through some notes today and came across this clip from a post that dated about two months back. The post explains the work of 2012 Nobel prize winners. There is an explanation that says quantum particles behave differently when we observe them. Someone raises the reasonable question “How do they know they are doing something different when we don’t observe them if we can’t observe them without affecting them previously?” Look at the explanation it got (permalink):

super mario boos

It’s like the boos in Mario. Whenever you look at (measure) them, they stop moving (act like particles). When you look away, they chase you (act like waves). When you look at them again, they’re somewhere totally different.

And just like boos, sometimes they go through walls. But only when you’re not looking.

Exactly what a 5-year would need to understand what’s going on. What’s more, it explains a scientific principle so brilliantly that any of us can understand (albeit it may not be 100% technically correct).

I highly recommend reading the whole thread.

Written by thameera

December 15, 2012 at 8:51 pm

Few hours with App.net

leave a comment »

So I joined app.net today. An year’s subscription costs $36 and there’s a monthly option for $5. I chose the latter for a start.

The global feed, similar to Twitter’s public timeline

It’s pretty much a Twitter-like service with a slightly different vocabulary. You create posts with a maximum length of 256 characters, as opposed to Twitter’s 140 limit on tweets. You can @ reply to other people’s posts and repost the good ones (just like retweeting). Or quote them (old-school retweet) and star them (favorite). There’s no counterpart to Twitter’s DMs as yet, but it’s coming soon. You can follow and unfollow other users.

How does it differ from Twitter?
For one thing, app.net will never advertise or sell their users’ data, as promised by the developers. It will be funded by the subscription fees. This also means only the people who are really interested will join app.net.

Secondly, app.net _is_ an open-source API. It focuses on users and third-party developers. Compare this with Twitter which now shuns third-party apps. Everyone had big hopes on Twitter a few years back, but not anymore. I tweeted a good post on this by Terence Eden some time back. Everyone should read that.

App.net may still be in its early stages, but developers have gathered around the platform and are building apps actively. There are quite a few apps already in the app.net directory. Other than the Alpha webapp by app.net itself, I tried out Dash for Android, NoodleApp for the web, and Texapp, a text-based client written in Perl just like Ttytter by the same developer. Best of all, you can use app.net with IFTTT as well.

appnetstats gives a realtime overview of the current app.net stats. Currently, majority of the users are developers and geeks, which is perhaps a good thing. Lots of constructive conversations going on.

Is app.net going to kill Twitter?
I don’t think so. Not being free will make most users stay out of it for the foreseeable future and stay with Twitter. But app.net will grow into a good community without any of Twitter’s stinking aspects. I really hope this will be the case. It’s been just a few hours, and if the going gets good I may subscribe for a full year. One may argue that no one should pay for a service that you can get for free, but in reality you cannot get what app.net offers from Twitter. You just can’t. They have explicitly defined their core values in their home page and Terms of Service in github.

Follow me on app.net if you’re there; I go by @thameera.

Written by thameera

November 3, 2012 at 8:32 pm