Skip to content

Instantly share code, notes, and snippets.

@rday
rday / case2.c
Created August 12, 2015 22:22
case2
#include <stdio.h>
#include <unistd.h>
int
main()
{
for(;;)
sleep(10);
}
@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 / 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 / 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 / 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 / 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 / watch.go
Created May 23, 2016 17:55
If the server drops the connection, reestablish
// While we are supposed to be processing, make sure to reestablish the
// client connection if anything unexpected happens.
for processing {
ch, err := client.Watch()
if err != nil {
glog.Error(err)
} else {
validChannel := true
msg := Event{}
@rday
rday / handle.go
Last active May 23, 2016 18:01
Only add services that can be accessed from outside the cluster
if msg.Type == ADDED || msg.Type == MODIFIED {
var service discovery.Service
// ClusterIP services are only accessible inside the cluster. They
// should be located with env vars provided by k8s. We will only announce
// externally available services here.
if msg.Object.Spec.Type == LOADBALANCER {
endpoints := make([]string, 0, len(msg.Object.Spec.Ports)*len(msg.Object.Status.LoadBalancer.Ingress))
for _, ingress := range msg.Object.Status.LoadBalancer.Ingress {
for _, port := range msg.Object.Spec.Ports {
@rday
rday / Makefile
Last active May 27, 2016 18:43
Example makefile
APP_SRC=${GOPATH}
APP_BIN=bin
BINARY=test-service
VERSION=0.2.1
.PHONY: all
all: dev
.PHONY: clean
clean:
@rday
rday / local-cluster.sh
Last active May 27, 2016 13:31
Bring up ubuntu cluster
#!/bin/sh
export KUBE_VERSION=1.2.4
export ETCD_VERSION=2.3.5
export nodes="vagrant@172.16.45.2"
export role="ai i i"
export NUM_NODES=1
# The range must match the Vagrant private network