Skip to content

Instantly share code, notes, and snippets.

View rmorlang's full-sized avatar

Rick Morlang rmorlang

  • Vancouver, Canada
View GitHub Profile
@rmorlang
rmorlang / stack-chain-preventExtensions-test.js
Created November 18, 2015 17:46
Example code that demonstrates how stack-chain will blow up if an error has been made non-extensible for some reason.
function createNonExtensibleError() {
var error = new Error("I am a non-extensible error");
Object.preventExtensions(error);
return error;
}
function handleError(e) {
console.log("\nERROR: " + e.message);
console.log("--- STACK TRACE BEGIN ---");
console.log(e.stack);
import requests
class HoverException(Exception):
pass
class HoverAPI(object):
def __init__(self, username, password):
params = {"username": username, "password": password}
r = requests.post("https://www.hover.com/api/login", params=params)
# The bug below has been fixed in color 1.4 which is
# the successor to color-tools 1.3.0
#
# There's a bug in color-tools when converting HSL to RGB for desaturated
# colors. It doesn't multiple the lightness value by 255, so every resulting
# set of RGB values ends up being (1,1,1). This monkeypatch fixes it.
class Color::HSL
def to_rgb_with_saturation_bugfix(ignored = nil)
return Color::RGB.new(*([@l * 0xff] * 3)) if @s <= 1e-5
to_rgb_without_saturation_bugfix(ignored)