Skip to content

Instantly share code, notes, and snippets.

View steveklabnik's full-sized avatar
🦀
Rustacean

Steve Klabnik steveklabnik

🦀
Rustacean
View GitHub Profile
@steveklabnik
steveklabnik / README.md
Last active February 6, 2025 22:16
An {#trycmdinclude} for mdbook (based on work by @bryceberger)

This is a little thing I put together to let you write mdbooks where you can test the output of CLI code examples with trycmd.

I've provided an example .trycmd, mdbook chapter page, and the mdbook plugin. Please note that the example .trycmd has a bunch of odd stuff in it; I'm using this for a jj tutorial, and you need to do certain things to ensure reproducibility there.

I'm not making this into a github repo yet because there's a few caveats and i want you to understand them before you give it a go:

  1. this, like trycmd generally, executes whatever you tell it to in a tempdir. Don't try to colorize the output of rm -rf / --no-preserve-root and then get mad at me.
  2. my code is bad. i put it together last night and this morning. no error handling, debug lines still in there, i didn't even run rustfmt or clippy.
  3. unlike {#include in rustdoc, the syntax highlighting can add lines, so the lines don't correspond to the .trycmd directly. It'll take some trial and error to get them right.
  4. other c
@steveklabnik
steveklabnik / aegis.txt
Last active April 21, 2024 03:58
aegis spreadsheet -> DIM wishlist
title:Aegis Endgame List
description:https://docs.google.com/spreadsheets/d/1JM-0SlxVDAi-C6rGVlLxa-J1WGewEeL8Qvq4htWZHhY/edit#gid=1767006917
// Dragon's Breath (pve)
//notes: tags:pve
dimwishlist:item=17096506&perks=1478423395,1996142143,2727957645,1067908860
// Raconteur (god-pve)
//notes: tags:god-pve
@steveklabnik
steveklabnik / oil.md
Last active January 15, 2021 21:32
Why is the price of oil negative?

so, why is oil's price negative?

(note: I am a software developer who has an interest in finance. This is my understanding. I am not a professional.)

first, what does that even mean? so, the "price of oil" is the price of "WTI Crude", which is a specific kind of oil. There are multiple kinds of oil with multiple prices.

Why is it negative? to understand this, we also have to understand why WTI is the price of oil: that is, it's the kind of oil that underpins the New York Mercantile Exchange's oil futures contracts. The NYMEX is kind of like the stock market, but for commodities, aka stuff.

@steveklabnik
steveklabnik / vectorlinkedlist.rs
Created September 7, 2018 21:12
yeah, it's a linked list with indices in a vector
#[derive(Debug)]
pub struct IndexList<T> {
contents: Vec<Option<Entry<T>>>,
}
#[derive(Debug)]
pub struct Entry<T> {
item: T,
next: Option<usize>,
prev: Option<usize>,
@steveklabnik
steveklabnik / linkedlist.rs
Created September 5, 2018 19:37
yeah it's a linked list
use std::ptr;
pub struct DoubleLinkedList<T> {
head: *mut Entry<T>,
tail: *mut Entry<T>,
}
pub struct Entry<T> {
item: T,
next: *mut Entry<T>,
@steveklabnik
steveklabnik / main.rs
Last active January 16, 2018 13:32 — forked from jefftime/main.rs
#![feature(lang_items, start)]
#![no_std]
#[link(name = "c")]
extern {
fn puts(s: *const u8) -> isize;
fn abort() -> !;
}
#[lang = "panic_fmt"]
#![feature(lang_items)]
#![no_std]
#[no_mangle]
pub fn add_one(x: i32) -> i32 {
x + 1
}
// needed for no_std
@steveklabnik
steveklabnik / main.rs
Created October 25, 2017 16:06
The Results of the Expressive C++17 Coding Challenge in Rust
use std::env;
use std::io;
use std::io::prelude::*;
use std::fs::File;
#[derive(Debug)]
enum Error {
Io(io::Error),
Program(&'static str),
}
@steveklabnik
steveklabnik / boot.asm
Created July 6, 2017 16:16 — forked from faraazahmad/boot.asm
error on make
global start
section .text
bits 32
start:
; Point the first entry of the level 4 page table to the first entry in the
; p3 table
mov eax, p3_table
or eax, 0b11 ;
mov dword [p4_table + 0], eax