Skip to content

Instantly share code, notes, and snippets.

View bric3's full-sized avatar
💭
🤨

Brice Dutheil bric3

💭
🤨
View GitHub Profile
@bric3
bric3 / install_jdk5_post_lion.sh
Last active April 18, 2023 06:50
Automate the install of JDK 5 on Lion, Mountain Lion, Mavericks
# _______ _ _ _ _ _
# |__ __| | (_) (_) | | | |
# | | | |__ _ ___ ___ ___ _ __ _ _ __ | |_ _ __ ___ _____ _____ __| |
# | | | '_ \| / __| / __|/ __| '__| | '_ \| __| | '_ ` _ \ / _ \ \ / / _ \/ _` |
# | | | | | | \__ \ \__ \ (__| | | | |_) | |_ | | | | | | (_) \ V / __/ (_| |
# |_| |_| |_|_|___/ |___/\___|_| |_| .__/ \__| |_| |_| |_|\___/ \_/ \___|\__,_|
# | |
# |_|
#
# New home : https://github.com/bric3/osx-jdk5-installer
@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 / hckr.zsh-theme
Last active January 24, 2017 16:41
hckr theme for oh-my-zsh
# HCKR oh-my-zsh theme
#
# see http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#SEC59
# inspired from http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/
# http://forrst.com/posts/Oh_my_zsh_iTerm2_Nice_Colors_git_hg_suppo-1Ct
#
# Dependencies
# ============
# svn-fast-info plugin
# battery plugin
@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 / URLPuzzler.java
Created October 29, 2013 17:06
Guess what could be printed on stdout !
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashSet;
public class URLPuzzler {
public static void main(String ... a) throws MalformedURLException, InterruptedException {
HashSet set = new HashSet();
set.add(new URL("http://google.com"));
System.out.println("containing `new URL(\"http://google.com\")` ? : " + set.contains(new URL("http://google.com")));
Thread.sleep(60000);
@bric3
bric3 / EasterEgg.java
Last active December 26, 2015 21:49
Another reason to not use java.util.Random for serious random data ;)
import java.util.Random;
public class EasterEgg {
public static void main(String[] args) {
System.out.println(new EasterEgg());
}
public String toString() {
return String.format(
"%s %s %s %s %s!\n\tSigned by %s, %s, %s, %s, %s, %s, %s, %s%s, %s, %s, %s, %s",
#!/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: $*"