Skip to content

Instantly share code, notes, and snippets.

View tcdowney's full-sized avatar

Tim Downey tcdowney

View GitHub Profile
@tcdowney
tcdowney / ubuntu-sleep-network-policy.yaml
Created August 31, 2020 22:49
Ubuntu Sleep Pod Allow All NetworkPolicy
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: ubuntu-allow-all
spec:
policyTypes:
- Egress
- Ingress
podSelector:
matchLabels:
@tcdowney
tcdowney / ubuntu-sleep.yaml
Created June 27, 2020 00:54
Ubuntu Sleep Pod
apiVersion: v1
kind: Pod
metadata:
name: ubuntu
labels:
app: ubuntu
spec:
containers:
- image: ubuntu
command:
@tcdowney
tcdowney / convert-loadbalancer-to-nodeport.yaml
Created June 13, 2020 19:28
Convert LoadBalancer Service to NodePort ytt
#! https://downey.io/notes/dev/convert-loadbalancer-service-to-nodeport-ytt/
#@ load("@ytt:overlay", "overlay")
#@overlay/match by=overlay.subset({"kind": "Service", "spec":{"type":"LoadBalancer"}}),expects=1
---
spec:
#@overlay/replace
type: NodePort
@tcdowney
tcdowney / cf-virtualservice-example.yaml
Created March 20, 2020 16:00
cf-for-k8s istio virtualservice example
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
annotations:
cloudfoundry.org/fqdn: whoami.tim-2020-03-18.routing.lol
metacontroller.k8s.io/last-applied-configuration: '{"apiVersion":"networking.istio.io/v1alpha3","kind":"VirtualService","metadata":{"annotations":{"cloudfoundry.org/fqdn":"whoami.tim-2020-03-18.routing.lol"},"creationTimestamp":null,"labels":{"cloudfoundry.org/route-bulk-sync":"true"},"name":"vs-f48b53b677be4b3ddd70beba027fb405fb0a45be6da7ff17bb7e3afdc1942cf3"},"spec":{"gateways":["istio-ingress"],"hosts":["whoami.tim-2020-03-18.routing.lol"],"http":[{"route":[{"destination":{"host":"s-e7017323-678b-454b-b099-9e196b33bb02"},"headers":{"request":{"set":{"CF-App-Id":"46f34772-4c8f-4a09-b18e-75505681265c","CF-App-Process-Type":"web","CF-Organization-Id":"631fec7d-47cc-4e82-8df1-add1c314d94f","CF-Space-Id":"a71aaf82-4f4a-4967-a0a6-471c44484186"}},"response":{}}}]}]}}'
creationTimestamp: "2020-03-18T22:35:21Z"
generation: 1
labels:
cloudfoundry.org/route-
@tcdowney
tcdowney / cf-for-k8s-tls-matrix.md
Last active December 8, 2020 20:26
cf4k8s TLS matrix
Source\Destination External Apps System Components
External

Keybase proof

I hereby claim:

  • I am tcdowney on github.
  • I am tcdowney (https://keybase.io/tcdowney) on keybase.
  • I have a public key whose fingerprint is 90C8 2606 77B1 FF63 34C1 1DEE 301B 9993 40D5 E292

To claim this, I am signing this object:

@tcdowney
tcdowney / rename_ga.rb
Created May 21, 2019 01:55
Hacky rename of Intro to Graduate Algorithms videos to get sorted correctly on Kindle Fire
leading_digit_regex = /\d+\s+/
path = '/Users/tcdowney/Downloads/ga-vids'
Dir.glob("#{path}/*.mp4") do |mp4_file|
filename = File.basename(mp4_file, File.extname(mp4_file))
leading_digits = filename.match(leading_digit_regex)[0].to_i
padded_digits = sprintf('%03d', leading_digits)
padded_filename = filename.gsub(leading_digits.to_s, padded_digits)
#puts padded_filename + File.extname(mp4_file)
File.rename(mp4_file, padded_filename + File.extname(mp4_file))
@tcdowney
tcdowney / raspbian-sd-longetivity.sh
Created June 3, 2018 03:13
Raspbian SD Longetivity Commands
# Inspired by https://raspberrypi.stackexchange.com/questions/169/how-can-i-extend-the-life-of-my-sd-card
# Gonna see if I can get by with just disabling swap for now
# Disable SWAP
sudo dphys-swapfile swapoff && \
sudo dphys-swapfile uninstall && \
sudo update-rc.d dphys-swapfile remove
@tcdowney
tcdowney / missing_translations.rb
Created October 10, 2014 02:39
Missing Translations RSpec Matcher
# spec/support/missing_translations.rb
require 'rspec/expectations'
RSpec::Matchers.define :have_missing_translations do
match do |actual|
missing_i18n_js = /\[missing ".*" translation\]/
missing_i18n_ruby = /class="translation_missing"/
!!(actual.body.match(missing_i18n_ruby) || actual.body.match(missing_i18n_js))
end
@tcdowney
tcdowney / primeperms.rb
Last active August 29, 2015 14:00 — forked from baweaver/primeperms.rb
Use the sieve :)
def eratosthenes(n)
nums = [nil, 1, *2..n]
(2..Math.sqrt(n)).each do |i|
(i**2..n).step(i){|m| nums[m] = nil} if nums[i]
end
nums
end
primes_to_million = eratosthenes(1_000_000)