Skip to content

Instantly share code, notes, and snippets.

Avatar
👽
In the zone

Hendrik Lammers hendriklammers

👽
In the zone
View GitHub Profile
View .prettierrc
{
"semi": false,
"singleQuote": true,
"trailingComma": "es5"
}
@hendriklammers
hendriklammers / .editorconfig
Last active Feb 25, 2019
Basic .editorconfig file
View .editorconfig
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_size = 2
indent_style = space
trim_trailing_whitespace = true
View .jshintrc
{
"globals": {
"jasmine": false,
"it": false,
"describe": false,
"expect": false,
"beforeEach": false,
"afterEach": false,
"spyOn": false,
"runs": false,
@hendriklammers
hendriklammers / Gruntfile.js
Last active Dec 16, 2015 — forked from kamiyam/Gruntfile.js
Grunt with livereload
View Gruntfile.js
'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 Apr 12, 2013
Javascript - createArray
View createArray.js
/**
* 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 Sep 4, 2020
Javascript: Split String into size based chunks
View splitString.js
/**
* 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 Dec 15, 2015
Javascript: isPrimeNumber checks whether given value is a prime number or not
View isPrimeNumber.js
/**
* 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 Mar 15, 2013
Javascript: forEach polyfill
View foreach.js
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 Mar 14, 2013
Javascript: bind polyfill
View bind.js
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 Mar 14, 2013
Javascript: classList polyfill
View classList.js
/*
* 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 */
You can’t perform that action at this time.