Skip to content

Instantly share code, notes, and snippets.

@stuart-warren
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 (
"bytes"
"code.google.com/p/go.crypto/openpgp"
"encoding/base64"
"io/ioutil"
"log"
"os"
)
@stuart-warren
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
10a11
> set $hyper Mod4+Mod1+Ctrl+Shift
61a63,66
> input "type:keyboard" {
> xkb_layout us
> xkb_variant dvorak
> }
74c79
< bindsym $mod+d exec $menu
---
@stuart-warren
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
stuart-warren / CreateJob.sh
Last active December 19, 2022 03:50
Create a job in Jenkins (or folder) using the HTTP API
View CreateJob.sh
# check if job exists
curl -XGET 'http://jenkins/checkJobName?value=yourJobFolderName' --user user.name:YourAPIToken
# with folder plugin
curl -s -XPOST 'http://jenkins/job/FolderName/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:YourAPIToken
# without folder plugin
curl -s -XPOST 'http://jenkins/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:YourAPIToken
# create folder
@stuart-warren
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/RubyProc.java:255:in `call'", "(eval):9:in `exec'", "org/jruby/RubyProc.java:255:in `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/RubyHash.java:1332:in `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/RubyProc.java:255:in `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
stuart-warren / tomcat-mkdeb.sh
Last active July 1, 2022 13:03
Create deb of Tomcat installing into its own dir (to allow multiple versions) Uses fpm
View tomcat-mkdeb.sh
#!/bin/bash -xe
#
# sudo gem install fpm
# sudo apt-get install curl
# # Put this script in a folder called tomcat-packaging
# ./mkdeb.sh 7.0.40
# ./mkdeb.sh 6.0.37
#
VERSION=$1
@stuart-warren
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 http://docs.vagrantup.com/v2/provisioning/shell.html It also creates one node for each key, value pair
View vagrant-shell-arguments.rb
Vagrant.configure("2") do |config|
HADOOP_NODES = {'hd-master' => '192.168.40.10',
'hd-slave1' => '192.168.40.11',
'hd-slave2' => '192.168.40.12'}
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
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
stuart-warren / webhook.py
Created November 29, 2018 10:53
kubernetes mutating admission webhook (Python)
View webhook.py
#!/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
stuart-warren / watch.sh
Created October 20, 2017 10:47
Watch a directory of files for changes
View watch.sh
# 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'