Skip to content

Instantly share code, notes, and snippets.

@codedot
codedot / hello.js
Created Apr 30, 2012
Uniweb Server Library
View hello.js
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
Uniweb Server Helper
View hello.js
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
Uniweb Server Merged
View client.js
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 Nov 14, 2012
Convert text into C strings
View Makefile
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 Nov 24, 2012
Tree Exercise
View Makefile
TEST = 0
all: gentree
./gentree $(TEST) >output.c
$(MAKE) output
[ $(TEST) = $$(./output) ]
clean:
-rm -f gentree output output.c
@codedot
codedot / add
Created Dec 23, 2012 — 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…
View add
#!/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 Dec 10, 2015
Strictly Conforming XSI Application that counts unique non-empty keys from standard input, and prints those appearing at least MINCNT times.
View Makefile
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 Jan 9, 2013
Shell Word Expansions using wordexp() system interface
View Makefile
.POSIX:
all: wordexp
./wordexp
clean:
-rm -f wordexp
@codedot
codedot / Makefile
Last active Dec 16, 2015
Recompile a Bitcoin miner per Getwork
View Makefile
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 Dec 18, 2015
Simulation of RAM0 using Verilog
View Makefile
all: ram0
./ram0
clean:
-rm -f ram0
.SUFFIXES: .v
.v:
iverilog -Wall -DSIM -o $@ $<