Skip to content

Instantly share code, notes, and snippets.

@wytten
wytten / .gitignore
Last active December 14, 2015 07:08
Submit a number of tasks to be executed by a fixed-size thread pool, then be informed as each task is completed. Exit when all are complete.
*.class
*~
.project
@wytten
wytten / TestHyperlink.groovy
Created March 8, 2013 15:06
Groovy Swing Hyperlinks
VERSION=1.2.0
EMACS=emacs
PREFIX=/usr/local
SYSCONFDIR=/etc
ELS=magit.el magit-svn.el magit-topgit.el magit-stgit.el magit-key-mode.el magit-bisect.el magit-wip.el rebase-mode.el magit-blame.el
ELS_CONTRIB=contrib/magit-simple-keys.el contrib/magit-classic-theme.el
ELCS=$(ELS:.el=.elc)
ELCS_CONTRIB=$(ELS_CONTRIB:.el=.elc)
DIST_FILES=$(ELS) Makefile magit.texi magit.info README.md magit.spec.in magit-pkg.el.in
DIST_FILES_CONTRIB=$(ELS_CONTRIB) contrib/magit
@wytten
wytten / gist:5213495
Created March 21, 2013 14:35
Popup a swing dialog to accept user input in Groovy
import javax.swing.*
def prompt = {
JFrame jframe = new JFrame()
String answer = JOptionPane.showInputDialog(jframe, it)
jframe.dispose()
answer
}
def first = prompt("Enter a number")
@wytten
wytten / Player.java
Created March 28, 2013 18:20
Getting the "next" value of a Java enumeration
public enum Player {
SOUTH, WEST, NORTH, EAST;
public Player next() {
int index = (this.ordinal() + 1) % values().length;
return values()[index];
}
}
@wytten
wytten / gist:5347343
Created April 9, 2013 16:51
How can I find out from where my class is loaded? Source: http://www.coderanch.com/how-to/java/Java-FAQ
import java.security.ProtectionDomain;
ProtectionDomain protectionDomain = getClass().getProtectionDomain();
File codeLoc = new File(protectionDomain.getCodeSource().getLocation().getFile());
@wytten
wytten / gist:5373366
Created April 12, 2013 16:43
Groovy Server Pages (gsp) example, including no-cache option
<% import org.wyttenbach.dale.groovy.webapp.Example %>
<%
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", 0);
%>
<link rel="stylesheet" href="css/sample.css" type="text/css">
Here is a bunch of text
@wytten
wytten / spaceship.gsp
Last active December 16, 2015 07:09 — forked from aalmiray/gist:5395913
A GSP (Groovy Server Pages) variation of the technique
<% import org.codehaus.groovy.control.CompilerConfiguration %>
<% import org.wyttenbach.dale.groovy.spaceship.* %>
<%
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", 0);
%>
<link rel="stylesheet" href="css/sample.css" type="text/css">
Here is a bunch of text
/*
* Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*