Skip to content

Instantly share code, notes, and snippets.

View havlan's full-sized avatar
🏠
Working from home

Håvard Langdal havlan

🏠
Working from home
View GitHub Profile
@havlan
havlan / find_sentinl_user.js
Created July 10, 2018 12:20
Elasticsearch client to find sentinl users when searchguard plugin protects
const elasticsearch = require('elasticsearch');
const bcrypt = require('bcrypt');
const login = 'admin';
const password = 'admin';
const config = {
host: [
{
host: 'localhost',
@havlan
havlan / getFlatUTCArray.js
Created June 14, 2018 10:53
Turns an UTC timestamp into a format
/*
Time fractions:
1000 ms/sec
60 sec/min
60 min/hour
24 hour/day
*/
let getFlatUTCArray = function (base_value, time_fractions) {
time_data = [base_value];
for (i = 0; i < time_fractions.length; i++) {
@havlan
havlan / actual.txt
Last active June 13, 2018 07:16
Sentinl_issue
{
"actions": {
"email_admin": {
"throttle_period": "0h15m0s",
"email": {
"to": "alarm@localhost",
"from": "sentinl@localhost",
"subject": "Alarm",
"priority": "high",
"body": "Found {{payload.hits.total}} Events"
@havlan
havlan / configloader.go
Last active April 25, 2018 14:22
Loading json config files in golang, useful for database type configs.
/*
layout of config file
{
"host":"localhost",
"port": 5432,
"user": "postgres",
"password": "123123",
"database": "example_db"
}
fn gcd(mut a:isize, mut b:isize) -> usize {
let mut t;
while a != 0 {
t = a;
a = b % a;
b = t;
}
b.abs() as usize
}
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <random>
using namespace std;