Skip to content

Instantly share code, notes, and snippets.

View csnover's full-sized avatar
🧹
ABC: Always Be Codejanitoring

Colin Snover csnover

🧹
ABC: Always Be Codejanitoring
View GitHub Profile
@csnover
csnover / README.md
Created February 21, 2011 01:11
Gyazo script
  1. Change $path and $uri as necessary in gyazo.php and upload it to your server
  2. Change HOST and CGI as necessary in script and use it to replace Gyazo.app/Contents/Resources/script (right-click -> Show Package Contents to get there)
  3. Continue along as usual
@csnover
csnover / gist:1110664
Created July 28, 2011 00:27
A base56 implementation
<?php
class Base56
{
/**
* Base56 alphabet. Technically, this component will do arbitrary encoding
* depending upon the alphabet, but whatevs!
* @var string
*/
private static $_alphabet = '23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz';
@csnover
csnover / gist:6210bc20379476d18e1a
Last active August 29, 2015 14:04
Hey snover, do you really have such a big problem with adding an exponentiation operator?

No, I don’t, not really. For projects that do these operations a lot, it would probably be a very useful enhancement. My reaction is a manifestation of my larger frustration with the direction of EcmaScript and TC39.

Why do I feel this way? A few reasons.

One, because here is the trap that we’re stuck in now:

  • Someone decides that feature X isn’t good enough, even though it has worked fine for years, so proposes functionally identical feature Y instead (see: exponentiation operator)
  • TC39 has decreed that EcmaScript shall not be versioned, so “legacy” syntax X cannot ever be removed
  • Now we have two competing ways to do the same thing
  • But sometimes the two ways are slightly different (reduced fat arrow function syntax, DIFFERENT lexical scope behaviour)
@csnover
csnover / gist:5900a60070d9a40fc7d8
Last active August 29, 2015 14:06
What should the first line of an error stack trace be, in different scenarios?
// scenario 1
var error = new Error('foo');
error.stack; // first line = ?
// scenario 2
var error = new Error('foo');
error.message = 'bar';
error.stack; // first line = ?
// scenario 3
@csnover
csnover / gist:3dbfd4670b4f79a176f0
Last active August 29, 2015 14:20
Spartan WebAudio bug: <audio> with playbackRate other than 1 is mute when routed through Web Audio API
<!DOCTYPE html>
<meta charset="utf-8">
<audio id="player" controls src="http://freedownloads.last.fm/download/415006180/So%2BSorry%2BGirl.mp3" type="audio/mp3"></audio><br>
<br>
<!-- playbackRate !== 1 should not cause audio to mute -->
Speed: <input type="range" min="0.5" max="2" value="1" step="0.01" onchange="player.playbackRate = +this.value">
<script>
var player = document.querySelector('#player');
if (window.AudioContext || window.webkitAudioContext) {
// License: MIT
module.exports = async function MakeNonNullableReferencesPlugin(builder, { pgConfig }) {
async function getPolicies() {
const { rows } = await pgConfig.query({
text: `SELECT DISTINCT polrelid::text, true FROM pg_policy WHERE polcmd IN ('r', '*')`,
rowMode: 'array'
});
return new Map(rows);
}