text:
package org.apache.flink.streaming.api.functions.sink.filesystem;

import org.apache.flink.api.common.serialization.SimpleStringEncoder;
import org.apache.flink.core.fs.FileSystem;
import org.apache.flink.core.fs.Path;
import org.apache.flink.core.io.SimpleVersionedSerialization;
import org.apache.flink.core.io.SimpleVersionedSerializer;
import org.apache.flink.streaming.api.functions.sink.filesystem.bucketassigners.SimpleVersionedStringSerializer;
import org.apache.flink.streaming.api.functions.sink.filesystem.rollingpolicies.DefaultRollingPolicy;
import org.apache.flink.util.FileUtils;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

/**
 * Utilities to generate sample bucket states so that we could test migration of bucket states.
 */
public class BucketStateGenerator {
	private final String bucketId;
	private final String inProgressContent;
	private final String pendingContent;
	private final BucketStatePathResolver pathResolver;

	public BucketStateGenerator(
			String bucketId,
			String inProgressContent,
			String pendingContent,
			java.nio.file.Path basePath,
			int currentVersion) {
		this.bucketId = bucketId;
		this.inProgressContent = inProgressContent;
		this.pendingContent = pendingContent;
		this.pathResolver = new BucketStatePathResolver(basePath, currentVersion);
	}

	public void prepareDeserializationEmpty() throws IOException {
		final String scenarioName = "empty";
		final java.nio.file.Path scenarioPath = pathResolver.getResourcePath(scenarioName);

		FileUtils.deleteDirectory(scenarioPath.toFile());
		Files.createDirectories(scenarioPath);

		final java.nio.file.Path outputPath = pathResolver.getOutputPath(scenarioName);
		final Path testBucketPath = new Path(outputPath.resolve(bucketId).toString());

		final Bucket<String, String> bucket = createNewBucket(testBucketPath);

		final BucketState<String> bucketState = bucket.onReceptionOfCheckpoint(0);

		byte[] bytes = SimpleVersionedSerialization.writeVersionAndSerialize(
				bucketStateSerializer(),
				bucketState);
		Files.write(pathResolver.getSnapshotPath(scenarioName), bytes);
	}

	public void prepareDeserializationOnlyInProgress() throws IOException {
		final String scenarioName = "only-in-progress";
		final java.nio.file.Path scenarioPath = pathResolver.getResourcePath(scenarioName);
		FileUtils.deleteDirectory(scenarioPath.toFile());
		Files.createDirectories(scenarioPath);

		final java.nio.file.Path outputPath = pathResolver.getOutputPath(scenarioName);
		final Path testBucketPath = new Path(outputPath.resolve(bucketId).toString());

		final Bucket<String, String> bucket =
				createNewBucket(testBucketPath);

		bucket.write(inProgressContent, System.currentTimeMillis());

		final BucketState<String> bucketState = bucket.onReceptionOfCheckpoint(0);

		final byte[] bytes = SimpleVersionedSerialization.writeVersionAndSerialize(
				bucketStateSerializer(), bucketState);

		Files.write(pathResolver.getSnapshotPath(scenarioName), bytes);
	}

	public void prepareDeserializationFull() throws IOException {
		prepareDeserializationFull(true, "full");
	}

	public void prepareDeserializationNullInProgress() throws IOException {
		prepareDeserializationFull(false, "full-no-in-progress");
	}

	private void prepareDeserializationFull(final boolean withInProgress, final String scenarioName) throws IOException {
		final java.nio.file.Path scenarioPath = pathResolver.getResourcePath(scenarioName);
		FileUtils.deleteDirectory(Paths.get(scenarioPath.toString() + "-template").toFile());
		Files.createDirectories(scenarioPath);

		final int noOfPendingCheckpoints = 5;

		final java.nio.file.Path outputPath = pathResolver.getOutputPath(scenarioName);

		final Path testBucketPath = new Path(outputPath.resolve(bucketId).toString());

		final Bucket<String, String> bucket = createNewBucket(testBucketPath);

		BucketState<String> bucketState = null;
		// pending for checkpoints
		for (int i = 0; i < noOfPendingCheckpoints; i++) {
			// write 10 bytes to the in progress file
			bucket.write(pendingContent, System.currentTimeMillis());
			bucket.write(pendingContent, System.currentTimeMillis());
			// every checkpoint would produce a pending file
			bucketState = bucket.onReceptionOfCheckpoint(i);
		}

		if (withInProgress) {
			// create a in progress file
			bucket.write(inProgressContent, System.currentTimeMillis());

			// 5 pending files and 1 in progress file
			bucketState = bucket.onReceptionOfCheckpoint(noOfPendingCheckpoints);
		}

		final byte[] bytes = SimpleVersionedSerialization.writeVersionAndSerialize(bucketStateSerializer(), bucketState);

		Files.write(pathResolver.getSnapshotPath(scenarioName), bytes);

		// copy the scenario file to a template directory.
		// it is because that the test `testSerializationFull` would change the in progress file to pending files.
		moveToTemplateDirectory(scenarioPath);
	}

