text:
package httpserver

import (
	"net/http"
	"net/http/httptest"
	"os"
	"strings"
	"testing"
	"time"
)

func TestNewReplacer(t *testing.T) {
	w := httptest.NewRecorder()
	recordRequest := NewResponseRecorder(w)
	reader := strings.NewReader(`{"username": "dennis"}`)

	request, err := http.NewRequest("POST", "http://localhost", reader)
	if err != nil {
		t.Fatal("Request Formation Failed\n")
	}
	rep := NewReplacer(request, recordRequest, "")

	switch v := rep.(type) {
	case *replacer:
		if v.getSubstitution("{host}") != "localhost" {
			t.Error("Expected host to be localhost")
		}
		if v.getSubstitution("{method}") != "POST" {
			t.Error("Expected request method  to be POST")
		}
	default:
		t.Fatalf("Expected *replacer underlying Replacer type, got: %#v", rep)
	}
}

func TestReplace(t *testing.T) {
	w := httptest.NewRecorder()
	recordRequest := NewResponseRecorder(w)
	reader := strings.NewReader(`{"username": "dennis"}`)

	request, err := http.NewRequest("POST", "http://localhost", reader)
	if err != nil {
		t.Fatal("Request Formation Failed\n")
	}
	request.Header.Set("Custom", "foobarbaz")
	request.Header.Set("ShorterVal", "1")
	repl := NewReplacer(request, recordRequest, "-")
	// add some headers after creating replacer
	request.Header.Set("CustomAdd", "caddy")

	hostname, err := os.Hostname()
	if err != nil {
		t.Fatal("Failed to determine hostname\n")
	}

	testCases := []struct {
		template string
		expect   string
	}{
		{"This hostname is {hostname}", "This hostname is " + hostname},
		{"This host is {host}.", "This host is localhost."},
		{"This request method is {method}.", "This request method is POST."},
		{"The response status is {status}.", "The response status is 200."},
		{"The Custom header is {>Custom}.", "The Custom header is foobarbaz."},
		{"The CustomAdd header is {>CustomAdd}.", "The CustomAdd header is caddy."},
		{"The request is {request}.", "The request is POST / HTTP/1.1\\r\\nHost: localhost\\r\\nCustom: foobarbaz\\r\\nCustomadd: caddy\\r\\nShorterval: 1\\r\\n\\r\\n."},
		{"The cUsToM header is {>cUsToM}...", "The cUsToM header is foobarbaz..."},
		{"The Non-Existent header is {>Non-Existent}.", "The Non-Existent header is -."},
		{"Bad {host placeholder...", "Bad {host placeholder..."},
		{"Bad {>Custom placeholder", "Bad {>Custom placeholder"},
		{"Bad {>Custom placeholder {>ShorterVal}", "Bad -"},
	}

	for _, c := range testCases {
		if expected, actual := c.expect, repl.Replace(c.template); expected != actual {
			t.Errorf("for template '%s', expected '%s', got '%s'", c.template, expected, actual)
		}
	}

	complexCases := []struct {
		template     string
		replacements map[string]string
		expect       string
	}{
		{
			"/a{1}/{2}",
			map[string]string{
				"{1}": "12",
				"{2}": "",
			},
			"/a12/"},
	}

	for _, c := range complexCases {
		repl := &replacer{
			customReplacements: c.replacements,
		}
		if expected, actual := c.expect, repl.Replace(c.template); expected != actual {
			t.Errorf("for template '%s', expected '%s', got '%s'", c.template, expected, actual)
		}
	}
}

func TestSet(t *testing.T) {
	w := httptest.NewRecorder()
	recordRequest := NewResponseRecorder(w)
	reader := strings.NewReader(`{"username": "dennis"}`)

	request, err := http.NewRequest("POST", "http://localhost", reader)
	if err != nil {
		t.Fatalf("Request Formation Failed: %s\n", err.Error())
	}
	repl := NewReplacer(request, recordRequest, "")

	repl.Set("host", "getcaddy.com")
	repl.Set("method", "GET")
	repl.Set("status", "201")
	repl.Set("variable", "value")

	if repl.Replace("This host is {host}") != "This host is getcaddy.com" {
		t.Error("Expected host replacement failed")
	}
	if repl.Replace("This request method is {method}") != "This request method is GET" {
		t.Error("Expected method replacement failed")
	}
	if repl.Replace("The response status is {status}") != "The response status is 201" {
		t.Error("Expected status replacement failed")
	}
	if repl.Replace("The value of variable is {variable}") != "The value of variable is value" {
		t.Error("Expected variable replacement failed")
	}
}

