Skip to content

Instantly share code, notes, and snippets.

View mitsos1os's full-sized avatar

Dimitris Halatsis mitsos1os

View GitHub Profile
@mitsos1os
mitsos1os / flatten.js
Last active April 4, 2023 14:28
flatten deep nested JSON object without recursion
const assert = require('assert').strict;
/**
* Pretty basic implementation to showcase non recursiveness.
* It would need to check for things such as Circular References in objects
*/
function flatten(source) {
const result = {};
// create an array that will hold depth-first keys as we encounter them during iteration
let keysArr = Object.keys(source);
@mitsos1os
mitsos1os / gnome-keyring-ssh.service
Created December 8, 2022 10:03
Modified systemd unit file for gnome-keyring-daemon in WSL2 after enabling system
# Works on WSL2 installation with enabled SystemD (https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/)
# File location: /usr/lib/systemd/user/gnome-keyring-ssh.service
# You can try it out by issuing:
# 1. `systemctl --user daemon-reload` -- will load the newly added file
# 2. `systemctl --user start gnome-keyring-ssh.service` -- will start the keyring daemon so that you can verify that it works
# 3. `systemctl --user enable gnome-keyring-ssh.service` -- will enable the service to run on system startup
[Unit]
Description=Start gnome-keyring as SSH agent
[Service]
@mitsos1os
mitsos1os / tax.js
Last active August 2, 2020 19:01
Simple NodeJS utility for calculating greek tax for 2020
'use strict';
const readline = require('readline');
// Tax percentages per salary level
const taxLevels = [10000, 20000, 30000, 40000, Infinity];
const taxPercentages = [0.09, 0.22, 0.28, 0.36, 0.44];
// Eisfora percentages
const eisforaLevels = [12000, 20000, 30000, 40000, 65000, 220000, Infinity];