text:
class AddCategoryToItems < ActiveRecord::Migration
  def change
    add_column :items, :category_id, :integer
  end
end

redpajama_set_name: RedPajamaGithub


text:
background_changer
==================

背景色を白から灰色にするChromeExtensions


text:
package keyman

import (
	"net"
	"os"
	"testing"
	"time"

	"github.com/stretchr/testify/assert"
)

const (
	PK_FILE   = "testpk.pem"
	CERT_FILE = "testcert.pem"

	ONE_WEEK  = 7 * 24 * time.Hour
	TWO_WEEKS = ONE_WEEK * 2
)

func TestRoundTrip(t *testing.T) {
	defer func() {
		if err := os.Remove(PK_FILE); err != nil {
			log.Debugf("Unable to remove file: %v", err)
		}
	}()
	defer func() {
		if err := os.Remove(CERT_FILE); err != nil {
			log.Debugf("Unable to remove file: %v", err)
		}
	}()

	pk, err := GeneratePK(1024)
	assert.NoError(t, err, "Unable to generate PK")

	err = pk.WriteToFile(PK_FILE)
	assert.NoError(t, err, "Unable to save PK")

	pk2, err := LoadPKFromFile(PK_FILE)
	assert.NoError(t, err, "Unable to load PK")
	assert.Equal(t, pk.PEMEncoded(), pk2.PEMEncoded(), "Loaded PK didn't match saved PK")

	cert, err := pk.TLSCertificateFor(time.Now().Add(TWO_WEEKS), true, nil, "Test Org", "TestCommonName", "testdomain.com", "127.0.0.1")
	assert.NoError(t, err, "Unable to generate self-signed certificate")

	numberOfDNSSans := len(cert.X509().DNSNames)
	if numberOfDNSSans != 2 {
		t.Errorf("Wrong number of DNS SANs, expected 1 got %d", numberOfDNSSans)
	} else {
		assert.Equal(t, "testdomain.com", cert.X509().DNSNames[0], "Wrong DNS SAN")
		assert.Equal(t, "TestCommonName", cert.X509().DNSNames[1], "Wrong DNS SAN")
	}

	numberOfIPSANs := len(cert.X509().IPAddresses)
	if numberOfIPSANs != 1 {
		t.Errorf("Wrong number of IP SANs, expected 1 got %d", numberOfIPSANs)
	} else {
		ip := cert.X509().IPAddresses[0]
		expectedIP := net.ParseIP("127.0.0.1")
		assert.Equal(t, expectedIP.String(), ip.String(), "Wrong IP SAN")
	}

	err = cert.WriteToFile(CERT_FILE)
	assert.NoError(t, err, "Unable to write certificate to file")

	cert2, err := LoadCertificateFromFile(CERT_FILE)
	assert.NoError(t, err, "Unable to load certificate from file")
	assert.Equal(t, cert.PEMEncoded(), cert2.PEMEncoded(), "Loaded certificate didn't match saved certificate")

	_, err = pk.Certificate(cert.X509(), cert)
	assert.NoError(t, err, "Unable to generate certificate signed by original certificate")

	pk3, err := GeneratePK(1024)
	assert.NoError(t, err, "Unable to generate PK 3")

	_, err = pk.CertificateForKey(cert.X509(), cert, &pk3.rsaKey.PublicKey)
	assert.NoError(t, err, "Unable to generate certificate for pk3")

	x509rt, err := LoadCertificateFromX509(cert.X509())
	assert.NoError(t, err, "Unable to load certificate from X509")
	assert.Equal(t, cert, x509rt, "X509 round tripped cert didn't match original")
}


text:
package fly.entity.historyLocationMove;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import fly.entity.dev.DevEntity;
import com.framework.system.db.dao.annotation.ColumnDescription;
import com.framework.system.db.dao.annotation.RelationlDescription;
import com.framework.system.db.dao.annotation.TableDescription;

/**
 * @Title: Entity
 * @Description: 定位器人卡分离历史状态
 * @author feng.gu
 * @date 2015-09-07 14:15:47
 * @version V1.0
 *
 */
@TableDescription(name = "mordo_state_history_location_move")
public class HistoryLocationMoveEntity implements java.io.Serializable {
    public final static String ID = "ID";
    public final static String DEV_ID = "DEV_ID";
    public final static String MOVING = "MOVING";
    public final static String MOVINGUPDATETIME = "MOVINGUPDATETIME";

    /**
	 * 编号
	 */
	@ColumnDescription(name = "ID", isPrimaryKey = true, isAutoIncrement = true)
	private Integer id;
    /**
	 * 设备编号
	 */
	@ColumnDescription(name = "DEV_ID")
	private Integer devId;
    /**
	 * Y-正常,N-人卡分离
	 */
	@ColumnDescription(name = "MOVING")
	private String moving;
    /**
	 * 人卡分离记录更新时间
	 */
	@ColumnDescription(name = "MOVINGUPDATETIME")
	private String movingupdatetime;

    public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
    public Integer getDevId() {
		return devId;
	}

	public void setDevId(Integer devId) {
		this.devId = devId;
	}
    public String getMoving() {
		return moving;
	}

	public void setMoving(String moving) {
		this.moving = moving;
	}
    public String getMovingupdatetime() {
		return movingupdatetime;
	}

	public void setMovingupdatetime(String movingupdatetime) {
		this.movingupdatetime = movingupdatetime;
	}

    /**
     * 关系描述
	 */
	    @RelationlDescription(relation = "ManyToOne",
		joinEntity="DevEntity"	,joinColumn="ID"	)

		private DevEntity dev;

	public DevEntity getDev() {
		return dev;
    }

	public void setDev(DevEntity dev) {
		this.dev = dev;
	}

}


text:
namespace blink {

class PLATFORM_EXPORT PicturePattern final : public Pattern {
public:
    static PassRefPtr<PicturePattern> create(PassRefPtr<SkPicture>, RepeatMode);

    ~PicturePattern() override;

protected:
    sk_sp<SkShader> createShader() const override;

private:
    PicturePattern(PassRefPtr<SkPicture>, RepeatMode);

    sk_sp<SkPicture> m_tilePicture;
};

} // namespace blink

#endif


text: Extends composite testing with common Ebean testing dependencies such as avaje-ebeanorm-mocker


text:
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/ioport.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/delay.h>
#include <linux/netdevice.h>
#include <linux/init.h>
#include <linux/arcdevice.h>
#include <linux/com20020.h>

#include <asm/io.h>

#define VERSION "arcnet: COM20020 chipset support (by David Woodhouse et al.)\n"

static char *clockrates[] =
{"10 Mb/s", "Reserved", "5 Mb/s",
 "2.5 Mb/s", "1.25Mb/s", "625 Kb/s", "312.5 Kb/s",
 "156.25 Kb/s", "Reserved", "Reserved", "Reserved"};

static void com20020_command(struct net_device *dev, int command);
static int com20020_status(struct net_device *dev);
static void com20020_setmask(struct net_device *dev, int mask);
static int com20020_reset(struct net_device *dev, int really_reset);
static void com20020_copy_to_card(struct net_device *dev, int bufnum,
				  int offset, void *buf, int count);
static void com20020_copy_from_card(struct net_device *dev, int bufnum,
				    int offset, void *buf, int count);
static void com20020_set_mc_list(struct net_device *dev);
static void com20020_close(struct net_device *);

static void com20020_copy_from_card(struct net_device *dev, int bufnum,
				    int offset, void *buf, int count)
{
	int ioaddr = dev->base_addr, ofs = 512 * bufnum + offset;

	/* set up the address register */
	outb((ofs >> 8) | RDDATAflag | AUTOINCflag, _ADDR_HI);
	outb(ofs & 0xff, _ADDR_LO);

	/* copy the data */
	TIME("insb", count, insb(_MEMDATA, buf, count));
}

static void com20020_copy_to_card(struct net_device *dev, int bufnum,
				  int offset, void *buf, int count)
{
	int ioaddr = dev->base_addr, ofs = 512 * bufnum + offset;

	/* set up the address register */
	outb((ofs >> 8) | AUTOINCflag, _ADDR_HI);
	outb(ofs & 0xff, _ADDR_LO);

	/* copy the data */
	TIME("outsb", count, outsb(_MEMDATA, buf, count));
}

/* Reset the card and check some basic stuff during the detection stage. */
int com20020_check(struct net_device *dev)
{
	int ioaddr = dev->base_addr, status;
	struct arcnet_local *lp = netdev_priv(dev);

	ARCRESET0;
	mdelay(RESETtime);

	lp->setup = lp->clockm ? 0 : (lp->clockp << 1);
	lp->setup2 = (lp->clockm << 4) | 8;

	/* CHECK: should we do this for SOHARD cards ? */
	/* Enable P1Mode for backplane mode */
	lp->setup = lp->setup | P1MODE;

	SET_SUBADR(SUB_SETUP1);
	outb(lp->setup, _XREG);

	if (lp->clockm != 0)
	{
		SET_SUBADR(SUB_SETUP2);
		outb(lp->setup2, _XREG);

		/* must now write the magic "restart operation" command */
		mdelay(1);
		outb(0x18, _COMMAND);
	}

	lp->config = 0x21 | (lp->timeout << 3) | (lp->backplane << 2);
	/* set node ID to 0x42 (but transmitter is disabled, so it's okay) */
	SETCONF;
	outb(0x42, ioaddr + BUS_ALIGN*7);

	status = ASTATUS();

	if ((status & 0x99) != (NORXflag | TXFREEflag | RESETflag)) {
		BUGMSG(D_NORMAL, "status invalid (%Xh).\n", status);
		return -ENODEV;
	}
	BUGMSG(D_INIT_REASONS, "status after reset: %X\n", status);

	/* Enable TX */
	outb(0x39, _CONFIG);
	outb(inb(ioaddr + BUS_ALIGN*8), ioaddr + BUS_ALIGN*7);

	ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear);

	status = ASTATUS();
	BUGMSG(D_INIT_REASONS, "status after reset acknowledged: %X\n",
	       status);

	/* Read first location of memory */
	outb(0 | RDDATAflag | AUTOINCflag, _ADDR_HI);
	outb(0, _ADDR_LO);

	if ((status = inb(_MEMDATA)) != TESTvalue) {
		BUGMSG(D_NORMAL, "Signature byte not found (%02Xh != D1h).\n",
		       status);
		return -ENODEV;
	}
	return 0;
}

const struct net_device_ops com20020_netdev_ops = {
	.ndo_open	= arcnet_open,
	.ndo_stop	= arcnet_close,
	.ndo_start_xmit = arcnet_send_packet,
	.ndo_tx_timeout = arcnet_timeout,
	.ndo_set_multicast_list = com20020_set_mc_list,
};

/* Set up the struct net_device associated with this card.  Called after
 * probing succeeds.
 */
int com20020_found(struct net_device *dev, int shared)
{
	struct arcnet_local *lp;
	int ioaddr = dev->base_addr;

	/* Initialize the rest of the device structure. */

	lp = netdev_priv(dev);

	lp->hw.owner = THIS_MODULE;
	lp->hw.command = com20020_command;
	lp->hw.status = com20020_status;
	lp->hw.intmask = com20020_setmask;
	lp->hw.reset = com20020_reset;
	lp->hw.copy_to_card = com20020_copy_to_card;
	lp->hw.copy_from_card = com20020_copy_from_card;
	lp->hw.close = com20020_close;

	if (!dev->dev_addr[0])
		dev->dev_addr[0] = inb(ioaddr + BUS_ALIGN*8);	/* FIXME: do this some other way! */

	SET_SUBADR(SUB_SETUP1);
	outb(lp->setup, _XREG);

	if (lp->card_flags & ARC_CAN_10MBIT)
	{
		SET_SUBADR(SUB_SETUP2);
		outb(lp->setup2, _XREG);

		/* must now write the magic "restart operation" command */
		mdelay(1);
		outb(0x18, _COMMAND);
	}

	lp->config = 0x20 | (lp->timeout << 3) | (lp->backplane << 2) | 1;
	/* Default 0x38 + register: Node ID */
	SETCONF;
	outb(dev->dev_addr[0], _XREG);

	/* reserve the irq */
	if (request_irq(dev->irq, &arcnet_interrupt, shared,
			"arcnet (COM20020)", dev)) {
		BUGMSG(D_NORMAL, "Can't get IRQ %d!\n", dev->irq);
		return -ENODEV;
	}

	dev->base_addr = ioaddr;

	BUGMSG(D_NORMAL, "%s: station %02Xh found at %03lXh, IRQ %d.\n",
	       lp->card_name, dev->dev_addr[0], dev->base_addr, dev->irq);

	if (lp->backplane)
		BUGMSG(D_NORMAL, "Using backplane mode.\n");

	if (lp->timeout != 3)
		BUGMSG(D_NORMAL, "Using extended timeout value of %d.\n", lp->timeout);

	BUGMSG(D_NORMAL, "Using CKP %d - data rate %s.\n",
	       lp->setup >> 1,
	       clockrates[3 - ((lp->setup2 & 0xF0) >> 4) + ((lp->setup & 0x0F) >> 1)]);

	if (register_netdev(dev)) {
		free_irq(dev->irq, dev);
		return -EIO;
	}
	return 0;
}

