Skip to content

Instantly share code, notes, and snippets.

import urllib2
def get_player_profiles(player_list):
# Returns a dict of player profile URLs to be used in the next step
# Dict will hold player profile pages indexed by player name
player_profile_urls=dict.fromkeys(player_list)
for n in player_list:
names=n.split(' ')
# Search for the player names at NFL.com to get their individual player profiles, which contain the
# data we ultimately want.
from twisted.enterprise import adbapi
from twisted.python import log
import MySQLdb
class ReconnectingConnectionPool(adbapi.ConnectionPool):
"""Reconnecting adbapi connection pool for MySQL.
This class improves on the solution posted at
http://www.gelens.org/2008/09/12/reinitializing-twisted-connectionpool/
by checking exceptions by error code and only disconnecting the current
@danmackinlay
danmackinlay / supervisord.sh
Created August 27, 2009 07:07
an init.d script for supervisord
#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
@eriwen
eriwen / check_feedburner.py
Created November 4, 2009 21:30
check_feedburner.py
#!/usr/bin/env python
# Usage: ./check_feedburner.py MyFeedName
import re, sys, urllib, fileinput
from xml.dom import minidom
AWARENESS_API_URL = 'https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=%s'
# If you want to replace the feedburner count in a given file, define it here
FEED_COUNT_FILE = '/path/to/your/file.php'
import os
import httplib
import tornado.web
class ErrorHandler(tornado.web.RequestHandler):
"""Generates an error response with status_code for all requests."""
def __init__(self, application, request, status_code):
tornado.web.RequestHandler.__init__(self, application, request)
self.set_status(status_code)
@macek
macek / .htaccess
Created September 29, 2010 21:59
Redirect without www on Nginx and Engine Yard
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
@perpetual-hydrofoil
perpetual-hydrofoil / unfollow.py
Last active January 19, 2023 01:35
Twitter Unfollow Example (python)
#! /usr/bin/env python
# how to unfollow everyone who isn't following you
# By Jamieson Becker (Public Domain/no copyright, do what you will)
# Easy instructions, even if you don't know Python
#
# 1. Install pip (apt-get install python-pip) and then
# pip install tweepy, which is the python twitter client
#
@cyberswat
cyberswat / git-init.sh
Created February 28, 2012 16:35
Initialize git repo and make first commit
# switch to the jenkins user
[root@li220-252:~] su jenkins
jenkins@li220-252:/root$
# Move into the jenkins directory
jenkins@li220-252:~$ cd /var/lib/jenkins/
# Intialize a git repository
jenkins@li220-252:~$ git init
Initialized empty Git repository in /var/lib/jenkins/.git/
@HowardMei
HowardMei / django_interface.py
Created May 7, 2012 03:47 — forked from niwinz/django_interface.py
Django websockets with tornado, gevent and zeromq
# -*- coding: utf-8 -*-
from gevent import monkey; monkey.patch_all()
import gevent
from gevent_zeromq import zmq
class WebSocketHandler(object):
def __init__(self, _id, in_queue, socket):
@cjgiridhar
cjgiridhar / sqliteform.html
Created August 25, 2012 16:39
Tornado - SQLite DB
<html>
<title>
SQLite Example
</title>
<body>
<FORM ACTION="/create" METHOD=POST>
Name: <input type="text" name="name">
Marks: <input type="text" name="marks">