Skip to content

Instantly share code, notes, and snippets.

View hillar's full-sized avatar

Hillar hillar

View GitHub Profile
@hillar
hillar / gist:6659934
Last active June 21, 2017 19:56
counting 'waves' or 'ticks' ...
has_waves <- function(c,try2=FALSE,try3=FALSE){
lc <- length(c)-1
if (lc < 3) {
return(NA)
}
notnas <- diff(which(!is.na(c)))
notnas <- notnas[notnas>1]
lnotnas <- length(notnas)
lunotnas <- length(unique(notnas))
if (lunotnas==1 & 2 < lnotnas & lnotnas < lc){
@hillar
hillar / whois
Created October 4, 2013 13:00
whois(ish) REST for netdot
<%doc>
whois(ish) REST for netdot
Fetch contact information for a given IP address
if ip not found, then closest covering netblock contacts are returned
if direct contacts not found,then parent contacts are returned
install == copy this next to other REST scripts
(/usr/local/netdot/htdocs/rest/whois)
@hillar
hillar / gist:6989933
Last active December 25, 2015 14:19
moloch kibana to get map working add aol/moloch/master/viewer/public/jquery-jvectormap-world-en.js to elasticsearch/kibana/master/src/app/panels/map/lib/
{
"title": "mlch kbn",
"services": {
"query": {
"idQueue": [
1,
2,
3,
4
],
@hillar
hillar / gist:7022867
Created October 17, 2013 10:50
test nodejs && estonian national id
//wget http://sk.ee/upload/files/JUUR-SK.PEM.cer
//wget http://sk.ee/upload/files/EECCRCA.pem.cer
//wget http://sk.ee/upload/files/ESTEID-SK%202007.PEM.cer
//wget http://sk.ee/upload/files/ESTEID-SK%202011.pem.cer
var fs = require('fs'),
http = require('http'),
https = require('https'),
express = require('express');
@hillar
hillar / gist:7030859
Created October 17, 2013 19:33
passport strategy for client certificate need a lot of work...
passport.use(new SSLClientCertificateStrategy({ca: Config.get('clientCertificateCA'),
crl: Config.get('clientCertificateCRL', []),
ocsp: Config.get('clientCertificateOCSP',[])},
function(userid, done) {
Db.get("users", "user", userid, function(err, suser) {
if (err) {return done(err);}
if (!suser || !suser.exists) {console.log(userid, "doesn't exist"); return done(null, false);}
if (!suser._source.enabled) {console.log(userid, "not enabled"); return done("Not enabled");}
suser._source.settings = suser._source.settings || {};
@hillar
hillar / not_analyzed_by_default
Created October 29, 2013 14:47
What is the best way to disable the default analyzer....
{
"template": "prefix-*",
"mappings": {
"_default_": {
"_source": { "compress": true },
"dynamic_templates": [
{
"string_template" : {
"match" : "*",
"mapping": { "type": "string", "index": "not_analyzed" },
@hillar
hillar / R_elasticsearch
Created January 29, 2014 02:37
R read data from elasticsearch
library(httr)
library (plyr)
set_config(config=structure(list(noproxy = c("127.0.0.1")), .Names = "noproxy", class = "config"));
set_config(config=accept_json());
u <- "http://127.0.0.1:9200/_all/_search"
# time series by fix period 1d
p <- "{\"facets\":{\"histo1\":{\"histogram\":{\"field\":\"yourtimefield\",\"time_interval\":\"1d\"}}},\"size\":0}"
r <- content(POST(u,body=p));
var async = require('async.js');
var data = {}
data.time = 12345678;
data.tags = [1,2,3];
function post (data) {
var results = {};
results.start = new Date().getTime();
var updateSession = function(callback) {
console.log('updateSession')
results.saved = true;
var LOG_LEVEL = 7; // 7 debug; 6 info; 5 notice; 4 error;
var ADMIN = "admin@localhost";
var NodeSyslogLoggerSimple = require('node-syslog-logger-simple');
var logger = new NodeSyslogLoggerSimple({'level':LOG_LEVEL});
logger.debug('logger=ok');
var exec = require('child_process').exec;
var EXEC_OPTIONS = { encoding: 'utf8',
timeout: 5000,
@hillar
hillar / LLRB.js
Created April 5, 2014 20:40
Left-leaning Red-Black Trees
// see Robert Sedgewick :: Left-leaning Red-Black Trees
const RED = true;
const BLACK = false;
var Node = function(key, value) {
this.key = key;
this.value = value;
this.color = RED;
this.N = 1;