Skip to content

Instantly share code, notes, and snippets.

View andrewserong's full-sized avatar

Andrew Serong andrewserong

View GitHub Profile
@andrewserong
andrewserong / two-columns-blocks.html
Created October 6, 2021 01:09
Gutenberg markup: Two columns blocks with background colors for testing blockGap support
<!-- wp:paragraph -->
<p>A paragraph.</p>
<!-- /wp:paragraph -->
<!-- wp:columns {"style":{"spacing":{"margin":{"top":"10px","bottom":"10px"}}},"backgroundColor":"blue"} -->
<div class="wp-block-columns has-blue-background-color has-background" style="margin-top:10px;margin-bottom:10px"><!-- wp:column {"style":{"spacing":{"padding":{"top":"10px","right":"10px","bottom":"10px","left":"10px"}}},"backgroundColor":"purple"} -->
<div class="wp-block-column has-purple-background-color has-background" style="padding-top:10px;padding-right:10px;padding-bottom:10px;padding-left:10px"><!-- wp:paragraph -->
<p>Col A</p>
<!-- /wp:paragraph --></div>
<!-- /wp:column -->
@andrewserong
andrewserong / startpuppeteer.js
Created September 13, 2018 23:37
A quick script to start puppeteer
// After installing 'puppeteer', run Node from a terminal,
// then type '.editor' to start a multi-line editor and type the following:
const puppeteer = require('puppeteer');
let page;
let browser;
(async function() {
browser = await puppeteer.launch({ headless: false });
page = await browser.newPage();
@andrewserong
andrewserong / content_middleware.py
Created June 15, 2018 07:16
An example of a simple Contentful middleware written for the Wonderland exhibition at ACMI
import contentful
import markdown
from flask import current_app
def get_contentful_posts(character_filter=None):
"""
Get contentful content for posts and return it as a dictionary
:character_filter: a string to filter posts by associated character (can only select one at a time)
@andrewserong
andrewserong / remove_dangling_docker_images.sh
Last active March 23, 2018 04:58
Remove dangling Docker images
# via docker rmi
docker rmi $(docker images -f “dangling=true” -q)
# or more elegantly
docker system prune
# remove all unused images, not just dangling ones
docker system prune -a
@andrewserong
andrewserong / VideoPlayer.jsx
Created October 19, 2017 05:47
An example Video JS component in React, based on the Video JS docs
import React from 'react';
import videojs from 'video.js';
import 'video.js/dist/video-js.css';
// video.js player from the docs: https://github.com/videojs/video.js/blob/master/docs/guides/react.md
class VideoPlayer extends React.Component {
componentDidMount() {
// instantiate Video.js
this.player = videojs(this.videoNode, this.props, function onPlayerReady() {
@andrewserong
andrewserong / multiscreenwhatson.js
Created June 28, 2017 06:29
Front end code for ACMI's multi-screen Cinemas Now Showing
/**
* A simple web app to display session times from the ACMI website JSON feed.
* This source file gets bundled together with its dependencies into bundle.js.
*
* Dependencies:
*
* query-string (https://www.npmjs.com/package/query-string)
* jquery (https://jquery.com/)
* moment (https://momentjs.com/)
*
@andrewserong
andrewserong / zip_current_folder.sh
Last active March 10, 2017 05:49
Zip up a folder from the command line on Mac, excluding __MACOSX folder
zip -r -X Archive.zip *
@andrewserong
andrewserong / ACMI_Umbraco_SlackPublish.cs
Created April 19, 2016 01:35
ACMI's version of "Post to Slack when Umbraco content is published"
private void ContentServicePublished(IPublishingStrategy sender, PublishEventArgs<IContent> e)
{
// Slack integration based on: http://blog.darren-ferguson.com/2015/02/03/post-to-slack-when-umbraco-content-is-published/
var slackUrl = SiteSettings.Settings.SlackHookPublishUrl;
var slackLinksPrefix = SiteSettings.Settings.SlackHookLinksPrefix;
if (slackUrl != null && slackLinksPrefix != null)
{
foreach (var entity in e.PublishedEntities)