This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from lxml import html | |
import requests | |
import os, sys | |
import time | |
def fetch_table(): | |
page = requests.get('http://en.wikipedia.org/wiki/List_of_S%26P_500_companies') | |
tree = html.fromstring(page.text) | |
xpath = '//*[@id="mw-content-text"]/table[1]' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
allpdfs="" | |
for f in "$@" ; do | |
filename=$(basename "$f") | |
filename="${filename%.*}" | |
pygmentize -f tex -O linenos -O title=$( echo $filename | tr '_' '-').py -O full -O style=default -o /tmp/$filename.tex $f | |
pdflatex -jobname=$filename -output-directory=/tmp /tmp/$filename.tex | |
allpdfs="$allpdfs /tmp/$filename.pdf" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for x in (x for x in arr if x>0): | |
print('{} is positive'.format(x)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#-*- coding: utf-8 -*- | |
# Copyright 2013 Subhodeep Moitra, all rights reserved | |
# [email protected] | |
import argparse | |
import os,sys | |
def log(n,base) : | |
return 0 if n==1 else 1+log(n/base,base) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ -n "$(grep gmail /etc/hosts)" ] | |
then | |
echo "Gmail found : $(grep gmail /etc/hosts)" | |
echo "Removing gmail" | |
sed '/gmail/d' /etc/hosts > /tmp/gmailtoggle | |
sudo cp /tmp/gmailtoggle /etc/hosts | |
else | |
echo "Gmail not found, Adding gmail" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"" Modified from Mahdi | |
set nocompatible | |
syntax enable | |
set encoding=utf-8 | |
set showcmd | |
set t_Co=256 | |
filetype off | |
execute pathogen#infect() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open('/tmp/bla','w') as fout : | |
for i in xrange(10) : | |
print >>fout, i,chr(64+i) | |
import sys | |
for i in xrange(10) : | |
print >>sys.stdout, i,chr(64+i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Goes to a HTML forms demo page and tries to submit some data to it | |
using the mechanize browser | |
""" | |
import mechanize | |
import re | |
page_link= "http://www.w3schools.com/html/html_forms.asp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
arr = range(10) | |
random.shuffle(arr) | |
reduce(lambda x,y: (x[1]<y[1])and x or y ,enumerate(x))[0] |