Skip to content

Instantly share code, notes, and snippets.

View danielreiser's full-sized avatar

Daniel Reiser danielreiser

View GitHub Profile
@danielreiser
danielreiser / vat-id-validation.constants.js
Created October 12, 2017 07:27
Regexes for validating european VAT-IDs.
/**
* Regexes for VAT-ID format validation.
*/
export const VAT_ID_REGEXES = {
AT: /^(AT)?U[0-9]{8}$/,
BE: /^(BE)?0[0-9]{9}$/,
BG: /^(BG)?[0-9]{9,10}$/,
CY: /^(CY)?[0-9]{8}L$/,
CZ: /^(CZ)?[0-9]{8,10}$/,
DE: /^(DE)?[0-9]{9}$/,

Keybase proof

I hereby claim:

  • I am danielreiser on github.
  • I am danielreiser (https://keybase.io/danielreiser) on keybase.
  • I have a public key ASDte3XvElURSZKlWfylMS6FDNz_hZZDfPio-8wdmXCeigo

To claim this, I am signing this object:

@danielreiser
danielreiser / ipmacscan.sh
Created August 7, 2018 11:32
Scan subnet for connected client, output IP & MAC-Address
nmap -n -sP 172.16.57.0/24 | awk '{printf $5;printf " ";getline;getline;print $3;}'
@danielreiser
danielreiser / mov2gif
Last active September 12, 2018 15:30
Convert mov to gif (slow down to 30 fps)
# Prerequisites ffmpeg (`brew install ffmpeg`) & gifsicle (`brew install gifsicle`)
# 1. Record screen with quicktime
# 2. Save as *.mov
# 3. Convert with ffmpeg & gifsicle :ok_hand:
ffmpeg -i input.mov -s 600x400 -pix_fmt rgb24 -r 30 -f gif - | gifsicle --optimize=3 --delay=3 > output.gif
@danielreiser
danielreiser / step2_osm-vector-tiles.sh
Created July 27, 2021 10:00
Install tooling and kick of the conversion process
# We need make in order for openmaptiles to work correctly
sudo apt-get install -y make
# get the openmaptiles tooling
git clone https://github.com/openmaptiles/openmaptiles.git
cd ./openmaptiles
# We've decided to only get the mapdata until zoom level 12. It's a good idea to check first which zoom levels you'll need. Eveything higher then 12 take a lot of time and space
sed -i "/MAX_ZOOM=/c\MAX_ZOOM=12" .env
# Prep openmaptiles and download the raw OSM data for europe
@danielreiser
danielreiser / step1_osm-vector-tiles.sh
Last active July 27, 2021 10:01
Install docker and docker-compose on an ubuntu based EC2 instance in AWS
# Update all package lists and update ubuntu
sudo apt-get -y update
sudo apt-get -y dist-upgrade
# Add the docker repository to make it available via apt-get install and update the package lists again
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
@danielreiser
danielreiser / osm-extract-vector-tiles-from-mbutils.sh
Last active July 30, 2021 06:52
Extract vector tiles from a MBTiles file
cd data/
sudo apt-get install -y python
git clone https://github.com/mapbox/mbutil.git
./mbutil/mb-util --image_format=pbf tiles.mbtiles tiles
cd ../tiles/
@danielreiser
danielreiser / osm-ungzip-vector-tiles.sh
Created July 30, 2021 06:53
Ungzip the extracted vector files from mbutil
# Un-gzip them
gzip -d -r -S .pbf *
# Rename them (this also renames all non-pbf files)
find . -type f -exec mv '{}' '{}'.pbf \;
# As i said, it renames all files so we have to remove the suffix once more
mv metadata.json{.pbf,}
@danielreiser
danielreiser / leevenshtein-404-approach-a.helper.js
Last active August 3, 2021 16:35
Snippet of the levenshtein distance calculator top correct a misspelled route - Approach A
const { closest, distance } = require('fastest-levenshtein')
// Approach A - Using closest
const routes = {
paymentMethods: 'paymentmethods',
accountData: 'account-data',
privacy: 'privacy',
privacySettings: 'privacy-settings',
}
@danielreiser
danielreiser / leevenshtein-404-approach-b.helper.js
Last active August 7, 2021 14:14
Snippet of the levenshtein distance calculator top correct a misspelled route - Approach B
const { distance } = require('fastest-levenshtein')
// Approach B - Using distance which gives us more control in conjunction with a MAX_DISTANCE value
const routes = {
paymentMethods: 'paymentmethods',
accountData: 'account-data',
profile: 'profile',
privacySettings: 'privacy-settings',
}