Skip to content

Instantly share code, notes, and snippets.

@sillero
sillero / github.css
Created September 17, 2012 17:28 — forked from tuzz/github.css
Github Markdown Stylesheet
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px;
color: #333;
}
@sillero
sillero / toFixed.js
Created October 22, 2012 19:35
javascript - avoiding bugs in .toFixed()
function toFixed(num, dec) {
var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec),
$arr = (result+[]).split('.'),
$int = $arr[0] + '.',
$dec = $arr[1] || '0';
return $int + $dec + (Math.pow(10,(dec - $dec.length))+[]).substr(1);
}
//OR
@sillero
sillero / readme.md
Created October 23, 2012 18:08
LiveReload + Sublime Text 2

#Como funciona? A extensão/addon se conecta ao Sublime e quando qualquer arquivo é salvo lá (independente da localização) o browser faz um refresh.

#Pré-requisitos 0. Sublime Text 2 0. Sublime Package Control

#Instalação 0. Através do Package Control (windows: ctrl+shift+p -> Package Control: Install Package) 0. Reiniciar o Sublime

@sillero
sillero / jquery.nstpubsub.js
Last active October 12, 2015 05:08
jQuery not-so-tiny Pub/Sub
/* jQuery Not-So-Tiny Pub/Sub - v0.4 - 2013-01-15
* http://sillero.github.com/
* Copyright (c) 2012 "sillero" Gustavo Sillero; Licensed MIT, GPL
*
* UPDATE (2013-01-15): now e (event) gets the folowwing properties
* published (eventName used in $.publish)
* subscribed (eventName used in $.subscribe)
*
* usage:
* $.subscribe('/path1', function(e, response){ console.log('path1',response.data); })
@sillero
sillero / Main.sublime-menu
Created November 1, 2012 18:11 — forked from GCheung55/Main.sublime-menu
Sublime Text 2 Layouts
/**
* Sublime Text 2 Layouts
* Place file in or modify file if existing
*
* OSX: /Users/ [USERNAME] /Library/Application Support/Sublime Text 2/Packages/User/
* Windows: C:\Users\ [USERNAME] \…\Sublime Text 2\Packages\User
*
*/
[{
@sillero
sillero / gist:4032637
Created November 7, 2012 16:30
Sublimelinter - remove 'missing radix' warning for parseInt

comment out these lines in jshint.js and jslint.js

if (left.value === "parseInt" && n === 1) {
    warning("Missing radix parameter.", token);
}

that's it :)

@sillero
sillero / compile.js
Created November 14, 2012 19:06
simple javascript {{ Tag }} compiler
$compile = function($template, $scope){
var $mask = /\{\{\s*[\w.]+\s*[^\}\}]\}\}/g,
$matches = $template.match($mask),
$templateScope = [], k;
for (k in $matches) {
var $match = $matches[k].replace(/[\{\}\s]/g,'').split('.');
$templateScope.push($match);
}
for (k in $templateScope) {
var $match = $templateScope[k],
@sillero
sillero / copyobj.js
Created December 4, 2012 15:00
copy object{} function
copyObject = function(o){ return JSON.parse(JSON.stringify(o)); };
@sillero
sillero / sscrollyfix.css
Created December 11, 2012 16:10
dataTables.net - table sScrollY fix for Firefox
.dataTable {
max-width: none; /* sScrollY fix */
}
@sillero
sillero / gist:4345292
Created December 20, 2012 13:20
js console polyfill/ie-protection
(function (con) {
// the dummy function
function dummy() {}
// console methods that may exist
for(var methods = "assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(','), func; func = methods.pop();) {
con[func] = con[func] || dummy;
}
}(window.console = window.console || {}));