Skip to content

Instantly share code, notes, and snippets.

View RienNeVaPlus's full-sized avatar
🔌
Plugged in

RienNeVaPlus RienNeVaPlus

🔌
Plugged in
View GitHub Profile
@RienNeVaPlus
RienNeVaPlus / letsencrypt-certbot-arangodb.md
Last active February 28, 2024 12:31
Using Let's Encrypt's Certbot SSL-Certificates with ArangoDB

Using Let's Encrypt's Certbot Certificates with ArangoDB

Let's Encrypt generates SSL certificates for free.
Follow these steps to create and use an SSL certificate with ArangoDB.

1. Install the Certbot from LetsEncrypt (Certbot instructions)

sudo apt-get update
sudo apt-get install software-properties-common
@RienNeVaPlus
RienNeVaPlus / emojiFlag.ts
Last active September 18, 2023 19:54
🏁 A TypeScript function that returns the unicode flag icon for a two-digit country code or a locale
/**
* 🏁 Returns an unicode-emoji-flag-icon for a two digit country code or a locale (eg. en-US)
* - Supports 239 countries
*
* @param {String} countryCode - the country code to display a flag for (eg. US)
* @param {String} [fallback=🏳] - fallback icon when no matching flag has been found
* @param {Object} [countryFlagData] - an object of country code : flag
*/
export function emojiFlag(countryCode: string, fallback: string = '🏳', countryFlagData: {[key: string]: string} = {
AD: '🇦🇩', AE: '🇦🇪', AF: '🇦🇫', AG: '🇦🇬', AI: '🇦🇮', AL: '🇦🇱', AM: '🇦🇲', AO: '🇦🇴', AQ: '🇦🇶', AR: '🇦🇷',
@RienNeVaPlus
RienNeVaPlus / dateDiff.ts
Last active August 23, 2023 00:20
🕤 dateDiff() - returns a detail object about the difference between two dates
/**
* ☃ dateDiff "Snowman Carl" (http://stackoverflow.com/questions/13903897)
* Returns a detail object about the difference between two dates
*
* When providing custom units, provide them in descending order (eg week,day,hour; not hour,day,week)
*
* @param {Date} dateStart - date to compare to
* @param {Date|string} [dateEnd=new Date()] - second date, can be used as unit param instead
* @param {...string} [units=Object.keys(dateDiffDef)] - limits the returned object to provided keys
*/
@RienNeVaPlus
RienNeVaPlus / object.querySelector.ts
Created September 20, 2022 02:19
A querySelector utility to fetch values from an object by providing a path string. `querySelector({a:[{b:3]}, 'a[0].b') === 3`
const querySelectorRegex = /(?<=\[)(?!")[^\]]+|(?<=\[")[^"]+|[^."[\]]+/g
export function objectQuerySelector(obj: any, path: string){
const match = path.match(objectQueryRegex)
return match ? match.reduce((res, prop) => res[prop], obj) : undefined
}
@RienNeVaPlus
RienNeVaPlus / EU-VAT.md
Last active August 29, 2022 20:03
VAT regulations for the European Union (EU)

Not part of OSS (below 10k EUR)

Annual sales not exceeding 10.000 EUR.

Customer from... same country other EU country outside of the EU
End customer homeland rate homeland rate 0%
Business customer homeland rate homeland rate 0%
... with TAX ID homeland rate reverse-charge (0%) 0%
@RienNeVaPlus
RienNeVaPlus / getAllPropertyNames.ts
Created April 30, 2020 03:14
getAllPropertyNames(obj) collects property names of the entire prototype chain until it reaches `Object` by using `Object.getOwnPropertyNames()`
/**
* Similar to Object.getOwnPropertyNames(obj) but including the properties of the entire prototype chain
* @param obj
* @param maxChainLength
*/
export function getAllPropertyNames(
obj: { new(): any },
maxChainLength: number = 10
): string[] {
let set: Set<string> = new Set(), i: number = 0;
@RienNeVaPlus
RienNeVaPlus / array2dFilterDuplicates.ts
Last active June 11, 2021 23:46
Filter duplicates from two dimensional array
function array2dUnique(arr: any[], index: number = 0){
return arr.filter((a, i1, $) => !$.find((b, i2) => i1 > i2 && a[index] === b[index]))
}
console.log(
array2dUnique([
[1],
[2],
[1]
])
@RienNeVaPlus
RienNeVaPlus / hostname.conf
Last active June 11, 2021 23:46
How-to configure Mail-in-a-Box (MIAB) nginx to work with StencilJS or any other JavaScript router that requires a single entry point
location / {
index index.html;
try_files $uri $uri/ /index.html;
}
@RienNeVaPlus
RienNeVaPlus / easing.js
Last active June 10, 2021 15:14 — forked from gre/easing.js
🔀 Simple Easing Functions in JavaScript using `export`
/**
* Easing functions
*
* https://gist.github.com/gre/1650294
* http://easings.net
*/
// no easing, no acceleration
export function easeLinear(t){ return t }
// accelerating from zero velocity
export function easeInQuad(t){ return t*t }
@RienNeVaPlus
RienNeVaPlus / isoLocale.js
Created August 17, 2019 08:38
ISO 639-1 + ISO 3166-1 alpha-2 - Inspired by https://gist.github.com/jacobbubu/1836273
export const isoLocale = {
'af-NA': 'Afrikaans (Namibia)',
'af-ZA': 'Afrikaans (South Africa)',
'af': 'Afrikaans',
'ak-GH': 'Akan (Ghana)',
'ak': 'Akan',
'sq-AL': 'Albanian (Albania)',
'sq': 'Albanian',
'am-ET': 'Amharic (Ethiopia)',
'am': 'Amharic',