Skip to content

Instantly share code, notes, and snippets.

View JensRantil's full-sized avatar

Jens Rantil JensRantil

View GitHub Profile
@JensRantil
JensRantil / go.mod
Last active April 25, 2019 09:35
A tiny application that connects to NATS and measure latencies to NATS.
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 March 7, 2019 02:31
Install jass - a utility to encrypt/decrypt stuff to/from SSH keys.
#!/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 / inform_github_users.py
Last active October 17, 2018 19:12
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!
# -*- 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 February 23, 2018 12:06
Test of running multiple HTTP listeners.
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
@JensRantil
JensRantil / go-compile.sh
Created September 17, 2013 10:12
$ brew install go --cross-compile-all Debug information.
$ brew install go --cross-compile-all
==> Downloading https://go.googlecode.com/files/go1.1.2.src.tar.gz
Already downloaded: /Library/Caches/Homebrew/go-1.1.2.tar.gz
==> ./make.bash --no-clean
==> ./make.bash --no-clean
==> ./make.bash --no-clean
/private/tmp/go-q5rl/go/src/cmd/5l/../ld/lib.c:661:9: error: no case matching constant switch condition '53' [-Werror]
switch(thechar){
^~~~~~~
1 error generated.
@JensRantil
JensRantil / salt-dry-run-single.sh
Last active August 25, 2017 13:10
Masterless CI of Salt.
#!/bin/bash
set -eu
MINIONID="$1"
SYNCMODULESLOG=$(mktemp)
SHOWTOPLOG=$(mktemp)
PILLARITEMSLOG=$(mktemp)
SHOWHIGHSTATELOG=$(mktemp)
# `--force-color` below is needed since we are writing output to a file.
@JensRantil
JensRantil / cassandra_stats.py
Created December 12, 2014 13:44
Calculate mean, average, max/min/percentiles from Cassandra `nodetool cfhistogram` output
"""Extract mean, median and percentiles from `nodetool cfhistogram` output.
Usage:
1. Run this script.
2. Paste in the output from a read or write latency histograms.
3. Press CTRL+D (to close stdin file descriptor).
"""
import sys
import collections
@JensRantil
JensRantil / empty.txt
Created June 4, 2017 15:53
Recreate an issue with markdown in a shortcode. See https://discuss.gohugo.io/t/best-practise-to-reuse-content/6855/2.
Empty.
@JensRantil
JensRantil / angular-post-fix.js
Created June 5, 2013 12:47
AngularJS module that can be reused in multiple Angular modules that are making POSTs to the backend.
// Modifies $httpProvider for correct server communication (POST variable format)
angular.module('http-post-fix', [], function($httpProvider) {
// This code is taken from http://victorblog.com/2012/12/20/make-angularjs-http-service-behave-like-jquery-ajax/
// Use x-www-form-urlencoded Content-Type
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
// Override $http service's default transformRequest
$httpProvider.defaults.transformRequest = [function(data) {
/**
@JensRantil
JensRantil / nsqd-without-heartbeat.txt
Created March 5, 2017 19:38
Stacktrace from when nsqd stops sending heartbeats. See https://github.com/nsqio/nsq/issues/859.
$ ./nsqd -lookupd-tcp-address localhost:4160
[nsqd] 2017/03/05 19:59:58.009064 nsqd v0.3.8 (built w/go1.6.2)
[nsqd] 2017/03/05 19:59:58.009214 ID: 219
[nsqd] 2017/03/05 19:59:58.010869 TOPIC(testtopic): created
[nsqd] 2017/03/05 19:59:58.011079 NSQ: persisting topic/channel metadata to nsqd.219.dat
[nsqd] 2017/03/05 19:59:58.011626 DISKQUEUE(testtopic): readOne() opened testtopic.diskqueue.000000.dat
[nsqd] 2017/03/05 19:59:58.013017 TCP: listening on [::]:4150
[nsqd] 2017/03/05 19:59:58.013208 HTTP: listening on [::]:4151
[nsqd] 2017/03/05 19:59:58.013216 LOOKUP(localhost:4160): adding peer
[nsqd] 2017/03/05 19:59:58.013269 LOOKUP connecting to localhost:4160