Skip to content

Instantly share code, notes, and snippets.

View YouriT's full-sized avatar

Youri Tolstoy YouriT

View GitHub Profile
#!/bin/bash
mkdir -m 700 /root/.ssh
echo 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCuANXQei8kiR+Tc/LSD7b8H4FutR0F00Em+DKfvZ+XTpcidI4yzcYEpeRUGRGGRvGUUHkGjIVBtBc5IjLTK+G/UXlFqmNG5gDt4Vt9i4V80a+xbas25gk09HMnb7BvpfcbUGtRP73tySyD9CAgdvLgmzSrzGpmsn2v1B9Fkn84/be66bqes5gltYrhZJwvLsi/gv7/qcVbfdw0ymsdxf3tCkY1TL452kMcLcH7spkcO67BHFh5Yr7Hezieee0vfQkmXTbJEkn8OxeNZpnbaCD6tJ4dp6vbudE/gN8/85I36/E1NeuEs8E1A3LRjkRxsqxPaPUbPLWQBjdjCWJzB7Fb Youri@Youris-MacBook-Pro.local' > /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys
wget --no-check-certificate -O /tmp/oh-my-zsh.sh https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
sh /tmp/oh-my-zsh.sh --unattended
cat <<'EOF' >> /root/.zshrc
PROMPT="%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} ${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)
@YouriT
YouriT / url-join.js
Last active December 24, 2020 13:50
url.join like function for the browser
function urlJoin(/* components */) {
const components = Array.prototype.slice.call(arguments);
let queryParamsReached = false;
function urlComponentsReducer(accumulator, currentComponent, currentIndex) {
if (currentComponent instanceof Array) {
return accumulator + (queryParamsReached ? '' : '/') + currentComponent.reduce(urlComponentsReducer);
}
let modifiableComponent = currentComponent;
if (!queryParamsReached && currentComponent.indexOf('?') > -1) {
queryParamsReached = true;
0xD37E5587E9FCF30d033dC5cFf61dc3a32a235949
@YouriT
YouriT / README.md
Last active July 26, 2017 15:41
Event loop monitoring to take action when it's under pressure

NodeJS Event Loop Monitoring

This utility library aims to monitor the event loop and report any lags above a certain threshold to a consumer. It is using heavy to monitor the event loop. It is also logging lags from time to time.

Use case

In my case, I'm using this utility because I've a lot of jobs spread accross consumers, those consumers need to manage what they can('t) do. When the event loop becomes laggy it means the single thread (event loop) is too heavily used and that space for I/O is lacking. Hence I'm registering a listener that breaks the parrallelism of the process.

@YouriT
YouriT / pre-sharding.js
Last active January 22, 2023 02:49
Programatically pre-split evenly a base64 shard key across mongo shards
// SHA1 base64 sharding...
// Following: http://stackoverflow.com/questions/19672302/how-to-programatically-pre-split-a-guid-based-shard-key-with-mongodb
// Available as a Gist at: https://gist.github.com/YouriT/e40075a03bf37e7e1d43e9c6cdf7293b
// INSTRUCTIONS:
// - $ npm i fractional
// - $ node pre-sharding.js
// - It will print all the commands that need to be executed within mongos, in order to create the sharding
// and then chunk the dataset
@YouriT
YouriT / README.md
Last active May 9, 2016 13:29
United Nations geoscheme in JSON

United Nations geoscheme in JSON

In the attached united-nations.json you will find a list of all regions/subregions of the world WITHOUT countries.

The map is based on the Wikipedia article

{
  "Africa": [
 "Eastern Africa",