Skip to content

Instantly share code, notes, and snippets.

View norganna's full-sized avatar

Ken Allan norganna

View GitHub Profile
@norganna
norganna / spamkick.lua
Created September 14, 2011 06:22
Spamkick
-- Copyright 2011, Norganna's AddOns Pty Ltd. All rights reserved.
-- Made by Worfox, modified by kevinsweijen.
local lib = register("spamkick")
local spamdata = {}
lib:hook("loggedin", nil, function (perform)
local player = lib.detail.username
spamdata['t' .. player] = os.clock()
@norganna
norganna / time.js
Created September 18, 2011 11:29
time offset
new Date((((~~(((+(new Date()) / 3600000) + 10) / 24)) * 24) - 10) * 3600000)
<html>
<head>
<script>
var id = Math.floor(Math.random() * 100000000);
timer = setInterval(function() {
console.log("Hi, I'm " + id);
}, 1000);
console.log("Starting " + id + " at " + (new Date));
</script>
</head>
@norganna
norganna / gist:3671724
Created September 8, 2012 04:07
Profile of node
ticks parent name
6621823 84.5% /lib/x86_64-linux-gnu/libc-2.15.so
1163611 14.8% /opt/node-0.6.21/bin/node
371121 31.9% Function: ~cb /opt/tf2whx/bundle/server/node_modules/fibers/future.js:88
371121 100.0% Function: Future.return /opt/tf2whx/bundle/server/node_modules/fibers/future.js:152
368973 99.4% Function: ~<anonymous> app/packages/mongo-livedata/mongo_driver.js:346
368973 100.0% Function: ~Cursor.toArray /opt/tf2whx/bundle/server/node_modules/mongodb/lib/mongodb/cursor.js:123
368973 100.0% Function: ~Cursor.each /opt/tf2whx/bundle/server/node_modules/mongodb/lib/mongodb/cursor.js:162
118130 10.2% LazyCompile: *_Mongo.LiveResultsSet._unthrottled_markDirty app/packages/mongo-livedata/mongo_driver.js:458
@norganna
norganna / spiderable.js.diff
Created November 17, 2012 15:26
spiderable patch to reattach hash fragment
--- spiderable.js.orig 2012-11-18 01:14:08.000000000 +1000
+++ spiderable.js 2012-11-18 01:16:08.000000000 +1000
@@ -14,10 +14,11 @@
var preQuery = req.url.substr(0, idx);
var queryStr = req.url.substr(idx + 1);
var parsed = querystring.parse(queryStr);
+ var fragment = '#!' + parsed['_escaped_fragment_'];
delete parsed['_escaped_fragment_'];
var newQuery = querystring.stringify(parsed);
var newPath = preQuery + (newQuery ? "?" + newQuery : "");
@norganna
norganna / header_spy.js
Last active December 14, 2015 12:48
A header spy for mongo, to intercept and store headers during the request, which can later be retrieved during a publish() handler.
!function() {
var storage = {};
// Install a ghost listener so we can spy on the client headers.
function install_spy() {
// Surplant the current request and upgrade listeners.
_.each(['request', 'upgrade'], function (event) {
var app = __meteor_bootstrap__.app;
var old_listeners = app.listeners(event).slice(0);
app.removeAllListeners(event);
@norganna
norganna / mongo_connect.php
Last active December 22, 2015 15:18
Mongo connection script example for replicaset connection and reconnect on failure (without having to restart server).
<?php
$retry = 0;
$m = false;
// Repeat while no connection and haven't tried 3 times
while (!$m and $retry < 3) {
try {
// Connect to replica set
$m = new MongoClient("mongodb://10.0.1.100,10.0.1.101,10.0.5.1", [
<?php
/*
* Weather update client
* Connects SUB socket to tcp://localhost:5556
* Collects weather updates and finds avg temp in zipcode
* @author Ian Barber <ian(dot)barber(at)gmail(dot)com>
*/
$context = new ZMQContext();
// Weather update client
// Connects SUB socket to tcp://localhost:5556
#include "zhelpers.h"
int main (int argc, char *argv [])
{
// Socket to talk to server
printf ("Collecting updates from weather server…\n");
void *context = zmq_ctx_new ();
core@ piano~$ curl - L http: //10.36.5.64:4001/v2/stats/leader
{
"leader": "visual",
"followers": {
"front": {
"latency": {
"current": 0.460931,
"average": 0.5663465316657799,
"standardDeviation": 0.547781903505012,
"minimum": 0.18624,