Skip to content

Instantly share code, notes, and snippets.

Avatar
📖
Reading; Donald Knuth, of course.

Emil Kreutzman ekreutz

📖
Reading; Donald Knuth, of course.
View GitHub Profile
@ekreutz
ekreutz / serial_counter.md
Last active March 20, 2023 18:23
Reset SERIAL counter for a PostgreSQL database table
View serial_counter.md
@ekreutz
ekreutz / round_sd.py
Created February 3, 2023 09:51
Python - round a number to significant digits
View round_sd.py
from math import log10, floor
from decimal import Decimal as Dec
# Note: the method spec uses a union type float | Dec introduced in Python 3.10
# Remove the type definitions to make it work with earlier versions.
def round_sd(x: float | Dec, sd: int = 3):
"""Round a value to a specified amount of significant digits `sd`.
"""
return round(x, sd - int(floor(log10(abs(x)))) - 1)
@ekreutz
ekreutz / update_conda.md
Last active August 20, 2021 07:52
How to update conda
View update_conda.md

Update conda

Or, how to update miniconda or Anaconda.

Simply run the following command:

conda update -n base conda
@ekreutz
ekreutz / pixel_aspect_ratios.md
Last active May 27, 2022 05:47
Pixel aspect ratios - a potential issue in object detection?
View pixel_aspect_ratios.md

Pixel aspect ratios - a potential issue in object detection?

Updated: Jan 25, 2021

Quick write-up about pixel aspect ratios in video files, and how they might affect performance in an object detection pipeline. I found very little good information about this online, so I decided to write this to summarize my findings.

Tl;dr: scroll down to the "final solution" code, for how to deal with this issue, using Python/OpenCV.


@ekreutz
ekreutz / attention.md
Last active July 6, 2023 12:12
Dot-product and Multi-head attention implementation in Tensorflow 2
View attention.md

Dot-product and Multi-head attention

Dot-product and Multi-head attention from the paper "Attention is all you need" (2017). Implementation in modern Tensorflow 2 using the Keras API.

Example use of the implementations below:

batch_size = 10
n_vectors = 150
d_model = 512
@ekreutz
ekreutz / tmux_conda_fix.md
Last active July 4, 2023 10:23
Fix tmux messing with conda path
View tmux_conda_fix.md

Fix tmux messing with conda

Problem: When running a conda environment and opening tmux on macOS, a utility called path_helper is run again. Essentially, the shell is initialized twice which messes up the ${PATH} so that the wrong Python version shows up within tmux.

Solution

If using bash, edit /etc/profile and add one line. (For zsh, edit /etc/zprofile)

...
@ekreutz
ekreutz / ansible_variable_precedence.md
Last active July 27, 2023 05:10
Ansible variable precedence (order, hierarchy)
View ansible_variable_precedence.md
@ekreutz
ekreutz / resetXcode.sh
Last active February 28, 2018 20:00 — forked from maciekish/resetXcode.sh
Reset Xcode. Clean, clear module cache, Derived Data and Xcode Caches
View resetXcode.sh
#!/bin/bash
#
# curl -O https://gist.githubusercontent.com/ekreutz/b245da335cc10b0d270136b35eb22d1f/raw/43c6d07b0b3d3165af9c10cef18e8709a07ce680/resetXcode.sh && bash ./resetXcode.sh ; rm ./resetXcode.sh
#
if [[ $(whoami) != jenkins ]]; then
echo "Run as jenkins"
exit 1
fi