Skip to content

Instantly share code, notes, and snippets.

View jarrad's full-sized avatar

jarrad jarrad

  • NC
View GitHub Profile
@jarrad
jarrad / AssertExceptionLamda.java
Last active July 20, 2016 19:40
Assert an Exception was thrown in JUnit with lambdas
assertThrows(MyException.class,
() -> systemUnderTest.throwingMethod());
// now do other testy things
@jarrad
jarrad / updates.sh
Created June 22, 2016 15:15
Check for dependency updates
mvn versions:display-dependency-updates
@jarrad
jarrad / template
Created June 21, 2016 12:18
Eclipse Guava checkNotNull template
${:importStatic(com.google.common.base.Preconditions.checkNotNull)}${var} = checkNotNull(${var});
@jarrad
jarrad / equals.template
Created October 30, 2015 02:19
Insert a basic equals method into your class
${:import(java.util.Objects)}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (!(obj instanceof ${enclosing_type})) {
return false;
}
${enclosing_type} other = (${enclosing_type}) obj;
@jarrad
jarrad / fizzBuzz.go
Last active August 28, 2015 19:53
FizzBuzz in golang
package main
import "fmt"
func main() {
for i := 0; i < 100; i++ {
m3 := i % 3 == 0
m5 := i % 5 == 0
@jarrad
jarrad / install-kafka.txt
Last active August 24, 2023 08:23
Install Kafka on OSX via Homebrew
$> brew cask install java
$> brew install kafka
$> vim ~/bin/kafka
# ~/bin/kafka
#!/bin/bash
zkServer start
kafka-server-start.sh /usr/local/etc/kafka/server.properties
@jarrad
jarrad / gunsoutsoftware.txt
Created March 11, 2015 01:36
G★O - Guns Out Software ASCII header
__ _____
___ ___ _____ ___ ___ __ __/ /____ ___ / _/ /__ _____ ________
/ _ `/ // / _ \(_-</ _ \/ // / __(_-</ _ \/ _/ __/ |/|/ / _ `/ __/ -_)
\_, /\_,_/_//_/___/\___/\_,_/\__/___/\___/_/ \__/|__,__/\_,_/_/ \__/
/___/
@jarrad
jarrad / devise_skip_confirmation.rb
Last active August 29, 2015 14:16
Skip Devise Confirmation
user = User.find(user_id).skip_confirmation!
user.save!
@jarrad
jarrad / lgfiles.sh
Last active August 29, 2015 14:15
find large files from the shell
find . -type f -size +10000k -exec ls -lh {} \; | awk '{ print $0 ": " $5 }'
@jarrad
jarrad / javahog.sh
Created February 11, 2015 14:18
Find the Java Thread that is hogging your CPU
# first find the process using top
top -H
# find the java process
top - 15:32:53 up 1 day, 2:20, 1 user, load average: 1.28, 1.17, 1.18
Tasks: 2355 total, 2 running, 2353 sleeping, 0 stopped, 0 zombie
Cpu(s): 26.4%us, 1.4%sy, 0.0%ni, 66.1%id, 5.7%wa, 0.0%hi, 0.2%si, 0.2%st
Mem: 16332248k total, 9613508k used, 6718740k free, 312148k buffers
Swap: 1048572k total, 0k used, 1048572k free, 1858716k cached