Skip to content

Instantly share code, notes, and snippets.

View gregplaysguitar's full-sized avatar

Greg Brown gregplaysguitar

View GitHub Profile

Typekit Font Events

Web fonts may be the best thing to happen to web design in years, but that doesn't mean there aren't some tricky issues to overcome. One of the most annoying things is dealing with what's become known as the FOUT or 'Flash of Unstyled Text'. It's what happens in some browsers while waiting for fonts to download.

Typekit is introducing Font Events to put you back in control when using web

div.customselect {
position: relative;
display: block;
width: 240px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
z-index: 100;
background: #F2FFDC;
color: #333;
$(document).unload(function(){
google.maps.Unload();
});
$(document).ready(function(){
$("input.location_picker").each(function (i) {
var me = $(this),
mapDiv = $('<div>').insertBefore(me).addClass('location_picker_map');
me.css('display','none');
@gregplaysguitar
gregplaysguitar / readme.markdown
Created November 10, 2010 21:50
The following is a simple django custom management command to handle model field additions and deletions on a development machine. It automates a common pattern in django development – that of renaming an existing table, recreating via syncdb, and inserti

Simple django management command to automate the process of renaming an existing table, recreating via syncdb, and inserting the old data into the new table. Currently does not handle field renames - will eat your data if you try.

To install, save this file into an installed django app's management/commands/ directory, eg

myapp/management/commands/simplemigration.py

Run the command from the command line as follows

python manage.py simplemigration APPNAME.MODELNAME

@gregplaysguitar
gregplaysguitar / .gitignore
Created May 8, 2011 22:00
Some simple Ubuntu server monitoring tools
*.pyc
conf.py
#!/usr/bin/python
from sorl.thumbnail.conf import settings
from sorl.thumbnail.base import ThumbnailBackend
FORMAT_DICT = {
'png': 'PNG',
'jpeg': 'JPEG',
'jpg': 'JPEG',
@gregplaysguitar
gregplaysguitar / upgrade_user_admin.py
Last active December 4, 2021 13:37
Enhance the django user admin with enforced unique emails, better filters and list items, and user profiles editable inline.
from django.contrib import admin
from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin
from django.forms.models import inlineformset_factory
from django import forms
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
def upgrade_user_admin(UserProfile=None, unique_email=False,
list_display=None):
/*
jquery.aggregate.js by Greg Brown 2011. See
http://gregbrown.co.nz/code/jquery-aggregate/ for details.
License information: http://gregbrown.co.nz/code/license/
*/
/*
@gregplaysguitar
gregplaysguitar / slash_middleware.py
Last active August 21, 2023 12:47
Append OR remove slash in django - like APPEND_SLASH but smarter.
from django import http
from django.utils.http import urlquote
from django import urls
from django.conf import settings
from django.utils.deprecation import MiddlewareMixin
class AppendOrRemoveSlashMiddleware(MiddlewareMixin):
"""Like django's built in APPEND_SLASH functionality, but also works in
reverse. Eg. will remove the slash if a slash-appended url won't resolve,