Skip to content

Instantly share code, notes, and snippets.

@abhinavgupta
abhinavgupta / aodv_802_15_4.tcl
Created August 7, 2012 10:03
A code snippet that implements a simple star topology with IEEE 802.15.4. Routing protocol - AODV. Simple Beginner simulation in NS2.
# Generated by Topology Generator for Network Simulator (c)
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(netif) Phy/WirelessPhy/802_15_4 ;# network interface type
set val(mac) Mac/802_15_4 ;# MAC type
set val(ifq) Queue/DropTail/PriQueue ;# interface queue type
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 100 ;# max packet in ifq
set val(nn) 500 ;# number of mobilenodes
import numpy as np
from matplotlib import pyplot as plt
#### From XKCD plot generator
"""
XKCD plot generator
-------------------
Author: Jake Vanderplas
This is a script that will take any matplotlib line diagram, and convert it
"""
From this paper: http://acl.ldc.upenn.edu/acl2004/emnlp/pdf/Mihalcea.pdf
I used python with nltk, and pygraph to do an implmentation of of textrank.
"""
import nltk
import itertools
@abhinavgupta
abhinavgupta / fetch_url.py
Created October 16, 2012 13:44
Simple script for faster fetching with urllib2 with exception handling
import threading, urllib2
import Queue
def read_url(url, queue):
try:
data = urllib2.urlopen(url).read()
except urllib2.HTTPError, e:
checksLogger.error('HTTPError = ' + str(e.code))
except urllib2.URLError, e:
checksLogger.error('URLError = ' + str(e.reason))
@abhinavgupta
abhinavgupta / TextRank.py
Created October 16, 2012 17:25
PageRank for text summarization
import networkx as nx
import numpy as np
from nltk.tokenize.punkt import PunktSentenceTokenizer
from sklearn.feature_extraction.text import TfidfTransformer, CountVectorizer
def textrank(document):
sentence_tokenizer = PunktSentenceTokenizer()
sentences = sentence_tokenizer.tokenize(document)
@abhinavgupta
abhinavgupta / opencv_install.sh
Created March 10, 2013 09:01
Shell script to install OpenCV 2.3 on your debian machine
arch=$(uname -m)
if [ "$arch" == "i686" -o "$arch" == "i386" -o "$arch" == "i486" -o "$arch" == "i586" ]; then
flag=1
else
flag=0
fi
echo "Installing OpenCV 2.4.3"
mkdir OpenCV
cd OpenCV
echo "Removing any pre-installed ffmpeg and x264"
@abhinavgupta
abhinavgupta / opencv_install.sh
Created March 10, 2013 09:01
Shell script to install OpenCV 2.3 on your debian machine
arch=$(uname -m)
if [ "$arch" == "i686" -o "$arch" == "i386" -o "$arch" == "i486" -o "$arch" == "i586" ]; then
flag=1
else
flag=0
fi
echo "Installing OpenCV 2.4.3"
mkdir OpenCV
cd OpenCV
echo "Removing any pre-installed ffmpeg and x264"
@abhinavgupta
abhinavgupta / opencv_install.sh
Created March 10, 2013 09:01
Shell script to install OpenCV 2.3 on your debian machine
arch=$(uname -m)
if [ "$arch" == "i686" -o "$arch" == "i386" -o "$arch" == "i486" -o "$arch" == "i586" ]; then
flag=1
else
flag=0
fi
echo "Installing OpenCV 2.4.3"
mkdir OpenCV
cd OpenCV
echo "Removing any pre-installed ffmpeg and x264"
@abhinavgupta
abhinavgupta / opencv_install.sh
Created March 10, 2013 09:01
Shell script to install OpenCV 2.3 on your debian machine
arch=$(uname -m)
if [ "$arch" == "i686" -o "$arch" == "i386" -o "$arch" == "i486" -o "$arch" == "i586" ]; then
flag=1
else
flag=0
fi
echo "Installing OpenCV 2.4.3"
mkdir OpenCV
cd OpenCV
echo "Removing any pre-installed ffmpeg and x264"
@abhinavgupta
abhinavgupta / opencv_install.sh
Created March 10, 2013 09:01
Shell script to install OpenCV 2.3 on your debian machine
arch=$(uname -m)
if [ "$arch" == "i686" -o "$arch" == "i386" -o "$arch" == "i486" -o "$arch" == "i586" ]; then
flag=1
else
flag=0
fi
echo "Installing OpenCV 2.4.3"
mkdir OpenCV
cd OpenCV
echo "Removing any pre-installed ffmpeg and x264"