Skip to content

Instantly share code, notes, and snippets.

@rday
rday / gist:a8d457ced018e5970e19
Created November 15, 2014 18:22
Embedded Static Handler for Martini
package main
import (
"bytes"
"github.com/go-martini/martini"
"log"
"net/http"
"path"
"time"
"strings"
;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 / 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'\
@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 / case2.c
Created August 12, 2015 22:22
case2
#include <stdio.h>
#include <unistd.h>
int
main()
{
for(;;)
sleep(10);
}
@rday
rday / gist:2644245
Created May 9, 2012 12:43
Quick IP addresses functions
import socket
import struct
def quadtolong(ip):
return struct.unpack('!L',socket.inet_aton(ip))[0]
def longtoquad(long):
return socket.inet_ntoa(struct.pack('!L', long))
def inc_ip(ip):
@rday
rday / gist:3711685
Created September 13, 2012 03:36
Install Golang
# Setup your home directory to handle a go installation
mkdir ~/go
cd ~/
# Grab and untar the binary the binary
# If you have a 64bit system, use http://go.googlecode.com/files/go1.0.2.linux-amd64.tar.gz
wget http://go.googlecode.com/files/go1.0.2.linux-386.tar.gz
tar -xzf go1.0.2.linux-386.tar.gz
# Setup your environment to handle the root Go install
@rday
rday / gist:3712141
Created September 13, 2012 05:45
Json decode
package main
import "fmt"
import "encoding/json"
import "net/http"
import "bytes"
type Test struct{
Name string
Token string
@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 / gist:4742553
Last active December 12, 2015 08:18
#
# Skeleton code, don't use this because it isn't going to work for you
"""
This is heavily taken from the MovingAverage
"""
import numpy
import talib
from numbers import Number