Skip to content

Instantly share code, notes, and snippets.

@jimjam88
jimjam88 / implode.java
Last active January 30, 2018 15:53
A Java mimic of PHP's implode function
// Imports required
import java.util.List;
import java.lang.StringBuilder;
/**
* Mimic's PHP's implode function.
*
* @param glue The character(s) you want to stick the peices together with
* @param array The subject
* @return A string concatenation of the List items
@jimjam88
jimjam88 / stackTraceToString.java
Last active January 4, 2016 03:09
Convert a Java exception stack trace to a string delimited by "\n"
// Imports required
import java.lang.StringBuilder;
/**
* Convert a debug back trace to a string.
*
* @param e The exception to be traced
* @return The stack trace as a string
*/
final public static String stackTraceToString(Throwable e)
@jimjam88
jimjam88 / print-resultset.java
Last active February 16, 2019 15:37
Print an ResultSet to the console (STDOUT)
// Imports required
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
/**
* Print a result set to system out.
*
* @param rs The ResultSet to print
* @throws SQLException If there is a problem reading the ResultSet
@jimjam88
jimjam88 / read-file.java
Created January 22, 2014 14:30
Read the contents of a file into a string
// Imports required
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
/**
* Read in a file.
*
* @param path The explicit path to the file to read
* @return The contents of the file as a string
@jimjam88
jimjam88 / convert-date.java
Created January 23, 2014 11:36
Java method to convert a date from one format to another
// Imports required
import java.text.SimpleDateFormat;
import java.text.ParseException;
/**
* Convert a date to a different format.
*
* @param currentFormat The current date format
* @param newFormat The new date format
* @param subject The date that's going to be converted
@jimjam88
jimjam88 / .vimrc
Created August 22, 2014 19:38
vimrc
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/vundle/
filetype plugin indent on " required!
"
" Brief help
" :BundleList - list configured bundles
" :BundleInstall(!) - install(update) bundles
@jimjam88
jimjam88 / .hg-prompt.sh
Created August 22, 2014 19:39
Mercurial branch in command prompt
function hg_in_repo() {
hg branch 2> /dev/null | awk '{print "on "}'
}
function hg_dirty() {
hg status --no-color 2> /dev/null \
| awk '$1 == "?" { print "?" } $1 != "?" { print "!" }' \
| sort | uniq | head -c1
}
@jimjam88
jimjam88 / .hgrc
Created August 22, 2014 19:41
hgrc
[ui]
username =
verbose = True
[auth]
storm.prefix =
storm.username =
storm.password =
[color]
@jimjam88
jimjam88 / .gitconfig
Created August 22, 2014 19:42
Git config
[user]
email =
name =
[alias]
ci = commit
st = status -sb
co = checkout
di = diff
dis = diff --staged
@jimjam88
jimjam88 / php-configure.sh
Last active August 29, 2015 14:05
PHP Configure
brew install mysql libjpeg libpng gd mcrypt openssl;
./configure \
--prefix=/usr \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--sysconfdir=/private/etc \
--with-apxs2=/usr/sbin/apxs \
--enable-cli \
--with-config-file-path=/etc \
--with-libxml-dir=/usr \