Skip to content

Instantly share code, notes, and snippets.

View dreadwarrior's full-sized avatar
📚
Currently totally into books 😊

Tommy Juhnke dreadwarrior

📚
Currently totally into books 😊
View GitHub Profile
@dreadwarrior
dreadwarrior / DropwizardToMicrometerBridge.java
Created July 14, 2022 10:04 — forked from jonmcewen/DropwizardToMicrometerBridge.java
Hacky bridge to grab dropwizard metrics and stick them into a micrometer registry. Add as a spring-boot Bean
package com.boohoo.esbdefused.metrics;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import com.codahale.metrics.Counter;
import com.codahale.metrics.Gauge;
import com.codahale.metrics.Histogram;
import com.codahale.metrics.Meter;
import com.codahale.metrics.MetricRegistry;
@dreadwarrior
dreadwarrior / kata-origin.java
Created June 30, 2022 15:29
Java Kata: Optional, Stream and List operations
ArrayList<String> list = new ArrayList<>();
String configs = params.getConfigurationIds(); // TODO: CSV list payload
if (configs != null && !configs.trim().isEmpty()) { // TODO: compare with call to StringValidator.isEmptyString() at line 5
// split the list and put all items into the list
if (!StringValidator.isEmptyString(configs)) { // TODO: method body like: string == null || string.trim().isEmpty()
String[] feld = configs.split(",");
if (feld != null) {
if (feld.length > 0) {
for (String dummy : feld) {
String tmp = dummy.trim();
@dreadwarrior
dreadwarrior / rollyourown.php
Created June 13, 2018 09:19 — forked from mathiasverraes/rollyourown.php
We don't need no DIC libs / we don't need no deps control
<?php
// Context: I'm trying to argue that DI (and DIC) are great, and DIC libs suck.
// Happy to be proven wrong!
final class Router {
private $dependencies;
public function __construct (Dependencies $dependencies) {
$this->dependencies = $dependencies;
// You might say that this is Service Locator, but it's not. This router is toplevel,
// and toplevel must have access to dependencies. After that it can all just bubble nicely using proper DI.

Test Doubles

There are five types:

  • Dummy
  • Stub
  • Spy
  • Mock
  • Fake
@dreadwarrior
dreadwarrior / gitproxy-socat
Created June 19, 2016 20:14 — forked from sit/gitproxy-socat
A simple wrapper around socat to use as a git proxy command
#!/bin/sh
# Use socat to proxy git through an HTTP CONNECT firewall.
# Useful if you are trying to clone git:// from inside a company.
# Requires that the proxy allows CONNECT to port 9418.
#
# Save this file as gitproxy somewhere in your path (e.g., ~/bin) and then run
# chmod +x gitproxy
# git config --global core.gitproxy gitproxy
#
# More details at http://tinyurl.com/8xvpny
@dreadwarrior
dreadwarrior / HOWTO.md
Last active June 6, 2016 11:39
How to block trello.com Stickers with uBlock Origin
  1. Open the uBlock dashboard
chrome://ublock0/content/dashboard.html
  1. Switch to "My Filters" and add these lines:
trello.com###board .sticker
@dreadwarrior
dreadwarrior / bash_aliases
Last active September 17, 2015 20:43
bash_aliases
alias g10psn='glances --time 10 --process-short-name'
#alias vmpm="VBoxManage showvminfo $(cat .vagrant/machines/$(vagrant status | sed -n 3p | awk '{print $1}')/virtualbox/id) | grep ^NIC | grep 'host port'"
alias vmpm='vname=`vagrant status | awk "NR==3 {print \\$1}"`; vid=`cat .vagrant/machines/\$vname/virtualbox/id`; VBoxManage showvminfo $vid | grep "^NIC.*host port"'
@dreadwarrior
dreadwarrior / fcgiwrap_gitolite.conf
Last active August 29, 2015 14:26 — forked from alanbriolat/fcgiwrap_gitolite.conf
fcgiwrap setup for gitweb + gitolite
; Spawn fcgiwrap as the user owning the git repositories, with a socket writeable by nginx
[fcgi-program:fcgiwrap_gitolite]
command = /usr/sbin/fcgiwrap
user = gitolite
socket = unix:///var/run/supervisor/%(program_name)s.sock
socket_owner = gitolite:nginx
socket_mode = 0770
@dreadwarrior
dreadwarrior / ssh-keyscan.sh
Created June 11, 2015 16:54
ssh-keyscan.sh
echo "Probing SSH Servers for updating known_hosts file..."
SERVER_LIST=(server1.example.org server2.example.org)
for h in ${SERVER_LIST[*]}; do
ip=$(dig +short $h)
echo "Update known_hosts for ${h} with IP ${ip}"
ssh-keygen -R $h -f /home/vagrant/.ssh/known_hosts
@dreadwarrior
dreadwarrior / 000-SSH+Firewall
Last active August 29, 2015 14:22
Linux Server Diary
1. Change root password after server provision
2. Create unprivileged user
3. Create SSH key pair on client machine and ssh-copy-id to user
4. Adjust /etc/ssh/sshd_config:
PermitRootLogin no
PubkeyAuthentication yes
AllowUsers %user%
PasswordAuthentication no
TCPKeepAlive no
UsePAM no