Skip to content

Instantly share code, notes, and snippets.

@jonas-schievink
jonas-schievink / disable-power-button.patch
Last active June 7, 2018 16:21
pfSense patches for use with the "System Patches" package
--- /etc/sysctl.conf 2018-05-27 18:31:54.209664000 +0200
+++ /etc/sysctl.conf 2018-05-27 18:53:09.071470000 +0200
@@ -1,9 +1,11 @@
# $FreeBSD$
#
# This file is read when going to multi-user and its contents piped thru
# ``sysctl'' to adjust kernel values. ``man 5 sysctl.conf'' for details.
#
+hw.acpi.power_button_state=NONE
@jonas-schievink
jonas-schievink / output-native-armv6.txt
Last active July 11, 2018 20:10
Passing multiple control messages at once over a Unix socket
creating socketpair
fds: 3 4
encoded cmsgs into 40 byte buf:
18 00 00 00 01 00 00 00 02 00 00 00 a7 2c 00 00 e8 03 00 00 e8 03 00 00 10 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00
re-decode msgs without going through socket:
raw control buffer size: 40 bytes
cmsg 1:
cmsg lvl: 1 (SOL_SOCKET = 1)
cmsg type: 2 (SCM_RIGHTS = 1, SCM_CREDENTIALS = 2)
cmsg len: 24 (for 1 int = 16, for ucred = 24)
@jonas-schievink
jonas-schievink / main.rs
Last active November 30, 2018 17:59
Default log level for (pretty_)env_logger
extern crate env_logger;
extern crate log;
use std::env;
fn main() {
// By default, log all `info!` messages and higher, in all modules and crates.
// Can be overridden by specifying the `RUST_LOG` environment variable.
if env::var_os("RUST_LOG").is_none() {
env_logger::Builder::from_default_env()
@jonas-schievink
jonas-schievink / metadiff.sh
Last active August 2, 2019 11:13
Compare metadata produced by successive invocations of rustc
#!/bin/bash
set -e
if [ -z "$RUSTC" ]; then
RUSTC=rustc
fi
crate="$1"
<html>
<head>
<title>Cargo Build Timings — rustc-main 0.0.0</title>
<meta charset="utf-8">
<style type="text/css">
html {
font-family: sans-serif;
}
//! NRVO on acyclic CFGs.
use crate::transform::{MirPass, MirSource};
use rustc_middle::mir::visit::Visitor;
use rustc_middle::mir::{
read_only, Body, BodyAndCache, Constant, Local, LocalKind, Location, Operand, Place, Rvalue,
StatementKind, Statement,
};
use rustc_middle::ty::TyCtxt;
use rustc_index::vec::IndexVec;
// MIR for `basics` after Nrvo
fn basics(_1: (f32,)) -> f32 {
let mut _0: f32; // return place in scope 0 at /home/jonas/dev/rust/src/test/ui/consts/const_let_eq_float.rs:11:34: 11:37
let _2: f32; // in scope 0 at /home/jonas/dev/rust/src/test/ui/consts/const_let_eq_float.rs:11:18: 11:19
let mut _4: f32; // in scope 0 at /home/jonas/dev/rust/src/test/ui/consts/const_let_eq_float.rs:14:9: 14:10
let mut _6: f32; // in scope 0 at /home/jonas/dev/rust/src/test/ui/consts/const_let_eq_float.rs:17:18: 17:19
let mut _8: f32; // in scope 0 at /home/jonas/dev/rust/src/test/ui/consts/const_let_eq_float.rs:20:22: 20:23
let mut _9: f32; // in scope 0 at /home/jonas/dev/rust/src/test/ui/consts/const_let_eq_float.rs:21:9: 21:10
scope 1 {
@jonas-schievink
jonas-schievink / notes.md
Created April 29, 2020 17:53
Contributing to Rust

Contribution Workflows

  • Doc-only changes:

    ./x.py doc --stage=0 src/libstd

  • libstd-only changes:

    ./x.py check --stage=0 src/libstd

@jonas-schievink
jonas-schievink / README.md
Last active April 26, 2021 15:37
Wireshark USB

First, run sudo modprobe usbmon.

Now Wireshark should show usbmon0-N capture devices.

They correspond to USB buses (see lsusb), so select the one on which the target device is attached.

Now filter out the right device on the bus by writing a filter.

usb.src and usb.dst are the packet's source and destination address, one of which will always be "host".

# A minimal Fish prompt based on the gitstatus prompt.
# Original gitstatus prompt from https://github.com/godfat/fish_prompt-gitstatus
# Adopted by OMF at https://github.com/oh-my-fish/theme-gitstatus
function _git_branch_name
echo (command git symbolic-ref HEAD 2> /dev/null | sed -e 's|^refs/heads/||')
end
function _git_status_symbol
set -l git_status (git status --porcelain 2> /dev/null)