I hereby claim:
- I am nelsonfncosta on github.
- I am nelson_costa (https://keybase.io/nelson_costa) on keybase.
- I have a public key ASCr9rX-RNCh2Pw_V_vXunwBuOFpm-mdxcBqihAB0eznwQo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
function Container(param) { | |
let secret = 3; | |
let that = this; | |
this.member = param; | |
function dec() { | |
if (secret > 0) { | |
secret -= 1; | |
return true; | |
} else { |
function Container(param) { | |
let secret = 3; | |
let that = this; | |
this.member = param; | |
function dec() { | |
if (secret > 0) { | |
secret -= 1; | |
return true; | |
} else { |
#!/bin/sh | |
# | |
# Automatically adds issue number (optional) and ticket number based on branch name or | |
# description to every commit message. | |
# | |
# Copy this file to .git/hooks under your local repository directory | |
# PS: If you're on linux you may need to change "sed -En" to "sed -rn" | |
# | |
# Example: | |
# |
function logItem() { | |
console.log(Array.from(arguments).join("\t")) | |
} | |
function numDuplicates(name, price, weight) { | |
const uniqueItems = new Set() | |
name.forEach( | |
(item, index) => { | |
const itemPrice = price[index] |
function readFile(file: File | null) { | |
const reader = new FileReader(); | |
reader.addEventListener("load", (event) => { | |
const result = event.target.result; | |
console.log(result); | |
}); | |
reader.addEventListener("progress", (event) => { |
function findCustomerCity(name) { | |
const texasCustomers = ['John', 'Ludwig', 'Kate']; | |
const californiaCustomers = ['Wade', 'Lucie','Kylie']; | |
return texasCustomers.includes(name) ? 'Texas' : | |
californiaCustomers.includes(name) ? 'California' : 'Unknown'; | |
}; | |
// For every call, memory is unnecessarily re-allocated to the variables texasCustometrs and californiaCustomers . |
// Longhand | |
switch (data) { | |
case 'a': | |
test1(); | |
break; | |
case 'b': | |
test2(); | |
break; |
function streamToString (stream) { | |
const chunks = [] | |
return new Promise((resolve, reject) => { | |
stream.on('data', (chunk) => chunks.push(Buffer.from(chunk))) | |
stream.on('error', (err) => reject(err)) | |
stream.on('end', () => resolve(Buffer.concat(chunks).toString('utf8'))) | |
}) | |
} |
function arrayBufferToString (buffer, encoding = 'UTF-8', callback = console.log) { | |
const blob = new Blob([buffer], { type: 'text/plain' }) | |
const reader = new FileReader() | |
reader.onload = evt => callback(evt.target.result) | |
reader.readAsText(blob, encoding) | |
} |