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 fs = require('fs') | |
fs.readFile('./arquivo.txt', (err, dados) => { | |
if (err) throw new Error(err) | |
fs.writeFile('./outroarquivo.txt', dados, (err) => { | |
if (err) throw new Error(err) | |
outraFuncaoAssincrona((err, dados) => { | |
const x = dados.split(',') | |
const y = x.map((e) => e.toUpperCase()) | |
maisUmaFuncaoAssincrona(y, (err, resultado) => { |
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
function readFile (path, callback) { | |
if (!path) throw new Error('Path is required') | |
// Leitura do arquivo de forma assíncrona | |
// Criando err como variável de erros e data como variável com o conteúdo | |
callback(err, dados) | |
} |
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 fs = require('fs') | |
fs.readFile('./arquivo.txt', (err, texto) => { | |
// fazer alguma coisa com o arquivo | |
}) |
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 fs = require('fs') | |
const texto = fs.readFileSync('./arquivo.txt') |
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
#!/bin/bash | |
rm -rf /swapfile | |
sudo fallocate -l 4G /swapfile | |
ls -lh /swapfile | |
sudo chmod 600 /swapfile | |
sudo mkswap /swapfile | |
sudo swapon /swapfile |
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
export function factory (service: ShipService, portService: PortService) { | |
return [ | |
/** | |
* Route handler | |
* ============= | |
*/ | |
rescue(async (req, res) => { | |
const ship = await service.delete(req.params.shipId, req.onBehalfOf) | |
await portService.undockShip(ship, 'Ship was deleted', req.onBehalfOf) |
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
Array.from($('#react-root > section > main > div > header + div + div + div > article > div > div').children).forEach(row => { | |
Array.from(row.children).forEach(async (image) => { | |
try { | |
const photoUrl = image.querySelector('a').getAttribute('href') | |
const response = await fetch(`https://instagram.com${photoUrl}`) | |
const responseText = await response.text() | |
const parser = new DOMParser() | |
const htmlDocument = parser.parseFromString(responseText, 'text/html') | |
const sharedData = JSON.parse(htmlDocument.querySelector('#react-root+script').innerText.replace('window._sharedData = ', '').replace('};', '}')) | |
const picData = sharedData.entry_data.PostPage[0] ? sharedData.entry_data.PostPage[0].graphql.shortcode_media : sharedData.entry_data |
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
console.log = (...items) => { | |
let output = '' | |
for (const item of items) { | |
output += console.inspect[typeof item](item) | |
if (item[Symbol.for('object.upper')]) output.toUpperCase() | |
output += ', ' | |
} | |
process.stdout.write(output + '\n') | |
} | |
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
let obj = { nome: 'Lucas' } | |
obj[Symbol.for('object.upper')] = true | |
console.log(obj) // { NOME: 'LUCAS' } | |
console.log(Object.keys(obj)) // ['NOME'] |
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
let foo = { | |
[Symbol()]: 'foo', | |
[Symbol('foo')]: 'bar', | |
[Symbol.for('bar')]: 'baz', | |
propriedade: 'legal' | |
} | |
console.log(Object.getOwnPropertySymbols(foo)) // [ Symbol(), Symbol(foo), Symbol(bar) ] | |
for (let symbol of Object.getOwnPropertySymbols(foo)) { |