Skip to content

Instantly share code, notes, and snippets.

@rday
rday / uart.c
Last active August 8, 2016 20:45
UART ISR w/o Driverlib
volatile uint8_t recv_buf[BUF_LEN];
volatile uint8_t recv_buf_idx = 0;
/* ... */
/* EUSCI A0 UART ISR - Echoes data back to PC host */
void euscia0_isr(void)
{
// If this interrupt is an RX interrupt
if (EUSCI_A_CMSIS(EUSCI_A0_MODULE)->rIE.r & EUSCI_A_UART_RECEIVE_INTERRUPT) {
@rday
rday / stack.go
Created January 7, 2016 01:30
Golang stacktrace
[negroni] Completed 200 OK in 3.955256ms
[negroni] Started GET /authfail
[negroni] Completed 200 OK in 10.011542ms
[negroni] Started GET /authfail
[negroni] Completed 200 OK in 9.598809ms
[negroni] Started GET /authfail
[negroni] Completed 200 OK in 11.324298ms
[negroni] Started GET /authfail
cannot handle page request order 16/0x1000!
panic: fatal error: malloc deadlock
@rday
rday / Makefile
Last active January 4, 2016 22:49
Makefile for the rump kernel python package
# XXX
# When building the latest version of Python (3.5.1) some binaries are built in order
# to build other binaries. For example, we need the Parser/pgen binary to generate a
# parser from the Grammar file. This requires us to build some *host* binaries before
# we apply patches and build the target (-rumprun) version of Python.
#
# The problem is that the 'hostbuild' task looks like it could be done better. I'm
# looking for ideas to improve that piece.
include ../Makefile.inc
@rday
rday / gpiomon.c
Created December 14, 2015 15:42
Kernel module to detect button presses and record the duration
/*
* Monitor GPIO for button press
* https://www.kernel.org/doc/Documentation/gpio/gpio.txt
* drivers/gpio/gpiolib.c
*
* This is a simple kernel module to detect the duration of a button press on a Raspberry Pi 2.
* The button press durations are stored in a kfifo. A character device can be read, and the
* next available button press will be sent to user space. Only one process can read from
* the character device at a time.
*
@rday
rday / makesetup.patch
Last active November 11, 2015 22:26
Proposed patch for makesetup
--- a/Modules/makesetup 2015-02-25 06:27:46.000000000 -0500
+++ b/Modules/makesetup 2015-11-11 16:18:44.831994585 -0500
@@ -128,7 +128,7 @@
# Output DEFS in reverse order so first definition overrides
case $line in
- *=*) DEFS="$line$NL$DEFS"; continue;;
+ [A-Za-z]*=*) DEFS="$line$NL$DEFS"; continue;;
'include '*) DEFS="$line$NL$DEFS"; continue;;
'*noobjects*')
@rday
rday / case2.c
Created August 12, 2015 22:22
case2
#include <stdio.h>
#include <unistd.h>
int
main()
{
for(;;)
sleep(10);
}
@rday
rday / case1.py
Last active August 29, 2015 14:27
case1.py
import socket
import struct
import fcntl
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sockfd = sock.fileno()
#define SIOCGIFADDR _IOWR('i', 33, struct ifreq) /* get ifnet address */
SIOCGIFADDR = 0xc0206921
@rday
rday / gist:cc831b2a9d5dac7e5494
Created August 12, 2015 22:05
Rumpkernel build
#!/bin/sh
PATH=/home/rday/Development/os/rump/qemu/bin:$PATH:/home/rday/Development/os/rump/rumprun/app-tools
cython --embed -v -3 -Werror main.py
x86_64-rumprun-netbsd-gcc main.c -I../Python-3.4.3/pythondist/include/python3.4m -L../Python-3.4.3/pythondist/lib -lpython3.4m -lutil -lm -lz -lssl -lcrypto
rumpbake hw_virtio a.bin a.out
rumprun qemu -D 1234 -i \
-I if,vioif,'-net tap,ifname=tap0,script=no'\
;NASM=nasm
;LD=ld
;LIBS=-lc
;LD_INCLUDES=-I/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
;
;
;echoserver: echoserver.o
; ${LD} ${LIBS} ${LD_INCLUDES} -o echoserver echoserver.o
;
;echoserver.o: echoserver.s
@rday
rday / notes-slide.py
Last active July 27, 2017 00:53
python pptx notes slide
"""
Example of accessing the notes slides of a presentation.
Requires python-pptx 0.5.6 or later.
ryan@ryanday.net
"""
from pptx.util import lazyproperty, Pt
from pptx.parts.slide import BaseSlide, Slide, _SlideShapeTree, _SlidePlaceholders
from pptx.shapes.shape import BaseShape