Skip to content

Instantly share code, notes, and snippets.

Avatar

Anthony Oliver xamox

View GitHub Profile
@xamox
xamox / mongo-to-elasticsearch.py
Created Oct 18, 2016
Move data from Mongo to Elasticsearch
View mongo-to-elasticsearch.py
'''
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 Apr 21, 2012
Object Tracking with SimpleCV (White Ball)
View balltrack.py
'''
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 Mar 7, 2019
How to forward a kubectl port-forward with socat
View kubectl-port-forward_forward.md

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 Sep 19, 2018
How to port-foward a kube port-forward
View 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
@xamox
xamox / arch-linux-install.md
Last active Sep 5, 2018 — 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
View arch-linux-install.md
View keybase.md

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 Apr 6, 2017
Used to reindex elasticsearch (ELK) setup for changing indexs
View reindex-elasticsearch-python.py
#!/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 Apr 21, 2012
Object Tracking with SimpleCV (White Ball) - Minimized Version
View balltrack-min.py
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 Nov 10, 2011
This is useful for setting nested dictionaries and setting items like objects
View AutoVivifaction.py
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}}}
You can’t perform that action at this time.