Skip to content

Instantly share code, notes, and snippets.

stuart-warren / simple-gpg-enc.go
Last active February 27, 2023 17:48
golang gpg/openpgp encryption/decryption example
View simple-gpg-enc.go
package main
import (
stuart-warren / sway.config.diff
Created February 22, 2023 21:33
Diff of sway config changes from default /etc/sway/config
View sway.config.diff
> set $hyper Mod4+Mod1+Ctrl+Shift
> input "type:keyboard" {
> xkb_layout us
> xkb_variant dvorak
> }
< bindsym $mod+d exec $menu
stuart-warren / Vagrantfile
Created August 18, 2015 07:38
Ubuntu cloud with user-data cloud config in Vagrant
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
CLOUD_CONFIG_PATH = File.join(File.dirname(__FILE__), "user-data")
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
stuart-warren /
Last active December 19, 2022 03:50
Create a job in Jenkins (or folder) using the HTTP API
# check if job exists
curl -XGET 'http://jenkins/checkJobName?value=yourJobFolderName' --user
# with folder plugin
curl -s -XPOST 'http://jenkins/job/FolderName/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user
# without folder plugin
curl -s -XPOST 'http://jenkins/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user
# create folder
stuart-warren / Exception.rb
Last active October 28, 2022 13:37
Windows Event log via nxlog (json) -> logstash 1.2 config
View Exception.rb
Exception in filterworker {"exception"=>#<NoMethodError: undefined method `[]=' for nil:NilClass>, "backtrace"=>["file:/opt/logstash/logstash.jar!/logstash/event.rb:135:in `[]='", "org/jruby/ `call'", "(eval):9:in `exec'", "org/jruby/ `call'", "file:/opt/logstash/logstash.jar!/logstash/util/fieldreference.rb:44:in `exec'", "file:/opt/logstash/logstash.jar!/logstash/event.rb:134:in `[]='", "file:/opt/logstash/logstash.jar!/logstash/filters/mutate.rb:234:in `rename'", "org/jruby/ `each'", "file:/opt/logstash/logstash.jar!/logstash/filters/mutate.rb:232:in `rename'", "file:/opt/logstash/logstash.jar!/logstash/filters/mutate.rb:205:in `filter'", "(eval):127:in `initialize'", "org/jruby/ `call'", "file:/opt/logstash/logstash.jar!/logstash/pipeline.rb:243:in `filter'", "file:/opt/logstash/logstash.jar!/logstash/pipeline.rb:191:in `filterworker'", "file:/opt/logstash/logstash.jar!/logstash/pipeline.rb:134:in `start_filters'"], :level=>:
stuart-warren /
Last active July 1, 2022 13:03
Create deb of Tomcat installing into its own dir (to allow multiple versions) Uses fpm
#!/bin/bash -xe
# sudo gem install fpm
# sudo apt-get install curl
# # Put this script in a folder called tomcat-packaging
# ./ 7.0.40
# ./ 6.0.37
stuart-warren / vagrant-shell-arguments.rb
Last active March 23, 2022 21:13
Vagrant shell provisioning with variable arguments. This example iterates through an object and passes its keys and values as parameters to a shell script It also creates one node for each key, value pair
View vagrant-shell-arguments.rb
Vagrant.configure("2") do |config|
HADOOP_NODES = {'hd-master' => '',
'hd-slave1' => '',
'hd-slave2' => ''}
HADOOP_NODES.each do |node_name, node_ip|
config.vm.provision :shell do |s|
s.inline = 'echo -e "$1\t$2" | sudo tee -a /etc/hosts'
s.args = "#{node_ip} #{node_name}"
stuart-warren / kubectx.zsh
Last active February 4, 2022 10:28
kubectx/kubens multi context magic
View kubectx.zsh
# BSD 2-Clause License
# Copyright (c) 2019, Stuart Warren
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
stuart-warren /
Created November 29, 2018 10:53
kubernetes mutating admission webhook (Python)
#!/usr/bin/env python
from http import HTTPStatus
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
import base64
import json
import logging
import os
import os.path
import ssl
stuart-warren /
Created October 20, 2017 10:47
Watch a directory of files for changes
# watch the current directory for changes to files
# order the files by size and output the files in 3 columns
# highlight changes between outputs
watch -d 'du -sh * | sort -hr | pr -3 -t'