Skip to content

Instantly share code, notes, and snippets.

View mgnisia's full-sized avatar

Moritz Gnisia mgnisia

View GitHub Profile
@pedrovgp
pedrovgp / upsert_df.py
Last active August 22, 2024 05:32
Allow upserting a pandas dataframe to a postgres table (equivalent to df.to_sql(..., if_exists='update')
# Upsert function for pandas to_sql with postgres
# https://stackoverflow.com/questions/1109061/insert-on-duplicate-update-in-postgresql/8702291#8702291
# https://www.postgresql.org/docs/devel/sql-insert.html#SQL-ON-CONFLICT
import pandas as pd
import sqlalchemy
import uuid
import os
def upsert_df(df: pd.DataFrame, table_name: str, engine: sqlalchemy.engine.Engine):
@AntonioMarsella
AntonioMarsella / read_json.py
Created March 17, 2020 07:10
Read Json files
import json
with open('filename.json', 'r') as f:
json_dict = json.load(f)
for key in json_dict:
print(key['attribute'])
@TechupBusiness
TechupBusiness / create_docker_compose_basic_auth_string_for_traefik.sh
Last active July 31, 2023 13:52
Generator to create basic authentication string for traefik (docker-compose.yml and .env)
#!/bin/bash
SUDO=''
if (( $EUID != 0 )); then SUDO='sudo'; fi
echo "Basic auth for traefik >= v1.7"
read -p "User: " USER
read -p "Password: " PW
# Checks if htpasswd is available or install it otherwise
@qoomon
qoomon / conventional-commits-cheatsheet.md
Last active April 27, 2025 18:06
Conventional Commits Cheatsheet

Conventional Commit Messages starline

See how a minor change to your commit message style can make a difference.

Tip

Take a look at git-conventional-commits , a CLI util to ensure these conventions, determine version and generate changelogs

Commit Message Formats

Default

@jlumbroso
jlumbroso / genanki-media-test.py
Created September 23, 2018 14:23
Minimal example of how to create a working Anki deck with a media file embedded.
import genanki
my_model = genanki.Model(
1380120064,
'Example',
fields=[
{'name': 'Object'},
{'name': 'Image'},
],
templates=[
@danisfermi
danisfermi / setupdb.md
Created December 15, 2017 23:00
Setup gdb on Mac OS Sierra/High Sierra

Here are the steps to installing and setting up GDB on Mac OS Sierra/High Sierra. Run brew install gdb. On starting gdb, you will get the following error:

Unable to find Mach task port for process-id 2133: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))

To fix this error, follow the following steps:

@analogic
analogic / docker-compose.yml
Last active June 6, 2024 12:12
Poste.io (with Lets Encrypt) + Nginx reverse proxy + Nginx Lets encrypt companion
version: '3'
services:
nginx-proxy:
image: jwilder/nginx-proxy
labels:
com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true"
container_name: nginx-proxy
restart: unless-stopped
ports:
@ZeroDeth
ZeroDeth / timezone-playbook.yml
Created August 10, 2017 23:58
Ansible Configure timezone setting
---
- hosts: all
become: yes
tasks:
- name: set timezone to Europe/London
timezone:
name: Europe/London
@mjj2000
mjj2000 / get-current-git-tag.sh
Last active January 31, 2025 08:18
[GIT] Get tag of current branch(that is HEAD) or fallback to short commit hash(7 digits) by single shell command
git describe --exact-match --tags 2> /dev/null || git rev-parse --short HEAD
@eguven
eguven / brew-list.sh
Last active April 13, 2025 05:34
List all packages installed using Homebrew and their sizes
# this original one uses values returned from 'brew info'
brew list --formula | xargs -n1 -P8 -I {} \
sh -c "brew info {} | egrep '[0-9]* files, ' | sed 's/^.*[0-9]* files, \(.*\)).*$/{} \1/'" | \
sort -h -r -k2 - | column -t
# faster alternative using 'du'
du -sch $(brew --cellar)/*/* | sed "s|$(brew --cellar)/\([^/]*\)/.*|\1|" | sort -k1h