Skip to content

Instantly share code, notes, and snippets.

View cedricvidal's full-sized avatar

Cedric Vidal cedricvidal

View GitHub Profile
@cedricvidal
cedricvidal / jolokia-camel-queries.md
Last active January 1, 2016 06:09
Jolokia Camel queries

Queries Load01, InflightExchanges and LastProcessingTime of all routes

http://localhost:9180/jolokia/read/org.apache.camel:context=*,type=routes,name=*/Load01,InflightExchanges,LastProcessingTime

Queries the current queue size of queue backed endpoints (selects only endpoints which are backed by a queue such as vm and seda)

http://localhost:9180/jolokia/read/org.apache.camel:context=*,type=endpoints,name=*/CurrentQueueSize
@cedricvidal
cedricvidal / .bash_profile
Created January 21, 2014 13:46
Set JDK Bash helper
function setjdk() {
if [ $# -ne 0 ]; then
removeFromPath '/System/Library/Frameworks/JavaVM.framework/Home/bin'
if [ -n "${JAVA_HOME+x}" ]; then
removeFromPath $JAVA_HOME
fi
export JAVA_HOME=`/usr/libexec/java_home -v $@`
export PATH=$JAVA_HOME/bin:$PATH
fi
echo JAVA_HOME set to $JAVA_HOME
@cedricvidal
cedricvidal / Vagrantfile
Created February 6, 2014 00:19
Ubuntu Raring Vagrantfile
Vagrant::Config.run do |config|
config.vm.box = "raring"
config.vm.box_url = "http://cloud-images.ubuntu.com/raring/current/raring-server-cloudimg-vagrant-amd64-disk1.box"
config.vm.share_folder("vagrant-root", "/vagrant", ".")
config.vm.customize ["modifyvm", :id, "--memory", 2048]
end

TLDR: I now add the following snippet to all my Dockerfiles:

# If host is running squid-deb-proxy on port 8000, populate /etc/apt/apt.conf.d/30proxy
# By default, squid-deb-proxy 403s unknown sources, so apt shouldn't proxy ppa.launchpad.net
RUN route -n | awk '/^0.0.0.0/ {print $2}' > /tmp/host_ip.txt
RUN echo "HEAD /" | nc `cat /tmp/host_ip.txt` 8000 | grep squid-deb-proxy \
  && (echo "Acquire::http::Proxy \"http://$(cat /tmp/host_ip.txt):8000\";" > /etc/apt/apt.conf.d/30proxy) \
  && (echo "Acquire::http::Proxy::ppa.launchpad.net DIRECT;" >> /etc/apt/apt.conf.d/30proxy) \
  || echo "No squid-deb-proxy detected on docker host"
import junit.framework.TestCase;
import org.junit.runner.RunWith;
import org.junit.runners.AllTests;
import junit.framework.TestSuite;
@RunWith(AllTests.class)
public final class MasterTester {
public static TestSuite suite() {
TestSuite suite = new TestSuite();
@cedricvidal
cedricvidal / ObservablesCartesianProduct.java
Last active September 5, 2016 14:51
RxJava Observables Cartesian Product
import rx.Observable;
import rx.functions.Func1;
import rx.functions.Func2;
import static java.util.Arrays.asList;
import static java.util.Collections.singleton;
/**
* Computes the cartesian product of Observables.
*
@cedricvidal
cedricvidal / remote-docker-ssh-shellinit.sh
Last active August 31, 2015 09:20
Configure remote docker over SSH
HOST=user@host
# Make sure socat is installed on remote before starting tunnel
ssh $HOST socat -V | grep "socat version" | cat 1>&2
# Start tunnel
echo "starting tunnel" 1>&2
(socat "UNIX-LISTEN:/tmp/$HOST-docker.sock,reuseaddr,fork" "EXEC:'ssh -kTax $HOST socat STDIO UNIX-CONNECT\:/var/run/docker.sock'" 2>&1 | >&2 xargs echo) &
# Tell docker
#!/bin/sh
V=0.2.1;JGFSVD=~/.jgitflow-semver/$V;JGFSV=$JGFSVD/jgitflow-semver-$V.sh; ([ ! -f $JGFSV ] && mkdir -p $JGFSVD && \
wget -q -O $JGFSV http://dl.bintray.com/cedric-vidal/jgitflow-semver/com/quicksign/jgitflow-semver/jgitflow-semver/$V/jgitflow-semver-$V-script.sh && \
chmod a+x $JGFSV || exit 0) && [ `md5 -q $JGFSV` == "90e7e6a8be2c198824e4d443f6f6f68e" ]
$JGFSV $*
@cedricvidal
cedricvidal / TamperedTimestampLoggingEvent.java
Last active March 31, 2016 07:37
Logback timestamp tampering example
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.LoggingEvent;
/**
* @author <a href="mailto:[email protected]">Cedric Vidal, Quicksign</a>
*/
public class TamperedTimestampLoggingEvent extends LoggingEvent {
private final long tamperedTimestamp;
@cedricvidal
cedricvidal / idempotent.py
Last active April 29, 2016 07:47
Command line idempotent python script which uses a Sqlite LSM key value store as idempotent store
#!/usr/bin/env python
from lsm import LSM
import argparse
import time
import sys
parser = argparse.ArgumentParser(description='Idempotent')
parser.add_argument('store', type=str,
help='path of the LSM database to use as idempotent store')
parser.add_argument('--save', type=bool, default=False,