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
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
anandology / shp2pgsql.txt
Created Mar 27, 2014
shp2pgsql for AC and PC data
View shp2pgsql.txt
[geosearch-anandology.rhcloud.com S01]\> shp2pgsql -W "latin1" -s4326 -d S01_AC ac geosearch > ac.sql
Shapefile type: Polygon
Postgis type: MULTIPOLYGON[2]
[geosearch-anandology.rhcloud.com S01]\> psql -q geosearch < ac.sql
dropgeometrycolumn
-------------------------------------
public.ac.geom effectively removed.
(1 row)
NOTICE: CREATE TABLE will create implicit sequence "ac_gid_seq" for serial column "ac.gid"
View voterlist2pdf.py
"""Script to generate voterlist PDF.
References:
* https://pkimber.net/howto/python/modules/reportlab/header-footer.html
* http://www.blog.pythonlibrary.org/2010/09/21/reportlab-tables-creating-tables-in-pdfs-with-python/
* http://www.hoboes.com/Mimsy/hacks/multiple-column-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)
p++;
@anandology
anandology / sa.py
Last active Aug 29, 2015
SA like query chaining for web.py db
View sa.py
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
anandology / 0-readme.md
Last active Aug 29, 2015
tcpdump analysis of ADE4
View 0-readme.md

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
anandology / winners.py
Last active Aug 29, 2015
Python script to select winners at random using donation amount as weight
View winners.py
"""Script to pick N random entries from a file using donation amount as weight.
USAGE: python winners.py filename num-winners
"""
import random
import sys
import argparse
import time
def weighted_choice(elements, weight_func):
@anandology
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
anandology / email-count.py
Created Apr 10, 2015
Script to find the number of emails in the given gmail account
View email-count.py
"""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
anandology / index.html
Created Jun 20, 2015
Example to try incremental template rendering
View index.html
<html>
<head><title>Incremental Tornado Templates</title></head>
<body>
<h1>Incremental Tornado Templates</h1>
{% import time %}
<ul>
{% for i in range(n) %}
<li>{{ i }}</li>
{{ time.sleep(delay) or "" }}
You can’t perform that action at this time.