Skip to content

Instantly share code, notes, and snippets.

View marlun78's full-sized avatar

Martin Eneqvist marlun78

View GitHub Profile
/**
* Handlebars eachIn helper
* Copyright (c) 2013, marlun78
* MIT License, https://gist.github.com/marlun78/bd0800cf5e8053ba9f83
*
* Description:
* A Handlebars helper to iterate over object properties rather than arrays.
*
* Usage:
* <script id="list-object" type="text/x-handlebars-template">
@marlun78
marlun78 / simpleCanvasSpinner.js
Last active December 12, 2015 03:29
A simple <canvas> spinner
/**
* Canvas Loading Spinner
* Copyright (c) 2013, marlun78
* MIT License, https://gist.github.com/marlun78/bd0800cf5e8053ba9f83
*/
(function(){
'use strict';
var _lineCaps = ['butt', 'round', 'square'],
@marlun78
marlun78 / parseUrl.js
Last active October 13, 2015 15:07
JavaScript URL parser
/**
* parseUrl
* Copyright (c) 2012, marlun78
* MIT License, https://gist.github.com/marlun78/bd0800cf5e8053ba9f83
*
* Needs to run in a browser, uses String.prototype.lastIndexOf method.
* Regexp stolen from: http://stevenbenner.com/2010/03/javascript-regex-trick-parse-a-query-string-into-an-object/
*/
var parseUrl = (function (element) {
@marlun78
marlun78 / httpStatusCodes.js
Last active October 23, 2020 00:45
An HTTP Status Codes object
/**
* HTTP Status Codes
* Copyright (c) 2012, marlun78
* MIT License, https://gist.github.com/marlun78/bd0800cf5e8053ba9f83
*
* Taken from: http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
* Visual Studio find regex: ^(\d{3}) ([^\r\n]+)\r\n
* Visual Studio replace regex: '$1': '$2', //
* Notes wrapped in parens moved manually
*/
@marlun78
marlun78 / jquery.autogrow.js
Last active October 6, 2015 08:28
A jQuery plugin that converts a textarea to a auto-growing textarea
/**
* Autogrow, version 1.0
* Copyright (c) 2012, marlun78
* MIT License, https://gist.github.com/marlun78/bd0800cf5e8053ba9f83
*
* A jQuery plugin that converts a textarea to a (Facebook-like) auto-growing textarea.
* Built for jQuery 1.5.1
*/
$.fn.autogrow = function () {
var refresh = function (area, element) {
@marlun78
marlun78 / setDefaultArguments.js
Last active October 6, 2015 08:27
Adds default param values to a function
/**
* Default Arguments
* Copyright (c) 2012, marlun78
* MIT License, https://gist.github.com/marlun78/bd0800cf5e8053ba9f83
*
* Set default arguments to a function
* @param {function} fn - The function to decorate
* @param {*} [args...] - Any default arguments
* @returns {function} - The new decorated function
*
@marlun78
marlun78 / underscore-1.3.3-templates.js
Last active April 23, 2023 20:55
Underscore.js templates as a standalone implementation
/*!
Underscore.js templates as a standalone implementation.
JavaScript micro-templating, similar to John Resig's implementation.
Underscore templates documentation: http://documentcloud.github.com/underscore/#template
Modifyed by marlun78
*/
(function () {
'use strict';
@marlun78
marlun78 / array.extras.js
Last active October 2, 2015 03:08
Some Array util methods.
/*!
* Array Extras, version 1.0
* Copyright (c) 2012, marlun78
* MIT License, https://gist.github.com/marlun78/bd0800cf5e8053ba9f83
*
* Depends on type.extras.js
*/
(function(ns){
// Returns the first index at which a given type can be found in the array, or -1 if it is not present.
@marlun78
marlun78 / type.extras.js
Last active October 2, 2015 03:08
Some type util methods.
/**
* Type Extras, version 1.0
* Copyright (c) 2012, marlun78
* MIT License, https://gist.github.com/marlun78/bd0800cf5e8053ba9f83
*/
(function (ns) {
// Returns an given element's internal [[Class]] property as a lower-case string
var _toString = Object.prototype.toString,
typeOf = function (object) {
@marlun78
marlun78 / jquery.makeplaceholders.js
Last active September 29, 2015 05:57
A fallback for HTML5s placeholder attribute when not supported by the browser
/**
* Make Placeholders jQuery plugin, version 1.0
* Copyright (c) 2012, marlun78
* MIT License, https://gist.github.com/marlun78/bd0800cf5e8053ba9f83
*
* === Description ===
*
* Use as a fallback for HTML5s placeholder attribute when not supported by the browser. It does this by creating a
* placeholder element that has to be positioned over the input. This plugin does not position it for you, but it
* makes it very easy for you to do so.