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 February 11, 2024 20:44
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_commit_messages.md
Last active May 7, 2024 19:27
Conventional Commit Messages

Conventional Commit Messages

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

Tip

Have a look at git-conventional-commits , a CLI util to ensure these conventions and generate verion and 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 February 20, 2024 14:20
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:
@mjj2000
mjj2000 / get-current-git-tag.sh
Last active April 1, 2024 01:11
[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
@nepsilon
nepsilon / git-change-commit-messages.md
Last active April 24, 2024 06:30
How to change your commit messages in Git? — First published in fullweb.io issue #55

How to change your commit messages in Git?

At some point you’ll find yourself in a situation where you need edit a commit message. That commit might already be pushed or not, be the most recent or burried below 10 other commits, but fear not, git has your back 🙂.

Not pushed + most recent commit:

git commit --amend

This will open your $EDITOR and let you change the message. Continue with your usual git push origin master.

@ilciavo
ilciavo / BoundaryConditions.py
Last active June 4, 2020 09:36
Poisson and Heat Equation with boundary conditions
#poisson solver
#u_xx = b(x)
%matplotlib inline
from __future__ import division
import numpy as np
from numpy import cos, sin, zeros, pi
from numpy.linalg import solve, norm
import matplotlib.pyplot as plt
from matplotlib import rcParams