Skip to main content


Showing posts from May, 2017

Come C tricks

Swapping the values of two variables with out using a third!! x = x ^ y; y = x ^ y; x = x ^ y; All hail the XOR operation Reference: int c; c &= (c-1); check if c == 0 This allows you to check if C is a power of 2 (i.e. 0,1,2,4,8...) Reading sentences (including spaces) from stdin: scanf("%s",str); can't read spaces in input string. To do that, you have to: scanf(" %[^\n]s",str); Note the space before % within the quotes. Reference:

Set Elon's latest tweet as your desktop wallpaper

If you have an Ubuntu box, you can use a script to to set your wallpaper's to Elon's Latest Tweet. Here is how you setup: Install required packages. Download - an OAuth based twitter client implemented completely as a bash script. Get Token keys for from your Twitter account and save it in the config file. You need this for OAuth that uses. Get a free account on and fetch your API keys. This service allows you to generate screenshot of any supplied URL - you can use this service to to fetch PNGs's of Elon's tweets. We do screenshots because aren't just interested in tweet's text but also any images that Elon chooses to attach with his tweets. In the batch script ( appended below, configure the pages2images API key Setup the batch script ( as a cron job which runs once every minute. You can set this script up on a Raspberry Pi running Raspbian connected to your TV as well.