Skip to content

Instantly share code, notes, and snippets.

Avatar
:electron:
Kubernetes Early Adopter (2016)

Stephan Kristyn stevek-pro

:electron:
Kubernetes Early Adopter (2016)
  • Site Reliability Engineer für testgetriebene Software Entwicklung, Automation, ML Pipelines, zeroOps
  • München, Bayern
  • Twitter @transformatik
View GitHub Profile
View bubblesort.py
def bubbleSort(aList):
for eachNum in range(len(aList)-1,0,-1):
for i in range(eachNum):
if (aList[i] > aList[i+1]):
temp = aList[i]
aList[i] = aList[i+1]
aList[i+1] = temp
return aList
View selectionSort.py
def selectionSort(aList):
# from n-1 to 0 (excluding 0) with the stepping -1
for eachNum in range (len(aList)-1,0,-1):
positionMax = 0
for i in range(eachNum+1):
if aList[i] > aList[positionMax]:
positionMax = i
temp = aList[eachNum]
aList[eachNum] = aList[positionMax]
aList[positionMax] = temp
View insertionSort.py
def insertionSort(aList):
# starting from 1 because n-1
for index in range(1,len(aList):
currentValue = aList[index]
position = index
while position > 0 and aList[position-1] > currentValue:
aList[position] = aList[position-1]
position = position-1
View binaryTree.py
class BinaryTree:
def __init__(self,rootObj):
self.key = rootObj
self.leftChild = None
self.rightChild = None
def getRightChild(self):
return self.rightChild
def getLeftChild(self):
View traversals.py
def preorder(tree):
if tree:
print(tree.getRootVal())
preorder(tree.getLeftChild())
preorder(tree.getRightChild())
def postorder(tree):
if tree:
postorder(tree.getLeftChild())
postorder(tree.getRightChild())
@stevek-pro
stevek-pro / fetch.sh
Last active Aug 29, 2015
Wget fetch files in a directory
View fetch.sh
#!/bin/bash
# Fetch Logs
wget -r --ca-certificate=theCert.pem \
-A gz --directory-prefix=logs/property/ \
-R html,gif,"index*","YourOtherExceptions" --no-verbose --no-parent \
--no-directories --user=YourUsername -e robots=off \
--password=YourPassword https://subdomain.domain/dir
View mrjob-bash
using configs in /home/username/.mrjob.conf
using existing scratch bucket mrjob-bd6adeda430251a6
using s3://mrjob-bd6adeda430251a6/tmp/ as our scratch dir on S3
creating tmp directory /tmp/mr_word_freq_count.username.20140624.222854.528710
writing master bootstrap script to /tmp/mr_word_freq_count.username.20140624.222854.528710/b.py
Copying non-input files into s3://mrjob-bd6adeda430251a6/tmp/mr_word_freq_count.username.20140624.222854.528710/files/
Waiting 5.0s for S3 eventual consistency
Creating Elastic MapReduce job flow
Job flow created with ID: j-28AM8D8NYX7P
Created new job flow j-28AM8D8NYX7P
@stevek-pro
stevek-pro / mrjob.conf
Last active Aug 29, 2015
Sample MrJob Config File
View mrjob.conf
runners:
emr:
aws_access_key_id: YOURACCESSKEY
aws_secret_access_key: YOURSUPERSECRET
runners:
emr:
ec2_key_pair: YOURKEYNAME
# ~/ and $ENV_VARS allowed here
ec2_key_pair_file: /home/yourusername/.ssh/supersecret.pem
@stevek-pro
stevek-pro / mongoose-exclude.js
Last active Aug 29, 2015
Mongoose Query with Selectors
View mongoose-exclude.js
/*
items = {
oranges: 'Navel',
apples: 'Braeburn',
grapes: 'Vroege van der Laan'
}
*/
@stevek-pro
stevek-pro / MRStep.py
Last active Aug 29, 2015
mr() is deprecated and will be removed in v0.6.0. Use mrjob.step.MRStep directly instead.
View MRStep.py
from mrjob.job import MRJob
from mrjob.step import MRStep
def steps(self):
return [
MRStep(mapper=self.myMapper,
combiner=self.myCombiner,
reducer=self.myReducer)
]