Skip to content

Instantly share code, notes, and snippets.


Greg Brown gregplaysguitar

View GitHub Profile
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
gregplaysguitar /
Last active Jun 23, 2017
MySQL to PostgreSQL migrate script for Django. Turns a mysql export into a matching postgres database.
1. Install Fabric -
2. Obtain from - put it in the same
directory as this fabfile.
gregplaysguitar /
Last active Mar 24, 2017 — forked from maccman/
Stripe Flask Example
import os
from flask import Flask, render_template, request
import stripe
stripe_keys = {
'secret_key': os.environ['SECRET_KEY'],
'publishable_key': os.environ['PUBLISHABLE_KEY']
stripe.api_key = stripe_keys['secret_key']
gregplaysguitar /
Last active Nov 28, 2018
Show object description and a link next to django's raw_id_fields, for ForeignKey and ManyToMany fields
Show customisable str representation of the linked objects next to each raw id
field in a django admin change form. Works for ForeignKey, OneToOneField, and
ManyToManyField fields.
from django.contrib import admin
from admin_raw_id import ImprovedRawIdFieldsAdmin
from .models import MyModel
gregplaysguitar /
Last active Jan 29, 2018
Postgres full-text search utils for django
# -*- coding: utf-8 -*-
To enable (and test) the unaccent function, as a superuser:
\connect DATABASE
SELECT unaccent('èéêë');
gregplaysguitar /
Last active Apr 19, 2017
Django simple search
# Deprecated - see
gregplaysguitar / LICENSE.txt
Last active Jan 26, 2021
Auto-generate srcset and sizes attributes for an <img> with Django & sorl-thumbnail
View LICENSE.txt
Copyright (c) 2015 Greg Brown
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
gregplaysguitar /
Last active Aug 29, 2015
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
mkdir -p $VIRTUAL_ENV/src && cd $VIRTUAL_ENV/src
curl -O$pkgver/xapian-core-$pkgver.tar.xz && tar xf xapian-core-$pkgver.tar.xz
curl -O$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
gregplaysguitar / placeholder.scss
Created Aug 29, 2012 — forked from antsa/placeholder.scss
Placeholder mixin for Sass
View placeholder.scss
// Placeholder @mixin for Sass
// A mixin to style placeholders in HTML5 form elements.
// Includes also a .placeholder class to be used with a polyfill e.g.
// Requires Sass 3.2.
// Example usage (.scss):
// input {