Skip to content

Instantly share code, notes, and snippets.

View Kazy's full-sized avatar
🍡

Jocelyn Boullier Kazy

🍡
  • Shuttle
  • Paris, France
View GitHub Profile
@nymous
nymous / README.md
Last active May 22, 2024 17:09
Logging setup for FastAPI, Uvicorn and Structlog (with Datadog integration)

Logging setup for FastAPI

This logging setup configures Structlog to output pretty logs in development, and JSON log lines in production.

Then, you can use Structlog loggers or standard logging loggers, and they both will be processed by the Structlog pipeline (see the hello() endpoint for reference). That way any log generated by your dependencies will also be processed and enriched, even if they know nothing about Structlog!

Requests are assigned a correlation ID with the asgi-correlation-id middleware (either captured from incoming request or generated on the fly). All logs are linked to the correlation ID, and to the Datadog trace/span if instrumented. This data "global to the request" is stored in context vars, and automatically added to all logs produced during the request thanks to Structlog. You can add to these "global local variables" at any point in an endpoint with `structlog.contextvars.bind_contextvars(custom

@danmikita
danmikita / init.vim
Created November 16, 2018 19:16
File preview with FZF, RG, Bat, and Devicons
nnoremap <silent> <leader>e :call Fzf_dev()<CR>
" ripgrep
if executable('rg')
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"'
set grepprg=rg\ --vimgrep
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>).'| tr -d "\017"', 1, <bang>0)
endif
" Files + devicons
@romgrk
romgrk / surround-function.vim
Last active September 18, 2021 18:53
Adds ability to manipulate function calls with vim-surround
" This lets vim-surround be able to surround a motion with a function-call,
" but it's not smart enough to handle delete-surrounding & change-surrounding,
" so it's handled by the functions below
let surround_{char2nr("f")} = "\1func: \1(\r)"
" Mappings
nmap dsf :call DSurroundFunc()<CR>
@dwijnand
dwijnand / reload.sbt
Last active October 6, 2017 07:25
Stick it in ~/.sbt/0.13/reload.sbt
def buildFiles(b: File) = ((b * "*.sbt") +++ ((b / "project") ** ("*.scala" | "*.sbt")) filter (_.isFile))
def genBuildFilesHashesAt(base: File) = buildFiles(base).get.map(f => f -> (Hash toHex Hash(f))).toMap
def genBuildFilesHashes(units: Map[URI, LoadedBuildUnit]) =
(units.values flatMap (_.defined) map (_._2.base) flatMap genBuildFilesHashesAt).toMap.##
val buildFilesHashes = settingKey[Int]("") in Global
buildFilesHashes := genBuildFilesHashes(loadedBuild.value.units)
shellPrompt in Global := (s =>
@cryzed
cryzed / fix-infinality.md
Last active May 8, 2024 17:00
A set of instructions on how to fix the harfbuzz + Infinality issue and restoring good-looking, Infinality-like font rendering.

Disclaimer: Please follow this guide being aware of the fact that I'm not an expert regarding the things outlined below, however I made my best attempt. A few people in IRC confirmed it worked for them and the results looked acceptable.

Attention: After following all the steps run gdk-pixbuf-query-loaders --update-cache as root, this prevents various gdk-related bugs that have been reported in the last few hours. Symptoms are varied, and for Cinnamon the DE fails to start entirely while for XFCE the icon theme seemingly can't be changed anymore etc.

Check the gist's comments for any further tips and instructions, especially if you are running into problems!

Screenshots

Results after following the guide as of 11.01.2017 13:08:

Getting Started in Scala

This is my attempt to give Scala newcomers a quick-and-easy rundown to the prerequisite steps they need to a) try Scala, and b) get a standard project up and running on their machine. I'm not going to talk about the language at all; there are plenty of better resources a google search away. This is just focused on the prerequisite tooling and machine setup. I will not be assuming you have any background in JVM languages. So if you're coming from Python, Ruby, JavaScript, Haskell, or anywhere…  I hope to present the information you need without assuming anything.

Disclaimer It has been over a decade since I was new to Scala, and when I was new to Scala, I was coming from a Java and Ruby background. This has probably caused me to unknowingly make some assumptions. Please feel free to call me out in comments/tweets!

One assumption I'm knowingly making is that you're on a Unix-like platform. Sorry, Windows users.

Getting the JVM

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@pathikrit
pathikrit / README.md
Last active April 24, 2021 17:36
My highly opinionated list of things needed to build an app in Scala