/*
 * Do a hardware reset on the card, and set up necessary registers.
 *
 * This should be called as little as possible, because it disrupts the
 * token on the network (causes a RECON) and requires a significant delay.
 *
 * However, it does make sure the card is in a defined state.
 */
static int com20020_reset(struct net_device *dev, int really_reset)
{
	struct arcnet_local *lp = netdev_priv(dev);
	u_int ioaddr = dev->base_addr;
	u_char inbyte;

	BUGMSG(D_DEBUG, "%s: %d: %s: dev: %p, lp: %p, dev->name: %s\n",
		__FILE__,__LINE__,__func__,dev,lp,dev->name);
	BUGMSG(D_INIT, "Resetting %s (status=%02Xh)\n",
	       dev->name, ASTATUS());

	BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);
	lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2);
	/* power-up defaults */
	SETCONF;
	BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);

	if (really_reset) {
		/* reset the card */
		ARCRESET;
		mdelay(RESETtime * 2);	/* COM20020 seems to be slower sometimes */
	}
	/* clear flags & end reset */
	BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);
	ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear);

	/* verify that the ARCnet signature byte is present */
	BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);

	com20020_copy_from_card(dev, 0, 0, &inbyte, 1);
	BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);
	if (inbyte != TESTvalue) {
		BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);
		BUGMSG(D_NORMAL, "reset failed: TESTvalue not present.\n");
		return 1;
	}
	/* enable extended (512-byte) packets */
	ACOMMAND(CONFIGcmd | EXTconf);
	BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);

	/* done!  return success. */
	return 0;
}

static void com20020_setmask(struct net_device *dev, int mask)
{
	u_int ioaddr = dev->base_addr;
	BUGMSG(D_DURING, "Setting mask to %x at %x\n",mask,ioaddr);
	AINTMASK(mask);
}

static void com20020_command(struct net_device *dev, int cmd)
{
	u_int ioaddr = dev->base_addr;
	ACOMMAND(cmd);
}

static int com20020_status(struct net_device *dev)
{
	u_int ioaddr = dev->base_addr;

	return ASTATUS() + (ADIAGSTATUS()<<8);
}

static void com20020_close(struct net_device *dev)
{
	struct arcnet_local *lp = netdev_priv(dev);
	int ioaddr = dev->base_addr;

	/* disable transmitter */
	lp->config &= ~TXENcfg;
	SETCONF;
}

/* Set or clear the multicast filter for this adaptor.
 * num_addrs == -1    Promiscuous mode, receive all packets
 * num_addrs == 0       Normal mode, clear multicast list
 * num_addrs > 0        Multicast mode, receive normal and MC packets, and do
 *                      best-effort filtering.
 *      FIXME - do multicast stuff, not just promiscuous.
 */
static void com20020_set_mc_list(struct net_device *dev)
{
	struct arcnet_local *lp = netdev_priv(dev);
	int ioaddr = dev->base_addr;

	if ((dev->flags & IFF_PROMISC) && (dev->flags & IFF_UP)) {	/* Enable promiscuous mode */
		if (!(lp->setup & PROMISCset))
			BUGMSG(D_NORMAL, "Setting promiscuous flag...\n");
		SET_SUBADR(SUB_SETUP1);
		lp->setup |= PROMISCset;
		outb(lp->setup, _XREG);
	} else
		/* Disable promiscuous mode, use normal mode */
	{
		if ((lp->setup & PROMISCset))
			BUGMSG(D_NORMAL, "Resetting promiscuous flag...\n");
		SET_SUBADR(SUB_SETUP1);
		lp->setup &= ~PROMISCset;
		outb(lp->setup, _XREG);
	}
}

#if defined(CONFIG_ARCNET_COM20020_PCI_MODULE) || \
    defined(CONFIG_ARCNET_COM20020_ISA_MODULE) || \
    defined(CONFIG_ARCNET_COM20020_CS_MODULE)
EXPORT_SYMBOL(com20020_check);
EXPORT_SYMBOL(com20020_found);
EXPORT_SYMBOL(com20020_netdev_ops);
#endif

MODULE_LICENSE("GPL");

#ifdef MODULE

static int __init com20020_module_init(void)
{
	BUGLVL(D_NORMAL) printk(VERSION);
	return 0;
}

static void __exit com20020_module_exit(void)
{
}
module_init(com20020_module_init);
module_exit(com20020_module_exit);
#endif				/* MODULE */


text:
class ModelAirplane
  include ActiveModel::Validations

  attr_accessor :wingspan
  attr_accessor :wingspan_before_type_cast

  validates :wingspan, numericality: { greater_than: 0, less_than: 5000 }
end


text:
from telemetry.page import page as page_module
from telemetry.page import page_set as page_set_module

class SkiaBuildbotDesktopPage(page_module.Page):

  def __init__(self, url, page_set):
    super(SkiaBuildbotDesktopPage, self).__init__(
        url=url,
        page_set=page_set,
        credentials_path='data/credentials.json')
    self.user_agent_type = 'tablet'
    self.archive_data_file = 'data/skia_engadget_nexus10.json'

  def RunNavigateSteps(self, action_runner):
    action_runner.NavigateToPage(self)
    action_runner.Wait(5)

class SkiaEngadgetNexus10PageSet(page_set_module.PageSet):

  """ Pages designed to represent the median, not highly optimized web """

  def __init__(self):
    super(SkiaEngadgetNexus10PageSet, self).__init__(
      user_agent_type='tablet',
      archive_data_file='data/skia_engadget_nexus10.json')

    urls_list = [
      # Why: from klobag.
      'http://www.engadget.com/',
    ]

    for url in urls_list:
      self.AddPage(SkiaBuildbotDesktopPage(url, self))


