Skip to content

Instantly share code, notes, and snippets.

View glauberramos's full-sized avatar

Glauber Ramos glauberramos

View GitHub Profile
setInterval([].forEach.bind($$("*"),function(a){a.style.outline="5px solid #"+(~~(Math.random()*(1<<24))).toString(16) }, 5), 10)
@glauberramos
glauberramos / doors.js
Created May 30, 2012 14:34
3 Doors (One with a reward) problem
var doors = [false, false ,true];
var didntChangeDoorCount = 0;
var changedDoorCount = 0;
for(i=0;i<10000;i++) {
var picker = Math.floor(Math.random()*3);
//dont change
if(doors[picker]) didntChangeDoorCount++;
@glauberramos
glauberramos / api.js
Created October 5, 2015 18:17
Github api
$.ajax({
method: 'GET',
url: 'https://api.github.com/repos/servicosgovbr/cartas-de-servico/contents/cartas-servico/v3/servicos'
}).then(function(data) {
var servicos = data;
});
var http = require('http');
var server = http.createServer(function (request, response) {
function funcOne(input) {
var request = require('request');
request.get('http://estruturaorganizacional.dados.gov.br/id/unidade-organizacional/1930',
{json: true, body: input},
function(err, res, body) {
if (!err && res.statusCode === 200) {
console.log(err);
@glauberramos
glauberramos / bad.js
Created July 19, 2012 02:33
Bad javascript code - Example for blog post - Identation
//this function represents a book from an online library
//it has 3 methods to search the book, remove a specific word and change it
//it has 4 attributes, name, author, date and content
//creates libaries stuffz
function elementliBRaryContent(a,b,c,d) {
var bnam = a;
var baut = b;
var bdat = c;
var bcont = d;
@glauberramos
glauberramos / bad.js
Created July 19, 2012 02:41
Bad javascript code - Example for blog post - Concise Comments
function book(name,author,content,date) {
var name = name;
var author = author;
var content = content;
var date = date;
var self = {
findWord: function(word) {
return content.indexOf(word)>=0;
},
@glauberramos
glauberramos / bad.js
Created July 19, 2012 03:17
Bad javascript code - Example for blog post - Remove Unuseful Code
function book(name, author, content, date) {
var name = name,
author = author,
content = content,
date = date;
var self = {
containsWord: function(word) {
return content.indexOf(word) >= 0;
},
@glauberramos
glauberramos / bad.js
Created July 19, 2012 02:37
Bad javascript code - Example for blog post - Meanful and Concise Variables/Methods Names
//this function represents a book from an online library
//it has 3 methods to search the book, remove a specific word and change it
//it has 4 attributes, name, author, date and content
//creates libaries stuffz
function book(name,author,content,date) {
var name = name;
var author = author;
var content = content;
var date = date;
@glauberramos
glauberramos / bad.js
Created July 19, 2012 02:44
Bad javascript code - Example for blog post - White Spaces
function book(name, author, content, date) {
var name = name;
var author = author;
var content = content;
var date = date;
var self = {
findWord: function(word) {
return content.indexOf(word) >= 0;
},
@glauberramos
glauberramos / bad.js
Created July 19, 2012 03:03
Bad javascript code - Example for blog post - DRY
function book(name, author, content, date) {
var name = name;
var author = author;
var content = content;
var date = date;
var self = {
containsWord: function(word) {
return content.indexOf(word) >= 0;
},