Skip to content

Instantly share code, notes, and snippets.

View danriti's full-sized avatar

Dan Riti danriti

View GitHub Profile
@danriti
danriti / twitter_api.py
Created January 24, 2012 03:16
Twitter API Access
#!/usr/bin/python
import simplejson as json
import oauth2 as oauth
# Create your consumer with the proper key/secret.
consumer = oauth.Consumer(key="YOUR_CONSUMER_KEY",
secret="YOUR_CONSUMER_SECRET")
@danriti
danriti / database.py
Created January 16, 2012 00:33
Python + MySQLdb + Unicode
#!/usr/bin/python
# -*- coding: utf-8 -*-
import MySQLdb as mysql
def QueryDatabase(query, values):
"""Function to query a MySQL database and return the results of the
query."""
# Initialize variables and return values.
@danriti
danriti / gist:41a1a3fd4af534955187
Created February 10, 2015 14:46
nginx simple proxy settings
location / {
proxy_pass http://localhost:3000/;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "you@example.com"
npm set init.author.url "http://yourblog.com"

npm adduser

@danriti
danriti / plot.py
Last active August 29, 2015 14:01
PHP Average Latency By Week
from datetime import datetime
import matplotlib.pyplot as plt
import traceview
API_KEY = 'API KEY HERE'
def main():
tv = traceview.TraceView(API_KEY)
results = tv.server.latency_by_layer('Default', time_window='week')
@danriti
danriti / pi.py
Last active August 29, 2015 13:57 — forked from Py-Gon-Gin/pi.py
#!/usr/bin/env python
import sys
import subprocess
def print_wiki_options(file) :
subprocess.call("clear")
with open(file, 'r') as f :
for line in f:
sys.stdout.write(line)