Skip to content

Instantly share code, notes, and snippets.

@subtleGradient
subtleGradient / gist:a158bd0a51edd2f449c5983e66317f5a
Last active December 14, 2018 16:47
GatsbyJS createPages TypeScript GraphQL syntax coloring fix
// Copyright (C) 2018 by Things That Do Stuff, LLC - All rights reversed
// http://www.unlicense.org/ (public domain)
const gql = (templateStringParts: TemplateStringsArray, ...vars: any[]): string =>
templateStringParts.map((part, index) => (index in vars ? part + JSON.stringify(vars[index]) : part)).join('');
export const createPages: GatsbyCreatePages = async ({ graphql, boundActionCreators }) => {
const query = gql`
{
site: contentfulSite(url: { eq: ${'thingsthatdostuff.com'} }) {
@subtleGradient
subtleGradient / youtube-get-the-transcript-text.bookmarklet.js
Last active February 16, 2022 20:17
JS Bookmarklet to Get the text content of any YouTube video that has a transcript!
javascript: void (()=>{
let text = null;
try {
text = document
.querySelector("ytd-transcript-renderer")
.__data
.data
.body
.transcriptBodyRenderer
.cueGroups
@subtleGradient
subtleGradient / Docs as Wiki (tools) icon.png
Last active September 9, 2018 01:13
Google Docs script to Create new Document from selected text and then link selected text to that new document URL; Use Google Docs like a Wiki
Docs as Wiki (tools) icon.png
//https://www.khanacademy.org/computer-programming/bouncy-hat/5273009214128128
var hatY = 0;
var HATY_MAX = 106;
var defaultSpringState = {
enabled: true,
mass: 10,
friction: 3,
stiffness: 120 / 100,
@subtleGradient
subtleGradient / fiddle.html
Last active November 24, 2020 17:06 — forked from anonymous/fiddle.html
(source: https://jsfiddle.net/SubtleGradient/vdre57wn/) Android monkey script generator UI thing
<!DOCTYPE html>
<meta charset="UTF-8">
<style>
html{background:#333}
</style>
<!-- <script src="lib/monkey keycodes.js"></script> -->
<script>
#lulz {
width:480px;
height:480px;
border-collapse:collapse;
}
#lulz td {
border: 2px solid black;
}
#lulz td.chosen {
border-color: red;
html,body{font-family: "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;}
*{margin:0;padding:0;}
body{padding:2ex;}
hr{margin:2ex 0;}
html,body,input,td,th{font-size:100%;}
div{border:4px solid #AEFFE6;background:#66FFCC;}
p {border:2px solid #66FFCC;background:#ffc;color:#cc0;}
//html{width:320px}
@subtleGradient
subtleGradient / idiomatic-web-naming.html
Last active March 17, 2018 14:07
Web conventions for naming stuff. What is normal? What is weird? Why?
<html>
<!-- It's normal NOT TO indent the children of the html element -->
<body>
<!-- It's normal NOT TO indent the children of the body element -->
<div style="background-color: lime" data-moo-mar-maz="abc123" id="abc123">
<!-- It's normal TO indent the innards of almost all HTML elements -->
Hello World.
</div>
@subtleGradient
subtleGradient / fixLeftNavSelection.js
Last active January 15, 2018 15:38
Fix SharePoint left sidebar selecting the wrong link with JavaScript
function fixLeftNavSelection() {
const leftNavBar = document.getElementById("DeltaPlaceHolderLeftNavBar");
if (leftNavBar == null) return;
const href = location.pathname + location.search;
const correctLink = leftNavBar.querySelector(
'li > a.ms-core-listMenu-item[href*="' + href + '"]'
);
if (correctLink == null) return;
// Remove selection from everything