Skip to content

Instantly share code, notes, and snippets.

@codedot
codedot / hello.js
Created April 30, 2012 12:55
Uniweb Server Library
var start = require("uniweb");
//var read = require("fs").readFileSync;
function hello(socket) {
socket.on("message", function(msg) {
socket.send("alert(\"" + msg + "\");");
});
socket.send("socket.send(\"Hello World!\");");
}
@codedot
codedot / hello.js
Created May 1, 2012 18:15
Uniweb Server Helper
var start = require("uniwebjs");
//var read = require("fs").readFileSync;
function hello(socket, data) {
if (data) {
socket.run(function(data) {
window.alert(data);
}, data);
} else {
socket.run(function() {
@codedot
codedot / client.js
Created May 2, 2012 12:20
Uniweb Server Merged
var orig = "<!doctype html>";
orig = orig.concat("<meta charset=\"utf-8\">");
orig = orig.concat("<title></title>");
orig = orig.concat("<script>");
orig = orig.concat("var socket = new WebSocket(\"url\");");
orig = orig.concat("socket.onmessage = function (msg) {");
orig = orig.concat("eval(msg.data);");
orig = orig.concat("};");
orig = orig.concat("</script>");
@codedot
codedot / Makefile
Created November 14, 2012 09:33
Convert text into C strings
all: verbatim.h
verbatim.h: txt2cs.sed def.h sim.c
printf '#define %s \\\n%s\n\n' >$*.tmp \
INDEF "$$(sed -f txt2cs.sed def.h)"
printf '#define %s \\\n%s\n' >>$*.tmp \
INSIM "$$(sed -f txt2cs.sed sim.c)"
mv $*.tmp $@
clean:
@codedot
codedot / Makefile
Created November 24, 2012 14:11
Tree Exercise
TEST = 0
all: gentree
./gentree $(TEST) >output.c
$(MAKE) output
[ $(TEST) = $$(./output) ]
clean:
-rm -f gentree output output.c
@codedot
codedot / add
Created December 23, 2012 18:03 — forked from anonymous/add
Scripts for cloning fair-scheduled zones in Solaris 11. To be installed under /opt/custom. Assume `chmod +x /opt/custom/{add,reset}; zonecfg -z origin "create; set zonepath=/zones/origin"; zoneadm -z origin install; zonecfg -z global set cpu-shares=1; dispadm -d FSS; reboot` done before using. Run /opt/custom/reset once, then /opt/custom/add for…
#!/usr/xpg4/bin/sh
set -Cex
export PATH=/usr/xpg6/bin:/usr/xpg4/bin:/usr/bin:/usr/sbin
MIN=10
MAX=99
POOL=busy
ROOT=/opt/custom
@codedot
codedot / Makefile
Last active December 10, 2015 06:58
Strictly Conforming XSI Application that counts unique non-empty keys from standard input, and prints those appearing at least MINCNT times.
SCRIPT = "awk -F , -f cut.awk <input.csv | ./count >output.txt"
.POSIX:
all: cut.awk count input.csv
time sh -c $(SCRIPT)
clean:
-rm -f count output.txt
@codedot
codedot / Makefile
Created January 9, 2013 10:44
Shell Word Expansions using wordexp() system interface
.POSIX:
all: wordexp
./wordexp
clean:
-rm -f wordexp
@codedot
codedot / Makefile
Last active December 16, 2015 15:18
Recompile a Bitcoin miner per Getwork
all: nonce
time ./nonce
nonce: nonce.c data.c
gcc -O3 -Wall -Werror nonce.c -o $@
data.c: parse.sed work.js
sed -n -f parse.sed work.js >$@
clean:
@codedot
codedot / Makefile
Last active December 18, 2015 07:49
Simulation of RAM0 using Verilog
all: ram0
./ram0
clean:
-rm -f ram0
.SUFFIXES: .v
.v:
iverilog -Wall -DSIM -o $@ $<