Skip to content

Instantly share code, notes, and snippets.

View dannycallaghan's full-sized avatar

Danny Callaghan dannycallaghan

  • London
View GitHub Profile
@dannycallaghan
dannycallaghan / AddSublimeToCLI
Created February 20, 2014 12:08
Add Sublime Text To CLI
n -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/bin/subl
*,
*:before,
*:after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
# copies the SSH key in id_rsa.pub to your clipboard
pbcopy < ~/.ssh/id_rsa.pub
# generates a SSH key for use with GitHub, etc
ssh-keygen -t rsa -C "your_email@example.com"
/* 5px shadow in every distance, with blur of 5 and spread of 6 */
.foo {
-moz-box-shadow: -5px -5px 5px 6px #888;
-webkit-box-shadow: -5px -5px 5px 6px#888;
box-shadow: -5px -5px 5px 6px #888;
}
/* 5px inner shadow in every distance */
.bar {
-moz-box-shadow: inset 0 0 5px 5px #888;
@dannycallaghan
dannycallaghan / (Better) JavaScript Type Detection
Created October 3, 2013 08:10
(Better) JavaScript Type Detection
/* Better type detection */
/*
- Checking a supposed array for a method like slice() isn't robust enough, as there's no reason why a non-array couldn't have a method of the same name
- instanceof Array works incorrectly when used across frames in some IE versions
*/
// ARRAY
var alpha = [];
console.log( typeof alpha ); // "object"
console.log( alpha.constructor === Array ); // true
console.log( Object.prototype.toString.call( alpha ) ); // "[object Array]"
@dannycallaghan
dannycallaghan / Repeat Character In JavaScript.js
Created October 3, 2013 08:11
Repeat a character (or set of characters) n times.
/* Repeat a character (or set of characters) n times */
var dashes = new Array( 21 ).join( '-' ); // Outputs 20 dashes
@dannycallaghan
dannycallaghan / isArray() in ES < 5.js
Created October 3, 2013 08:13
isArray() in ECMAScript < 5
/* isArray() in ECMAScript < 5 */
if ( typeof Array.isArray === "undefined" ) {
Array.isArray = function ( arg ) {
return Object.prototype.toString.call( arg ) === "[object Array]";
};
}
@dannycallaghan
dannycallaghan / Overflow Auto Scroll Fix
Created October 3, 2013 14:02
Fixes the sometimes visible vertical scrollbar when using 'overflow: auto' (invariably as a clear float fix). Includes a fix for IE8. From http://stackoverflow.com/questions/7646538/disable-vertical-scroll-bar-on-div-overflow-auto
.foo {
overflow: auto;
overflow-y: hidden;
-ms-overflow-y: hidden; /* IE8 fix */
}
/* The Error Object */
try {
// something bad happened, throw an error
throw {
name : "MyErrorType", // custom error type
message : "oops",
extra : "This was rather embarrassing",
remedy : genericErrorHandler // who should handle it
};
} catch ( e ) {