	private static RowWiseBucketWriter<String, String> createBucketWriter() throws IOException {
		return new RowWiseBucketWriter<>(FileSystem.getLocalFileSystem().createRecoverableWriter(), new SimpleStringEncoder<>());
	}

	private static SimpleVersionedSerializer<BucketState<String>> bucketStateSerializer() throws IOException {
		final RowWiseBucketWriter bucketWriter = createBucketWriter();
		return new BucketStateSerializer<>(
				bucketWriter.getProperties().getInProgressFileRecoverableSerializer(),
				bucketWriter.getProperties().getPendingFileRecoverableSerializer(),
				SimpleVersionedStringSerializer.INSTANCE);
	}

	private Bucket<String, String> createNewBucket(Path bucketPath) throws IOException {
		return Bucket.getNew(
				0,
				bucketId,
				bucketPath,
				0,
				createBucketWriter(),
				DefaultRollingPolicy.builder().withMaxPartSize(10).build(),
				null,
				OutputFileConfig.builder().build());
	}

	private void moveToTemplateDirectory(java.nio.file.Path scenarioPath) throws IOException {
		FileUtils.copy(new Path(scenarioPath.toString()), new Path(scenarioPath.toString() + "-template"), false);
		FileUtils.deleteDirectory(scenarioPath.toFile());
	}
}

redpajama_set_name: RedPajamaGithub


text:
package org.ehcache.server.rest.pojo;

import net.sf.ehcache.CacheException;
import net.sf.ehcache.MimeTypeByteArray;
import net.sf.ehcache.util.MemoryEfficientByteArrayOutputStream;

import java.io.IOException;

/**
 * A representation of a core Ehcache Element.
 *

 * Caches have default settings for timeToLive, timeToIdle and eternal. If any of those is set
 * then defaults are not applied.
 *
 * @author Greg Luck
 */
public class Element {

  /**
   * A representation of the payload value of the Element.
   * Used with MIME Type to figure out what to do with it.
   */
  private byte[] value;

  /**
   * The RESTful resource address for this Element. Only relevant where the
   * server is configured to serve RESTful Web Services.
   */
  private String resourceUri;

  /**
   * When Elements are PUT into the cache, a MIME Type should be set in the request header.
   * The MIME Type is preserved and put into the response header when a GET is done.
   *

   * Some common MIME Types which are expected to be used by clients are:
   *

   *

   *
text/plain Plain text
   *
application/xml Extensible Markup Language. Defined in RFC 3023
   *
application/json JavaScript Object Notation JSON. Defined in RFC 4627
   *
application/x-java-serialized-object A serialized Java object
   *
application/octet-stream Used for unrecgonized binary types. See RFC2046
   *

   */
  private String mimeType;

  private Object key;

  private Long version;

  private Long creationTime;
  private Long lastUpdateTime;
  private Long expirationDate;

  private Boolean eternal;
  private Integer timeToIdleSeconds;
  private Integer timeToLiveSeconds;

  /**
   * Empty Constructor
   */
  public Element() {
  }

  /**
   * Full constructor
   *
   * @param value
   * @param resourceUri
   * @param mimeType
   */
  public Element(byte[] value, String resourceUri, String mimeType) {
    setValue(value);
    setResourceUri(resourceUri);
    setMimeType(mimeType);
  }

  /**
   * Constructor which takes an Ehcache core Element.
   *

   * The {@link #mimeType} and {@link #value} are stored in
   * the core Ehcache value field using {@link net.sf.ehcache.MimeTypeByteArray}
   *

   * If the MIME Type is not set, an attempt is made to set a sensible value. The rules for setting the Mime Type are:
   *

   *
If the value in element is null, the mimeType is set to null.
   *
If we stored the mimeType in ehcache, then mimeType is set with it.
   *
If no mimeType was set and the value is a byte[] the mimeType is set to "application/octet-stream".
   *
If no mimeType was set and the value is a String the mimeType is set to "text/plain".
   *

   *
   * @param element the ehcache core Element
   * @throws net.sf.ehcache.CacheException if an Exception occurred in the underlying cache.
   */
  public Element(net.sf.ehcache.Element element, String resourceUri) throws CacheException {
    this(element);
    this.resourceUri = resourceUri;
  }

