Let there be light, in skype!

At home, my video would always show a silhouette in G+ and Skype, and I always thought that this was because the lighting at home was not sufficient. At office, the video was decent. But, moving to sit right under the light also didn't help much.

Struggling with a bunch of tools like v4lctl, guvcview didn't help. But, during these struggles I noticed that cheese would show me bright and cheerful, while all the other programs showed my silhouette.

I set out to "fake" the output of cheese as a video device that skype and other programs could use. But, I didn't have to go all the way. I ended up using v4l2loopback to create a loopback video device, and just using gst-launch to redirect video to that device, did the trick! Thanks gstreamer! Thanks v4l2loopback! :)

Here's a convenient script to use it every time I need it.

Scraping Google Groups

I was playing around with a few ideas for creating a timeline for the mumbai ultimate group, and as a part of playing around with stuff, for that idea, I ended up wanting to scrape all the emails on our google group. After looking around a little bit, I failed to find anything that claims to be able to do this.

So I ended up writing my own hacky script to download all the emails sent on the group. Like I said, this is a hack and can be improved quite a bit, but I am not inclined to do anything about it, right now. Since, everything about google groups is ajaxy, this script uses selenium and does things on the page, that one would do by hand. It's not something that I am proud of, but it does the job!

A smarter 404 page.

Voodoo found a broken link referring to a one of my posts, on Quora. Given that I have changed my site generator a bunch of times now, it is quite possible that there are other broken links at various other places. So, I implemented a smart 404 page for the site, yesterday. It is very similar to something I came across on brettterpstra's site. I just hooked up fuse.js with Nikola's tipue-search plugin's output file. My glue code essentially, just figures out the search term from the URL, performs a Fuse search on the json data created by Nikola's search plugin, and returns a list of top 5 results. It just took me about an hour to write, but is pretty useful, I think.

Blogging with Nikola and Org-mode

Sigh! I made yet another change to the way this blog gets published. But, I have a feeling this mechanism, is here to stay!

We've been using Nikola quite regularly for our Ultimate site, and I quite like it. I've also contributed a bunch of features to Nikola to get it to work the way I would like it to. This weekend I ported my blog from o-blog to Nikola. The only thing that was stopping me from doing it, until now is the fact that all my posts are in org markup and porting them over to one of the formats that Nikola supports would be a PITA. So, I wrote a pretty simple plugin to Nikola to support posting from org files. And then with a little Python, I was able to move everything over to use Nikola.

Hopefully, I'll keep my blog more updated, from here on!

GitHub Cue: Recommendations for GitHub Repos

If you aren't already aware of it, I'm one of those people who goes around saying, "GitHub is my Facebook". I spend quite a lot of time on GitHub, browsing the work of various people, looking at loads of interesting stuff that people built. I keep jumping between people pages and projects using the Watchers/Watching & Followers/Following pages. This way, I do come across interesting people and projects, but the SNR is too low. I wanted a better way to be able to see stuff, that I find interesting. That's how the idea for this Chromium app โ€“ GitHub Cue โ€“ was born.

@baali and I hacked on this, during the last few days and got it working. It works as follows, (from the README) โ€”

  1. Scrapes all the descriptions of the repositories being watched by the user.
  2. Key terms are extracted from this description text using the Yahoo Term Extractor.
  3. A list of languages is obtained, based on the languages of the repositories, the user if watching.
  4. GitHub searches are performed for a combination of 3 randomly chosen languages and 5 random key terms.
  5. 10 random repositories out of all these, are shown.

This is a very simplistic algorithm, but works decently for my purposes. Ideally, I would've liked to use a Collaborative Filtering algorithm, but I found the data to be too sparse, and the amount of computation to be too much to be done on the fly. I wasn't really interested in pre-computing stuff and putting it onto my server. I settled down to the next best thing I could think of.

I would appreciate any further ideas and suggestions. Thanks!

Do our eyes suck at blue?

This is some fun I had, trying to replicate what was written in this post. I had been trying to understand what was happening here, and found this post on Hacker News very helpful.

It is a known fact that our eyes have more cones for green and red as compared to blue. The Bayer filter used for digital camera lenses is based upon this principle. This post tries to illustrate that using the following two arguments.

  • Looking at only the blue channel of an image looks very dark.
  • Tripling the pixel size of blue channel doesn't cause much distortion in the final image.

Hence, our eyes suck at blue.

Their argument is flawed, but we could try and improve a few things.

Looking at the blue channel.

