Skip to content

Instantly share code, notes, and snippets.

View bric3's full-sized avatar
💭
🤨

Brice Dutheil bric3

💭
🤨
View GitHub Profile
#!/bin/bash
LINKDIR=/usr/bin
JHOME=/usr/java/latest
JREDIR=$JHOME/jre/bin
JDKDIR=$JHOME/bin
sudo alternatives --install $LINKDIR/java java $JREDIR/java 20000 \
--slave $LINKDIR/keytool keytool $JREDIR/keytool \
--slave $LINKDIR/orbd orbd $JREDIR/orbd \
# Call `setup_ssh_socket` to setup the control socket (function will return once
# the socket is ready to go), and `ssh_target` will connect using the control socket.
# Assumes TARGET_HOST variable is set.
# The connection is automatically closed when the script exists.
# TARGET_HOST="wolever.net"
# setup_ssh_control_socket
# ssh_target "hostname"
debug() {
echo "DEBUG: $*"
@bric3
bric3 / create_user_schema.sql
Created March 23, 2015 15:13
Simple user/schema ME Oracle SQL creation script
create role ME_ROLE;
grant
create materialized view,
create session,
alter session,
create table,
create indextype,
create sequence,
create synonym,
@bric3
bric3 / gist:670bd9b3ba9783573751
Last active August 29, 2015 14:24
Opening JMX port at runtime

Comment ouvrir les ports JMX remote à chaud

Copied from : http://blog.alexis-hassler.com/2015/06/ouvrir-jmx-remote-chaud.html

Pour permettre un accès distant au MBeans d'une JVM Oracle ou OpenJDK, il faut la démarrer avec la propriété com.sun.management.jmxremote.port, plus quelques autres propriétés détaillées sur JTips.

java -Dcom.sun.management.jmxremote.port=1099 fr.sewatech.myapp.MyMain
@bric3
bric3 / JMXLoopback.java
Created October 14, 2011 10:56
Commodity class to create a JMX loopback connection
import javax.management.MBeanServer;
import javax.management.MBeanServerConnection;
import javax.management.remote.*;
import java.io.IOException;
import java.lang.management.ManagementFactory;
/**
* Utilitarian/commodity class to allow easy JMX testing by setting up a loopback connection
* by wrapping the logic of a {@link JMXConnectorServer}.
@bric3
bric3 / gist:4060796
Created November 12, 2012 17:45 — forked from jbowes/gist:1391823
/**
* Copyright (c) 2011 Red Hat, Inc.
*
* This software is licensed to you under the GNU General Public License,
* version 2 (GPLv2). There is NO WARRANTY for this software, express or
* implied, including the implied warranties of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
* along with this software; if not, see
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
@bric3
bric3 / gist:4060802
Created November 12, 2012 17:46 — forked from jbowes/gist:1391824
/**
* Copyright (c) 2011 Red Hat, Inc.
*
* This software is licensed to you under the GNU General Public License,
* version 2 (GPLv2). There is NO WARRANTY for this software, express or
* implied, including the implied warranties of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
* along with this software; if not, see
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
@bric3
bric3 / server_certificates_to_pem.md
Created November 13, 2012 14:38 — forked from stevenhaddox/server_certificates_to_pem.md
Convert .crt & .key files into .pem file for HTTParty

Two ways to do it, but only worked for me so I'll put it first and the second for reference:

$ openssl pkcs12 -export -in hostname.crt -inkey hsotname.key -out hostname.p12
$ openssl pkcs12 -in hostname.p12 -nodes -out hostname.pem

Other options for this method in comments below:

# Note, the -certfile root.crt appends all CA certs to the export, I've never needed these so it's optional for my personal steps
$ openssl pkcs12 -export -in hostname.crt -inkey hsotname.key -certfile root.crt -out hostname.p12

Note, I've always had my hostname.crt as part of my .pem, so I keep my certs but apparently you may not have to, hence the nocerts flag being an extra option in this sample

@bric3
bric3 / codebreaker.md
Last active November 1, 2015 13:52
recruitment tests

Codebreaker

Implement a simple program that match the requirements below.

The game

Code breaking is all about finding the secret code.

When the game starts the player should be able to guess the secret code by providing a 4 digits number. The game finishes when the player have found the exact match for the secret code.

@bric3
bric3 / CacheSizing.java
Last active November 6, 2015 18:03
Calculate the size of a cache using jol (Java Object Layout) (eviction concerns not taken care of)
public class CacheSizing {
public static final int _10_MEGABYTE = 10_000_000;
// The type Value is a Value Object whose max size is known, that is :
// - no string with "unbounded" variable length
// - no Collection with any size
@Test
public void possible_cache_size_value() {
int possible_cache_size_per_server = 10_000;
LoadingCache<String, Value> c = CacheBuilder.newBuilder()