Alessandro Ghedini /dev/random

Movie time!

I find it very annoying when, in the middle of a video playback I have to move the mouse to avoid the screensaver to start.

To solve this, I wrote a little utility to inhbit any screensaver by moving up and down the mouse pointer every 5 minutes or so automatically. It also hides the mouse cursor so that it doesn’t show up in the middle of the screen:

The code is also on GitHub.

jQuery internals

A video by Paul Irish about the jQuery internals. It explains the jQuery functioning and some elegant and very useful JavaScript tecniques, which can be adapted and used inside your own projects.

Fun with WAVE files in C

Need information about a WAVE audio file? No problem. The format of a WAVE file is quite simple, and most of the information about a given file is stored in its header, which has the following format:

struct wav_header{
    char    id[4];
    int     size;
    char    fmt[8];
    int     format;
    short   pcm;
    short   channels;
    int     frequency;
    int     bytes_per_second;
    short   bytes_by_capture;
    short   bits_per_sample;
    char    data[4];
    int     bytes_in_data;
};

Reading it from a file and storing it in memory, is a a matter of a couple of function calls:

struct wav_header header;
int fd = fopen("/path/to/file", "rb");

fread(&header, sizeof(header), 1, fd);

Now you have the header variable containing all the information about the file.

Here is a little more complete example:

You can find the code in GitHub too.

Apply a patch to the Linux stable tree

In this video Greg Kroah-Hartmann (one of the main Linux developers) explains how patches are applied to the stable tree. It is quite old (about 4 months) but it’s useful to test the template of the blog.

Page 3 of 3