Skip to content

Instantly share code, notes, and snippets.

View tcarmelveilleux's full-sized avatar

Tennessee Carmel-Veilleux tcarmelveilleux

View GitHub Profile
@tcarmelveilleux
tcarmelveilleux / snippet.kt
Created April 2, 2023 13:55 — forked from renaudcerrato/snippet.kt
Kotlin Interfaces
interface A {
val a: Int // abstract
val b: Int // abstract
fun foo() // abstract
fun bar() {
// optional body
}
}
interface B { ... }
@tcarmelveilleux
tcarmelveilleux / thread_args_test.c
Created May 8, 2018 14:26
Stack overflow pthread arguments passing example
/*
============================================================================
Name : thread_test.c
Author : Tennessee Carmel-Veilleux
Version :
Copyright : Public domain
Description : Simple args-passing example with pthreads
============================================================================
*/
@tcarmelveilleux
tcarmelveilleux / ihex_checksum.py
Created January 27, 2017 19:30
Simple Intel HEX checksum for when you hack/modify Intel HEX files.
def ihex_csum(hex_data):
"""
Compute Intel Hex checksum of all bytes of a line of hex. The hex_data is a
hex string of data, without checksum.
>>> ihex_csum("0C00000000020B11129B12000B66EAE7")
213
"""
hex_bytes = [ord(b) for b in hex_data.decode("hex")]
@tcarmelveilleux
tcarmelveilleux / make_c_array.py
Created February 17, 2016 01:59
Convert hex string to C arrary
def arrayify(name, buf):
return "uint8_t %s[] = { %s };" % (name, ", ".join(["0x%02X" % ord(c) for c in buf.decode('hex')]))