Skip to content

Instantly share code, notes, and snippets.

@oliverdaff
oliverdaff / GutenbergCrunch
Created October 31, 2011 22:50
Parse Gutenberg using scala pull parser
import java.io.{FileInputStream, BufferedInputStream}
import scala.io.Source
import scala.xml.pull.{XMLEventReader, EvElemStart, EvElemEnd, EvText}
object GutenbergCrunch
{
private def parseBook( parser : XMLEventReader ) : (String, String, String) =
@oliverdaff
oliverdaff / SimpleDate.html
Created December 5, 2011 10:37
Simple PlayFramework Date Picker tag
<div class="clearfix">
<label for="time">Time</label>
<div class="input">
<select class="small" name="hour" id="hour" size="1">
#{list items:0..23, as:'i'}<option value="${i}"
#{if new Date().format('HH') == Integer.toString(i) }selected="true"#{/if}>${i}:00</option>#{/list}
</select>
</div>
</div>
<div class="clearfix">
@oliverdaff
oliverdaff / TerracottaJMXMonitor.groovy
Created December 7, 2011 04:12
Terracotta JMX Monitor
import javax.management.remote.JMXServiceURL
import javax.management.remote.JMXConnectorFactory as JmxFactory
import java.lang.management.*
def beanName = "org.terracotta:type=Terracotta Server,name=DSO"
def serverUrl = new JMXServiceURL('service:jmx:jmxmp://localhost:9520')
def server = JmxFactory.connect(serverUrl, null).MBeanServerConnection
def liveObjectCount = new GroovyMBean(server, beanName).LiveObjectCount
@oliverdaff
oliverdaff / config.log
Created February 2, 2012 10:08
brew gnutils upgrade error
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by GnuTLS configure 2.12.16, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ ./configure --disable-debug --disable-dependency-tracking --disable-guile --disable-static --prefix=/usr/local/Cellar/gnutls/2.12.16 --with-libgcrypt --without-p11-kit
## --------- ##
## Platform. ##
@oliverdaff
oliverdaff / nexus.rb
Created March 28, 2012 06:18
Nexus Homebrew
require 'formula'
class Nexus < Formula
homepage 'http://www.sonatype.org/nexus/'
url 'http://www.sonatype.org/downloads/nexus-2.0.2-bundle.tar.gz'
md5 '7403fbcb06eea8d20f85c5ed36661570'
skip_clean :all
def install
@oliverdaff
oliverdaff / nexus.rb
Created March 28, 2012 06:19
Nexus Homebrew
require 'formula'
class Nexus < Formula
homepage 'http://www.sonatype.org/nexus/'
url 'http://www.sonatype.org/downloads/nexus-2.0.2-bundle.tar.gz'
md5 '7403fbcb06eea8d20f85c5ed36661570'
skip_clean :all
def install
@oliverdaff
oliverdaff / NexusArtifactCleanup.groovy
Created March 29, 2012 05:47
Clean up nexus artifacts with API
import groovyx.net.http.*;
import static groovyx.net.http.ContentType.*;
import static groovyx.net.http.Method.*;
class NexusArtifactCleanup {
/**
* Settings in which to run script.
*/
@oliverdaff
oliverdaff / jira-precommit.sh
Created April 24, 2012 00:02
svn JIRA Precommit hook
#!/bin/sh -x
## REST API JIRA KEY check
#List of projects that do not require strict JIRA KEY commits
#list in space and case-insensitive
NON_STRICT="sports"
# Authentication credentials
username=root
@oliverdaff
oliverdaff / packagefacts.rb
Created June 7, 2012 00:16
Facter to set facts of versions installed
require 'puppet'
require 'puppet/application'
require 'facter'
typeobj = Puppet::Type.type("package")
properties = typeobj.properties.collect { |s| s.name }
format = proc {|trans|
trans.dup.collect do |param, value|
if value.nil? or value.to_s.empty?
trans.delete(param)
@oliverdaff
oliverdaff / fact_curl_request.sh
Created June 7, 2012 00:23
Get facts from puppet master
#expose yam facts under /var/lib/puppet/yaml/facts/ in /etc/puppet/fileserver.conf and access via http
curl -k -H "Accept: yaml" https://puppetmaster:8140/production/facts/hostname