Skip to content

Instantly share code, notes, and snippets.

Avatar

Aaron Miller AaronM04

  • Orange County, CA
View GitHub Profile
@AaronM04
AaronM04 / battmon.sh
Last active Sep 6, 2020
Flicker-free battery monitor for OpenBSD
View battmon.sh
#!/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%" ("*}"
View sndio_test.c
#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 Feb 21, 2020
Pretty Print XML in Rust
View Cargo.toml
[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"
View Cargo.toml
[package]
name = "filefuture"
version = "0.1.0"
authors = ["you"]
edition = "2018"
[dependencies]
futures = "*"
@AaronM04
AaronM04 / wow.rs
Created Feb 24, 2019
Rust does not compare function argument types when determining which trait's implementation to use
View wow.rs
/// 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 Mar 2, 2020 — forked from codesections/linked_list.rs
A simple linked list implemented in Rust
View linked_list.rs
#[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 Jun 26, 2018
testing BitGrid iterators
View bitgrid_iter.rs
// 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 Jan 8, 2018
Simple Ruby thread pool
View thread_pool.rb
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 Dec 15, 2017
astroblasto for 0.2 branch -- compare rustc stable vs nightly
View astroblasto_line595.rs
//! 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::*;
You can’t perform that action at this time.