text: [APNET 2017](http://conferences.sigcomm.org/events/apnet2017)


text:
namespace sandbox {

// This class provides a small wrapper around setrlimit().
class SANDBOX_EXPORT ResourceLimits {
 public:
  ResourceLimits() = delete;
  ResourceLimits(const ResourceLimits&) = delete;
  ResourceLimits& operator=(const ResourceLimits&) = delete;

  // Lower the soft and hard limit of |resource| to |limit|. If the current
  // limit is lower than |limit|, keep it. Returns 0 on success, or |errno|.
  static int Lower(int resource, rlim_t limit) WARN_UNUSED_RESULT;

  // Lower the soft limit of |resource| to |limit| and the hard limit to |max|.
  // If the current limit is lower than the new values, keep it. Returns 0 on
  // success, or |errno|.
  static int LowerSoftAndHardLimits(int resource,
                                    rlim_t soft_limit,
                                    rlim_t hard_limit) WARN_UNUSED_RESULT;

  // Change soft limit of |resource| to the current limit plus |change|. If
  // |resource + change| is larger than the hard limit, the soft limit is set to
  // be the same as the hard limit. Fails and returns false if the underlying
  // call to setrlimit fails. Returns 0 on success, or |errno|.
  static int AdjustCurrent(int resource,
                           long long int change) WARN_UNUSED_RESULT;
};

}  // namespace sandbox

#endif  // SANDBOX_LINUX_SERVICES_RESOURCE_LIMITS_H_


text:
from django.conf.urls.defaults import *
from django.conf import settings

urlpatterns = patterns('lighthouse.views.btoscript',
    url(r'^$', 'index', name="btoscript"),
    url(r'^args/$', 'args'),
#    url(r'^codes/$', 'codes'),
)


text:
<!doctype html>
<html>
<head>
  <title>Jasmine Bowling Game Runner</title>
  <link rel="stylesheet" type="text/css" href="css/jasmine.css">
  <script src="js/libs/jasmine.js"></script>
  <script src="js/libs/jasmine-html.js"></script>
  <script src="js/libs/require.js" data-main="js/app/config/config"></script>
</head>
<body>
    <script>
      // Add your Jasmine spec files here
      require(["../../test/specs/bowlingSpec"], function(spec) {
        jasmine.getEnv().addReporter(new jasmine.HtmlReporter());
        jasmine.getEnv().execute();
      });
    </script>
</body>
</html>


text:
package org.burroloco.donkey.spit.csv;

import org.burroloco.donkey.data.core.Data;

import java.util.Set;

import static org.burroloco.donkey.util.FileConstants.WIN_EOL;

public class DefaultHeaderProcessor implements HeaderProcessor {
    SliceProcessor sliceProcessor;

    public void process(Data data, StringBuilder results) {
        Set<String> columns = data.names();
        sliceProcessor.values(results, columns);
        results.append(WIN_EOL);
    }

}


text:
package br.edu.ufsj.dcomp.pertence;

import java.io.Serializable;

import br.edu.ufsj.dcomp.grupo_usuario.GrupoUsuario;
import br.edu.ufsj.dcomp.pessoa.Pessoa;

public class Pertence implements Serializable {

	private static final long serialVersionUID = 1L;

	private GrupoUsuario grupo_usuario;
	private Pessoa pessoa;

	public Pertence() {
		super();
		// TODO Auto-generated constructor stub
	}

	public GrupoUsuario getGrupo_usuario() {
		return grupo_usuario;
	}

	public void setGrupo_usuario(GrupoUsuario grupo_usuario) {
		this.grupo_usuario = grupo_usuario;
	}

	public Pessoa getPessoa() {
		return pessoa;
	}

	public void setPessoa(Pessoa pessoa) {
		this.pessoa = pessoa;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((grupo_usuario == null) ? 0 : grupo_usuario.hashCode());
		result = prime * result + ((pessoa == null) ? 0 : pessoa.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Pertence other = (Pertence) obj;
		if (grupo_usuario == null) {
			if (other.grupo_usuario != null)
				return false;
		} else if (!grupo_usuario.equals(other.grupo_usuario))
			return false;
		if (pessoa == null) {
			if (other.pessoa != null)
				return false;
		} else if (!pessoa.equals(other.pessoa))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Pertence [grupo_usuario=" + grupo_usuario.getId() + ", pessoa=" + pessoa.getId() + "]";
	}

}


text:
/*
 * This file is part of FFmpeg.
 *
 * FFmpeg 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.1 of the License, or (at your option) any later version.
 *
 * FFmpeg is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with FFmpeg; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#include "config.h"
#include "libavutil/mem.h"
#include "avfft.h"

int main(int argc, char **argv)
{
    int i;
#define LEN 1024
    FFTSample *ref  = av_malloc_array(LEN, sizeof(*ref));
    FFTSample *data = av_malloc_array(LEN, sizeof(*data));
    RDFTContext *rdft_context  = av_rdft_init(10, DFT_R2C);
    RDFTContext *irdft_context = av_rdft_init(10, IDFT_C2R);

    if (!ref || !data || !rdft_context || !irdft_context)
        return 2;
    for (i=0; i<LEN; i++) {
        ref[i] = data[i] = i*456 + 123 + i*i;
    }
    av_rdft_calc(rdft_context, data);
    av_rdft_calc(irdft_context, data);

    for (i=0; i<LEN; i++) {
        if (fabs(ref[i] - data[i]/LEN*2) > 1) {
            fprintf(stderr, "Failed at %d (%f %f)\n", i, ref[i], data[i]/LEN*2);
            return 1;
        }
    }

    av_rdft_end(rdft_context);
    av_rdft_end(irdft_context);
    av_free(data);
    av_free(ref);

    return 0;
}


text:
<?xml version="1.0"?>
<schema version="0.3">
	<table name="sixeightdatadisplayTemplates">
		<field name="tID" type="I">
			<key />
			<unsigned />
			<autoincrement />
		</field>
		<field name="fID" type="I" />
		<field name="templateName" type="C" size="255"></field>
		<field name="templateType" type="C" size="255"></field>
		<field name="templateHeader" type="X2"/>
		<field name="templateContent" type="X2"/>
		<field name="templateAlternateContent" type="X2"/>
		<field name="templateFooter" type="X2"/>
		<field name="templateEmpty" type="X2"/>
	</table>
</schema>


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<TITLE>
communication.unicast
</TITLE>

<META NAME="date" CONTENT="2013-12-06">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style">

communication.unicast

Interfaces

UnicastClient

Classes

UnicastServer

UnicastSocketClient

UnicastSocketServer


text:
{{{
"title": "Register an Existing AWS Windows Instance",
"date": "03-30-2017",
"author": "Thomas Broadwell",
"attachments": [],
"contentIsHTML": false
}}}

<iframe width="560" height="315" src="https://player.vimeo.com/video/210482890" frameborder="0" allowfullscreen></iframe>

### Introduction

This tutorial will show you how to import an existing Windows instance that was auto-discovered in your AWS provider using [Cloud Application Manager](https://www.ctl.io/cloud-application-manager).

### Find an AWS Windows Instance

Within the Cloud Application Manager workspace, navigate to your AWS provider and run the sync function by clicking **Sync**.

![Run Sync](../../images/cloud-application-manager/cam-register-existing-aws-windows-instance-1.png)

The sync process will discover unregistered AWS instances and list them under the **Unregistered Instances** tab.

![Locate Unregistered Instances](../../images/cloud-application-manager/cam-register-existing-aws-windows-instance-2.png)

### Register the Instance

Under the Unregistered Instances tab, click the instance you want to import and register.

Provide any details for the instance in the fields provided.

![Register Instance](../../images/cloud-application-manager/cam-register-existing-aws-windows-instance-3.png)

Click **Register** to register the instance.

Cloud Application Manager returns an error message because the agent installation script that allows CenturyLink to register the instance is not yet executed on this instance.

### Install the Agent Installation Script

Copy the agent installation script provided in the **Activity** tab in the log details.

![Copy agent installation script](../../images/cloud-application-manager/cam-register-existing-aws-windows-instance-4.png)

Log-in to the instance residing in your AWS provider.

Execute the agent installation script.

![Execute agent installation script](../../images/cloud-application-manager/cam-register-existing-aws-windows-instance-5.png)

Once the script is executed, the instance will be available in Cloud Application Manager.

You can now use lifecycle application management features on this instance in Cloud Application Manager.


text:
<?php

namespace tourze\Html\Tag;

use tourze\Html\Element\BlockElement;
use tourze\Html\Tag;

/**
 * P标签
 */
class P extends Tag implements BlockElement
{

    protected $_tagName = 'p';

}


text:
title: Telerik.Web.UI.ProgressBarType
page_title: Client-side API Reference
description: Client-side API Reference
slug: Telerik.Web.UI.ProgressBarType
---

# enum Telerik.Web.UI.ProgressBarType

## Inheritance Hierarchy

* *[Telerik.Web.UI.ProgressBarType]({%slug Telerik.Web.UI.ProgressBarType%})*

## Fields

### Value `0`

### Percent `1`

### Chunk `2`


text:
#ifndef _pid_h
#define _pid_h

/** \addtogroup pid PID-Controller
 *  \ingroup Flight
 *  Simple implementation for multiple floating-point
 *  PID Controllers.
 *  @{
 */

/** \file pid.h
 *  PID Library Header
 */

/** Data Structure for a single PID Controller.
 *  Stores all needed constants and state variables.
 */
typedef struct {
    double kp; /**< Proportional factor. Default is #PID_P. */
    double ki; /**< Integral factor. Default is #PID_I. */
    double kd; /**< Derivative factor. Default is #PID_D. */
    double outMin; /**< Minimum Output. Default is #PID_OUTMIN. */
    double outMax; /**< Maximum Output. Default is #PID_OUTMAX. */
    double intMin; /**< Minimum Integral sum. Default is #PID_INTMIN. */
    double intMax; /**< Maximum Integral sum. Default is #PID_INTMAX. */
    double lastError; /**< Derivative State. */
    double sumError; /**< Integral state. Kept in #intMin, #intMax Range. */
    time_t last; /**< Last execution time. For dT calculation. */
} PIDState;

#define ROLL 0 /**< Roll index for #pidTarget, #pidOutput and #pidStates. */
#define PITCH 1 /**< Pitch index for #pidTarget, #pidOutput and #pidStates. */

extern double pidTarget[2]; /**< Roll and Pitch target angles. */
extern double pidOutput[2]; /**< Roll and Pitch PID Output. */
extern PIDState pidStates[2]; /**< Roll and Pitch PID States. */

/** Initialize Roll and Pitch PID.
 * Stores the PID States in #pidStates.
 * Also resets #pidTarget to zero.
 */
void pidInit(void);

/** Step the Roll and Pitch PID Controllers.
 * Placing their output in #pidOutput and reading the input
 * from #pidTarget and the global orientation Angles.
 */
void pidTask(void);

/** Set the parameters of a PID controller.
 *  The state variables will be reset to zero.
 *
 * \param pid PIDState to be changed.
 * \param kp New Proportional constant.
 * \param ki New Integral constant.
 * \param kd New Derivative constant.
 * \param min New minimum Output.
 * \param max New maximum Output.
 * \param iMin New minimal Integral Sum.
 * \param iMax New maximal Integral Sum.
 */
void pidSet(PIDState *pid, double kp, double ki, double kd, double min, double max, double iMin, double iMax);

/** Execute a single PID Control Step.
 * \param should Target value
 * \param is Measured value
 * \param state PID State
 * \return PID Output
 */
double pidExecute(double should, double is, PIDState *state);

#endif
/** @} */


text:
namespace BABYLON {

struct BABYLON_SHARED_EXPORT MultiMaterialPropertyGridComponent {

  static void renderChildMaterial(const MultiMaterialPtr& material)
  {
    // --- CHILDREN ---
    static auto childrenContainerOpened = true;
    ImGui::SetNextTreeNodeOpen(childrenContainerOpened, ImGuiCond_Always);
    if (ImGui::CollapsingHeader("CHILDREN")) {
      auto i = 0;
      for (const auto& mat : material->subMaterials()) {
        if (mat) {
          TextLineComponent::render(StringTools::printf("Material #%d", i).c_str(), mat->name);
        }
        ++i;
      }
      childrenContainerOpened = true;
    }
    else {
      childrenContainerOpened = false;
    }
  }

  static void render(const MultiMaterialPtr& material)
  {
    CommonMaterialPropertyGridComponent::render(material);
    renderChildMaterial(material);
  }

}; // end of struct MultiMaterialPropertyGridComponent

} // end of namespace BABYLON

#endif // end of
       // BABYLON_INSPECTOR_COMPONENTS_ACTION_TABS_TABS_PROPERTY_GRIDS_MATERIALS_MULTI_MATERIAL_PROPERTY_GRID_COMPONENT_H


text:
<?php global $wp_query; if ( $wp_query->max_num_pages > 1 ) { ?>

<?php next_posts_link(sprintf( __( '%s older', '' ), '←' ) ) ?>

<?php previous_posts_link(sprintf( __( 'newer %s', '' ), '→' ) ) ?>

<?php } ?>


text:
require "rails_helper"

describe InvitationMailer, :type => :mailer do
  let(:invite) { FactoryGirl.create(:invite, referrer: FactoryGirl.create(:user, name: "Foo bar")) }
  let(:mail) { InvitationMailer.send_invite(invite) }

  it 'renders the subject' do
    expect(mail.subject).to eql('Foo bar invites you to join string on Linkastor')
  end

  it 'renders the receiver email' do
    expect(mail.to).to eql(invite.email)
  end

  it 'renders the sender email' do
    expect(mail.from).to eql(['noreply@linkastor.herokuapp.com'])
  end

  it 'assigns referrer name' do
    expect(mail.body.encoded).to match(invite.referrer.name)
  end

  it 'assigns group name' do
    expect(mail.body.encoded).to match(invite.group.name)
  end

  it 'assigns join_url' do
    expect(mail.body.encoded).to match("http://localhost/invites/#{invite.code}")
  end
end


text:
FROM alpine:3.10

ENV TERRAFORM_VERSION 0.12.16

RUN apk add --update wget ca-certificates unzip git bash && \
    wget -q -O /terraform.zip "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" && \
    unzip /terraform.zip -d /bin && \
    apk del --purge wget ca-certificates unzip && \
    rm -rf /var/cache/apk/* /terraform.zip

VOLUME ["/data"]
WORKDIR /data

ENTRYPOINT ["/bin/terraform"]

CMD ["--help"]


text:
using System;
using System.Reflection;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("Xero.Bus")]
[assembly: AssemblyDescription("The Xero Bus interfaces used for intra and cross-app messaging")]
[assembly: AssemblyCompany("Xero")]
[assembly: AssemblyProduct("Xero.Bus")]
[assembly: AssemblyCopyright("Copyright © Xero 2013")]
[assembly: ComVisible(false)]
[assembly: CLSCompliant(true)]


text:
package net.metanotion.util;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.SynchronousQueue;

/** A "stream" view of java.util.concurrent.*Queue's. This provides a pipe metaphor, the InPipe is an ObjectInputStream
which reads objects written to the OutPipe, which is an ObjectOutputStream. The underlying ObjectPipe uses the
java.util.concurrent Queue implementations to provide various blocking semantics and memory bounds.
	@param <I> the type of objects the streams read/write.
*/
public final class ObjectPipe<I> {
	private final BlockingQueue q;

	private boolean closed = false;

	/** Create an object pipe.
		@param capacity If capacity is -1, queue will use a linked list(unbounded size), 0 will use a synchronous
			queue, and > 0 will bound the size of the queue.
	*/
	public ObjectPipe(final int capacity) {
		if(capacity <= 0) {
			this.q = new LinkedBlockingQueue();
		} else if(capacity == 0) {
			this.q = new SynchronousQueue();
		} else {
			this.q = new ArrayBlockingQueue(capacity);
		}
	}

	private static final Object EOFMarker = new Object();

	private static final class InPipe<I> implements ObjectInputStream<I> {
		private final ObjectPipe<I> pipe;
		private InPipe(final ObjectPipe<I> p) { this.pipe = p; }

		public int available() { return pipe.q.size(); }

		public I read() throws ObjectStreamClosedException {
			while((!pipe.closed) || (!pipe.q.isEmpty())) {
				try {
					final Object o = pipe.q.take();
					if(o != EOFMarker) { return (I) o; }
				} catch (InterruptedException ie) { }
			}
			throw new ObjectStreamClosedException();
		}

		public boolean isEOF() {
			if(pipe.closed && pipe.q.isEmpty()) { return true; }
			return false;
		}

		public void close() { pipe.close(); }
	}

	private static final class OutPipe<I> implements ObjectOutputStream<I> {
		private final ObjectPipe<I> pipe;
		private OutPipe(final ObjectPipe<I> p) { this.pipe = p; }

		public void write(final I d) throws ObjectStreamClosedException {
			boolean tryAgain = true;
			while(tryAgain) {
				if(pipe.closed) { throw new ObjectStreamClosedException(); }
				try {
					pipe.q.put(d);
					tryAgain = false;
				} catch (InterruptedException ie) { }
			}
		}
		public void close() { pipe.close(); }
		public void flush() { }
	}

	/** Close the pipe(input and output pipes will receive an ObjectStreamClosedException after the queue's empty).
	*/
	private void close() {
		this.closed = true;
		boolean tryAgain = true;
		while(tryAgain) {
			try {
				q.put(EOFMarker);
				tryAgain = false;
			} catch (InterruptedException ie) { }
		}
	}

	/** Return the writer side of the pipe.
		@return Stream to write objects in to the pipe.
	*/
	public ObjectOutputStream<I> getOutput() {
		if(closed) { throw new ObjectStreamClosedException(); }
		return new OutPipe<I>(this);
	}

	/** Return the reader side of the pipe.
		@return Stream to read objects from the pipe.
	*/
	public ObjectInputStream<I> getInput() { return new InPipe<I>(this); }
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>R.color</title>
<meta name="date" content="2017-05-21">
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Skip navigation links

Overview

Package

Class

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method

com.incoherentglitch.mybillardassistant

Class R.color

java.lang.Object

com.incoherentglitch.mybillardassistant.R.color

Enclosing class:

R

public static final class R.color
extends java.lang.Object

Field Summary

Fields

Modifier and Type
Field and Description

static int
abc_background_cache_hint_selector_material_dark

static int
abc_background_cache_hint_selector_material_light

static int
abc_btn_colored_borderless_text_material

static int
abc_btn_colored_text_material

static int
abc_color_highlight_material

static int
abc_hint_foreground_material_dark

static int
abc_hint_foreground_material_light

static int
abc_input_method_navigation_guard

static int
abc_primary_text_disable_only_material_dark

static int
abc_primary_text_disable_only_material_light

static int
abc_primary_text_material_dark

static int
abc_primary_text_material_light

static int
abc_search_url_text

static int
abc_search_url_text_normal

static int
abc_search_url_text_pressed

static int
abc_search_url_text_selected

static int
abc_secondary_text_material_dark

static int
abc_secondary_text_material_light

static int
abc_tint_btn_checkable

static int
abc_tint_default

static int
abc_tint_edittext

static int
abc_tint_seek_thumb

static int
abc_tint_spinner

static int
abc_tint_switch_thumb

static int
abc_tint_switch_track

static int
accent_material_dark

static int
accent_material_light

static int
background_floating_material_dark

static int
background_floating_material_light

static int
background_material_dark

static int
background_material_light

static int
bright_foreground_disabled_material_dark

static int
bright_foreground_disabled_material_light

static int
bright_foreground_inverse_material_dark

static int
bright_foreground_inverse_material_light

static int
bright_foreground_material_dark

static int
bright_foreground_material_light

static int
button_material_dark

static int
button_material_light

static int
colorAccent

static int
colorPrimary

static int
colorPrimaryDark

static int
common_action_bar_splitter

static int
common_google_signin_btn_text_dark

static int
common_google_signin_btn_text_dark_default

static int
common_google_signin_btn_text_dark_disabled

static int
common_google_signin_btn_text_dark_focused

static int
common_google_signin_btn_text_dark_pressed

static int
common_google_signin_btn_text_light

static int
common_google_signin_btn_text_light_default

static int
common_google_signin_btn_text_light_disabled

static int
common_google_signin_btn_text_light_focused

static int
common_google_signin_btn_text_light_pressed

static int
common_plus_signin_btn_text_dark

static int
common_plus_signin_btn_text_dark_default

static int
common_plus_signin_btn_text_dark_disabled

static int
common_plus_signin_btn_text_dark_focused

static int
common_plus_signin_btn_text_dark_pressed

static int
common_plus_signin_btn_text_light

static int
common_plus_signin_btn_text_light_default

static int
common_plus_signin_btn_text_light_disabled

static int
common_plus_signin_btn_text_light_focused

static int
common_plus_signin_btn_text_light_pressed

static int
design_bottom_navigation_shadow_color

static int
design_error

static int
design_fab_shadow_end_color

static int
design_fab_shadow_mid_color

static int
design_fab_shadow_start_color

static int
design_fab_stroke_end_inner_color

static int
design_fab_stroke_end_outer_color

static int
design_fab_stroke_top_inner_color

static int
design_fab_stroke_top_outer_color

static int
design_snackbar_background_color

static int
design_textinput_error_color_dark

static int
design_textinput_error_color_light

static int
design_tint_password_toggle

static int
dim_foreground_disabled_material_dark

static int
dim_foreground_disabled_material_light

static int
dim_foreground_material_dark

static int
dim_foreground_material_light

static int
foreground_material_dark

static int
foreground_material_light

static int
highlighted_text_material_dark

static int
highlighted_text_material_light

static int
material_blue_grey_800

static int
material_blue_grey_900

static int
material_blue_grey_950

static int
material_deep_teal_200

static int
material_deep_teal_500

static int
material_grey_100

static int
material_grey_300

static int
material_grey_50

static int
material_grey_600

static int
material_grey_800

static int
material_grey_850

static int
material_grey_900

static int
notification_action_color_filter

static int
notification_icon_bg_color

static int
notification_material_background_media_default_color

static int
primary_dark_material_dark

static int
primary_dark_material_light

static int
primary_material_dark

static int
primary_material_light

static int
primary_text_default_material_dark

static int
primary_text_default_material_light

static int
primary_text_disabled_material_dark

static int
primary_text_disabled_material_light

static int
ripple_material_dark

static int
ripple_material_light

static int
secondary_text_default_material_dark

static int
secondary_text_default_material_light

static int
secondary_text_disabled_material_dark

static int
secondary_text_disabled_material_light

static int
switch_thumb_disabled_material_dark

static int
switch_thumb_disabled_material_light

static int
switch_thumb_material_dark

static int
switch_thumb_material_light

static int
switch_thumb_normal_material_dark

static int
switch_thumb_normal_material_light

static int
translucide

Constructor Summary

Constructors

Constructor and Description

color()

Method Summary

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

abc_background_cache_hint_selector_material_dark

public static final int abc_background_cache_hint_selector_material_dark

See Also:

Constant Field Values

abc_background_cache_hint_selector_material_light

public static final int abc_background_cache_hint_selector_material_light

See Also:

Constant Field Values

abc_btn_colored_borderless_text_material

public static final int abc_btn_colored_borderless_text_material

See Also:

Constant Field Values

abc_btn_colored_text_material

public static final int abc_btn_colored_text_material

See Also:

Constant Field Values

abc_color_highlight_material

public static final int abc_color_highlight_material

See Also:

Constant Field Values

abc_hint_foreground_material_dark

public static final int abc_hint_foreground_material_dark

See Also:

Constant Field Values

abc_hint_foreground_material_light

public static final int abc_hint_foreground_material_light

See Also:

Constant Field Values

abc_input_method_navigation_guard

public static final int abc_input_method_navigation_guard

See Also:

Constant Field Values

abc_primary_text_disable_only_material_dark

public static final int abc_primary_text_disable_only_material_dark

See Also:

Constant Field Values

abc_primary_text_disable_only_material_light

public static final int abc_primary_text_disable_only_material_light

See Also:

Constant Field Values

abc_primary_text_material_dark

public static final int abc_primary_text_material_dark

See Also:

Constant Field Values

abc_primary_text_material_light

public static final int abc_primary_text_material_light

See Also:

Constant Field Values

abc_search_url_text

public static final int abc_search_url_text

See Also:

Constant Field Values

abc_search_url_text_normal

public static final int abc_search_url_text_normal

See Also:

Constant Field Values

abc_search_url_text_pressed

public static final int abc_search_url_text_pressed

See Also:

Constant Field Values

abc_search_url_text_selected

public static final int abc_search_url_text_selected

See Also:

Constant Field Values

abc_secondary_text_material_dark

public static final int abc_secondary_text_material_dark

See Also:

Constant Field Values

abc_secondary_text_material_light

public static final int abc_secondary_text_material_light

See Also:

Constant Field Values

abc_tint_btn_checkable

public static final int abc_tint_btn_checkable

See Also:

Constant Field Values

abc_tint_default

public static final int abc_tint_default

See Also:

Constant Field Values

abc_tint_edittext

public static final int abc_tint_edittext

See Also:

Constant Field Values

abc_tint_seek_thumb

public static final int abc_tint_seek_thumb

See Also:

Constant Field Values

abc_tint_spinner

public static final int abc_tint_spinner

See Also:

Constant Field Values

abc_tint_switch_thumb

public static final int abc_tint_switch_thumb

See Also:

Constant Field Values

abc_tint_switch_track

public static final int abc_tint_switch_track

See Also:

Constant Field Values

accent_material_dark

public static final int accent_material_dark

See Also:

Constant Field Values

accent_material_light

public static final int accent_material_light

See Also:

Constant Field Values

background_floating_material_dark

public static final int background_floating_material_dark

See Also:

Constant Field Values

background_floating_material_light

public static final int background_floating_material_light

See Also:

Constant Field Values

background_material_dark

public static final int background_material_dark

See Also:

Constant Field Values

background_material_light

public static final int background_material_light

See Also:

Constant Field Values

bright_foreground_disabled_material_dark

public static final int bright_foreground_disabled_material_dark

See Also:

Constant Field Values

bright_foreground_disabled_material_light

public static final int bright_foreground_disabled_material_light

See Also:

Constant Field Values

bright_foreground_inverse_material_dark

public static final int bright_foreground_inverse_material_dark

See Also:

Constant Field Values

bright_foreground_inverse_material_light

public static final int bright_foreground_inverse_material_light

See Also:

Constant Field Values

bright_foreground_material_dark

public static final int bright_foreground_material_dark

See Also:

Constant Field Values

bright_foreground_material_light

public static final int bright_foreground_material_light

See Also:

Constant Field Values

button_material_dark

public static final int button_material_dark

See Also:

Constant Field Values

button_material_light

public static final int button_material_light

See Also:

Constant Field Values

colorAccent

public static final int colorAccent

See Also:

Constant Field Values

colorPrimary

public static final int colorPrimary

See Also:

Constant Field Values

colorPrimaryDark

public static final int colorPrimaryDark

See Also:

Constant Field Values

common_action_bar_splitter

public static final int common_action_bar_splitter

See Also:

Constant Field Values

common_google_signin_btn_text_dark

public static final int common_google_signin_btn_text_dark

See Also:

Constant Field Values

common_google_signin_btn_text_dark_default

public static final int common_google_signin_btn_text_dark_default

See Also:

Constant Field Values

common_google_signin_btn_text_dark_disabled

public static final int common_google_signin_btn_text_dark_disabled

See Also:

Constant Field Values

common_google_signin_btn_text_dark_focused

public static final int common_google_signin_btn_text_dark_focused

See Also:

Constant Field Values

common_google_signin_btn_text_dark_pressed

public static final int common_google_signin_btn_text_dark_pressed

See Also:

Constant Field Values

common_google_signin_btn_text_light

public static final int common_google_signin_btn_text_light

See Also:

Constant Field Values

common_google_signin_btn_text_light_default

public static final int common_google_signin_btn_text_light_default

See Also:

Constant Field Values

common_google_signin_btn_text_light_disabled

public static final int common_google_signin_btn_text_light_disabled

See Also:

Constant Field Values

common_google_signin_btn_text_light_focused

public static final int common_google_signin_btn_text_light_focused

See Also:

Constant Field Values

common_google_signin_btn_text_light_pressed

public static final int common_google_signin_btn_text_light_pressed

See Also:

Constant Field Values

common_plus_signin_btn_text_dark

public static final int common_plus_signin_btn_text_dark

See Also:

Constant Field Values

common_plus_signin_btn_text_dark_default

public static final int common_plus_signin_btn_text_dark_default

See Also:

Constant Field Values

common_plus_signin_btn_text_dark_disabled

public static final int common_plus_signin_btn_text_dark_disabled

See Also:

Constant Field Values

common_plus_signin_btn_text_dark_focused

public static final int common_plus_signin_btn_text_dark_focused

See Also:

Constant Field Values

common_plus_signin_btn_text_dark_pressed

public static final int common_plus_signin_btn_text_dark_pressed

See Also:

Constant Field Values

common_plus_signin_btn_text_light

public static final int common_plus_signin_btn_text_light

See Also:

Constant Field Values

common_plus_signin_btn_text_light_default

public static final int common_plus_signin_btn_text_light_default

See Also:

Constant Field Values

common_plus_signin_btn_text_light_disabled

public static final int common_plus_signin_btn_text_light_disabled

See Also:

Constant Field Values

common_plus_signin_btn_text_light_focused

public static final int common_plus_signin_btn_text_light_focused

See Also:

Constant Field Values

common_plus_signin_btn_text_light_pressed

public static final int common_plus_signin_btn_text_light_pressed

See Also:

Constant Field Values

design_bottom_navigation_shadow_color

public static final int design_bottom_navigation_shadow_color

See Also:

Constant Field Values

design_error

public static final int design_error

See Also:

Constant Field Values

design_fab_shadow_end_color

public static final int design_fab_shadow_end_color

See Also:

Constant Field Values

design_fab_shadow_mid_color

public static final int design_fab_shadow_mid_color

See Also:

Constant Field Values

design_fab_shadow_start_color

public static final int design_fab_shadow_start_color

See Also:

Constant Field Values

design_fab_stroke_end_inner_color

public static final int design_fab_stroke_end_inner_color

See Also:

Constant Field Values

design_fab_stroke_end_outer_color

public static final int design_fab_stroke_end_outer_color

See Also:

Constant Field Values

design_fab_stroke_top_inner_color

public static final int design_fab_stroke_top_inner_color

See Also:

Constant Field Values

design_fab_stroke_top_outer_color

public static final int design_fab_stroke_top_outer_color

See Also:

Constant Field Values

design_snackbar_background_color

public static final int design_snackbar_background_color

See Also:

Constant Field Values

design_textinput_error_color_dark

public static final int design_textinput_error_color_dark

See Also:

Constant Field Values

design_textinput_error_color_light

public static final int design_textinput_error_color_light

See Also:

Constant Field Values

design_tint_password_toggle

public static final int design_tint_password_toggle

See Also:

Constant Field Values

dim_foreground_disabled_material_dark

public static final int dim_foreground_disabled_material_dark

See Also:

Constant Field Values

dim_foreground_disabled_material_light

public static final int dim_foreground_disabled_material_light

See Also:

Constant Field Values

dim_foreground_material_dark

public static final int dim_foreground_material_dark

See Also:

Constant Field Values

dim_foreground_material_light

public static final int dim_foreground_material_light

See Also:

Constant Field Values

foreground_material_dark

public static final int foreground_material_dark

See Also:

Constant Field Values

foreground_material_light

public static final int foreground_material_light

See Also:

Constant Field Values

highlighted_text_material_dark

public static final int highlighted_text_material_dark

See Also:

Constant Field Values

highlighted_text_material_light

public static final int highlighted_text_material_light

See Also:

Constant Field Values

material_blue_grey_800

public static final int material_blue_grey_800

See Also:

Constant Field Values

material_blue_grey_900

public static final int material_blue_grey_900

See Also:

Constant Field Values

material_blue_grey_950

public static final int material_blue_grey_950

See Also:

Constant Field Values

material_deep_teal_200

public static final int material_deep_teal_200

See Also:

Constant Field Values

material_deep_teal_500

public static final int material_deep_teal_500

See Also:

Constant Field Values

material_grey_100

public static final int material_grey_100

See Also:

Constant Field Values

material_grey_300

public static final int material_grey_300

See Also:

Constant Field Values

material_grey_50

public static final int material_grey_50

See Also:

Constant Field Values

material_grey_600

public static final int material_grey_600

See Also:

Constant Field Values

material_grey_800

public static final int material_grey_800

See Also:

Constant Field Values

material_grey_850

public static final int material_grey_850

See Also:

Constant Field Values

material_grey_900

public static final int material_grey_900

See Also:

Constant Field Values

notification_action_color_filter

public static final int notification_action_color_filter

See Also:

Constant Field Values

notification_icon_bg_color

public static final int notification_icon_bg_color

See Also:

Constant Field Values

notification_material_background_media_default_color

public static final int notification_material_background_media_default_color

See Also:

Constant Field Values

primary_dark_material_dark

public static final int primary_dark_material_dark

See Also:

Constant Field Values

primary_dark_material_light

public static final int primary_dark_material_light

See Also:

Constant Field Values

primary_material_dark

public static final int primary_material_dark

See Also:

Constant Field Values

primary_material_light

public static final int primary_material_light

See Also:

Constant Field Values

primary_text_default_material_dark

public static final int primary_text_default_material_dark

See Also:

Constant Field Values

primary_text_default_material_light

public static final int primary_text_default_material_light

See Also:

Constant Field Values

primary_text_disabled_material_dark

public static final int primary_text_disabled_material_dark

See Also:

Constant Field Values

primary_text_disabled_material_light

public static final int primary_text_disabled_material_light

See Also:

Constant Field Values

ripple_material_dark

public static final int ripple_material_dark

See Also:

Constant Field Values

ripple_material_light

public static final int ripple_material_light

See Also:

Constant Field Values

secondary_text_default_material_dark

public static final int secondary_text_default_material_dark

See Also:

Constant Field Values

secondary_text_default_material_light

public static final int secondary_text_default_material_light

See Also:

Constant Field Values

secondary_text_disabled_material_dark

public static final int secondary_text_disabled_material_dark

See Also:

Constant Field Values

secondary_text_disabled_material_light

public static final int secondary_text_disabled_material_light

See Also:

Constant Field Values

switch_thumb_disabled_material_dark

public static final int switch_thumb_disabled_material_dark

See Also:

Constant Field Values

switch_thumb_disabled_material_light

public static final int switch_thumb_disabled_material_light

See Also:

Constant Field Values

switch_thumb_material_dark

public static final int switch_thumb_material_dark

See Also:

Constant Field Values

switch_thumb_material_light

public static final int switch_thumb_material_light

See Also:

Constant Field Values

switch_thumb_normal_material_dark

public static final int switch_thumb_normal_material_dark

See Also:

Constant Field Values

switch_thumb_normal_material_light

public static final int switch_thumb_normal_material_light

See Also:

Constant Field Values

translucide

public static final int translucide

See Also:

Constant Field Values

Constructor Detail

color

public color()

Skip navigation links

Overview

Package

Class

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method


text:
package models.quiz

import models.SkillId

case class Skill(id: SkillId, name: String, short_name: String, intercept: Double, correct: Double, incorrect: Double) {
  def β = intercept
  def γ = correct
  def ρ = incorrect
}


text:
'use strict';
const chai = require('chai');
const sinon = require('sinon');
const sinonTest = require('sinon-test');
var test = sinonTest(sinon);
const expect = require('chai').expect;
let request = require('superagent');

let BlockCypher = require('../../lib/bcypher');
let chain = 'btc';
let network = 'main';
let token = process.env.TOKEN;
let bcapi = new BlockCypher(chain, network, token);

describe('Blockcypher getBlock Method: ', function () {

  describe('Success: ', function () {

    it('When block hash/heightis a string and params exists', test(function (done) {

      let hh = '12345';
      let params = {};

      let validReturn = { data: { key1: 'value', key2: 2 } };
      this.stub(bcapi, '_get').yields(null, validReturn);
      bcapi.getBlock(hh, params, function (e, r) {

        var callArgs = bcapi._get.getCall(0).args;
        expect(callArgs[0]).to.equal('/blocks/' + hh);
        expect(callArgs[1]).to.deep.equal(params);
        expect(typeof callArgs[2]).to.equal('function');
        expect(Object.keys(callArgs).length).to.equal(3);

        expect(e).to.equal(null);
        expect(r).to.deep.equal(validReturn);
        done();
      });
    }));

    it('When block hash/height is an int and params exists', test(function (done) {

      let hh = 12345;
      let params = {};

      let validReturn = { data: { key1: 'value', key2: 2 } };
      this.stub(bcapi, '_get').yields(null, validReturn);
      bcapi.getBlock(hh, params, function (e, r) {

        var callArgs = bcapi._get.getCall(0).args;
        expect(callArgs[0]).to.equal('/blocks/' + hh);
        expect(callArgs[1]).to.deep.equal(params);
        expect(typeof callArgs[2]).to.equal('function');
        expect(Object.keys(callArgs).length).to.equal(3);

        expect(e).to.equal(null);
        expect(r).to.deep.equal(validReturn);
        done();
      });
    }));

    it('When block hash/heightis is a string and params does NOT exist', test(function (done) {

      let hh = '12345';
      let params = {};

      let validReturn = { data: { key1: 'value', key2: 2 } };
      this.stub(bcapi, '_get').yields(null, validReturn);
      bcapi.getBlock(hh, function (e, r) {

        var callArgs = bcapi._get.getCall(0).args;
        expect(callArgs[0]).to.equal('/blocks/' + hh);
        expect(callArgs[1]).to.deep.equal(params);
        expect(typeof callArgs[2]).to.equal('function');
        expect(Object.keys(callArgs).length).to.equal(3);

        expect(e).to.equal(null);
        expect(r).to.deep.equal(validReturn);
        done();
      });
    }));

    it('When block hash/height is an int and params does NOT exist', test(function (done) {

      let hh = 12345;
      let params = {};

      let validReturn = { data: { key1: 'value', key2: 2 } };
      this.stub(bcapi, '_get').yields(null, validReturn);
      bcapi.getBlock(hh, function (e, r) {

        var callArgs = bcapi._get.getCall(0).args;
        expect(callArgs[0]).to.equal('/blocks/' + hh);
        expect(callArgs[1]).to.deep.equal(params);
        expect(typeof callArgs[2]).to.equal('function');
        expect(Object.keys(callArgs).length).to.equal(3);

        expect(e).to.equal(null);
        expect(r).to.deep.equal(validReturn);
        done();
      });
    }));

  });//end of success cases;

  describe('Errors: ', function () {

    it('bubbles up error when _get returns error', test(function (done) {

      let hh = '12345';
      let params = {};
      let badRequestError = "Bad Request";

      let validReturn = { data: { key1: 'value', key2: 2 } };
      this.stub(bcapi, '_get').yields(badRequestError, validReturn);
      bcapi.getBlock(hh, params, function (e, r) {

        var callArgs = bcapi._get.getCall(0).args;
        expect(callArgs[0]).to.equal('/blocks/' + hh);
        expect(callArgs[1]).to.deep.equal(params);
        expect(typeof callArgs[2]).to.equal('function');
        expect(Object.keys(callArgs).length).to.equal(3);

        expect(e).to.equal(badRequestError);
        expect(r).to.deep.equal(validReturn);
        done();
      });
    }));

    it.skip('should return error when block hash/height is missing', function (done) { done() });

  });//end of error cases;

});//end of getBlock


text:
<?php

namespace Good\Manners;

interface StorableFactory
{
    public function createStorable($type);
}

?>


text:
@implementation SBBTwitterAccountTableViewCell

@end


text:
'use strict'

const signalling = require('./index')
const argv = require('minimist')(process.argv.slice(2))

let server

signalling.start({
  port: argv.port || argv.p || 9090,
  host: argv.host || argv.h || '0.0.0.0'
}, (err, _server) => {
  if (err) {
    throw err
  }
  server = _server

  console.log('Listening on:', server.info.uri)
})

process.on('SIGINT', () => {
  server.stop(() => {
    console.log('Signalling server stopped')
    process.exit()
  })
})


text:
#define __USE_LARGEFILE64

#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <netdb.h>
#include <poll.h>
#include <pthread.h>
#include <atomic>
#include <vector>
#include <dirent.h>
#include <unordered_set>
#include <string>

using namespace std;

#include "streamserver.h"
#include "parseklib.h"
#include "streamnw.h"

/* An aggregation server */
struct aggregator {
    char  hostname[256];  /* hostname for this aggregator */
    uint32_t port;
    u_int num_epochs;     /* how many epochs it will handle */
    int   s;              /* socket used for communication */
};

/* A dift server */
struct dift {
    char  hostname[256];
    u_int num_epochs;
    int   s;
    vector<char *> ckpts; /* The checkpoints for this aggregator */
};

/* An individual epoch */
struct epoch {
    struct aggregator* pagg;
    struct dift* pdift;
    struct epoch_data data;
};

/* All the configuration data */
struct config {
    vector<dift *> difts;
    vector<aggregator *> aggregators;
    vector<epoch> epochs;
};

// One for each streamserver
struct epoch_ctl {
    u_long start;
    u_long num;
    int    s;
    pid_t wait_pid;
};

bool test_and_set(vector<struct cache_info> &cfiles, struct cache_info &cinfo){
    bool found = false;
    for(struct cache_info c : cfiles) {
	if (c.dev == cinfo.dev && c.ino == cinfo.ino &&
	    c.mtime.tv_sec == cinfo.mtime.tv_sec &&
	    c.mtime.tv_nsec == cinfo.mtime.tv_nsec)
	    found = true;
    }
    if (!found) cfiles.push_back(cinfo);
    return found;
}

int connect_to_server (const char* hostname, int port)
{
    // Connect to streamserver
    struct hostent* hp = gethostbyname (hostname);
    if (hp == NULL) {
	fprintf (stderr, "Invalid host %s, errno=%d\n", hostname, h_errno);
	return -1;
    }

    int s = socket (AF_INET, SOCK_STREAM, 0);
    if (s < 0) {
	fprintf (stderr, "Cannot create socket, errno=%d\n", errno);
	return s;
    }

    struct sockaddr_in addr;
    addr.sin_family = AF_INET;
    addr.sin_port = htons(port);
    memcpy (&addr.sin_addr, hp->h_addr, hp->h_length);

    // Receiver may not be started, so spin until connection is accepted
    long rc = connect (s, (struct sockaddr *) &addr, sizeof(addr));
    if (rc < 0) {
	fprintf (stderr, "Cannot connect to %s:%d, errno=%d\n", hostname, port, errno);
	return rc;
    }
    return s;
}

int fetch_results (char* top_dir, struct epoch_ctl ectl)
{
    char dir[512];

    for (u_long i = 0; i < ectl.num; i++) {
	sprintf (dir, "%s/%lu", top_dir, ectl.start+i);
	long rc = mkdir (dir, 0755);
	if (rc < 0) {
	    fprintf (stderr, "Cannot make dir %s\n", dir);
	    return rc;
	}
	// Fetch 4 files: results, addresses, input and output tokens
	for (int j = 0; j < 4; j++) {
	    if (fetch_file(ectl.s, dir) < 0) return -1;
	}
    }
    return 0;
}

void format ()
{
    fprintf (stderr, "format: streamctl <epoch description file> <host config file> [-w] [-s] [-c] [-lowmem]\n");
    fprintf (stderr, "                  [-filter_inet] [-v dest_dir cmp_dir] [-stats] [-seq/-seqpp]\n");
    exit (0);
}

int main (int argc, char* argv[])
{
    int rc;
    char dirname[80];
    int wait_for_response = 0, validate = 0, get_stats = 0, sync_files = 0, nw_compress = 0, low_memory = 0, filter_inet = 0, stream_ls = 0;
    bool record_trace = false;
    int pid = -1; //used for the out2mergecmp
    char* filter_part = NULL;
    char* filter_output_after = NULL;
    char* dest_dir, *cmp_dir;
    struct vector<struct replay_path> log_files;
    struct vector<struct cache_info> cache_files;

    char ckpts[1024][1024]; //can only support 1024 checkpoints

    u_char agg_type = AGG_TYPE_STREAM;
    struct config conf;
    int parallelize = 1;

    if (argc < 3) {
	format();
    }

    const char* host_suffix;

    const char* epoch_filename = argv[1];
    const char* config_filename = argv[2];

    for (int i = 3; i < argc; i++) {
	if (!strcmp (argv[i], "-w")) {
	    wait_for_response = 1;
	} else if (!strcmp (argv[i], "-s")) {
	    sync_files = 1;
	} else if (!strcmp (argv[i], "-c")) {
	    nw_compress = 1;
	} else if (!strcmp (argv[i], "-p")) {
	    pid = atoi(argv[i+1]);
	    i++;
	} else if (!strcmp (argv[i], "-lowmem")) {
	    low_memory = 1;
	} else if (!strcmp (argv[i], "-streamls")) {
	    stream_ls = 1;
	} else if (!strcmp (argv[i], "-filter_inet")) {
	    filter_inet = 1;
	} else if (!strcmp (argv[i], "-filter_part")) {
	    filter_part = argv[i+1];
	    i++;
	} else if (!strcmp (argv[i], "-filter_output_after")) {
	    filter_output_after = argv[i+1];
	    i++;
	} else if (!strcmp (argv[i], "-stats")) {
	    get_stats = 1;
	} else if (!strcmp (argv[i], "-hs")) {
	  host_suffix = argv[i+1];
	  i++;
	} else if (!strcmp (argv[i], "-record_trace")) {
	    record_trace = true;
	} else if (!strcmp (argv[i], "-v")) {
	    i++;
	    if (i < argc) {
		dest_dir = argv[i];
		i++;
		if (i < argc) {
		    cmp_dir = argv[i];
		    validate = 1;
		} else {
		    format();
		}
	    } else {
		format();
	    }
	} else if (!strcmp (argv[i], "-seq")) {
	    agg_type = AGG_TYPE_SEQ;
	} else if (!strcmp (argv[i], "-seqppl")) {
	    agg_type = AGG_TYPE_SEQ_PPL;
	} else if (!strcmp (argv[i], "-seqppg")) {
	    agg_type = AGG_TYPE_SEQ_PPG;
	} else {
	    format();
}
    }

    if (validate) {
	// Create directory for results files
	rc = mkdir (dest_dir, 0755);
	if (rc < 0) {
	    fprintf (stderr, "Cannot make dir %s\n", dest_dir);
	    return rc;
	}
    }

    // Read in the epoch file
    FILE* file = fopen(epoch_filename, "r");
    if (file == NULL) {
	fprintf (stderr, "Unable to open epoch description file %s, errno=%d\n", epoch_filename, errno);
	return -1;
    }
    rc = fscanf (file, "%79s\n", dirname);
    if (rc != 1) {
	fprintf (stderr, "Unable to parse header line of epoch descrtion file, rc=%d\n", rc);
	return -1;
    }
    int next_ckpt = 0;
    while (!feof(file)) {
	char line[256];
	if (fgets (line, 255, file)) {
	    struct epoch e;
	    u_int unused;
	    rc = sscanf (line, "%d %c %u %c %u %u %u %u\n", &e.data.start_pid, &e.data.start_level, &e.data.start_clock, &e.data.stop_level, &e.data.stop_clock, &unused, &e.data.ckpt, &e.data.fork_flags);
	    if (rc != 8) {
		fprintf (stderr, "Unable to parse line of epoch descrtion file: %s\n", line);
		return -1;
	    }
	    conf.epochs.push_back(e);

	    sprintf(ckpts[next_ckpt],"%s/ckpt.%d",dirname,e.data.ckpt);
	    next_ckpt++;

	}
    }
    fclose(file);

    for (int i = 0; i < next_ckpt; i++) {
      fprintf(stderr, "next ckpt: %s\n",ckpts[i]);
    }

    // Read in the host configuration file
    file = fopen(config_filename, "r");
    if (file == NULL) {
	fprintf (stderr, "Unable to open host configuration file %s, errno=%d\n", epoch_filename, errno);
	return -1;
    }

    // Now parse the configuration file
    // Stop if # of epochs is exceeded (config is generic so may work for more epochs)
    struct dift* prev_dift = NULL;
    struct aggregator* prev_agg = NULL;
    u_int epoch_cnt = 0;
    next_ckpt = 0;
    while (!feof(file) && epoch_cnt < conf.epochs.size()) {
	char line[256];
	if (fgets (line, 255, file)) {
	    int num_epochs;
	    char dift_host[256];
	    char agg_host[256];
	    rc = sscanf (line, "%d %s %s\n", &num_epochs, dift_host, agg_host);
	    if (rc != 3) {
		fprintf (stderr, "Unable to parse line of server config file: %s\n", line);
		return -1;
	    }
	    if (epoch_cnt + num_epochs > conf.epochs.size()) {
		// Will not use all the epochs in this row
		num_epochs -= (epoch_cnt + num_epochs) - conf.epochs.size();
		printf ("Truncated num_epochs to %d\n", num_epochs);
	    }
	    struct dift* d;
	    if (!prev_dift || strcmp(dift_host, prev_dift->hostname)) {
		d = new dift;
		strcpy (d->hostname, dift_host);
		d->num_epochs = num_epochs;
		d->s = -1;
		conf.difts.push_back(d);
		prev_dift = d;

		for (int i = 0; i < num_epochs; i++) {
		    d->ckpts.push_back(ckpts[next_ckpt]);
		    next_ckpt++;
		}

	    } else {
		d = prev_dift;
		d->num_epochs += num_epochs;

		for (int i = 0; i < num_epochs; i++) {
		    d->ckpts.push_back(ckpts[next_ckpt]);
		    next_ckpt++;
		}

	    }

	    struct aggregator* a;
	    if (!prev_agg || strcmp(agg_host, prev_agg->hostname)) {
		a = new aggregator;
		strcpy (a->hostname, agg_host);
		a->num_epochs = num_epochs;
		a->port = STREAMSERVER_PORT; //needs to be changed
		a->s = -1;
		conf.aggregators.push_back(a);
		prev_agg = a;
	    } else {
		a = prev_agg;
		a->num_epochs += num_epochs;
	    }

	    for (auto i = 0; i < num_epochs; i++) {
		conf.epochs[epoch_cnt].pdift = d;
		conf.epochs[epoch_cnt].pagg = a;
		epoch_cnt++;
	    }
	}
    }
    fclose(file);

    for (u_int i = 0; i < conf.difts.size(); i++) {
	fprintf(stderr, "machine %s ckpts: ",conf.difts[i]->hostname);
	for (auto c : conf.difts[i]->ckpts) {
	    fprintf(stderr, "%s ",c);
	}
	fprintf(stderr, "\n");
    }

    if (sync_files) {
	// First build up a list of files that are needed for this replay
	struct dirent* de;
	DIR* dir = opendir(dirname);
	if (dir == NULL) {
	    fprintf (stderr, "Cannot open replay dir %s\n", dirname);
	    return -1;
	}
	//unordered set of already seen cache files (optimizatino for nginx, which stinks because there are like, 100k files)

	while ((de = readdir(dir)) != NULL) {
	    if (!strncmp(de->d_name, "ckpt",4) || !strcmp(de->d_name, "mlog") || !strncmp(de->d_name, "ulog", 4)) {
		struct replay_path pathname;
		sprintf (pathname.path, "%s/%s", dirname, de->d_name);
		log_files.push_back(pathname);
	    } else if (!strncmp(de->d_name, "klog", 4)) {
		struct klogfile *log;
		struct klog_result *res;
		struct replay_path pathname;
		struct cache_info cinfo;

		sprintf (pathname.path, "%s/%s", dirname, de->d_name);
		log_files.push_back(pathname);
		// Parse to look for more cache files
		log = parseklog_open(pathname.path);
		if (!log) {
		    fprintf(stderr, "%s doesn't appear to be a valid klog file!\n", pathname.path);
		    return -1;
		}
		while ((res = parseklog_get_next_psr(log)) != NULL) {
		    if (res->psr.sysnum == 5) {
			struct open_retvals* pretvals = (struct open_retvals *) res->retparams;
			if (pretvals) {
			    cinfo.dev = pretvals->dev;
			    cinfo.ino = pretvals->ino;
			    cinfo.mtime = pretvals->mtime;
			    test_and_set(cache_files, cinfo);
#if 0
			    printf ("open cache file dev %x ino %x mtime %lx.%lx log %s\n",
				    cinfo.dev, cinfo.ino, cinfo.mtime.tv_sec, cinfo.mtime.tv_nsec, de->d_name);
#endif
			}
		    } else if (res->psr.sysnum == 11) {
			struct execve_retvals* pretvals = (struct execve_retvals *) res->retparams;
			if (pretvals && !pretvals->is_new_group) {
			    cinfo.dev = pretvals->data.same_group.dev;
			    cinfo.ino = pretvals->data.same_group.ino;
			    cinfo.mtime = pretvals->data.same_group.mtime;
			    test_and_set(cache_files, cinfo);
#if 0
			    printf ("exec cache file dev %x ino %x mtime %lx.%lx log %s\n",
				    cinfo.dev, cinfo.ino, cinfo.mtime.tv_sec, cinfo.mtime.tv_nsec, de->d_name);
#endif
			}
		    } else if (res->psr.sysnum == 86 || res->psr.sysnum == 192) {
			struct mmap_pgoff_retvals* pretvals = (struct mmap_pgoff_retvals *) res->retparams;
			if (pretvals) {
			    cinfo.dev = pretvals->dev;
			    cinfo.ino = pretvals->ino;
			    cinfo.mtime = pretvals->mtime;
			    test_and_set(cache_files, cinfo);
#if 0
			    printf ("mmap cache file dev %x ino %x mtime %lx.%lx log %s\n",
				    cinfo.dev, cinfo.ino, cinfo.mtime.tv_sec, cinfo.mtime.tv_nsec, de->d_name);
#endif
			}
		    }
		}
		parseklog_close(log);
	    }
	}
	closedir(dir);
    }
    fprintf(stderr, "found that we need %d files\n", cache_files.size());

    // Set up the aggregators first
    for (u_int i = 0; i < conf.aggregators.size(); i++) {
	struct epoch_hdr ehdr;
	ehdr.flags = 0;
	if (wait_for_response) ehdr.flags |= SEND_ACK;
	if (validate) ehdr.flags |= SEND_RESULTS;
	if (get_stats) ehdr.flags |= SEND_STATS;
	if (nw_compress) ehdr.flags |= NW_COMPRESS;
	if (low_memory) ehdr.flags |= LOW_MEMORY;
	if (stream_ls) ehdr.flags |= STREAM_LS;

	ehdr.filter_flags = 0;
	if (filter_inet) ehdr.filter_flags |= FILTER_INET;
	if (filter_part) {
	    ehdr.filter_flags |= FILTER_PART;
	    strcpy (ehdr.filter_part, filter_part);
	}
	if (filter_output_after) {
	    ehdr.filter_flags |= FILTER_OUT;
	    strcpy (ehdr.filter_output_after, filter_output_after);
	}

	strcpy (ehdr.dirname, dirname);
	ehdr.epochs = conf.aggregators[i]->num_epochs;
	if (i == 0) {
	    ehdr.start_flag = true;
	} else {
	    ehdr.start_flag = false;
	    strcpy (ehdr.prev_host, conf.aggregators[i-1]->hostname);
	}
	if (i == conf.aggregators.size()-1) {
	    ehdr.finish_flag = true;
	} else {
	    ehdr.finish_flag = false;
	    strcpy (ehdr.next_host, conf.aggregators[i+1]->hostname);
	}
	ehdr.cmd_type = agg_type;
	ehdr.parallelize = conf.aggregators[i]->num_epochs;
	if (ehdr.parallelize > parallelize) parallelize = ehdr.parallelize;

	char real_host[1024];
	if (host_suffix && strstr(conf.aggregators[i]->hostname, ".net") == NULL)
	  sprintf(real_host,"%s%s",conf.aggregators[i]->hostname,host_suffix);
	else
	  sprintf(real_host,"%s",conf.aggregators[i]->hostname);

	    conf.aggregators[i]->s = connect_to_server (real_host, conf.aggregators[i]->port);
	if (conf.aggregators[i]->s < 0) return conf.aggregators[i]->s;

	rc = safe_write (conf.aggregators[i]->s, &ehdr, sizeof(ehdr));
	if (rc != sizeof(ehdr)) {
	    fprintf (stderr, "Cannot send header to streamserver, rc=%d\n", rc);
	    return rc;
	}
    }

    // Now contact the individual DIFT servers and send them the epoch data
    // Assumption is that the epochs handled by a server are contiguous
    epoch_cnt = 0;
    u_int agg_cnt = 0;
    u_int cur_agg_epochs = 0;
    for (u_int i = 0; i < conf.difts.size(); i++) {
	char real_host[1024];
	if (host_suffix && strstr(conf.difts[i]->hostname, ".net") == NULL)
	  sprintf(real_host,"%s%s",conf.difts[i]->hostname,host_suffix);
	else
	  sprintf(real_host,"%s",conf.difts[i]->hostname);

	conf.difts[i]->s = connect_to_server (real_host, STREAMSERVER_PORT);
	if (conf.difts[i]->s < 0) return conf.difts[i]->s;

	struct epoch_hdr ehdr;
	ehdr.cmd_type = DO_DIFT;
	ehdr.flags = 0;
	if (sync_files) ehdr.flags |= SYNC_LOGFILES;
	if (get_stats) ehdr.flags |= SEND_STATS;
	ehdr.record_trace = record_trace;
	strcpy (ehdr.dirname, dirname);
	ehdr.epochs = conf.difts[i]->num_epochs;
	if (i == 0) {
	    ehdr.start_flag = true;
	} else {
	    ehdr.start_flag = false;
	    strcpy (ehdr.prev_host, conf.difts[i-1]->hostname);
	}
	if (i == conf.difts.size()-1) {
	    ehdr.finish_flag = true;
	} else {
	    ehdr.finish_flag = false;
	    strcpy (ehdr.next_host, conf.difts[i+1]->hostname);
	}

	rc = safe_write (conf.difts[i]->s, &ehdr, sizeof(ehdr));
	if (rc != sizeof(ehdr)) {
	    fprintf (stderr, "Cannot send header to streamserver, rc=%d\n", rc);
	    return rc;
	}

	for (u_int j = 0; j < conf.difts[i]->num_epochs; j++) {
	    strcpy (conf.epochs[epoch_cnt].data.hostname, conf.aggregators[agg_cnt]->hostname);
	    conf.epochs[epoch_cnt].data.port = AGG_BASE_PORT+cur_agg_epochs;
	    rc = safe_write (conf.difts[i]->s, &conf.epochs[epoch_cnt].data, sizeof(struct epoch_data));
	    if (rc != sizeof(struct epoch_data)) {
		fprintf (stderr, "Cannot send epoch data to streamserver, rc=%d\n", rc);
		return rc;
	    }
	    cur_agg_epochs++;
	    epoch_cnt++;
	    if (cur_agg_epochs == conf.aggregators[agg_cnt]->num_epochs) {
		// Move to next aggregator
		agg_cnt++;
		cur_agg_epochs = 0;
	    }
	}

	if (sync_files) {

	    //need to figure out what to do at this point:
	    struct vector<struct replay_path> elog_files;
	    for (auto l : log_files) {

		if (strstr(l.path, "ckpt.")) {
		    bool found = false;
		    for (auto c : conf.difts[i]->ckpts) {
			if (!strcmp(l.path,c)){
			    found = true;
			    break;
			}
		    }
		    if (found) {
			elog_files.push_back(l);
			fprintf(stderr, "sending %s\n",l.path);
		    }
		}
		else {
		    elog_files.push_back(l);
		}
	    }
	    fprintf(stderr, "sending %u instead of %u logfiles to %s",elog_files.size(), log_files.size(),conf.difts[i]->hostname);

	    // First send count of log files
	    uint32_t cnt = elog_files.size();
	    rc = safe_write (conf.difts[i]->s, &cnt, sizeof(cnt));
	    if (rc != sizeof(cnt)) {
		fprintf (stderr, "Cannot send log file count to streamserver, rc=%d\n", rc);
		return rc;
	    }

	    // Next send log files
	    for (auto iter = elog_files.begin(); iter != elog_files.end(); iter++) {
		struct replay_path p = *iter;
		rc = safe_write (conf.difts[i]->s, &p, sizeof(struct replay_path));
		if (rc != sizeof(struct replay_path)) {
		    fprintf (stderr, "Cannot send log file to streamserver, rc=%d\n", rc);
		    return rc;
		}
	    }

	    // Next send count of cache files
	    cnt = cache_files.size();
	    rc = safe_write (conf.difts[i]->s, &cnt, sizeof(cnt));
	    if (rc != sizeof(cnt)) {
		fprintf (stderr, "Cannot send cache file count to streamserver, rc=%d\n", rc);
		return rc;
	    }
	    fprintf(stderr, "we have %u cache files to send to %s\n", cnt, conf.difts[i]->hostname);

	    // And finally the cache files
	    for (auto iter = cache_files.begin(); iter != cache_files.end(); iter++) {
		struct cache_info c = *iter;
		rc = safe_write (conf.difts[i]->s, &c, sizeof(struct cache_info));
		if (rc != sizeof(struct cache_info)) {
		    fprintf (stderr, "Cannot send cache file to streamserver, rc=%d\n", rc);
		    return rc;
		}
	    }

	    // Get back response
	    bool response[elog_files.size()+cache_files.size()];
	    rc = safe_read (conf.difts[i]->s, response, sizeof(bool)*(elog_files.size()+cache_files.size()));
	    if (rc != (long) (sizeof(bool)*(elog_files.size()+cache_files.size()))) {
		fprintf (stderr, "Cannot read sync results, rc=%d\n", rc);
		return rc;
	    }

	    // Send requested files
	    u_long l, j;
	    for (l = 0; l < elog_files.size(); l++) {
		if (response[l]) {
		    fprintf (stderr,"%ld of %d log files requested\n", l, elog_files.size());
		    char* filename = NULL;
		    for (int j = strlen(elog_files[l].path); j >= 0; j--) {
			if (elog_files[l].path[j] == '/') {
			    filename = &elog_files[l].path[j+1];
			    break;
			}
		    }
		    if (filename == NULL) {
			fprintf (stderr, "Bad path name: %s\n", elog_files[l].path);
			return -1;
		    }
		    rc = send_file (conf.difts[i]->s, elog_files[l].path, filename);
		    if (rc < 0) {
			fprintf (stderr, "Unable to send log file %s\n", elog_files[l].path);
			return rc;
		    }
		}
	    }
	    for (j = 0; j < cache_files.size(); j++) {
		if (response[l+j]) {
		    char cname[PATHLEN];
		    struct stat64 st;

		    // Find the cache file locally
		    sprintf (cname, "/replay_cache/%x_%x", cache_files[j].dev, cache_files[j].ino);
		    rc = stat64 (cname, &st);
		    if (rc < 0) {
			fprintf (stderr, "cannot stat cache file %s, rc=%d\n", cname, rc);
			return rc;
		    }

		    if (st.st_mtim.tv_sec != cache_files[j].mtime.tv_sec || st.st_mtim.tv_nsec != cache_files[j].mtime.tv_nsec) {
			// if times do not match, open a past version
			sprintf (cname, "/replay_cache/%x_%x_%lu_%lu", cache_files[j].dev, cache_files[j].ino,
				 cache_files[j].mtime.tv_sec, cache_files[j].mtime.tv_nsec);
		    }

		    // Send the file to streamserver
		    rc = send_file (conf.difts[i]->s, cname, "rename_me");
		}
	    }
	}
    }
    if (wait_for_response) {
	for (u_int i = 0; i < conf.aggregators.size(); i++) {
	    struct epoch_ack ack;
	    rc = safe_read (conf.aggregators[i]->s, &ack, sizeof(ack));
	    if (rc != sizeof(ack)) {
		fprintf (stderr, "Cannot recv ack,rc=%d,errno=%d\n", rc, errno);
	    }
	}
    }

    if (validate) {
	// Fetch the files into each directory
	char rdir[512];
	for (u_long i = 0; i < conf.epochs.size(); i++) {
	    sprintf (rdir, "%s/%lu", dest_dir, i);
	    long rc = mkdir (rdir, 0755);
	    if (rc < 0) {
		fprintf (stderr, "Cannot make dir %s\n", rdir);
		return rc;
	    }

	    // Fetch n+3 files: results, addresses, input and output tokens
	    for (int j = 0; j < parallelize+3; j++) {
		if (fetch_file(conf.epochs[i].pagg->s, rdir) < 0) return -1;
	    }
	}

	// Now actually do the comaprison
	char cmd[512];
	if (pid < 0)
	    sprintf (cmd, "../dift/proc64/out2mergecmp %d %s -d %s", parallelize, cmp_dir, dest_dir);
	else
	    sprintf (cmd, "../dift/proc64/out2mergecmp %d %s -p %d -d %s", parallelize, cmp_dir, pid, dest_dir);

	for (u_long i = 0; i < conf.epochs.size(); i++) {
	    char add[64];
	    sprintf (add, " %lu", i);
	    strcat (cmd, add);
	}
	system (cmd);
    }

    if (get_stats) {
	// Fetch the stats files into the tmp directory
	for (u_long i = 0; i < conf.epochs.size(); i++) {
	    char statfile[256];
	    sprintf (statfile, "/tmp/stream-stats-%lu", i);
	    if (fetch_file(conf.epochs[i].pagg->s, "/tmp") < 0) return -1;
	    rc = rename ("/tmp/stream-stats", statfile);
	    if (rc < 0) printf ("Unable to rename aggregator stats file, rc=%d, errno=%d\n", rc, errno);

	    sprintf (statfile, "/tmp/taint-stats-%lu", i);
	    if (fetch_file(conf.epochs[i].pdift->s, "/tmp") < 0) return -1;
	    rc = rename ("/tmp/taint-stats", statfile);
	    if (rc < 0) printf ("Unable to rename dift stats file, rc=%d, errno=%d\n", rc, errno);
	}
    }

    if (record_trace) {
	// Fetch trace files into the tmp directory
	for (u_long i = 0; i < conf.epochs.size(); i++) {
	    char statfile[256];
	    sprintf (statfile, "/tmp/trace-exec-%lu", i);
	    if (fetch_file(conf.epochs[i].pdift->s, "/tmp") < 0) return -1;
	    rc = rename ("/tmp/trace_exec", statfile);
	    if (rc < 0) printf ("Unable to rename trace execution file, rc=%d, errno=%d\n", rc, errno);

	    sprintf (statfile, "/tmp/trace-inst-%lu", i);
	    if (fetch_file(conf.epochs[i].pdift->s, "/tmp") < 0) return -1;
	    rc = rename ("/tmp/trace_inst", statfile);
	    if (rc < 0) printf ("Unable to rename trace instruction count file, rc=%d, errno=%d\n", rc, errno);
	}
    }

    return 0;
}


text:
// SPDX-License-Identifier: MIT
// Copyright (C) 2018-present iced project and contributors

#if ENCODER && BLOCK_ENCODER
using System;
using Iced.Intel;
using Xunit;

namespace Iced.UnitTests.Intel.EncoderTests {
	public sealed class BlockEncoderTest_Misc {
		[Fact]
		void Encode_zero_blocks() {
			bool b;
			string errorMessage;
			BlockEncoderResult[] result;

			b = BlockEncoder.TryEncode(16, new InstructionBlock[0], out errorMessage, out result, BlockEncoderOptions.None);
			Assert.True(b);
			Assert.Null(errorMessage);
			Assert.NotNull(result);
			Assert.True(result.Length == 0);

			b = BlockEncoder.TryEncode(32, new InstructionBlock[0], out errorMessage, out result, BlockEncoderOptions.None);
			Assert.True(b);
			Assert.Null(errorMessage);
			Assert.NotNull(result);
			Assert.True(result.Length == 0);

			b = BlockEncoder.TryEncode(64, new InstructionBlock[0], out errorMessage, out result, BlockEncoderOptions.None);
			Assert.True(b);
			Assert.Null(errorMessage);
			Assert.NotNull(result);
			Assert.True(result.Length == 0);
		}

		[Fact]
		void Encode_zero_instructions() {
			bool b;
			string errorMessage;
			BlockEncoderResult result;
			var codeWriter = new CodeWriterImpl();

			b = BlockEncoder.TryEncode(16, new InstructionBlock(codeWriter, Array.Empty<Instruction>(), 0), out errorMessage, out result, BlockEncoderOptions.None);
			Assert.True(b);
			Assert.Null(errorMessage);
			Assert.Empty(codeWriter.ToArray());
			Assert.Equal(0UL, result.RIP);
			Assert.Null(result.RelocInfos);
			Assert.NotNull(result.NewInstructionOffsets);
			Assert.True(result.NewInstructionOffsets.Length == 0);
			Assert.NotNull(result.ConstantOffsets);
			Assert.True(result.ConstantOffsets.Length == 0);

			b = BlockEncoder.TryEncode(32, new InstructionBlock(codeWriter, Array.Empty<Instruction>(), 0), out errorMessage, out result, BlockEncoderOptions.None);
			Assert.True(b);
			Assert.Null(errorMessage);
			Assert.Empty(codeWriter.ToArray());
			Assert.Equal(0UL, result.RIP);
			Assert.Null(result.RelocInfos);
			Assert.NotNull(result.NewInstructionOffsets);
			Assert.True(result.NewInstructionOffsets.Length == 0);
			Assert.NotNull(result.ConstantOffsets);
			Assert.True(result.ConstantOffsets.Length == 0);

			b = BlockEncoder.TryEncode(64, new InstructionBlock(codeWriter, Array.Empty<Instruction>(), 0), out errorMessage, out result, BlockEncoderOptions.None);
			Assert.True(b);
			Assert.Null(errorMessage);
			Assert.Empty(codeWriter.ToArray());
			Assert.Equal(0UL, result.RIP);
			Assert.Null(result.RelocInfos);
			Assert.NotNull(result.NewInstructionOffsets);
			Assert.True(result.NewInstructionOffsets.Length == 0);
			Assert.NotNull(result.ConstantOffsets);
			Assert.True(result.ConstantOffsets.Length == 0);
		}

		[Fact]
		void DefaultArgs() {
			const int bitness = 64;
			const ulong origRip = 0x123456789ABCDE00;
			const ulong newRip = 0x8000000000000000;

			var originalData = new byte[] {
				/*0000*/ 0xB0, 0x00,// mov al,0
				/*0002*/ 0xEB, 0x09,// jmp short 123456789ABCDE0Dh
				/*0004*/ 0xB0, 0x01,// mov al,1
				/*0006*/ 0xE9, 0x03, 0x00, 0x00, 0x00,// jmp near ptr 123456789ABCDE0Eh
				/*000B*/ 0xB0, 0x02,// mov al,2
			};
			var instructions = BlockEncoderTest.Decode(bitness, origRip, originalData, DecoderOptions.None);
			var codeWriter = new CodeWriterImpl();
			bool b = BlockEncoder.TryEncode(bitness, new InstructionBlock(codeWriter, instructions, newRip), out var errorMessage, out var result);
			Assert.True(b);
			Assert.Null(errorMessage);
			Assert.Equal(newRip, result.RIP);
			Assert.Equal(0x28, codeWriter.ToArray().Length);
			Assert.Null(result.RelocInfos);
			Assert.NotNull(result.NewInstructionOffsets);
			Assert.True(result.NewInstructionOffsets.Length == 0);
			Assert.NotNull(result.ConstantOffsets);
			Assert.True(result.ConstantOffsets.Length == 0);
		}

		[Theory]
		[InlineData(BlockEncoderOptions.ReturnRelocInfos)]
		[InlineData(BlockEncoderOptions.ReturnNewInstructionOffsets)]
		[InlineData(BlockEncoderOptions.ReturnConstantOffsets)]
		void VerifyResultArrays(BlockEncoderOptions options) {
			const int bitness = 64;
			const ulong origRip1 = 0x123456789ABCDE00;
			const ulong origRip2 = 0x223456789ABCDE00;
			const ulong newRip1 = 0x8000000000000000;
			const ulong newRip2 = 0x9000000000000000;

			{
				var instructions1 = BlockEncoderTest.Decode(bitness, origRip1, new byte[] { 0xE9, 0x56, 0x78, 0xA5, 0x5A }, DecoderOptions.None);
				var codeWriter1 = new CodeWriterImpl();
				bool b = BlockEncoder.TryEncode(bitness, new InstructionBlock(codeWriter1, instructions1, newRip1), out var errorMessage, out var result, options);
				Assert.True(b);
				Assert.Null(errorMessage);
				Assert.Equal(newRip1, result.RIP);
				if ((options & BlockEncoderOptions.ReturnRelocInfos) != 0) {
					Assert.NotNull(result.RelocInfos);
					Assert.True(result.RelocInfos.Count == 1);
				}
				else
					Assert.Null(result.RelocInfos);
				if ((options & BlockEncoderOptions.ReturnNewInstructionOffsets) != 0) {
					Assert.NotNull(result.NewInstructionOffsets);
					Assert.True(result.NewInstructionOffsets.Length == 1);
				}
				else {
					Assert.NotNull(result.NewInstructionOffsets);
					Assert.True(result.NewInstructionOffsets.Length == 0);
				}
				if ((options & BlockEncoderOptions.ReturnConstantOffsets) != 0) {
					Assert.NotNull(result.ConstantOffsets);
					Assert.True(result.ConstantOffsets.Length == 1);
				}
				else {
					Assert.NotNull(result.ConstantOffsets);
					Assert.True(result.ConstantOffsets.Length == 0);
				}
			}
			{
				var instructions1 = BlockEncoderTest.Decode(bitness, origRip1, new byte[] { 0xE9, 0x56, 0x78, 0xA5, 0x5A }, DecoderOptions.None);
				var instructions2 = BlockEncoderTest.Decode(bitness, origRip2, new byte[] { 0x90, 0xE9, 0x56, 0x78, 0xA5, 0x5A }, DecoderOptions.None);
				var codeWriter1 = new CodeWriterImpl();
				var codeWriter2 = new CodeWriterImpl();
				var block1 = new InstructionBlock(codeWriter1, instructions1, newRip1);
				var block2 = new InstructionBlock(codeWriter2, instructions2, newRip2);
				bool b = BlockEncoder.TryEncode(bitness, new[] { block1, block2 }, out var errorMessage, out var resultArray, options);
				Assert.True(b);
				Assert.Null(errorMessage);
				Assert.NotNull(resultArray);
				Assert.Equal(2, resultArray.Length);
				Assert.Equal(newRip1, resultArray[0].RIP);
				Assert.Equal(newRip2, resultArray[1].RIP);
				if ((options & BlockEncoderOptions.ReturnRelocInfos) != 0) {
					Assert.NotNull(resultArray[0].RelocInfos);
					Assert.NotNull(resultArray[1].RelocInfos);
					Assert.True(resultArray[0].RelocInfos.Count == 1);
					Assert.True(resultArray[1].RelocInfos.Count == 1);
				}
				else {
					Assert.Null(resultArray[0].RelocInfos);
					Assert.Null(resultArray[1].RelocInfos);
				}
				if ((options & BlockEncoderOptions.ReturnNewInstructionOffsets) != 0) {
					Assert.NotNull(resultArray[0].NewInstructionOffsets);
					Assert.NotNull(resultArray[1].NewInstructionOffsets);
					Assert.True(resultArray[0].NewInstructionOffsets.Length == 1);
					Assert.True(resultArray[1].NewInstructionOffsets.Length == 2);
				}
				else {
					Assert.NotNull(resultArray[0].NewInstructionOffsets);
					Assert.True(resultArray[0].NewInstructionOffsets.Length == 0);
					Assert.NotNull(resultArray[1].NewInstructionOffsets);
					Assert.True(resultArray[1].NewInstructionOffsets.Length == 0);
				}
				if ((options & BlockEncoderOptions.ReturnConstantOffsets) != 0) {
					Assert.NotNull(resultArray[0].ConstantOffsets);
					Assert.NotNull(resultArray[1].ConstantOffsets);
					Assert.True(resultArray[0].ConstantOffsets.Length == 1);
					Assert.True(resultArray[1].ConstantOffsets.Length == 2);
				}
				else {
					Assert.NotNull(resultArray[0].ConstantOffsets);
					Assert.True(resultArray[0].ConstantOffsets.Length == 0);
					Assert.NotNull(resultArray[1].ConstantOffsets);
					Assert.True(resultArray[1].ConstantOffsets.Length == 0);
				}
			}
		}

		[Theory]
		[InlineData("5A")]
		[InlineData("F0 D2 7A 18 A0")]
		[InlineData("77 A9 CE 9D 55 05 42 6C 86 32 FE 4F 34 27 AA 08")]
		void EncodeDeclareByte(string hexBytes) {
			const int bitness = 64;
			const ulong newRip = 0x8000000000000000;

			var data = HexUtils.ToByteArray(hexBytes);
			var instructions = new Instruction[] {
				Instruction.Create(Code.Nopd),
				Instruction.CreateDeclareByte(data),
				Instruction.Create(Code.Nopd),
			};

			var expectedData = new byte[data.Length + 2];
			expectedData[0] = 0x90;
			Array.Copy(data, 0, expectedData, 1, data.Length);
			expectedData[expectedData.Length - 1] = 0x90;

			var codeWriter = new CodeWriterImpl();
			bool b = BlockEncoder.TryEncode(bitness, new InstructionBlock(codeWriter, instructions, newRip), out var errorMessage, out var result);
			Assert.True(b);
			Assert.Null(errorMessage);
			Assert.Equal(expectedData, codeWriter.ToArray());
			Assert.Equal(newRip, result.RIP);
			Assert.Null(result.RelocInfos);
			Assert.NotNull(result.NewInstructionOffsets);
			Assert.True(result.NewInstructionOffsets.Length == 0);
			Assert.NotNull(result.ConstantOffsets);
			Assert.True(result.ConstantOffsets.Length == 0);
		}

		[Fact]
		void TryEncode_with_default_InstructionBlock_throws() {
			Assert.Throws<ArgumentException>(() => BlockEncoder.TryEncode(64, default(InstructionBlock), out _, out _));
			Assert.Throws<ArgumentException>(() => BlockEncoder.TryEncode(64, new InstructionBlock[3], out _, out _));
		}

		[Fact]
		void TryEncode_with_null_array_throws() =>
			Assert.Throws<ArgumentNullException>(() => BlockEncoder.TryEncode(64, null, out _, out _));

		[Fact]
		void TryEncode_with_invalid_bitness_throws() {
			foreach (var bitness in BitnessUtils.GetInvalidBitnessValues())
				Assert.Throws<ArgumentOutOfRangeException>(() => BlockEncoder.TryEncode(bitness, new InstructionBlock(new CodeWriterImpl(), new Instruction[1], 0), out _, out _));
			foreach (var bitness in BitnessUtils.GetInvalidBitnessValues())
				Assert.Throws<ArgumentOutOfRangeException>(() => BlockEncoder.TryEncode(bitness, new[] { new InstructionBlock(new CodeWriterImpl(), new Instruction[1], 0) }, out _, out _));
		}

		[Fact]
		void InstructionBlock_throws_if_invalid_input() {
			Assert.Throws<ArgumentNullException>(() => new InstructionBlock(null, Array.Empty<Instruction>(), 0));
			Assert.Throws<ArgumentNullException>(() => new InstructionBlock(new CodeWriterImpl(), null, 0));
		}

		[Fact]
		void EncodeRipRelMemOp() {
			var instr = Instruction.Create(Code.Add_r32_rm32, Register.ECX, new MemoryOperand(Register.RIP, Register.None, 1, 0x1234_5678_9ABC_DEF1, 8, false, Register.None));
			var codeWriter = new CodeWriterImpl();
			bool b = BlockEncoder.TryEncode(64, new InstructionBlock(codeWriter, new[] { instr }, 0x1234_5678_ABCD_EF02), out var errorMessage, out _);
			Assert.True(b, $"Couldn't encode it: {errorMessage}");
			var encoded = codeWriter.ToArray();
			var expected = new byte[] { 0x03, 0x0D, 0xE9, 0xEF, 0xEE, 0xEE };
			Assert.Equal(expected, encoded);
		}
	}
}
#endif


text:
#define TRUE 1
#include "SortedList.h"
#include "string.h"

int SortedList_length(SortedList_t *list) {

        /* list head should not be corrupt */
        if(list->prev != NULL || list->key != NULL)
                return -1;

        int len = 0;
        SortedListElement_t *curr_node = list;
        SortedListElement_t *prev_node;

        /* iterate over all nodes, checking for corruption & incrementing len */
        while(curr_node->next != NULL)
        {
                len++;
                prev_node = curr_node;
                // Call yield in the middle of iterating over the nodes to really screw things
                if(opt_yield & SEARCH_YIELD)
                        pthread_yield();
                curr_node = curr_node->next;

                if(curr_node->prev != prev_node)
                        return -1;

                if(curr_node->key == NULL)
                        return -1;
        }

        return len;
}

void SortedList_insert(SortedList_t *list, SortedListElement_t *element) {

        SortedListElement_t *curr_node  = list;
        SortedListElement_t *prev_node = list;

        if(curr_node->next == NULL)
                goto EOL;
        else
                curr_node = curr_node->next;

        int bias;
        /** Iterate until EOL **/
        do {
                bias = strcmp(element->key, curr_node->key);
                /* curr_node > element, insert element to left of curr_node */
                if(bias < 0)
                {
                        prev_node->next = element;
                        element->prev = prev_node;

                        if(opt_yield & INSERT_YIELD)
                                pthread_yield();

                        element->next = curr_node;
                        curr_node->prev = element;

                        return;
                }

                /* curr_node <= element, iterate to next node or break if EOL */
                else if (curr_node->next != NULL)
                {
                        prev_node = curr_node;
                        curr_node = curr_node->next;
                }
                else
                        goto EOL;
        } while(TRUE);

        /* Control reaches here if we reach EOL w/o inserting the element */
        /* Insert element to EOL and set element->next = NULL */
EOL:
        curr_node->next = element;
        element->prev = curr_node;
        element->next = NULL;
}

/**
 * SortedList_lookup ... search sorted list for a key
 *
 *	The specified list will be searched for an
 *	element with the specified key.
 *
 * @param SortedList_t *list ... header for the list
 * @param const char * key ... the desired key
 *
 * @return pointer to matching element, or NULL if none is found
 *
 * Note: if (opt_yield & SEARCH_YIELD)
 *		call pthread_yield in middle of critical section
 */
SortedListElement_t *SortedList_lookup(SortedList_t *list, const char *key) {

        SortedListElement_t *curr_node = list;

        /* If list is empty, return NULL. Else move to first node */
        if(curr_node->next == NULL)
                goto EOL;
        else
                curr_node = curr_node->next;
        do {
                /* If key matches, return the current node */
                if(strcmp(key, curr_node->key) == 0)
                        return curr_node;

                /* Else move to the next node if possible */
                else if(curr_node->next != NULL) {
                        if(opt_yield & SEARCH_YIELD)
                                pthread_yield();
                        curr_node = curr_node->next;
                }

                /* Not possible to go to next node. Reached EOL, return NULL */
                else
                        goto EOL;
        } while(TRUE);

        /* Reached EOL, key not found. Return NULL */
EOL:
        return NULL;
}

/**
 * SortedList_delete ... remove an element from a sorted list
 *
 *	The specified element will be removed from whatever
 *	list it is currently in.
 *
 *	Before doing the deletion, we check to make sure that
 *	next->prev and prev->next both point to this node
 *
 * @param SortedListElement_t *element ... element to be removed
 *
 * @return 0: element deleted successfully, 1: corrtuped prev/next pointers
 *
 * Note: if (opt_yield & DELETE_YIELD)
 *		call pthread_yield in middle of critical section
 */
int SortedList_delete( SortedListElement_t *element) {

        SortedListElement_t *next_node  = NULL;
        SortedListElement_t *prev_node  = NULL;

        /* Check to see if next_node->prev points to curr_node */
        if(element->next != NULL)
        {
                next_node = element->next;
                if(next_node->prev != element)
                        return 1;
        }

        /* Check to see if prev_node->next points to curr_node */
        if(element->prev != NULL)
        {
                prev_node = element->prev;
                if(prev_node->next != element)
                        return 1;
        }

        /* If we survived till here, it means that prev_node OR next_node
         * OR BOTH nodes are either curr_node or expected nodes. But they are
         * definitely not corrupted. Which means they are safe to unlink if
         * they exist.
         */
        if(prev_node != NULL)
                prev_node->next = next_node;

        if(opt_yield & DELETE_YIELD)
                pthread_yield();

        if(next_node != NULL)
                next_node->prev = prev_node;
        return 0;
}