Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

public class RosVerhalten implements Verhalten {
@Override
public void arbeiten() {
System.out.println("das mache ich weil ich es muss ...");
}
@Override
public void chillen() {
System.out.println("Ach meine Leidenschaft ...");
}
@mrbuk
mrbuk / pseudo_java_profiler.sh
Last active August 29, 2015 14:15
A little "pseudo java profiler" for the *NIX command line. Checks the top 10 cpu consuming java threads and prints for each of these the current thread stack. If threads are really really shortlived it can happen that we won't catch them with jstack.
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Usage: $0 jps-filter-grep-expr"
exit 1
fi
jps_filter=$1
# extract the PID of the java process
@mrbuk
mrbuk / ParseHeapDump.sh
Created May 20, 2015 08:52
MAT headless mode
#!/bin/sh
#
# This script parses a heap dump.
#
# Usage: ParseHeapDump.sh <path/to/dump.hprof> [report]*
#
# The leak report has the id org.eclipse.mat.api:suspects
# The top component report has the id org.eclipse.mat.api:top_components
#
@mrbuk
mrbuk / README.md
Last active April 4, 2017 02:24
Sticky IP addresses with VMWare Fusion

It is possible in VMWare Fusion to ensure that a VM will always be assigned the same IP address - this is more convenient than making the VM use static IP via config of the Linux box it uses. The simplest way to achieve this is as follows (all performed on the Mac host, not the Linux guests)

sudo vim /Library/Preferences/VMware\ Fusion/vmnet8/dhcpd.conf

At the bottom of the file, after the following line:-

####### VMNET DHCP Configuration. End of "DO NOT MODIFY SECTION" #######

Before changing the configuration file it is recommended to put the vmnet service into config mode so that the file is not overwritten by Fusion itself. To do so run

@mrbuk
mrbuk / four-clojure-problem-92-1.clj
Last active November 15, 2015 15:47
Solution for 4clojure problem 92
;;
;; first not so idiomatic approach to the problem to convert roman numerals to decimal.
;;
(fn roman-to-dec [s]
(let [default-f (fn [last acc]
(+ acc))
prefixed-f (fn [prefixes]
(fn [last acc]
(if (some #(= % last) prefixes)
@mrbuk
mrbuk / toggle_natural_scrolling.command
Created May 29, 2016 08:08
Toggle natural scrolling on OSX
#!/bin/bash
osascript <<EOF
tell application "System Preferences"
set current pane to pane "com.apple.preference.trackpad"
end tell
tell application "System Events"
tell application process "System Preferences"
tell tab group 1 of window "Trackpad"
@mrbuk
mrbuk / refresh_pac.command
Last active May 29, 2016 18:15
Refresh PAC by disabling/enabling proxy state
#! /bin/sh
read -r -d '' script << _EOF_
networksetup -listallnetworkservices | awk 'NR>1' | while read SERVICE ; do
if networksetup -getautoproxyurl "\$SERVICE" | grep '^Enabled: Yes' >/dev/null; then
networksetup -setautoproxystate "\$SERVICE" off
networksetup -setautoproxystate "\$SERVICE" on
echo "\$SERVICE" bounced.
fi
done
@mrbuk
mrbuk / check_if_skipped.py
Created June 22, 2016 12:32
Check log output for skipped lines
# when checking cf logs invoke with
# awk '{print $4}' log-example.out | egrep '^[0-9]+' | sort -n | python script.py
#
import sys
def checkLineConsistency(previous, current):
if previous[0]+1 != current[0]:
print "Inconsistency between line %d ('%d') and %d ('%d')" % (previous[1], previous[0], current[1], current[0])
@mrbuk
mrbuk / Dockerfile
Last active June 27, 2016 09:27
firehose-to-syslog build env
FROM centos:centos6
# install epel for new git version
RUN rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# golang dependencies: gcc for cgo
RUN yum -y update && yum -y install \
g++ \
gcc \
libc6-dev \
#!/bin/bash
# if the notebook lid is closed the the display is identified as "DisplayPort-0". If the notebook lid is open it is identified as "DisplayPort-1"
# in case of a closed lid "DisplayPort-1 disconnected" can be found in xrandr output.
# default to notebook lid is open
TARGET_DISPLAY="DisplayPort-1"
xrandr | grep 'DisplayPort-1 disconnected' > /dev/null
if [ "$?" == 0 ]; then