Skip to content

Instantly share code, notes, and snippets.

View Trott's full-sized avatar

Rich Trott Trott

View GitHub Profile
@Trott
Trott / rebase.md
Created May 27, 2022 22:52
Rebasing away merge conflicts
$ git fetch upstream
$ git fetch origin
$ git checkout feature-branch
$ git rebase origin/feature-branch
$ git rebase upstream/main

Oh noes! A merge conflict appears here!

'use strict'
const { parentPort, workerData } = require('worker_threads')
const individualTrack = require('music-routes-data/data/individual_track.json')
const tracks = []
const individuals = []
const { id, index } = workerData
// Use Node.js 11.7.0 or newer to avoid having to use --experimental-workers flag
'use strict'
const { Worker } = require('worker_threads')
const individualTrack = require('music-routes-data/data/individual_track.json')
const tracks = [[], []]
const individuals = [[], []]
'use strict'
const individualTrack = require('music-routes-data/data/individual_track.json')
const tracks1 = []
const tracks2 = []
const individuals1 = []
const individuals2 = []
const allIndividuals = require('music-routes-data/data/individuals.json')
@Trott
Trott / test.js
Created January 14, 2019 04:29
Only assigns available ports
// Testing for macOS, which supplies available ports sequentially.
var net = require('net');
createServer(0, function () {
var port = this.address().port;
console.log('server was assigned port ' + port);
createServer(port+1, function () {
var port = this.address().port;
console.log('server was assigned port ' + port);
'use strict';
const { Worker, isMainThread, parentPort, workerData } = require('worker_threads');
const min = 2;
let primes = [];
function generatePrimes(start, range) {
let isPrime = true;
let end = start + range;
for (let i = start; i < end; i++) {
for (let j = min; j < Math.sqrt(end); j++) {
if (i !== j && i%j === 0) {
'use strict';
const min = 2;
const max = 1e7;
const primes = [];
function generatePrimes(start, range) {
let isPrime = true;
let end = start + range;
for (let i = start; i < end; i++) {
for (let j = min; j < Math.sqrt(end); j++) {
if (i !== j && i%j === 0) {
const { Worker, isMainThread, parentPort } = require('worker_threads');
if (isMainThread) {
// This code is executed in the main thread and not in the worker.
// Create the worker.
const worker = new Worker(__filename);
// Listen for messages from the worker and print them.
worker.on('message', (msg) => { console.log(msg); });
} else {
// This code is executed in the worker and not in the main thread.
$ nvm use 8.11.3
Now using node v8.11.3 (npm v5.6.0)
$ node
> path.win32.resolve('D:\\work\repl', '/SOME_SOMEELSE_2018-10-11T00-37-36.html') 
'D:\\SOME_SOMEELSE_2018-10-11T00-37-36.html'
> path.win32.resolve('D:\\work\\repl', 'SOME_SOMEELSE_2018-10-11T00-37-36.html') 
'D:\\work\\repl\\SOME_SOMEELSE_2018-10-11T00-37-36.html'
> 
@Trott
Trott / diff.txt
Created November 17, 2017 07:15
Node.fz vs. nodejs master conflicts
diff --cc .gitignore
index 5951901b65,3d6b7a51a3..0000000000
--- a/.gitignore
+++ b/.gitignore
@@@ -1,20 -1,4 +1,24 @@@
++<<<<<<< HEAD
+# Whitelist dotfiles
+.*
+!deps/**/.*
+!test/fixtures/**/.*