func TestRound(t *testing.T) {
	var tests = map[time.Duration]time.Duration{
		// 599.935µs -> 560µs
		559935 * time.Nanosecond: 560 * time.Microsecond,
		// 1.55ms    -> 2ms
		1550 * time.Microsecond: 2 * time.Millisecond,
		// 1.5555s   -> 1.556s
		1555500 * time.Microsecond: 1556 * time.Millisecond,
		// 1m2.0035s -> 1m2.004s
		62003500 * time.Microsecond: 62004 * time.Millisecond,
	}

	for dur, expected := range tests {
		rounded := roundDuration(dur)
		if rounded != expected {
			t.Errorf("Expected %v, Got %v", expected, rounded)
		}
	}
}

func TestMillisecondConverstion(t *testing.T) {
	var testCases = map[time.Duration]int64{
		2 * time.Second:           2000,
		9039492 * time.Nanosecond: 9,
		1000 * time.Microsecond:   1,
		127 * time.Nanosecond:     0,
		0 * time.Millisecond:      0,
		255 * time.Millisecond:    255,
	}

	for dur, expected := range testCases {
		numMillisecond := convertToMilliseconds(dur)
		if numMillisecond != expected {
			t.Errorf("Expected %v. Got %v", expected, numMillisecond)
		}
	}
}


text:
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder
  xmlns:ui="urn:ui:com.google.gwt.uibinder"
  xmlns:b="urn:import:org.gwtbootstrap3.client.ui"
  xmlns:bh="urn:import:org.gwtbootstrap3.client.ui.html"
  xmlns:g="urn:import:com.google.gwt.user.client.ui"
  xmlns:w="urn:import:org.sagebionetworks.web.client.widget"
>
  <bh:Div addStyleNames="margin-5">
    <bh:Div
      ui:field="htmlSanitizedWarning"
      visible="false"
      addStyleNames="margin-top-20 margin-bottom-10"
    >
      <b:Alert type="INFO">
        <bh:Text text="Limited rendering only." />
        <b:Anchor
          ui:field="showContentLink"
          text="External view available."
          addStyleNames="margin-left-5"
        />
      </b:Alert>
    </bh:Div>
    <bh:Div ui:field="loadingUI" addStyleNames="center center-block">
      <w:LoadingSpinner size="31px" />
      <bh:Text ui:field="loadingMessage" />
    </bh:Div>
    <bh:Div ui:field="htmlContainer" />
    <bh:Span ui:field="storeRawHtmlSpan" visible="false" />
    <bh:Div ui:field="synAlertContainer" />
  </bh:Div>
</ui:UiBinder>

redpajama_set_name: RedPajamaGithub


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
Geophytology 3(1): 113 (1973)

#### Original name
Anaptychia coronata Kurok.

### Remarks
null


text:
package com.ansorgit.plugins.bash.lang.psi.util;

import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiFile;

import java.util.List;

import javax.annotation.Nullable;

/**
 * User: jansorg
 * Date: Nov 2, 2009
 * Time: 8:50:30 PM
 */
public class BashPsiFileUtils {
    /**
     * Takes an existing psi file and tries to find another file relative to the first.
     * The file path is given as a relative path.
     *
     * @param start        The existing psi file
     * @param relativePath The relative path as a string
     * @return The psi file or null if nothing has been found
     */
    @Nullable
    public static PsiFile findRelativeFile(PsiFile start, String relativePath) {
        PsiDirectory startDirectory = BashPsiUtils.findFileContext(start).getContainingDirectory();
        if (startDirectory == null || StringUtil.isEmptyOrSpaces(relativePath)) {
            return null;
        }

        //fixme handle escaped / chars!
        PsiDirectory currentDir = startDirectory;

        List<String> parts = StringUtil.split(relativePath, "/");
        String filePart = parts.size() > 0 ? parts.get(parts.size() - 1) : "";

        for (int i = 0, partsLength = parts.size() - 1; (i < partsLength) && (currentDir != null); i++) {
            String part = parts.get(i);

            if (".".equals(part)) {
                //ignore this
            } else if ("..".equals(part)) {
                currentDir = currentDir.getParentDirectory();
            } else {
                currentDir = currentDir.findSubdirectory(part);
            }
        }

        if (currentDir != null) {
            return currentDir.findFile(filePart);
        }

        return null;
    }
}


text:
package org.elasticsearch.index.fielddata.plain;

import org.apache.lucene.index.AtomicReader;
import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.index.Terms;
import org.apache.lucene.util.*;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.common.util.DoubleArray;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.fielddata.*;
import org.elasticsearch.index.fielddata.fieldcomparator.DoubleValuesComparatorSource;
import org.elasticsearch.index.fielddata.ordinals.GlobalOrdinalsBuilder;
import org.elasticsearch.index.fielddata.ordinals.Ordinals;
import org.elasticsearch.index.fielddata.ordinals.OrdinalsBuilder;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.settings.IndexSettings;
import org.elasticsearch.indices.fielddata.breaker.CircuitBreakerService;
import org.elasticsearch.search.MultiValueMode;

