Skip to content

Instantly share code, notes, and snippets.

View hendriklammers's full-sized avatar

Hendrik Lammers hendriklammers

View GitHub Profile
@hendriklammers
hendriklammers / gist:4037649
Created November 8, 2012 08:59
Sass: underline mixin
/* Replace default underline on a link with a bottom border */
@mixin underline($color, $width: 1px) {
text-decoration: none;
display: block-inline;
position: relative;
&:before {
content: '';
display: block-inline;
position: absolute;
@hendriklammers
hendriklammers / gist:4109599
Created November 19, 2012 08:40
Terminal shortcuts
Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
Ctrl + L Clears the Screen, similar to the clear command
Ctrl + U Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + H Same as backspace
Ctrl + R Let’s you search through previously used commands
Ctrl + C Kill whatever you are running
Ctrl + D Exit the current shell
Ctrl + Z Puts whatever you are running into a suspended background process. fg restores it.
Ctrl + W Delete the word before the cursor
@hendriklammers
hendriklammers / gist:4709866
Created February 4, 2013 21:27
Javascript: isArray
function isArray(value) {
return Object.prototype.toString.call(value) === "[object Array]";
}
@hendriklammers
hendriklammers / .jshintrc
Created February 15, 2013 14:12
jshintrc: For Yeoman with jasmine testing. Needs to be updated with more globals...
{
"globals": {
"$": false,
"jasmine": false,
"it": false,
"describe": false,
"expect": false,
"beforeEach": false,
"afterEach": false,
"spyOn": false,
@hendriklammers
hendriklammers / Gruntfile.js
Created February 15, 2013 14:16
Javascript: Yeoman grunt file, updated for Jasmine testing
module.exports = function( grunt ) {
'use strict';
//
// Grunt configuration:
//
// https://github.com/cowboy/grunt/blob/master/docs/getting_started.md
//
grunt.initConfig({
// Project configuration
@hendriklammers
hendriklammers / isArray.js
Last active December 14, 2015 15:58
Javascript: Array.isArray() polyfill
if(!Array.isArray) {
Array.isArray = function (vArg) {
return Object.prototype.toString.call(vArg) === "[object Array]";
};
}
@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 */
@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 / 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 / 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;