  /**
   * Constructor which takes an Ehcache core Element.
   *

   * The {@link #mimeType} and {@link #value} are stored in
   * the core Ehcache value field using {@link net.sf.ehcache.MimeTypeByteArray}
   *

   * If the MIME Type is not set, an attempt is made to set a sensible value. The rules for setting the Mime Type are:
   *

   *
If the value in element is null, the mimeType is set to null.
   *
If we stored the mimeType in ehcache, then mimeType is set with it.
   *
If no mimeType was set and the value is a byte[] the mimeType is set to "application/octet-stream".
   *
If no mimeType was set and the value is a String the mimeType is set to "text/plain".
   *

   *
   * @param element the ehcache core Element
   * @throws net.sf.ehcache.CacheException if an Exception occurred in the underlying cache.
   */
  public Element(net.sf.ehcache.Element element) throws CacheException {

    key = element.getKey();
    expirationDate = element.getExpirationTime();

    Object ehcacheValue = element.getObjectValue();

    if (ehcacheValue == null) {
      this.value = null;
      this.mimeType = null;
    }
    if (ehcacheValue instanceof MimeTypeByteArray) {
      //we have Mime Type data to extract
      mimeType = ((MimeTypeByteArray) ehcacheValue).getMimeType();
      if (mimeType == null) {
        //Jersey is returning */* for these which I think is wrong. Reported to Paul Sandoz.
        mimeType = "application/octet-stream";
      }
      this.value = ((MimeTypeByteArray) ehcacheValue).getValue();

    } else if (ehcacheValue instanceof byte[]) {
      //already a byte[]
      this.value = (byte[]) ehcacheValue;
      mimeType = "application/octet-stream";
    } else if (ehcacheValue instanceof String) {
      //a String such as XML
      this.value = ((String) ehcacheValue).getBytes();
      this.mimeType = "text/plain";
    } else {
      //A type we do not handle therefore serialize using Java Serialization
      MemoryEfficientByteArrayOutputStream stream = null;
      try {
        stream = MemoryEfficientByteArrayOutputStream.serialize(element.getValue());
      } catch (IOException e) {
        throw new CacheException(e);
      }
      this.value = stream.getBytes();
      this.mimeType = "application/x-java-serialized-object";
    }

  }

  /**
   * The key for this element. It needs to be Serializable. To work with the RESTful API it needs to be a String.
   *
   * @return the value of the key
   */
  public Object getKey() {
    return key;
  }

  /**
   * The key for this element. It needs to be Serializable. To work with the RESTful API it needs to be a String.
   *
   * @param key the value of the key
   */
  public void setKey(Object key) {
    this.key = key;
  }

  /**
   * Gets the payload.
   * Use the MIME type to work out how to decode this
   *
   * @return the value as bytes
   */
  public byte[] getValue() {
    return value;
  }

  /**
   * Sets the payload
   * Should be set in conjunction with the MIME type
   *
   * @param value the value as bytes
   */
  public void setValue(byte[] value) {
    this.value = value;
  }

  /**
   * Gets the URI for this resource
   *
   * @return a string being a fully qualified URI e.g. http://localhost:9090/ehcache/rest/sampleCache1/34
   */
  public String getResourceUri() {
    return resourceUri;
  }

  /**
   * Sets the URI for this resource
   *
   * @param resourceUri a string being a fully qualified URI e.g. http://localhost:9090/ehcache/rest/sampleCache1/34
   */
  public void setResourceUri(String resourceUri) {
    this.resourceUri = resourceUri;
  }

  /**
   * From ehcache-1.6, ehcache supports non-Java clients. The Web Services serialize the element
   * value as a byte[]. That byte array could be of any type. To give clients assistance in determining
   * the type, a MIME Type has been added.
   *

   * Gets the MIME Type.
   *

   * When Elements are put into the cache, a MIME Type should be set.
   *

   * The MIME Type is preserved and put into the response header when a GET is done.
   *

   * Some common MIME Types which are expected to be used by clients are:
   *

   *
text/plain Plain text
   *
application/xmlExtensible Markup Language. Defined in RFC 3023
   *
application/jsonJavaScript Object Notation JSON. Defined in RFC 4627
   *
application/x-java-serialized-objectA serialized Java object
   *

   * A Mime Type of null indicates the value is a Java Object.
   *
   * @return
   */
  public String getMimeType() {
    return mimeType;
  }

  /**
   * Sets the MIME Type
   *
   * @param mimeType
   */
  public void setMimeType(String mimeType) {
    this.mimeType = mimeType;
  }

  /**
   * Sets time to idle
   *
   * @param timeToIdleSeconds the number of seconds to idle
   */
  public void setTimeToIdle(Integer timeToIdleSeconds) {
    this.timeToIdleSeconds = timeToIdleSeconds;
  }

