Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
hash tag farm lyfe

George Hickman ghickman

🏠
hash tag farm lyfe
View GitHub Profile
View code.sql
WITH ethnicities AS (
SELECT
Patient_ID,
date,
ethnicity_code,
ROW_NUMBER() OVER (
PARTITION BY Patient_ID ORDER BY date DESC
) AS row_num
FROM (
SELECT
@ghickman
ghickman / add_inline.js
Created Jun 11, 2011
Add an inline Django form to the formset without reloading the page.
View add_inline.js
function add_inline_form(prefix) {
var count = parseInt($('#id_' + prefix + '-TOTAL_FORMS').val(), 10);
var last_form = $('.' + prefix + ':last');
var new_form = last_form.clone(false).html(last_form.html().replace(
new RegExp(prefix + '-\\\\d-', 'g'), prefix + '-' + count + '-'));
new_form.find('input[type="text"], textarea').each(function () {
$(this).val('');
});
new_form.hide().insertAfter(last_form).slideDown(300);
View settings.py
AUTHENTICATION_BACKENDS = (
'social_auth.backends.google.GoogleOAuth2Backend',
'django.contrib.auth.backends.ModelBackend',
)
LOGIN_REDIRECT_URL = '/'
GOOGLE_OAUTH2_CLIENT_ID = os.environ['GOOGLE_OAUTH2_CLIENT_ID']
GOOGLE_OAUTH2_CLIENT_SECRET = os.environ['GOOGLE_OAUTH2_CLIENT_SECRET']
GOOGLE_WHITE_LISTED_DOMAINS = ['incuna.com']
SOCIAL_AUTH_USER_MODEL = 'auth.User'
@ghickman
ghickman / _contact.rb
Created Jul 4, 2010
Jekyll Contact Form with Sinatra
View _contact.rb
require 'rubygems'
require 'sinatra'
require 'pony'
require 'haml'
set :haml, {:format => :html5}
set :public, File.dirname(__FILE__)
set :views, File.dirname(__FILE__)
# Create the page class and give it a title of Contact for the layout
@ghickman
ghickman / generic.py
Created Jul 15, 2012
Generate unique slugs for Django models
View generic.py
from django.template.defaultfilters import slugify
def generate_slug(cls, value):
count = 1
slug = slugify(value)
if not isinstance(cls, type):
cls = cls.__class__
def _get_query(cls, **kwargs):
if cls.objects.filter(**kwargs).count():
@ghickman
ghickman / .troverc
Created Jul 4, 2012
Example .troverc file.
View .troverc
[trove]
username=me
password=secret
url=http://trove.example.com
@ghickman
ghickman / gist:1326435
Created Oct 30, 2011
fix broken midwich images
View gist:1326435
#!/usr/bin/env python
"""
midwich_image_fix.py
Created by Lee Perry on 2011-10-30.
Copyright (c) 2011 iCode Solutions Ltd. All rights reserved.
"""
import sys
import csv
View gist:1255782
<advancedsettings>
<moviestacking action="append">
<regexp>(.+)\(([0-9])\)()(\.[^.]+)$</regexp>
</moviestacking>
</advancedsettings>
View gist:1125096
" Remember last location in file
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif
endif
View gitalist.conf
name Gitalist
<Model::CollectionOfRepos>
#git /path/to/git
# Configure this to where your repositories are.
repo_dir /home/git/repositories/
</Model::CollectionOfRepos>
sitename "Gitalist"