Skip to content

Instantly share code, notes, and snippets.

View garybernhardt's full-sized avatar

Gary Bernhardt garybernhardt

View GitHub Profile
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"
commit 9f676b29d4a49356e756048ff249d17e552b5faa (HEAD -> master, origin/master)
Author: Gary Bernhardt <gary.bernhardt@gmail.com>
Date: Sun Mar 15 13:36:55 2020 -0700
cache public dir between deploys (note)
Problem:
1. A deploy starts.
2. A browser starts loading a page.
3. The deploy finishes.
ES2015
Optimisation
proper tail calls (tail call optimisation)
Syntax
default function parameters
rest parameters
spread syntax for iterable objects
object literal extensions
for..of loops
octal and binary literals
{
"extends": "../tsconfig.json",
"compilerOptions": {
"composite": true,
"rootDir": ".",
"outDir": "../../build/common"
},
"include": ["."]
}
function f() {
switch (x) {
case "1":
<div>foo</div>
case "2":
return <div>
<div>
foo
</div>
<div>foo</div>
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',
// 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
garybernhardt / gist:c2fceef67bcba989b2742dad88c9170b
Created September 17, 2018 18:34
Automatically fix rubocop errors, with one commit per error
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"
fi
done
#!/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.)
#!/usr/bin/env ruby
require 'base64'
require 'nokogiri'
require 'uri'
def main
html = Nokogiri::HTML($stdin.read)
inline_all_images(html)
inline_all_css(html)