Skip to content

Instantly share code, notes, and snippets.

View cescoffier's full-sized avatar
⚗️
Quarking...

Clement Escoffier cescoffier

⚗️
Quarking...
View GitHub Profile
@cescoffier
cescoffier / gist:641920
Created October 23, 2010 08:02
iPOJO Inheritence
public class Parent {
@Requires
LogService log;
public void doSomething() {
log.log();
}
}
public class Child extends Parent {
//...
@cescoffier
cescoffier / gist:1303334
Created October 21, 2011 08:04
Play + MongoDB + Java deployment with puppet
notice: Scope(Class[Play]): Installing Play 1.2.3
notice: Scope(Play::Module[mongodb module]): Installing module mongo-1.3
notice: Scope(Play::Module[less module]): Installing module less-0.3
notice: /Stage[main]/Play/Exec[download-play-framework]/returns: executed successfully
notice: /Stage[main]/Play/Package[unzip]/ensure: ensure changed 'purged' to 'present'
notice: /Stage[main]/Play/Exec[unzip-play-framework]/returns: executed successfully
notice: /Stage[main]/Play/File[/opt/play-1.2.3/play]/mode: mode changed '777' to '755'
notice: /Stage[main]//Play::Module[less module]/Exec[install-play-module-less-0.3]/returns: executed successfully
notice: /Stage[main]/Mongodb/Package[python-software-properties]/ensure: ensure changed 'purged' to 'present'
notice: /Stage[main]/Mongodb/Exec[10gen-apt-repo]/returns: executed successfully
@cescoffier
cescoffier / cleanup_maven_repository.sh
Created January 9, 2012 11:45
A shell script to cleanup your local maven repository. It removes all snapshot from more than 6 months
#!/bin/sh
M2_REPO=${HOME}/.m2
OLDFILES=/tmp/deleted_artifacts.txt
AGE=181 # more or less 6 months and it's a palindromic prime number, so it's cool
echo "==== To be Deleted Jars ====" >> ${OLDFILES}
find "${M2_REPO}" -name '*-SNAPSHOT*jar' -atime +${AGE} -exec dirname {} \; >> ${OLDFILES}
echo "==== To be Deleted Wars/Ears ====" >> ${OLDFILES}
@cescoffier
cescoffier / script
Created January 23, 2012 16:39
Update Jabber server in Jenkins builds.When switching to another Jabber server, builds needs to be updated to use the new Jabber server, i.e. xxx@server1.de needs to become xxx@server2.de.This groovy script just updates the configuration.
import hudson.model.*
import hudson.maven.*
import hudson.maven.reporters.*
import hudson.tasks.*
def instance = hudson.model.Hudson.instance;
// To update to match the old server and new configuration
def oldServer = "akquinet.dnsalias.com";
def newServer = "chat.spree.de";
generateMethodHeader
private void generateMethodHeader(int access, String name, String desc, String signature, String[] exceptions, List<AnnotationDescriptor> annotations, Map<Integer, List<AnnotationDescriptor>> paramAnnotations) {
GeneratorAdapter mv = new GeneratorAdapter(cv.visitMethod(access, name, desc, signature, exceptions), access, name, desc);
mv.visitCode();
Type returnType = Type.getReturnType(desc);
// Compute result and exception stack location
// We also compute the actual Thread stack, when it requires the returned object.
@cescoffier
cescoffier / PlentyOfAnnotations.java
Created April 17, 2012 15:08
Unit Test reproducing FELIX-3461
package test;
import org.apache.felix.ipojo.annotations.*;
import test.ipojo.ExternalHandler;
import java.util.List;
@Component
@Instantiate
public class PlentyOfAnnotations {
@cescoffier
cescoffier / jsdoc3.rb
Created August 19, 2012 07:38
jsdoc 3.0.1 homebrew formula
require 'formula'
class Jsdoc3 < Formula
homepage 'http://usejsdoc.org/'
url 'https://github.com/jsdoc3/jsdoc/tarball/v3.0.1'
sha1 '0c6ad2321d300a3eaa2e1d543f3fbf166ff1ce18'
def install
libexec.install Dir['*']
# Custom invoker that just passes on whatever arguments you give it
@cescoffier
cescoffier / MockitoTest.java
Created February 21, 2013 08:50
Mockito can't be resolved with the Pax Exam Junit bundles.
package org.apache.felix.ipojo.runtime.core;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.CoreOptions;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
import org.ops4j.pax.exam.spi.reactors.PerClass;
@cescoffier
cescoffier / ComponentWithProperties.java
Created May 6, 2013 12:37
Component using static properties
package org.apache.felix.ipojo.runtime.core.test.components.components;
import org.apache.felix.ipojo.annotations.Component;
import org.apache.felix.ipojo.annotations.Instantiate;
import org.apache.felix.ipojo.annotations.Provides;
import org.apache.felix.ipojo.annotations.StaticServiceProperty;
import org.apache.felix.ipojo.runtime.core.test.services.FooService;
import java.util.Properties;