Month: December 2011

Bash script to find mutual friends in Identica

I guess this is my first technical post involving script in it.

Starting this week, due to a recent change in my job role, I planned to spare my knowledge more on coding, along with technical aspects.

As a start, I came across my junior’s blog post yesterday about finding mutual friends in twitter. I thought to try one for Identica as well. As a result, I found the equivalent api’s for Identica. Here comes the code with a slight modification. Hope the below script is self explanatory.

#!/bin/bash

curl ‘http://identi.ca/api/friends/ids.json?screen_name=’$1 > .fol.tmp

curl ‘http://identi.ca/api/friends/ids.json?screen_name=’$2 > .fol2.tmp

cat .fol.tmp | sed ‘s/.*[([0-9,]*)].*/1/’ | sed ‘s/,/n/g’ | sort > .ids.tmp

cat .fol2.tmp | sed ‘s/.*[([0-9,]*)].*/1/’ | sed ‘s/,/n/g’ | sort > .ids2.tmp

#comm -12 is same as grep -xFf 🙂

grep -xFf .ids.tmp .ids2.tmp | tr ‘n’ ‘,’ | sed ‘s/,$//’ > .comids.tmp

comids=`cat .comids.tmp`

curl ‘http://identi.ca/api/users/show.json?user_id=’$comids > .lookup.tmp

cat .lookup.tmp | tr ‘,’ ‘n’ | grep ‘”name”‘ | sed ‘s/.*:”([^”]*)”/1/g’ > .show.tmp

#If loop to find if the file is empty. Read the man pages of test to understand the below logic.

if [[ -s .show.tmp ]] ; then

cat .show.tmp

else

echo “No mutual friends in Identica, Try with a different pair”

fi ;

rm .fol.tmp .fol2.tmp .ids.tmp .ids2.tmp .comids.tmp .lookup.tmp .show.tmp

The Output is as follows :

$ ./identica.sh ijeyanthan vigneshwaranr

No Identica followers, Try with a different pair

Unfortunately, not many people are using Identica and thus a very few followers.

This is applicable for any other StatusNet installs. The API root will be determined by whatever you set in your  in config file.

Eg :  http://www.yoursite.org/statusnet/api

and for Twitter, replace identica with http://api.twitter.com/1/,

Please add your suggestions & tips for better coding.

How to stop Ctrl+Shift+Q from closing in Chrome abruptly?

I am an ardent fan of Google Chrome browser. I always work with multiple tabs ranging 25 to 40+ kept open. I also use multiple laptops for my work (Thank to Google Sync, as it helps me manage preferences, extensions across computers). As the keyboard layout differs among PC’s, I sometimes hit Ctrl+Shift+Q  by mistake instead of Ctrl+Shift+tab and it annoys the hell out of me. Yes, it closes the entire set of opened tabs without any warning popup message. Though there is a way to restore all those closed tabs by clicking “Recently closed tabs”, I badly need to get rid of this shortcut.

The browser has to save the exact state of the closed tabs contents if you plan to restore later, this might mess with web applications that work asynchronously and try to keep track of the client’s connection and session. Salesforce annoys me not just by logging out, but also gets the page redirected to it’s home page when I expect it to restore it’s session as such before closing.  The pathetic thing is, it deletes the entire history when we click back. Firefox does a pretty good job of maintaining this perfectly.

There can be only two options. Either to disable ctrl+shift+Q shortcut or to have a popup cautioning me about the closure, so that I can cancel it. Firefox, Internet Explorer 7+, and Safari all do this nicely now (either warning, or both warning and offering to re-open all tabs when next run).

I have been missing this feature for so long and so does many other impatient users. Looks like it has not yet been fixed yet.

http://code.google.com/p/chromium/issues/detail?id=147

To overcome this, I was trying out some extensions to overcome this issue and found the following app to be promising.

https://chrome.google.com/webstore/detail/lnpifgapnmpninomacbhdlconlpikdai – Window Close Protector.

Though there are few other extensions available in Chrome Webstore for altering the shortcut and was not so useful, I stick to this simple extension. This saved my day 🙂

Please be informed about it’s known bug..

If you’ve just installed the extension, it will not retroactively protect pages that are already open. Only new windows get protected. So, don’t try right away if it works. I was already victimized the first time 🙂

List of free courses offered from Stanford, Yale, Harvard and MIT !

Hi,

Encouraged by the response for the three online classes currently running
http://www.ai-class.com/
http://www.ml-class.org/
http://www.db-class.org/

Stanford is now launching the following classes in 2012:

Immediately below, you’ll find the latest additions. All of these courses feature interactive video clips; short quizzes that provide instant feedback; the ability to pose high value questions to Stanford instructors; and feedback on your overall performance in the class.

Courses start in January and February. Enroll today for free. And, if something doesn’t pique your interest below, don’t miss our big list of 400 Free Online Courses.

Newly added:

Technology Entrepreneurship
Making Green Buildings
Anatomy
Information Theory
Design and Analysis of Algorithms I
The Lean Launchpad
Cryptography

Originally mentioned:

Computer Science 101
Software Engineering for SaaS
Human Computer Intereaction
Natural Language Processing
Game Theory
Probabilistic Graphical Models
Machine Learning

More Free Courses from Top Universities

You can download lectures (usually in audio and video) from iTunes, or directly from the Yale web site. And then, of course, YouTube is a good third option…

MIT Introduces Complete Courses to OpenCourseWare Project

Harvard Presents Free Courses with the Open Learning Initiative

 

Source : http://www.openculture.com