Skip to content

Instantly share code, notes, and snippets.

We are hiring!

Anand Chitipothu anandology

We are hiring!
Block or report user

Report or block anandology

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
anandology / day1.ipynb
Last active Aug 29, 2015
Advanced Python Training at LinkedIn -- Feb 26 - Mar 1, 2014
View day1.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
anandology / shp2pgsql.txt
Created Mar 27, 2014
shp2pgsql for AC and PC data
View shp2pgsql.txt
[ S01]\> shp2pgsql -W "latin1" -s4326 -d S01_AC ac geosearch > ac.sql
Shapefile type: Polygon
Postgis type: MULTIPOLYGON[2]
[ S01]\> psql -q geosearch < ac.sql
------------------------------------- effectively removed.
(1 row)
NOTICE: CREATE TABLE will create implicit sequence "ac_gid_seq" for serial column "ac.gid"
"""Script to generate voterlist PDF.
from reportlab.platypus import BaseDocTemplate, Frame, PageTemplate, Table, TableStyle
from reportlab.lib.pagesizes import A4, inch, landscape
from reportlab.lib import colors
View 225.c
#include <stdio.h>
void hack() {
int start = 0;
int *p=&start;
/* start moving up the stack until we find the marker. */
while (*p != 0x12345678)
anandology /
Last active Aug 29, 2015
SA like query chaining for db
import web
class SelectQuery:
def __init__(self, tables):
if isinstance(tables, basestring):
tables = [tables]
self._tables = tables
self._columns = "*"
self._where = web.SQLQuery("")
self._order = []
anandology /
Last active Aug 29, 2015
tcpdump analysis of ADE4

After reading [Adobe is Spying on Users, Collecting Data on Their eBook Libraries][1] article by [Nate Hoffelder][2], I didnt an test my self to see how it is effecting [Internet Archive][3]'s [Open Library][4] lending program.

Here are the things that I did, in this order.

  • borrowed a book from OL in epub format
  • started tcpdump
  • started ADE
  • opened the book in ADE
  • read it
  • read some other epub book
anandology /
Last active Aug 29, 2015
Python script to select winners at random using donation amount as weight
"""Script to pick N random entries from a file using donation amount as weight.
USAGE: python filename num-winners
import random
import sys
import argparse
import time
def weighted_choice(elements, weight_func):
anandology / math.txt
Last active Aug 29, 2015
Are my trainings very expensive?
View math.txt
Someone on twitter said my python course is too expensive.
Here are some quick calculations to show cost-of-class-per-day is not any more expensive than typical college education.
Tution fee per year for college education - Rs. 1,00,000
Number of working days = 200
Fee per day - 100000/200 = 500
Number of students in class = 60
cost per class per day = 60*500 = 30000
anandology /
Created Apr 10, 2015
Script to find the number of emails in the given gmail account
"""Script to count the emails received in a gmail account and posts it to a web hook.
import imaplib
import optparse
import json
import urllib2
def count_emails(username, password, folder="INBOX"):
"""Returns the number of emails in specified folder.
anandology / index.html
Created Jun 20, 2015
Example to try incremental template rendering
View index.html
<head><title>Incremental Tornado Templates</title></head>
<h1>Incremental Tornado Templates</h1>
{% import time %}
{% for i in range(n) %}
<li>{{ i }}</li>
{{ time.sleep(delay) or "" }}
You can’t perform that action at this time.