Skip to content

Instantly share code, notes, and snippets.

View Ugbot's full-sized avatar
🏠
Working from home

Ben Gamble Ugbot

🏠
Working from home
View GitHub Profile
@cshenton
cshenton / d3d11_triangle.c
Last active May 14, 2024 16:09
D3D11 Triangle in C99
#include <assert.h>
#define COBJMACROS
#include <windows.h>
#include <d3d11_1.h>
#include <d3dcompiler.h>
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define TITLE "D3D11 Triangle C"
@cshenton
cshenton / block_allocator.odin
Last active March 25, 2024 00:45
Allocator based on Sebastian Aaltonen's Offset Allocator, for suballocating GPU heaps
package block_allocator
// Allocator based on Sebastian Aaltonen's Offset Allocator:
// https://github.com/sebbbi/OffsetAllocator/blob/main/offsetAllocator.cpp
import "core:fmt"
import "core:math/bits"
import "core:math/rand"
assert_allocator_layout_good :: proc(allocator: ^Block_Allocator) {
@jdah
jdah / wfc.hpp
Created August 5, 2022 15:18
Wave Function Collapse
#pragma once
#include "util/types.hpp"
#include "util/std.hpp"
#include "util/ndarray.hpp"
#include "util/collections.hpp"
#include "util/rand.hpp"
#include "util/hash.hpp"
#include "util/assert.hpp"
#include "util/bitset.hpp"
@nymous
nymous / README.md
Last active May 28, 2024 02:02
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

@richiejarvis
richiejarvis / gist:1dd18c1e905df850d508959c6b348d7e
Created March 29, 2022 12:44
Example python3 publish via Ably
#!/usr/bin/env python3
from __future__ import print_function
import sys
import os
import time
import asyncio
from ably import AblyRest
my_path = os.path.abspath(__file__) # Find the full path of this python script
# get the path location only (excluding script name)
base_dir = my_path[0:my_path.rfind("/")+1]
@Phate334
Phate334 / docker-compose.yml
Last active March 2, 2024 01:33
JanusGraph and OpenSearch
version: "3"
services:
janusgraph:
image: janusgraph/janusgraph:0.6.2
container_name: jce-janusgraph
env_file:
- janusgraph.env
ports:
- "8182:8182"
@nylonee
nylonee / Kafka Rest Proxy API.postman_collection.json
Created March 20, 2021 18:39
Kafka Rest Proxy Postman Collection
{
"info": {
"_postman_id": "07c117b0-7200-41b9-94fc-5836a6b08d7b",
"name": "Kafka Rest Proxy API",
"description": "Adapted from https://docs.confluent.io/current/kafka-rest/api.html",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "v2",
@inlife
inlife / uv_read_file.c
Created February 13, 2017 13:58
Sample for reading a file asynchronously using libuv
// Sample for reading a file asynchronously using libuv
// taken from https://www.snip2code.com/Snippet/247423/Sample-for-reading-a-file-asynchronously
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <uv.h>
static uv_fs_t openReq;
static uv_fs_t readReq;
@kbarbary
kbarbary / simd-vmv.c
Created October 8, 2016 18:29
Vector-matrix-vector multiplication with SIMD (AVX) intrinsics
// Doing the operation:
//
// | a a a a | | y |
// x * A * y = [ x x x x ] | a a a a | | y |
// | a a a a | | y |
// | a a a a | | y |
//
// with SIMD intrinics (specifically AVX).
//
// adapted from https://gist.github.com/rygorous/4172889
@drmalex07
drmalex07 / README-setup-tunnel-as-systemd-service.md
Last active June 4, 2024 20:50
Setup a secure (SSH) tunnel as a systemd service. #systemd #ssh #ssh-tunnel #ssh-forward

README

Create a template service file at /etc/systemd/system/secure-tunnel@.service. The template parameter will correspond to the name of target host:

[Unit]
Description=Setup a secure tunnel to %I
After=network.target