Skip to content

Instantly share code, notes, and snippets.

View felquis's full-sized avatar
🔎
aligning divs with style

Felquis G felquis

🔎
aligning divs with style
View GitHub Profile
@felquis
felquis / globals.get.js
Last active July 11, 2017 11:23
Find global variables in the browser, discover global variables a web side is exposing in JavaScript
/*
Usage
global.get() // return Array of globals found
*/
;(function (global) {
function Globals () {}
@felquis
felquis / average.js
Created June 17, 2017 01:55
Take the average number of a x list of numbers in a sequence
export default function average (limit) {
let list = []
let current = 0
return (x) => {
list = [...list, x]
if (list.length < limit) return current
current = list.reduce((acc, x, index) => {
@felquis
felquis / estimate-reading-time.js
Last active March 18, 2017 06:15
How much time would I take to read a web page?
// output is in minutes
document.body.innerText.split(' ')
.filter((split) => split.length > 1)
.map((split) => split.replace(/[^a-zZ-a]+/g, ''))
.filter((split) => split.length > 1)
.reduce((acc, split) => {
const time = split.split('').length * 115
return [...acc, (time > 500) ? time : 500]
}, [])
.reduce((acc, time) => ([acc[0] + time]), [0])
fetch('https://api.pagar.me/1/zipcodes/86900000', { method: 'get' })
.then(response => response.json())
.then(console.log)
@felquis
felquis / index.js
Last active February 15, 2017 00:58
const cep = require(‘cep-promise’)
cep(‘86900000’).then(console.log)
@felquis
felquis / index.js
Last active January 21, 2017 11:01
Promise chain mutating Object with setTimeout, + fixing with R.merge
// Test 1, what will be displayed in the logs?
Promise.resolve()
.then(() => {
const car = {
color: 'Green'
}
setTimeout(() => {
car.color = 'Orange'
}, 0)
@felquis
felquis / data.js
Last active July 12, 2016 21:08
How many times a word in bold is mentioned in the AngularJS CHANGELOG?
(function () {
'use strict'
window.data = `<a name="1.5.7"></a># 1.5.7 hexagonal-circumvolution (2016-06-15)## Bug Fixes- **$compile:** - don't add merged attributes twice to $attrs ([ebbaa4ac](https://github.com/angular/angular.js/commit/ebbaa4ac5e3559df9267203438a0bb18c2d3b7d8), [#8159](https://github.com/angular/angular.js/issues/8159), [#14737](https://github.com/angular/angular.js/issues/14737)) - cope with $onChanges hooks throwing ([3749c858](https://github.com/angular/angular.js/commit/3749c85829406ca57cc5729e80696c7f34134068), [#14444](https://github.com/angular/angular.js/issues/14444), [#14463](https://github.com/angular/angular.js/issues/14463))- **$parse:** allow arguments to contain filter chains ([cc6dcb4b](https://github.com/angular/angular.js/commit/cc6dcb4bc28aadff4f62d76d6451b0f80b928e69), [#4175](https://github.com/angular/angular.js/issues/4175), [#4168](https://github.com/angular/angular.js/issues/4168), [#14720](https://github.com/angular/angular.js/issues/14720))- **$ro
@felquis
felquis / minimal-css-reset.css
Last active April 17, 2016 14:13 — forked from gpessia/minimal-css-reset.css
Minimal CSS Reset, resets margins, paddings and line-heights of every element needed, please adjust the selector below if you need paddings in lists
/**
Minimal CSS Reset
reset margins, paddings and line-heights of every element needed
if you need paddings into li, dl, dd elements, just remove them
from the selector below
Felquis Gimenes
MIT Licence
https://gist.github.com/felquis/1278d5f62dcc5f606bbb
@felquis
felquis / gist:1261abef589af89f1114
Created March 11, 2016 17:19
Truly Global Unique Identifier generator for Web Apps using Crypto API, with fallback to pseudo random numbers Math.random
/*
Cria um Globally Unique Identifier randomico
para uso junto ao Google Measurement Protocol
A discussão sobre isso é grande e eu cansei de ler
o lance é o seguinte, usamos `window.crypto` quando disponível
quando não disponível (browsers antigos) usamos o Math.random
que não é la grandes coisas, mas mesmo assim já é TOP!
Resposta no Stackoverflow http://stackoverflow.com/a/8472700/2588556
+ minhas adaptações
@felquis
felquis / user-agents.md
Last active January 28, 2016 13:33
User Agents

Windows Phone Lumia 640

Internet Explorer

Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; Microsoft; RM-1109) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537