Skip to content

Instantly share code, notes, and snippets.

Ben Ng ben-ng

Block or report user

Report or block ben-ng

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
@ben-ng
ben-ng / a-repro.js
Created Mar 24, 2017
Salesforce Marketing Cloud constructor-from-closure bug
View a-repro.js
function newEnv () {
function Foo () {
Write('Hello World');
};
var f = {
Foo: Foo
}
return f;
@ben-ng
ben-ng / a-repro.js
Last active Mar 24, 2017
Salesforce Marketing Cloud closure scope bug
View a-repro.js
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 Dec 5, 2016
Swift build failure logs
View try-1.txt
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 Dec 1, 2016
Benchmarking improvements to the ArrayElementValuePropagation pass
View mergesort.swift
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)
}
View 1-README.md

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 Jul 19, 2013
Heroku DB URL parser
View parser.js
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
View keybase.md

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:

View leaky.js
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 Jan 11, 2014
requirebin sketch
View index.js
var Backbone = require('backbone')
, $ = require('jquery')(window)
, View
, myView
, testModel;
Backbone.$ = $;
testModel = new Backbone.Model();
View gist:8326943
, 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;
});
You can’t perform that action at this time.