Skip to content

Instantly share code, notes, and snippets.

@solace
solace / post.js
Created March 18, 2022 06:16
Rendering Contentful embedded assets and entries in GatsbyJS
import { documentToReactComponents } from '@contentful/rich-text-react-renderer';
import { graphql } from 'gatsby';
import React from 'react';
// Custom renderer for embedded content which accepts `body` / `references` from the graphql query.
// Search `references` for the embedded object ID for full access to nested content.
const rendererOptions = (references) => ({
renderNode: {
[BLOCKS.EMBEDDED_ASSET]: (node) => {
const imageID = node.data.target.sys.id;
@solace
solace / bakesrt.sh
Last active July 17, 2022 00:38
Bake-in captions into videos using srts and ffmpeg
#!/bin/bash
# Check out STEAM Powered (https://steampoweredshow.com/) where I have conversations
# with women in STEAM to learn a bit about what they do and who they are.
# https://steampoweredshow.com/learn-more/
# Usage
# =====
#
# Execute script in the directory containing the video and srts files, or modify to take
@solace
solace / plugins--gatsby-remark-cleaner--index.js
Last active October 20, 2021 12:43
gatsby remark transformer plugin that cleans up extraneous wrapper paragraph tags and table whitespace nodes that can raise errors/warnings.
const visit = require(`unist-util-visit`);
const remove = require(`unist-util-remove`);
const HTMLParser = require('node-html-parser');
const matches = (classes, value) => {
const fragment = HTMLParser.parse(value);
if (!fragment.firstChild.classList) {
return false;
}
@solace
solace / slurm.conf
Last active September 15, 2021 09:39
slurm.conf for 16.05.9-1+deb9u
###
# WARNING: This config is for development use only.
#
# It was created using https://slurm.schedmd.com/configurator.html and modified
# enough for use on Docker kaldiasr/kaldi with slurm 16.05.9-1+deb9u.
#
# slurm < 20.02.7 is no longer available due to a security vulnerability.
# See: https://www.schedmd.com/archives.php
# Get the latest version and use the configurator from there.
###
@solace
solace / admin.py
Created January 3, 2021 08:09
django-addanother with django-autocomplete-light and GenericForeignKeys
# Source: https://github.com/yourlabs/django-autocomplete-light/blob/master/test_project/select2_generic_foreign_key/admin.py
import json
from django.contrib import admin
from django.contrib.admin.options import IS_POPUP_VAR, TO_FIELD_VAR
from django.contrib.contenttypes.models import ContentType
from django.template.response import TemplateResponse
from .forms import TForm
@solace
solace / makesrt.py
Last active September 21, 2021 04:34
Google Cloud Speech-to-Text SRT Generator
"""
Check out STEAM Powered (https://steampoweredshow.com/) where I have conversations
with women in STEAM to learn a bit about what they do and who they are.
https://steampoweredshow.com/learn-more/
"""
"""
Requirements
************
@solace
solace / README.md
Last active July 27, 2023 12:40
Django: augmented user_passes_test to accept params for test_func with matching template tag
@solace
solace / migration.py
Created November 6, 2020 14:00
Django: Add Permissions to Groups during Migration
# YMMV
from django.conf import settings
from django.contrib.auth.models import Group, Permission
from django.core.management.sql import emit_post_migrate_signal
from django.db import migrations, models
import django.db.models.deletion
import logging
@solace
solace / README.md
Created October 14, 2020 04:40
Custom SVG Definition for @fortawesome/react-fontawesome

Usage

Wherever you are initialising the FontAwesome library:

import { library } from '@fortawesome/fontawesome-svg-core';
import faTheName from 'custom-icon';

...
@solace
solace / rule.js
Last active May 7, 2022 15:48 — forked from vktr/rule.js
Auth0 Rule: Add Stripe Customer Id to existing token data
// If you have multiple rules in your workflow that need to update token data.
function (user, context, callback) {
user.app_metadata = user.app_metadata || {};
const token_namespace = 'https://your-domain.com/app_metadata';
// assumes your metadata object is shallow
const addCustomerId = stripe_customer_id => ({
...context.idToken[token_namespace],