Skip to content

Instantly share code, notes, and snippets.

@rambo
rambo / void_ptr.c
Created March 16, 2018 09:29
reminder to self on how to deref void pointer to integer
// gcc -Wall void_ptr.c -o void_ptr ; ./void_ptr
#include <stdio.h>
#include <stdint.h>
void muck_count(void* param)
{
uint8_t *foo = (uint8_t*)param;
printf("foo %u\n", *foo);
*foo = 0;
}
@rambo
rambo / output.txt
Created January 18, 2019 19:12
Python class method recursion test
rambombp2015-674:Downloads rambo$ python2.7 rec_test.py
level is 0
level is 1
level is 2
level is 3
level is 4
level is 5
level is 6
level is 7
level is 8
@rambo
rambo / futures_test.py
Created January 20, 2019 10:10
concurrent.futures example where futures can generate more work to do
from concurrent.futures import ProcessPoolExecutor
import time
import random
def long_task(sleeptime):
print("Sleeping {}".format(sleeptime))
time.sleep(sleeptime)
if sleeptime < 1:
return []
if random.random() > 0.7:
@rambo
rambo / sc_pro_tips.md
Last active December 24, 2024 10:30
Collection of tutorials and good tips for Star Citizen

SC pro tips

Basics

@rambo
rambo / profile2edit.py
Last active November 19, 2024 17:26
GameTouchController .profile file parser for editing looong macros
from pathlib import Path
import ast
import pprint
import sys
if len(sys.argv) < 2:
print("Enter filename: ", end=None)
pname = Path(input())
else:
pname = Path(sys.argv[1])
"""
Hash the STM32 UID, Python version
Original C code from from https://pcbartists.com/firmware/stm32-firmware/generating-32-bit-stm32-unique-id/
"""
import pyb
import struct
# Magic numbers for 32-bit hashing, copied from Murmur3
C1 = 0xcc9e2d51
@rambo
rambo / sht4x.py
Last active March 7, 2025 13:03
MicroPython SHT40, SHT41, SHT43, SHT45 asyncio driver
"""
SHT40, SHT41, SHT43, SHT45
MicroPython driver for micro:bit
https://www.fredscave.com/drivers/008-sht4x.html
AUTHOR: fredscave.com
DATE : 2024/10
VERSION : 1.00
Converted to asyncio by rambo@iki.fi on 2025-03-07