Skip to content

Instantly share code, notes, and snippets.

View brunoborges's full-sized avatar
🏠
Working from home, as always

Bruno Borges brunoborges

🏠
Working from home, as always
View GitHub Profile
public static Date randomShiftOnDate(Date someDate) {
Random random = new Random();
int randomValue = random.nextInt(31) * 60 * 1000; // 30 min.
boolean subtract = random.nextBoolean();
if (subtract) randomValue *= -1;
long time = someDate.getTime();
time += randomValue;
Calendar cal = Calendar.getInstance();
asadmin> get resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.*
resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.portNumber=3306
resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.serverName=localhost
resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.databaseName=gf2wls
resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.User=gf2wls
resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.URL=jdbc:mysql://localhost:3306/gf2wls?zeroDateTimeBehavior=convertToNull
resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.driverClass=com.mysql.jdbc.Driver
resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.Password=gf2wls
resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.allow-non-component-callers=false
resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.associate-with-thread=false
package foo;
import java.util.Arrays;
import java.util.Locale;
/**
* @author bruno borges
*/
public class Foo {
public class EventProducer {
@Inject Event event;
public void doSomething() {
MyEvent e = new @Async MyEvent();
e.data = "This is a test event";
e.eventTime = new Date();
event.fire(e);
}
@brunoborges
brunoborges / FooBar.java
Created May 5, 2014 00:49
JDK 8 compiler fails if referenced final variable is not being called with "this."
/**
* @author bruno.borges@oracle.com
*/
public class FooBar {
private final String foobar;
public FooBar() {
foobar = "foobar";
}
#!/bin.sh
MAVEN_OPTS=-Xmx1024M -XX:MaxPermSize=512m
svn checkout https://svn.java.net/svn/glassfish~svn/trunk/main
cd main
mvn install -Dmaven.wagon.http.ssl.insecure=true \
-Dmaven.wagon.http.ssl.allowall=true \
-DskipTests
@brunoborges
brunoborges / browser.js
Created May 13, 2014 08:25
A simple Javascript code to create a browser in JavaFX for a given URL. Invoke this with: $ jjs -fx browser.js -- http://someaddress.com
var WebView = javafx.scene.web.WebView;
var StackPane = javafx.scene.layout.StackPane;
var Scene = javafx.scene.Scene;
var url = arguments.join('');
function start(stage) {
var browser = new WebView();
var engine = browser.getEngine();
engine.load(url);
var root = new StackPane();
root.children.add(browser);
public class WebViewSample extends Application {
@Override public void start(Stage stage) {
WebView browser = new WebView();
browser.getEngine().load("http://twitter.com/brunoborges");
StackPane root = new StackPane();
root.getChildren().add(browser);
stage.setTitle("WebView");
stage.setScene(new Scene(root, 750, 500));
private void hackScriptEngine(FXMLLoader loader) {
try {
Field fse = loader.getClass().getDeclaredField("scriptEngine");
fse.setAccessible(true);
scriptEngine = (ScriptEngine) fse.get(loader);
} catch (IllegalAccessException | NoSuchFieldException | SecurityException ex) {
LOGGER.log(Level.SEVERE, null, ex);
}
}
#!/usr/bin/jjs -J-Djava.class.path=lib/kvclient.jar
var oracle = Packages.oracle;
var KVStore = oracle.kv.KVStore;
var KVStoreConfig = oracle.kv.KVStoreConfig;
var KVStoreFactory = oracle.kv.KVStoreFactory;
var Direction = oracle.kv.Direction;
var store = KVStoreFactory.getStore(new KVStoreConfig("kvstore", "localhost:5000"));
var batchSize = 10;