  /**
   * If there is an Element in the Cache and it is replaced with a new Element for the same key,
   * then both the version number and lastUpdateTime should be updated to reflect that. The creation time
   * will be the creation time of the new Element, not the original one, so that TTL concepts still work.
   *
   * @return the time when the last update occured. If this is the original Element, the time will be null
   */
  public long getLastUpdateTime() {
    return lastUpdateTime;
  }

  /**
   * Throws a UnsupportedOperationException if called. This is immutatble but
   * a setter must be provided to support the JavaBeans convention.
   *
   * @throws UnsupportedOperationException do not call this method. This is immutable
   */
  public void setLastUpdateTime(Long lastUpdateTime) throws UnsupportedOperationException {
    throw new UnsupportedOperationException("Last Update Time is immutable.");
  }

  /**
   * @return true if the element is eternal
   */
  public Boolean isEternal() {
    return eternal;
  }

  /**
   * Sets whether the element is eternal.
   *
   * @param eternal true if it lives forever
   */
  public void setEternal(Boolean eternal) {
    this.eternal = eternal;
  }

  /**
   * @return the time to live, in seconds
   */
  public Integer getTimeToLiveSeconds() {
    return timeToLiveSeconds;
  }

  /**
   * Sets time to Live
   *
   * @param timeToLiveSeconds the number of seconds to live
   */
  public void setTimeToLiveSeconds(Integer timeToLiveSeconds) {
    this.timeToLiveSeconds = timeToLiveSeconds;

  }

  /**
   * @return the time to idle, in seconds
   */
  public Integer getTimeToIdleSeconds() {
    return timeToIdleSeconds;
  }

  /**
   * @param timeToIdleSeconds the time an element may be unused before it becomes stale
   */
  public void setTimeToIdleSeconds(Integer timeToIdleSeconds) {
    this.timeToIdleSeconds = timeToIdleSeconds;
  }

  /**
   * @return the version of this element
   */
  public long getVersion() {
    return version;
  }

  /**
   * Throws a UnsupportedOperationException if called. This is immutatble but
   * a setter must be provided to support the JavaBeans convention.
   *
   * @throws UnsupportedOperationException do not call this method. This is immutable
   */
  public void setVersion(Long version) throws UnsupportedOperationException {
    throw new UnsupportedOperationException("Version is immutable.");
  }

  /**
   * @return the time this element was created in the cache
   */
  public long getCreationTime() {
    return creationTime;
  }

  /**
   * Throws a UnsupportedOperationException if called. This is immutatble but
   * a setter must be provided to support the JavaBeans convention.
   *
   * @throws UnsupportedOperationException do not call this method. This is immutable
   */
  public void setCreationTime(Long creationTime) throws UnsupportedOperationException {
    throw new UnsupportedOperationException("Creation time is immutable.");
  }

  /**
   * Gets the core Ehcache element.
   *
   * @return the core Ehcache element. The {@link #mimeType} and {@link #value} are stored in
   * the core Ehcache value field using {@link net.sf.ehcache.MimeTypeByteArray}
   */
  public net.sf.ehcache.Element getEhcacheElement() {
    MimeTypeByteArray mimeTypeByteArray = new MimeTypeByteArray(mimeType, value);
    return new net.sf.ehcache.Element(key, mimeTypeByteArray, eternal, timeToIdleSeconds, timeToLiveSeconds);
  }

  /**
   * Returns the expiration time of the element
   *
   * @return the best estimate of the expiration date of this element from the cache. If the element is eternal
   * {@link Long#MAX_VALUE} is returned.
   * @see net.sf.ehcache.Element#getExpirationTime()
   */
  public Long getExpirationDate() {
    return expirationDate;
  }

  /**
   * Do not call. This is immutable from the point of view of a client.
   *
   * @throws UnsupportedOperationException do not call this method. This is immutable.
   */
  public void setExpirationDate(Long expirationDate) throws UnsupportedOperationException {
    throw new UnsupportedOperationException("Last Update Time is immutable.");
  }
}


