Skip to content

Instantly share code, notes, and snippets.

@boxofrox
boxofrox / .bashrc
Created February 10, 2020 18:52 — forked from kevinoid/.bashrc
GnuPG pinentry script for terminal or graphical interface based on $PINENTRY_USER_DATA.
# ~/.bashrc: executed by bash(1) for non-login shells.
# If file exists (likely) copy fragment below into existing script:
# If stdin is a terminal
if [ -t 0 ]; then
# Set GPG_TTY so gpg-agent knows where to prompt. See gpg-agent(1)
export GPG_TTY="$(tty)"
# Set PINENTRY_USER_DATA so pinentry-auto knows to present a text UI.
export PINENTRY_USER_DATA=USE_TTY=1
@boxofrox
boxofrox / readme.md
Last active October 31, 2020 16:57
Debugging streaming audio over TCP
@boxofrox
boxofrox / Cargo.toml
Last active December 2, 2019 00:31
rustc E0277 when using async block vs without.
[package]
name = "debug-await-method-chaining"
version = "0.1.0"
authors = ["boxofrox"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tokio = { version = "0.2", features = [ "full" ] }
@boxofrox
boxofrox / .gitignore
Last active November 12, 2019 20:55
Print file limits for systemd services.
result
*.qcow2
@boxofrox
boxofrox / cargo_test.txt
Last active March 15, 2018 17:50
simple shell parser in Rust using combine crate (not working)
$ cargo test
Compiling csvmap v0.1.0 (file:///home/charetjc/files/development/rust/tinker/csvmap)
Finished dev [unoptimized + debuginfo] target(s) in 2.34 secs
Running target/debug/deps/csvmap-cdc7458d4bf17d5e
running 5 tests
test tests::can_parse ... ok
test tests::can_parse_single_quoted_shell_arg ... ok
test tests::can_parse_double_quoted_shell_arg ... ok
test tests::can_parse_any_shell_arg ... FAILED
@boxofrox
boxofrox / playground.rs
Created March 13, 2018 18:36 — forked from anonymous/playground.rs
Rust code shared from the playground
#[macro_use] extern crate nom;
fn to_s(i: Vec<u8>) -> String {
String::from_utf8_lossy(&i).into_owned()
}
named!( single_quoted_shell_arg(&[u8]) -> String
, map!( delimited!( char!('\'')
, escaped_transform!( take_until!("\\'")
, "\\"
@boxofrox
boxofrox / install.txt
Last active December 4, 2017 19:30
Installing pijul 0.8.3 on NixOS
# Setup rust overlay to gain access to rust nightlies with fix for jobserver error
cd $HOME
git clone https://github.com/mozilla/nixpkgs-mozilla.git
cd nixpkgs-mozilla
./rust-overlay-install.sh
# Install rust nightly (swap nixos with nixpkgs if not on NixOS?)
nix-env -iA nixos.latest.rustChannels.nightly.rust
# Setup environment to link openssl
@boxofrox
boxofrox / a-rust-utils.nix
Created December 1, 2017 17:38
Example result for extracting shell code from rust-utils.nix
# Code for buildRustCrate, a Nix function that builds Rust code, just
# like Cargo, but using Nix instead.
#
# This can be useful for deploying packages with NixOps, and to share
# binary dependencies between projects.
{ lib, buildPlatform, stdenv, defaultCrateOverrides, fetchCrate, ncurses, rustc }:
let buildCrate = { crateName, crateVersion, crateAuthors, buildDependencies,
dependencies, completeDeps, completeBuildDeps,
@boxofrox
boxofrox / crates-overlay.nix
Last active November 20, 2017 17:37
carnix bug: example: missing cargo environment variables for compiling http-box crate
# ~/.config/nixpkgs/overlays/crates-overlay.nix
self: super:
{
rustHttpBox = super.callPackage ./crates/httpbox.nix { };
}
@boxofrox
boxofrox / a-question.md
Created November 16, 2017 17:30
How to compute the SHA256 hash for a new Nix package?

How does one find the sha256 of a new package?

I read that I should put a garbage sha256 into my package file, build it, and nix will report the correct sha256 I should use.

I put sha256 = "01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b" into my package file as the garbage sha256.

When I built the package, the error reports: