Skip to content

Instantly share code, notes, and snippets.

View jarek-przygodzki's full-sized avatar

Jarek Przygódzki jarek-przygodzki

View GitHub Profile
@jarek-przygodzki
jarek-przygodzki / GroovyConsoleHelper.java
Created September 17, 2012 19:55
groovy.ui.Console helper class
import groovy.ui.Console;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
public class GroovyConsoleHelper {
private final Console console;
@jarek-przygodzki
jarek-przygodzki / RuntimeStacklessException.java
Created September 23, 2012 20:02
Base class for unchecked exceptions that does not fill in a stack trace of the current thread
/**
* Base class for unchecked exceptions that does not fill in a stack trace of
* the current thread
*/
@SuppressWarnings("serial")
public class RuntimeStacklessException extends RuntimeException {
public RuntimeStacklessException() {
super();
}
@jarek-przygodzki
jarek-przygodzki / StacklessException.java
Created September 23, 2012 20:03
Base class for checked exceptions that does not fill in a stack trace of the current thread.
/**
* Base class for checked exceptions that does not fill in a stack trace of the
* current thread.
*/
@SuppressWarnings("serial")
public class StacklessException extends Exception {
public StacklessException() {
super();
}
@jarek-przygodzki
jarek-przygodzki / StacklessExceptionsTest.java
Created September 23, 2012 20:05
Unit test for stackless exceptions
import org.junit.Test;
import static org.junit.Assert.assertThat;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
/**
* Unit test for stackless exceptions
import socket, struct
def inet_ntoa(address):
# !: big-endian; i:int; I:unsigned int;
packed_value = struct.pack('!I', address)
return socket.inet_ntoa(packed_value)
assert inet_ntoa(2130706433) == '127.0.0.1'
@jarek-przygodzki
jarek-przygodzki / jstack.groovy
Created November 25, 2012 20:48
JVM thread dump in Groovy
#!/usr/bin/env groovy
import java.lang.management.*
import javax.management.*
import javax.management.remote.*
import java.text.*
def vmInfo(prop) {
def vmName = prop.getProperty('java.vm.name')
ANT_OPTS=-Dbuild.sysclasspath=ignore
ANT_OPTS=-Dbuild.sysclasspath=ignore -Dbuild.compilerarg=-Xlint:-options
diff -Naur jetm-src-1.2.3\build.properties jetm-modified-src-1.2.3\build.properties
--- jetm-src-1.2.3\build.properties Tue Mar 10 07:17:18 2009
+++ jetm-modified-src-1.2.3\build.properties Sat Dec 01 23:45:56 2012
@@ -1,4 +1,4 @@
-release.version=1.2.3
+release.version=1.2.3.1
release.name=jetm
diff -Naur jetm-src-1.2.3\etc\build\build-contrib.xml jetm-modified-src-1.2.3\etc\build\build-contrib.xml
@jarek-przygodzki
jarek-przygodzki / copyJar.groovy
Last active October 13, 2015 17:07
Copy Jar input/output streams
/*******************************************************************************
* Copyright (c) 2012 Jarosław Przygódzki
*******************************************************************************/
package net.jarekprzygodzki.util.jar
import java.util.jar.*
import java.util.zip.*