text:
define(['util/undoManager'], function(undoManager) {

    var _ = function() { };

    describe('undoManager', function() {

        beforeEach(function() {
            undoManager.reset();
        });

        it('should exist', function() {
            expect(undoManager).to.be.a('object');
        });

        it('should have a performedAction method', function() {
            expect(undoManager).to.respondTo('performedAction');
        });

        it('should require proper arguments to performedAction', function() {
            expect(undoManager.performedAction.bind(undoManager)).to.throw(Error);

            expect(function() {
                undoManager.performedAction('test');
            }).to.throw(Error);

            expect(function() {
                undoManager.performedAction('test', { undo: ' ', redo: _ });
            }).to.throw(Error);

            expect(function() {
                undoManager.performedAction('test', { undo: _, redo: ' ' });
            }).to.throw(Error);

            expect(function() {
                undoManager.performedAction('test', { undo: _, redo: _ });
            }).to.not.throw(Error);
        });

        it('should bind callbacks if specified in options', function(done) {
            var x = { message: 'bound object' };

            undoManager.performedAction('test', {
                undo: function() {
                    expect(this).to.equal(x);
                },
                redo: function() {
                    expect(this).to.equal(x);
                    expect(this.message).to.equal(x.message);
                    done();
                },
                bind: x
            });

            undoManager.performUndo();
            undoManager.performRedo();
        });

        it('should be able to undo an action', function(done) {
            undoManager.performedAction('test undo', {
                undo: function() {
                    done();
                },
                redo: _
            });

            undoManager.performUndo();
        });

        it('should be able to undo, then redo an action', function() {
            var initial = 42,
                other = 32,
                x = initial;

            x = other;
            undoManager.performedAction('test undo', {
                undo: function() {
                    x = initial;
                },
                redo: function() {
                    x = other;
                }
            });

            expect(x).to.equal(other);

            undoManager.performUndo();
            expect(x).to.equal(initial);

            undoManager.performRedo();
            expect(x).to.equal(other);

            undoManager.performUndo();
            expect(x).to.equal(initial);

            expect(undoManager.undos.length).to.equal(0);
            expect(undoManager.redos.length).to.equal(1);
        });

        it('should know when undo is possible', function() {
            expect(undoManager.canUndo()).to.equal(false);

            undoManager.performedAction('test undo', { undo: _, redo: _ });
            expect(undoManager.canUndo()).to.equal(true);

            undoManager.performUndo();
            expect(undoManager.canUndo()).to.equal(false);
        });

        it('should know when redo is possible', function() {
            expect(undoManager.canRedo()).to.equal(false);

            undoManager.performedAction('test undo', { undo: _, redo: _ });
            expect(undoManager.canRedo()).to.equal(false);

            undoManager.performUndo();
            expect(undoManager.canRedo()).to.equal(true);

            undoManager.performRedo();
            expect(undoManager.canRedo()).to.equal(false);
        });

        it('should not blow up if can not undo and do anyway', function() {
            expect(undoManager.canUndo()).to.equal(false);
            expect(undoManager.performUndo.bind(undoManager)).to.not.throw(Error);
        });

        it('should not blow up if can not redo and do anyway', function() {
            expect(undoManager.canRedo()).to.equal(false);
            expect(undoManager.performRedo.bind(undoManager)).to.not.throw(Error);
        });

        it('should handle undo key events on mac', function() {
            var Z = 90;

            shouldPerformUndoWithEvent(
                jQuery.Event('keydown', { which: Z, metaKey: true })
            );
        });

        it('should handle undo key events on windows', function() {
            var Z = 90;

            shouldPerformUndoWithEvent(
                jQuery.Event('keydown', { which: Z, ctrlKey: true })
            );
        });

        it('should handle redo key events on mac', function() {
            var Z = 90;

            shouldPerformRedoWithEvent(
                jQuery.Event('keydown', { which: Z, metaKey: true, shiftKey: true })
            );
        });

        it('should handle redo key events on windows', function() {
            var Y = 89;

            shouldPerformRedoWithEvent(
                jQuery.Event('keydown', { which: Y, ctrlKey: true })
            );
        });

        function shouldPerformUndoWithEvent(event) {
            canUndo(false);
            undoManager.performedAction('test undo', { undo: _, redo: _ });
            canUndo(true);
            undoManager._handleKey(event);
            canUndo(false);
        }

        function shouldPerformRedoWithEvent(event) {
            canRedo(false);
            undoManager.performedAction('test undo', { undo: _, redo: _ });
            canUndo(true);
            undoManager.performUndo();
            canUndo(false);
            canRedo(true);
            undoManager._handleKey(event);
            canUndo(true);
            canRedo(false);
        }

        function canUndo(expected) {
            expect(undoManager.canUndo()).to.equal(expected);
        }
        function canRedo(expected) {
            expect(undoManager.canRedo()).to.equal(expected);
        }
    });
});


text:
package org.culturegraph.mf.morph.maps;

import static org.junit.Assert.assertNotNull;

import java.io.IOException;

import org.junit.Test;

/**
 * Tests {@link JndiSqlMap}.
 * @author schaeferd
 *
 */
public final class JndiSqlMapTest {
	@Test
	public void testGetDatasource() throws IOException {
		final JndiSqlMap map = new JndiSqlMap();
		map.setDatasource("testDataSource");

		assertNotNull(map.getDatasource());
		map.close();
	}

}


