Skip to content

Instantly share code, notes, and snippets.

View nathggns's full-sized avatar

Nate Higgins nathggns

View GitHub Profile
@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,
@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 / 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 / README.md
Last active January 26, 2017 12:11
Fibonacci Generator in LMC

LMC Fibonacci Generator

Screenshot

You can run this program on any LMC emulator, such as http://peterhigginson.co.uk/LMC/

LMC, which stands for Little Man Computer is a model of a computer, used to teach students how CPUs work. Read More.

Lines 1-2

@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 / hangman.py
Last active March 13, 2018 00:42
Python hangman game
# All this code is in one file for simplicity. It wouldn't normally be.
#
# This code makes advanced use of classes and regular expressions.
# Good luck with it.
# Let me know if there's anything you can't understand.
#
# Oh it also used list comprehensions. Enjoy those.
import re
@nathggns
nathggns / freebsd-java.md
Created January 29, 2015 20:25
Installing java on FreeBSD

Before installing this JRE, you have to install the linux binary compatibility on FreeBSD, you can follow this documentation. Jave requires some information about the proc. You have to mount linprocfs, type:

kldload linprocfs
mount -t linprocfs linprocfs /compat/linux/proc

and add this line to /etc/fstab:

linprocfs   /compat/linux/proc   linprocfs   rw   0  0
@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 / 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
.no-select, .no-select * {
-webkit-user-select: none;
}
.selectable, .selectable * {
-webkit-user-select: all:
}