Skip to content

Instantly share code, notes, and snippets.


Gary Bernhardt garybernhardt

View GitHub Profile
View page.tsx
import React, { useEffect } from "react"
import { META_DESCRIPTION } from "../../util"
export const Page: React.FC<{
title?: string
metaDescription?: string
}> = props => {
useEffect(() => {
document.title = props.title ?? "Execute Program"
View asset-expiration.diff
commit 9f676b29d4a49356e756048ff249d17e552b5faa (HEAD -> master, origin/master)
Author: Gary Bernhardt <>
Date: Sun Mar 15 13:36:55 2020 -0700
cache public dir between deploys (note)
1. A deploy starts.
2. A browser starts loading a page.
3. The deploy finishes.
View gist:f5ab5283c760ba3fe593f4da23b68169
proper tail calls (tail call optimisation)
default function parameters
rest parameters
spread syntax for iterable objects
object literal extensions
for..of loops
octal and binary literals
View src__common__tsconfig.json
"extends": "../tsconfig.json",
"compilerOptions": {
"composite": true,
"rootDir": ".",
"outDir": "../../build/common"
"include": ["."]
View gist:55254ce390b87b2121cee69f1c2f61f6
function f() {
switch (x) {
case "1":
case "2":
return <div>
View gist:2f9dc11d5548943b8ac118341aa8bac9
const webpack = require('webpack');
const path = require('path');
const StatsWriterPlugin = require("webpack-stats-plugin").StatsWriterPlugin
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const production = process.env.RACK_ENV == 'production'
const config = {
mode: production ? "production" : "development",
entry: './build/client/app.js',
View print-leaked-events.js
// This has been updated. You'll have to go back in time in the gist history to
// see older versions.
const { writeSync } = require("fs")
const async_hooks = require("async_hooks")
async function printLeakedEvents(f) {
// Track all active event IDs
const eventIDs = new Set()
garybernhardt / gist:c2fceef67bcba989b2742dad88c9170b
Created Sep 17, 2018
Automatically fix rubocop errors, with one commit per error
View gist:c2fceef67bcba989b2742dad88c9170b
rubocop | egrep ' (W|C): ' | cut -d ' ' -f 3 | sort -u | sed 's/:$//' | while read cop; do
git checkout .
rubocop -a --only "$cop";
if [[ $(git diff --stat) != '' ]]; then
git add --all
git commit -m "fix rubocop cop $cop"
View test.rb
#!/usr/bin/env ruby
# This script tests par2 recovery when the par2 files themselves are corrupted.
# Process:
# 1. Generate a file containing all 256 possible bytes.
# (More would be better, but it gets slow fast.)
# 2. Generate par2 data for the file.
# 3. Individually corrupt each par2 file at each offset.
# (Write byte 0 unless the offset already contains byte 0; then, write byte 255.)
# (Writing each possible byte would be better, but it gets slow fast.)
View inline.rb
#!/usr/bin/env ruby
require 'base64'
require 'nokogiri'
require 'uri'
def main
html = Nokogiri::HTML($
You can’t perform that action at this time.