Skip to content

Instantly share code, notes, and snippets.

View benatkin's full-sized avatar

Benjamin Atkin benatkin

View GitHub Profile
def iequals(str1, str2):
"""Returns true if two strings are equal in a case-insensitive comparison."""
import re
return re.match(re.escape(str1) + r'\Z', str2, re.I) is not None
// my silly change to the default code on http://sketch.processing.org/
void setup()
{
size(200,200);
background(0, 82, 51);
fill(255);
noLoop();
PFont fontA = loadFont("courier");
textFont(fontA, 14);

Stopping habitual time-wasting on twitter

Quit using twitter for three weeks. Do it in a way that will require a password reset.

  1. Make sure you're comfortable with your twitter page looking the same for a long period of time.
  2. Post a simple tweet saying you'll be gone. Mine was #hiatus.
  3. Generate a random password and copy it to the clipboard. A one-liner that does it in OS X is provided at the bottom.
  4. Delete all GUI twitter clients from all devices. For me, this meant my MBP, my iPad, and my iPhone.
  5. Log out of twitter on all browsers, except one.
  6. Go to the password change page in settings. Paste the password in twice and save it.
import oauth2.clients.imap as imaplib
import email
class Mailbox(object):
def __init__(self, conn):
self.conn = conn
self.total = self.conn.select('INBOX')[1][0]
self.current = 1
! I hope to expand this later, but for now, I got it working by following
! the instructions at the URL below, installing both the chrome extension
! and the gem, saving the refresh-chrome script, and adding this to my ~/.vimrc.
!
! http://github.com/kzys/chromerepl
map <leader>r :silent !/Users/ben/bin/refresh-chrome<cr>
if ($.inArray('something_strange', neighbourhood) != -1) {
ghostbusters.call();
}
from django.contrib import admin
from django.contrib.admin.views.main import ChangeList
from tunes.models import Song
class SpecialOrderingChangeList(ChangeList):
def apply_special_ordering(self, queryset):
order_type, order_by = [self.params.get(param, None) for param in ('ot', 'o')]
special_ordering = self.model_admin.special_ordering
if special_ordering and order_type and order_by:
try:
# A partial port of http://geewax.org/introducing-appmake to Rake
PYTHON = "python"
APPENGINE = "/usr/local/google_appengine"
APP_ID = "" # replace with your app id
EMAIL = "" # replace with your email address
SERVE_PORT = 9091
SERVE_ADDRESS = "0.0.0.0"
DATASTORE_PATH = "./datastore"

WatchWednesday for 20100929

Please fork and post your own! Others from this week:

Faraday is a rack-inspired API client library. It supports middleware and multiple backends. Like rack, it's the kind of thing that makes you wonder why no highly-skilled hacker built it sooner.

Testing out this gist stuff =p


I love gists.