Skip to content

Instantly share code, notes, and snippets.

View wankdanker's full-sized avatar

Dan VerWeire wankdanker

View GitHub Profile
@wankdanker
wankdanker / ksmstat
Created September 9, 2011 18:12
bash script to calculate ksm stats in kb
#!/bin/bash
if [ "$1" != "" ]; then
echo "
----------------------------------------------------------------------------
http://www.kernel.org/doc/Documentation/vm/ksm.txt :
The effectiveness of KSM and MADV_MERGEABLE is shown in /sys/kernel/mm/ksm/:
@wankdanker
wankdanker / gist:1270888
Created October 7, 2011 17:38
node-odbc debug
self: 0x7f16b4000ba0 hdbc: 0x16cff40 stmt: (nil)
self: 0x16a9050 hdbc: 0x16b5d20 stmt: 0x2f00c208053e0f2f
self: 0x16a94f0 hdbc: 0x7f16b40011d0 stmt: 0x3f077ba918000000
self: 0x7f16ac000d00 hdbc: 0x178c770 stmt: (nil)
self: 0x7f16ac000ba0 hdbc: 0x7f16b4047f90 stmt: (nil)
self: 0x16a76b0 hdbc: 0x16d13c0 stmt: 0x6c6975622f636264
self: 0x7f16ac000e60 hdbc: 0x17f31c0 stmt: (nil)
self: 0x7f16ac001120 hdbc: 0x16e02d0 stmt: (nil)
self: 0x7f16ac000fc0 hdbc: 0x7f16ac0762e0 stmt: (nil)
self: 0x7f16ac001280 hdbc: 0x182f400 stmt: (nil)
@wankdanker
wankdanker / broadcast.js
Created November 2, 2011 18:51
simple test cases for broadcast and multicast compatibility between node.js v0.4.x and v0.6.x
var dgram = require('dgram');
var socket = dgram.createSocket('udp4');
var testMessage = "[hello world] pid: " + process.pid;
var broadcastAddress = '255.255.255.255';
var broadcastPort = 5555;
socket.setBroadcast(true);
socket.bind(broadcastPort, '0.0.0.0');
/*
* Copyright (c) 2011, Ben Noordhuis <info@bnoordhuis.nl>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
@wankdanker
wankdanker / 0001-Add-support-for-uv_udp_set_broadcast.patch
Created November 4, 2011 14:35
Add setBroadcase support to node 0.5.10 and libuv
From 8ebf3363017dc223da153e69b372749ace222244 Mon Sep 17 00:00:00 2001
From: Dan VerWeire <dverweire@gmail.com>
Date: Thu, 27 Oct 2011 10:48:10 -0400
Subject: [PATCH 1/2] Add support for uv_udp_set_broadcast
---
deps/uv/include/uv.h | 12 ++++++++++++
deps/uv/src/unix/udp.c | 16 ++++++++++++++++
2 files changed, 28 insertions(+), 0 deletions(-)
@wankdanker
wankdanker / Linux-2.6.32-22-generic.md
Created November 4, 2011 17:37
nodejs tests for 0.6 release

####Linux inspection09 2.6.32-22-generic #36-Ubuntu SMP Thu Jun 3 22:02:19 UTC 2010 i686 GNU/Linux

[23:28|% 100|+ 623|-   9]: Done

Notes: Head @ 5213c390, bare metal


DEST_OS: linux
@wankdanker
wankdanker / Linux-2.6.32.md
Created November 7, 2011 15:43
udp multiple process bind test results
user@inspection09:/tmp$ uname -a
Linux inspection09 2.6.32-22-generic #36-Ubuntu SMP Thu Jun 3 22:02:19 UTC 2010 i686 GNU/Linux


user@inspection09:/tmp$ netstat -plun
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
udp        0      0 0.0.0.0:12345           0.0.0.0:*                           7853/udp-bind-twice
udp        0      0 0.0.0.0:12345           0.0.0.0:*                           7776/udp-bind-twice
@wankdanker
wankdanker / SimpleHTTPServer.js
Created November 18, 2011 16:13
A simple static file server for node
var http = require('http'),
fs = require('fs'),
cwd = process.cwd();
http.createServer()
.on('request', function (request, response) {
var url = unescape(request.url);
var path = cwd + url;
console.log(request.socket.remoteAddress, path);
@wankdanker
wankdanker / gist:1377895
Created November 18, 2011 21:58
node 0.6.2 windows xp
=== debug test-c-ares ===
Path: simple/test-c-ares
C:\node\test\simple\test-c-ares.js:46
if (error) throw error;
^
Error: getaddrinfo ENOENT
at errnoException (dns.js:31:11)
at Object.onanswer [as oncomplete] (dns.js:140:16)
Command: C:\node\Debug\node.exe C:\node\test\simple\test-c-ares.js
=== debug test-child-process-double-pipe ===
@wankdanker
wankdanker / dgram-multicast.md
Created November 21, 2011 22:25
Links regarding dgram multicast

This page has Windows tools that can send and receive test multicast messages. With this tool, I have been able to run multiple instances of mcreceive.exe on the same machine. The both instances receive all messages sent by mcsend.exe.

This page has code which can be compiled on Linux (and other Unix?). Multiple instances can be run and they will not argue about listening on the same UDP port.