Python scripts with Facebook Api

In earlier posts we used facebook php api . Now it’s time to try basic python api usage . Please note that this api is not official .

There are many amazing things you can do with python api , like data mining . So let’s get started.


Get access token from Graph explorer  

Get access token


Install facebook-sdk using pip

pip install facebook-sdk

Get list of all facebook friends

import facebook

#import this package to print data structure in better way
from pprint import pprint  

#use acess token from previous step
graph = facebook.GraphAPI(access_token)

my_profile = graph.get_object("me")

friends = graph.get_connections("me","friends")

#view only first 10 friends

Status update from terminal

graph.put_object("me", "feed", message="python is awesome")

Get likes of friends

#ge likes of first friend
likes = graph.get_connections(friends['data'][0]['id'],"likes")

I’ll add more code soon.

Vim for beginners

I recently started using vim and it is the best editor I ever used . With right .vimrc settings and plugins productivity can be increased . I have listed here some resources I use .

.vimrc Settings

Open your .vimrc file(located in home folder) and add following lines to have features.

"Show line number in code
set number

"To wrap up lines
set wrap

"Return to position you last edited (very important)
autocmd BufReadPost *
 \ if line("'\"") > 0 && line("'\"") <= line("$") |
 \ exe "normal! g`\"" |
 \ endif

 " See what you are typing as a command.
set showcmd

" For Syntax Highlighting
 filetype on
 filetype plugin on
 syntax enable
 set grepprg=grep\ -nH\ $*

" Enable mouse support in console
 set mouse=a

" Highlight current line
set cul

" Show matching brackets (useful while coding)
set showmatch

" highlight the search
set hlsearch

" Swap ; and : Convenient. You don't have to type SHFT + ; only ; would work , thus saves you a key stroke
 nnoremap ; :
 nnoremap : ;

" Remap jj to escape in insert mode.
 inoremap jj <Esc>

Vim have lots of plugins, but remember excessive plugin usage can slow down your vim.

Pathogen : This should be your first plugin to install . It make  super easy to install plugins and manage them. After using pathogen your ~/.vim directory will have a bundle subdirectory, where you put all your plugins.

SuperTab : Supertab allows you to use <Tab> for all your insert completion needs

Nerd tree : The NERD tree allows you to explore your filesystem and to open files and directories. It presents the filesystem to you in the form of a tree which you manipulate with the keyboard and/or mouse.

Conque Shell : Conque is a Vim plugin which allows you to run interactive programs, such as bash on linux or powershell.exe on Windows, inside a Vim buffer. In other words it is a terminal emulator which uses a Vim buffer to display the program output.

Color schemes

There are many color schemes available for vim . To use these color schemes make colors subdirectory in .vim directory and put all your color schemes there.

Solarized is one of the most famous color scheme.

Real time Online visitor counter with Firebase

Firebase is THE api to build realtime applications quickly. All you have to do is to manage your front end . I have made an online visitors counter with real time update.

Live Demo


I used web api to integrate firebase with app. Main front end code is written in javascript.

I am storing visitor’s ip address and and their referral as shown in line 6.

//firebase reference
var userListRef= new Firebase('');

//register yourself
var myUserRef = userListRef.push();
myUserRef .set({'IP': '<? echo $_SERVER[SERVER_ADDR]?>', 'Referrer': '<?echo $_SERVER['HTTP_REFERER']?>'});

// Get a reference to my own presence status.
var connectedRef = new Firebase("");
connectedRef.on("value", function(isOnline) {
if (isOnline.val()) {
 // If we lose our internet connection, we want ourselves removed from the list.

//update counter whenever a user is added
userListRef.on("child_added", function(snapshot) {
 userListRef.once('value',function(snapshot) {
 var x = snapshot.numChildren();
 $("#show_counter").html("<div style='text-align:center;font-size:72pt;'>"+x+"</div>");

//update counter whenever a user is deleted
userListRef.on("child_removed", function(snapshot) {
 userListRef.once('value',function(snapshot) {
 var x = snapshot.numChildren();
 $("#show_counter").html("<div style='text-align:center;font-size:72pt;'>"+x+"</div>");

Data structure

Real time data of your app is hosted on firebase servers. You can see your data on your firebase generated url . Mine looks like this.
firebase datastructure

Apps android users must have

Power Toggles

This is a home screen widget and notification widget. Containing 40+ toggles including Flashlight, Wifi, Bluetooth , Mobile Data (3G/4G) , Custom application shortcut, Custom system shortcuts and many more. It has many customization options like changing themes and icons for individual toggles.


It is a free app which helps you to remember everything. It helps to take notes, capture photos, create to-do lists, record voice reminders and makes these notes completely searchable anytime or anywhere.

AVG Antivirus

The most  popular antivirus for PC is also available for mobile and is free too. You must have this app to prevent yourself from virus.

Juice Defender

One complaint which android user may have is of its power consumption. This app helps you to save the juice of your battery by  managing  the most battery draining components, like 3G/4G connectivity and WiFi. Its comes in a free and paid version also.

There are other alternatives to juice defender like Autoairplane which does similar function like juice defender.

File Explorer

This app helps you to easily manage the files present in your mobile. It also provides support to share your files through LAN and FTP.

Office suite Viewer

This app lets you to view and edit all your documents from  your mobile. Its supports DOC, DOCX, DOCM, RTF, TXT, LOG, XLS, XLSX, XLSM, CSV, PPT, PPTX, PPS, PPSX, PPTM, PPSM, EML, PDF and ZIP file