text:
set -eu
SCRIPT=$(readlink -m $(type -p "$0"))
SCRIPTDIR=$(dirname "$SCRIPT")
source "$SCRIPTDIR/util.sh"

HELP="DWI EPI distortion correction.

Usage:
    ${0##*/} [-d] [-f|--fast] <dwi> <dwimask> <t2> <t2mask> <out>

-f     Fast registration, for debugging
-d     Debug, don't delete temporary output directory
"

DOFAST_rigid=""
DEBUG=false
while getopts "hfd" flag; do
    case "$flag" in
        h) usage 1;;
        f) DOFAST_rigid="-f";;
        d) export DEBUG=true;;
    esac
done
shift $((OPTIND-1))

# Get args
[ $# -lt 4 ] && usage 1
inputvars="dwi dwimask t2 t2mask out"
read -r $inputvars <<< "$@"

# Check args and ANTS paths and print
checkexists dwi dwimask t2 t2mask
checkvars ANTSPATH
printvars DEBUG ANTSPATH $inputvars

# Set derived data paths
tmp=$(mktemp -d)
startlogging
bse="$tmp/$(base "$dwi")-maskedbse.nrrd"
t2masked="$tmp/$(base "$t2")-masked.nrrd"
t2inbse="$tmp/$(base "$t2")-in-bse-rigid.nrrd"
epiwarp="$tmp/$(base "$dwi")_in_$(base "$t2")-epiwarp.nii.gz"

log "1. Extract and mask the DWI baseline"
#run "unu slice -a 3 -p 0 -i "$dwi" | unu 3op ifelse "$dwimask" - 0 -o "$bse""
run "$SCRIPTDIR/bse.sh -m "$dwimask" -i "$dwi" -o "$bse""
log_success "1. Made masked baseline: '$bse'"

log "2. Mask the T2"
run "unu 3op ifelse "$t2mask" "$t2" 0 -o "$t2masked""
log_success "1. Made masked baseline: '$t2masked'"

log "3. Compute a rigid registration from the T2 to the DWI baseline"
#run \"$SCRIPTDIR/warp.sh\" $DOFAST_rigid -r "$t2masked" "$bse" "$t2inbse"  # -r for rigid
run $ANTSSRC/Scripts/antsRegistrationSyN.sh -d 3 -f $bse -m $t2masked -t r -o $tmp/t2tobse_rigid
run $ANTSPATH/antsApplyTransforms -d 3 -i "$t2masked" -o "$t2inbse" -r "$bse" -t "$tmp/t2tobse_rigid0GenericAffine.mat"
log_success "2. Made rigidly registered T2: '$t2inbse'"

log "4. Compute 1d nonlinear registration from the DWI to the T2 along the phase direction"
moving=$bse
fixed=$t2inbse
pre="$tmp/$(base $moving)_in_$(base $fixed)_warp"
#run $ANTSPATH/ANTS 3 -m CC[$fixed,$moving,1,5] -i 50x20x10 -r Gauss[3,0] -t SyN[1] -o $pre --Restrict-Deformation 0x1x0 --do-rigid $DOFAST_warp
#run "$ANTSPATH/ComposeMultiTransform 3 "$epiwarp" -R "$fixed" "${pre}Warp.nii.gz" "${pre}Affine.txt" || true"
# Note: composeMultiTransform has exit status 1 even when it completes successfully without an error message, hence the '|| true'
#run $ANTSSRC/Scripts/antsRegistrationSyN.sh -d 3 -f $fixed -m $moving -t r -o $tmp/rigid_init
run "$ANTSPATH/antsRegistration -d 3 \
    -m cc[$fixed,$moving,1,2] -t SyN[0.25,3,0] -c 50x50x10 -f 4x2x1 \
    -s 2x1x0 --restrict-deformation 0x1x0 -v 1 -o $pre"
#run "$ANTSPATH/ComposeMultiTransform 3 "$epiwarp" -R "$fixed" "${pre}1Warp.nii.gz" $tmp/rigid_init0GenericAffine.mat || true"
run mv "${pre}0Warp.nii.gz" "$epiwarp"
log_success "3. Made 1d epi corrective warp: '$epiwarp'"

log "5. Apply warp to the DWI"
run \"$SCRIPTDIR/antsApplyTransformsDWI.sh\" "$dwi" "$dwimask" "$epiwarp" "$out"

log_success "Made epi corrected DWI '$out'"
stoplogging $out.log

$DEBUG || rm -rf "$tmp"


text:
package io.quarkus.redis.runtime.datasource;

import java.time.Duration;
import java.util.List;

import io.quarkus.redis.datasource.RedisDataSource;
import io.quarkus.redis.datasource.cuckoo.CfInsertArgs;
import io.quarkus.redis.datasource.cuckoo.CfReserveArgs;
import io.quarkus.redis.datasource.cuckoo.CuckooCommands;
import io.quarkus.redis.datasource.cuckoo.ReactiveCuckooCommands;

public class BlockingCuckooCommandsImpl<K, V> extends AbstractRedisCommandGroup implements CuckooCommands<K, V> {

    private final ReactiveCuckooCommands<K, V> reactive;

    public BlockingCuckooCommandsImpl(RedisDataSource ds, ReactiveCuckooCommands<K, V> reactive, Duration timeout) {
        super(ds, timeout);
        this.reactive = reactive;
    }

    @Override
    public void cfadd(K key, V value) {
        reactive.cfadd(key, value).await().atMost(timeout);
    }

    @Override
    public boolean cfaddnx(K key, V value) {
        return reactive.cfaddnx(key, value).await().atMost(timeout);
    }

    @Override
    public long cfcount(K key, V value) {
        return reactive.cfcount(key, value).await().atMost(timeout);
    }

    @Override
    public boolean cfdel(K key, V value) {
        return reactive.cfdel(key, value).await().atMost(timeout);
    }

    @Override
    public boolean cfexists(K key, V value) {
        return reactive.cfexists(key, value).await().atMost(timeout);
    }

    @Override
    public void cfinsert(K key, V... values) {
        reactive.cfinsert(key, values).await().atMost(timeout);
    }

    @Override
    public void cfinsert(K key, CfInsertArgs args, V... values) {
        reactive.cfinsert(key, args, values).await().atMost(timeout);
    }

    @Override
    public List<Boolean> cfinsertnx(K key, V... values) {
        return reactive.cfinsertnx(key, values).await().atMost(timeout);
    }

    @Override
    public List<Boolean> cfinsertnx(K key, CfInsertArgs args, V... values) {
        return reactive.cfinsertnx(key, args, values).await().atMost(timeout);
    }

    @Override
    public List<Boolean> cfmexists(K key, V... values) {
        return reactive.cfmexists(key, values).await().atMost(timeout);
    }

    @Override
    public void cfreserve(K key, long capacity) {
        reactive.cfreserve(key, capacity).await().atMost(timeout);
    }

    @Override
    public void cfreserve(K key, long capacity, CfReserveArgs args) {
        reactive.cfreserve(key, capacity, args).await().atMost(timeout);
    }
}


text:
"""
Randomize the order of blocks in a MAF file. If `sample_size` is specified,
that many random blocks will be kept from the original maf

usage: %prog [sample_size] < maf > maf
"""

import sys

import sys, random
from bx.align import maf
from math import *
from optparse import OptionParser

def __main__():

    #if len( sys.argv ) > 1: fraction = float( sys.argv[1] )
    if len( sys.argv ) > 1: sample_size = int( sys.argv[1] )

    maf_reader = maf.Reader( sys.stdin )
    maf_writer = maf.Writer( sys.stdout )

    mafs = list( maf_reader )

    # for m in maf_reader: mafs.append( m )

    random.shuffle( mafs )

    if not sample_size: sample_size = len( mafs )

    for i in range( 0, sample_size ): maf_writer.write( mafs[ i ] )

if __name__ == "__main__": __main__()


text:
(testAppOnReady)... next line should read "bar":

${foo}


text: Gives people minions when they join


text:
package org.wso2.carbon.esb.file.inbound.transport.test;

import java.io.File;
import java.io.IOException;

import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.util.AXIOMUtil;
import org.apache.commons.io.FileUtils;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.wso2.carbon.automation.engine.annotations.ExecutionEnvironment;
import org.wso2.carbon.automation.engine.annotations.SetEnvironment;
import org.wso2.carbon.automation.engine.frameworkutils.FrameworkPathUtil;
import org.wso2.carbon.integration.common.admin.client.LogViewerClient;
import org.wso2.carbon.logging.view.data.xsd.LogEvent;
import org.wso2.esb.integration.common.utils.ESBIntegrationTest;
import org.wso2.esb.integration.common.utils.Utils;

public class InboundEndpointContentTypePlainTest extends ESBIntegrationTest {

    private LogViewerClient logViewerClient;
    private File InboundFileFolder;
    private String pathToFtpDir;

    @BeforeClass(alwaysRun = true)
    public void setEnvironment() throws Exception {

	    pathToFtpDir = getESBResourceLocation() + File.separator + "synapseconfig" + File.separator + "vfsTransport";

        InboundFileFolder = new File(pathToFtpDir + File.separator + "InboundFileFolder");

        // create InboundFileFolder if not exists
        if (InboundFileFolder.exists()) {
            FileUtils.deleteDirectory(InboundFileFolder);
        }
        Assert.assertTrue(InboundFileFolder.mkdir(), "InboundFileFolder not created");

        super.init();

        logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(),
                getSessionCookie());

    }

    @AfterClass(alwaysRun = true)
    public void destroy() throws Exception {
        super.cleanup();
    }

    @SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
    @Test(groups = "wso2.esb", description = "Inbound endpoint Reading file with Content type Plain Test Case")
    public void testInboundEnpointReadFileContentTypePlain() throws Exception {

        File sourceFile = new File(pathToFtpDir + File.separator + "test.txt");
        File targetFolder = new File(InboundFileFolder + File.separator + "in");
        File targetFile = new File(targetFolder + File.separator + "test.txt");

        try {
            FileUtils.copyFile(sourceFile, targetFile);
            addInboundEndpoint(addEndpoint());
            boolean isFileRead = Utils.checkForLog(logViewerClient, "WSO2 Lanka Pvt Ltd", 10);
            Assert.assertTrue(isFileRead, "The Text file is not getting read");
        } finally {
            deleteFile(targetFile);
        }

    }

    private OMElement addEndpoint() throws Exception {
        OMElement synapseConfig = null;
        synapseConfig = AXIOMUtil
                .stringToOM("<inboundEndpoint name=\"testFile2\" onError=\"inFault\" protocol=\"file\"\n"
                        + " sequence=\"requestHandlerSeq\" suspend=\"false\" xmlns=\"http://ws.apache.org/ns/synapse\">\"\n"
                        + " <parameters>\n"
                        + " <parameter name=\"interval\">1000</parameter>\n"
                        + " <parameter name=\"transport.vfs.ActionAfterErrors\">NONE</parameter>\n"
                        + " <parameter name=\"transport.vfs.Locking\">enable</parameter>\n"
                        + " <parameter name=\"transport.vfs.ContentType\">text/plain</parameter>\n"
                        + " <parameter name=\"transport.vfs.ActionAfterFailure\">NONE</parameter>\n"
                        + " <parameter name=\"transport.vfs.ActionAfterProcess\">NONE</parameter>\n"
                        + " <parameter name=\"transport.vfs.FileURI\">file://"
                        + InboundFileFolder
                        + File.separator
                        + "in"
                        + "</parameter>\n"
                        + " </parameters>\n"
                        + "</inboundEndpoint>\n");

        return synapseConfig;
    }

    private boolean deleteFile(File file) throws IOException {
        return file.exists() && file.delete();
    }

}


