Skip to content

Instantly share code, notes, and snippets.

View benevans's full-sized avatar

Ben Evans benevans

  • Microsoft Corporation
  • Hamilton, NZ
View GitHub Profile
@benevans
benevans / artifactory.sh
Created September 25, 2014 10:46
Artifactory start script for supervisord
#!/bin/bash
# Artifactory start script for supervisord
# Derived from http://serverfault.com/questions/425132/controlling-tomcat-with-supervisor
ARTHOME=$HOME/artifactory-3.3.1
function shutdown() {
echo "$(date): Shutting down Artifactory"
$ARTHOME/bin/artifactory.sh stop
}
@benevans
benevans / af-offline-query.xsl
Created July 1, 2014 10:01
Enable/disable an Artifactory Proxies' offline mode from the command line
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:af="http://artifactory.jfrog.org/xsd/1.5.1">
<xsl:output method="text" indent="no"/>
<xsl:template match="text()"/>
<xsl:template match="af:config/af:offlineMode">
<xsl:value-of select="./text()" />
import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import java.net.InetSocketAddress;
import java.util.concurrent.CountDownLatch;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.string.StringEncoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
@benevans
benevans / canonical_path
Last active December 19, 2015 08:19
Finds the real path of a possibly symlinked pathname.
#!/usr/bin/env bash
# Adapted from Maven's mvn script.
# Given a path possibly containing symlinks, work back to get the
# real path. Useful when a script needs to derive its base dir from
# $(dirname $0), but $0 is a symlink to the real script.
canonical_path() {
local path="$1"
while [ -L "$path" ]; do
local link="$(expr "$(ls -ld "$path")" : '.*-> \(.*\)$')"
@benevans
benevans / add_to_var
Last active December 10, 2015 22:18
Appends value(s) onto the given VAR with a delimiter.
#!/usr/bin/env bash
# Appends value(s) onto the given VAR, separated by delim.
# If not specified, delim is $IFS.
# Example: building a list of command-line options
# addto OPTIONS -server -Dfoo=true
# addto OPTIONS -host 127.0.0.1 -port 9999
# addto OPTIONS -debug
# program ${OPTIONS} "$@"