Evangelista de tecnologias FrontEnd, foco em Javascript (Node.Js e browser apps).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*jshint forin:true, eqeqeq:true*/ | |
jQuery.getScript('js/libs/yepnope.js', function($) { | |
var scripts = { | |
listaPalestras : function() { | |
var listP = jQuery('#listaPalestras'); | |
if ( !listP.length ) { | |
return; | |
} | |
jQuery.getJSON('js/frontinrio.json', function(data) { | |
var items = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*jshint browser: true, curly: true, eqeqeq: true, forin: true, immed: true, noempty: true, white: true */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tips for jQuery Mobile Bug Patching | |
# There are some assumptions made here, one being that you're | |
# set up with some form of "localhost" http server and that it's running. | |
# - http://www.mamp.info/en/mamp/ | |
# - sudo apt-get install apache | |
# Get it running: | |
# On Mac: | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Song = Backbone.Model.extend({ | |
defaults: { | |
name: "Not specified", | |
artist: "Not specified" | |
}, | |
initialize: function() { | |
console.log("Music is the answer"); | |
} | |
}), Album = Backbone.Collection.extend({ | |
model: Song |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var konami = {}; | |
konami.keys = []; | |
konami.string = '38,38,40,40,37,39,37,39,66,65'; | |
konami.check = function(e) { | |
konami.keys.push(e.keyCode); | |
// no memory abuses | |
if (konami.keys.length > 10) { | |
konami.keys.shift(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Primeiro instanciou uma array com 3 elementos: [1, 2, 3] | |
var b = [1, 2, 3]; | |
console.log(b); // => [1, 2, 3] | |
console.log(b.length); // => 3 | |
//depois adicionou um valor (4) pra chave 1000 da array. | |
b[1000] = 4; | |
// Inclusive isso ficou claro quando viu o log: o valor | |
// na chave 0 é 1, na chave 1 é 2, na chave 2 é 3. |
Original em: http://leobalter.net/cases/escrever-ruby-de-uma-forma-melhor-com-tipagem-ou-codigo-mais-bonito/
Depois das ideias super bacanas que a comunidade Ruby trouxe, de fomentar o CoffeScript para escrever um “JavaScript” mais bonito, ou da Google de fazer o Dart para escrever um JavaScript “tipado”, resolvi também trabalhar em algo que deixaria o Ruby perfeito.
Puby e Juby! São dois projetos distintos mas com propósitos excelentes:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.serializeObject = function() | |
{ | |
var o = {}; | |
var a = this.serializeArray(); | |
$.each(a, function() { | |
if (o[this.name] !== undefined) { | |
if (!o[this.name].push) { | |
o[this.name] = [o[this.name]]; | |
} | |
o[this.name].push(this.value || ''); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.time('prof 1'); | |
var i = 0; | |
var str = ''; | |
while (i < 1000000) { | |
str += (i & 1); | |
i++; | |
} | |
console.log(str); | |
console.timeEnd('prof 1'); |