Skip to content

Instantly share code, notes, and snippets.

View forgive me
$('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 Apr 22, 2015
don't give bloggers money
View amazon links without referral
View templateloader.js
// 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) {
View useLayout.js
// 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();
View easy rgb to hex.js
function rgbToHex (r, g, b) {
return [].slice.apply(arguments).map(function (n) {
return n.toString(16);
}).join('').toUpperCase();
}
View dumb.js
setInterval( function(){
document.body.style.zoom = ((+document.body.style.zoom || 1) + 0.01)
},1000)
@edfuh
edfuh / gist:5390267
Created Apr 15, 2013
dumb dirty way to find if an object key exists in a deep object
View gist:5390267
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 Mar 9, 2013
simple countdown timer for some stuff
View timer.js
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 Mar 17, 2012
Hacky ass ways to filter backbone collections
View filter.js
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 Mar 15, 2012
TextMate JS syntax file
View js.TMsyntax
{ 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 = {