Skip to content

Instantly share code, notes, and snippets.

View benjaminws's full-sized avatar

Benjamin W. Smith benjaminws

View GitHub Profile
@benjaminws
benjaminws / common.bzl
Last active October 13, 2019 19:52
argo workflow in starlark
metav1 = proto.package("k8s.io.apimachinery.pkg.apis.meta.v1")
wfv1 = proto.package("github.com.argoproj.argo.pkg.apis.workflow.v1alpha1")
def workflow(name = None):
""" Common workflow metadata to be used in many workflows """
if not name:
name = "workflow"
return wfv1.Workflow(
metadata = metav1.ObjectMeta(
@benjaminws
benjaminws / green_hill_zone.rb
Created December 31, 2018 23:49
someone discovered sonic-pi
use_debug true
use_bpm 140
use_synth :piano
define :song_structure do |i|
1.times { i.call }
end
# Piano Trebel
in_thread do
@benjaminws
benjaminws / Makefile
Last active June 26, 2018 18:23
spin-login
STAMP_DEPS := .deps
PHONY: clean run install
clean:
@rm -rf $(STAMP_DEPS)
$(STAMP_DEPS):
@pip3 install -r requirements.txt > /dev/null 2>&1
@touch $@
@benjaminws
benjaminws / ls-node-taints.md
Created April 16, 2018 22:22
list node taints
→ cat nodes-taint.tmpl
{{printf "%-50s %-12s\n" "Node" "Taint"}}
{{- range .items}}
    {{- if $taint := (index .spec "taints") }}
        {{- .metadata.name }}{{ "\t" }}
        {{- range $taint }}
            {{- .key }}={{ .value }}:{{ .effect }}{{ "\t" }}
        {{- end }}
 {{- "\n" }}
@benjaminws
benjaminws / test-kitchen-berks.log
Created November 6, 2013 17:48
Every now and I then I see this from Berkshelf. This example was running in a test kitchen.
D ------Exception-------
D Class: Kitchen::ActionFailed
D Message: Failed to complete #converge action: [bad response #<Faraday::Response:0x007f31560f7df8 @env={:method=>:get, :body=>"503", :url=>#<URI::HTTPS:0x007f3156099050 URL:https://api.berkshelf.com/universe>, :request_headers=>{"User-Agent"=>"Faraday v0.8.8"}, :parallel_manager=>nil, :request=>{:proxy=>nil}, :ssl=>{}, :status=>503, :response_headers=>{"content-type"=>"application/json", "retry-after"=>"600", "content-length"=>"3", "connection"=>"Close"}, :response=>#<Faraday::Response:0x007f31560f7df8 ...>}, @on_complete_callbacks=[]>]
D ---Nested Exception---
D Class: RuntimeError
D Message: bad response #<Faraday::Response:0x007f31560f7df8 @env={:method=>:get, :body=>"503", :url=>#<URI::HTTPS:0x007f3156099050 URL:https://api.berkshelf.com/universe>, :request_headers=>{"User-Agent"=>"Faraday v0.8.8"}, :parallel_manager=>nil, :request=>{:proxy=>nil}, :ssl=>{}, :status=>503, :response_headers=>{"content-type"=>"application/
@benjaminws
benjaminws / what_the_crap.rb
Created July 17, 2013 19:18
found in some rubby
%w{ crazy method names all over the place }.each do |method|
class_eval "def #{method}; self[:'#{method}']; end"
class_eval "def #{method}=(value); self[:'#{method}'] = value; end"
end
@benjaminws
benjaminws / ssh_service.pp
Created March 2, 2013 21:55
nagios service example
@@nagios_service { "check_ssh_${::hostname}":
ensure => present,
use => 'local-service',
check_command => 'check_ssh',
service_description => 'SSH',
host_name => $::fqdn,
notifications_enabled => 1,
target => "/etc/nagios/servers/${::fqdn}_host.cfg",
}
def new_time(timestamp, options)
Time.new(
options[:year] || timestamp.year,
options[:month] || timestamp.month,
options[:day] || timestamp.day,
options[:hour] || timestamp.hour,
options[:min] || (opt
# Assumes /home/me/myapp is a virtualenv...
script "Install Requirements" do
interpreter "bash"
user "me"
group "me"
code <<-EOC
/home/me/myapp/bin/pip install -r /home/me/myapp/requirements.txt
EOC
not_if "/home/me/myapp/bin/pip freeze | grep 'an_dependency' > /dev/null"
@benjaminws
benjaminws / lpthw_ex_17.py
Last active December 10, 2015 20:39
My son wanted to know how to do LPTHW ex17 in one line...
import sys; open(sys.argv[2], 'w').write(open(sys.argv[1]).read())