Skip to content

Instantly share code, notes, and snippets.

Darren Waddell fakedarren

View GitHub Profile
View Products Schema
type Product {
id: ID!
title: String
description: String
image: String
type Query {
product(id: ID!): Product
View Categories Schema
type Category {
id: ID!
name: String!
parentID: ID
children: [Category]
products: [Product]
type Product {
id: ID!
View stats

Some stats from

I've shared this because it gives an unfiltered insight into what devices and browsers are used by Momentum's demographic. I would assume that this matches the demographic a lot of startups also target. That's an assumption on my part though.

Uses Node, Express, Handlebars for backend. jQuery and Google Maps for front end. MongoDB for database (and crucially geospatial search). Cloudflare and Heroku for hosting / scaling.


View gist:4b17aaba8db62177374e
var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;";
var to = "aaaaeeeeiiiioooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++) {
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
View gist:28953b01e455078fb4f8

I feel the need to have a little rant about MooTools and ES7 and the whole 'Array.contains' hoo-hah.

When MooTools came out in 2006, the most popular framework was Prototype. As the name suggests, it extended prototypes, as did MooTools. People still referred to making websites with JavaScript as 'DHTML', there was no trim method on strings, there wasn't even a forEach method on arrays. JavaScript was a crippled language. IE6 ruled the waves.

MooTools, Prototype, Dojo, Base2 - they made the language usable, even fun, to work with. By using an incredible feature of JavaScript, prototypical inheritance, we were able to add features to the language that made it palatable.

Be it simple methods like number.toInt, string.trim, array.forEach, or familiar programming constructs such as Class, MooTools and its ilk took JavaScript from something impossible to work with to something that you could properly use to build awesome sites, and even apps - Microsoft, IE and desktop ruled everything, and the concept of a 'we

View gist:705c59069bf91fddd46c
var script = document.createElement('script'),
major = Math.random() * (2 - 1) + 1 ,
minor = 0;
if (major === 1){
minor = Math.random() * (11 - 0);
} else {
minor = Math.random() * (2 - 1) + 1;
fakedarren / regex.js
Created Mar 27, 2013
Just a few regexs I wrote / stole when creating a wysiwyg text editor a few years ago. God give me strength. Related:
View regex.js
cleanHTML: function() {
var html = this.textarea.value;
// Remove double new lines
html = html.replace(/\n\n+/g, "\n");
// Stupid apple-style-spans etc
View gist:4968358
$ packager build Core/* \
-blocks 1.2compat 1.3compat '!ES5' '!ES5-bind' \
IE ltIE9 ltIE8 firefox ltFF4 > core.js
fakedarren /
Last active Dec 11, 2015
A few links to some of the things I've done
You can’t perform that action at this time.