Skip to content

Instantly share code, notes, and snippets.

@seenaburns
seenaburns / getattr_example.py
Last active December 11, 2015 01:19
Overriding __getattr__ for the sake of API Design
class Color:
def __init__(self):
pass
def __getattr__(self, name):
if name is 'saturation':
# Warn user of hls / saturation
saturation_warning = 'Color.saturation is ambiguous. Use Color.hls_saturation or Color.hsv_saturation'
raise AttributeError(saturation_warning)
else:
@seenaburns
seenaburns / strtoi-add-argv.arm
Created April 16, 2019 15:48
ARM program to take parse argv[1], argv[2] as ints, add them, and print them back to stdout
.data
Input:
.ascii "89\0"
NewlineString:
.ascii "\n\0"
TestString:
.ascii "Some string\n\0"
@seenaburns
seenaburns / strtoi-add-argv.s
Last active March 11, 2023 18:08
ARM assembly to take parse argv[1], argv[2] as ints, add them, and print them back to stdout
// Building (on x86):
//
// arm-linux-gnueabi-as -o strtoi-add-argv.o strtoi-add-argv.s
// arm-linux-gnueabi-ld -o strtoi-add-argv strtoi-add-argv.o
//
// Running:
// qemu-arm strtoi-add-argv 100 23; echo $?
//
.data