Skip to content

Instantly share code, notes, and snippets.

Colin Snover csnover

Block or report user

Report or block csnover

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View PgNonNullReferencesPlugin.js
// 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);
}
@csnover
csnover / gist:3dbfd4670b4f79a176f0
Last active Aug 29, 2015
Spartan WebAudio bug: <audio> with playbackRate other than 1 is mute when routed through Web Audio API
View gist:3dbfd4670b4f79a176f0
<!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) {
@csnover
csnover / gist:5900a60070d9a40fc7d8
Last active Aug 29, 2015
What should the first line of an error stack trace be, in different scenarios?
View gist:5900a60070d9a40fc7d8
// 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:6210bc20379476d18e1a
Last active Aug 29, 2015
Hey snover, do you really have such a big problem with adding an exponentiation operator?
View gist:6210bc20379476d18e1a

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:1110664
Created Jul 28, 2011
A base56 implementation
View gist:1110664
<?php
class Base56
{
/**
* Base56 alphabet. Technically, this component will do arbitrary encoding
* depending upon the alphabet, but whatevs!
* @var string
*/
private static $_alphabet = '23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz';
View README.md
  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
You can’t perform that action at this time.