Skip to content

Instantly share code, notes, and snippets.

@aembleton
aembleton / itext.java
Created May 8, 2013 11:28
Example of iText that repeats an image all over a page and draws a semi-transparent yellow line on top.
import java.awt.Color;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.MalformedURLException;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
@aembleton
aembleton / diskspace.sql
Created May 8, 2013 14:45
Calculates used disk space on Oracle
SELECT df.tablespace_name "Tablespace",
totalusedspace "Used MB",
(df.totalspace - tu.totalusedspace) "Free MB",
df.totalspace "Total MB",
ROUND(100 * ( (df.totalspace - tu.totalusedspace)/ df.totalspace)) "Pct. Free"
FROM
(SELECT tablespace_name,
ROUND(SUM(bytes) / 1048576) TotalSpace
FROM dba_data_files
GROUP BY tablespace_name
@aembleton
aembleton / listFiles.scala
Created September 19, 2013 09:31
Gets a list of files in a given directory and all child directories
/**
* Gets a list of files in a given directory and all child directories
* @param f This is the File representing the root directory
* @return A list of File objects, each one representing a File inside f, either directly or in a sub-directory
*/
def listFiles(f: File): List[File] = f match{
case f if f.isDirectory => f.listFiles.toList.flatMap(listFiles(_))
case f if f.isFile => List(f)
case _ => Nil
}
@aembleton
aembleton / build.info
Last active December 25, 2015 00:29
Builds a jar
#Sat, 12 Oct 2013 23:12:10 +0100
major=0
minor=1
build=3
@aembleton
aembleton / rename.bat
Created October 15, 2013 14:38
Renames files that have a name ending in 20131015-140115.csv to the current date in the format yyyyMMdd then a -, then the number already in the file name, incremented by 1. File ending in 20131015-140115.csv ran through this script on 1 January 2014 will have their ending renamed as 20130101-140116.csv
@echo off
setlocal enabledelayedexpansion
set FOLDER_PATH=.
set year=%date:~-4%
set month=%date:~3,2%
set day=%date:~0,2%
pushd %FOLDER_PATH%
for %%f in (*csv) do if %%f neq %~nx0 (
set "filename=%%~nf"
set "postfix=!filename:~-6!"
package uk.transactis.csvParsing.util;
public class ArrayUtil {
/**
* Trims all elements of an array without side affect.
*
* @param array
* Array from which to base the output array
* @return A new array that equals input array but with each element
@aembleton
aembleton / CookiesUtil.scala
Created November 18, 2013 09:27
Util for Play Cookies
package util
import play.api.mvc.{Cookie, Cookies}
/**
* Created with IntelliJ IDEA.
* User: arthur
* Date: 17/11/13
* Time: 22:26
* To change this template use File | Settings | File Templates.
@aembleton
aembleton / ImageUtil.scala
Created November 18, 2013 09:28
Implicit ImageUtil class for manipulating images
package util
import java.awt.image.BufferedImage
import java.awt.{Color, Image}
/**
* Created with IntelliJ IDEA.
* User: arthur
* Date: 17/11/13
* Time: 22:26
@aembleton
aembleton / StringUtils.scala
Last active December 28, 2015 15:58
Implict String Utilities
package util
/**
* Created with IntelliJ IDEA.
* User: arthur
* Date: 17/11/13
* Time: 22:26
* To change this template use File | Settings | File Templates.
*/
object StringUtils {

Keybase proof

I hereby claim:

  • I am aembleton on github.
  • I am hiker (https://keybase.io/hiker) on keybase.
  • I have a public key ASDch2xpzBE1fntduHm0Jv_iY4WKDWu_2LQ8_oCLXperbAo

To claim this, I am signing this object: