Skip to content

Instantly share code, notes, and snippets.

/**
* This is an updated 1.0.1 version
*
* Changes: `template:lorem` became `hx-template#lorem`
*
* === Original description:
*
* HTMX Template Extension
* by Katrina Scialdone (https://github.com/katrinakitten)
*
@imbolc
imbolc / main.rs
Created July 15, 2022 12:43
Statically checked sqlxmq context and job list
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use std::fmt::Debug;
use std::marker::PhantomData;
use std::sync::Arc;
struct JobRegistry<J, C> {
jobs: PhantomData<J>,
context: Arc<C>,
}
@imbolc
imbolc / Cargo.toml
Created February 16, 2021 13:51
Rust logging into journald configured by the `RUST_LOG` environment variable
anyhow = "1"
log = "0.4"
tracing = { git = "https://github.com/tokio-rs/tracing", rev = "f81426b" }
tracing-subscriber = { git = "https://github.com/tokio-rs/tracing", rev = "f81426b" }
tracing-journald = { git = "https://github.com/tokio-rs/tracing", rev = "f81426b" }
@imbolc
imbolc / README.md
Last active September 2, 2020 07:56
Channels-wrapped django-3.1 native async views hang on internal requests

The issue

Django native async views can handle multiple concurrent requests to another internal pages. But wrapped in channels application it hangs on a low level of concurrency. It doesn't happen with external requests though.

Preparation

pip install uvicorn aiohttp channels channels-redis
@imbolc
imbolc / hello_flask.py
Created April 24, 2020 03:05
Flask vs Japronto hello-world benchmark
from flask import Flask, jsonify
app = Flask(__name__)
@app.route("/")
def hello_world():
return jsonify(hello="world")

Flake8 complains with 4:5: F401 'pydantic' imported but unused about this code:

from typing import TYPE_CHECKING, Optional, Type

if TYPE_CHECKING:
    import pydantic

def f(*, model: Optional[Type["pydantic.BaseModel"]] = None):
 pass
@imbolc
imbolc / httpx_aiohttp.py
Created March 1, 2020 10:47
Httpx vs aiohttp benchmark
from starlette.applications import Starlette
from starlette.routing import Route
from starlette.responses import PlainTextResponse
import httpx
import aiohttp
HOST, PORT = "localhost", 8000
URL = f"http://{HOST}:{PORT}/"
@imbolc
imbolc / keybase.md
Created May 24, 2019 22:09
keybase.md

Keybase proof

I hereby claim:

  • I am imbolc on github.
  • I am imbolc (https://keybase.io/imbolc) on keybase.
  • I have a public key ASCm5CHgFY1EKuPBDsM6EiRk_E4K_gCyigotWFgtEICo9Ao

To claim this, I am signing this object:

@imbolc
imbolc / App.svelte
Last active March 25, 2019 07:02
`bind:group` does not work with nested components
{#each menu as flavour}
<Flavour {flavour}/>
{/each}
<script>
import Flavour from "./Flavour.svelte"
let menu = [
'Cookies and cream',
'Mint choc chip',
'Raspberry ripple'
@imbolc
imbolc / dot.py
Last active January 7, 2019 07:55
Dot product on rust vs numpy
import time
import numpy as np
tm = time.time()
size = 10000
cycles = 100
matrix = np.ones((size, size), dtype=int)
vector = np.array([-1 if x % 2 else 1 for x in range(size)])
for i in range(cycles):