Skip to content

Instantly share code, notes, and snippets.

@xamox
xamox / arch-linux-install.md
Last active January 13, 2023 12:35 — forked from mattiaslundberg/arch-linux-install
Minimal instructions for installing arch linux on an UEFI system with full system encryption using dm-crypt and luks
@xamox
xamox / mongo-to-elasticsearch.py
Created October 18, 2016 22:09
Move data from Mongo to Elasticsearch
'''
Tested with:
Mongo 3.0.12
pymongo 3.3.0
Elasticsearch 2.1.2
Kibana 4.3.3
elasticsearch python 2.1.0
'''
@xamox
xamox / balltrack.py
Created April 21, 2012 18:05
Object Tracking with SimpleCV (White Ball)
'''
This is how to track a white ball example using SimpleCV
The parameters may need to be adjusted to match the RGB color
of your object.
The demo video can be found at:
http://www.youtube.com/watch?v=jihxqg3kr-g
'''
print __doc__
@xamox
xamox / kubectl-port-forward_forward.md
Last active January 14, 2022 18:51
How to forward a kubectl port-forward with socat

Yo dawg, I heard you like port-fowards so I'm going to port-forward your port-forward.

Say you want to test something like maybe run something in minikube locally but connect to something running in the kube cluster.

Do your kube port foward

kubectl --context k8s-uw1-gcp port-forward prometheus-prometheus-server-7b6f9d99f8-m4vt6 9090
@xamox
xamox / How to port-foward a kube port-forward
Created September 19, 2018 19:51
How to port-foward a kube port-forward
Yo dawg, I heard you like port-fowards so I'm going to port-forward your port-forward.
Say you want to test something like maybe run something in minikube locally but connect to something running in the kube cluster.
Do your kube port foward
kubectl --context k8s-uw1-gcp port-forward prometheus-prometheus-server-7b6f9d99f8-m4vt6 9090
On your host system
socat -v TCP-LISTEN:9091,fork TCP:127.0.0.1:9090

Keybase proof

I hereby claim:

  • I am xamox on github.
  • I am xamox (https://keybase.io/xamox) on keybase.
  • I have a public key ASCNCyQflmLq7t15MAqOI6F6N59VFxVOfLVO4KaOzGQWogo

To claim this, I am signing this object:

@xamox
xamox / reindex-elasticsearch-python.py
Last active April 6, 2017 13:19
Used to reindex elasticsearch (ELK) setup for changing indexs
#!/usr/bin/env python
import elasticsearch
import elasticsearch.helpers
elasticSource = elasticsearch.Elasticsearch([{"host": "localhost", "port": 9200}])
elasticDestination = elasticsearch.Elasticsearch([{"host": "localhost", "port": 9200}])
# Setup source and destinations connection to Elasticsearch. Could have been different clusters
# Delete index so we know it doesn't exist.
elasticDestination.indices.delete(index="index_destination", ignore=[400, 404])
# Create index with nothing in it.
elasticDestination.indices.create(index="index_source", ignore=[400, 404])
@xamox
xamox / balltrack-min.py
Created April 21, 2012 18:11
Object Tracking with SimpleCV (White Ball) - Minimized Version
from SimpleCV import *
cam = Camera()
while True:
img = cam.getImage().flipHorizontal()
dist = img.colorDistance(Color.BLACK).dilate(2)
segmented = dist.stretch(200,255)
blobs = segmented.findBlobs()
if blobs:
circles = blobs.filter([b.isCircle(0.2) for b in blobs])
@xamox
xamox / AutoVivifaction.py
Created November 10, 2011 04:22
This is useful for setting nested dictionaries and setting items like objects
class AutoVivification(dict):
"""
Implementation of perl's autovivification feature.
>>> a = AutoVivification()
>>> a[1][2][3] = 4
>>> a[1][3][3] = 5
>>> a[1][2]['test'] = 6
>>> print a
>>> {1: {2: {'test': 6, 3: 4}, 3: {3: 5}}}