Skip to content

Instantly share code, notes, and snippets.

View mdiener21's full-sized avatar

Michael Diener mdiener21

View GitHub Profile
@mdiener21
mdiener21 / create_glab_pull_merge_request.sh
Last active July 15, 2026 06:08
Gitlab worktree bash alias to pull merge request locally with glab cli
# cmr - open a GitLab merge request branch in a separate Git worktree
# Usage: cmr <MR_ID> [REMOTE]
# Example: cmr 1234 origin
# Uses 'origin' when no remote is provided.
# The worktree is created one directory above the repository using the branch name.
@mdiener21
mdiener21 / create_git_worktree_alias.sh
Created July 15, 2026 06:02
git worktree alias for my bash
git config --global alias.wta '!f() { git worktree add -b "$1" "../$1"; }; f'
git config --global alias.wtr '!f() { git worktree remove "../$1"; }; f'
git config --global alias.wtl '!f() { git worktree list; }; f'
@mdiener21
mdiener21 / git-commands.sh
Last active February 19, 2026 06:20
Git commands I forget
# set local credentials
git config --global credential.helper store
git config --global user.name "$GITLAB_USER_NAME"
git config --global user.email "$GITLAB_USER_EMAIL"
# update remote url
git remote set-url origin <NEW_GIT_URL_HERE>
# git commits per developer
@mdiener21
mdiener21 / round_minutes_to_quarter_hour.py
Last active April 4, 2024 09:05
Python round minutes to the nearest quarter hour
def round_to_nearest_quarter_hour(minutes, base=15):
"""
Input: A value in minutes.
Return: An integer rounded to the nearest quarter-hour (0, 15, 30, 45) based on the base interval,
with special handling to ensure rounding from 0 up to 7 goes to 0 and 8 to 15 round to 15
Example round_to_nearest_quarter_hour(0) rounds to 0
round_to_nearest_quarter_hour(7) rounds to 0
round_to_nearest_quarter_hour(8) rounds to 15
round_to_nearest_quarter_hour(22) rounds to 15
@mdiener21
mdiener21 / create osm routes
Created May 16, 2014 07:03
create spatialite routing data using openstreetmap
#* original post here http://blog.mikeasoft.com/2010/09/24/local-map-rendering-and-route-finding-with-libchamplain-spatialite-and-open-street-map/
Importing OSM data into spatialite
spatialite_osm -o mydownloadeddata.osm -d myNewDB.sqlite -T roads -m
Generating a routing table
spatialite_network -d myNewDB.sqlite -T roads -g geometry -c cost -t node_to -f node_from -n name --oneway-fromto oneway_fromto --oneway-tofrom oneway_tofrom -o roads_net_data
@mdiener21
mdiener21 / solve_rubics_cube_wired.md
Created October 27, 2022 17:59
Solve Rubiks Cube Wired instructions

Make the daisy Create the white cross Solve the first layer Solve the second layer Create the yellow cross: F U R U' R' F' Solve the yellow face: R U R' U R U2 R' Move yellow stickers upper right-hand corner of left-face Orient "fish" down and to the left relative to your perspective

@mdiener21
mdiener21 / delete_geoserver_layer.py
Created March 19, 2022 14:24
Delete a geoserver layer using the API with Python Requests
import requests
def delete_layer(layer_name):
s = requests.Session()
GEOSERVER_USER = 'someusername'
GEOSERVER_PASS = 'asecretthingy'
s.auth = (GEOSERVER_USER, GEOSERVER_PASS)
headers_json = {'Content-type': 'application/json', }
del_url = "https:/yourgeoserver.com/workspaces/SsmeWorkspaceName/datastores/someDataStoreName/featuretypes/" + layer_name + "?recurse=true"
r = s.delete(del_url, headers=headers_json, data={})
@mdiener21
mdiener21 / generate_git_stats.sh
Last active January 22, 2022 06:31
Git log commands for engineering managers
# git commits per developer
git shortlog -sn --no-merges --since "01 January 2019"
# a clearer better git log view of commits
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
@mdiener21
mdiener21 / calc_merge_stats.sh
Created January 31, 2021 19:23
print to sdout user git merge info
#!/bin/bash -e
set -o pipefail
# Any arguments are incorrect. Note that git intercepts --help and tries to
# open the man page.
if [ $# -gt 0 ]; then
echo 'Usage: git merge-stats'
exit 1
fi
@mdiener21
mdiener21 / install-postgres-postgis-gdal.sh
Last active June 24, 2020 16:18
Setup Ubuntu 16.04 for GIS development postgresql 9.6, postgis 2.3, gdal 2.1.2, python 3.5, pgrouting
sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main"
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.6
sudo apt-get install postgresql-9.6-postgis-2.3
sudo apt-get install postgresql-9.6-pgrouting
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update