This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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%" ("*}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "filefuture" | |
version = "0.1.0" | |
authors = ["you"] | |
edition = "2018" | |
[dependencies] | |
futures = "*" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 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` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Debug)] | |
pub struct LinkedList { | |
head: Option<Box<Node>>, | |
tail: Option<*mut Node>, | |
} | |
#[derive(Debug)] | |
struct Node { | |
value: i32, | |
next: Option<Box<Node>>, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! 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::*; |