Skip to content

Instantly share code, notes, and snippets.

View gregplaysguitar's full-sized avatar

Greg Brown gregplaysguitar

View GitHub Profile
pkgver=1.2.19
mkdir -p $VIRTUAL_ENV/src && cd $VIRTUAL_ENV/src
curl -O http://oligarchy.co.uk/xapian/$pkgver/xapian-core-$pkgver.tar.xz && tar xf xapian-core-$pkgver.tar.xz
curl -O http://oligarchy.co.uk/xapian/$pkgver/xapian-bindings-$pkgver.tar.xz && tar xf xapian-bindings-$pkgver.tar.xz
cd $VIRTUAL_ENV/src/xapian-core-$pkgver
./configure --prefix=$VIRTUAL_ENV && make && make install
export LD_LIBRARY_PATH=$VIRTUAL_ENV/lib
@gregplaysguitar
gregplaysguitar / jinja_cms.py
Last active August 29, 2015 14:14
Djangocms2000 template tag file for Coffin & Jinja2 compatibility
# -*- coding: utf-8 -*-
from django.conf import settings
from coffin import template
from jinja2 import contextfunction, Markup
from cms.application import get_rendered_block, get_rendered_image
from cms.templatetags.cms_editor import cms_editor
from cms.utils import is_editing

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

#!/usr/bin/python
from sorl.thumbnail.conf import settings
from sorl.thumbnail.base import ThumbnailBackend
FORMAT_DICT = {
'png': 'PNG',
'jpeg': 'JPEG',
'jpg': 'JPEG',
/*
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 / jquery.fancydropdown.js
Created January 27, 2012 01:56
Create dropdown menus with jquery
/*
Example usage:
$('ul.dropdown').fancydropdown();
(elements must have a 'title' attribute in order to populate the prompt)
*/
$.fn.fancydropdown = (function(options){
@gregplaysguitar
gregplaysguitar / fields.py
Created June 27, 2012 00:48
Memory-safe ImageField for Django - checks filesize and dimensions before loading the uploaded file into memory.
try:
from PIL import Image
except ImportError:
import Image
from django import forms
from django.template.defaultfilters import filesizeformat
from django.core.exceptions import ValidationError