Skip to content

Instantly share code, notes, and snippets.

View cablehead's full-sized avatar

Andy Gayton cablehead

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
@jimmychu0807
jimmychu0807 / string-conversion.rs
Created November 21, 2019 10:20
Conversion between String, str, Vec<u8>, Vec<char> in Rust
use std::str;
fn main() {
// -- FROM: vec of chars --
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}'];
// to String
let string1: String = src1.iter().collect::<String>();
// to str
let str1: &str = &src1.iter().collect::<String>();
// to vec of byte
@progrium
progrium / fbpost
Last active August 17, 2018 19:43
Facebook no longer allows news feed posts to be added programmatically via API. But we can still post them programmatically... https://medium.com/@progrium/the-only-way-you-can-automate-facebook-posts-now-bd3a40fd1c4b
#!/usr/bin/env node
// Usage:
// Login manually, saving your authenticated session in "data":
// $ ./fbpost --login
//
// Now you can post whatever you want via argument:
// $ ./fbpost "Hello world, this is a post!"
//
(async() => {
const puppeteer = require('puppeteer');
@RichardBronosky
RichardBronosky / README.MD
Last active April 26, 2025 17:38
cb - A leak-proof tee to the clipboard - Unify the copy and paste commands into one intelligent chainable command.

cb

A leak-proof tee to the clipboard

This script is modeled after tee (see [man tee][2]) and works on Linux, macOS, Cygwin, WSL/WSL2

It's like your normal copy and paste commands, but unified and able to sense when you want it to be chainable.

This project started as an answer to the StackOverflow question: [How can I copy the output of a command directly into my clipboard?][3]