Skip to content

Instantly share code, notes, and snippets.

View gilgamez's full-sized avatar

Gilgamesh Nootebos gilgamez

  • The Netherlands
View GitHub Profile
def workspace = manager.build.workspace
def matcher = manager.getLogMatcher(".*Messages transferred +: (\\d+).*")
def writeToCsv(csv, text) {
csv.act({f,c->f.withWriterAppend("UTF-8") { it.write(text + "\n") }} as hudson.FilePath.FileCallable<Void>)
}
if(matcher?.matches()) {
def result = matcher.group(1)
def csv = workspace.child("messages_transferred.csv")
if (!csv.exists()) {writeToCsv(csv, "transferred")}
@gilgamez
gilgamez / smtp.sh
Created June 7, 2013 07:33
sent smtp mail from the command line
#!/bin/bash
#### Command line parameters ####
HELO=`hostname`
MAILSERVER=${1:?Mailserver}
PORT=${2:?Mailserver Port}
MAILFROM=${3:?From}
MAILTO=${4:?To}
SUBJECT=${5:?Subject}
@gilgamez
gilgamez / my_sshuttle
Last active December 28, 2015 09:49
my companion script to kick a sshuttle session into action. sshuttle is here https://github.com/apenwarr/sshuttle
#!/bin/bash
SSH_SERVER=<some host config ssh understands>
VERBOSITY=-v
cat <<-EOF |
# My Project
172.16.103.183/29 # buildserver
172.16.228.219/28 # issuetracker
172.16.228.246/26 # test
@gilgamez
gilgamez / unique
Created December 17, 2013 11:01
awk/shell script that filters its input and only outputs identical lines once
#!/bin/sh
IN=${1:--}
OUT=${2:-/dev/tty}
# see http://stackoverflow.com/questions/11532157/unix-removing-duplicate-lines-without-sorting#11532197
awk '!x[$0]++' $IN >$OUT

Requirements

  • Docker Machine + Docker
  • curl
  • A Virtualbox-driven Docker Machine called "default" docker-machine create --driver virtualbox default (this is the default with Docker toolkit).

Usage

The git.io URL (https://git.io/v2tb5) is a shortened form of the raw url of the plist.

#!/bin/bash
usage ()
{
cat <<UsageHERE
boot2docker-fwd -- Helper function to quickly manage port forwards between the boot2docker-vm and the host
Usage: boot2docker-fwd [ -n RULE_NAME ] [ -h HOST_PORT ] [ -p {tcp|udp} ] [ -i HOST_IP ] GUEST_PORT
or boot2docker-fwd -d RULE_NAME
or boot2docker-fwd -l
or boot2docker-fwd -A
@gilgamez
gilgamez / reject-if-undefined.js
Created June 14, 2016 11:40
Promise reject if falsey
const rejectIfUndefined = (value, E = Error, message = '') => new Promise((resolve, reject) => {
if (value) {
resolve(value);
} else {
reject(new E(message));
}
});
@gilgamez
gilgamez / gist:00fc127e7afc2ec4598f2c5066e835b9
Created July 12, 2016 14:03 — forked from eduardocardoso/gist:82a629882ddb02ab3677
Script to delete exited containers and untagged/unused images from docker
#!/bin/bash
set -o errexit
echo "Removing exited docker containers..."
docker ps -a -f status=exited -q | xargs -r docker rm -v
echo "Removing dangling images..."
docker images --no-trunc -q -f dangling=true | xargs -r docker rmi
@gilgamez
gilgamez / log-with-supplier
Created January 8, 2019 15:04
wrapper method that evaluates toString dynamically, useful in performance sensitive logging
#!java --source 11
import java.util.function.Supplier;
import java.util.List;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.stream.Stream;
public class LogWithSuplier {

Keybase proof

I hereby claim:

  • I am gilgamez on github.
  • I am gilgamesh (https://keybase.io/gilgamesh) on keybase.
  • I have a public key ASAhEF_oRwZ44BBiUYItOZi2UVMfiy_bJOSiIPwZ0EXWBwo

To claim this, I am signing this object: