Skip to content

Instantly share code, notes, and snippets.

View hendriklammers's full-sized avatar

Hendrik Lammers hendriklammers

View GitHub Profile
@hendriklammers
hendriklammers / .prettierrc
Created July 23, 2019 09:07
My prettier config
{
"semi": false,
"singleQuote": true,
"trailingComma": "es5"
}
@hendriklammers
hendriklammers / .editorconfig
Last active February 25, 2019 07:32
Basic .editorconfig file
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_size = 2
indent_style = space
trim_trailing_whitespace = true
@hendriklammers
hendriklammers / .jshintrc
Created May 11, 2013 15:37
jshint settings
{
"globals": {
"jasmine": false,
"it": false,
"describe": false,
"expect": false,
"beforeEach": false,
"afterEach": false,
"spyOn": false,
"runs": false,
@hendriklammers
hendriklammers / Gruntfile.js
Last active December 16, 2015 15:29 — forked from kamiyam/Gruntfile.js
Grunt with livereload
'use strict';
var path = require('path');
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
var folderMount = function folderMount(connect, point) {
return connect.static(path.resolve(point));
};
module.exports = function (grunt) {
// Project configuration.
@hendriklammers
hendriklammers / createArray.js
Created April 12, 2013 14:30
Javascript - createArray
/**
* Creates a multidimensional Array
* @param {Number} length Number of dimensions the new Array should have
* @return {Array} The newly created Array
*/
function createArray(length) {
var arr = new Array(length || 0),
i = length;
if (arguments.length > 1) {
@hendriklammers
hendriklammers / splitString.js
Last active January 6, 2024 15:46
Javascript: Split String into size based chunks
/**
* Split a string into chunks of the given size
* @param {String} string is the String to split
* @param {Number} size is the size you of the cuts
* @return {Array} an Array with the strings
*/
function splitString (string, size) {
var re = new RegExp('.{1,' + size + '}', 'g');
return string.match(re);
}
@hendriklammers
hendriklammers / isPrimeNumber.js
Last active December 15, 2015 07:09
Javascript: isPrimeNumber checks whether given value is a prime number or not
/**
* Use isPrimeNumber to check whether a number is a Prime number or not.
* @param {Number} value The number to check
* @return {Boolean} Is the given value a Prime Number or not.
*/
function isPrimeNumber (value) {
var max = Math.sqrt(value);
// Do some checks to prevent the loop from running for numbers that are obvious
if (isNaN(value) || !isFinite(value) || value % 1 || value < 2) {
return false;
@hendriklammers
hendriklammers / foreach.js
Created March 15, 2013 07:43
Javascript: forEach polyfill
if ( !Array.prototype.forEach ) {
Array.prototype.forEach = function(fn, scope) {
for(var i = 0, len = this.length; i < len; ++i) {
fn.call(scope, this[i], i, this);
}
}
}
@hendriklammers
hendriklammers / bind.js
Created March 14, 2013 22:08
Javascript: bind polyfill
if (!Function.prototype.bind) {
Function.prototype.bind = function (oThis) {
if (typeof this !== "function") {
// closest thing possible to the ECMAScript 5 internal IsCallable function
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
}
var aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
fNOP = function () {},
@hendriklammers
hendriklammers / classList.js
Created March 14, 2013 22:05
Javascript: classList polyfill
/*
* classList.js: Cross-browser full element.classList implementation.
* 2012-11-15
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
/*global self, document, DOMException */