Skip to content

Instantly share code, notes, and snippets.

View hendriklammers's full-sized avatar

Hendrik Lammers hendriklammers

View GitHub Profile
@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 / 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 / .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 / gist:4709866
Created February 4, 2013 21:27
Javascript: isArray
function isArray(value) {
return Object.prototype.toString.call(value) === "[object Array]";
}
@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: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:3823114
Created October 2, 2012 20:35 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@hendriklammers
hendriklammers / mouse_position.js
Created September 25, 2012 11:34
Javascript: Canvas mouse position
// Add mousePosition on the Canvas element
(function () {
function mousePosition(event) {
var totalOffsetX = 0,
totalOffsetY = 0,
coordX = 0,
coordY = 0,
currentElement = this,
mouseX = 0,
mouseY = 0;
@hendriklammers
hendriklammers / addEventListener-polyfill.js
Created September 24, 2012 21:48 — forked from eirikbacker/addEventListener-polyfill.js
Javascript: addEventListener polyfill for IE6+
//addEventListener polyfill 1.0 / Eirik Backer / MIT Licence
(function(win, doc){
if(win.addEventListener)return; //No need to polyfill
function docHijack(p){var old = doc[p];doc[p] = function(v){return addListen(old(v))}}
function addEvent(on, fn, self){
return (self = this).attachEvent('on' + on, function(e){
var e = e || win.event;
e.preventDefault = e.preventDefault || function(){e.returnValue = false}
e.stopPropagation = e.stopPropagation || function(){e.cancelBubble = true}
@hendriklammers
hendriklammers / bind_polyfill.js
Created September 23, 2012 21:32
Javascript: bind polyfill (Mozilla)
// Mozilla 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,