Skip to content

Instantly share code, notes, and snippets.

View nastra's full-sized avatar
:octocat:

Eduard Tudenhoefner nastra

:octocat:
View GitHub Profile
How to run ETCD on K8S locally
1. Install any local K8S distribution. I've used microk8s: https://microk8s.io/
2. Install etcd so you can use etcdctl: https://github.com/etcd-io/etcd/releases/
3. Run etcd on k8s via the Bitnami image. Using microk8s:
$> microk8s kubectl run --image=bitnami/etcd:latest etcd --env ALLOW_NONE_AUTHENTICATION=yes --labels app=etcd
@nastra
nastra / AtScaleConf2017.md
Last active September 13, 2017 19:58
@scale Conference 2017 - San Jose - Summary of attended Talks
@nastra
nastra / add-loopback.sh
Last active June 9, 2016 10:35
Adding loopback interfaces
#!/bin/bash
echo "Will add $1 loopback interfaces, starting at 127.0.0.2"
ifaces=$(expr $1 + 2)
for ((i=2;i<$ifaces;i++))
do
sudo ifconfig lo0 alias 127.0.0.$i up
echo "Added loopback interface 127.0.0.$i"
done
@nastra
nastra / system.log
Last active March 21, 2016 17:00
Random system.log for testing
This file has been truncated, but you can view the full file.
INFO [main] 2016-03-21 06:54:14,255 DseModule.java:71 - Loading DSE module
INFO [main] 2016-03-21 06:54:14,319 DseConfigYamlLoader.java:39 - Loading settings from file:/usr/local/lib/dse/resources/dse/conf/dse.yaml
INFO [main] 2016-03-21 06:54:14,619 DseConfig.java:285 - Load of settings is done.
INFO [main] 2016-03-21 06:54:14,620 DseConfig.java:305 - CQL slow log is enabled
INFO [main] 2016-03-21 06:54:14,622 DseConfig.java:306 - CQL system info tables are not enabled
INFO [main] 2016-03-21 06:54:14,622 DseConfig.java:307 - Resource level latency tracking is not enabled
INFO [main] 2016-03-21 06:54:14,622 DseConfig.java:308 - Database summary stats are not enabled
INFO [main] 2016-03-21 06:54:14,623 DseConfig.java:309 - Cluster summary stats are not enabled
INFO [main] 2016-03-21 06:54:14,623 DseConfig.java:310 - Histogram data tables are not enabled
INFO [main] 2016-03-21 06:54:14,623 DseConfig.java:311 - User level latency tracking is not enabled
@nastra
nastra / syntax_highlighting_broken.py
Last active October 22, 2015 08:23
Python Syntax Highlighting broken
class SomeTest(object):
@classmethod
def init_suite(cls):
cls.MIXED_CASE_KS = "Test"
cls.TYPE_TABLES = {"ascii":"ascii_table", "bigint":"bigint_table", "blob":"blob_table", "boolean":"boolean_table",
"counter":"counter_table", "decimal":"decimal_table", "double":"double_table", "float":"float_table",
"inet":"inet_table", "int":"int_table", "text":"text_table", "timestamp":"timestamp_table",
"uuid":"uuid_table", "timeuuid":"timeuuid_table", "varchar":"varchar_table", "varint":"varint_table"}
cls.COLLECTION_TABLES = {"list":"list_table", "set":"set_table", "map":"map_table"}
@nastra
nastra / boot2docker_nfs.MD
Created August 28, 2015 06:49
Boot2Docker with NFS instead of vboxfs on OSX

Get boot2docker working with nfs instead of vboxsf.

Tested on:

Client:
 Version:      1.8.1
 API version:  1.20
 Go version:   go1.4.2
 Git commit: d12ea79

This actually requires https://superuser.com/questions/1200539/cannot-increase-open-file-limit-past-4096-ubuntu/1200818#_=_

Modify **/etc/systemd/user.conf **and /etc/systemd/system.conf with the following line (this takes care of graphical login):

DefaultLimitNOFILE=65535

echo '* hard nofile unlimited' | sudo tee --append /etc/security/limits.conf echo '* soft nofile unlimited' | sudo tee --append /etc/security/limits.conf echo '* soft nproc 32768' | sudo tee --append /etc/security/limits.conf

@nastra
nastra / mergesort.py
Last active December 12, 2015 09:48
This module implements the Mergesort algorithm.
'''
This module implements the Mergesort algorithm. Mergesort uses the
Divide-and-Conquer approach, consisting of the following parts:
- Divide: divide the problem into smaller subproblems
- Conquer: conquer the two subproblems using recursive calls
- Combine: combine the solution of the subproblems into one for the original problem
The worst-case running time of the algorithm is O(n log n) for an input size n, consisting of the following parts:
- dividing problem into subproblems runs in log n, because each time the input is divided by 2
- merging takes linear time, since we have to visit each element exactly once
@nastra
nastra / sampling.py
Last active December 12, 2015 09:39
Implements the random reservoir sampling algorithm of Vitter. Reservoir Sampling is an algorithm designed to take K samples from a stream of samples of unknown size in linear time. This is a solution to the following interview question: "You have a stream of infinite queries (ie: real time Google search queries that people are entering). Describ…
from random import randint
class Sampler:
def __init__(self, maxSamples=30): # maxSamples set to 30 by default for better console output
self.samples = []
self.counter = 0
self.maxSamples = maxSamples
def sample(self, sample):
if(self.counter < self.maxSamples):
@nastra
nastra / countInversions.py
Created February 11, 2013 10:29
Counts the number of inversions in a given list by using the Mergesort algorithm. If a list is already sorted, then the number of inversions is 0. If the list is sorted in reverse order, then the number of inversions is at its maximum. The number of possible inversions can be expressed by n * (n - 1) / 2 where n is the length of the input list. …
def countInversionsAndSort(numbers):
''' Sorts an input list by using the divide-and-conquer approach. Also counts the number
of possible inversions in that list and returns both the sorted list and the number
of found inversions. '''
# if there is just one element, no work has to be done
if len(numbers) <= 1:
return numbers, 0
mid = len(numbers) // 2
left, leftInv = countInversionsAndSort(numbers[0:mid]) # sort the left list