Skip to content

Instantly share code, notes, and snippets.

View ceharris's full-sized avatar

Carl Harris ceharris

  • Blacksburg, VA, USA
View GitHub Profile
@ceharris
ceharris / collections.md
Last active November 23, 2016 14:40
prospecto collection syntax improvement

This is the current syntax...

mapOfObjects(Role.class, Contributor.class)
    .reference("person", PERSON_SUMMARY_TEMPLATE)
    .arrayOfObjects("credits")
          .reference("responsibleOrganization", ORG_SUMMARY_TEMPLATE)
          .value("percentCredit")
          .end()
@ceharris
ceharris / gist:25dddcb7049ec8ebf5be31d2c27a9f10
Created August 23, 2016 09:14
Publicly verify my Blockstack ID
Verifying that "ceharris.id" is my Blockstack ID. https://onename.com/ceharris

Keybase proof

I hereby claim:

  • I am ceharris on github.
  • I am ceharris (https://keybase.io/ceharris) on keybase.
  • I have a public key whose fingerprint is 5CD3 C1D5 CD3D AC5C 1040 75CC DF48 BD89 3F1F 38CE

To claim this, I am signing this object:

@ceharris
ceharris / jax-rs-web.xml
Created October 16, 2014 11:41
JAX-RS Application Servlet Mapping
<!-- This gist simply provides the web.xml configuration needed to support JAX-RS endpoints -->
<servlet>
<servlet-name>javax.ws.rs.core.Application</servlet-name>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>javax.ws.rs.core.Application</servlet-name>
<url-pattern>/api/*</url-pattern>
@ceharris
ceharris / SOAPRewriteDemo.java
Last active December 21, 2015 03:39
Using Java with JDOM to write a SOAP header. Either finds and replaces or adds a SOAP header containing a session ID.
package demo;
import java.io.InputStream;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.Namespace;
import org.jdom2.input.SAXBuilder;
import org.jdom2.output.Format;
import org.jdom2.output.XMLOutputter;
class AbstractSocketAppender extends ...
implements EventDispatcher, ExceptionHandler {
private SocketConnectorFactory connectorFactory;
private ConnectionRunner connectionRunner;
private Future<?> runnerTask;
public void start() {
...
// extract method to create connector factory...
@ceharris
ceharris / README.md
Last active December 16, 2015 20:39
An example of the (non-)effect of Thread.interrupt on a fairly typical long-running task.

I think that Thread.interrupt() sounds more intrusive than it really is. Thread interruption in Java is entirely advisory. Generally a task does not need to go to any effort to avoid being interrupted. Rather, it usually takes some real effort to properly observe the interrupt status in order to exit when interrupted, if such is desired. Short of putting in the effort to observe the thread's interrupt status, I think you'll find that arbitrary tasks are quite resilient in the face of interrupts.

A task can check the thread's interrupt status at any time by calling Thread.isInterrupted(). If you wish to make a runnable task interruptible, your code must occasionally check the interrupt status and exit the run() method if the task has been interrupted. If you don't want your task to be interrupted, simply ignore the thread's interrupt status.

JDK methods that examine the thread's interrupt status are consistently declared to throw InterruptedException, so they are easily identified. I/O calls w