Skip to content

Instantly share code, notes, and snippets.

@colin-haber
colin-haber / gist:977837
Created May 18, 2011 01:39
JConsolePane.print()
public void print(String tag, String message) {
AttributeSet as = StyleContext.getDefaultStyleContext().addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, foregroundColor);
try {
if (isTimestampEnabled) {
sdConsole.insertString(sdConsole.getLength(), "[" + timestampFormat.format(new Date()) + "] ", as);
}
sdConsole.insertString(sdConsole.getLength(), "[" , as);
for (int i=0;i<tag.length();i++) {
if (new Character(tag.charAt(i)).equals('\\')) {
i++;
@colin-haber
colin-haber / gist:994301
Created May 26, 2011 22:58
Grid Standard Pack 1.7.1
eJzNWMt247gR/aFZ5WSLhSVZtjuWrDE17TPZQWSJxBEIMCBoNf8+twDwJcuZWWYjE7cKr3rcKlhqf5D
55SW3RmyoJed/k3ehd9uS4B8e7GXrBf8ECRW7rq2ctbXA96rz3hoWrEiVNIqerA56LFnL3HetOGipgm
bcJqtcdxJvWn1SVGDR0RFpkp/UipWyNS2xAImVsxcy2qbTHZShPVGhhzkM3AjuTtxbV0u9ku4iPqwtN
vgYpgWQPwZwpVxeBTR8bawPx81ko5UpRbjLDOCpYjhHwsLEOD2gOBkOrGUYfVQk/XJUOtm2b4bWVtvO
iVdVVn60yUIj870m8eSSeSfZ8WrTbL7HnclQiJOfZR+vWR66urkoI9awekMuujwcVdYna/8fxhvlvOC
fEB1KayrG4RNfa4qdMLzr/SB5JVP6SrxaUwafGHvdOHWePMHIHaUbCJFtLitt84tYayyr8uCtEPsVtb
4VHwgAKibUybM/yhMs/yeFSFpZe2kr0hz5CXqXhbLD4Lg/xhDILp3WwYscs9amyIiJIpsJeUbKBKe+y
qKgmdq7VLq9GWL71kMJATBiG/KUeyyXIU3ClpkqTQPF8dDslxQo43rP0hTTvY4W8U6z7VZWTvNli+C1
yJV3klq1XuUMb60riV3Q+iH/AnS0jXgxxU8yPoZB25BpZSXenJGelCm61jsldUzjFitnqqAknsCts8a
LR4RT21Ix4SvwoHgi6U7214QedAffJfsdpKH58lqBb5JC1mjp/0r25mCMnxKnjJd4wVkCxhYIcQniXA
@colin-haber
colin-haber / gist:994558
Created May 27, 2011 02:56
JavaCon Error Stream handling
Thread t = null;
try {
final PipedOutputStream errOut = new PipedOutputStream();
System.setErr(new PrintStream(errOut));
final BufferedReader errIn = new BufferedReader(new InputStreamReader(new PipedInputStream(errOut)));
t = new Thread(
new Runnable() {
public void run() {
try {
this.wait();
@colin-haber
colin-haber / gist:997953
Created May 29, 2011 17:02
Print Queue Handler
private void runPrinter() {
new Thread(new Runnable() {
@Override
public void run() {
while (true) {
if (!JConsolePane.this.messages.isEmpty()) {
JConsolePane.this.print(JConsolePane.this.messages.get(0));
JConsolePane.this.messages.remove(0);
}
}
@colin-haber
colin-haber / gist:1003796
Created June 2, 2011 02:21
unnable Why You No Work
//This works.
new ServerHandler(WorldServer.this, WorldServer.this.listener.accept());
//This does not.
new ServerHandler(WorldServer.this, WorldServer.this.listener.accept()).start();
//Yes, ServerHandler implements Runnable.
@colin-haber
colin-haber / gist:1007345
Created June 3, 2011 23:22
detailed debug message : 388 characters
System.out.println(text + System.getProperty("line.separator") + Thread.currentThread().getStackTrace()[stackDepth].getFileName() + ":" + Thread.currentThread().getStackTrace()[stackDepth].getLineNumber() + System.getProperty("line.separator") + Thread.currentThread().getStackTrace()[stackDepth].getClassName() + "." + Thread.currentThread().getStackTrace()[stackDepth].getMethodName());
private void initPrinter() {
new Thread(new Runnable() { public void run() {while (true) {
Message read = messageQueue.read();
String text = read.getText();
//process and print
} catch (Exception e) {
e.printStackTrace();
}
}}}).start();
}
@colin-haber
colin-haber / gist:1194257
Created September 5, 2011 06:43
A new contender for the Dojo Longest Line Award
tpInput.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(consoleForeground), BorderFactory.createEmptyBorder(4, 4, 4, 4))));
@colin-haber
colin-haber / compare.html
Created September 8, 2011 23:52
lickbike.com price compare buttons
<td valign="top" bgcolor="White" align="right">
<a href="http://www.google.com/search?q=$query&amp;tbm=shop&amp;hl=en">
<div style="background-color: #45a5ff; color: #ffffff; float: left; padding: 6px; font-weight:bold;">Compare Prices</div>
</a>
<!-- This should be placed directly before the <nobr> tag that wraps the price text in the variants table on product pages. -->
@colin-haber
colin-haber / gist:1205212
Created September 9, 2011 00:49
Grid Standard Pack 1.7.3.2
eJztWcly6zgS/KH+BRy0WLbeWLbaVD9Hzw0SSyRCIMEBQcucr58sANxkyuHo81xsMrOwFWqlpHZ7ebp
sT6YUL+Rysn/IWejN1CT4D7+8yNoJ/uMZSndNnVtjCoHnZeOcKZlYksqopwZ8JU+uqcVeS+Xf11STdU
lum6N41eqDggBTB0ukSX5QLZbKFDTFPCSW1lyo1Cbuba9KeiFKdTeGgRtiduCLsYXUS2kv4t2YdI2Hb
pgH+aEDl8qeco/6p7VxfruJrLQqM8FiGbZZjkAeLrq9RMwPDlN4FLvDprX0b+85SScSVVSa+vfMyrp+
LWlltGmseFZZ7nrNTCQS12oSO0qnzOFq4lje5MxQCEyGLlW2b4rqokqxwpGqaA5hq7I4GsPvf9X0rnT
qZxB/k9dGDzx61K/lNzwhn5Vu9zIV77lyNGGinXiTmBCvH2S1bDfaXMlOBwYMZigOjVZVPcX/Jo3/Yo
l/UwL3coFCVN16g1TWCf7jzU1pjem619FZ+tdZc/LMM5WZy8WzKTN/waW5rq06u/6SGZkRuoHgKuVlq
c3pIlYa06pTr8dVTrWrxTusidIBtfLsDvKIa4yXsTTmUuek2ZUi9CZTZbqXw8shWFNyaaJ22AmMseIJ
ztb2Ux+srDzsEc8x/CzTlCIYJle6vnnFHmoHIZhUj63J0clhugTO59dNVFZWEOx3zpYWTa+f70mW6XC
4g4EH0Wi5pZHDeFnDGQy8742kVrVTJ4Y3xmbE91C7zqs9dDCV2JbpbypdsIW6orKWeYhXqkyb2lkldY