Skip to content

Instantly share code, notes, and snippets.

View manobi's full-sized avatar

Gabriel de Oliveira Barbosa manobi

View GitHub Profile
/**
* usage
* DIR='public/js' node directory-size.js
* => "size of public/js is: 12,432
*/
var fs = require('fs'),
_ = require('./underscore'); // requires underscore for _.flatten()
function format(n) {
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/pt_BR/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<script>
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){
js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}
}(document,"script","twitter-wjs");
</script>
require(["helper/util"], function(util) {
//This function is called when scripts/helper/util.js is loaded.
//If util.js calls define(), then this function is not fired until
//util's dependencies have loaded, and the util argument will hold
//the module value for "helper/util".
});
<script id="adlayerScript" async="true" src="//api.adlayerjavascriptsdk.com/page.min.js?page=82e719877b60e205471a9d8ef00564ab&site=82e719877b60e205471a9d8ef0055af6" language="javascript" type="text/javascript" ></script>
@manobi
manobi / bulk_delete.js
Created March 8, 2014 04:10
Bulk delete with cradle
var docs = [
{ _id: 'a82e5e9a093b197960f69dfa17005132',
_rev: '1-70aa8fe77bbe596bded4a9de3aa185e4'
},
{ _id: 'a82e5e9a093b197960f69dfa1700534e',
_rev: '1-70aa8fe77bbe596bded4a9de3aa185e4'
}
]
docs = docs.map(function(doc){
@manobi
manobi / dogs-api.spec.js
Created September 20, 2018 00:21
Pollyjs do not persist nor intercept anything
const {expect} = require('chai');
const fetch = require('node-fetch');
const Polly = require('@pollyjs/core').Polly;
const FetchAdapter = require('@pollyjs/adapter-fetch');
const FSPersister = require('@pollyjs/persister-fs');
global.fetch = fetch;
global.Request = fetch.Request;
global.Response = fetch.Response;
@manobi
manobi / pokedexscript.js
Last active November 27, 2018 02:01
pokedexscript
var modal = document.getElementById('myModal');
var btn = document.getElementById("myBtn");
var span = document.getElementsByClassName("close")[0];
btn.onclick = function () {
modal.style.display = "block";
}
span.onclick = function () {
modal.style.display = "none";
}
window.onclick = function (event) {
@manobi
manobi / auth-0-webtask-io.js
Created February 19, 2019 17:41
FaaS comparison
//https://webtask.io/docs/model
module.exports = function(cb) {
cb(null, { i_am: 'done '});
}
@manobi
manobi / small-enought.js
Created February 18, 2020 02:21
pure smallEnought version
/**
* pure smallEnought version
* @param {array} a
* @param {number} limit
*/
const smallEnought = ([head, ...tail], limit) => (!head && !tail.length) || ((head > limit) ? false : smallEnought(tail, limit))