Skip to content

Instantly share code, notes, and snippets.

Jens Rantil JensRantil

Block or report user

Report or block JensRantil

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View go.mod
module github.com/JensRantil/yo
go 1.13
require github.com/nats-io/nats-streaming-server v0.16.2
@JensRantil
JensRantil / channel_demo.go
Last active Aug 18, 2019
Simplification of sample code at https://blog.gopheracademy.com/advent-2015/automi-stream-processing-over-go-channels/ Best practise is 1) to inject channels and 2) avoid concurrency in APIs.
View channel_demo.go
func ingest(out <-chan []string) {
out <- []string{"aaaa", "bbb"}
out <- []string{"cccccc", "dddddd"}
out <- []string{"e", "fffff", "g"}
close(out)
}
func process(in <-chan []string, out <-chan int) {
for data := range in {
for _, word := range data {
@JensRantil
JensRantil / tombstone-count.sh
Last active Jul 3, 2019
How to count number of tombstones per partition key in one or multiple sstables.
View tombstone-count.sh
#!/bin/bash
#
# Counts number of tombstones per partition key in one or multiple sstables.
#
# Usage: ./tombstone-count.sh /var/lib/cassandra/data/mykeyspace/mytable/*-Data.db
#
# Sample output:
# "40e6a9839bf44bdaa624cc53e96733fe" 8
# "8e177ab222c14f868bcb6d2922b18d2b" 8
# "28aaa9db0dad4ae78cabe8bcc25d14a3" 9
@JensRantil
JensRantil / go.mod
Last active May 8, 2019
TopK implementation with filtering from dictionary.
View go.mod
module github.com/JensRantil/topk-challenge
require (
github.com/funkygao/golib v0.0.0-20180314131852-90d4905c1961 // indirect
github.com/google/pprof v0.0.0-20190502144155-8358a9778bd1 // indirect
github.com/hashicorp/go-multierror v1.0.0
github.com/pkg/errors v0.8.1
golang.org/x/arch v0.0.0-20190312162104-788fe5ffcd8c // indirect
golang.org/x/sync v0.0.0-20190423024810-112230192c58
)
@JensRantil
JensRantil / go.mod
Last active May 3, 2019
Demonstrating potential memory leak.
View go.mod
module github.com/tink-ab/tink-backend/src/nats-streaming-pinger
require (
github.com/armon/go-metrics v0.0.0-20190423201044-2801d9688273 // indirect
github.com/go-sql-driver/mysql v1.4.1 // indirect
github.com/gogo/protobuf v1.2.1 // indirect
github.com/hashicorp/go-msgpack v0.5.4 // indirect
github.com/hashicorp/raft v1.0.1 // indirect
github.com/lib/pq v1.1.0 // indirect
github.com/nats-io/gnatsd v1.4.1 // indirect
@JensRantil
JensRantil / go.mod
Last active Apr 25, 2019
A tiny application that connects to NATS and measure latencies to NATS.
View go.mod
module github.com/tink-ab/tink-backend/src/nats-checker
require (
github.com/nats-io/gnatsd v1.4.1 // indirect
github.com/nats-io/go-nats v1.7.2
github.com/nats-io/nkeys v0.0.2 // indirect
github.com/nats-io/nuid v1.0.1 // indirect
github.com/oklog/ulid v1.3.1
github.com/prometheus/client_golang v0.9.2
golang.org/x/sys v0.0.0-20190425045458-9f0b1ff7b46a // indirect
@JensRantil
JensRantil / install.sh
Last active Mar 7, 2019
Install jass - a utility to encrypt/decrypt stuff to/from SSH keys.
View install.sh
#!/bin/bash
# Install using:
# curl https://gist.github.com/JensRantil/ba21c50e7720bfc62050/raw/c34825afc94940388b1b1dca2abe4c813211ecd0/install.sh | bash -e
# ...but PLEASE have a look at the URL to make sure its sane first!
#
# An alternative is obviously to download the script and executing it.
# Fail early.
set -e
@JensRantil
JensRantil / backup-keyspace.sh
Created Nov 27, 2014
Basic Cassandra -> S3 backup script
View backup-keyspace.sh
#!/bin/bash
KEYSPACE=$1
DATE=`date +"%Y-%m-%d--%H-%M-%S"`
FOLDER_NAME=${DATE}-daily
S3_BUCKET=s3://YOUR-S3-BUCKET
S3_BUCKET_PATH=cassandra/full/`date +"%Y/%m/%d/%H/%M"`/`cat /etc/hostname`
SNAPSHOTID=`uuidgen --time`
PGP_KEY_RECIPIENT=YOUR-PGP-KEY-RECIPIENT
@JensRantil
JensRantil / inform_github_users.py
Last active Oct 17, 2018
Script that inform Github users of removal of a Github team. Modify for your organization and copy-paste the generated text into your favourite mail client!
View inform_github_users.py
# -*- coding: utf-8 -*-
import requests
import os
import pprint
def request(url):
return requests.get(url, auth=('JensRantil', os.environ['APIKEY']), headers={"Accept": "application/vnd.github.hellcat-preview+json"})
teams = dict([(e['id'], e['name']) for e in request('https://api.github.com/orgs/tink-ab/teams').json()])
pprint.pprint(teams)
@JensRantil
JensRantil / exeuction.sh
Created Feb 23, 2018
Test of running multiple HTTP listeners.
View exeuction.sh
bash-3.2$ curl -v http://localhost:8080/bar && echo
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> GET /bar HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 200 OK
You can’t perform that action at this time.