Skip to content

Instantly share code, notes, and snippets.

package distance
import (
"errors"
"math"
)
// Eucledian implements eucledian distance between two vectors
func Eucledian(vec1, vec2 []float64) float64 {
distance := 0.0
package main
import (
"bufio"
"encoding/json"
"errors"
"flag"
"fmt"
"io/ioutil"
"log"
@markuskont
markuskont / hyperLogLog.go
Last active September 26, 2017 11:26
Simple implementation of hyperloglog cardinality estimation algorithm. Bare minimum for counting unique words in log files, but relies on Golang 1.9 for counting leading zeros. Only implements dense estimation with Add() and Count().
package main
import(
"fmt"
"flag"
"errors"
"math/bits"
"os"
"log"
"bufio"
FROM ubuntu:16.04
RUN echo "deb http://cran.rstudio.com/bin/linux/ubuntu xenial/" | tee -a /etc/apt/sources.list && \
gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9 && \
gpg -a --export E084DAB9 | apt-key add -
RUN apt-get update && apt-get install -y sudo gdebi-core wget libxslt1-dev libxkbcommon-dev libxcb-xkb-dev libxslt1-dev libgstreamer-plugins-base0.10-dev libgl1-mesa-glx libgl1-mesa-dri
RUN apt-get install -y r-base r-base-dev
RUN apt-get build-dep -y r-cran-rgl
@markuskont
markuskont / snoopy.rb
Created September 6, 2017 11:23
rulebase files for liblognorm
version=2
include=/opt/liblognorm-rulebase/stdtypes.rb
type=@ssh:%[
{"type": "ipv4", "name":"src_ip"},
{"type": "whitespace"},
{"type": "number", "name":"src_port"},
{"type": "whitespace"},
{"type": "ipv4", "name":"dst_ip"},
@markuskont
markuskont / gist:d90cdaf5d76ba0038f244284197fe501
Created August 30, 2017 08:12 — forked from debasishg/gist:8172796
A collection of links for streaming algorithms and data structures
  1. General Background and Overview
@markuskont
markuskont / Dockerfile
Last active November 6, 2017 12:22
Simple node-js script for sending avro-encoded netflow into kafka
FROM node:6.11.5-slim
WORKDIR /opt/app
ARG port=9995
ARG topic=test-topic-1
ARG zookeeper=zoo1
RUN apt-get update && \
apt-get install -y python build-essential && \
rm -rf /var/lib/apt/lists/*
# clear all messages in kafka topics by temorarily changing retention time in (in ms)
# doing this with kafka-topics.sh may be deprecated in future
MS=1000
IP=127.0.0.1
for topic in `./kafka-topics.sh --list --zookeeper $IP:2181` ; do ./kafka-topics.sh --zookeeper $IP:2181 --alter --topic $topic --config retention.ms=$MS ; done
MS=259200000
...
# show consumer groups
./kafka-consumer-groups.sh --zookeeper $IP:2181 --list
$provision_script = <<SCRIPT
apt-get update
GOLANG="go1.8.3.linux-amd64.tar.gz"
cd /vagrant
[[ -f $GOLANG ]] || wget -q -4 https://storage.googleapis.com/golang/$GOLANG
tar -zxvf $GOLANG -C /usr/local/ > /dev/null 2>&1
package main
import (
"fmt"
"log"
"strings"
"time"
"sync"
"sync/atomic"
"os"