Skip to content

Instantly share code, notes, and snippets.

View gregplaysguitar's full-sized avatar

Greg Brown gregplaysguitar

View GitHub Profile
@gregplaysguitar
gregplaysguitar / machine.js
Created September 15, 2021 10:05
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@gregplaysguitar
gregplaysguitar / machine.js
Last active August 9, 2021 22:15
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@gregplaysguitar
gregplaysguitar / .gitignore
Last active July 28, 2021 05:06
DynamoDB data streaming with localstack
*.zip
@gregplaysguitar
gregplaysguitar / machine.js
Last active December 18, 2019 02:00
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@gregplaysguitar
gregplaysguitar / fabfile.py
Last active June 23, 2017 01:50
MySQL to PostgreSQL migrate script for Django. Turns a mysql export into a matching postgres database.
"""
Usage
=====
1. Install Fabric - http://www.fabfile.org/
2. Obtain db_converter.py from
https://github.com/lanyrd/mysql-postgresql-converter - put it in the same
directory as this fabfile.
@gregplaysguitar
gregplaysguitar / app.py
Last active March 24, 2017 01:45 — forked from maccman/app.py
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
gregplaysguitar / admin_raw_id.py
Last active October 19, 2022 05:52
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.
Example:
from django.contrib import admin
from admin_raw_id import ImprovedRawIdFieldsAdmin
from .models import MyModel
@gregplaysguitar
gregplaysguitar / postgres_ft.py
Last active January 29, 2018 07:54
Postgres full-text search utils for django
# -*- coding: utf-8 -*-
"""
To enable (and test) the unaccent function, as a superuser:
\connect DATABASE
CREATE EXTENSION unaccent;
SELECT unaccent('èéêë');
Example
@gregplaysguitar
gregplaysguitar / simple_search.py
Last active April 19, 2017 05:05
Django simple search
# Deprecated - see https://github.com/gregplaysguitar/django-simple-search/
@gregplaysguitar
gregplaysguitar / LICENSE.txt
Last active June 23, 2023 21:46
Auto-generate srcset and sizes attributes for an <img> with Django & sorl-thumbnail
Copyright (c) 2015 Greg Brown
[gregbrown.co.nz](http://gregbrown.co.nz)
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