Skip to content

Instantly share code, notes, and snippets.

@lundman
lundman / time.h
Last active March 23, 2025 21:02
time.h style timers for macOS
#include <sys/stdtypes.h>
#include <stdbool.h>
#include <mach/boolean.h>
#include <sys/errno.h>
#include <stdlib.h>
#include <dispatch/dispatch.h>
#if !defined(MAC_OS_X_VERSION_10_12) || \
(MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12)
@bitRAKE
bitRAKE / bitmap_decode_ctz.asm
Last active October 16, 2022 12:12
convert bitmask buffer to array indices
; references:
; https://branchfree.org/2018/05/22/bits-to-indexes-in-bmi2-and-avx-512/
; https://lemire.me/blog/2018/03/08/iterating-over-set-bits-quickly-simd-edition/
; http://0x80.pl/notesen/2019-01-05-avx512vbmi-remove-spaces.html
align 64
; RCX : number of quadword to convert
; RSI : source bit array
; RDI : destination index array
bitmap_decode_ctz:
jrcxz .all_zero
@thecarlhall
thecarlhall / FreeTime.gs
Created November 6, 2023 15:49
Find how much free time (i.e., unscheduled) there is per calendar day
/*
* User Settings
*/
// Always use current week. How many weeks past that to check?
const WEEKS_AHEAD = 0;
// Assume each day starts, ends at the same times
const WORK_START_HR = 9;
const WORK_END_HR = 18;