Skip to content

Instantly share code, notes, and snippets.

View nathggns's full-sized avatar

Nate Higgins nathggns

View GitHub Profile
interface SomeInterface {
(a : string, b : number, c : boolean) : void
}
function SomeFunction : SomeInterface() {
}
// Would be the same as
@nathggns
nathggns / lisp.js
Last active August 29, 2015 14:02
Lisp Interpreter
var readline = require('readline');
function Scope(variables, parent) {
this.variables = variables || {};
this.parent = parent;
}
Scope.prototype.find = function(name) {
return this.variables.hasOwnProperty(name) ?
this.variables[name] :
@nathggns
nathggns / clamp.js
Created June 25, 2014 14:06
Knockout (2.3+) binding for clamp
define(['knockout', 'clamp'], function(ko, $clamp) {
'use strict';
var textKey = 'originalClampText';
ko.bindingHandlers.clamp = {
update: function(element, valueAccessor, allBindings) {
var defaultText;
.no-select, .no-select * {
-webkit-user-select: none;
}
.selectable, .selectable * {
-webkit-user-select: all:
}
@nathggns
nathggns / README.md
Last active August 29, 2015 14:08
Helper function for dealing with cakephp form fields. Requires Lodash and jQuery.

Example:

HTML:

<form id="myForm">
    <label for="PermissionsWrite">Write</label>
    <input id="PermissionsWrite" type="checkbox" name="data[Permissions][]" value="Write" checked />
    
 Read
@nathggns
nathggns / stack-server.ts
Last active August 29, 2015 14:13
A proof of concept for a middleware stack based server written in TypeScript.
/// <reference path="./typings/node/node.d.ts" />
import http = require('http');
/**
* Takes a value from one middleware, and passes it to the next.
*
* If there is no next middleware, it returns the value to the middleware consumer
*/
interface MiddlewareDoneFunction<T> {
@nathggns
nathggns / helpers.php
Created April 2, 2015 20:40
Named Route Helper for Laravel
<?php
/**
*
* Nathaniel Higgins
*
* Add some easy helpers for adding named routes
*
* Use as follows:
*
* get('/', named('home', 'HomeController@index'));
@nathggns
nathggns / greeter.js
Created May 5, 2015 13:10
ES6 Greeter vs ES5 Greeter
class Greeter {
name;
constructor(name) {
this.name = name;
}
greet() {
return `Hello, ${this.name}`;
}
@nathggns
nathggns / dict-merge.js
Created May 9, 2015 01:01
Explaining dictionary merges
var obj = {
child : {
a : '0',
b : '2'
}
};
var extra = {
b : '3'
};
@nathggns
nathggns / results.json
Last active August 29, 2015 14:20
Results of the 2015 UK General Election (taken from the BBC Website)
{
"Aberavon": [
{
"name": "(LAB)",
"votes": 15416,
"share": 0.48
},
{
"name": "(UKIP)",
"votes": 4971,