Skip to content

Instantly share code, notes, and snippets.

View mazzma12's full-sized avatar

MazzMa mazzma12

View GitHub Profile
@mazzma12
mazzma12 / HTTPSServer.py
Last active March 26, 2021 15:09
Dummy HTTPS server in python3 based on http.server library
# Dummy HTTPS server
# Taken from : https://gist.github.com/dragermrb/108158f5a284b5fba806 and other repos
import http.server
import cgi
import base64
import json
from urllib.parse import urlparse, parse_qs
import ssl
import os
import socketserver
@mazzma12
mazzma12 / kml_io.py
Last active February 22, 2024 17:01
IO / Read and write KML file with geopandas and fiona driver
import fiona
import geopandas as gpd
# Enable fiona driver
gpd.io.file.fiona.drvsupport.supported_drivers['KML'] = 'rw'
# Read file
df = gpd.read_file(path, driver='KML')
# Write file
@mazzma12
mazzma12 / haversine.py
Created October 11, 2018 13:03
Fast Haversine distance with NumPY
def haversine_np(lon1, lat1, lon2, lat2):
"""
Calculate the great circle distance between two points
on the earth (specified in decimal degrees)
Reference:
https://stackoverflow.com/a/29546836/7657658
"""
lon1, lat1, lon2, lat2 = map(np.radians, [lon1, lat1, lon2, lat2])
@mazzma12
mazzma12 / manjaro_experience.md
Last active January 18, 2021 22:02
Manjaro Exerience Records

This will only contains the pitfalls met at installation and during utilization. So far it's great.

ORG Website

  • Use the wiki page instead of the official org website which is not really uptodate.
  • Website points to an outdated repo that host the manjaro image. If you carefully read there is a forward message on the repo pointing toward the new one
  • SHA checksum are not up-to-date on the org website. They can be found in the new repo listed above

ISO Image

@mazzma12
mazzma12 / set-gnome-shell-hotkeys.sh
Last active June 7, 2023 02:38
i3 gnome-shell keyboard bindings
# Remove switch to app https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/1250
for i in {1..9}; do gsettings set "org.gnome.shell.keybindings" "switch-to-application-$i" "[]"; done
# Necessary even with gnomesome : https://github.com/ChWick/gnomesome
for i in {1..9}; do gsettings set "org.gnome.desktop.wm.keybindings" "switch-to-workspace-$i" "['<super>$i']"; done
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-1 "['<super>1']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-2 "['<super>2']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-3 "['<super>3']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-4 "['<super>4']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-5 "['<super>5']"

Keybase proof

I hereby claim:

  • I am mazzma12 on github.
  • I am mcmzl (https://keybase.io/mcmzl) on keybase.
  • I have a public key ASDefTzbN9XeopYmMf1xZ9BcsPTfYSLByZdnnlMfjU98jQo

To claim this, I am signing this object:

@mazzma12
mazzma12 / cat_jupyter_url.sh
Created March 26, 2020 21:50
Cat the url of the last most recent jupyter notebook under the user home.
#!/usr/bin/env bash
cat_jupyter_url () {
file=$(ls -rt $HOME/.local/share/jupyter/runtime/*.html | tail -n 1)
cat $file | grep href= | cut -d'"' -f2
}
@mazzma12
mazzma12 / csv_with_location_to_geojson.py
Created September 29, 2020 15:13
Convert location points to GeoJSON
"""
Once often need to parse manually a CSV which contains erroneous cell, therefore I prefer not to use gpd.read_file()
"""
from pathlib import Path
import geopandas as gpd
import pandas as pd
import shapely
@mazzma12
mazzma12 / mask_trackpad_area.sh
Created April 14, 2021 08:14
Disable trackpad area - HP Spectre X360
# Hp spectre x360 trackpad are too sensitive on the sides, which is error prone due to palm touch
# This work on Ubuntu 16.04, 18.04,
@mazzma12
mazzma12 / find_expression.sh
Last active May 21, 2021 14:58
Find and grep occurences in file
#!/usr/bin/env bash
# Find THE notebook you have lost
expr=$1 # The content you are looking for : "*myCode*"
files=${2:-*.ipynb} # File patterns
find . -type f -name "$files" -exec grep -E "$expr" --with-filename {} \;