Skip to content

Instantly share code, notes, and snippets.

"""Python boilerplate for using Twitter API w/OAuth, based on sixohsix-twitter.
As of 2010-08-31, Twitter has shut down Basic Auth completely.
You must use OAuth instead. This boilerplate does just that.
http://dev.twitter.com/pages/basic_auth_shutdown
This Python script uses the Python twitter package by Mike Verdone et al.
http://pypi.python.org/pypi/twitter
http://mike.verdone.ca/twitter/
@joshfinnie
joshfinnie / gist:1102695
Created July 24, 2011 14:51
Flask Signup/Login Template
from datetime import datetime
from flask import *
from flaskext.wtf import *
from flaskext.sqlalchemy import *
from werkzeug import generate_password_hash, check_password_hash
app = Flask()
app.config.from_pyfile('app_settings.py')
db = SQLAlchemy(app)
@joshfinnie
joshfinnie / gist:1885537
Created February 22, 2012 15:26
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+X delete line
Ctrl+↩ insert line after
Ctrl+⇧+↩ insert line before
Ctrl+⇧+↑ move line (or selection) up
@joshfinnie
joshfinnie / gist:2040709
Created March 15, 2012 00:32 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@joshfinnie
joshfinnie / .htaccess
Created September 21, 2012 14:57
WWW. Redirect
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
@joshfinnie
joshfinnie / gist:4046138
Created November 9, 2012 14:54
Installing Mezzanine on Heroku

Lately, I have been looking into Python CMSs. There are many out there, but for some reason or another Mezzanine stuck out as one I should try. Installing it is easy enough, but getting it up on running on my new favorite host, Heroku, was a bit of a challege.

Below you will find the steps that I took to get Mezzanine up and running on Heroku. Please let me know in the comments below if anything didn't work for you.

Setting up the Database

Heroku is shortly depricating Django's standard DATABASES dictionary in favor for a package which takes OS Environment Variables and builds the required dictionary for you. This is a good thing because it makes setting up a database on Heroku very easy. The package is called dj_database_url and it makes short work of getting a PostgreSQL database up and running with Mezzanine. Below is the code that you want to put in Mezzanine's DATABASES section:

import dj_database_url
DATABASES = {'default': dj_database_url.config(default='postgres://localhost')}
@joshfinnie
joshfinnie / modernizr_load.js
Created December 4, 2012 19:24
Modernizr Webgl Test
function testWebGL() {
try {
return !!window.WebGLRenderingContext && !!document.createElement('canvas').getContext('experimental-webgl');
} catch(e) {
return false;
}
}
Modernizr.load([
{
@joshfinnie
joshfinnie / setup.py
Created July 25, 2013 22:29
Start of a setup.py
#!/usr/bin/env python
import os
import sys
import app
try:
from setuptools import setup
except ImportError:
@joshfinnie
joshfinnie / install.txt
Created October 2, 2013 14:42
How I install Python on OS X
$ cd /tmp
$ curl -O http://python.org/ftp/python/X.Y.Z/Python-X.Y.Z.tgz
$ tar zxf Python-X.Y.Z.tgz
$ cd Python-X.Y.Z
$ ./configure --prefix=/usr/local/python/X.Y.Z
$ make
$ make install
$ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | /usr/local/python/X.Y.Z/bin/python
$ /usr/local/python/X.Y.Z/bin/easy_install pip
$ /usr/local/python/X.Y.Z/bin/pip install virtualenv
@joshfinnie
joshfinnie / writeup.md
Last active December 30, 2015 09:19
Node.DC Office Hours writeup

After the success of our last meetup, Hack Night, we are continuing the trend with a different kind of meetup, Office Hours.

This is a casual "geek gathering", where you can hack on a node.js project, get help/advice, or ask questions about anything node.js related. Anyone working with node.js at any level (or anyone wanting to work with it) is welcome.

Our meetups are always filled with a mix of people and skills present, and I expect this to be the same. So feel free to bring your questions pertaining to system admin/dev ops, best practices, installation issues, etc.

We are also looking for food/drink sponsors in exchange for five to ten minutes of air time to announce your product/hiring/etc. Contact Josh Finnie for details.

Attendance is free, and food and drink will be provided if we have found some sponsors. For this reason, it is mandatory that you keep your RSVP up to date. The deadline for changing your mind will be one day before the event.