Skip to content

Instantly share code, notes, and snippets.

public class ObjectsAndEquals
{
public static void main(String[] args)
{
Integer m0 = 127;
Integer m1 = 127;
System.out.println(m0 == m1); // true
System.out.println(m0.equals(m1)); // true
Integer n0 = 128;
package com.example;
/**
* Requires java 5+
*/
public class FluentBuilderExample {
public static void main(String[] args) {
System.out.println(FooBuilder.create().bar().prop("setting the bar prop!").build().build().toString());
}
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC8oxgvGh9mj3DGukQ/iUeeEkkmM7NwJIAwrkYAmZIEo8kqS1fbs6S91m6/4SXYfbzd7FW7ltwNPiJrkeJahX+KiX3au29ZhtGw/SJiMWzeutHex0qkx4cgBnWFdlyrHAz/rGofSARI+PQM6jKWvTJ50JrMjt1/vy51dKRplBUHeGYLb33cTMxk1+wBznO8mDq+wbob3zqvcMqnPHp1Nm8qUdonISn49Pub1F8fgJEuaJS16pTJQxdAcY9nVq+X7K2D4MLIzeZJTPAw+FB7rQe1P7GqPmCNyGYkTrGlpo2cbO/fwmIYQqc2ND+uJSgzdB7v0KsbP9d3jNm60htWYvgD
@djeikyb
djeikyb / Interpolate
Created February 28, 2015 21:01
Linear interpolation
package com.example;
public final class Interpolate {
private static final String pattern = "{}";
public static String interpolate(String msg, Object...args) {
if (args == null || args.length < 1) return msg;
int idx = msg.indexOf(pattern);
if (idx == -1) return msg;
@djeikyb
djeikyb / Tablifier.java
Last active August 29, 2015 14:17
Creates a simple ascii table from an array of objects
/**
* LICENSE: wtfpl v1 or v2, at your whim
*
* @Test
* public void test() throws IllegalArgumentException, IllegalAccessException {
* String expected = ""
* + "| a | b | c |"
* + "\n|-------+------+--------|"
* + "\n| one | null | five |"
* + "\n| seven | nine | eleven |"
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.pdf.AcroFields;
import com.itextpdf.text.pdf.FdfReader;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.PdfStamper;
@djeikyb
djeikyb / flac2mp3
Last active September 26, 2015 23:11
#!/bin/sh
source "$(which libsolarized.sh)"
function fileError() {
local err=$1
local f=$2
echo "$base1$err: $base2$f$reset"
exit 1
}
@djeikyb
djeikyb / rotate
Last active September 26, 2015 23:57
#!/usr/bin/env bash
if [[ -z $1 || ! -f $1 ]]; then
exit 1
fi
base=$1
last=""
@djeikyb
djeikyb / fixsort
Created January 28, 2012 08:13
Copy TPE1 to TSOP to prevent ipod displaying first last but sorting last first
#!/bin/bash
# Requires mutagen. I used 1.20
# http://code.google.com/p/mutagen/
#
# Changes artist sort tag from Last, First to just
# be whatever the artist name is.
"ls" *mp3 | while read FILE
do
TPE1=$(mid3v2 -l "$FILE" | "grep" TPE1 | cut -d= -f2)
@djeikyb
djeikyb / gist:5680749
Created May 30, 2013 20:08
playing with fibonacci sequence generators
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Fibonacci
{
public static void main(String...args)
{
// fib(new BigInteger("7886"));