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
| const getLog2 = (n) => Math.round(Math.log2(n)) | |
| const reverseSeq = (n) => Array.from(Array(n + 1).keys()).reverse() | |
| const getPow = (b, n) => Math.pow(b, n) | |
| const decToBin = (n) => { | |
| reverseSeq(getLog2(n)).reduce( | |
| (acc, curr) => (getPow(2, curr) <= n) ? ( n -= getPow(2, curr), acc + '1' ) : acc + '0', '' | |
| ) |
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
| const createScript = (path, version) => { | |
| const scriptTag = document.createElement('script') | |
| scriptTag.src = path + '?v=' + version | |
| scriptTag.type = 'text/javascript' | |
| document.head.appendChild(scriptTag) | |
| } | |
| const createStyle = (path, version) => { |
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
| const assert = require('assert') | |
| , crypto = require('crypto') | |
| class HKDFBufferGenerator { | |
| constructor(alg, ikm, info, salt, size) { | |
| this._alg = alg | |
| this._ikm = ikm | |
| this._info = info | |
| this._salt = salt | |
| this._size = size |
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
| // entrada | |
| [ | |
| { | |
| "nome_ponto": "ponto A", | |
| "nome_parametro": "parametro X" | |
| }, | |
| { | |
| "nome_ponto": "ponto B", | |
| "nome_parametro": "parametro Y" | |
| }, |
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
| const asn1 = require('asn1.js') | |
| , BN = require('bn.js') | |
| , crypto = require('crypto') | |
| const privKey = '{' + | |
| '"version": "0",' + | |
| '"modulus": "259154769957187194386805172792520197599479908823949686364408864499' + | |
| '94962945058195024520647063684248740786360017811823364689336100960942063494732020' + | |
| '91812725346950176505638890859938367164068105119839615900697880416966060139081266' + | |
| '35977887948210779573734140292700996701877639405960971827664641117294919785640103' + |
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
| // capKey vem de uma iteração em um objeto | |
| $('#div' + capKey).find('input') | |
| .keydown(e => { | |
| const key = e.key | |
| , arrKeys = [ | |
| 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowUp','Backspace', | |
| 'Control', 'Delete', 'End', 'Home', 'Tab' | |
| ] | |
| , input = $(e.currentTarget) |
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
| /* Smartphones (portrait and landscape) ----------- */ | |
| @media only screen and (min-device-width: 320px) and (max-device-width: 480px) { | |
| /* Styles */ | |
| } | |
| /* Smartphones (landscape) ----------- */ | |
| @media only screen and (min-width: 321px) { | |
| /* Styles */ | |
| } |
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
| const arrStr = 'a.b.c.d'.split('.') | |
| const res = arrStr.reduce((acc, curr, i, j) => { | |
| acc.push({ [`${curr}`]: {} }) | |
| return acc | |
| }, []).reduce((acc, curr, i, arr) => { | |
| acc = arr[0] | |
| if(i < arr.length) { |
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
| const arr = [{ price: 10, qtd: 2}, { price: 20, qtd: 1}] | |
| , res = arr.reduce((acc, curr) => { acc.price = (acc.price || 0) + curr.price * curr.qtd; acc.qtd = (acc.qtd || 0) + curr.qtd; return acc }, {}) | |
| console.log(res) |
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
| const groupBy = (xs, key) => xs.reduce((rv, x) => { | |
| (rv[x[key]] = rv[x[key]] || []).push(x); | |
| return rv; | |
| }, {}); |
OlderNewer