Skip to content

Instantly share code, notes, and snippets.

View geedew's full-sized avatar

Drew geedew

View GitHub Profile
@geedew
geedew / js-frame-bust
Created February 20, 2014 15:46
Javascript Frame Busting
if(top != self) {
top.onbeforeunload = function() {};
top.location.replace(self.location.href);
}
@geedew
geedew / dw-js-frame-bust
Created February 20, 2014 15:47
David Walsh's Frame Busting
if (top.location != self.location) {
top.location = self.location.href;
}
@geedew
geedew / designer.html
Created June 20, 2014 02:18
designer
<link rel="import" href="../components/polymer/polymer.html">
<polymer-element name="ss-message">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
@geedew
geedew / html4-change-input.html
Last active August 29, 2015 14:13
HTML Change/KeyUp events vs Input event
<!-- index.html -->
<input id='abc'/>
<script>
var input = document.getElementById('abc');
input.addEventListener('change', function(event) {
// .. only triggers on input loss of focus
});
input.addEventListener('keyup', function(event) {
// .. triggers on any keyboard interaction
@geedew
geedew / strip.string.js
Last active August 29, 2015 14:15
JavaScript String.Strip
var strip = function(string, characters) {
if(!characters) {
if(typeof String.prototype.trim !== undefined) {
// Simply use the String.trim as a default
return String.prototype.trim.call(string);
} else {
// set characters to whitespaces
characters = "\s\uFEFF\xA0";
}
}
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<!-- Online here: http://ejohn.org/files/bugs/isObjectLiteral/ -->
<title>isObjectLiteral</title>
<style>
li { background: green; } li.FAIL { background: red; }
iframe { display: none; }
</style>
@geedew
geedew / rAF.js
Created September 5, 2013 02:20 — forked from paulirish/rAF.js
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@geedew
geedew / broken.js
Last active December 26, 2015 13:29
Test Code
;(function(win, undefined) {
var applicationName = "My Broken App";
libs = { one : 'jQuery', two : 'Underscore', three : 'Backbone' };
BioSync.Common.loadLibs = function( libraries ) {
"use strict";
var e = 0, r;
BioSync.Common.applicationName = applicationName;
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Updated: 2010/12/05
// License: MIT
//
// Copyright (c) 2010-2013 Diego Perini (http://www.iport.it)
//
// Permission is hereby granted, free of charge, to any person
var fs = require('fs');
var rmdirAsync = function(path, callback) {
fs.readdir(path, function(err, files) {
if(err) {
// Pass the error on to callback
callback(err, []);
return;
}
var wait = files.length,
count = 0,