Skip to content

Instantly share code, notes, and snippets.

View m-doughty's full-sized avatar

Matt D m-doughty

View GitHub Profile
my $conc = (%*ENV<CONC> // 4).Int;
my $mb = (%*ENV<MB> // 4).Int;
my $rounds = (%*ENV<ROUNDS> // 60).Int;
my $chars = $mb * 1024 * 1024;
my $blob = ('a' x $chars).encode('utf8');
say "decoding {$blob.elems} bytes x $rounds on $conc threads, $conc allocator threads";
my @w;
#include <algorithm>
#include <print>
#include <span>
#include <string_view>
// Separate this out into a function to make it easier to test.
bool is_palindrome(std::string_view s) {
// Avoids manual pointer manipulation, still does n/2 checks.
// Note: integer division floors, but this is correct since given an
// odd-length string, middle char will always equal itself.
.global _main
.align 2
.data
guess_msg: .ascii "INPUT A NUMBER (0-9):"
guess_len = . - guess_msg
equal_msg: .ascii "BOTH NUMBERS ARE EQUAL!\n"
equal_len = . - equal_msg
lower_msg: .ascii "FIRST NUMBER IS HIGHER!\n"
lower_len = . - lower_msg
.global _main
.align 2
.data
msg: .ascii "Hello, World!\n" ; non-null terminated 'string'
len = . - msg ; Calculate string length (14 bytes)
.text
_main:
mov x0, #1 ; File descriptor 1 = stdout
.global _main
.align 2
.data
random_path: .asciz "/dev/urandom"
guess_msg: .ascii "GUESS A NUMBER (0-9): "
guess_len = . - guess_msg
equal_msg: .ascii "CORRECT - YOU WIN\n"
equal_len = . - equal_msg
lower_msg: .ascii "TRY AGAIN (HINT: LOWER): "
#!/usr/bin/env python3
"""
slow_smoke.py – cross-platform “smoking throttle” timer
• Chimes every N minutes between 08:00 and 01:00 (local time)
• Shows Last smoke / Next smoke / Interval / Time-to-next, with red→green
• Press any key to register a smoke
• Adds +1 min to the interval each new day, persisting state in ~/.slow_smoke_state.json
"""
import datetime as dt
import json, os, sys, time, pathlib, signal, shutil, platform, select