Skip to content

Instantly share code, notes, and snippets.

View Magnuti's full-sized avatar

Magnuti

  • Trondheim, Norway
View GitHub Profile
@Magnuti
Magnuti / .gitconfig
Last active December 20, 2023 15:35
Global .gitconfig file
[alias]
st = status
[push]
autosetupremote = true
# Fixes contrasts issues on Powershell terminals with blue background
[color "status"]
changed = red bold
untracked = red bold
added = green bold
@Magnuti
Magnuti / posh_git_installation.md
Last active January 18, 2022 20:33
PoshGit installation
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm
PowerShellGet\Install-Module posh-git -Scope CurrentUser -Force
Add-PoshGitToProfile -AllHosts
@Magnuti
Magnuti / zshrc.md
Last active February 2, 2024 08:29
.zshrc profile for Git autocompletion and branch name

Git autocompletion and Git branch name in Z shell prompt

autoload -Uz compinit && compinit

function parse_git_branch() {
    git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
}

COLOR_GIT=$'%F{39}'
@Magnuti
Magnuti / .zshrc.md
Last active November 20, 2024 10:01
Useful .zshrc settings

Autocomplete

autoload -Uz compinit && compinit

Ignore duplicate commands in history

# Ignore duplicate commands in history
setopt histignoredups
@Magnuti
Magnuti / csharp_nswag.md
Last active November 29, 2024 13:46
C# client generation from Swagger specification with NSwag on Docker

C# client generation from Swagger specification with NSwag on Docker

FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine

# Install Node.js - we use Node.js 20 here, pick another version if you like that
RUN apk update \
    && apk add --no-cache curl \
    && curl -sL https://deb.nodesource.com/setup_20.x \
    && apk add --no-cache nodejs npm build-base
@Magnuti
Magnuti / iterate_dict.py
Created January 13, 2025 15:09
Iterate JSON structure in Python
def iterate_dict(d, path="", level=0):
for key, value in d.items():
new_path = f"{path}.{key}" if path else key
if isinstance(value, dict):
yield new_path
yield from iterate_dict(value, new_path, level+1)
else:
yield new_path
with open(filename, 'r') as f: