Skip to content

Instantly share code, notes, and snippets.

$('iframe:not(:visible)').remove();
urls = ['https://edfuh.com', 'https://google.com']; i = 0;
[].slice.call(frames).forEach(function(f){ console.log(f.location.assign(urls[i++])) })
@edfuh
edfuh / amazon links without referral
Created April 22, 2015 18:54
don't give bloggers money
@edfuh
edfuh / templateloader.js
Created March 11, 2015 01:20
template loader
// The Template Loader. Used to asynchronously load templates located in separate .html files
window.templateLoader = {
load: function(views, callback) {
var deferreds = [];
$.each(views, function(index, view) {
if (window[view]) {
deferreds.push($.get('tpl/' + view + '.html', function(data) {
// Defining the application router, you can attach sub routers here.
var Router = Backbone.Router.extend({
routes: {
"": "index"
},
index: function() {
this.useLayout("main").setViews({
header: new UI.Views.Toolbar()
}).render();
@edfuh
edfuh / easy rgb to hex.js
Created May 28, 2013 17:36
I use this a lot
function rgbToHex (r, g, b) {
return [].slice.apply(arguments).map(function (n) {
return n.toString(16);
}).join('').toUpperCase();
}
@edfuh
edfuh / dumb.js
Created April 19, 2013 17:43
dumb stuff
setInterval( function(){
document.body.style.zoom = ((+document.body.style.zoom || 1) + 0.01)
},1000)
@edfuh
edfuh / gist:5390267
Created April 15, 2013 18:35
dumb dirty way to find if an object key exists in a deep object
keyExists = function(obj, structure) {
var F = function(){};
F.prototype = obj;
var parts = structure.split('.');
var testObj = new F;
for (var i = 0, j = parts.length; i < j; i++) {
if (!testObj[parts[i]]) {
@edfuh
edfuh / timer.js
Created March 9, 2013 23:01
simple countdown timer for some stuff
function Countdown(seconds, update, done) {
this.length = seconds;
this.update = update;
this.done = done;
}
Countdown.prototype.start = function () {
var self = this;
self.update(self.length);
@edfuh
edfuh / filter.js
Created March 17, 2012 00:11
Hacky ass ways to filter backbone collections
Backbone.Collection.extend({
// #sadface
// collection.sadFilter().invoke('save') <- TypeError
sadFilter : function (m) {
return this.filter(function (m) {
return m.get('happiness') < 1
})
},
// First option
// Wrap in underscore object
@edfuh
edfuh / js.TMsyntax
Created March 15, 2012 01:30
TextMate JS syntax file
{ scopeName = 'source.js';
comment = 'JavaScript Syntax: version 2.0';
fileTypes = ( 'js', 'htc', 'jsx' );
foldingStartMarker = '^.*\bfunction\s*(\w+\s*)?\([^\)]*\)(\s*\{[^\}]*)?\s*$';
foldingStopMarker = '^\s*\}';
patterns = (
{ name = 'meta.class.js';
comment = 'match stuff like: Sound.prototype = { É } when extending an object';
match = '([a-zA-Z_?.$][\w?.$]*)\.(prototype)\s*(=)\s*';
captures = {