Skip to content

Instantly share code, notes, and snippets.

View stalep's full-sized avatar

Ståle Pedersen stalep

  • Red Hat
  • Arendal, Norway
View GitHub Profile
@stalep
stalep / gist:4676928
Last active December 11, 2015 23:28
public interface UICommand
{
public UICommandID getId();
public void initializeUI(UIContext context) throws Exception;
public void validate(UIValidationContext context);
public Result execute(UIContext context) throws Exception;
@stalep
stalep / gist:5468815
Created April 26, 2013 17:17
reading a file thats located in a inner jar
import java.util.jar.*;
import java.util.zip.*;
import java.io.*;
import java.util.*;
public class JarReader {
public static void main(String args[]) {
try {
String jarName = "specj.ear";
FileInputStream fin = new FileInputStream(jarName);
@stalep
stalep / gist:6270936
Created August 19, 2013 16:17
aeshcommand thoughts
@InjectCommand
AeshCommand command
public interface Command {
void execute() throws IOException;
}
vs
public interface Command {
@stalep
stalep / gist:6293925
Created August 21, 2013 12:38
jboss-cli script example
#!/bin/bash
bla
bla
bla
./jboss-cli.sh -c <<EOF
bob
admin123$
batch
/system-property=bar:add(value=foo)
run-batch
@stalep
stalep / msmtprc
Created September 26, 2013 08:44
# Set default values for all following accounts.
defaults
#tls on
#tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.msmtp.log
# redhat
account redhat
host smtp.corp.redhat.com
from spederse@redhat.com
[general]
accounts = work
maxsyncaccounts = 1
maxconnections = 1
ui = Noninteractive.Basic
#ui = Noninteractive.quiet
# -------------------- Work details. --------------------
[Account work]
localrepository = work-Local
@stalep
stalep / hibernate_bytecode
Created October 22, 2013 13:01
reduce the number of reflection calls from EntityTuplizer in hibernate
public interface HibernateValueMapper {
void $hibernate_setValue(Object value, String fieldName);
}
bytecode impl in entities:
...
public void $hibernate_setValue(Object value, String fieldName) {
if(fieldName == "name")
name = (String) value;
else if(fieldName == "address";
@stalep
stalep / gist:8422820
Created January 14, 2014 18:07
run æsh from a script
$ cat aeshtest.sh
#!/bin/bash
java -cp . AeshExample <<EOFDEL
login
admin
admin!234
ls
exit
import org.jboss.aesh.cl.Arguments;
import org.jboss.aesh.cl.CommandDefinition;
import org.jboss.aesh.console.AeshConsole;
import org.jboss.aesh.console.AeshConsoleBuilder;
import org.jboss.aesh.console.Prompt;
import org.jboss.aesh.console.command.Command;
import org.jboss.aesh.console.command.CommandResult;
import org.jboss.aesh.console.command.invocation.CommandInvocation;
import org.jboss.aesh.console.command.registry.AeshCommandRegistryBuilder;
import org.jboss.aesh.console.command.registry.CommandRegistry;
import org.jboss.aesh.console.AeshConsoleCallback;
import org.jboss.aesh.console.Console;
import org.jboss.aesh.console.ConsoleCallback;
import org.jboss.aesh.console.ConsoleOperation;
import org.jboss.aesh.console.Prompt;
import org.jboss.aesh.console.settings.SettingsBuilder;
public class ConsoleExample {
public static void main(String... args) {