Skip to content

Instantly share code, notes, and snippets.

/**
* Use listenTo/stopListening from Backbone.js with any DOM element
*
* Example:
*
* view.listenTo(asEvents(window), "resize", handler);
*
* and the listener will be remove automatically on view.remove() or
* view.stoplistening()
*
{
"binary_file_patterns":
[
"*.jpg",
"*.jpeg",
"*.png",
"*.gif",
"*.ttf",
"*.tga",
"*.dds",
%clearfix {
&:before,
&:after {
content: "";
display: table;
}
&:after {
clear: both;
}
}
@esouto
esouto / observe.js
Created April 17, 2013 03:49
js: observe
//Observe input events
// Do your stuff after 1 seconds of last user input
$('.observe').live('input keyup', function () {
var $this = $(this);
var delay = 500; // 0.5 seconds delay after last input
clearTimeout($this.data('timer'));
$this.data('timer', setTimeout(function () {
$this.removeData('timer');
// Do your stuff after 0.5 seconds of last user input
/**
* Based conceptually on the _.extend() function in underscore.js ( see http://documentcloud.github.com/underscore/#extend for more details )
* Copyright (C) 2012 Kurt Milam - http://xioup.com | Source: https://gist.github.com/1868955
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
**/
@esouto
esouto / HtmlFull.sublime-snippet
Created February 25, 2013 16:32
snippet html: Html Full
<snippet>
<content><![CDATA[
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">
<link rel="shortcut icon" href="/favicon.ico">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<link rel="stylesheet" href="style.css">
@esouto
esouto / ConsoleLog.sublime-snippet
Created February 25, 2013 16:16
snippet js: console log
<snippet>
<content><![CDATA[
console.log("${1:message}");
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>log</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.js</scope>
</snippet>
@esouto
esouto / gist:5004140
Created February 21, 2013 11:33
js: two columns same height
var highestCol = Math.max($('#element1').height(),$('#element2').height());
$('.elements').height(highestCol);
@esouto
esouto / cssreset-min.css
Created February 20, 2013 13:25
css: YUI 3.8.1 cssreset-min.css
/* YUI 3.8.1 (build 5795) Copyright 2013 Yahoo! Inc. http://yuilibrary.com/license/ */
html{color:#000;background:#FFF}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0}table{border-collapse:collapse;border-spacing:0}fieldset,img{border:0}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal}ol,ul{list-style:none}caption,th{text-align:left}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal}q:before,q:after{content:''}abbr,acronym{border:0;font-variant:normal}sup{vertical-align:text-top}sub{vertical-align:text-bottom}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit}input,textarea,select{*font-size:100%}legend{color:#000}#yui3-css-stamp.cssreset{display:none}
@esouto
esouto / gist:4979809
Created February 18, 2013 19:10
js: jQuery PubSub
(function($) {
var o = $( {} );
$.each({
on: "submit",
trigger: "publish",
off: "unsibscribe"
}, function(key, api) {
$[api] = function() {
o[key].apply( o, arguments );