Skip to content

Instantly share code, notes, and snippets.

View sundarj's full-sized avatar

Sundar Joshi sundarj

View GitHub Profile
@sundarj
sundarj / slugify.js
Last active April 24, 2016 20:41 — forked from mathewbyrne/slugify.js
Javascript Slugify (works with unicode chars)
function slugify( title ) {
return (title+'')
.toLowerCase()
.replace(/\s+/g, '-')
.replace(/[!"'£$%\^&*()_+=\/\|`¬/><.,{}[\]:;]/g, '')
.replace(/\-\-+/g, '-')
.replace(/^-+/, '')
.replace(/-+$/, '')
}
@sundarj
sundarj / ractive.parse.js
Last active October 19, 2015 13:37
Standalone Ractive.parse (minus Mustache parsing)
/**
* Parser base class
* ractivejs/ractive/blob/master/src/parse/
*/
var Parser, ParseError, leadingWhitespace = /^\s+/;
ParseError = function ( message ) {
this.name = 'ParseError';
this.message = message;
@sundarj
sundarj / micro.js
Last active December 13, 2015 19:37
Performant implementations of common helper functions
(function() {
"use strict";
var root = typeof self == 'object' && self.self === self && self ||
typeof global == 'object' && global.global === global && global ||
this;
var micro = function (obj) {
if (obj instanceof micro) return obj;
if (!(this instanceof micro)) return new micro;
a {
display: inline-block
vertical-align: middle
} :hover {
opacity: .7
}
header !important {
background-color: pink
@sundarj
sundarj / Q.js
Last active December 3, 2015 19:18
tiny, fast, Zepto/jQuery-like query engine
(function(exports, document, Element, Array) {
"use strict";
let selectorPattern = /^(#?[\w-]+|\.[\w-.]+)$/;
let periods = /\./g;
// https://github.com/ryanmorr/query
function query(selector, context, first) {
context = context || document;
let results = null;
@sundarj
sundarj / ircd.js
Created December 19, 2015 21:11 — forked from ry/ircd.js
node.js ircd
#!/usr/bin/env node
// ircd demo for jsconf.eu/2009
// This was written with Node version 0.1.16. An earlier version will not
// work with this script, however later versions might.
port = 6667;
serverName = "irc.nodejs.org";
topic = "node.js ircd https://gist.github.com/a3d0bbbff196af633995";
@sundarj
sundarj / compose.js
Last active January 6, 2016 13:17
function composition
export default const compose = (fns) => {
return (...args) => {
return fns.reduce(
(f, g) => {
return g(
typeof f === 'function' ?
f(...args) :
f
)
}
@sundarj
sundarj / 0 - data.md
Last active December 5, 2019 10:47
data: towards enlightenment

data

towards enlightenment

‘It is a capital mistake to theorize before one has data. Insensibly one begins to twist facts to suit theories, instead of theories to suit facts.’

Afghanistan
Åland Islands
Albania
Algeria
American Samoa
Andorra
Angola
Anguilla
Antarctica
Antigua and Barbuda
@sundarj
sundarj / middleware slash index.js
Last active January 28, 2016 21:08
example api for http server module
module.exports = [
function setContentType(req, res) {
res.header('content-type', 'text/html')
},
/*
function catchAll(req, res) {
res.pipe('error %s', res.status)
}
*/
]