Skip to content

Instantly share code, notes, and snippets.

View zefhemel's full-sized avatar

Zef Hemel zefhemel

View GitHub Profile
# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.1 30600 1732 ? Ss May22 0:02 systemd --log-target=journal
root 2 0.0 0.0 0 0 ? S May22 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S May22 0:01 [ksoftirqd/0]
root 5 0.0 0.0 0 0 ? S May22 0:00 [kworker/u:0]
root 6 0.0 0.0 0 0 ? S May22 0:02 [migration/0]
root 7 0.0 0.0 0 0 ? S May22 0:02 [migration/1]
root 9 0.0 0.0 0 0 ? S May22 0:00 [ksoftirqd/1]
root 11 0.0 0.0 0 0 ? S< May22 0:00 [cpuset]
@zefhemel
zefhemel / output.logic
Last active December 12, 2015 00:58
Sample that demonstrates how to generate Datalog with new Java API.
parent(a, b) ->
string(a),
string(b).
ancestor(a, b) ->
string(a),
string(b).
ancestor(a, c) <-
parent(a, b).
function isEven(a) {
   a = a.toString().replace(/[^0-9.]/g, "");
   var stack = [];
   var rev = a.split('').reverse();
   for (var ix = 0; ix < rev.length; ix++) {
       if (rev[ix] == ".") stack.push("dot")
       else if (rev[ix] == "1" || rev[ix] == "3" || rev[ix] =="5" || rev[ix] == "7" || rev[ix] == "9")
          stack.push("oneven")
       else
          stack.push('even')
@zefhemel
zefhemel / server.js
Created October 31, 2011 10:53
Hello world with delay node.js
var http = require('http');
var server = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('Hello\n');
setTimeout(function() {
res.end('World\n');
}, 1000);
});
@zefhemel
zefhemel / gist:1327216
Created October 31, 2011 10:02
Hello world of node.js
var http = require('http');
var server = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
});
server.listen(process.env.C9_PORT, "0.0.0.0");
console.log('Server running!');
const LOOP_COUNT = 1000 * 1000;
var startTime = 0;
function benchStart() {
startTime = new Date().getTime();
}
function printTime() {
console.log((new Date().getTime())- startTime);
const LOOP_COUNT = 1000 * 1000;
var startTime = 0;
function benchStart() {
startTime = new Date().getTime();
}
function printTime() {
console.log((new Date().getTime())- startTime);