Skip to content

Instantly share code, notes, and snippets.

View LarsFronius's full-sized avatar
:octocat:

Lars Fronius LarsFronius

:octocat:
View GitHub Profile
@LarsFronius
LarsFronius / rethink.sh
Created January 11, 2019 13:31
rethinkdb installation post removal
#!/bin/bash
source /etc/lsb-release && echo "deb http://download.rethinkdb.com/apt $DISTRIB_CODENAME main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list
wget -qO- http://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -
apt update && apt install -y rethinkdb
cp /etc/rethinkdb/default.conf.sample /etc/rethinkdb/instances.d/instance1.conf
echo 'http-port=50836' >> /etc/rethinkdb/instances.d/instance1.conf
service rethinkdb start
@LarsFronius
LarsFronius / rehash.bash
Created May 12, 2017 14:44
Rehash pyenv on every invocation of a shimmed executable
#!/usr/bin/env bash
# Install this file into ${HOME}/.pyenv/plugins/pyenv-rehash/etc/pyenv.d/exec/rehash.bash
#
# Executes pyenv-rehash on invocation of any pyenv shimmed executable in ${HOME}/.pyenv/shims/
set -e
# Remove pyenv-exec from $@
shift 1
@LarsFronius
LarsFronius / hash-dict-as-key-value.md
Last active January 11, 2019 13:48
Representing Hash/Dicts/Hashmaps as Key-Value

Representing Hash/Dicts/Hashmaps/Objects as Key-Value

Docker is on a rise, Terraform only allows flat maps or lists and generally the "Twelve-Factor App" manifest suggests storing configuration in environment variables, which are technically key-value pairs.

However, if you find yourself on a path of migrating your app towards twelve-factor, and for some reasons uses nested dictionaries/hashes as a configuration format, it can come in handy to have a standard library to interact with the two different representation formats of a key-value ENV variable list and the nested dict/hash representation.

This gist is meant to collect the different libraries or code snippets in different programming languages to interact with the two representation formats.

Python

@LarsFronius
LarsFronius / gist:4e1307eccf3a99337e89
Last active October 21, 2019 22:12
All the fastly SSL SNI domains.
for x in {a..z}; do openssl s_client -connect ${x}.ssl.fastly.net:443 < <( echo "Q\r" ) 2>/dev/null | openssl x509 -noout -text 2>/dev/null | grep 'DNS:' | tr ',' '\n' | sed 's/.*DNS://g' ; done | sort | uniq
*.01click.net
*.12wbt.com
*.1stdibs.com
*.1stdibs.us.com
*.1stdibscdn.com
*.2brightlights.info
*.4ormat.com
*.4sqi.net
export PROMPT_COMMAND='prompt_status=$?'
export PS1='$(if [[ $prompt_status == 0 ]]; then echo "ᕕ( ᐛ )ᕗ"; else echo "¯\_(ツ)_/¯"; fi)'
@LarsFronius
LarsFronius / gist:e579051d7f140fd803b0
Created February 24, 2015 16:52
If you ever want to debug a kinesis stream, copy this bash one liner.
On a mac, `brew install awscli gnu-sed` before.
streamname=staging;aws kinesis describe-stream --stream-name $streamname --output text | grep SHARDS | awk '{print $2}' | while read shard; do aws kinesis get-shard-iterator --stream-name $streamname --shard-id $shard --shard-iterator-type LATEST --output text | while read iterator; do while output=`aws kinesis get-records --shard-iterator $iterator --output text`; do iterator=`echo "$output" | head -n1`; echo "$output" | gsed 1d | grep RECORDS | while read record; do echo $record | awk '{print $2}' | base64 -D; done; done; done; done
@LarsFronius
LarsFronius / gist:7871213
Created December 9, 2013 11:58
weird performance on elasticsearch
POST /foobar/photo/_search
{
"query": {
"function_score": {
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {