Skip to content

Instantly share code, notes, and snippets.

@vladimir-ivanov
Last active December 3, 2017 21:10
Show Gist options
  • Save vladimir-ivanov/5610f078da5f05ad2eb387244296f3b8 to your computer and use it in GitHub Desktop.
Save vladimir-ivanov/5610f078da5f05ad2eb387244296f3b8 to your computer and use it in GitHub Desktop.
kdb large data
n:1000; timerange:5D; freq:0D00:01; calls:3000;
depts:`finance`packing`logistics`management`hoopjumping`trading`telesales; startcpu:(til n)!25+n?20; fcn:n*fc:`long$timerange%freq;
computer:([]time:(-0D00:00:10 + fcn?0D00:00:20)+fcn#(.z.p - timerange)+freq*til fc; id:raze fc#'key startcpu)
computer:update `g#id from `time xasc update cpu:{100&3|startcpu[first x]+sums(count x)?-2 -1 -1 0 0 1 1 2}[id] by id from computer
/ And generate some random logged calls
calls:([] time:(.z.p - timerange)+asc calls?timerange; id:calls?key startcpu; severity:calls?1 2 3)
computerlookup:([id:key startcpu] dept:n?depts; os:n?`win7`win8`osx`vista)
.z.ws:{0N! x; neg[.z.w] .j.j[select[1000000] from computer]}
.z.pw:{show x; show y; x=`usernamess}
<html>
<head>
<script src="c.js"></script>
</head>
<body><title>websocket</title>
<form action="">
<input type="button" value="connect" onclick="connect()">
<input type="text" id="x" placeholder="q)">
<input type="submit" value="send" onclick="return send()">
<input type="button" value="close" onclick="ws.close()">
</form>
<textarea id="out" rows=25 cols=80></textarea>
<script>
var ws, out = document.getElementById("out");
function connect() {
if ("WebSocket" in window) {
ws = new WebSocket("ws://usernamess:pass@localhost:5000/glad?vlad=more");
out.value = "connecting...";
ws.onopen = function (e) {
out.value = "connected";
}
ws.onclose = function (e) {
out.value = "disconnected";
}
ws.onmessage = function (e) {
console.timeEnd("sendingMessage")
//out.value = e.data;
}
ws.onerror = function (e) {
out.value = e.data;
}
} else alert("WebSockets not supported on your browser.");
}
function send() {
console.time("sendingMessage");
x = document.getElementById("x");
v = x.value;
ws.send(v);
//out.value = "sent " + v;
return false;
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment