Skip to content

Instantly share code, notes, and snippets.

View dportabella's full-sized avatar

David Portabella dportabella

  • Lausanne, Switzerland
View GitHub Profile
@dportabella
dportabella / setup_puppet_developer_env_and_run_spec_tests.sh
Last active August 29, 2015 13:59
Set-up an environment to run puppet as a developer and run the spec tests
# here there is a guide about contributing to puppet:
# https://github.com/puppetlabs/puppet/blob/master/docs/quickstart.md
# It says:
# Quick Start to Developing on Puppet
# Before diving into the code, you should first take the time to make sure you have an environment where you can run puppet as a developer.
# In a nutshell you need: the puppet codebase, ruby versions, and dependencies.
# Once you've got all of that in place you can make sure that you have a working development system by running the puppet spec tests.
#
# I didn't manage to install all this in my OSX without breaking other dependencies, so I created a vagrant box with Ubuntu.
# I share here this set-up, so that it can be reproduced easily by anyone.
@dportabella
dportabella / biemond-orawls-vagrant-javaexec-log.txt
Created April 10, 2014 11:41
install weblogic with wlst using biemond-orawls puppet module. this is the log of all java executions, by using this patched vagrant https://github.com/dportabella/biemond-orawls-vagrant/tree/javaexec_log
+++++++++++++++++++++++++++++
+++ EXECUTING JAVA. CMD: java -version +++ start provisioning +++
+++ EXECUTING JAVA. time: 20140410-093331
+++ EXECUTING JAVA. java: /usr/java/jdk1.7.0_51/jre/bin/java
+++ EXECUTING JAVA. cp:
+++ EXECUTING JAVA. user: root
+++ EXECUTING JAVA. running. log: /tmp/log_puppet_weblogic/log-20140410-093331.txt
+++ EXECUTING JAVA. cat /tmp/log_puppet_weblogic/log-20140410-093331.txt. START.
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
@dportabella
dportabella / gist:9388448
Last active August 29, 2015 13:57
ruby, converting an array of hashes to a hash based on hash key
def hasharray2hash(array, hash_key)
if (!array.kind_of?(Array) || !hash_key.kind_of?(String))
raise 'invalid parameters'
end
array.reduce({}){|cumulate,entry|
if !entry.kind_of?(Hash)
raise 'expecting a hash: ' + entry.to_s
end
key = entry[hash_key]
@dportabella
dportabella / dstat
Last active August 29, 2015 13:56
command line tool to list all files, with properties and checksum
#! /bin/bash
# use this script as follows: find . -mount -exec dstat {} \;
# this produces a list as follows:
# Regular File -rw-r--r-- david staff 2013-11-09 01:33:24 2013-11-09 01:33:24 14787 c3a7afd9e3cf89543352ee58e26cfb10 Invoice_41010102336895558_6601081486112013.pdf pdf ./accounting/files/Invoice_41010102336895557_6601081486112013.pdf
# Regular File -rw-r--r-- david staff 2013-09-01 00:41:05 2013-09-01 00:41:05 13636 55b47d2a41d5d6a072439ef2dabacac4 Invoice_41010102336895558_6601108809092013.pdf pdf ./accounting/files/Invoice_41010102336895557_6601108809092013.pdf
# ...
# see http://linux.die.net/man/1/stat for more stat options
if [ -z "$1" ] ; then
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>david.rundeck</string>
<key>ProgramArguments</key>
<array>
<string>/Users/david/bin/rundeck/server/sbin/rundeck_launchd</string>
</array>
@dportabella
dportabella / TestJKS.java
Last active January 26, 2024 19:34
Test your JKS file easily with java -Djavax.net.ssl.trustStore=your_trust_store.jks TestJKS <url> [<user> <password>]
/*
Test your JKS file easily.
You have created a java JKS trust store file to access a webservice with a certificate, and you want to test if it works?
Some colleagues often test this by deploying the jks to the application server (tomcat, weblogic...), restarting the server and manually running tests,
and repeating this procedure until the jks is properly created.
you can speed up this test by using this simple java program:
> javac TestJKS.java
@dportabella
dportabella / gist:5766099
Last active December 18, 2015 10:09
Transform a callback function to an iterator/list (in Scala or Java). See an example use case: http://scalaenthusiast.wordpress.com/2013/06/12/transform-a-callback-function-to-an-iteratorlist-in-scala/
import java.util.concurrent.ArrayBlockingQueue
trait OptionNextToIterator[T] extends Iterator[T] {
def getOptionNext: Option[T];
var answerReady: Boolean = false
var eof: Boolean = false
var element: T = _
def hasNext = {