/**
 */
public class DoubleArrayIndexFieldData extends AbstractIndexFieldData<DoubleArrayAtomicFieldData> implements IndexNumericFieldData<DoubleArrayAtomicFieldData> {

    private final CircuitBreakerService breakerService;

    public static class Builder implements IndexFieldData.Builder {

        @Override
        public IndexFieldData<?> build(Index index, @IndexSettings Settings indexSettings, FieldMapper<?> mapper, IndexFieldDataCache cache,
                                       CircuitBreakerService breakerService, MapperService mapperService, GlobalOrdinalsBuilder globalOrdinalBuilder) {
            return new DoubleArrayIndexFieldData(index, indexSettings, mapper.names(), mapper.fieldDataType(), cache, breakerService);
        }
    }

    public DoubleArrayIndexFieldData(Index index, @IndexSettings Settings indexSettings, FieldMapper.Names fieldNames,
                                     FieldDataType fieldDataType, IndexFieldDataCache cache, CircuitBreakerService breakerService) {
        super(index, indexSettings, fieldNames, fieldDataType, cache);
        this.breakerService = breakerService;
    }

    @Override
    public NumericType getNumericType() {
        return NumericType.DOUBLE;
    }

    @Override
    public boolean valuesOrdered() {
        // because we might have single values? we can dynamically update a flag to reflect that
        // based on the atomic field data loaded
        return false;
    }

    @Override
    public DoubleArrayAtomicFieldData loadDirect(AtomicReaderContext context) throws Exception {

        AtomicReader reader = context.reader();
        Terms terms = reader.terms(getFieldNames().indexName());
        DoubleArrayAtomicFieldData data = null;
        // TODO: Use an actual estimator to estimate before loading.
        NonEstimatingEstimator estimator = new NonEstimatingEstimator(breakerService.getBreaker());
        if (terms == null) {
            data = DoubleArrayAtomicFieldData.empty();
            estimator.afterLoad(null, data.ramBytesUsed());
            return data;
        }
        // TODO: how can we guess the number of terms? numerics end up creating more terms per value...
        DoubleArray values = BigArrays.NON_RECYCLING_INSTANCE.newDoubleArray(128);

        final float acceptableTransientOverheadRatio = fieldDataType.getSettings().getAsFloat("acceptable_transient_overhead_ratio", OrdinalsBuilder.DEFAULT_ACCEPTABLE_OVERHEAD_RATIO);
        boolean success = false;
        try (OrdinalsBuilder builder = new OrdinalsBuilder(reader.maxDoc(), acceptableTransientOverheadRatio)) {
            final BytesRefIterator iter = builder.buildFromTerms(getNumericType().wrapTermsEnum(terms.iterator(null)));
            BytesRef term;
            long numTerms = 0;
            while ((term = iter.next()) != null) {
                values = BigArrays.NON_RECYCLING_INSTANCE.grow(values, numTerms + 1);
                values.set(numTerms++, NumericUtils.sortableLongToDouble(NumericUtils.prefixCodedToLong(term)));
            }
            values = BigArrays.NON_RECYCLING_INSTANCE.resize(values, numTerms);
            Ordinals build = builder.build(fieldDataType.getSettings());
            BytesValues.WithOrdinals ordinals = build.ordinals();
            if (ordinals.isMultiValued() || CommonSettings.getMemoryStorageHint(fieldDataType) == CommonSettings.MemoryStorageFormat.ORDINALS) {
                data = new DoubleArrayAtomicFieldData.WithOrdinals(values, build);
            } else {
                final FixedBitSet set = builder.buildDocsWithValuesSet();

                // there's sweet spot where due to low unique value count, using ordinals will consume less memory
                long singleValuesArraySize = reader.maxDoc() * RamUsageEstimator.NUM_BYTES_DOUBLE + (set == null ? 0 : RamUsageEstimator.sizeOf(set.getBits()) + RamUsageEstimator.NUM_BYTES_INT);
                long uniqueValuesArraySize = values.ramBytesUsed();
                long ordinalsSize = build.ramBytesUsed();
                if (uniqueValuesArraySize + ordinalsSize < singleValuesArraySize) {
                    data = new DoubleArrayAtomicFieldData.WithOrdinals(values, build);
                    success = true;
                    return data;
                }

                int maxDoc = reader.maxDoc();
                DoubleArray sValues = BigArrays.NON_RECYCLING_INSTANCE.newDoubleArray(maxDoc);
                for (int i = 0; i < maxDoc; i++) {
                    final long ordinal = ordinals.getOrd(i);
                    if (ordinal != BytesValues.WithOrdinals.MISSING_ORDINAL) {
                        sValues.set(i, values.get(ordinal));
                    }
                }
                assert sValues.size() == maxDoc;
                if (set == null) {
                    data = new DoubleArrayAtomicFieldData.Single(sValues);
                } else {
                    data = new DoubleArrayAtomicFieldData.SingleFixedSet(sValues, set);
                }
            }
            success = true;
            return data;
        } finally {
            if (success) {
                estimator.afterLoad(null, data.ramBytesUsed());
            }

        }

    }

