Skip to content

Instantly share code, notes, and snippets.

View bric3's full-sized avatar
💭
🤨

Brice Dutheil bric3

💭
🤨
View GitHub Profile
@bric3
bric3 / ShadowTest.java
Created February 1, 2022 10:51 — forked from mattdesl/ShadowTest.java
Simple Dynamic Shadows in Java2D
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.Polygon;
import java.awt.RadialGradientPaint;
import java.awt.RenderingHints;
import java.awt.Shape;
@bric3
bric3 / RsyncOverSsh_Fast_Documentation.md
Created June 8, 2020 08:45 — forked from thomasdarimont/RsyncOverSsh_Fast_Documentation.md
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
@bric3
bric3 / Node.java
Created March 13, 2019 15:09 — forked from norswap/Node.java
Fast Java Reflection
package demo;
public interface Node {}
@bric3
bric3 / slack_history.py
Last active June 29, 2018 19:13 — forked from minniel/slack_history.py
Download Slack Channel/PrivateChannel/DirectMessage History
from slacker import Slacker
import json
import argparse
import os
import shutil
import copy
import requests
import urllib3
#from io import open
from datetime import datetime
@bric3
bric3 / WeakeningAgent.java
Created October 1, 2016 19:43 — forked from raphw/WeakeningAgent.java
A Java agent for fixing exports for an app that is not yet Java 9 aware.
import java.lang.instrument.Instrumentation;
import java.lang.reflect.Layer;
import java.lang.reflect.Module;
import java.util.*;
public class WeakeningAgent {
public static void premain(String argument, Instrumentation instrumentation) {
boolean full = argument != null && argument.equals("full");
Set<Module> importing = new HashSet<>(), exporting = new HashSet<>();
@bric3
bric3 / kafka-move-leadership.sh
Created March 24, 2016 10:25 — forked from miguno/kafka-move-leadership.sh
A simple Ops helper script for Apache Kafka to generate a partition reassignment JSON snippet for moving partition leadership away from a given Kafka broker. Use cases include 1) safely restarting a broker while minimizing risk of data loss, 2) replacing a broker, 3) preparing a broker for maintenance.
#!/usr/bin/env bash
#
# File: kafka-move-leadership.sh
#
# Description
# ===========
#
# Generates a Kafka partition reassignment JSON snippet to STDOUT to move the leadership
# of any replicas away from the provided "source" broker to different, randomly selected
# "target" brokers. Run this script with `-h` to show detailed usage instructions.
@bric3
bric3 / benchmark-commands.txt
Created March 6, 2016 22:50 — forked from jkreps/benchmark-commands.txt
Kafka Benchmark Commands
Producer
Setup
bin/kafka-topics.sh --zookeeper esv4-hcl197.grid.linkedin.com:2181 --create --topic test-rep-one --partitions 6 --replication-factor 1
bin/kafka-topics.sh --zookeeper esv4-hcl197.grid.linkedin.com:2181 --create --topic test --partitions 6 --replication-factor 3
Single thread, no replication
bin/kafka-run-class.sh org.apache.kafka.clients.tools.ProducerPerformance test7 50000000 100 -1 acks=1 bootstrap.servers=esv4-hcl198.grid.linkedin.com:9092 buffer.memory=67108864 batch.size=8196
# 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: $*"
#!/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 \
@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