Skip to content

Instantly share code, notes, and snippets.

@ianhomer
ianhomer / Message.groovy
Created January 4, 2012 17:16
Simple String Templating with Defaults
import groovy.text.SimpleTemplateEngine
class Message() {
String body
String populateBodyWith(binding) {
new SimpleTemplateEngine().createTemplate(body).make(binding.withDefault { '${' + it + '}' })
}
}
# Create SSH key - alternative to ssh-copy-id
export USER=me
export HOST=myhost.com
if [ ! -f ~/.ssh/${USER}_rsa ] ; then echo "Creating SSH key" ; ssh-keygen -t rsa -f ~/.ssh/${USER}_rsa -C "${USER} access" ; fi
cat ~/.ssh/${USER}_rsa.pub | ssh $USER@$HOST 'mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat - >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys'
cat >> ~/.ssh/config << EOF
<!-- Tridion JSP template with contextual selection -->
<%@taglib prefix="context" uri="http://context.sdl.com/taglib" %>
<tcdl:if expression="os.model == 'Android'">
Would you like to try our new Android app?
- <a href=" ... google app store link ... ">download now</a>
</tcdl:if>
# Add to /etc/bashrc to customise command prompt
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="(production) - \u@\[\e[1;31m\]myhost.com\[\e[0m\]:\w \\$ "
@ianhomer
ianhomer / report-jar-implementations.sh
Last active August 29, 2015 13:57
List implementation details (including version) from jar manifests (ONE LINE)
find . -name "*.jar" -exec unzip -p {} META-INF/MANIFEST.MF \; | grep Implementation
@ianhomer
ianhomer / find-needle-in-haystack.sh
Last active August 29, 2015 13:59
Find text in files in folder (recursively)
ack needle
@ianhomer
ianhomer / ldap-continue-after-error
Created May 8, 2015 12:50
LDAP Add continue after error
# -c => Continue after error
ldapadd -c -x -W -D "cn=admin,dc=id,dc=sdl,dc=com" -f id_test_data.ldif
@ianhomer
ianhomer / curl-ipv4.sh
Last active June 17, 2024 03:56
Force CURL to use ipv4
# curl not smart enough for ipv6, so force ipv4
# on my mac I started to get localhost connect failure
#
# curl: (7) Failed to connect to localhost port 9031: Connection refused
echo '--ipv4' >> ~/.curlrc
#!/bin/bash
# Set static routing tables to route some external IP addresses
# direct instead of via VPN
action=${1:-create}
gateway=${2:-192.168.1.254}
nonVpnHosts=${3:-$NON_VPN_HOSTS}
if [ -z "$nonVpnHosts" ] ; then