Skip to content

Instantly share code, notes, and snippets.

View gabssnake's full-sized avatar

gabssnake gabssnake

  • Lyon
View GitHub Profile
@gabssnake
gabssnake / SimpleSpy.js
Created October 2, 2015 12:14
Javascript Spy on object method. Keeps the arguments of each call and can be later destroyed
function Spy (object, method) {
var original = object[method];
var spy = {
calls: [],
destroy: function () {
object[method] = original;
}
};
object[method] = function () {
var args = Array.prototype.slice.call(arguments);
wget \
--recursive \
--no-parent \
--page-requisites \
--no-clobber \
--html-extension \
--convert-links \
--restrict-file-names=windows \

Mac OS X 10.10 Yosemite

Custom recipe to get OS X 10.10 Yosemite running from scratch, setup applications and developer environment. I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. On average, I reinstall each computer from scratch every 6 months, and I do not perform upgrades between distros.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your own needs.

Install Software

@gabssnake
gabssnake / __ js placeholder mini polyfill.js
Created September 2, 2014 14:52
placeholder polyfill
// simple placeholder polyfill (requires jQuery)
// http://snippetrepo.com/snippets/html5-placeholder-on-ie8-input-fields
(function($, document){
var test = document.createElement('input');
var polyfill = function () {
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
@gabssnake
gabssnake / css-hex-to-rgba
Last active August 29, 2015 14:03
Convert CSS hex color to rgba() with opacity
// adapted from awesomest http://gist.github.com/lrvick/2080648
var hexToRGB = function ( hex ) {
var r,g,b;
hex = parseInt( hex.replace('#',''), 16 );
r = hex >> 16;
g = hex >> 8 & 0xFF;
b = hex & 0xFF;
return [r,g,b];
};
/**
* jQuery.support.cssProperty
* To verify that a CSS property is supported (or any of its browser-specific implementations)
*
* @param string p - css property name
* [@param] bool rp - optional, if set to true, the css property name will be returned, instead of a boolean support indicator
*
* @Author: Axel Jack Fuchs (Cologne, Germany)
* @Date: 08-29-2010 18:43
*
@gabssnake
gabssnake / .gitconfig
Last active August 29, 2015 13:57
git config file
[core]
excludesfile = ~/.gitignore_global
editor = subl
[color]
ui = auto
diff = auto
status = auto
branch = auto
interactive = auto
grep = always
/*
* // to set options per instance
* $('#elem').classlider({ message: 'Goodbye World!' });
* // to instantiate with simple Javascript
* var instance = new Classlider(
* document.getElementById('elem'),
* { message: 'Goodbye World!' }
* ).init();
@gabssnake
gabssnake / js element is visible in viewport hittest
Created February 5, 2014 11:08
find out if element is within the viewport, thus visible in that sense
// http://ejohn.org/blog/getboundingclientrect-is-awesome/
// http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport/7557433#7557433
function visible_viewport(el, offset) {
var r, html;
offset = typeof offset !== 'undefined' ? offset : 200;
if ( !el || 1 !== el.nodeType ) { return false; }
html = document.documentElement;
r = el.getBoundingClientRect();
return ( !!r && r.bottom >= offset && r.right >= offset && r.top <= (html.clientHeight+offset) && r.left <= (html.clientWidth+offset) );
@gabssnake
gabssnake / js throttle debounce scroll resize
Last active August 29, 2015 13:56
js throttle debounce scroll resize
// throttle - http://ejohn.org/blog/learning-from-twitter/
// be sure to cache selector
var elem = $(".details"),
scrolled = false;
$(window).on('scroll', function() {
scrolled = true;
});
// $(window).on('resize', function() { resized = true; });