Skip to content

Instantly share code, notes, and snippets.

@hobbsh
hobbsh / nums.py
Created January 18, 2019 22:07
Sort arbitrary sized file filled with random integers by N biggest
#!/usr/bin/env python
import random
import sys
import threading, Queue
from heapq import nlargest
import os
# job queue
queue = Queue.Queue()
# result queue
@hobbsh
hobbsh / parallel_analyze.py
Created August 28, 2018 16:41
Analyze postgres tables in parallel
#!/usr/bin/env python
import multiprocessing
import psycopg2
import time
"""
Run analyze on multiple tables in parallel
Author: Wylie Hobbs - 2018
"""
@hobbsh
hobbsh / redshift_unload_wrapper.sh
Last active November 29, 2019 17:54
Wrapper for redshift_unload_copy.py to unload/copy multiple tables in a loop
#!/bin/bash
# Wylie Hobbs - 2018
# Copy multiple tables at once with redshift unload-copy utility
# Usage: ./redshift_unload_wrapper.sh
# Requires a clone of amazon-redshift-utils and the packages: jq, awscli
# Create redshift_unload_wrapper.sh, tables.txt and config.json in src/UnloadCopyUtility and run this script
#tables.txt is newline delimited list of tables in SCHEMA.TABLE notation
TABLES=$(cat tables.txt)
@hobbsh
hobbsh / drain_old_nodes.sh
Last active August 10, 2018 23:09
Drain kubernetes nodes that are part of an older autoscaling group
#!/bin/bash -e
# As mentioned here: https://thinklumo.com/blue-green-node-deployment-kubernetes-eks-terraform
# Author: Wylie Hobbs - 2018
# usage:
# normal: ./drain_old_nodes.sh
# dry run: ./drain_old_nodes.sh noop
DRY_RUN="$1"
function drain(){
@hobbsh
hobbsh / rq_rl-slides.html
Last active March 16, 2018 19:57
Resource Quotas and Resource Limits Slides
<section data-background-transition='zoom' data-transition='concave' data-background='https://pixel.nymag.com/imgs/daily/vulture/2016/07/29/29-steve-brule-check-it-out.w710.h473.2x.jpg' data-state='blackout'>
<h2>Kubernetes Resource Quotas and Resource Limits</h2>
</br>
<h3>For your health</h3>
</section>
<section data-background-transition='zoom' data-transition='linear' id='try-it'>
<section data-transition='concave'>
<h2>Resource Limits vs Resource Quotas</h2>
<p>Memory and CPU constraints for a container are configured with resource requests and resource limits</p>
<p><b>Resource Quotas:</b> are resource limits that apply to a namespace</p>
@hobbsh
hobbsh / hashrate_poller.py
Last active January 16, 2018 03:05
Polls xmr-stak hashrate page and sends data to graphite
#!/usr/bin/env python
# Author: Wylie Hobbs - 01/15/2018
import requests
import sys
import json
import socket
import time
# Set your carbon server's IP/port
@hobbsh
hobbsh / vega_ulps_crossfire_disable.ps1
Last active January 15, 2018 01:12
Dsiables the EnableUlps and EnableCrossfireAutoLink in Windows 10 Registry for Vega GPUs
Function Test-RegistryValue {
param(
[Alias("PSPath")]
[Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[String]$Path
,
[Parameter(Position = 1, Mandatory = $true)]
[String]$Name
,
[Switch]$PassThru
@hobbsh
hobbsh / kubecon_curl.sh
Created December 9, 2017 04:23
Download Kubecon Austin 2017 presentations from Sched
#!/bin/bash
DAYS=("2017-12-06" "2017-12-07" "2017-12-08")
for DAY in "${DAYS[@]}"; do
#Super shitty pipefest because of grep matched groups sadness
LINKS=($(curl https://kccncna17.sched.com/${DAY}/overview | grep -oEi "f='(.*)' cl" | cut -d\' -f 2 | tr '\n' ' '))
for LINK in "${LINKS[@]}"; do
echo "Requesting https://kccncna17.sched.com/${LINK}"
#Find file link on event page
FILE_URL=$(curl -s https://kccncna17.sched.com${LINK} | grep "file-uploaded" | cut -d\" -f 4)