Skip to content

Instantly share code, notes, and snippets.

HAI 1.2
CAN HAS STDIO?
VISIBLE "Grattis Palle!"
KTHXBYE
@magnuspalmer
magnuspalmer / elasticsearch.sh
Created February 11, 2015 09:17
RedHat initscript for Elasticsearch
### BEGIN INIT INFO
# Provides: elasticsearch
# Required-Start:
# Required-Stop:
# Default-Start: 3 5
# Default-Stop: 0 6
# Short-Description: ElasticSearch
# Description: ElasticSearch
# NoSQL database used by Graylog2
### END INIT INFO
@magnuspalmer
magnuspalmer / tailLogFile.groovy
Created March 7, 2015 08:40
Groovy tail -f using Apache Commons IO
@Grapes([
@Grab(group='commons-io', module='commons-io', version='2.4'),
@Grab('log4j:log4j:1.2.17')
])
import org.apache.commons.io.input.*
import org.apache.log4j.*
import groovy.util.logging.*
@magnuspalmer
magnuspalmer / gist:060c82d32c8436842f2d
Created July 2, 2015 14:11
table repeat with header, body and footer for AngularJS
<table>
<thead>
<tr>
<th ng-repeat="col in myData.header track by $index"> {{col}}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in myData.rows track by $index">
<td ng-repeat="col in row track by $index"> {{col}}</td>
</tr>
@magnuspalmer
magnuspalmer / csv2xml.groovy
Last active August 29, 2015 14:27
CSV To XML Groovy mapping
@Grapes(
@Grab(group='org.apache.commons', module='commons-csv', version='1.1')
)
import org.apache.commons.csv.*
import groovy.xml.*
def inputCSV = '''a,b,c,
e,f,g,
'''
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.mule.tools.devkit</groupId>
<artifactId>mule-devkit-parent</artifactId>
<version>3.7.2</version>
</parent>
@magnuspalmer
magnuspalmer / RestAssuredTest.groovy
Created April 17, 2016 11:36
RestAssured ContentLength
@Grapes([
@Grab('com.jayway.restassured:rest-assured:2.9.0'),
@GrabExclude(group = 'org.codehaus.groovy', module='groovy-all'),
@GrabExclude(group = 'org.codehaus.groovy', module='groovy-xml')
])
import static com.jayway.restassured.RestAssured.*
import static com.jayway.restassured.matcher.RestAssuredMatchers.*
import static org.hamcrest.Matchers.*
import static com.jayway.restassured.config.RestAssuredConfig.*
@magnuspalmer
magnuspalmer / WsliteWithDefaultCharsetUTF8.groovy
Created July 1, 2016 09:54
How to replace default charset used by wslite responses
@Grapes(
[
@Grab(group='com.github.groovy-wslite', module='groovy-wslite', version='1.1.2'),
]
)
import wslite.rest.*
import wslite.http.HTTP
String restEndpoint = "http://someurl"
@magnuspalmer
magnuspalmer / install-docker.sh
Created September 2, 2016 13:22
Install a specific version inside jenkins docker image
echo deb http://http.debian.net/debian wheezy-backports main > /etc/apt/sources.list.d/backports.list
apt-get update
apt-get install -y apt-transport-https ca-certificates
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo deb https://apt.dockerproject.org/repo debian-jessie main > /etc/apt/sources.list.d/docker.list
apt-get update
#Show the available versions for package docker-engine
#apt-cache showpkg docker-engine
apt-get install docker-engine=1.11.2-0~jessie
@magnuspalmer
magnuspalmer / rancher-setup-windows.md
Created September 22, 2016 09:33
Rancher scratchpad

Setup Rancher on windows for fun and work (and probably Linux as well)

Create a network - ranchernet

docker network create --subnet 173.18.0.0/16 ranchernet

Start the server, use the ranchernet and assign static IP

docker run -d --restart=always --net ranchernet --ip=173.18.0.2 -p 8080:8080 rancher/server

Through the Rancher UI, get the command, but add it also to the rancher net and give static ip

docker run -e CATTLE_AGENT_IP="173.18.0.3" --net ranchernet --ip 173.18.0.3 -d --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.0.2 http://173.18.0.2:8080/v1/scripts/