{ This gist will help the ones that are still confused about forking a repository properly.
Well, you might say that this is just an 'easy peasy' stuff for you, but not all are like you.
The purpose for this gist is share some guidance to how properly fork and then how to properly pull
the latest updates from the original repo. I hope this gist can help. }
This file contains 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
for (let i = 1; i < 100; i++) { | |
let res = ''; | |
if (i % 3 === 0) { res += 'Fizz'; } | |
if (i % 5 === 0) { res += 'Buzz'; } | |
if (res === '') { res = i; } | |
console.log(res); | |
} |
This file contains 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
// Your unique variables here | |
const allCapsAlpha = [..."ABCDEFGHIJKLMNOPQRSTUVWXYZ"]; | |
const allLowerAlpha = [..."abcdefghijklmnopqrstuvwxyz"]; | |
const allUniqueChars = [...'~!@#$%^&*()_+`-=[]\\{}|;:\'",./<>?']; | |
const allNumbers = [..."0123456789"]; | |
// This is the 'pattern', alternate the order if you want. | |
// The final output (order of pattern) will not be the same though, | |
// but you can improve this utility to achieve that. | |
const base = [...allCapsAlpha, ...allNumbers, ...allLowerAlpha, ...allUniqueChars]; |
This file contains 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 readline = require('readline'); | |
const rl = readline.createInterface(process.stdin, process.stdout); | |
const aPerson = { | |
name: '', | |
sayings: [] | |
}; | |
// ask a question, then use the callback to use the user's answer | |
rl.question('What is your name? ', (nameAnswer) => { |
This file contains 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 readline = require('readline'); | |
const rl = readline.createInterface(process.stdin, process.stdout); | |
const fs = require('fs'); | |
const aPerson = { | |
name: '', | |
sayings: [] | |
}; | |
// ask a question, then use the callback to use the user's answer |
This file contains 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 EventEmitter = require('events').EventEmitter; | |
const util = require('util'); | |
// constructor function | |
const Person = function(name) { | |
this.name = name; | |
}; | |
// let Person inherit all the EventEmitter features | |
util.inherits(Person, EventEmitter); |
This file contains 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 { createReadStream, createWriteStream} = require('fs'); | |
// You should include a real file live video, image, etc | |
const readStream = createReadStream(__dirname+'/powder-day.mp4'); | |
const writeStream = createWriteStream(__dirname+'/copy.mp4', { highWaterMark: 1628920 }); | |
// => flowing stream | |
readStream.on('data', (chunk) => { | |
// if this will be false, meaning the stream is full | |
const result = writeStream.write(chunk); |
This file contains 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 { createReadStream, createWriteStream } = require('fs'); | |
const readStream = createReadStream(__dirname+'/powder-day.mp4'); | |
const writeStream = createWriteStream(__dirname+'/copy.mp4' ); | |
// Pipe, will handle backpressure automatically | |
readStream | |
.pipe(writeStream) | |
.on('error', console.error); |
This file contains 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 { createWriteStream } = require('fs'); | |
const writeStream = createWriteStream('./file-test.txt'); | |
// using stdin, stream and pipe, this will automatically log all the text you will type | |
process.stdin.pipe(writeStream); | |
process.stdin.on('data', (data) => { | |
if (data.toString().toLowerCase().trim() === 'exit>this') { | |
process.exit(); |
This file contains 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 { promisify } = require('util'); | |
const writeFile = promisify(fs.writeFile); | |
writeFile('sample.txt', 'this is a sample phrase') | |
.then(() => console.log('done!')) | |
.catch(e => console.log(e)); |
OlderNewer