Skip to content

Instantly share code, notes, and snippets.

@buchanae
buchanae / test.js
Created January 24, 2016 01:35
Failing test script for mapbox-gl-native on node.js
var fs = require('fs');
var path = require('path');
var mbgl = require('../../mapbox-gl-native/lib/mapbox-gl-native');
var request = require('request');
var url = require('url');
var SegfaultHandler = require('segfault-handler');
SegfaultHandler.registerHandler("crash.log");
var options = {
@buchanae
buchanae / maki-sdf-sprite.json
Last active March 25, 2024 23:47
Maki SDF sprite
{
"aerialway": {
"x": 30,
"y": 0,
"width": 30,
"height": 30,
"pixelRatio": 1,
"sdf": true
},
"airfield": {
@buchanae
buchanae / multigetattr.py
Created January 12, 2015 02:53
Python multi getattr
class NoDefaultProvided(object):
pass
def getattrd(obj, name, default=NoDefaultProvided):
"""
Same as getattr(), but allows dot notation lookup
Discussed in:
http://stackoverflow.com/questions/11975781
"""
@buchanae
buchanae / lazy.js
Created June 19, 2014 02:48
Javascript lazy evaluate function
function lazy(func) {
var called = false;
var value;
var func = function() {
if (!called) {
value = func.apply({}, arguments);
}
return value;
}
@buchanae
buchanae / System.failed.json
Created June 8, 2014 02:34
SystemJS System.failed
[
{
"status": "loaded",
"name": "app\/app",
"linkSets": [
],
"dependencies": [
@buchanae
buchanae / index.html
Created June 7, 2014 18:04
SystemJS error handling
<!doctype html>
/**
* Count bytes in string
*
* Count and return the number of bytes in a given string
*
* @access public
* @param string
* @return int
*/
function getByteLen(normal_val)
@buchanae
buchanae / pathlib_notes.py
Last active December 31, 2015 01:59
notes on my first experiences with pathlib
from pathlib import Path
# Often I create a base path that is used frequently,
# such as getting files relative to a "data" directory.
data_path = Path(__file__).parent.joinpath('../data').resolve()
# I intuitively expected there to be a "basename" attribute.
# e.g. Path(__file__).basename
@buchanae
buchanae / alt_init.py
Last active December 30, 2015 20:39
Experimental alternate initializer pattern in Python
from collections import namedtuple
import functools
import unittest
# The following example is contrived and over-simplified.
class Vehicle(object):
mod.factory('DataTable', function(someInjectable) {
function DataTable(rows) {
// ... can use "someInjectable" here ...
}
// This seems like boilerplate,
// but I think I'm missing something.
return {
create: function(rows) {
return new DataTable(rows);