Skip to content

Instantly share code, notes, and snippets.

Phil Gyford philgyford

Block or report user

Report or block philgyford

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
philgyford / functions.php
Last active Sep 4, 2019
Sparkling WordPress theme, child
View functions.php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
$parent_style = 'sparkling-style'; // This is 'sparkling-style' for the sparkling theme.
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
philgyford / article.html
Created Mar 15, 2019
Example of how to add a form to every instance of a type of Wagtail CMS Page, without having to manually build the page for each new page in the Admin
View article.html
{% extends "base.html" %}
{% block content %}
<p>(Article content here.)</p>
<p>Send us your thoughts:</p>
<form action="{% pageurl page %}" method="POST">
{% csrf_token %}
philgyford /
Last active Mar 10, 2018
Migrating a Django postgresql database to sqlite3

Migrating a Django postgresql database to sqlite3

I wanted to export data from a few Django apps, held in a postgres database, and import that data into an sqlite3 database to run locally.

This worked for me, but I'm sure there are other wrinkles, depending on your use of postgres-specific features, etc.

  1. Export the data from postgres
philgyford /
Created Jan 5, 2018
Find and replace text in Django objects' fields

Django Find and Replace

This was used to replace all the instances of old Media URLs with new ones, but could be used for any kind of text search/replace across Django objects.

  1. Change the model import to whatever your app and model is.
  2. Set the to_find and to_replace strings to whatever you need.
  3. Change Post to your model name, and the fields to whatever field(s) you want to search and replace across.
philgyford / .gitignore
Last active Nov 23, 2017
A script for importing images, and data about them in a CSV file, into WordPress
View .gitignore
philgyford / .block
Last active Dec 12, 2017
Book series years chart
View .block
license: cc-by-sa-4.0
height: 1200
scrolling: no
border: yes
philgyford /
Created Jul 22, 2017
File for displaying %CPU and RAM usage on a system. Not sure where I got this from originally.
#!/usr/bin/env python2.7
import subprocess
import sys
import re
import os,pwd
from pprint import pprint
class TerminalController:
philgyford / .block
Last active Dec 12, 2017
D3.js v4 Ladder Graph
View .block
license: cc-by-sa-4.0
height: 570
scrolling: no
border: yes
View post.hbs
{{#get "posts" limit="1" order="published_at desc" filter=tag:getting-started+published_at:<{{published_at}}"}}
{{#foreach posts}}
<a href="{{url}}">{{title}}</a>
You can’t perform that action at this time.