Skip to content

Instantly share code, notes, and snippets.

type Product {
id: ID!
title: String
description: String
image: String
}
type Query {
product(id: ID!): Product
}
type Category {
id: ID!
name: String!
parentID: ID
children: [Category]
products: [Product]
}
type Product {
id: ID!
@fakedarren
fakedarren / MNM.md
Last active January 13, 2019 08:22

mynearestmarginal.com stats

Some stats from mynearestmarginal.com.

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.

Browsers

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));
}

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

@fakedarren
fakedarren / gist:705c59069bf91fddd46c
Last active August 29, 2015 14:04
jQuery Roulette
(function(){
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
fakedarren / regex.js
Created March 27, 2013 22:20
Just a few regexs I wrote / stole when creating a wysiwyg text editor a few years ago. God give me strength. Related: http://stackoverflow.com/a/1732454/299237
UI.TextEditor.implement({
cleanHTML: function() {
var html = this.textarea.value;
// Remove double new lines
html = html.replace(/\n\n+/g, "\n");
// Stupid apple-style-spans etc
$ packager build Core/* \
-blocks 1.2compat 1.3compat '!ES5' '!ES5-bind' \
IE ltIE9 ltIE8 firefox ltFF4 > core.js
@fakedarren
fakedarren / Links.md
Last active December 11, 2015 08:18
A few links to some of the things I've done