Skip to content

Instantly share code, notes, and snippets.

@pirate
pirate / parseURLParameters.js
Last active December 15, 2023 07:17
Parse URL query parameters in ES6
function getUrlParams(search) {
const hashes = search.slice(search.indexOf('?') + 1).split('&')
const params = {}
hashes.map(hash => {
const [key, val] = hash.split('=')
params[key] = decodeURIComponent(val)
})
return params
}
@watert
watert / gruntfile.coffee
Last active August 29, 2015 14:07
require config with bower
###
Gruntfile example for requirejs optimizing and less files watching
###
module.exports = (grunt) ->
out = (path)-> "../public-dist/#{path}"
grunt.initConfig
requirejs:
options:
mainConfigFile: "../public/require-config.js"
baseUrl: "../public"
@jayj
jayj / flexbox.less
Last active November 20, 2023 04:51
CSS3 Flexbox - LESS Mixins
// --------------------------------------------------
// Flexbox LESS mixins
// The spec: http://www.w3.org/TR/css3-flexbox
// --------------------------------------------------
// Flexbox display
// flex or inline-flex
.flex-display(@display: flex) {
display: ~"-webkit-@{display}";
display: ~"-ms-@{display}box"; // IE10 uses -ms-flexbox
@al6x
al6x / context.coffee
Created March 28, 2012 20:36
Adding context for Express.js req/res cycle
# Adding context for req/res cycle for Express.js.
# With context it would be possible to write more terse code:
#
# app.use ->
# @user = {name: 'Anonymous'}
# @next()
#
# app.get '/', ->
# @res.end "Hello, #{@user.name}"
#
@unscriptable
unscriptable / tiny Promise.js
Created February 7, 2011 06:02
A minimalist implementation of a javascript promise
// (c) copyright unscriptable.com / John Hann
// License MIT
// For more robust promises, see https://github.com/briancavalier/when.js.
function Promise () {
this._thens = [];
}
Promise.prototype = {