Skip to content

Instantly share code, notes, and snippets.

View thclark's full-sized avatar

Tom Clark thclark

View GitHub Profile
@thclark
thclark / sketch.yml
Created March 17, 2022 12:57
Sketch of what a set of octue github actions would look like
name: octue
on:
push:
branches:
- main
pull_request:
branches:
- main
@thclark
thclark / UserSnap.jsx
Created January 5, 2022 11:57
UserSnap in react or gatsby
import React from 'react'
import { Helmet } from 'react-helmet'
// Replace with the API keys from your widget installation page
const USERSNAP_GLOBAL_API_KEY = '<YOUR_USERSNAP_GLOBAL_API_KEY>'
/* Render this anywhere in your tree (preferably at the top of your app) to invoke the usersnap widget.
*/
const UserSnap = () => {
return (
@thclark
thclark / stack_mixin.py
Created October 27, 2021 14:32
Stack Printing Mixin
class StackMixin:
""" A mixin to print out methods as they're called on classes.
Mix this in to classes whose logic flow you're trying to analyse, and you'll get a clear print out
of what methods are called and when.
"""
def __getattribute__(self, attr):
method = object.__getattribute__(self, attr)
@thclark
thclark / gtest.rb
Last active March 11, 2020 10:00 — forked from Kronuz/gtest.rb
Homebrew Formula for Google Test
# Homebrew Formula for Google Test
# Usage: brew install --HEAD https://gist.githubusercontent.com/Kronuz/96ac10fbd8472eb1e7566d740c4034f8/raw/gtest.rb
require 'formula'
class Gtest < Formula
desc "Google Test"
homepage "https://github.com/google/googletest"
head "git://github.com/google/googletest.git", :using => :git
@thclark
thclark / heroku_local.sh
Created December 6, 2019 10:28
Running celery, flower and heroku locally for a django app
#!/usr/bin/env bash
export PYTHONUNBUFFERED=1
export DJANGO_READ_DOT_ENV_FILE=1
export DJANGO_SETTINGS_MODULE=backend.settings.local
heroku local -p 8000
@thclark
thclark / # osgeo-gdal - 2019-12-04_16-57-56.txt
Created December 4, 2019 17:02
osgeo-gdal (osgeo/osgeo4mac/osgeo-gdal) on macOS 10.14.6 - Homebrew build logs
Homebrew build logs for osgeo/osgeo4mac/osgeo-gdal on macOS 10.14.6
Build date: 2019-12-04 16:57:56
@thclark
thclark / dataProvider.js
Created October 18, 2019 08:11
A django dataProvider for react-admin v3.x
import { stringify } from 'query-string'
import { fetchUtils } from 'react-admin'
import Cookies from 'universal-cookie'
import { store } from 'index'
const camelCaseKeys = require('camelcase-keys')
const snakeCaseKeys = require('snakecase-keys')
@thclark
thclark / blocks.py
Created May 23, 2019 19:18
Wagtail serializers for streamfield - example of customizing per-block
class HeroBlock(StructBlock):
content = StreamBlock([
('button', StructBlock([
('text', CharBlock(required=False, max_length=80, label='Label')),
('url', URLBlock(required=False, label='URL')),
], label='Call to action', help_text='A "call-to-action" button, like "Sign Up Now!"')),
('video', EmbedBlock(label='Video')),
('quote', StructBlock([
('text', TextBlock()),
@thclark
thclark / FullArea.js
Created February 21, 2019 22:34
React HOC that places children in a div the size of the remaining window space. Updates on window resize. More info at https://stackoverflow.com/a/54112855/3556110
import React, { Component } from 'react'
import PropTypes from 'prop-types'
class FullArea extends Component {
constructor(props) {
super(props)
this.state = {
width: 0,
height: 0,
@thclark
thclark / LoadingPage.js
Last active February 21, 2019 22:29
Loading spinner, centred on a page, in React. Designed for use with creative-tim material kit pro, but could be adapted.
import classNames from 'classnames'
import PropTypes from 'prop-types'
import React, { Component } from 'react'
import withStyles from '@material-ui/core/styles/withStyles'
import CircularProgress from '@material-ui/core/CircularProgress'
import FullArea from 'components/FullArea'
import GridContainer from 'components/Grid/GridContainer'
import GridItem from 'components/Grid/GridItem'