Skip to content

Instantly share code, notes, and snippets.

View mde's full-sized avatar

Matthew Eernisse mde

View GitHub Profile
var Foo = Ember.Object.extend({zerb: function () {}});
undefined
var bar = Foo.create();
undefined
JSON.stringify(bar);
"{}"
bar.set('asdf', 'ASDF');
Class {asdf: "ASDF", __ember1458770221107: null, __nextSuper: undefined, __ember_meta__: Object}
JSON.stringify(bar);
"{"asdf":"ASDF"}"
function filterGhNotifications() {
var sourceLabel = GmailApp.getUserLabelByName('GH');
var addedLabel = GmailApp.getUserLabelByName('GH -- mde');
var pat = /@mde/;
var threads;
var foundThreads = [];
threads = sourceLabel.getThreads(0, 20);
threads.forEach(function (thread) {
var messages = thread.getMessages();
var subject;
@mde
mde / iterative_cps.js
Created September 22, 2015 00:06
Iterative, but CPS
var iterativeRunner = function (arr) {
var funcs = arr.map(function (item, index) {
return function () {
item(function () {
if (funcs[index + 1]) {
funcs[index + 1]();
}
});
};
});
@mde
mde / gist:ae752b3bb4a66c152371
Created June 20, 2015 04:54
PropagateAction mixin
import Ember from 'ember';
export default Ember.Mixin.create({
_sendActionPropagateChannel: '_sendActionPropagateChannel',
actions: {
_sendActionPropagateChannel: function () {
try {
this.send.apply(this, arguments);
}
catch (err) {
@mde
mde / gist:3825a3732effbe76ee62
Created May 19, 2015 23:49
JavaScript "this"
var foo = {
a: function () {
console.log(this);
}
};
foo.a(); // Logs the foo obj
foo['a'](); // Same, logs the foo obj
@mde
mde / gist:8c5c8a3cd48d6c2dd545
Created May 19, 2015 23:33
JavaScript closures
var foo = function (seed) {
var currVal = seed;
var incrementor = function () {
currVal++;
console.log(currVal);
};
return incrementor;
};
@mde
mde / gist:81b131ff6810ed7c4e0e
Last active August 29, 2015 14:18
Simple left-to-right mixin
var mixin = function () {
var args = Array.prototype.slice.call(arguments);
var target = args.shift();
var source = args.shift();
// We don't need no hasOwnProperty checks!
for (var prop in source) {
target[prop] = source[prop];
}
if (args.length) {
args.unshift(target);
@mde
mde / gist:82a934b6a3fa1da604be
Created October 1, 2014 05:55
JavaScript noodling
> var foo = function (a) { return function (b) { return a * b; }; };
undefined
> var bar = foo(2);
undefined
> bar(5);
10
> var foo = function () { console.log(arguments.length); };
undefined
> foo();
0
var http = require('http')
, domain = require('domain')
, riakpbc = require('./index')
, riak = riakpbc.createClient({host: 'localhost', port: 8087});
http.createServer(function (req, res) {
var dmn = domain.create();
dmn.on('error', function (err) {
console.dir(arguments);
bash-3.2$ npm install
npm http GET https://registry.npmjs.org/filelist
npm http GET https://registry.npmjs.org/minimatch/0.2.3
npm http 200 https://registry.npmjs.org/filelist
npm http GET https://registry.npmjs.org/filelist/-/filelist-0.0.2.tgz
npm http 200 https://registry.npmjs.org/minimatch/0.2.3
npm http GET https://registry.npmjs.org/minimatch/-/minimatch-0.2.3.tgz
npm http 200 https://registry.npmjs.org/filelist/-/filelist-0.0.2.tgz
npm WARN package.json filelist@0.0.2 No README.md file found!
npm http 200 https://registry.npmjs.org/minimatch/-/minimatch-0.2.3.tgz