    @Override
    public XFieldComparatorSource comparatorSource(@Nullable Object missingValue, MultiValueMode sortMode) {
        return new DoubleValuesComparatorSource(this, missingValue, sortMode);
    }
}


text:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>ws.ament.microservices</groupId>
    <artifactId>ms-utils</artifactId>
    <packaging>jar</packaging>
    <parent>
        <groupId>ws.ament.microservices</groupId>
        <artifactId>microservices-examples</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <dependencies>
        <dependency>
            <groupId>org.jboss.weld.se</groupId>
            <artifactId>weld-se</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jaxrs</artifactId>
        </dependency>
        <dependency>
            <groupId>io.undertow</groupId>
            <artifactId>undertow-core</artifactId>
        </dependency>
        <dependency>
            <groupId>io.undertow</groupId>
            <artifactId>undertow-servlet</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-cdi</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>async-http-servlet-3.0</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.container</groupId>
            <artifactId>arquillian-weld-se-embedded-1.1</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.deltaspike.cdictrl</groupId>
            <artifactId>deltaspike-cdictrl-weld</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.deltaspike.cdictrl</groupId>
            <artifactId>deltaspike-cdictrl-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.deltaspike.core</groupId>
            <artifactId>deltaspike-core-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.deltaspike.core</groupId>
            <artifactId>deltaspike-core-impl</artifactId>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>ws.ament.ms.startup.StartupApplication</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>


text:
package com.beecavegames.videopoker.handlers;

import static com.google.common.base.Preconditions.*;

import com.beecavegames.bjc.util.PlayerUtil;
import com.beecavegames.common.Response;
import com.beecavegames.common.data.StaticData;
import com.beecavegames.dispatch.Param;
import com.beecavegames.eris.cards.Shoe;
import com.beecavegames.eris.cards.euchre.EuchreCard;
import com.beecavegames.videopoker.data.VideoPokerSpec;
import com.google.inject.Inject;

public class CheatHandler {
	@Inject
	StaticData staticData;

	@Inject
	PlayerUtil playerUtil;

	public Response handle(@Param("specId") long specId, @Param("cards") String[] cards, @Param("beeId") long beeId) {
		final VideoPokerSpec spec = staticData
				.get(VideoPokerSpec.class, specId);
		checkNotNull(spec, "No such spec");
		Shoe<EuchreCard> shoe = spec.buildShoe();

		shoe.stackTop(EuchreCard.fromCodes(cards));

		playerUtil.modifyPlayer(beeId, p -> {
			p.getVpPlayer().setCheatShoe(shoe);
		});

		return new Response();
	}
}


text:
**Rotation Plug-in Sample** demonstrates how to use **Media SDK** (hereinafter referred to as "**SDK**") API to implement user-defined functions using a special **SDK** API extension to make user-defined functions able to participate in the **SDK** pipeline.

## Features

**Rotation Plug-in Sample** implements 180 degree picture rotation.

## Software Requirements

See [`<install-folder>/Media_Samples_Guide_Linux.md`](./Media_Samples_Guide_Linux.md).

## How to Build the Application

See [`<install-folder>/Media_Samples_Guide_Linux.md`](./Media_Samples_Guide_Linux.md).

## Running the Software

**Rotation Plug-in Sample** is a shared library which can be invoked from the **Encoding Sample** by running **Encoding Sample** with the option `–angle 180` or from the **Transcoding Sample** with the same option `–angle 180`.

See `<install-folder>/doc/samples/readme-encode.md` or `<install-folder>/doc/samples/readme-multi-transcode.md` for details.

## Known Limitations

* Rotation plugin does not work with opaque memory. Use `–ext_allocator` option of sample_multi_transcode to use external allocator instead of opaque memory.

## Legal Information

INFORMATION IN THIS DOCUMENT IS PROVIDED IN CONNECTION WITH INTEL PRODUCTS. NO LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY INTELLECTUAL PROPERTY RIGHTS IS GRANTED BY THIS DOCUMENT. EXCEPT AS PROVIDED IN INTEL'S TERMS AND CONDITIONS OF SALE FOR SUCH PRODUCTS, INTEL ASSUMES NO LIABILITY WHATSOEVER AND INTEL DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO SALE AND/OR USE OF INTEL PRODUCTS INCLUDING LIABILITY OR WARRANTIES RELATING TO FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.

