Skip to content

Instantly share code, notes, and snippets.

View 0atman's full-sized avatar
🦀
Oxidising

Tristram Oaten 0atman

🦀
Oxidising
View GitHub Profile
@0atman
0atman / configuration.nix
Last active April 20, 2024 21:45
A rebuild script that commits on a successful build
{
config,
pkgs,
options,
...
}: let
hostname = "oatman-pc"; # to alllow per-machine config
in {
networking.hostName = hostname;
@0atman
0atman / benchmark.md
Last active April 17, 2024 11:25
My standard 'install a specific ripgrep' benchmark, now with hyperfine and zero install with nix

With Rust installed natively

(through https://rustup.rs)

hyperfine --warmup=1 'cargo install -f ripgrep@14.1.0'

without installation on any machine with nix

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#![allow(dead_code, unused_variables)]
fn main() {}
struct Machine<State> {
data: Vec<u16>,
state: State,
}
struct State1 {}
struct State2 {}
@0atman
0atman / scoped_threads.rs
Last active March 13, 2024 11:05
Unlike non-scoped threads, scoped threads can borrow non-'static data, as the scope guarantees all threads will be joined at the end of the scope.
use std::thread;
struct User {
age: u16,
}
fn simple_thread() {
let user = User { age: 30 };
// thread::spawn(|| &user); // can't borrow `user` as thread may outlive current function
thread::spawn(|| user); // can only move into thread, then it's gone.
@0atman
0atman / PR-Template.md
Created December 4, 2023 09:17
I'd love to learn more about git-native issues and projects, though my first thought is that if they're stored in markdown, you can build them in whatever editors you would like! Here's a mockup

head: 0atman:branch-name-with-your-changes assignee: 0atman base: local-branch-name-on-this-repo draft: true issue: linked issue url? reviewers:

  • 0atman
  • user2
  • user3
@0atman
0atman / README.md
Last active November 14, 2023 00:55
The Testable Documentation Manifesto

#! blaze sh

The Testable Documentation Manifesto

One of the problems with tech documentation (api, installation instructions etc) is that they get stale. APIs change, software and plugins alter their interface and commands, and websites go away.

To solve this, I propose we write our documentation in a way that can be executed, or verified.

Luckily, I wrote blaze to execute codeblocks inside of markdown, which means that with a little help from a few common unix tools, we can solve this problem.

@0atman
0atman / set-gnome-shell-hotkeys.sh
Created September 29, 2014 10:19
i3 gnome-shell keyboard bindings
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-1 "['<alt>1']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-2 "['<alt>2']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-3 "['<alt>3']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-4 "['<alt>4']"
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-1 "['<alt><shift>1']"
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-2 "['<alt><shift>2']"
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-3 "['<alt><shift>3']"
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-4 "['<alt><shift>4']"
@0atman
0atman / typer.rs
Created June 12, 2022 08:39
Auto-typer from Lost Terminal
use std::fs;
use std::io::{self, BufRead, Write};
use std::{thread, time};
/// stdout readline implementation
fn wait() {
io::stdin().lock().lines().next();
}
/// Type the script at 300wpm
@0atman
0atman / thread.py
Last active March 29, 2023 19:17 — forked from anonymous/chain.py
clojure `->`-style functional threading
from functools import reduce
def thread(*args):
"""
Functional thread ->, inspired by clojure and https://stackoverflow.com/a/17122666/333294
Toy example that only works for functions or airity 1
"""
caller = lambda x, y: y(x)
return reduce(caller, args[1:], args[0])