Skip to content

Instantly share code, notes, and snippets.

View erikvullings's full-sized avatar

Erik Vullings erikvullings

View GitHub Profile
@erikvullings
erikvullings / readme.md
Created January 30, 2022 10:50
Add SSH site to Windows Terminal

Source.

You can use a commandline field in your profile configuration to initiate an SSH connection on tab creation.

Step-by-step guide:

  1. Open Settings (Ctrl+,)
  2. Find the "list" array in the "profiles" object
  3. Duplicate a Command Prompt profile ("commandline": "cmd.exe")
  4. Change the commandline value to: ssh me@my-server -p 22 -i ~/.ssh/id_rsa (use your own connection command).
@erikvullings
erikvullings / README.md
Last active December 2, 2021 10:36
Asynchronous retry pattern with delay in Typescript
@erikvullings
erikvullings / README.md
Created November 10, 2021 13:08
EADDRINUSE error

EADDRINUSE error (Endpoint Address In Use)

Error: listen EADDRINUSE: address already in use :::1234

When node.js complains that an address is in use, this may happen because the service did not end properly. In order to kill the hanging process, do the following in an Admin PowerShell window:

netstat -ano|findstr "PID :1234"
@erikvullings
erikvullings / xml2json.ts
Last active November 18, 2023 17:39
Convert XML to JSON using the browser's DOMParser without external dependencies.
export interface IObject {
[key: string]: any;
}
/*
This work is licensed under Creative Commons GNU LGPL License.
License: http://creativecommons.org/licenses/LGPL/2.1/
Version: 0.9
Author: Stefan Goessner/2006,
Conversion: Erik Vullings/2021 converted to TypeScript
@erikvullings
erikvullings / capitalize.ts
Created December 13, 2020 11:33
Capitalize first names derived from an email address (Dutch)
export const capitalize = (s: string) => s.charAt(0).toUpperCase() + s.slice(1);
/** Capitalize first names that are derived from an email, like anne_merel or jan_willem. */
export const capitalizeName = (s: string) =>
/^ij/i.test(s) // names like IJsbrand
? s.replace(/^ij/i, 'IJ')
: /_/.test(s) // names like jan_willem
? s.split('_').map(capitalize).join('-')
: capitalize(s); // other names
@erikvullings
erikvullings / pdok.html
Created July 30, 2020 10:50
Add a Dutch background map to your leaflet application.
<!DOCTYPE html>
<html>
<head>
<title>PDOK achtergrondkaarten</title>
<!-- https://www.pdok.nl/introductie/-/article/basisregistratie-topografie-achtergrondkaarten-brt-a-
Zie ook de wizard hier:
https://nlmaps.nl/
PDOK biedt 4 base maps aan van NL: standaard, grijs, water, en pastel. Deze kun je gratis gebruiken
const copyToClipboard = str => {
const el = document.createElement('textarea');
el.value = str;
el.setAttribute('readonly', '');
el.style.position = 'absolute';
el.style.left = '-9999px';
document.body.appendChild(el);
const selected =
document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false;
el.select();
@erikvullings
erikvullings / toEnglish.vba
Last active February 15, 2024 10:17
Change the language of your PowerPoint presentation
'Change the language of your PowerPoint
'In newer PowerPoint version, you need to first save your PowerPoint with macros enabled.
'Go to the VIEW tab, select MACROS (at the right), enter a name, e.g. toEnglish, and press create to enter below text.
'Now you can run the macro from the same menu.
'Alternatively, but less complete, go to the VIEW tab, select OUTLINE, select all slides (using CTRL-A).
'Now go to the REVIEW tab, select Language, and change the proofing language.
'Also make sure that you set the WINDOWS Language (taskbar, bottom right) to the preferred language, otherwise all new text
'will have the same problem (Press CTRL + WINDOWS + SPACE to switch the Keyboard input language).
Option Explicit
Sub toEnglish()
@erikvullings
erikvullings / Excel_time_to_UTC_time.md
Last active November 29, 2021 21:03
Convert Excel time to UTC time

The problem

I had a CSV file that needed to be processed on a web page. So I had to convert the Excel time to UTC time.

The solution

According to this answer on StackOverflow:

The Excel number for a modern date is most easily calculated as the number of days since 12/30/1899 on the Gregorian calendar.

Excel treats the mythical date 01/00/1900 (i.e., 12/31/1899) as corresponding to 0, and incorrectly treats year 1900 as a leap year. So for dates before 03/01/1900, the Excel number is effectively the number of days after 12/31/1899.