Skip to content

Instantly share code, notes, and snippets.

@ben-ng
ben-ng / a-repro.js
Created March 24, 2017 18:32
Salesforce Marketing Cloud constructor-from-closure bug
function newEnv () {
function Foo () {
Write('Hello World');
};
var f = {
Foo: Foo
}
return f;
@ben-ng
ben-ng / a-repro.js
Last active March 24, 2017 18:20
Salesforce Marketing Cloud closure scope bug
function foo() {
function boom() {
Write('Boom');
};
function bar () {
function baz() {
boom(); // Fails here, "boom" can't be found
};
@ben-ng
ben-ng / try-1.txt
Last active December 5, 2016 01:10
Swift build failure logs
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-31-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
100 packages can be updated.
47 updates are security updates.
@ben-ng
ben-ng / mergesort.swift
Created December 1, 2016 07:00
Benchmarking improvements to the ArrayElementValuePropagation pass
import Cocoa
func mergeSort(_ array: [Int]) -> [Int] {
guard array.count > 1 else { return array }
let middleIndex = array.count / 2
let leftArray = mergeSort(Array(array[0..<middleIndex]))
let rightArray = mergeSort(Array(array[middleIndex..<array.count]))
return merge(leftPile: leftArray, rightPile: rightArray)
}
@ben-ng
ben-ng / 1-README.md
Last active March 31, 2016 19:26
Test Spec

Tasks

Before you start

Depending on your assigned system, read the README-ORACLE.md or README-POSTGRES.md file.

You might need to configure user accounts and permissions to accomplish these tasks.

Tasks

@ben-ng
ben-ng / parser.js
Created July 19, 2013 18:10
Heroku DB URL parser
function parse_url(str, component) {
// http://kevin.vanzonneveld.net
// + original by: Steven Levithan (http://blog.stevenlevithan.com)
// + reimplemented by: Brett Zamir (http://brett-zamir.me)
// + input by: Lorenzo Pisani
// + input by: Tony
// + improved by: Brett Zamir (http://brett-zamir.me)
// + improved by: Ben Ng (http://benng.me)
// % note: Based on http://stevenlevithan.com/demo/parseuri/js/assets/parseuri.js
// % note: blog post at http://blog.stevenlevithan.com/archives/parseuri
@ben-ng
ben-ng / keybase.md
Created March 21, 2016 16:28
Keybase

Keybase proof

I hereby claim:

  • I am ben-ng on github.
  • I am benng (https://keybase.io/benng) on keybase.
  • I have a public key ASDpep_MuCxliK8Ty1NbkbFqxaqIh4dbgrd1NNpMoUV3tQo

To claim this, I am signing this object:

@ben-ng
ben-ng / leaky.js
Last active January 3, 2016 10:59
var MyView = Ribcage.View.extend({
afterInit: function (opts) {
this.action = opts.action;
}
, beforeRender: function () {
this.button = new ButtonView({
action: this.action
});
}
, afterRender: function () {
@ben-ng
ben-ng / index.js
Created January 11, 2014 01:16
requirebin sketch
var Backbone = require('backbone')
, $ = require('jquery')(window)
, View
, myView
, testModel;
Backbone.$ = $;
testModel = new Backbone.Model();
, getComments: function () {
if(!this.comments)
throw new Error('You need to loadComments before you can get comments');
return this.comments.map(function (comment) {
var obj = comment.toJSON();
obj.relativeDate = relative(obj.updated);
return obj;
});