Skip to content

Instantly share code, notes, and snippets.

View anandology's full-sized avatar

Anand Chitipothu anandology

View GitHub Profile
@anandology
anandology / pyexec.py
Last active December 15, 2015 04:59
Example to demonstrate exec in Python
def run(init_code, code, wrapper, tests):
env = {}
exec(init_code, env)
runTests = env['runTests']
# Now all the variables and functions defined in init_code will be available in env
# replace the marker in wrapper. This will be done by erb template in pythonmonk
"""Example to compute word frequency using simple map/reduce utility from openlibrary.
https://github.com/internetarchive/openlibrary/tree/master/openlibrary/data/mapreduce.py
"""
import sys
import logging
from openlibrary.data import mapreduce
class WordFrequecy(mapreduce.Task):
def map(self, key, value):
@anandology
anandology / mysql2pgsql.py
Created May 20, 2013 11:13
Utility to translate MySQL queries to PostgreSQL
"""Script to translate MySQL query to PostgreSQL.
There are three main differences between MySQL and PostgreSQL.
* Postgres expects single-quotes for quoting values, but mysql allows
both single and double quotes. Need to change all the double
quoted values into single quotes.
* Postgres expects double-quotes for column names and mysql expects
back-quotes. Need to change all back quotes to double quotes.
@anandology
anandology / runserver.py
Created May 21, 2013 10:19
suggested improvements to funnel runserver.py
import sys
from website import app, models, init_for
init_for('dev')
models.db.create_all()
try:
port = int(sys.argv[1])
except (IndexError, ValueError):
port = 3000
app.run('0.0.0.0', port=port, debug=True)
@anandology
anandology / funnel-notes.md
Created May 21, 2013 10:23
Notes for setting up funnel

May 21, 2013: Notes from IRC chat with kiran.

jace: funnel has a new user groups feature
jace: we're using that for fifthel to only count votes from ticket holders
anandology: cool. We might want to use it for pyconindia.
jace: you can go to /<space>/users to manage user groups

jace: and then //json will show vote counts by group if you are a siteadmin

@anandology
anandology / Advanced Python Workshop.ipynb
Created May 24, 2013 11:52
Advanced Python Workshop - Class Notes
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@anandology
anandology / 3 - Classes (Advanced Python Workshop).ipynb
Last active December 17, 2015 17:49
Notes from Advanced Python workshop
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@anandology
anandology / 4 - Context Managers (Advanced Python Workshop).ipynb
Created May 26, 2013 10:40
Advanced Python Workshop - Class Notes
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@anandology
anandology / 5 - Meta Classes (Advanced Python Workshop).ipynb
Created May 26, 2013 10:42
Advanced Python Workshop - Class Notes
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.