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
var http = require('http'), | |
, httpProxy = require('http-proxy') | |
, express = require('express'); | |
app = express(); | |
var apiUrl = 'http://api.example.com:80'; | |
var proxy = httpProxy.createProxyServer({target:apiUrl}); | |
app.all('/api/*', function(req, res) { |
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 | |
from pandas.io.sql import read_sql | |
import MySQLdb | |
from flask import Flask | |
app = Flask(__name__) | |
qry = "select * from adh_bayescomp_msn limit 100" | |
db = MySQLdb.connect(read_default_file="~/.my.cnf.quark") |
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 json | |
import hashlib | |
import flask | |
import flask.ext.sqlalchemy | |
import flask.ext.restless | |
from flask.ext.restless import ProcessingException | |
app = flask.Flask(__name__) | |
app.config['DEBUG'] = True | |
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db' |
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
# get count of users by birthday who've clicked in the last 7 days | |
results = session.query(User)\ | |
.join(Click, User.id == Click.user_id)\ | |
.filter(Click.created_at > datetime.datetime.today() - datetime.timedelta(days=7))\ | |
.groupby(User.birthday)\ | |
.orderby(User.birthday)\ | |
.values(User.birthday, | |
func.count(func.distinct(User.id))) |
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 | |
# Download your chat history | |
# http://stackoverflow.com/questions/8146970/accessing-chat-folder-in-python-using-imaplib | |
import imaplib | |
conn = imaplib.IMAP4_SSL("imap.gmail.com", 993) | |
conn.login("[email protected]", "password") | |
lb_list = conn.list() |
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 MySQLdb | |
db = MySQLdb.connect(host="localhost", user="root", passwd="password", db="example") | |
c = MySQLdb.cursors.DictCursor(db) | |
c.execute("SELECT * FROM students") | |
result = c.fetchall() | |
for row in result: | |
do_something(row['first_name'], row['last_name'], row['grade'], row['year']) | |
c.close() | |
# effectively eliminating that ugly index-referencing of the row results-- |
NewerOlder