Skip to content

Instantly share code, notes, and snippets.

@justincormack
justincormack / nginx.conf
Created April 29, 2011 14:57
Using Lua and Nginx to proxy Amazon web services example
# example location parts of nginx.conf
# add your own AWS keys, server lines etc, and set your aws domains, paths
http {
# you will need the luacrypto in the cpath, download from http://luacrypto.luaforge.net/
lua_package_cpath "/home/justin/lua/luacrypto-0.2.0/src/l?.so.0.2.0;;";
server {
listen 80;
@justincormack
justincormack / perf.lua
Created July 11, 2011 23:24
ljsyscall perf test
local S = require "syscall"
local t = S.t
local oldassert = assert
function assert(c, s)
return oldassert(c, tostring(s)) -- annoyingly, assert does not call tostring!
end
local s = assert(S.socket("inet", "stream, nonblock"))
@justincormack
justincormack / index.html
Created March 2, 2012 14:46
Colour tests
<html>
<head>
<title>Testing colours</title>
</head>
<body>
<script src="https://raw.github.com/justincormack/d3/master/d3.v2.min.js"></script>
<p>Brighter and darker, RGB vs HSL vs CIELab</p>
<svg id="rgb-bright1"></svg>
@justincormack
justincormack / tmp.lua
Created August 4, 2012 17:46
test case for segfault
local ffi = require "ffi"
local bit = require "bit"
local C = ffi.C
local S = {}
local t = {}
local s = {}
@justincormack
justincormack / sigint backtrace
Created April 17, 2013 22:37
How to get SIGINT to give a backtrace using ljsyscall
local S = require "syscall"
local t = S.t
local c = S.c
local ffi = require "ffi"
local ip
if ffi.arch == "x86" then ip = c.REG.EIP
elseif ffi.arch == "x64" then ip = c.REG.RIP
else error "unsupported architecture" end
@justincormack
justincormack / gist:5934351
Created July 5, 2013 12:53
metatypes for bounds checking
ffi = require "ffi"
local VHOST_VRING_SIZE = 32*1024
ffi.cdef [[
enum { VHOST_VRING_SIZE = 32*1024 };
struct vring_avail {
uint16_t flags;
uint16_t idx;
@justincormack
justincormack / bounds
Created July 5, 2013 13:33
ffi array bounds checking 2
ffi = require "ffi"
local VHOST_VRING_SIZE = 32*1024
ffi.cdef [[
enum { VHOST_VRING_SIZE = 32*1024 };
struct vring_avail {
uint16_t flags;
uint16_t idx;
@justincormack
justincormack / pts.c
Created July 14, 2013 09:07
rump kernel ioctl issue
#include <dlfcn.h>
#include <stdio.h>
#include <sys/types.h>
#include <inttypes.h>
#include <rump/rump.h>
#include <rump/rump_syscalls.h>
#include <rump/netconfig.h>
typedef uint32_t _netbsd_mode_t;
@justincormack
justincormack / gist:6526826
Created September 11, 2013 17:19
First run of the ljsyscall test suite on Xen
sudo xl create -c domain_config
Parsing config from domain_config
DEBUG libxl__blktap_devpath 37 aio:/home/justin/minios/32/test.ffs
DEBUG libxl__blktap_devpath 40 /dev/xen/blktap-2/tapdev4
Daemon running with PID 1968
start_info: 0x2f4000(VA)
nr_pages: 0x2000
shared_inf: 0xc775e000(MA)
pt_base: 0x2f7000(VA)
nr_pt_frames: 0x5
@justincormack
justincormack / gist:6556530
Created September 13, 2013 21:49
ljsyscall passing all tests under xen!
Parsing config from domain_config
DEBUG libxl__blktap_devpath 37 aio:/home/justin/minios/32/test.ffs
DEBUG libxl__blktap_devpath 40 /dev/xen/blktap-2/tapdev4
Daemon running with PID 12219
start_info: 0x326000(VA)
nr_pages: 0x4000
shared_inf: 0xd8af1000(MA)
pt_base: 0x329000(VA)
nr_pt_frames: 0x5
mfn_list: 0x316000(VA)