I hereby claim:
- I am luqih on github.
- I am lucasjanon (https://keybase.io/lucasjanon) on keybase.
- I have a public key whose fingerprint is 136F 8334 AF90 55DD 3513 6A0F 910C D2A6 3691 CAA4
To claim this, I am signing this object:
{"lastUpload":"2022-02-27T01:58:56.837Z","extensionVersion":"v3.4.3"} |
#!/usr/bin/env node | |
const fs = require('fs') | |
if (!process.argv[2]) { | |
console.log('File path needed') | |
process.exit() | |
} | |
const rx = /import (.*?) from '@material-ui\/(.*?)\/(.*?)';/ |
# rar | |
export PATH="/Applications/rar:${PATH}" | |
# shortcuts to folders | |
alias dt='cd /Users/lucasjanon/Desktop' | |
alias rt='cd ~/' | |
alias docs='cd /Users/lucasjanon/Documents' | |
alias shortcuts='cat ~/.bash_profile' | |
# command shortcuts |
const numberAsUsd = price => price.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,'); // numberAsUsd(1000) === 1,000 | |
const usdToArs = price => price.replace(/[,.]/g, x => (x === ',' ? '.' : ',')); // usdToArs(1,000) === 1.000 | |
const deleteZerosAfterComma = price => price.replace(',00', ''); // deleteZerosAfterComma(1.000,00) === 1.000 | |
export const numberAsArs = price => `$ ${deleteZerosAfterComma(usdToArs(numberAsUsd(price)))}`; // numberAsArs(1000) === '$ 1.000' |
{"lastUpload":"2020-04-04T18:58:21.162Z","extensionVersion":"v3.4.3"} |
/** | |
* The logic is the following: first call: no parents, then the node can have any value | |
* then it goes down recursively on both left and right nodes, checking that left.value < node.value & right.value > node.value | |
* but the magic is the following, and it's where most algorithms fail (or use much more computation than this one): | |
* in the recursive call involving the left node, the algorithm sets a maximum value to subsequent recursive calls, so when the left node | |
* calls validateTree on its right node, that right node is forced to not just being higher than its parent but also | |
* being lower than the parent of its parent, because remember that a binary search tree can't have any direct or indirect higher value | |
* on its left. The same logic is applied to its right, but of course with a minimum value. | |
*/ | |
const validateTree = (node, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER) => { |
class MinHeap { | |
constructor ({ items } = {}) { | |
this.heap = items ? [...items] : [] | |
this.length = this.heap.length | |
} | |
get () { | |
return this.heap | |
} |
I hereby claim:
To claim this, I am signing this object:
const arr = [9, 90, 95, 99, 50, 5, 56, 504, 5006, 544, 1] | |
const highestCombination = (a) => { | |
const grouped = a.reduce( | |
(acc, c) => { | |
const cInitial = `${c}`.split('')[0] | |
acc[cInitial] ? | |
acc[cInitial].items.push(c) | |
: | |
acc[cInitial] = { items: [c], longest: 0 } |
// Adds a .catch to the express callback to handle errors that happen in async/await functions | |
// you should wrap every route with this handler | |
// ie: errorHandler((req, res) => res.send(JSON.stringify(res.locals.user))) | |
const errorHandler = fn => (req, res, next) => { | |
Promise.resolve(fn(req, res, next)) | |
.catch(error => { | |
if (process.NODE_ENV === 'development') console.log(require('util').inspect(error)) | |
next(error) | |
}) | |
} |