Skip to content

Instantly share code, notes, and snippets.

@timjstewart
timjstewart / j
Created March 10, 2016 20:30
a script that makes creating quick Java projects and experiments easy.
#! /bin/bash
# A script to make it very easy to try things in Java.
#
# Pros:
#
# * Create Java project quickly
# * Create unit test files quickly
# * Create source code files quickly
# * Run unit tests easily
@timjstewart
timjstewart / C
Last active January 20, 2016 17:45
Hi <Brother-In-Law>,
I hear that you are interested in learning a computer programming
language.
Since there are so many different programming languages, I thought I'd
share one resource that attempts to calculate programming language
popularity. Theoretically the more popular a language is, the bigger
the market for the language. That resource is the TIOBE Index.
@timjstewart
timjstewart / jme.el
Last active August 29, 2015 14:26
Testing this out to see if it helps me get better feed back during Java development. Should be a minor mode....
;;; package -- jme - java-mode extensions
;;; Commentary:
;;; Useful Commands:
;;;
;;; jme-check-file-style - run checkstyle on the current file.
;;;
;;; jme-compile-current-file - compile the current file (saving any unsaved
;;; changes).
@timjstewart
timjstewart / Result.java
Created June 23, 2015 04:04
A Java class similar to Haskell's Either.
package com.timjstewart;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.NoSuchElementException;
/**
* A value that can either be a value or a exception.
public void create(final Request request, final Response response) throws Exception {
SubPubMessage subPubMessage = null;
try {
subPubMessage = SubPubMessage.fromFormPost(request);
} catch (Exception e) {
log.error("Could not parse SubPub message, message not ack'd from SubPub.", e);
throw new Exception("Could not parse SubPub message, message not ack'd from SubPub.", e);
}
@timjstewart
timjstewart / Idea #1
Created April 3, 2015 15:12
Would something like this work?
public class VertexProperty extends Element {
// Identifies the vertex that this Element's properties will be upserted to.
private Pair<String, Object> vertexIdentifier;
// Creates a VertexProperty with the vertex key and value used to find the vertex
public VertexProperty(final String key, final Object value) {
this.vertexIdentifier = new Pair<>(
Objects.requireNonNull(key),
Objects.requireNonNull(value)
@timjstewart
timjstewart / Main.java
Created March 31, 2015 16:29
One potential implementation
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.function.Consumer;
/**
* An ad hoc Element class (to be replaced with real Element class).
*/
class Element {
private String key;
@timjstewart
timjstewart / cotd
Created February 19, 2015 16:29
Java 8 Class of the Day
#! /bin/bash
#
# cotd - Class of the Day. Pseudorandomly selects a Java 8 class and
# opens that class' documentation in your default browser.
#
# relative paths to all of the JavaDocs I consider to be useful
# (e.g. no corba, XML, or crypto, etc.)
#
# If you're not interested in some of these, you can safely delete
@timjstewart
timjstewart / 1) The JSON
Created February 11, 2015 23:41
This is the JSON I POSTed to create a schema
{
"namePath": "/item/song",
"descriptionPath": "/item/comments",
"security": {
"rules": []
},
"createdDate": "2013-07-17T09:29:07.089+10:00",
"modifiedDate": "2013-07-17T09:29:07.089+10:00",
"uuid": "32acbf04-f7b7-4187-85cb-2e6f99fe9123",
"name": "Song Schema",
@timjstewart
timjstewart / cabal-init
Last active August 29, 2015 14:10
Quickly create a scratch cabal sandbox and project complete with hspec/QuickCheck tests.
#! /bin/bash
package_name=$(basename `pwd`)
log_file=./cabal-init.log
function fatal() {
echo "$1. Examine ${log_file} for more information." 2>&1
exit 1
}