- GitHub Staff
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
// This code snippet aims to demonstrate the difference between Node 10 and Node 12 Array.sort implementations. | |
// The result is guaranteed to be sorted. | |
// However, the order is not guaranteed. | |
// For better understanding see v8 array-sort blog post https://v8.dev/blog/array-sort. | |
// Related discussion in node repo https://github.com/nodejs/node/issues/24294. | |
// Below we have multiple members with the same `num` values. | |
// The `title` properties are here for visibility, they're not used for sorting. | |
// In Node 12 we receive known pangrams in the sorted result. |
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
var buffer = Buffer.from('something') | |
console.log('buffer.__proto__') | |
console.log(buffer.__proto__) | |
console.log() | |
console.log('buffer instanceof Buffer') | |
console.log(buffer instanceof Buffer) | |
console.log() |
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 waitFor = (ms) => new Promise(r => setTimeout(r, ms)); | |
const startSequential = async () => { | |
for (const num of [3, 2, 1]) { | |
await waitFor(1000 * num); | |
console.log(num + ' ' + new Date().toISOString()); | |
} | |
console.log('Done Sequential'); | |
} |
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
brew install v8-315 | |
gem install libv8 -v '3.16.14.19' -- --with-system-v8 | |
gem install therubyracer -v '0.12.3' -- --with-v8-dir=/usr/local/opt/[email protected] | |
bundle install |
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
#!/bin/sh | |
# Replaces tilda with left shift (literally making left shift button "longer") | |
# Replaces paragraph with tilda (so your tilda is in top left corner under escape now) | |
hidutil property --set '{"UserKeyMapping":[ | |
{"HIDKeyboardModifierMappingSrc":0x700000035,"HIDKeyboardModifierMappingDst":0x7000000E1}, | |
{"HIDKeyboardModifierMappingSrc":0x700000064,"HIDKeyboardModifierMappingDst":0x700000035} | |
]}' |
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
"ban": [ | |
true, | |
[ "angular", "each", "Don't rely on angular to perform loops. Either use a 'for of' loop or the native 'array.forEach': https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_each" ], | |
[ "jQuery", "each", "Don't rely on jQuery to perform loops. Either use a 'for of' loop or the native 'array.forEach': https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_each" ], | |
[ "$", "each", "Don't rely on jQuery to perform loops. Either use a 'for of' loop or the native 'array.forEach': https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_each" ], | |
[ "_", "each", "Don't rely on Underscore to perform loops. Either use a 'for of' loop or the native 'array.forEach': https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_each" ], | |
[ "_", "forEach", "Don't rely on Underscore to perform loops. Either use a 'for of' loop or the native 'array.forEach': https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_ |
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
// Takes an URL and object to pass to the server. | |
// Sends to the server. The server can respond with binary data to download. | |
jQuery.download = function(url, object) { | |
// Build a form | |
var form = $('<form></form>').attr('action', url).attr('method', 'post'); | |
var keyValuePairs = jQuery.param(object).split('&').map(function(x) { | |
var splitted = x.split('='); | |
return { | |
key: decodeURIComponent(splitted[0]), |
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
var flies = [ | |
{ | |
legs: 4, | |
wings: 2 | |
}, | |
{ | |
legs: 6, | |
wings: 4 | |
} | |
]; |