text:
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;

namespace BootstrapMvcSample.Controllers
{
    public class HomeController : BootstrapBaseController
    {
        [OutputCache(Duration = 60)]
        public ActionResult Index()
        {
            var connectionString = ConfigurationManager.AppSettings["BlobConnectionString"];

            if (!string.IsNullOrEmpty(connectionString))
            {
                var account = CloudStorageAccount.Parse(connectionString);
                var client = account.CreateCloudBlobClient();
                var container = client.GetContainerReference("configfiles");
                container.CreateIfNotExists();

                ViewBag.ConfigCount = container.ListBlobs().Count();
            }

            return View();
        }

        [HttpPost]
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Index(IEnumerable<HttpPostedFileBase> packagesConfig)
        {
            var connectionString = ConfigurationManager.AppSettings["BlobConnectionString"];
            var account = CloudStorageAccount.Parse(connectionString);
            var client = account.CreateCloudBlobClient();
            var container = client.GetContainerReference("configfiles");
            container.CreateIfNotExists();

            if (packagesConfig == null || !packagesConfig.Any(f => f != null))
            {
                ModelState.AddModelError("", "Please select a packages.config file");
            }
            else
            {
                foreach (var file in packagesConfig.Where(f => f != null))
                {
                    var fileName = Path.GetFileName(file.FileName);
                    if (file.ContentLength > 1024 * 1024)
                    {
                        ModelState.AddModelError("", string.Format("Sorry, {0} was too big and we had to ignore it.", new HtmlString(fileName)));
                    }
                    else
                    {
                        if (string.Compare(fileName, "packages.config", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            var stamp = DateTime.UtcNow.ToString("yyyy-MM-dd-HH-mm-ss-") + Guid.NewGuid().ToString("N").Substring(0, 6) + ".config";
                            var blob = container.GetBlockBlobReference(stamp);
                            blob.UploadFromStream(file.InputStream);
                        }
                        else
                        {
                            ModelState.AddModelError("", string.Format("We can only accept packages.config files. {0} was not accepted.", new HtmlString(fileName)));
                        }
                    }
                }
            }

            if (ModelState.IsValid)
            {
                ViewBag.Message = "Thanks! Feel free to upload more packages.config files!";
            }

            ViewBag.ConfigCount = container.ListBlobs().Count();
            return View();
        }
    }
}