Skip to content

Instantly share code, notes, and snippets.

View AaronM04's full-sized avatar

Aaron Miller AaronM04

  • Orange County, CA
  • 16:35 (UTC -07:00)
View GitHub Profile
@AaronM04
AaronM04 / window_arrange.py
Created July 10, 2022 06:33 — forked from YuriyGuts/window_arrange.py
Save or restore X11 desktop window arrangement using the wmctrl package
#!/usr/bin/env python3
"""
Save or restore X11 desktop window arrangement.
Requires the `wmctrl` package to work.
Examples:
window_arrange.py save
window_arrange.py restore
window_arrange.py --profile ~/.winlayout-home save
@AaronM04
AaronM04 / battmon.sh
Last active March 24, 2021 03:46
Flicker-free battery monitor for OpenBSD
#!/bin/sh
# Flicker-free battery monitor for OpenBSD. Requires Python 3
# One could somewhat easily rewrite the Python part in Perl if they want to use base exclusively.
BATT=acpibat0
while true; do
RATE="$(sysctl -n hw.sensors.$BATT.power0)"
RATE="${RATE%" ("*}"
@AaronM04
AaronM04 / sndio_test.c
Created May 26, 2020 03:39
sndio test
#include <stdio.h>
#include <sndio.h>
#include <stdlib.h>
#include <errno.h>
#define BUF_SAMPLES 4800
#define OUTFILE "recorded.pcm"
#define ITERATIONS 500
// ffmpeg -y -f s16le -ar 48000 -ac 1 -i recorded.pcm recorded.mp3 && mpv recorded.mp3
@AaronM04
AaronM04 / Cargo.toml
Last active October 8, 2023 07:14
Pretty Print XML in Rust
[package]
name = "xmlformat"
version = "0.1.0"
authors = ["aaron"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
xmltree = "0.10"
[package]
name = "filefuture"
version = "0.1.0"
authors = ["you"]
edition = "2018"
[dependencies]
futures = "*"
@AaronM04
AaronM04 / wow.rs
Created February 24, 2019 00:34
Rust does not compare function argument types when determining which trait's implementation to use
/// Won't compile:
///
/// $ rustc wow.rs
/// error[E0034]: multiple applicable items in scope
/// --> wow.rs:33:9
/// |
/// 33 | foo.wow("TSecond is str");
/// | ^^^ multiple `wow` found
/// |
/// note: candidate #1 is defined in an impl of the trait `TFirst` for the type `Foo`
@AaronM04
AaronM04 / linked_list.rs
Last active March 2, 2020 03:38 — forked from codesections/linked_list.rs
A simple linked list implemented in Rust
#[derive(Debug)]
pub struct LinkedList {
head: Option<Box<Node>>,
tail: Option<*mut Node>,
}
#[derive(Debug)]
struct Node {
value: i32,
next: Option<Box<Node>>,
}
@AaronM04
AaronM04 / bitgrid_iter.rs
Last active June 26, 2018 04:04
testing BitGrid iterators
// testing bit grid iterators
// $ cargo test
type BitGrid = Vec<Vec<u64>>;
fn new_bitgrid(width_in_words: usize, height: usize) -> BitGrid {
assert!(width_in_words != 0);
assert!(height != 0);
let mut result: BitGrid = Vec::new();
@AaronM04
AaronM04 / thread_pool.rb
Created January 8, 2018 19:22
Simple Ruby thread pool
class ThreadPool
def initialize(num_threads)
@tasks = Queue.new # contains either blocks to run, or :terminate
@threads = []
@terminated = false # only used to stop new work from being enqueued
num_threads.times do
@threads << Thread.new{ process }.run
end
end
@AaronM04
AaronM04 / astroblasto_line595.rs
Created December 15, 2017 04:45
astroblasto for 0.2 branch -- compare rustc stable vs nightly
//! An Asteroids-ish example game to show off ggez.
//! The idea is that this game is simple but still
//! non-trivial enough to be interesting.
extern crate ggez;
extern crate rand;
use ggez::audio;
use ggez::conf;
use ggez::event::*;