Execute multiple programs and redirect their outputs (Linux)

Recently, I had a situation where I needed to execute multiple programs in Linux at the same time while redirecting their outputs to separated log files and wait for them to finish.

If you ever need to do something like that, I leave year the script that I used to accomplish that task:


# Add the full path processes to run to the array
PROCESSES_TO_RUN=("/home/joao/Code/test/prog_1/prog1" \
# You can keep adding processes to the array...

for i in ${PROCESSES_TO_RUN[@]}; do
    ${i%/*}/./${i##*/} > ${i}.log 2>&1 &
    # ${i%/*} -> Get folder name until the /
    # ${i##*/} -> Get the filename after the /

# Wait for the processes to finish


Gulp vs Grunt in an awesome presentation

Gulp vs Grunt…

Ever used Grunt or Gulp? Both or none? Don’t worry!

This awesome presentation by Mark Dalgleish called build Build Wars will give you a little overview of the differences and similarities between those two builders and hopefully guide you to a final decision.

This presentation was built using Mark’s DIY Presentation Micro-Framework Bespoke.js.

(To see it, just click on it and use your keyboard arrows to navigate.)

If you are having any problem with viewing the presentation, click here.

(NOTE: This presentation is a little old, and back then Gulp was still pretty new. But still gives a nice overview on both.)

How to play an alarm/sound notification in your (python) application

On the other day, I decided to add a sound notification to my unity pomodoro applet and I did a little research. Turns out there are a few options to do this, but not many examples on the internet. And some of those options depend heavily on the operating system and the installation of external modules.

So I ended up being grateful, again, for the invention of Stack Overflow! :)

My solution:

from os import popen

popen("canberra-gtk-play --file=" +
      os.path.join(os.path.dirname(os.path.realpath(__file__)), 'sounds/sound.ogg') + 
      " > /dev/null 2>&1 || true")

Continue reading

Create your first github repository

Why this post?

I know, I know! You’re thinking: “It’s 2015!! Who doesn’t know how to work with github?”

But unfortunately, I still find myself talking with my developer friends and see them talking about the new widget or plugin they developed for some framework they use and I always ask:

Wow that seems really nice, are you thinking about sharing that on github or something?”

And almost always I get the same response:

“Hum no, I don’t usually do that…” or worst, “I never used github…

How? And why? Since it only takes 4, very simple steps, to share your code on gihub.

Continue reading

Scroll a page up and down with jQuery

Sometimes it’s useful to scroll a page up or down automatically to send users to certain parts of the page. One way we can easily accomplish that is by using the scrollTop function from jQuery.

Code example:

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script language="JavaScript">
    function scroll_top()
    function scroll_to_last_div()
        $(window).scrollTop($('#container div:last').offset().top);
    <div id="container" style="display:block; width:400px; margin: 0 auto; text-align: center;">
        <a href="javascript:scroll_to_last_div();">Scroll to last div!</a>
        <div style="display: block; height: 600px; width: 400px; background: #234a34;"></div>
        <a href="javascript:scroll_top();">Scroll to top!</a>
        <div style="display: block; height: 600px; width: 400px; background: #fa342a;"></div>