Skip to content

Instantly share code, notes, and snippets.

@monksy
monksy / startKafka.sh
Created October 10, 2018 20:38
Start kafka
#!/bin/bash
cd /home/steven/Downloads/kafka/kafka_2.12-1.1.1
tmux new-session \; \
send-keys 'bin/zookeeper-server-start.sh config/zookeeper.properties' C-m \; \
split-window -h \; \
send-keys 'bin/kafka-server-start.sh config/server.properties' C-m \;
@monksy
monksy / Fizzbuzz.scala
Created April 26, 2018 03:10
Fizzbuzz in scala
def fizzBuzz(number: Int): String = {
number match {
case z if z % 3 == 0 && z % 5 == 0 => "Fizzbuzz"
case z if z % 3 == 0 => "Fizz"
case z if z % 5 == 0 => "Buzz"
case _ => number.toString
}
}
(1 to 100).foreach(a=> println(fizzBuzz(a)))
@monksy
monksy / upgradeServicefolderByGit.sh
Last active February 22, 2016 15:15
This gist is responsible for upgrading a system service (systemd) and going into the folder by it's specified user and performing a git pull. After the pull occures bring the service back up.
#! /bin/sh
if [ $# -lt 3 ]; then
echo "No arguments supplied."
echo " Example: upgradeFoldByBash: [Service name] [service account] [folder]"
exit 1
fi
echo "Stopping the $1 Service"
systemctl stop $1
@monksy
monksy / gist:e5db51c39a589333e8b5
Last active August 29, 2015 14:04
Generate a Flight Radar image for background reasons
#!/bin/bash
# */15 9-18 * * 1,2,3,4,5 /home/shicks/testenvironment/flightradar/flightscreenshot.sh
rm desktopfile.png
xvfb-run -a -s "-screen 0 3200x900x24" wkhtmltoimage --width 1500 --height 900 --javascript-delay 3000 --crop-x 224 --crop-y 51 --crop-w 930 --crop-h 352 -q http://www.flightradar24.com/41.98,-87.91/8 desktopfile.png
width=`identify -format %w desktopfile.png`;
datetime="`date`"
rm annotateddesktop.png
convert -background '#0008' -fill white -gravity center -size ${width}x30 caption:"ORD @ $datetime" desktopfile.png +swap -gravity south -composite annotateddesktop.png
@monksy
monksy / gist:4948011
Created February 13, 2013 20:37
This class is responsible for finding all of the classes within a package path. This does not work for remote packages. This code was based on the work found here: http://svn.apache.org/repos/asf/incubator/chukwa/trunk/src/main/java/org/apache/hadoop/chukwa/util/ClassUtils.java http://tapestry.1045711.n5.nabble.com/T5-Auto-Binding-of-DAOs-td5715…
import com.google.common.base.Preconditions;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.JarURLConnection;
import java.net.URL;
import java.net.URLDecoder;
import java.util.*;
import java.util.jar.JarEntry;