Skip to content

Instantly share code, notes, and snippets.

View billywhizz's full-sized avatar
🤓
always be learning

Andrew Johnston billywhizz

🤓
always be learning
View GitHub Profile
const { Socket, TCP } = library('socket', {})
const server = new Socket(TCP)
const read = Buffer.alloc(64 * 1024)
const write = Buffer.alloc(64 * 1024)
const bytes = new Uint8Array(read.bytes)
let off = 0, records = 0, resLength = 0
const response = `HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nServer: dv8\r\nDate: ${(new Date()).toUTCString()}\r\nContent-Length: 13\r\n\r\nHello, World!`
while (1) {
resLength = write.write(response, off)
off += resLength
@billywhizz
billywhizz / bpf.md
Last active May 24, 2019 07:42
BPF Bits
@billywhizz
billywhizz / README.md
Last active December 4, 2018 23:58
dv8 DNS client example

Running

## clone the gist
git clone [email protected]:3f612e0bb9758e7fe80e629e3dc6b2c2.git
cd 3f612e0bb9758e7fe80e629e3dc6b2c2
## the docker command to use
DV8_DNS="docker run -it --rm --name=dv8-dns --net=host -v $(pwd):/app billywhizz/dv8:0.0.5a dv8 ./dns.js"
## query google 8.8.8.8 dns server using UDP on port 53
$DV8_DNS www.google.com
## query local dnsmasq using UDP on port 53
@billywhizz
billywhizz / readme.md
Created March 14, 2018 16:45
Kong Bootstrap
@billywhizz
billywhizz / 0_reuse_code.js
Created April 5, 2017 11:57
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@billywhizz
billywhizz / foo.md
Created April 5, 2017 11:48
the end of the world as we know it

this is a test. i am writing. how cool

here is a list

  • omg

here is some code

let a = b;
@billywhizz
billywhizz / README.md
Created February 22, 2017 23:45
uWebSockets Techempower Benchmark

install

npm install

run node.js server

node app
function inherits(ctor, superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
@billywhizz
billywhizz / Array.sliceAfter.js
Created June 6, 2013 22:48
get slice of sorted array greater than passed in value
Array.prototype.sliceAfter = function(expr) {
var index = 0;
var found = this.some(function(v, i, a) {
if(v > expr) {
index = i;
return true;
}
});
if(!found) return [];
return this.slice(index);
@billywhizz
billywhizz / statement-cache.diff
Created October 25, 2012 17:49
node-oracle statement cache patch
diff --git a/src/oracle_bindings.cpp b/src/oracle_bindings.cpp
old mode 100644
new mode 100755
index bbcf611..1ea38a2
--- a/src/oracle_bindings.cpp
+++ b/src/oracle_bindings.cpp
@@ -84,6 +84,7 @@ void OracleClient::EIO_Connect(uv_work_t* req) {
std::ostringstream connectionStr;
connectionStr << "//" << baton->hostname << ":" << baton->port << "/" << baton->database;
baton->connection = baton->environment->createConnection(baton->user, baton->password, connectionStr.str());