Skip to content

Instantly share code, notes, and snippets.

View dominikb1888's full-sized avatar

Dominik Böhler dominikb1888

View GitHub Profile
#![deny(clippy::all)]
#![deny(clippy::nursery)]
#![allow(clippy::cast_possible_truncation)]
use std::{
collections::hash_map::RandomState,
hash::{BuildHasher, Hash, Hasher},
};
#[derive(Debug, Clone)]
@dabeaz
dabeaz / lala.py
Last active August 20, 2024 07:20
Some lambdas
# Author: David Beazley (https://www.dabeaz.com)
# Twitter: @dabeaz
from functools import reduce
run = lambda s: reduce(lambda *_:..., iter(lambda s=[s]:
(_:=s.pop()(),s.append(_))[0], None))
const = lambda v,c : lambda: c(v)
add = lambda x,y,c : lambda: c(x+y)
mul = lambda x,y,c : lambda: c(x*y)
@adlerweb
adlerweb / deploy_yay.sh
Last active June 25, 2022 11:18
Unattended deployment of yay on a system. Useful when generating VMs on the fly.
#!/bin/bash
version=$(git -c 'versionsort.suffix=-' ls-remote --exit-code --refs --sort='version:refname' --tags https://github.com/Jguer/yay.git '*.*.*' | tail --lines=1 | cut --delimiter='/' --fields=3 | tr -d 'v')
url="https://github.com/Jguer/yay/releases/download/v${version}/yay_${version}_x86_64.tar.gz"
tmp=$(mktemp -d)
if [ -d "$tmp" ]
then
if [ "$(ls -A $tmp)" ]; then
echo "Oops. Temporary directory $tmp is not empty"
@imankulov
imankulov / sqlalchemy_with_pydantic.py
Last active November 8, 2025 14:34
Using pydantic models as SQLAlchemy JSON fields (convert beween JSON and pydantic.BaseModel subclasses)
#!/usr/bin/env ipython -i
import datetime
import json
from typing import Optional
import sqlalchemy as sa
from sqlalchemy.orm import declarative_base, sessionmaker
from sqlalchemy.dialects.postgresql import JSONB
from pydantic import BaseModel, Field, parse_obj_as
@sts10
sts10 / rust-command-line-utilities.markdown
Last active March 14, 2026 17:33
A curated list of command-line utilities written in Rust

A curated list of command-line utilities written in Rust

Note: I have moved this list to a proper repository. I'll leave this gist up, but it won't be updated. To submit an idea, open a PR on the repo.

Note that I have not tried all of these personally, and cannot and do not vouch for all of the tools listed here. In most cases, the descriptions here are copied directly from their code repos. Some may have been abandoned. Investigate before installing/using.

The ones I use regularly include: bat, dust, fd, fend, hyperfine, miniserve, ripgrep, just, cargo-audit and cargo-wipe.

  • atuin: "Magical shell history"
  • bandwhich: Terminal bandwidth utilization tool
@benevidesh
benevidesh / zn
Last active March 12, 2024 16:10
Zettelkasten Workflow (WIP)
#!/usr/bin/bash
# zn - as zettell
# new export variables EDITOR for your editor and
#+ NOTES for your notes folder.
main () {
note_id=$(date +'%Y%m%d%H%M%S')
$EDITOR $NOTES/"$note_id".md
}
@jmatsushita
jmatsushita / README
Last active December 21, 2025 02:10
Setup nix, nix-darwin and home-manager from scratch on an M1 Macbook Pro
###
### [2023-06-19] UPDATE: Just tried to use my instructions again on a fresh install and it failed in a number of places.
###. Not sure if I'll update this gist (though I realise it seems to still have some traffic), but here's a list of
###. things to watch out for:
### - Check out the `nix-darwin` instructions, as they have changed.
### - There's a home manager gotcha https://github.com/nix-community/home-manager/issues/4026
###
# I found some good resources but they seem to do a bit too much (maybe from a time when there were more bugs).
# So here's a minimal Gist which worked for me as an install on a new M1 Pro.
  1. Generate the file:
$ awk 'BEGIN { for(c=0;c<10000000;c++) printf "<p>LOL</p>" }' > 100M.html
$ (for I in `seq 1 100`; do cat 100M.html; done) | pv | gzip -9 > 10G.boomgz
  1. Check it is indeed good:
@MarcSkovMadsen
MarcSkovMadsen / holoviz_linked_brushing.py
Last active October 23, 2024 09:30
Linked brushing with HoloViz
# pip install panel==0.12.4 bokeh==2.4.0 holoviews==1.14.6 hvplot==0.7.3 shapely==1.7.1
# panel serve holoviz_linked_brushing.py --autoreload --show
import hvplot.pandas
import holoviews as hv
import panel as pn
from bokeh.sampledata.iris import flowers
pn.extension(sizing_mode="stretch_width")
hv.extension("bokeh")
@4Maarifa
4Maarifa / autocrop.ts
Created December 1, 2020 23:23 — forked from bbernstein/autocrop.ts
Zoom auto-crop algorithm
type LayoutDescription = {
area: number;
cols: number;
rows: number;
width: number;
height: number;
}
type CropValues = {
left: number;