Pay attention on the details. It matters!

I watched by accident yesterday this TED talk by Rory Sutherland and it changed (at least for now) my view of the “small stuff” or the details. As a developer doing IT consulting as daily job I have hundreds of little tasks on my todo list which I don’t like doing. Some of them are really small changes, like changing the font size somewhere etc, but I never have the appetite to d them. I just find them boring & while there are more “important” things to do I never find time to do any of them.

But yesterday after watching this talk I got inspired and I did some improvements on a data dashboard. Those were small stuff like making the table header scroll down so you it’s always visible or changing the display of dates from “2012-10-25” to “Mon 25/10”.

And you know what? It worked! Today at noon I got this email (see below).

The changes you have made to the dashboard for the data checking is AWESOME!!!!!!

Super Thank you!!!!! :-)

This has of course brought a big smile on my face and a lot of motivation to do more things. Some of them are other small stuff that I would never do.

Enjoy the talk! which very probably you’ll find completely irrelevant to what I wrote above but it worked for me so I want to share it with you 🙂

Multiple editing with Sublime Text 2

There are many times where you want to rename a variable that appears in many lines right? How can you do that with Sublime Text 2?

Alt + F3 <while having the cursor on what you want to rename>

Also, if Alt + F3 selects too many variables you can use to select them one by one (selects the next appearance each time you press it)

Ctrl + D <again while having the cursor on what you want to rename>

I know it’s really simple shortcut & you might be wondering why did I even post about it. Well .. the reason is that I simply forget it every time and I thought of writing it here so I know where to find it when I need it. Cause apparently I’m searching with the wrong keywords (multiple line editing in Sublime Text 2) and I don’t get the quick answer I need.

Hope this will be useful to somebody else as well 🙂

Update: Found this nice about the multiple selection keyboard shortcuts for Sublime Text 2

Have a nice day!

Alt + Shift + 0 on DWM

I have been using DWM for more than a year & I certainly love this window manager. It’s so lightweight, fast & simple that makes you forget all the features it is missing.

What I discovered today by accident is that you can attach a window to all the tags! Guess how?

Alt + Shift + 0 of course!

Why would that be useful? Well .. for me it’s useful cause I want sometimes to have the browser in all the tags so I can see it when I am looking at the code or when I’m doing some database changes on the terminal. Other reason could be to have an active skype chat all around so that you notice when a person replied.

If you don’t find it useful then you can not use it of course. But I won’t tell you the command how to remove it from all tags 🙂

Functional Programming in PHP

For the last half a year I have been coding in Scala and today I had to switch back to PHP to add some functionality to an old service. The interesting part was that it was coming more naturally to me to use filter and map to do my job instead of using foreach. Well .. here is what came out:

$keywords = array_filter( explode(" ",$keyword), function($x) { return !empty($x); } );
$keywordsQuery = implode( " AND ", array_map ( function($x) { return "body LIKE '%$x%'"; }, $keywords) );

This was the first time I was using array_filter and array_map and anonymous functions so I was very excited while writing it but the result isn’t the most readable. Also it wasn’t so easy to write it cause I had to go to the PHP website to check in which order do the arguments go (first the callback or the array?), which is something you don’t need to check when coding in a more object-oriented way. Also I noticed that PHP’s anonymous functions have a similar ugliness with Javascript. You have to write the whole word “function” which takes quite some space and makes inline anonymous functions very verbose & hard to read.

Anyway. Luckily I wont have to write too much code in PHP for this new feature and I hope there wont be many more things to write in PHP. I’m not saying that the there is something wrong with the language. I’m just saying it’s hard to go back from Scala to PHP.

So .. that’s all I wanted to share with you today. Below is the code of how I would do it in Scala (didn’t run it but more or less it should work!).

keywords = keyword.split(" ").filter(_.nonEmpty).map(x => "body LIKE '%" + x + "%'").mkString(" AND ")

Gist for my little scripts & configuration files

From time to time I write some scripts to automate tasks. For example, I might write a script to upload some files using POST to a service, or a script to deploy code to a server etc. But not always I can add them to a repository so they are backed up by a version control system. And when the time comes to format my computer I need to go all around & make copies of those scripts.

Sometime ago I discovered Gist offered by Github. Gist allows you to create a repository for storing the contents of one file & keep versions whenever you re-upload it (edit it). And you can do it all through the browser & access those files anywhere and at anytime. This is perfect for backing up your scripts & configuration files. I used Gist for the following:

  • apache & nginx configuration file
  • ~/.bashrc
  • various scripts to do any sorts of tasks
  • nice terminal commands that you can never remember

And I’m planning to add there each little script I write from now and on! But I need to remember every time I modify the script to re-upload it to Gist.

Ok .. that’s all I wanted to write. Not very interesting but really useful! I’m not joking. I just moved to my new laptop & I didn’t need to move any configuration file from my previous computer cause I had them all on Gist 🙂