Skip to content

Instantly share code, notes, and snippets.

View Havvy's full-sized avatar

Ryan Scheel Havvy

  • Work is not programming related
  • Washington, USA
View GitHub Profile
macro m { rule { $v } => { $v } }
let it = macro {
rule { $name:lit { $body ... } } => {
it($name, function () {
$body ...
});
}
}
@Havvy
Havvy / server.sjs
Created January 19, 2014 08:11
Ah, the difference a year makes.
/*
var util = require('util');
var ServerModule = function () {
this.capabilities = {};
};
ServerModule.prototype.getModule = function () {
return {
function keysWhere (obj, predicate) {
return Object.keys(obj).reduce(function (acc, key) {
if (predicate(key, obj[key])) {
acc.push(key);
}
return acc;
}, []);
}
fez.js (*)
test-src/
test-bdd.sjs (*)
test/
node_modules/
fez/
fez-sweet.js/
plugin.js (*)
node_modules/
sweet.js/
var sinon = require('sinon');
var assert = require('better-assert');
var equal = require('deep-eql');
var inspect = require('util').inspect;
var format = require('util').format;
var debug = false;
var logfn = debug ? console.log.bind(console) : function () {};
var logger = {debug: logfn, info: logfn, notice: logfn, warn: logfn, error: logfn};
@Havvy
Havvy / post.js
Created November 29, 2013 01:50
Do a POST request, redirecting the current page to the result.
function post(url, values) {
function add_input(name, value) {
var input = document.createElement("input");
input.name = name;
input.value = value;
form.appendChild(input);
}
var form = document.createElement("form");
@Havvy
Havvy / id_rsa.pub
Created November 7, 2013 18:58 — forked from anonymous/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQChecVDc+Ydwqnri7ikD5fPFgPsY0xuD/XLYD9piJqWLQKyogEhWZqMoQ/eZEfRPuRjaoHfZ+9vjl29LSQgqSApamgANSefw6jpJw/AvVFcAe/fBn44x8tHWSrV0iTR4MSjEPnupnIALa1qq/MTcbmcGnuLKSj8VvjVXHiw1THk7ErjHV5P5lXvurw+KFznxiwqgx2NsWZAPEEhFPb+C2v/w/W+fQ7jZTq7AqYG1AHp/wOpG7dHDmgXxx3x5T1t6xMG1eMlsfhwBwgULCFGElv7Mgwglx+SkMtGKuEjSK2MKML/9nPIV0UPMWoBfYbQTJK5rDfS0ib6MtCgkI+TOmHN ryan.havvy@gmail.com
var config = require('./config/mibbit.json');
var Client = require('tennu').Client;
new Client(config).connect();
@Havvy
Havvy / delayFns.js
Last active December 18, 2015 22:49
module.exports = function (delayedFn, period) {
var queue = [];
var queueEmpty = true;
var interval;
function consume () {
if (queue.length === 0) {
queueEmpty = true;
clearInterval(interval);
} else {

JS Wishes

  • Remove labels. They clutter the syntax for no real gain compared to what PHP did.
  • Replace with break and continue statements taking an optional positive integer (default 1), breaking that many loops out.
  • Match statement (See match.js)
  • [[call]] special property in object literal syntax.
  • [[prototype]] special property in object literal syntax.
  • 'self' lexical variable that refers to current object.
  • 'self(integer n)' lexical function that refers to the nth highest object literal. This looks ugly, but that's intentional. Note that the integer passed must be a literal integer.
  • Mixins via the [[prototype]] property being an array. First go through the prototype chain of the first object in the array. If not found, go through the second. Ect. ect. Until the end. If not found, the key is empty, and return undefined.