Skip to content

Instantly share code, notes, and snippets.

View fkei's full-sized avatar
😀

fkei fkei

😀
View GitHub Profile
@nymous
nymous / README.md
Last active May 1, 2024 21:18
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

@digitalkaoz
digitalkaoz / index.js
Created December 20, 2017 21:32
gatsby in aws lambda
const AWS = require("aws-sdk");
const {link} = require("linkfs");
const mock = require('mock-require');
const fs = require('fs');
const tmpDir = require('os').tmpdir();
exports.handler = (event, context) => {
rewriteFs();
invokeGatsby(context);
}
@samthor
samthor / importPolyfill.js
Last active February 6, 2024 02:18 — forked from surma/importPolyfill.js
Polyfill for dynamic module loading that supports onerror
// usage:
// importScript('./path/to/script.js').then((allExports) => { .... }));
function importScript(path) {
let entry = window.importScript.__db[path];
if (entry === undefined) {
const escape = path.replace(`'`, `\\'`);
const script = Object.assign(document.createElement('script'), {
type: 'module',
textContent: `import * as x from '${escape}'; importScript.__db['${escape}'].resolve(x);`,
});
@lopezjurip
lopezjurip / Caddyfile
Last active June 24, 2017 22:18
Feathers.js + Docker + Caddy | SSL + HTTP2
your.domain.com {
proxy / web:3030 {
proxy_header Host {host}
proxy_header X-Real-IP {remote}
proxy_header X-Forwarded-Proto {scheme}
websocket
}
tls youremail@gmail.com
}
@everpeace
everpeace / Why People Want Microservices.md
Last active November 8, 2022 10:37
マイクロサービス化が進む背景について考えてみた

マイクロサービス化が進む背景について考えてみた

最近マイクロサービスって流行ってますよね。バズってると言ってもいいくらい。

個人的には、「マイクロサービスって結局何なの?」とか、「SOAと何が違うわけ?」とかいう議論は苦手です。

でも「なんでみんなマイクロサービスで作りたいのか?なんでマイクロサービスで作られるサービスが多いのか?」にはすごく興味があるんです。

僕は今、シリコンバレーにある日系SIerの小さな子会社で駐在員をやっていますが、このエリアに居ると、とにかく最近、

「サービス全体が、独立した小さなサービスの集合で構成されるようになってきている」

@nikuyoshi
nikuyoshi / build-crosscompile-env.sh
Last active November 20, 2022 13:17
Goのクロスコンパイル環境構築のためのシェルスクリプト
#!/bin/sh
# Environment list
# $GOOS $GOARCH
# darwin 386
# darwin amd64
# freebsd 386
# freebsd amd64
# freebsd arm
# linux 386
@sluchin
sluchin / .emacs.el
Last active December 15, 2015 17:49
;;; GNU Global
;; wget http://tamacom.com/global/global-6.2.8.tar.gz
(when (and (executable-find "global")
(locate-library "gtags"))
(autoload 'gtags-mode "gtags" "Gtags facility for Emacs." t)
(add-hook 'gtags-select-mode-hook
(lambda ()
(when (fboundp 'hl-line-mode) ; 強調表示
(hl-line-mode 1))))
(let ((hook (lambda ()
@hakobe
hakobe / backbone_sample.html
Last active December 15, 2015 04:59
3種類の方式のクライアントサイドMVCをつかった疑似TODOアプリ実装
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<head>
<style>
body {
margin : 0;
padding : 0;
background-color: #eee;
font-size: 25px;
@knzm
knzm / gist:5185369
Last active December 30, 2020 14:34

Python パッケージングのこれまでとこれから

第1世代: distutils

$ python setup.py build