Skip to content

Instantly share code, notes, and snippets.

View chosak's full-sized avatar

Andy Chosak chosak

View GitHub Profile
@chosak
chosak / index.html
Created July 12, 2016 03:26
Indy PZ tweet timeline
<!DOCTYPE html>
<meta charset="utf-8">
<title>projects/indy/data/tweets/indy-0.json</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min.js"></script>
<style>
.axis text {
font: 10px sans-serif;
}
@chosak
chosak / export.py
Created January 18, 2017 11:54
Wordpress export script
#!/usr/bin/env python
from __future__ import absolute_import, print_function, unicode_literals
import argparse
import os
import re
import requests
from getpass import getpass
@chosak
chosak / home_page.html
Last active February 12, 2019 18:24
Prototype solution to prevent caching of Wagtail previews - https://github.com/wagtail/wagtail/issues/5074
{# home/templates/home/home_page.html #}
{# Uses safecache instead of cache to prevent caching of preview content #}
{% load safecache %}
{# Usage of cache tag remains the same #}
{% cache 3600 homepage_charfield %}
{{ self.a_charfield }}
{% endcache %}
@chosak
chosak / notes.md
Created May 3, 2019 20:07
PyCon US 2019 Wagtail open session

We had a nice open session this afternoon at PyCon US, organized by Sean Harrison from Caktus Group. There were about 15 people in the room. The session agenda was generally to discuss improving Wagtail for developers.

StreamField data migrations

Adding fields or blocks won't cause problems as long as you don't rename or removing anything.

Sean presented a nice multi-step approach that he recommends when migrating StreamFields. This way you can run each step independently and verify that it worked correctly.

  1. First add the new field or block (example).
  2. Make a migration that copies the data from old fields to new fields, but don't remove anything yet (example).