Skip to content

Instantly share code, notes, and snippets.

View simianhacker's full-sized avatar

Chris Cowan simianhacker

View GitHub Profile
@simianhacker
simianhacker / tsvb-examples.ndjson
Last active April 21, 2020 14:31
Demystifying Rates in TSVB
{"attributes":{"description":"","kibanaSavedObjectMeta":{"searchSourceJSON":"{\"query\":{\"language\":\"kuery\",\"query\":\"\"},\"filter\":[]}"},"title":"TSVB Example: Events Per Second","uiStateJSON":"{}","version":1,"visState":"{\"type\":\"metrics\",\"aggs\":[],\"params\":{\"axis_formatter\":\"number\",\"axis_position\":\"left\",\"axis_scale\":\"normal\",\"default_index_pattern\":\"metricbeat-*\",\"default_timefield\":\"@timestamp\",\"id\":\"61ca57f0-469d-11e7-af02-69e470af7417\",\"index_pattern\":\"kibana_sample*\",\"interval\":\">=10m\",\"isModelInvalid\":false,\"series\":[{\"axis_position\":\"right\",\"chart_type\":\"bar\",\"color\":\"rgba(104,204,202,1)\",\"fill\":\"1\",\"formatter\":\"number\",\"id\":\"61ca57f1-469d-11e7-af02-69e470af7417\",\"line_width\":\"0\",\"metrics\":[{\"id\":\"61ca57f2-469d-11e7-af02-69e470af7417\",\"type\":\"count\"},{\"id\":\"d2ea8870-79a2-11ea-8742-197c8d25f072\",\"type\":\"math\",\"variables\":[{\"id\":\"d745a530-79a2-11ea-8742-197c8d25f072\",\"name\":\"count\",\"field\":\"6
@simianhacker
simianhacker / index.js
Created February 10, 2016 22:18
Metric Sledgehammer
module.exports = function (kibana) {
return new kibana.Plugin({
id: 'metric_sledgehammer',
uiExports: {
sledgehammers: [
]
}
});
};
var wd = require('wd');
var _ = require('lodash');
var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');
var asserters = wd.asserters;
var mocha = require('mocha');
chai.use(chaiAsPromised);
chai.should();
chaiAsPromised.transferPromiseness = wd.transferPromiseness;
define(function (require) {
'use strict';
var _ = require('lodash');
var vents = {};
return {
on: function (id, cb) {
if (!_.isArray(vents[id])) {
vents[id] = [];
}
vents[id].push(cb);
var request = require('request');
var expect = require('chai').expect;
describe('GET /api/users', function () {
it('should return a 200 statusCode', function (done) {
request('http://localhost:5555/api/users', function (err, resp, body) {
expect(resp.statusCode).to.equal(200);
done();
});
});
});
import natlink
import natlinkmain
import pprint
def myCallback(type,args):
print "type: %s" % type;
pprint.pprint(args);
apply(natlinkmain.changeCallback, [type,args])
natlink.setChangeCallback(myCallback)
var insert = function (data, callback) {
console.log('fail', data);
callback();
}
var update = function (data, callback) {
this.insert(data, callback);
};
module.exports.insert = insert;
@simianhacker
simianhacker / require.snippet
Created August 24, 2013 02:14
This snippet will convert `req` to `var SomeName = require('some_name');`
snippet req "Require a module where it converts CamelCase to underscore (camel_case)" !b
var ${1:name} = require(${2:'${3:${1/(^[A-Z])|([A-Z])/(?2:_\l$2:\l$1)/g}}'});
endsnippet
@simianhacker
simianhacker / index.js
Last active December 17, 2015 13:59
Just testing Jaws to see what happens when you hit it with 100 concurrent connections without warming the cache.
siege -b -c 100 http://localhost:4444/cache-this
@simianhacker
simianhacker / json_path.sql
Last active May 13, 2019 17:40
Here is a set of functions for working with a PostgreSQL+JSON+PLV8 database.
-- Function: json_path(json, text)
-- DROP FUNCTION json_path(json, text);
CREATE OR REPLACE FUNCTION json_path(data json, path text)
RETURNS text AS
$BODY$
/* JSONPath 0.8.0 - XPath for JSON
*
* Copyright (c) 2007 Stefan Goessner (goessner.net)