UNLESS OTHERWISE AGREED IN WRITING BY INTEL, THE INTEL PRODUCTS ARE NOT DESIGNED NOR INTENDED FOR ANY APPLICATION IN WHICH THE FAILURE OF THE INTEL PRODUCT COULD CREATE A SITUATION WHERE PERSONAL INJURY OR DEATH MAY OCCUR.

Intel may make changes to specifications and product descriptions at any time, without notice. Designers must not rely on the absence or characteristics of any features or instructions marked "reserved" or "undefined." Intel reserves these for future definition and shall have no responsibility whatsoever for conflicts or incompatibilities arising from future changes to them. The information here is subject to change without notice. Do not finalize a design with this information.

The products described in this document may contain design defects or errors known as errata which may cause the product to deviate from published specifications. Current characterized errata are available on request.

Contact your local Intel sales office or your distributor to obtain the latest specifications and before placing your product order.

Copies of documents which have an order number and are referenced in this document, or other Intel literature, may be obtained by calling 1-800-548-4725, or by visiting Intel's Web Site.

MPEG is an international standard for video compression/decompression promoted by ISO. Implementations of MPEG CODECs, or MPEG enabled platforms may require licenses from various entities, including Intel Corporation.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

**Optimization Notice**

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel.

Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.
Notice revision #20110804


text:
avr_mppt_charge_controller
==========================

To build a maximum power point tracking (MPPT) charge controller for cheap.

This is no big deal, thousands of people around the world has already done this.
I started this to reuse components from few malfunctioning buck and boost converters I got from eBay.
Figured out that although control circuits of these failed, inductors, MOSFET s and Schottky diodes worked like almost new.
Than throwing them into garbage I thought of recycling them into my own intelligent charge controller.

This is my first time working with inductors. It was a trial and fail case with trying out different PWM frequencies with inductors.
Chose 32kHz as it gave me best efficiency out of the circuit.

Schematic diagram is added.

Please bear in mind that I am a full time Linux, Java, Python guy who is into C, avr-gcc, Microcontrollers and electronics
just for a hobby. Please don't be rude of the code quality of my C programming (because it is not what I do as a full time professinal).

I think somebody will get some use out of this code. Feedbacks are welcome!

Cheers!


text:
\defmodule {ubrent}

