Skip to content

Instantly share code, notes, and snippets.

View louwersj's full-sized avatar
🏠
Working from home

Johan Louwers louwersj

🏠
Working from home
View GitHub Profile
@louwersj
louwersj / OracleCloudSparkNodeCconfig.sh
Last active April 29, 2024 11:29
Script to deploy spark nodes in OCI. Deploy them in the same subnet, ensure a rule is in place for communication between nodes on TCP port 7077. Ensure the master node is called 'master' and the worker nodes are named worker-node-n. The same script can be used for both masters and workers. First deploy a master node, all worker nodes will join t…
#!/bin/bash
# GPL License Disclaimer
# This script is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@louwersj
louwersj / Kaliningrad.overpass
Created April 3, 2024 15:30
search openstreetmaps with overpass turbo for military objects in Kaliningrad Oblast
[out:json];
area[name="Калининградская область"]->.searchArea; // Setting the search area to Kaliningrad Oblast
(
node["military"](area.searchArea);
way["military"](area.searchArea);
relation["military"](area.searchArea);
);
out body;
>;
out skel qt;
@louwersj
louwersj / example_convert_rd_to_gps.py
Created September 15, 2023 08:18
convert Rijksdriehoek coordinates into Latitude and longitude
from pyproj import Proj, transform
def convert_rd_to_gps(eastings, northings):
# Define the Rijksdriehoek coordinate system
rd_proj = Proj(proj="sterea", ellps="bessel", lat_0=52.15616055555555, lon_0=5.3876388888889, x_0=155000, y_0=463000, k=1.0008035)
# Define the WGS84 coordinate system (GPS)
wgs84_proj = Proj(proj="latlong", datum="WGS84")
# Convert RD coordinates to GPS coordinates
@louwersj
louwersj / example.json
Created June 22, 2023 14:07
example.GeoJSON
{
"type": "Feature",
"properties": {
"postalCode": "3273"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
@louwersj
louwersj / wordMerge.py
Created May 5, 2023 08:23
Example code to show how XML data can be infused into a docx template based upon Jinja2.
# Example code to show how XML data can be infused into a docx template based upon Jinja2.
import sys
import uuid
import xml.etree.cElementTree as ET
from docxtpl import DocxTemplate
xmlStructure = ("input_data.xml")
# Developed for taking a number of .csv files with flight data from flightradar24 and prepare them for use in kepler.gl to
# visualize flight paths over time.
#
# This script uses the Pandas library to manipulate CSV files. It starts by using the glob library to find all CSV files in
# the current directory, and stores them in a list called "csv_files".
#
# It then creates an empty list called "df_list" which will be used to store the modified DataFrames.
#
# A for loop then iterates over each file in the "csv_files" list, using the Pandas function "pd.read_csv()" to read the file
# and store it as a DataFrame. It then uses the Pandas function "df["Position"].str.replace('"','')" to remove any double
We can't make this file beautiful and searchable because it's too large.
Timestamp,UTC,Callsign,Position,Altitude,Speed,Direction,Latitude,Longitude
1667197760,2022-10-31T06:29:20Z,RSD882,"52.654221,38.848267",2875,141,169,52.654221,38.848267
1667197765,2022-10-31T06:29:25Z,RSD882,"52.651428,38.849182",2875,140,169,52.651428,38.849182
1667197770,2022-10-31T06:29:30Z,RSD882,"52.647766,38.850327",2900,141,169,52.647766,38.850327
1667197778,2022-10-31T06:29:38Z,RSD882,"52.642639,38.851929",2875,141,169,52.642639,38.851929
1667197785,2022-10-31T06:29:45Z,RSD882,"52.638153,38.853386",2875,141,168,52.638153,38.853386
1667197792,2022-10-31T06:29:52Z,RSD882,"52.634262,38.854599",2900,140,169,52.634262,38.854599
1667197797,2022-10-31T06:29:57Z,RSD882,"52.63047,38.855816",2875,141,169,52.63047,38.855816
1667197805,2022-10-31T06:30:05Z,RSD882,"52.625748,38.857269",2875,141,169,52.625748,38.857269
1667197811,2022-10-31T06:30:11Z,RSD882,"52.622044,38.858406",2900,142,169,52.622044,38.858406
@louwersj
louwersj / bash_remove_spaces.md
Created January 17, 2023 21:07
BASH remove space from file

You can use the command sed to remove spaces from a file. The basic syntax for removing spaces from a file is:

sed 's/ //g' <input file> > <output file>

This command will take the input file, find all instances of spaces ( ) and replace them with nothing, effectively removing them, and write the output to the specified output file.

If you want to remove spaces at the beginning of each line, you can use the following command:

@louwersj
louwersj / bash_replace_char.md
Created January 17, 2023 21:06
BASH replace characters in a file

You can use the command sed to replace all instances of a specific character or string in a file. The basic syntax for replacing text in a file is:

sed 's/<old text>/<new text>/g' <input file> > <output file>

To replace all commas with semicolons in a file, you would use the following command:

sed 's/,/;/g' <input file> > <output file>
@louwersj
louwersj / bash_switch_columns_csv.md
Created January 17, 2023 20:33
BASH switch columns

You can use the command awk to manipulate columns in a file. To switch the first and second columns in a semicolon-delimited file, you can use the following command:

awk -F ';' '{print $2 ";" $1}' <input file> > <output file>

This command will read the input file, specifying the semicolon as the field separator (-F ';'), and for each line, print the second field ($2), followed by a semicolon, followed by the first field ($1). The output will be written to the specified output file.

If you want to change the file in place, you can use sed command as well.