Pointers for making good use of your processing cores

In the era of multicore processors, one may ask himself “how do I make use of all this processing power on my hands?”. I won’t be writing any in-depth material here, but rather spreading out some interesting pointers.

If you are coding in C/C++, you can give OpenMP a try. I haven’t tried it yet, but I surely want to, as it seems extremely easy: you just add a couple #pragma instructions in your code and it automagically parallelizes it for you! Really, check our their tutorials!

For those that are more Python-oriented, like me, you can try Parallel Python. Not only it can explore the available cores in your computer, but it may also use cores in other computers connected in your local network! I did some testing of this and it worked remarkably well. I plan on doing something fun with this someday.

Last, but not least, if you just have to run the same application several times and would like to use your several cores instead of queueing it all on a single one, then you might want to learn something about xargs… It can do the job for you!

Detailed explanation of the use of xargs is out of the scope of this blog post, so I’ll just point you to the -P switch: it controls how many simultaneous processes it should run at a time. As soon as one terminates, it spawns another one. Great, isn’t it? Credit goes to this blog.

What about you? Any tips for exploring the processing powers of multicore CPUs? Share in the comments!


Avoiding SSH timeouts

I use SSH a lot, and it is a pain when my session times out. This often happens when I step away from the task at hand for a couple minutes. Most of the time, this task is editing a file in vim, and I end up having to restore the file, delete the swap file, etc. Not fun.

My solution for a while was to use screen. This way, I reconnect and continue where I stopped. Better, but the timeouts are still annoying as my terminal becomes unresponsive and I have to close it and reconnect on a new one.

So I decided it was time to solve this. Turns out a simple Google Search found the solution on this blog, and it is dead simple:

Edit your ~/.ssh/config file and add a line containing ServerAliveInterval 60. This sends a keep-alive packet every 60 seconds, which is more than enough to keep your connection from timing out.

Painless, right? Now go and configure your machine, too!

Easy file sharing with Python

I have previously blogged about On-demand Web Server with Python, which is great to serve files you want people (or even yourself, remotely) to download from your computer. Unfortunately, it is unidirectional: people cannot upload files back to you. Luckily, that’s what we are going to address in this post!

Read the rest of this entry »

Word-by-word diffs in Git

I personally like all my LaTeX files wrapped at about 80 columns, with rare exceptions. Of course, I track them all with Git. I use Vim, so it’s really easy to rewrap a paragraph whenever I add or delete content from it. The sad thing is, it totally screws up my diffs!

Have you ever tried looking at the history for any page in Wikipedia? It’s beautiful, intuitive, and word-centered. Forget about lines, they’re not suitable for text. Words, however, are.

Example of the word-by-word diff in Wikipedia

Example of the word-by-word diff in Wikipedia

Well, version control systems use the line-by-line diffs, which don’t really help when comparing two versions of a text file. What to do now?

Read the rest of this entry »

More comfortable reading on the computer screen

Reading PDFs and long texts on the screen has always been something that bothered me and most people I know. It’s just not comfortable! Well, today a colleague of mine showed me something that feels like a solution so good that I wonder why it took me so long to actually stumble upon it.

Read the rest of this entry »

A bash “plugin”: timelast

Did you ever run a process in a terminal that took longer than you expected to finish, and like such, you wanted to know how long it took? Since you didn’t know it would be a long one, you thought running it with time was unnecessary, or maybe you just forgot it… Now what?

Wouldn’t it be awesome if you could find out how long that process took to run? How about if it were as simple as typing timelast or another command that makes sense to you? Well, awesomeness now exists. 😎

Read the rest of this entry »

Setting up a no-password SSH session

As a (really late) follow up to my earlier post about SSH tricks, here follows some instructions on how to setup a no-password SSH session. As a plus, some cool configuration tips for saving some keystrokes! 😉

Read the rest of this entry »