Skip to content

Instantly share code, notes, and snippets.

View jcurtis-cc's full-sized avatar
🎯
Focusing

J Curtis jcurtis-cc

🎯
Focusing
View GitHub Profile
@jcurtis-cc
jcurtis-cc / README.md
Created February 22, 2025 06:59 — forked from liviaerxin/README.md
FastAPI and Uvicorn Logging #python #fastapi #uvicorn #logging

FastAPI and Uvicorn Logging

When running FastAPI app, all the logs in console are from Uvicorn and they do not have timestamp and other useful information. As Uvicorn applies python logging module, we can override Uvicorn logging formatter by applying a new logging configuration.

Meanwhile, it's able to unify the your endpoints logging with the Uvicorn logging by configuring all of them in the config file log_conf.yaml.

Before overriding:

uvicorn main:app --reload
###############################################################################
# Helpful Docker commands and code snippets
###############################################################################
### CONTAINERS ###
docker stop $(docker ps -a -q) #stop ALL containers
docker rm -f $(docker ps -a -q) # remove ALL containers
docker rm -f $(sudo docker ps --before="container_id_here" -q) # can also filter
# exec into container
@jcurtis-cc
jcurtis-cc / ffmpeg-format-to-mimetype.js
Created February 11, 2025 06:24 — forked from DusanBrejka/ffmpeg-format-to-mimetype.js
FFMPEG - map of formats to default mime types
// INCOMPLETE
// This command will give you list of available FFMPEG formats and their default Mime types
// ffmpeg -formats -hide_banner | tail -n +5 | cut -c5- | cut -d' ' -f1 | xargs -i{} ffmpeg -hide_banner -h demuxer={} | pcregrep -o2 -o4 -M '(Muxer (\w+) )|(Mime type:( .*).)'
// And then parse the output with regex to JSON format in JavaScript for example:
// str.match(/(.*)\n (.*)/gm).map(m => `"${m.replace(/\n /, '": "')}"`).join(',\n');
// Combine the output with MDN - Common MIME types
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
// And with IANA:
@jcurtis-cc
jcurtis-cc / install_valgrind_3_23_0.sh
Created May 6, 2024 02:23
Install latest Valgrind (3.23.0)
wget https://sourceware.org/pub/valgrind/valgrind-3.23.0.tar.bz2
tar -xjf valgrind-3.23.0.tar.bz2
cd valgrind-3.23.0
./configure
make
sudo make install
@jcurtis-cc
jcurtis-cc / musicalConversions.js
Created February 9, 2023 09:33
JavaScript functions for music related conversions
let pitchclassToKeyString = function(k) {
ks = Math.floor(k/2);
ks += (k > 4 && k%2 == 1) ? 1 : 0;
ks %= 5; ks += k > 8 ? 65 : 67;
var keystr = String.fromCharCode(ks);
keystr += ((k<5 && k%2==1)||(k>5&&k%2==0)) ? "#" : "";
return keystr
}
let keyStringToPitchclass = function(k) {
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';