This is definitely flawed, since the intensity of blue in the image they have taken may be less and hence giving us a false positive.

We could instead gray-scale the image and use these pixel values in the 3 channels and look at the images.

This also eliminates the problem of the image being captured through a Bayer filter.

Here's some python code to do the same. (uses matplotlib)

def show_channels(I):
    for i in range(3):
	J = zeros_like(I)
	J[:, :, i] = I[:, :, i]
	figure(i)
	imshow(J)

def show_grey_channels(I):
    K = average(I, axis=2)
    for i in range(3):
	J = zeros_like(I)
	J[:, :, i] = K
	figure(i+10)
	imshow(J)

Pixelating the blue channel

Again, there was this argument of use of Bayer filter affecting the image and the like.

What I did was to swap the channels, and then look at the images. However I swapped the channels, the image where the green channel was pixelated always looked the worst. The difference between blue and red was less noticeable, I feel.

Here's the code.

def zoom(x, factor=2):
    rows, cols = x.shape
    row_stride, col_stride = x.strides
    view = np.lib.stride_tricks.as_strided(x,
			(rows, factor, cols, factor),
			(row_stride, 0, col_stride, 0))
    return view.reshape((rows*factor, cols*factor))

def subsample(I):
    for i in range(3):
	J = I.copy()
	J[:, :, i] = zoom(I[::4, ::4, i], 4)
	figure(i)
	title("%s channel subsampled" %colors[i])
	imshow(J)

def swap_subsample(I, k=1):
    for c, color in enumerate(colors):
	print "%s <-- %s" %(colors[c], colors[(c+k)%3])
    for i in range(3):
	J = zeros_like(I)
	for j in range(3):
	    J[:, :, j] = I[:, :, (j+k)%3]
	J[:, :, i] = zoom(I[::4, ::4, (i+k)%3], 4)
	figure(i+10)
	title("%s channel subsampled" %colors[i])
	imshow(J)

Images

Here are a few images. (View them in their original size)

channels.png

subsample.png

Raise windows (on current desktop) xdotool & bash

I posted a snippet 1 of python code that used xdotool to raise windows. I got one patch from dusual 2 that enabled raising of windows in the current workspace only.

More importantly, Jordan gave a one-liner 3 in bash, that could do the same thing as my long and elaborate python snippet. I had a feeling that this would be much shorter in bash, but I don't feel comfortable writing bash scripts. :P

Below is a bash snippet that tries to incorporates both the changes. :)

found=0

for win in `xdotool search --class $1`;
do
if [ `xdotool get_desktop_for_window $win` -eq `xdotool get_desktop` ];
then found=1; break;
fi;
done

if [ $found -eq 1 ]; then xdotool windowactivate $win; else $1; fi

Note: When you've visual effects enabled (the default option on Ubuntu), getting the current desktop/workspace doesn't work, probably because Root Window properties are being messed around by it.

Note2: search takes an option --screen. It'd be nice if it also had an option --desktop. This task could then be done in a one-liner.

Footnotes:

1

My python snippet

2

dusual on twitter

3

Jordan's one liner

Is Disney buying MIT??

web.hacked.screenshot.medium.gif

On April Fools Day of 1998, hackers broke into the MIT web server and changed the MIT home page to indicate that The Walt Disney Company had purchased MIT for $6.9 billion.

The hacked page contained a link fake to a press release titled Walt Disney Corporation to Acquire MIT for $6.9 Billion.

Later that day the MIT News Office issued a press release titled MIT says "Disney buys MIT" hack revealed by low price

A "Free Software" Hack!!

freesoftware.hack.jpg

Date: Sun, 31 Aug 2003 23:45:42 -0500
From: "Harley D. Eades III"
To: rms@gnu.org
Subject: Tribute to freedom.

Hello,

One late rainy night I had an idea. There is a hill on IL route 29
in Peoria IL, that people climb and write a small message across
this hill for everyone to view from a far. What would be better
than spreading my two most favorite words across this hill. So we
set out with a little over 200 garbage bags and nearly 400
nails. 12:30am and rainy so you can figure that a hill of that
size is going to be slippery (lol) nearly falling down hill with
every step we start building each letter. At around 2:30am we have
finished and now the sun will rise over a hill which spreads the
words Free Software to every person that passes by. This is by far
a vary small non-complex hack but I beleve it is a hack in it
self. This is a tribute to Free Software [and the GNU Project].

Happy Hacking
Harley D. Eades III
FSF Associate Member
Hacker