Skip to content

Instantly share code, notes, and snippets.

View joekiller's full-sized avatar

Joseph Lawson joekiller

View GitHub Profile
@joekiller
joekiller / clean-docker.sh
Last active May 9, 2017 16:40
Delete docker images volumes and containers
#!/bin/bash
# !!!!DESTRUCTIVE!!!!
# This will delete all local docker images.
CleanDocker () {
docker ps -aq | xargs docker rm
docker images | awk '{print $1":"$2}' | xargs docker rmi
docker volume prune
}
@joekiller
joekiller / delete_all_object_versions.sh
Last active April 11, 2017 17:50 — forked from weavenet/delete_all_object_versions.sh
Delete all versions of all files in s3 versioned bucket using AWS CLI and jq.
#!/bin/bash
bucket=$1
set -e
echo "Removing all versions from $bucket"
versions=`aws s3api list-object-versions --bucket $bucket |jq '.Versions'`
markers=`aws s3api list-object-versions --bucket $bucket |jq '.DeleteMarkers'`
@joekiller
joekiller / zip.clj
Created March 9, 2017 05:21
zip up a target directory
(with-open [zip (ZipOutputStream. (io/output-stream "target/lambda.zip"))]
(doseq [f (file-seq (io/file *compile-path*)) :when (.isFile f)]
(.putNextEntry zip (ZipEntry. (subs (.getPath f) (+ 1 (count *compile-path*)))))
(io/copy f zip)
(.closeEntry zip)))
@joekiller
joekiller / README.md
Last active November 21, 2016 18:43
alias bash profiles based on client names

Say you support multiple clients or multiple projects but don't want everything on your shell at once. This script in your .bashrc file will allow you to automatically create aliases for any directory that has it's own .bashrc file. It starts a new bash shell so no existing variables are overwritten and you can exit when needed.

For example, say you have project or client named superx and another named johndoe. You create a directory superx and johndoe. Within each you pust a custom .bashrc file and optional .superx-secrets and .johndoe-secrets file and then your shell (upon next login) will detect those files and alias them to the parent directory's name. So if I want superx stuff, I just run superx and vice versa for johndoe.

Some references:

http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-environment http://www.linuxjournal.com/content/tech-tip-dereference-variable-names-inside-bash-functions http://stackoverflow.com/questions/3601515/how-to-check-if-a-v

@joekiller
joekiller / README.md
Created September 23, 2016 20:03
Hardware recommendations for Arch Linux Laptop

If you want to run Arch on a Laptop, use pure Intel hardware as much as possible. Especially for WiFi. Next use NVIDIA hardware if you need a discreet video card. AMD support is lacking to say the least.

@joekiller
joekiller / README.md
Created September 15, 2016 21:07
csd-wrapper.sh to help run openconnect against an old cisco anyconnect vpn
VPN=https://vpn.company.com
alias vpntun="sudo ip tuntap add vpn0 mode tun user `whoami`"
alias vpn="openconnect --csd-wrapper ~/.cisco/csd-wrapper.sh ${VPN} --no-cert-check -i vpn0 -s 'sudo -E /etc/vpnc/vpnc-script'"
@joekiller
joekiller / flume.conf
Last active May 25, 2016 02:34
Flume With Solr 6
# example.conf: A single-node Flume configuration
# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1
a1.sources.r1.type = spooldir
a1.sources.r1.channels = c1
a1.sources.r1.spoolDir = /tmp/messages
@joekiller
joekiller / perf_test_logstash_kafka_input.sh
Last active March 23, 2016 18:50
Test the performance of the logstash-input-kafka plugin.

Old

1 Thread:
2.86MiB 0:00:32 [  91KiB/s] [  91KiB/s]

4 Threads:
2.86MiB 0:00:31 [93.1KiB/s] [93.1KiB/s]

1 Decorated Thread:
@joekiller
joekiller / prep-vagrant-ent
Last active December 22, 2015 16:28
centos6 vagrant
#!/bin/bash
#This script will prep a centos6 box for vagrant box packaging
cat << EOF | tee /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="dhcp"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
@joekiller
joekiller / jenkins.json
Created October 20, 2015 17:23
Jenkins EC2 Centos 6 codepipeline and codecommit
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Jenkins Stack. Using https://aws.amazon.com/marketplace/ordering/ref=dtl_psb_continue?ie=UTF8&productId=74e73035-3435-48d6-88e0-89cc02ad83ee&region=us-east-1 for CentOS 6",
"Parameters" : {
"KeyName": {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance",
"Type": "AWS::EC2::KeyPair::KeyName",
"ConstraintDescription" : "must be the name of an existing EC2 KeyPair."