View AsymmetricalLockingExample.java
import java.util.Optional;
import java.util.function.Supplier;
// See https://stackoverflow.com/questions/46864834/best-design-pattern-for-managing-asymmetrical-resource-use
public class AsymmetricalLockingExample {
public static void main(String args[]) throws Exception {
try (final ManagedRelease<Collection> mcol =
new ManagedRelease<>(getCollection("col1 name", LockMode.WRITE_LOCK))) {
View ant-show-deps.xqy
(:~
: XQuery to display the dependencies of an Ant target.
:
: There are two modes of operation:
: 1) Display all targets and immediate dependencies, specified by $project-file
: 2) Show a tree of a single targets dependencies, this happens when $target-name is set as well.
:
: External parameters:
: $project-file The initial Ant file to start parsing from (imports will be expanded)
: $target-name If specified we examine only a single target and produce a tree of all dependencies (recursively)
View .jdk1.8.jinfo
alias=jdk1.8
section=non-free
jre servertool /usr/lib/jvm/jdk1.8/jre/bin/servertool
jre keytool /usr/lib/jvm/jdk1.8/jre/bin/keytool
jre java /usr/lib/jvm/jdk1.8/jre/bin/java
jre jcontrol /usr/lib/jvm/jdk1.8/jre/bin/jcontrol
jre rmid /usr/lib/jvm/jdk1.8/jre/bin/rmid
jre ControlPanel /usr/lib/jvm/jdk1.8/jre/bin/ControlPanel
jre rmiregistry /usr/lib/jvm/jdk1.8/jre/bin/rmiregistry
jre orbd /usr/lib/jvm/jdk1.8/jre/bin/orbd
View TestMerge1.java
package org.rocksdb;
import java.io.IOException;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.List;
/**
* Created by aretter on 30/05/2017.
View recursive-serialize
/*
* eXist Open Source Native XML Database
* Copyright (C) 2001-2011 The eXist-db Project
* http://exist-db.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
View CompTest.java
package comptest;
import org.rocksdb.*;
import static java.nio.charset.StandardCharsets.UTF_8;
/**
* Created by aretter on 14/06/2016.
*/
public class CompTest {
View upload.scala
def storeUploadedFile(data: Source[ByteString, Any]): \/[Seq[Throwable], Future[DefaultPath]] = {
val tmpUpload = Path.createTempFile(prefix = "uploaded", dir = settings.TempDir, deleteOnExit = true)
try {
val os = new FileOutputStream(tmpUpload.jfile)
val sink = OutputStreamSink(() => os)
val f = data.runWith(sink).map(_ => tmpUpload)
f.onComplete { _ =>
info(s"Stored temporary uploaded PDF ${tmpUpload.path}")
os.close
View anon-recursion.xqy
xquery version "3.0";
(:~
: Anonymous function recursion in XQuery
:
: @author Adam Retter <adam.retter@googlemail.com>
:)
let $factorialHelper := function($f, $x) {
if($x eq 0) then
View TestingUnapply2.scala
Updating the code to:
```scala
import scala.reflect.ClassTag
object TestingUnapply {
sealed trait Thing
case class ThingA(a: String) extends Thing
case class ThingB(b: String, thingA: ThingA) extends Thing
View TestingUnapply.scala
object TestingUnapply {
sealed trait Thing
case class ThingA(a: String) extends Thing
case class ThingB(b: String, thingA: ThingA) extends Thing
val x: Thing = ThingA("hello")
val y: Thing = ThingB("goodbye", ThingA("maybe"))
process(x, new { def unapply(thing: ThingA) = ThingA.unapply(thing)})