Skip to content

Instantly share code, notes, and snippets.

Avatar

Joel Verhagen joelverhagen

View GitHub Profile
@joelverhagen
joelverhagen / README.md
Created Feb 12, 2012
Jekyll YouTube Embed Plugin
View README.md

This is a plugin meant for Jekyll.

Example use:

Easily embed a YouTube video. Just drop this file in your _plugins directory.

{% youtube oHg5SJYRHA0 %}
@joelverhagen
joelverhagen / README.md
Created Feb 17, 2012
Jekyll JSON Filter
View README.md

This is a plugin meant for Jekyll.

This filter is described at the Shopify Liquid wiki, but somehow didn't make it into the general repository.

Just plop this guy in your _plugins directory and use it like this:

var title = {{ page.title | json }};
@joelverhagen
joelverhagen / uc_codes.json
Created Mar 30, 2012
List of Various University of Cincinnati Codes
View uc_codes.json
{
"BoK Codes": {
"Diversity & Culture": "DC",
"English Composition": "EC",
"Fine Arts": "FA",
"Historical Perspectives": "HP",
"Humanities": "HU",
"Literature": "LT",
"Natural Sciences": "NS",
"Quantitative Reasoning": "QR",
@joelverhagen
joelverhagen / count-occurrences.js
Created Aug 10, 2012
Requires DelimEmitter from my Loggie project.
View count-occurrences.js
"use strict";
var DelimEmitter = require("./delimemitter").DelimEmitter;
exports.countInString = function(haystack, needle) {
var count = 0;
var position = 0;
while(true) {
position = haystack.indexOf(needle, position);
if(position !== -1) {
@joelverhagen
joelverhagen / generate_cert.sh
Created Aug 10, 2012
A nice helper script for generating a self-signed certificate. Great for getting HTTPS running on a home server.
View generate_cert.sh
#!/bin/bash
# ensure the script is running as root
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root." 1>&2
exit 1
fi
NAME=${1:-self-signed}
@joelverhagen
joelverhagen / flask_login_basic_auth.py
Created Sep 13, 2012
HTTP Basic Authorization with Flask and Flask-Login
View flask_login_basic_auth.py
# Flask, http://flask.pocoo.org/
# Flask-Login, https://github.com/maxcountryman/flask-login
@app.before_request
def basic_authorize():
auth = request.authorization
if not current_user.is_active() and auth and auth.type == 'basic':
# change to your specific call to get the user based off username and password
# you're hopefully bcrypting your password, so fetch by username then check password :)
user = User.get_login_user(unicode(auth.username), unicode(auth.password))
@joelverhagen
joelverhagen / oauth_quirks.md
Created Sep 16, 2012
Quirks with various common OAuth providers
View oauth_quirks.md

OAuth Quirks:

People just can't agree on things. Google and Facebook are doing the best, with OAuth 2.0 (and following the standards pretty well). Here is a list of various common OAuth providers that I've worked with... and found some little problems with.

GitHub

  • user_denied instead of access_denied

This is an email I got concerning this issue.

@joelverhagen
joelverhagen / clean_py.sh
Created Oct 8, 2012
Recursively removes all .pyc files and __pycache__ directories in the current directory
View clean_py.sh
#!/bin/sh
# recursively removes all .pyc files and __pycache__ directories in the current
# directory
find . | \
grep -E "(__pycache__|\.pyc$)" | \
xargs rm -rf
# or, for copy-pasting:
@joelverhagen
joelverhagen / craigslist_locations.sql
Created Oct 16, 2012
A SQL schema of all regions, states, and locations (cities) that Craigslist supports, as of October 16, 2012. This data was originally made for PostgreSQL. This data is fetched from http://www.craigslist.org/about/sites.
View craigslist_locations.sql
CREATE TABLE regions (
region_id integer NOT NULL,
name character varying(255) NOT NULL
);
CREATE TABLE states (
state_id integer NOT NULL,
region_id integer NOT NULL,
name character varying(255) NOT NULL
);
@joelverhagen
joelverhagen / hangman.py
Created Oct 31, 2012
Solve Dan's hangman puzzle. This is cludgy code. Please disregard.
View hangman.py
# digraphs, sorted by how common they are in the english language
digraphs = ['th', 'he', 'in', 'er', 'an', 're', 'on', 'at', 'en', 'nd', 'st', 'or', 'te', 'es', 'is', 'ha', 'ou', 'it', 'to', 'ed', 'ti', 'ng', 'ar', 'se', 'al', 'nt', 'as', 'le', 've', 'of', 'me', 'hi', 'ea', 'ne', 'de', 'co', 'ro', 'll', 'ri', 'li', 'ra', 'io', 'be', 'el', 'ch', 'ic', 'ce', 'ta', 'ma', 'ur', 'om', 'ho', 'et', 'no', 'ut', 'si', 'ca', 'la', 'il', 'fo', 'us', 'pe', 'ot', 'ec', 'lo', 'di', 'ns', 'ge', 'ly', 'ac', 'wi', 'wh', 'tr', 'ee', 'so', 'un', 'rs', 'wa', 'ow', 'id', 'ad', 'ai', 'ss', 'pr', 'ct', 'we', 'mo', 'ol', 'em', 'nc', 'rt', 'sh', 'po', 'ie', 'ul', 'im', 'ts', 'am', 'ir', 'yo', 'fi', 'os', 'pa', 'ni', 'ld', 'sa', 'ay', 'ke', 'mi', 'na', 'oo', 'su', 'do', 'ig', 'ev', 'gh', 'bl', 'if', 'tu', 'av', 'pl', 'wo', 'ry', 'bu', 'iv', 'ab', 'ia', 'vi', 'ex', 'op', 'bo', 'fe', 'ag', 'ci', 'da', 'mp', 'tt', 'sp', 'ck', 'ty', 'fr', 'ei', 'ap', 'rd', 'gr', 'od', 'ef', 'go', 'ba', 'ey', 'cl', 'cr', 'ov', 'ht', 'rn', 'fa', 'ls', 'gi'