Skip to content

Instantly share code, notes, and snippets.

View ALRubinger's full-sized avatar

Andrew Lee Rubinger ALRubinger

View GitHub Profile
@ALRubinger
ALRubinger / LogFile.java
Created February 22, 2014 02:09
Blocking Logger implementation that should have gotten me expelled from University
/**
* @(#)LogFile.java
*
* Copyright (c) 2001 Andrew Lee Rubinger
*
* @author Andrew Lee Rubinger
* @version 1.0
*/
package com.alrubinger.util;
String name = "test.jar";
ArchivePath path = ArchivePaths.create("WEB-INF/lib", name);
JavaArchive war = ShrinkWrap.create(JavaArchive.class)
.add(
ShrinkWrap.create(JavaArchive.class, name)
.add(EmptyAsset.INSTANCE, "some"), path, ZipExporter.class);
Assert.assertTrue(war.contains(path));
war.delete(path);
Assert.assertFalse("Path should have been deleted", war.contains(path));
alr@distortion ~/business/jboss/git/shrinkwrap/resolver $ rhc show-app site --gears quota -ldevnation-internal@redhat.com
Password: ********************
Gear Cartridges Used Limit
------------------------ ---------------------- ------ -----
5293f1b6e0b8cdb082000082 jbosseap-6 haproxy-1.4 1.2 GB 1 GB
@ALRubinger
ALRubinger / gist:1bb712de02a7ede347f1
Last active August 29, 2015 14:01
Using TinkerPop Frames to map a Java object model to a Graph, then TinkerPop Blueprints to persist it to underlying Graph storage (impl in OrientDB)
public interface Organization {
String PROP_NAME = "name";
String REL_PROJECTS = "sponsors";
/**
* Gets the name of this {@link org.jboss.metrics.playground.model.Organization}
* @return
*/
@Property(PROP_NAME)
Calling:
FramedGraph:
public <F> F frame(final Vertex vertex, final Class<F> kind)
like:
final String framedObject = framedGraph.frame(vertex, String.class);
...yields:
@ALRubinger
ALRubinger / NarayanaNeo4jTestCase.java
Created May 26, 2014 07:36
Using Neo4j With an Existing TransactionManager
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.neo4j2.Neo4j2Graph;
import org.jboss.metrics.playground.persistence.Neo4jExternalTransactionManager;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
/**
* Open a browser at the given URL using {@link Desktop} if available, or alternatively output the
* URL to {@link System#out} for command-line applications.
*
* @param url URL to browse
*/
public static void browse(String url) {
Preconditions.checkNotNull(url);
// Ask user to open in their browser using copy-paste
System.out.println("Please open the following address in your browser:");
@ALRubinger
ALRubinger / NullVarArgs.java
Last active August 29, 2015 14:03
Java Puzzler
public class NullVarArgs {
public static void main(String... args) {
// 1
exec(null);
// 2
exec((String) null);
alr@distortion ~/business/jboss/git/bu/metrics (6 *) $ osprey list rest/src/assets/raml/api.raml
GET /sites
GET /sites/{siteId}
#%RAML 0.8
---
title: Red Hat JBoss Middleware Metrics
baseUri: http://metricsrest-alrubinger.rhcloud.com/api/{version}
version: v1
/sites:
@ALRubinger
ALRubinger / BlueprintsGraphPersistenceRepository.java
Created July 16, 2014 17:31
Mucking with Blueprints and Frames
package org.jboss.metrics.impl.persistence.blueprints;
import com.tinkerpop.blueprints.CloseableIterable;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.Index;
import com.tinkerpop.blueprints.IndexableGraph;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.frames.FramedGraph;
import com.tinkerpop.frames.FramedGraphFactory;
import org.jboss.metrics.spi.model.PersistentEntity;