Skip to content

Instantly share code, notes, and snippets.

View limelights's full-sized avatar

Henrik Andersson limelights

View GitHub Profile
@limelights
limelights / gist:7ca5c656cc3579490e8481871650dc19
Last active March 9, 2019 16:03
A super simple ticketing system
function ticket() {
mkdir -p tickets/resolved
if [ $1 = 'resolve' ]; then
mv ./tickets/$2.md ./tickets/resolved/resolved-$2.md
git add .; echo "[$2] $3" | git commit -F -
elif [ $1 = 'list' ]; then
ls ./tickets/
elif [ ! -z "$1" ]; then
echo $(date +"%Y%m%d-%H%M%S") "${@:2}" >> "./tickets/$1-$(ls -lR tickets/**/*.md | grep $1 | wc -l | awk '{$1=$1};1').md"
fi
@limelights
limelights / gist:0bdc634f388af78aad3064438ad47696
Last active February 28, 2023 06:23
How I setup Workbox with Django
Setting up [WorkboxJS](workboxjs.org) with [Django](djangoproject.com).
Prerequisites:
My particular project is using Docker to power the Django app.
In front of the Django app there is Nginx which serves and caches assets.
Your setup might be a bit different but I have yet to find any "best practices" regarding ServiceWorkers with Workbox, webpack, Nginx and Django.
I wanted to use Workbox because I wanted to use precaching and background analytics for my site. This is quite lengthy.
@limelights
limelights / gist:c7ef93efd4abba5a7ea1
Last active October 4, 2018 06:09
Basic SSR for express app
// Server
app.use((req, res, next) => {
match({ routes, location: req.url }, (error, redirectLocation, renderProps) => {
let store = setupStore();
let promises = collectPromises(req.url, renderProps.routes, store);
collectToken(req.cookies, store);
Keys.all(promises).then(() => {
const html = renderToString(<Provider store={store}>