This module implements some random number generators proposed by Richard
  P. Brent (Web pages at \index{Generator!Xorshift}%
\url{http://web.comlab.ox.ac.uk/oucl/work/richard.brent/}
and \url{http://wwwmaths.anu.edu.au/~brent/random.html}).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\bigskip
\hrule
\code\hide
/* ubrent.h for ANSI C */
#ifndef UBRENT_H
#define UBRENT_H
\endhide
#include "gdef.h"
#include "unif01.h"
\endcode

\guisec{The xorgens generators, version 2004}
\code

unif01_Gen* ubrent_CreateXorgen32 (int r, int s, int a, int b, int c, int d,
                                   lebool hasWeyl, unsigned int seed);
\endcode
  \tab Some fast long-period random number generators \cite{rBRE04a}
        generalizing Marsaglia's \textit{Xorshift} RNGs \cite{rMAR03a}
 (see page \pageref{marsa-xorshift} of this guide).  The
   output may be combined with a Weyl generator.
 % (This is the \textbf{2004 version} of these generators.)
 The parameters $r, s, a, b,  c, d$ are chosen such that the $n \times n$
   matrix $T$ defining the recurrence has a minimal polynomial which
\index{Generator!Xorgen32}%
      is of degree $n$ and primitive over $\mathbb{F}_2$.
The state of the generator is made up of $n= 32 r$ bits.
The primary recurrence is $x_k = x_{k-r}A + x_{k-s}B$, where matrices
$A$ and $B$ implement a combination of left and right shifts;
 in the notation of Marsaglia, $A = (I + L^a)(I + R^b)$ and
 $B = (I + L^c)(I + R^d)$ with
 $I$ the identity matrix, $L^a$ a left shift by $a$ bits,
and $R^b$ a right shift by $b$ bits. If \texttt{hasWeyl} is \texttt{TRUE},
then the Weyl combination is added to the output as in Brent original
code. If it is  \texttt{FALSE}, then no Weyl combination is added;
 this is useful for testing these \textit{xorgens} by themselves.
Restrictions: $r > 1$, $0 < s < r$ and $0 < a,b,c,d < 32$,
and $r$ must be a power of 2.
%
The following table gives parameters recommended by Brent
for the \textit{best} 32-bit generators of this kind
according to the criteria given in \url{ftp://ftp.comlab.ox.ac.uk/pub/Documents/techpapers/Richard.Brent/random/xortable.txt}.
\endtab
%
\begin {table}
\centering
\label {tab:brentparam32}
\caption {Good parameters for Brent's \texttt{xorgens} generators}
\begin {tabular}{@{\extracolsep{15pt}}|rrrcccccc|}
\hline
    $n$ &  $r$  &   $s$ &   $a$ &  $b$ &  $c$ &  $d$ &  Weight & delta \\
\hline
 64  &   2  &  1  &  17  &  14  &  12  &  19  &  \phantom{1}31  &  12 \\
 128  &  4  &  3  &  15  &  14  &  12  &  17  &  \phantom{1}55  &  12 \\
 256  &  8  &  3  &  18  &  13  &  14  &  15  &  109  &  13 \\
 512  &  16  &  1  &  17  &  15  &  13  &  14  &  185  &  13 \\
 1024  &  32  &  15  &  19  &  11  &  13  &  16  &  225  &  11 \\
 2048  &  64  &  59  &  19  &  12  &  14  &  15  &  213  &  12 \\
 4096  &  128  &  95  &  17  &  12  &  13  &  15  &  251  &  12 \\
% 4224  & 132  &  67 & 15 & 14 & 13 & 18 &  243 &  13 \\
%  4480  & 140 &   19 & 17 & 13 & 15 & 16 &  251 &   13 \\
\hline
\end {tabular}
\end {table}
\code

unif01_Gen* ubrent_CreateXor4096s (unsigned int seed);
\endcode
  \tab This is the 32-bit generator  \textit{xor4096s} with period
 $2^{32}(2^{4096}-1)$ proposed by Brent \cite{rBRE04a}.
%  (This is the \textbf{2004 version} of this generator.)
 It is a generalization of
 Marsaglia's \textit{Xorshift} generators \cite{rMAR03a} (see page
 \pageref{marsa-xorshift} of this guide).
  The initial seed is \texttt{seed}. This generator corresponds to the more
general case above with parameters
$n=4096$,  $r=128$,   $s=95$,  $a=17$,  $b=12$,  $c=13$, $d=15$,
 Weight $=251$,  delta $=12$.
\index{Generator!xor4096s}%
  \endtab
\code

#ifdef USE_LONGLONG

unif01_Gen* ubrent_CreateXorgen64 (int r, int s, int a, int b, int c, int d,
                                   lebool hasWeyl, ulonglong seed);
\endcode
  \tab Similar to \texttt{ubrent\_CreateXorgen32} above but with 64-bit
  generators. % (This is the \textbf{2004 version} of these generators.)
  The state of the generator is made up of $n= 64 r$ bits,
  but only the 32 most significant bits
  of each generated number are used here.
\index{Generator!Xorgen64}%
  Restrictions: $r > 1$, $0 < s < r$ and $0 < a,b,c,d < 64$,
  and $r$ must be a power of 2.
The following table gives parameters recommended by Brent
for the \textit{best} generators of their kind
according to the criteria given in \url{ftp://ftp.comlab.ox.ac.uk/pub/Documents/techpapers/Richard.Brent/random/xortable.txt}.
\endtab
%
\begin {table}
\centering
\label {tab:brentparam64}
\caption {Good parameters for Brent's \texttt{xorgens} generators}
\begin {tabular}{@{\extracolsep{15pt}}|rrrcccccc|}
\hline
    $n$ &  $r$  &   $s$ &   $a$ &  $b$ &  $c$ &  $d$ &  Weight & delta \\
\hline
 128  &  2   & 1  & 33 & 31 & 28 & 29  & 65  & 28 \\
 256  &  4   & 3  & 37 & 27 & 29 & 33  & 127 & 27 \\
 512  &  8   & 1  & 37 & 26 & 29 & 34  & 231 & 26 \\
 1024 &  16  & 7  & 34 & 29 & 25 & 31  & 439 & 25 \\
 2048 &  32  & 1  & 35 & 27 & 26 & 37  & 745 & 26 \\
 4096 &  64  & 53 & 33 & 26 & 27 & 29  & 961 & 26 \\
% 4224 &  66  & 41 & 33 & 31 & 27 & 29  & 987 & 27 \\
%  4480 &  70  & 61 & 34 & 29 & 30 & 31  & 951 & 29 \\
\hline
\end {tabular}
\end {table}
\code

unif01_Gen* ubrent_CreateXor4096l (ulonglong seed);
\endcode
  \tab This is the 64-bit generator  \textit{xor4096l} with period at least
 $(2^{4096}-1)$ proposed by Brent \cite{rBRE04a}.
%  (This is the \textbf{2004 version} of this generator.)
 It is a generalization of Marsaglia's \textit{Xorshift} generators
 \cite{rMAR03a} (see page \pageref{marsa-xorshift} of this guide).
  The initial seed is \texttt{seed}. While Brent's original code returns
  64-bit numbers, only the 32 most significant bits
  of each generated number are used here.
\index{Generator!xor4096l}%
  \endtab
\code

unif01_Gen* ubrent_CreateXor4096d (ulonglong seed);
\endcode
  \tab This is the 53-bit floating-point generator \textit{xor4096d}
 with period at least $(2^{4096}-1)$ proposed by Brent \cite{rBRE04a}.
 % (This is the \textbf{2004 version} of this generator.)
  It is based on \textit{xor4096l} (implemented in \texttt{ubrent\_CreateXor4096l}
  above) and uses its 53  most significant bits. The initial seed is \texttt{seed}.
\index{Generator!xor4096d}%
 \endtab
\code

#endif
\endcode

\guisec{The xorgens generators, version 2006}
\code

unif01_Gen* ubrent_CreateXor4096i (unsigned long seed);
\endcode
  \tab This is the % 32-bit (on 32-bit machine) or 64-bit (on 64-bit machine)
  integer random number generator  \textit{xor4096i} with period at least
 $(2^{4096}-1)$ proposed by Brent (see
  \url{http://wwwmaths.anu.edu.au/~brent/random.html}).  This is the
   {2006 version} of the generators \textit{xor4096s} and
  \textit{xor4096l}. It has a different initialization and a slightly
  different algorithm from the 2004 version.
\index{Generator!xor4096i}%
  \endtab
\code

unif01_Gen* ubrent_CreateXor4096r (unsigned long seed);
\endcode
  \tab This is the floating-point generator \textit{xor4096r} proposed by Brent
  (see \url{http://wwwmaths.anu.edu.au/~brent/random.html}).
  This is the {2006 version} of the generators \textit{xor4096f} and
  \textit{xor4096d}. It is based on \textit{xor4096i} implemented in
  \texttt{ubrent\_CreateXor4096i} above. The initial seed is \texttt{seed}.
\index{Generator!xor4096r}%
 \endtab

\guisec{Clean-up functions}
\code

void ubrent_DeleteXorgen32 (unif01_Gen *);
void ubrent_DeleteXor4096s (unif01_Gen *);
void ubrent_DeleteXor4096i (unif01_Gen *);
void ubrent_DeleteXor4096r (unif01_Gen *);

#ifdef USE_LONGLONG
   void ubrent_DeleteXorgen64 (unif01_Gen *);
   void ubrent_DeleteXor4096l (unif01_Gen *);
   void ubrent_DeleteXor4096d (unif01_Gen *);
#endif
\endcode
  \tab Frees the dynamic memory allocated by the corresponding
  \texttt{Create} functions of this module. \endtab
\code\hide
#endif
\endhide\endcode


text:
@annotate: folktale.concurrency.future.rejected
category: Constructing
---

Constructs a future holding a failure value.

## Example::

    const { rejected } = require('folktale/concurrency/future');

    rejected(1).mapRejected(x => {
      $ASSERT(x == 1);
    });


text:
/*
 * $Id$
 */

/*

Copyright (c) 2000-2013 Board of Trustees of Leland Stanford Jr. University,
all rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
STANFORD UNIVERSITY BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of Stanford University shall not
be used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from Stanford University.

*/

package org.lockss.protocol;

import java.io.*;
import java.util.HashSet;

import org.lockss.util.IOUtil;

/**
 * @author edwardsb
 *
 */
public class DatedPeerIdSetImpl extends PersistentPeerIdSetImpl implements
    DatedPeerIdSet {

  public static final long k_dateDefault = -1;

  private long m_date;

  /**
   * @param filePeerId
   * @param identityManager
   */
  public DatedPeerIdSetImpl(File filePeerId, IdentityManager identityManager) {
    super(filePeerId, identityManager);

    m_date = k_dateDefault;
  }

  /** (non-Javadoc)
   * @see org.lockss.protocol.DatedPeerIdSet#getDate()
   */
  public long getDate() throws IOException {
    loadIfNecessary();
    return m_date;
  }

  /* (non-Javadoc)
   * @see org.lockss.protocol.DatedPeerIdSet#setDate(java.lang.Long)
   */
  public void setDate(long l) throws IOException {
    loadIfNecessary();
    if (m_date != l) {
      m_date = l;
      m_changed = true;
      storeIfNecessary();
    }
  }

  @Override
  protected void readData(DataInputStream is) throws IOException {
    m_date = is.readLong();
    super.readData(is);
  }

  @Override
  protected void newData() throws IOException {
    m_date = k_dateDefault;
    super.newData();
  }

  @Override
  protected void writeData(DataOutputStream dos) throws IOException {
    dos.writeLong(m_date);
    super.writeData(dos);
  }
}


text:
.class public Landroid/media/soundtrigger/SoundTriggerManager$Model;
.super Ljava/lang/Object;
.source "SoundTriggerManager.java"

# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Landroid/media/soundtrigger/SoundTriggerManager;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x9
    name = "Model"
.end annotation

# instance fields
.field private mGenericSoundModel:Landroid/hardware/soundtrigger/SoundTrigger$GenericSoundModel;

# direct methods
.method constructor <init>(Landroid/hardware/soundtrigger/SoundTrigger$GenericSoundModel;)V
    .locals 0

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    iput-object p1, p0, Landroid/media/soundtrigger/SoundTriggerManager$Model;->mGenericSoundModel:Landroid/hardware/soundtrigger/SoundTrigger$GenericSoundModel;

    return-void
.end method

.method public static create(Ljava/util/UUID;Ljava/util/UUID;[B)Landroid/media/soundtrigger/SoundTriggerManager$Model;
    .locals 2

    new-instance v0, Landroid/media/soundtrigger/SoundTriggerManager$Model;

    new-instance v1, Landroid/hardware/soundtrigger/SoundTrigger$GenericSoundModel;

    invoke-direct {v1, p0, p1, p2}, Landroid/hardware/soundtrigger/SoundTrigger$GenericSoundModel;-><init>(Ljava/util/UUID;Ljava/util/UUID;[B)V

    invoke-direct {v0, v1}, Landroid/media/soundtrigger/SoundTriggerManager$Model;-><init>(Landroid/hardware/soundtrigger/SoundTrigger$GenericSoundModel;)V

    return-object v0
.end method

# virtual methods
.method getGenericSoundModel()Landroid/hardware/soundtrigger/SoundTrigger$GenericSoundModel;
    .locals 1

    iget-object v0, p0, Landroid/media/soundtrigger/SoundTriggerManager$Model;->mGenericSoundModel:Landroid/hardware/soundtrigger/SoundTrigger$GenericSoundModel;

    return-object v0
.end method

.method public getModelData()[B
    .locals 1

    iget-object v0, p0, Landroid/media/soundtrigger/SoundTriggerManager$Model;->mGenericSoundModel:Landroid/hardware/soundtrigger/SoundTrigger$GenericSoundModel;

    iget-object v0, v0, Landroid/hardware/soundtrigger/SoundTrigger$GenericSoundModel;->data:[B

    return-object v0
.end method

.method public getModelUuid()Ljava/util/UUID;
    .locals 1

    iget-object v0, p0, Landroid/media/soundtrigger/SoundTriggerManager$Model;->mGenericSoundModel:Landroid/hardware/soundtrigger/SoundTrigger$GenericSoundModel;

    iget-object v0, v0, Landroid/hardware/soundtrigger/SoundTrigger$GenericSoundModel;->uuid:Ljava/util/UUID;

    return-object v0
.end method

.method public getVendorUuid()Ljava/util/UUID;
    .locals 1

    iget-object v0, p0, Landroid/media/soundtrigger/SoundTriggerManager$Model;->mGenericSoundModel:Landroid/hardware/soundtrigger/SoundTrigger$GenericSoundModel;

    iget-object v0, v0, Landroid/hardware/soundtrigger/SoundTrigger$GenericSoundModel;->vendorUuid:Ljava/util/UUID;

    return-object v0
.end method


text:
exiterr() { echo "Error: ${1}" >&2; exit 1; }

set -e
set -x

if [ ! -f /.dockerenv ]; then
  exiterr "This script ONLY runs in a Docker container."
fi

export
cmake -D CMAKE_BUILD_TYPE=Release \
      -D PACKAGE_SYSTEM_NAME=debian /source
make package


text:
%**************************************************************************
% Returns the volume of a rectangular box.
%
% @param   l   The length of the rectangular box.
% @param   w   The width of the rectangular box.
% @param   h   The height of the rectangular box.
%
% @return  The volume, l*w*h.
%
% [1] Hunt, Richard A., Calculus of a Single Variable, Harper & Row
%     1998.
%**************************************************************************
% If you have any questions, comments, or find bugs, please feel free to
% email me at geoff.hayes74@gmail.com.
%
% Geoff Hayes 2014
%**************************************************************************
function [v] = vol_rect(l,w,h)

    v = l*w*h;

end


text:
module HttpMonkey

  class Configuration

    def initialize
      net_adapter(:net_http)  #default adapter
      @behaviours = HttpMonkey::Configuration::Behaviours.new
      # behaviour default always return response
      @behaviours.on_unknown { |client, req, response| response }
      @middlewares = HttpMonkey::Configuration::Middlewares.new
      @storage = Hash.new
    end

    def initialize_copy(source)
      super
      @behaviours = @behaviours.clone
      @middlewares = @middlewares.clone
    end

    def net_adapter(adapter = nil)
      @net_adapter = adapter unless adapter.nil?
      @net_adapter
    end

    def behaviours(&block)
      @behaviours.instance_eval(&block) if block_given?
      @behaviours
    end

    def middlewares(&block)
      @middlewares.instance_eval(&block) if block_given?
      @middlewares
    end

    def storage(store = nil)
      @storage = store unless store.nil?
      @storage
    end

  end

end