Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View gordey4doronin's full-sized avatar

Gordey Doronin gordey4doronin

  • GitHub Staff
  • Munich, Germany
  • 15:26 (UTC +02:00)
View GitHub Profile
@gordey4doronin
gordey4doronin / node10-vs-node12-array-sort.js
Created May 3, 2021 09:14
This code snippet aims to demonstrate the difference between Node 10 and Node 12 Array.sort implementations.
// 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.
@gordey4doronin
gordey4doronin / javascript-prototypes.js
Created August 25, 2020 09:09
Check the prototype of an object in JavaScript
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()
@gordey4doronin
gordey4doronin / concurrency-example.js
Last active August 26, 2020 05:39
Sequential async/await VS concurrent Promise.all
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');
}
@gordey4doronin
gordey4doronin / fix-libv8-mac.txt
Last active November 12, 2019 06:11 — forked from fernandoaleman/fix-libv8-mac.txt
Fixing libv8 and therubyracer on Mac
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/v8@3.15
bundle install
@gordey4doronin
gordey4doronin / replace-paragraph-and-tilda.sh
Last active May 15, 2021 09:02
Remap Tilda and Paragraph buttons on a macbook keyboard https://apple.stackexchange.com/a/374074/351784
#!/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}
]}'
@gordey4doronin
gordey4doronin / tslint-ban-config.json
Created April 10, 2017 09:06 — forked from FiniteLooper/tslint-ban-config.json
Configuration for TSLint's "ban" rule for modern Angular applications
"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#_
@gordey4doronin
gordey4doronin / filedownloader.js
Last active April 20, 2016 09:23 — forked from DavidMah/filedownloader.js
File Download requests using jquery/POST request with psuedo ajax
// 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]),
@gordey4doronin
gordey4doronin / read-git.md
Last active September 30, 2016 08:01
Useful links about git. Articles, presentations etc.
@gordey4doronin
gordey4doronin / flies-and-cutlets.js
Last active August 29, 2015 14:18
Rx. Trying to merge two streams of differents types. Flies and cutlets. It works without problems in JavaScript cause of its dynamic typing nature. But it doesn't compile in TypeScript because of generic merge<T> function type safety.
var flies = [
{
legs: 4,
wings: 2
},
{
legs: 6,
wings: 4
}
];