Author Archive

resize an image to a given width by keeping the aspect ratio

You want to resize an image to a given width but you want to keep the width/height ratio of the image.


convert -resize 200 big.jpg small.jpg

Here the new width will be 200 pixels.

Categories: bash Tags: , ,

Google Maps knows where you are

If you type in Google Maps your name, it will show where you are located most of the time. It worked for me. Scary…

list your Firefox add-ons

I use several machines and I would like to create a unified list that contains my favourite Firefox add-ons. This list could be kept in Dropbox, thus I could access it on all my machines. How to generate a list of installed add-ons?

The add-on Addon List Dumper can do exactly this. Here is a screenshot about this add-on:


Categories: firefox Tags:

how to sort 3 values

You have 3 values (e.g. three numbers), and you need to sort them. It could be a simple interview question to warm you up :)

The easiest way might be to use the good ol’ bubble sort. It can be done manually, without loops, since we only have three numbers.

Three values (let’s call them A, B, and C) are sorted, if A <= B <= C. Thus, the pseudo code to sort them is the following:

if A > B: swap(A, B)
if B > C: swap(B, C)    # the largest value is now in C
if A > B: swap(A, B)    # A and B are also sorted now

And now, let’s see it in C:

#include <stdio.h>

int main(int argc, char *argv[])
    int a = 8;
    int b = 7;
    int c = 6;
    int tmp;

    /* sort them in asc. order */
    if (a > b) {
        tmp = a; a = b; b = tmp;
    if (b > c) {
        tmp = b; b = c; c = tmp;
    if (a > b) {
        tmp = a; a = b; b = tmp;

    /* print result */
    printf("%d <= %d <= %d\n", a, b, c);

    return 0;


6 <= 7 <= 8


GitHub status page

If GitHub is down or slow, visit the address above to figure out what’s going on.

Categories: Uncategorized Tags:

extract an animated gif from a video

You have a video and you want to create an animated gif from a part of it.

You can use MoviePy for that. Here you can find a blog post from the author of MoviePy, where the process is explained through several examples. Here I copy three simple examples:

Example 1:

from moviepy.editor import *

clip = (VideoFileClip("frozen_trailer.mp4")  # input video
        .subclip((1,22.65),(1,23.2))         # part to extract, where 1’22.65 means 1 minute 22.65 seconds
        .resize(0.3))                        # resize to 30% of the original
clip.write_gif("use_your_head.gif")          # output animated gif

Example 2 (cropping):

kris_sven = (VideoFileClip("frozen_trailer.mp4")
             .crop(x1=145,x2=400))  # cropping: remove left-right borders

Example 3 (play forward and backward):

def time_symetrize(clip):
    return concatenate([clip, clip.fx( vfx.time_mirror )])

clip = (VideoFileClip("frozen_trailer.mp4", audio=False)
        .crop(x1=189, x2=433)
        .fx( time_symetrize ))  # the effect is added here

For more advanced usage, see the original blog post.

Categories: python Tags: , , ,

bypass redirects in Firefox

There are certain sites where links are randomly redirected to other sites and if you want to visit the intended link, you need to click on the link three or four times and then maybe you are sent to the correct URL.

I found a Firefox add-on called Redirect Bypasser that allows you to visit the correct URL. On a link it shows a little icon, and the little icon is linked to the good URL.

Categories: firefox Tags: ,

Get every new post delivered to your Inbox.

Join 78 other followers