text:
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/mm.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/pci.h>
#include <linux/poll.h>
#include <linux/highmem.h>
#include <linux/interrupt.h>
#include <linux/pagemap.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/syscalls.h>
#include <linux/mutex.h>
#include <linux/spinlock.h>
#include <linux/slab.h>

#include "vme.h"
#include "vme_bridge.h"

/* Bitmask and mutex to keep track of bridge numbers */
static unsigned int vme_bus_numbers;
static DEFINE_MUTEX(vme_bus_num_mtx);

static void __exit vme_exit(void);
static int __init vme_init(void);

/*
 * Find the bridge resource associated with a specific device resource
 */
static struct vme_bridge *dev_to_bridge(struct device *dev)
{
	return dev->platform_data;
}

/*
 * Find the bridge that the resource is associated with.
 */
static struct vme_bridge *find_bridge(struct vme_resource *resource)
{
	/* Get list to search */
	switch (resource->type) {
	case VME_MASTER:
		return list_entry(resource->entry, struct vme_master_resource,
			list)->parent;
		break;
	case VME_SLAVE:
		return list_entry(resource->entry, struct vme_slave_resource,
			list)->parent;
		break;
	case VME_DMA:
		return list_entry(resource->entry, struct vme_dma_resource,
			list)->parent;
		break;
	case VME_LM:
		return list_entry(resource->entry, struct vme_lm_resource,
			list)->parent;
		break;
	default:
		printk(KERN_ERR "Unknown resource type\n");
		return NULL;
		break;
	}
}

/*
 * Allocate a contiguous block of memory for use by the driver. This is used to
 * create the buffers for the slave windows.
 *
 * XXX VME bridges could be available on buses other than PCI. At the momment
 *     this framework only supports PCI devices.
 */
void *vme_alloc_consistent(struct vme_resource *resource, size_t size,
	dma_addr_t *dma)
{
	struct vme_bridge *bridge;
	struct pci_dev *pdev;

	if (resource == NULL) {
		printk(KERN_ERR "No resource\n");
		return NULL;
	}

	bridge = find_bridge(resource);
	if (bridge == NULL) {
		printk(KERN_ERR "Can't find bridge\n");
		return NULL;
	}

	/* Find pci_dev container of dev */
	if (bridge->parent == NULL) {
		printk(KERN_ERR "Dev entry NULL\n");
		return NULL;
	}
	pdev = container_of(bridge->parent, struct pci_dev, dev);

	return pci_alloc_consistent(pdev, size, dma);
}
EXPORT_SYMBOL(vme_alloc_consistent);

/*
 * Free previously allocated contiguous block of memory.
 *
 * XXX VME bridges could be available on buses other than PCI. At the momment
 *     this framework only supports PCI devices.
 */
void vme_free_consistent(struct vme_resource *resource, size_t size,
	void *vaddr, dma_addr_t dma)
{
	struct vme_bridge *bridge;
	struct pci_dev *pdev;

	if (resource == NULL) {
		printk(KERN_ERR "No resource\n");
		return;
	}

	bridge = find_bridge(resource);
	if (bridge == NULL) {
		printk(KERN_ERR "Can't find bridge\n");
		return;
	}

	/* Find pci_dev container of dev */
	pdev = container_of(bridge->parent, struct pci_dev, dev);

	pci_free_consistent(pdev, size, vaddr, dma);
}
EXPORT_SYMBOL(vme_free_consistent);

size_t vme_get_size(struct vme_resource *resource)
{
	int enabled, retval;
	unsigned long long base, size;
	dma_addr_t buf_base;
	vme_address_t aspace;
	vme_cycle_t cycle;
	vme_width_t dwidth;

	switch (resource->type) {
	case VME_MASTER:
		retval = vme_master_get(resource, &enabled, &base, &size,
			&aspace, &cycle, &dwidth);

		return size;
		break;
	case VME_SLAVE:
		retval = vme_slave_get(resource, &enabled, &base, &size,
			&buf_base, &aspace, &cycle);

		return size;
		break;
	case VME_DMA:
		return 0;
		break;
	default:
		printk(KERN_ERR "Unknown resource type\n");
		return 0;
		break;
	}
}
EXPORT_SYMBOL(vme_get_size);

static int vme_check_window(vme_address_t aspace, unsigned long long vme_base,
	unsigned long long size)
{
	int retval = 0;

	switch (aspace) {
	case VME_A16:
		if (((vme_base + size) > VME_A16_MAX) ||
				(vme_base > VME_A16_MAX))
			retval = -EFAULT;
		break;
	case VME_A24:
		if (((vme_base + size) > VME_A24_MAX) ||
				(vme_base > VME_A24_MAX))
			retval = -EFAULT;
		break;
	case VME_A32:
		if (((vme_base + size) > VME_A32_MAX) ||
				(vme_base > VME_A32_MAX))
			retval = -EFAULT;
		break;
	case VME_A64:
		/*
		 * Any value held in an unsigned long long can be used as the
		 * base
		 */
		break;
	case VME_CRCSR:
		if (((vme_base + size) > VME_CRCSR_MAX) ||
				(vme_base > VME_CRCSR_MAX))
			retval = -EFAULT;
		break;
	case VME_USER1:
	case VME_USER2:
	case VME_USER3:
	case VME_USER4:
		/* User Defined */
		break;
	default:
		printk(KERN_ERR "Invalid address space\n");
		retval = -EINVAL;
		break;
	}

	return retval;
}

/*
 * Request a slave image with specific attributes, return some unique
 * identifier.
 */
struct vme_resource *vme_slave_request(struct device *dev,
	vme_address_t address, vme_cycle_t cycle)
{
	struct vme_bridge *bridge;
	struct list_head *slave_pos = NULL;
	struct vme_slave_resource *allocated_image = NULL;
	struct vme_slave_resource *slave_image = NULL;
	struct vme_resource *resource = NULL;

	bridge = dev_to_bridge(dev);
	if (bridge == NULL) {
		printk(KERN_ERR "Can't find VME bus\n");
		goto err_bus;
	}

	/* Loop through slave resources */
	list_for_each(slave_pos, &bridge->slave_resources) {
		slave_image = list_entry(slave_pos,
			struct vme_slave_resource, list);

		if (slave_image == NULL) {
			printk(KERN_ERR "Registered NULL Slave resource\n");
			continue;
		}

		/* Find an unlocked and compatible image */
		mutex_lock(&slave_image->mtx);
		if (((slave_image->address_attr & address) == address) &&
			((slave_image->cycle_attr & cycle) == cycle) &&
			(slave_image->locked == 0)) {

			slave_image->locked = 1;
			mutex_unlock(&slave_image->mtx);
			allocated_image = slave_image;
			break;
		}
		mutex_unlock(&slave_image->mtx);
	}

	/* No free image */
	if (allocated_image == NULL)
		goto err_image;

	resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL);
	if (resource == NULL) {
		printk(KERN_WARNING "Unable to allocate resource structure\n");
		goto err_alloc;
	}
	resource->type = VME_SLAVE;
	resource->entry = &allocated_image->list;

	return resource;

err_alloc:
	/* Unlock image */
	mutex_lock(&slave_image->mtx);
	slave_image->locked = 0;
	mutex_unlock(&slave_image->mtx);
err_image:
err_bus:
	return NULL;
}
EXPORT_SYMBOL(vme_slave_request);

int vme_slave_set(struct vme_resource *resource, int enabled,
	unsigned long long vme_base, unsigned long long size,
	dma_addr_t buf_base, vme_address_t aspace, vme_cycle_t cycle)
{
	struct vme_bridge *bridge = find_bridge(resource);
	struct vme_slave_resource *image;
	int retval;

	if (resource->type != VME_SLAVE) {
		printk(KERN_ERR "Not a slave resource\n");
		return -EINVAL;
	}

	image = list_entry(resource->entry, struct vme_slave_resource, list);

	if (bridge->slave_set == NULL) {
		printk(KERN_ERR "Function not supported\n");
		return -ENOSYS;
	}

	if (!(((image->address_attr & aspace) == aspace) &&
		((image->cycle_attr & cycle) == cycle))) {
		printk(KERN_ERR "Invalid attributes\n");
		return -EINVAL;
	}

	retval = vme_check_window(aspace, vme_base, size);
	if (retval)
		return retval;

	return bridge->slave_set(image, enabled, vme_base, size, buf_base,
		aspace, cycle);
}
EXPORT_SYMBOL(vme_slave_set);

int vme_slave_get(struct vme_resource *resource, int *enabled,
	unsigned long long *vme_base, unsigned long long *size,
	dma_addr_t *buf_base, vme_address_t *aspace, vme_cycle_t *cycle)
{
	struct vme_bridge *bridge = find_bridge(resource);
	struct vme_slave_resource *image;

	if (resource->type != VME_SLAVE) {
		printk(KERN_ERR "Not a slave resource\n");
		return -EINVAL;
	}

	image = list_entry(resource->entry, struct vme_slave_resource, list);

	if (bridge->slave_get == NULL) {
		printk(KERN_ERR "vme_slave_get not supported\n");
		return -EINVAL;
	}

	return bridge->slave_get(image, enabled, vme_base, size, buf_base,
		aspace, cycle);
}
EXPORT_SYMBOL(vme_slave_get);

void vme_slave_free(struct vme_resource *resource)
{
	struct vme_slave_resource *slave_image;

	if (resource->type != VME_SLAVE) {
		printk(KERN_ERR "Not a slave resource\n");
		return;
	}

	slave_image = list_entry(resource->entry, struct vme_slave_resource,
		list);
	if (slave_image == NULL) {
		printk(KERN_ERR "Can't find slave resource\n");
		return;
	}

	/* Unlock image */
	mutex_lock(&slave_image->mtx);
	if (slave_image->locked == 0)
		printk(KERN_ERR "Image is already free\n");

	slave_image->locked = 0;
	mutex_unlock(&slave_image->mtx);

	/* Free up resource memory */
	kfree(resource);
}
EXPORT_SYMBOL(vme_slave_free);

/*
 * Request a master image with specific attributes, return some unique
 * identifier.
 */
struct vme_resource *vme_master_request(struct device *dev,
	vme_address_t address, vme_cycle_t cycle, vme_width_t dwidth)
{
	struct vme_bridge *bridge;
	struct list_head *master_pos = NULL;
	struct vme_master_resource *allocated_image = NULL;
	struct vme_master_resource *master_image = NULL;
	struct vme_resource *resource = NULL;

	bridge = dev_to_bridge(dev);
	if (bridge == NULL) {
		printk(KERN_ERR "Can't find VME bus\n");
		goto err_bus;
	}

	/* Loop through master resources */
	list_for_each(master_pos, &bridge->master_resources) {
		master_image = list_entry(master_pos,
			struct vme_master_resource, list);

		if (master_image == NULL) {
			printk(KERN_WARNING "Registered NULL master resource\n");
			continue;
		}

		/* Find an unlocked and compatible image */
		spin_lock(&master_image->lock);
		if (((master_image->address_attr & address) == address) &&
			((master_image->cycle_attr & cycle) == cycle) &&
			((master_image->width_attr & dwidth) == dwidth) &&
			(master_image->locked == 0)) {

			master_image->locked = 1;
			spin_unlock(&master_image->lock);
			allocated_image = master_image;
			break;
		}
		spin_unlock(&master_image->lock);
	}

	/* Check to see if we found a resource */
	if (allocated_image == NULL) {
		printk(KERN_ERR "Can't find a suitable resource\n");
		goto err_image;
	}

	resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL);
	if (resource == NULL) {
		printk(KERN_ERR "Unable to allocate resource structure\n");
		goto err_alloc;
	}
	resource->type = VME_MASTER;
	resource->entry = &allocated_image->list;

	return resource;

err_alloc:
	/* Unlock image */
	spin_lock(&master_image->lock);
	master_image->locked = 0;
	spin_unlock(&master_image->lock);
err_image:
err_bus:
	return NULL;
}
EXPORT_SYMBOL(vme_master_request);

int vme_master_set(struct vme_resource *resource, int enabled,
	unsigned long long vme_base, unsigned long long size,
	vme_address_t aspace, vme_cycle_t cycle, vme_width_t dwidth)
{
	struct vme_bridge *bridge = find_bridge(resource);
	struct vme_master_resource *image;
	int retval;

	if (resource->type != VME_MASTER) {
		printk(KERN_ERR "Not a master resource\n");
		return -EINVAL;
	}

	image = list_entry(resource->entry, struct vme_master_resource, list);

	if (bridge->master_set == NULL) {
		printk(KERN_WARNING "vme_master_set not supported\n");
		return -EINVAL;
	}

	if (!(((image->address_attr & aspace) == aspace) &&
		((image->cycle_attr & cycle) == cycle) &&
		((image->width_attr & dwidth) == dwidth))) {
		printk(KERN_WARNING "Invalid attributes\n");
		return -EINVAL;
	}

	retval = vme_check_window(aspace, vme_base, size);
	if (retval)
		return retval;

	return bridge->master_set(image, enabled, vme_base, size, aspace,
		cycle, dwidth);
}
EXPORT_SYMBOL(vme_master_set);

int vme_master_get(struct vme_resource *resource, int *enabled,
	unsigned long long *vme_base, unsigned long long *size,
	vme_address_t *aspace, vme_cycle_t *cycle, vme_width_t *dwidth)
{
	struct vme_bridge *bridge = find_bridge(resource);
	struct vme_master_resource *image;

	if (resource->type != VME_MASTER) {
		printk(KERN_ERR "Not a master resource\n");
		return -EINVAL;
	}

	image = list_entry(resource->entry, struct vme_master_resource, list);

	if (bridge->master_get == NULL) {
		printk(KERN_WARNING "vme_master_set not supported\n");
		return -EINVAL;
	}

	return bridge->master_get(image, enabled, vme_base, size, aspace,
		cycle, dwidth);
}
EXPORT_SYMBOL(vme_master_get);

/*
 * Read data out of VME space into a buffer.
 */
ssize_t vme_master_read(struct vme_resource *resource, void *buf, size_t count,
	loff_t offset)
{
	struct vme_bridge *bridge = find_bridge(resource);
	struct vme_master_resource *image;
	size_t length;

	if (bridge->master_read == NULL) {
		printk(KERN_WARNING "Reading from resource not supported\n");
		return -EINVAL;
	}

	if (resource->type != VME_MASTER) {
		printk(KERN_ERR "Not a master resource\n");
		return -EINVAL;
	}

	image = list_entry(resource->entry, struct vme_master_resource, list);

	length = vme_get_size(resource);

	if (offset > length) {
		printk(KERN_WARNING "Invalid Offset\n");
		return -EFAULT;
	}

	if ((offset + count) > length)
		count = length - offset;

	return bridge->master_read(image, buf, count, offset);

}
EXPORT_SYMBOL(vme_master_read);

/*
 * Write data out to VME space from a buffer.
 */
ssize_t vme_master_write(struct vme_resource *resource, void *buf,
	size_t count, loff_t offset)
{
	struct vme_bridge *bridge = find_bridge(resource);
	struct vme_master_resource *image;
	size_t length;

	if (bridge->master_write == NULL) {
		printk(KERN_WARNING "Writing to resource not supported\n");
		return -EINVAL;
	}

	if (resource->type != VME_MASTER) {
		printk(KERN_ERR "Not a master resource\n");
		return -EINVAL;
	}

	image = list_entry(resource->entry, struct vme_master_resource, list);

	length = vme_get_size(resource);

	if (offset > length) {
		printk(KERN_WARNING "Invalid Offset\n");
		return -EFAULT;
	}

	if ((offset + count) > length)
		count = length - offset;

	return bridge->master_write(image, buf, count, offset);
}
EXPORT_SYMBOL(vme_master_write);

/*
 * Perform RMW cycle to provided location.
 */
unsigned int vme_master_rmw(struct vme_resource *resource, unsigned int mask,
	unsigned int compare, unsigned int swap, loff_t offset)
{
	struct vme_bridge *bridge = find_bridge(resource);
	struct vme_master_resource *image;

	if (bridge->master_rmw == NULL) {
		printk(KERN_WARNING "Writing to resource not supported\n");
		return -EINVAL;
	}

	if (resource->type != VME_MASTER) {
		printk(KERN_ERR "Not a master resource\n");
		return -EINVAL;
	}

	image = list_entry(resource->entry, struct vme_master_resource, list);

	return bridge->master_rmw(image, mask, compare, swap, offset);
}
EXPORT_SYMBOL(vme_master_rmw);

void vme_master_free(struct vme_resource *resource)
{
	struct vme_master_resource *master_image;

	if (resource->type != VME_MASTER) {
		printk(KERN_ERR "Not a master resource\n");
		return;
	}

	master_image = list_entry(resource->entry, struct vme_master_resource,
		list);
	if (master_image == NULL) {
		printk(KERN_ERR "Can't find master resource\n");
		return;
	}

	/* Unlock image */
	spin_lock(&master_image->lock);
	if (master_image->locked == 0)
		printk(KERN_ERR "Image is already free\n");

	master_image->locked = 0;
	spin_unlock(&master_image->lock);

	/* Free up resource memory */
	kfree(resource);
}
EXPORT_SYMBOL(vme_master_free);

/*
 * Request a DMA controller with specific attributes, return some unique
 * identifier.
 */
struct vme_resource *vme_dma_request(struct device *dev, vme_dma_route_t route)
{
	struct vme_bridge *bridge;
	struct list_head *dma_pos = NULL;
	struct vme_dma_resource *allocated_ctrlr = NULL;
	struct vme_dma_resource *dma_ctrlr = NULL;
	struct vme_resource *resource = NULL;

	/* XXX Not checking resource attributes */
	printk(KERN_ERR "No VME resource Attribute tests done\n");

	bridge = dev_to_bridge(dev);
	if (bridge == NULL) {
		printk(KERN_ERR "Can't find VME bus\n");
		goto err_bus;
	}

	/* Loop through DMA resources */
	list_for_each(dma_pos, &bridge->dma_resources) {
		dma_ctrlr = list_entry(dma_pos,
			struct vme_dma_resource, list);

		if (dma_ctrlr == NULL) {
			printk(KERN_ERR "Registered NULL DMA resource\n");
			continue;
		}

		/* Find an unlocked and compatible controller */
		mutex_lock(&dma_ctrlr->mtx);
		if (((dma_ctrlr->route_attr & route) == route) &&
			(dma_ctrlr->locked == 0)) {

			dma_ctrlr->locked = 1;
			mutex_unlock(&dma_ctrlr->mtx);
			allocated_ctrlr = dma_ctrlr;
			break;
		}
		mutex_unlock(&dma_ctrlr->mtx);
	}

	/* Check to see if we found a resource */
	if (allocated_ctrlr == NULL)
		goto err_ctrlr;

	resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL);
	if (resource == NULL) {
		printk(KERN_WARNING "Unable to allocate resource structure\n");
		goto err_alloc;
	}
	resource->type = VME_DMA;
	resource->entry = &allocated_ctrlr->list;

	return resource;

err_alloc:
	/* Unlock image */
	mutex_lock(&dma_ctrlr->mtx);
	dma_ctrlr->locked = 0;
	mutex_unlock(&dma_ctrlr->mtx);
err_ctrlr:
err_bus:
	return NULL;
}
EXPORT_SYMBOL(vme_dma_request);

/*
 * Start new list
 */
struct vme_dma_list *vme_new_dma_list(struct vme_resource *resource)
{
	struct vme_dma_resource *ctrlr;
	struct vme_dma_list *dma_list;

	if (resource->type != VME_DMA) {
		printk(KERN_ERR "Not a DMA resource\n");
		return NULL;
	}

	ctrlr = list_entry(resource->entry, struct vme_dma_resource, list);

	dma_list = kmalloc(sizeof(struct vme_dma_list), GFP_KERNEL);
	if (dma_list == NULL) {
		printk(KERN_ERR "Unable to allocate memory for new dma list\n");
		return NULL;
	}
	INIT_LIST_HEAD(&dma_list->entries);
	dma_list->parent = ctrlr;
	mutex_init(&dma_list->mtx);

	return dma_list;
}
EXPORT_SYMBOL(vme_new_dma_list);

/*
 * Create "Pattern" type attributes
 */
struct vme_dma_attr *vme_dma_pattern_attribute(u32 pattern,
	vme_pattern_t type)
{
	struct vme_dma_attr *attributes;
	struct vme_dma_pattern *pattern_attr;

	attributes = kmalloc(sizeof(struct vme_dma_attr), GFP_KERNEL);
	if (attributes == NULL) {
		printk(KERN_ERR "Unable to allocate memory for attributes "
			"structure\n");
		goto err_attr;
	}

	pattern_attr = kmalloc(sizeof(struct vme_dma_pattern), GFP_KERNEL);
	if (pattern_attr == NULL) {
		printk(KERN_ERR "Unable to allocate memory for pattern "
			"attributes\n");
		goto err_pat;
	}

	attributes->type = VME_DMA_PATTERN;
	attributes->private = (void *)pattern_attr;

	pattern_attr->pattern = pattern;
	pattern_attr->type = type;

	return attributes;

err_pat:
	kfree(attributes);
err_attr:
	return NULL;
}
EXPORT_SYMBOL(vme_dma_pattern_attribute);

/*
 * Create "PCI" type attributes
 */
struct vme_dma_attr *vme_dma_pci_attribute(dma_addr_t address)
{
	struct vme_dma_attr *attributes;
	struct vme_dma_pci *pci_attr;

	/* XXX Run some sanity checks here */

	attributes = kmalloc(sizeof(struct vme_dma_attr), GFP_KERNEL);
	if (attributes == NULL) {
		printk(KERN_ERR "Unable to allocate memory for attributes "
			"structure\n");
		goto err_attr;
	}

	pci_attr = kmalloc(sizeof(struct vme_dma_pci), GFP_KERNEL);
	if (pci_attr == NULL) {
		printk(KERN_ERR "Unable to allocate memory for pci "
			"attributes\n");
		goto err_pci;
	}

	attributes->type = VME_DMA_PCI;
	attributes->private = (void *)pci_attr;

	pci_attr->address = address;

	return attributes;

err_pci:
	kfree(attributes);
err_attr:
	return NULL;
}
EXPORT_SYMBOL(vme_dma_pci_attribute);

/*
 * Create "VME" type attributes
 */
struct vme_dma_attr *vme_dma_vme_attribute(unsigned long long address,
	vme_address_t aspace, vme_cycle_t cycle, vme_width_t dwidth)
{
	struct vme_dma_attr *attributes;
	struct vme_dma_vme *vme_attr;

	attributes = kmalloc(
		sizeof(struct vme_dma_attr), GFP_KERNEL);
	if (attributes == NULL) {
		printk(KERN_ERR "Unable to allocate memory for attributes "
			"structure\n");
		goto err_attr;
	}

	vme_attr = kmalloc(sizeof(struct vme_dma_vme), GFP_KERNEL);
	if (vme_attr == NULL) {
		printk(KERN_ERR "Unable to allocate memory for vme "
			"attributes\n");
		goto err_vme;
	}

	attributes->type = VME_DMA_VME;
	attributes->private = (void *)vme_attr;

	vme_attr->address = address;
	vme_attr->aspace = aspace;
	vme_attr->cycle = cycle;
	vme_attr->dwidth = dwidth;

	return attributes;

err_vme:
	kfree(attributes);
err_attr:
	return NULL;
}
EXPORT_SYMBOL(vme_dma_vme_attribute);

/*
 * Free attribute
 */
void vme_dma_free_attribute(struct vme_dma_attr *attributes)
{
	kfree(attributes->private);
	kfree(attributes);
}
EXPORT_SYMBOL(vme_dma_free_attribute);

int vme_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src,
	struct vme_dma_attr *dest, size_t count)
{
	struct vme_bridge *bridge = list->parent->parent;
	int retval;

	if (bridge->dma_list_add == NULL) {
		printk(KERN_WARNING "Link List DMA generation not supported\n");
		return -EINVAL;
	}

	if (!mutex_trylock(&list->mtx)) {
		printk(KERN_ERR "Link List already submitted\n");
		return -EINVAL;
	}

	retval = bridge->dma_list_add(list, src, dest, count);

	mutex_unlock(&list->mtx);

	return retval;
}
EXPORT_SYMBOL(vme_dma_list_add);

int vme_dma_list_exec(struct vme_dma_list *list)
{
	struct vme_bridge *bridge = list->parent->parent;
	int retval;

	if (bridge->dma_list_exec == NULL) {
		printk(KERN_ERR "Link List DMA execution not supported\n");
		return -EINVAL;
	}

	mutex_lock(&list->mtx);

	retval = bridge->dma_list_exec(list);

	mutex_unlock(&list->mtx);

	return retval;
}
EXPORT_SYMBOL(vme_dma_list_exec);

int vme_dma_list_free(struct vme_dma_list *list)
{
	struct vme_bridge *bridge = list->parent->parent;
	int retval;

	if (bridge->dma_list_empty == NULL) {
		printk(KERN_WARNING "Emptying of Link Lists not supported\n");
		return -EINVAL;
	}

	if (!mutex_trylock(&list->mtx)) {
		printk(KERN_ERR "Link List in use\n");
		return -EINVAL;
	}

	/*
	 * Empty out all of the entries from the dma list. We need to go to the
	 * low level driver as dma entries are driver specific.
	 */
	retval = bridge->dma_list_empty(list);
	if (retval) {
		printk(KERN_ERR "Unable to empty link-list entries\n");
		mutex_unlock(&list->mtx);
		return retval;
	}
	mutex_unlock(&list->mtx);
	kfree(list);

	return retval;
}
EXPORT_SYMBOL(vme_dma_list_free);

int vme_dma_free(struct vme_resource *resource)
{
	struct vme_dma_resource *ctrlr;

	if (resource->type != VME_DMA) {
		printk(KERN_ERR "Not a DMA resource\n");
		return -EINVAL;
	}

	ctrlr = list_entry(resource->entry, struct vme_dma_resource, list);

	if (!mutex_trylock(&ctrlr->mtx)) {
		printk(KERN_ERR "Resource busy, can't free\n");
		return -EBUSY;
	}

	if (!(list_empty(&ctrlr->pending) && list_empty(&ctrlr->running))) {
		printk(KERN_WARNING "Resource still processing transfers\n");
		mutex_unlock(&ctrlr->mtx);
		return -EBUSY;
	}

	ctrlr->locked = 0;

	mutex_unlock(&ctrlr->mtx);

	return 0;
}
EXPORT_SYMBOL(vme_dma_free);

void vme_irq_handler(struct vme_bridge *bridge, int level, int statid)
{
	void (*call)(int, int, void *);
	void *priv_data;

	call = bridge->irq[level - 1].callback[statid].func;
	priv_data = bridge->irq[level - 1].callback[statid].priv_data;

	if (call != NULL)
		call(level, statid, priv_data);
	else
		printk(KERN_WARNING "Spurilous VME interrupt, level:%x, "
			"vector:%x\n", level, statid);
}
EXPORT_SYMBOL(vme_irq_handler);

int vme_irq_request(struct device *dev, int level, int statid,
	void (*callback)(int, int, void *),
	void *priv_data)
{
	struct vme_bridge *bridge;

	bridge = dev_to_bridge(dev);
	if (bridge == NULL) {
		printk(KERN_ERR "Can't find VME bus\n");
		return -EINVAL;
	}

	if ((level < 1) || (level > 7)) {
		printk(KERN_ERR "Invalid interrupt level\n");
		return -EINVAL;
	}

	if (bridge->irq_set == NULL) {
		printk(KERN_ERR "Configuring interrupts not supported\n");
		return -EINVAL;
	}

	mutex_lock(&bridge->irq_mtx);

	if (bridge->irq[level - 1].callback[statid].func) {
		mutex_unlock(&bridge->irq_mtx);
		printk(KERN_WARNING "VME Interrupt already taken\n");
		return -EBUSY;
	}

	bridge->irq[level - 1].count++;
	bridge->irq[level - 1].callback[statid].priv_data = priv_data;
	bridge->irq[level - 1].callback[statid].func = callback;

	/* Enable IRQ level */
	bridge->irq_set(bridge, level, 1, 1);

	mutex_unlock(&bridge->irq_mtx);

	return 0;
}
EXPORT_SYMBOL(vme_irq_request);

void vme_irq_free(struct device *dev, int level, int statid)
{
	struct vme_bridge *bridge;

	bridge = dev_to_bridge(dev);
	if (bridge == NULL) {
		printk(KERN_ERR "Can't find VME bus\n");
		return;
	}

	if ((level < 1) || (level > 7)) {
		printk(KERN_ERR "Invalid interrupt level\n");
		return;
	}

	if (bridge->irq_set == NULL) {
		printk(KERN_ERR "Configuring interrupts not supported\n");
		return;
	}

	mutex_lock(&bridge->irq_mtx);

	bridge->irq[level - 1].count--;

	/* Disable IRQ level if no more interrupts attached at this level*/
	if (bridge->irq[level - 1].count == 0)
		bridge->irq_set(bridge, level, 0, 1);

	bridge->irq[level - 1].callback[statid].func = NULL;
	bridge->irq[level - 1].callback[statid].priv_data = NULL;

	mutex_unlock(&bridge->irq_mtx);
}
EXPORT_SYMBOL(vme_irq_free);

int vme_irq_generate(struct device *dev, int level, int statid)
{
	struct vme_bridge *bridge;

	bridge = dev_to_bridge(dev);
	if (bridge == NULL) {
		printk(KERN_ERR "Can't find VME bus\n");
		return -EINVAL;
	}

	if ((level < 1) || (level > 7)) {
		printk(KERN_WARNING "Invalid interrupt level\n");
		return -EINVAL;
	}

	if (bridge->irq_generate == NULL) {
		printk(KERN_WARNING "Interrupt generation not supported\n");
		return -EINVAL;
	}

	return bridge->irq_generate(bridge, level, statid);
}
EXPORT_SYMBOL(vme_irq_generate);

/*
 * Request the location monitor, return resource or NULL
 */
struct vme_resource *vme_lm_request(struct device *dev)
{
	struct vme_bridge *bridge;
	struct list_head *lm_pos = NULL;
	struct vme_lm_resource *allocated_lm = NULL;
	struct vme_lm_resource *lm = NULL;
	struct vme_resource *resource = NULL;

	bridge = dev_to_bridge(dev);
	if (bridge == NULL) {
		printk(KERN_ERR "Can't find VME bus\n");
		goto err_bus;
	}

	/* Loop through DMA resources */
	list_for_each(lm_pos, &bridge->lm_resources) {
		lm = list_entry(lm_pos,
			struct vme_lm_resource, list);

		if (lm == NULL) {
			printk(KERN_ERR "Registered NULL Location Monitor "
				"resource\n");
			continue;
		}

		/* Find an unlocked controller */
		mutex_lock(&lm->mtx);
		if (lm->locked == 0) {
			lm->locked = 1;
			mutex_unlock(&lm->mtx);
			allocated_lm = lm;
			break;
		}
		mutex_unlock(&lm->mtx);
	}

	/* Check to see if we found a resource */
	if (allocated_lm == NULL)
		goto err_lm;

	resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL);
	if (resource == NULL) {
		printk(KERN_ERR "Unable to allocate resource structure\n");
		goto err_alloc;
	}
	resource->type = VME_LM;
	resource->entry = &allocated_lm->list;

	return resource;

err_alloc:
	/* Unlock image */
	mutex_lock(&lm->mtx);
	lm->locked = 0;
	mutex_unlock(&lm->mtx);
err_lm:
err_bus:
	return NULL;
}
EXPORT_SYMBOL(vme_lm_request);

int vme_lm_count(struct vme_resource *resource)
{
	struct vme_lm_resource *lm;

	if (resource->type != VME_LM) {
		printk(KERN_ERR "Not a Location Monitor resource\n");
		return -EINVAL;
	}

	lm = list_entry(resource->entry, struct vme_lm_resource, list);

	return lm->monitors;
}
EXPORT_SYMBOL(vme_lm_count);

int vme_lm_set(struct vme_resource *resource, unsigned long long lm_base,
	vme_address_t aspace, vme_cycle_t cycle)
{
	struct vme_bridge *bridge = find_bridge(resource);
	struct vme_lm_resource *lm;

	if (resource->type != VME_LM) {
		printk(KERN_ERR "Not a Location Monitor resource\n");
		return -EINVAL;
	}

	lm = list_entry(resource->entry, struct vme_lm_resource, list);

	if (bridge->lm_set == NULL) {
		printk(KERN_ERR "vme_lm_set not supported\n");
		return -EINVAL;
	}

	return bridge->lm_set(lm, lm_base, aspace, cycle);
}
EXPORT_SYMBOL(vme_lm_set);

int vme_lm_get(struct vme_resource *resource, unsigned long long *lm_base,
	vme_address_t *aspace, vme_cycle_t *cycle)
{
	struct vme_bridge *bridge = find_bridge(resource);
	struct vme_lm_resource *lm;

	if (resource->type != VME_LM) {
		printk(KERN_ERR "Not a Location Monitor resource\n");
		return -EINVAL;
	}

	lm = list_entry(resource->entry, struct vme_lm_resource, list);

	if (bridge->lm_get == NULL) {
		printk(KERN_ERR "vme_lm_get not supported\n");
		return -EINVAL;
	}

	return bridge->lm_get(lm, lm_base, aspace, cycle);
}
EXPORT_SYMBOL(vme_lm_get);

int vme_lm_attach(struct vme_resource *resource, int monitor,
	void (*callback)(int))
{
	struct vme_bridge *bridge = find_bridge(resource);
	struct vme_lm_resource *lm;

	if (resource->type != VME_LM) {
		printk(KERN_ERR "Not a Location Monitor resource\n");
		return -EINVAL;
	}

	lm = list_entry(resource->entry, struct vme_lm_resource, list);

	if (bridge->lm_attach == NULL) {
		printk(KERN_ERR "vme_lm_attach not supported\n");
		return -EINVAL;
	}

	return bridge->lm_attach(lm, monitor, callback);
}
EXPORT_SYMBOL(vme_lm_attach);

int vme_lm_detach(struct vme_resource *resource, int monitor)
{
	struct vme_bridge *bridge = find_bridge(resource);
	struct vme_lm_resource *lm;

	if (resource->type != VME_LM) {
		printk(KERN_ERR "Not a Location Monitor resource\n");
		return -EINVAL;
	}

	lm = list_entry(resource->entry, struct vme_lm_resource, list);

	if (bridge->lm_detach == NULL) {
		printk(KERN_ERR "vme_lm_detach not supported\n");
		return -EINVAL;
	}

	return bridge->lm_detach(lm, monitor);
}
EXPORT_SYMBOL(vme_lm_detach);

void vme_lm_free(struct vme_resource *resource)
{
	struct vme_lm_resource *lm;

	if (resource->type != VME_LM) {
		printk(KERN_ERR "Not a Location Monitor resource\n");
		return;
	}

	lm = list_entry(resource->entry, struct vme_lm_resource, list);

	mutex_lock(&lm->mtx);

	/* XXX
	 * Check to see that there aren't any callbacks still attached, if
	 * there are we should probably be detaching them!
	 */

	lm->locked = 0;

	mutex_unlock(&lm->mtx);

	kfree(resource);
}
EXPORT_SYMBOL(vme_lm_free);

int vme_slot_get(struct device *bus)
{
	struct vme_bridge *bridge;

	bridge = dev_to_bridge(bus);
	if (bridge == NULL) {
		printk(KERN_ERR "Can't find VME bus\n");
		return -EINVAL;
	}

	if (bridge->slot_get == NULL) {
		printk(KERN_WARNING "vme_slot_get not supported\n");
		return -EINVAL;
	}

	return bridge->slot_get(bridge);
}
EXPORT_SYMBOL(vme_slot_get);

/* - Bridge Registration --------------------------------------------------- */

static int vme_alloc_bus_num(void)
{
	int i;

	mutex_lock(&vme_bus_num_mtx);
	for (i = 0; i < sizeof(vme_bus_numbers) * 8; i++) {
		if (((vme_bus_numbers >> i) & 0x1) == 0) {
			vme_bus_numbers |= (0x1 << i);
			break;
		}
	}
	mutex_unlock(&vme_bus_num_mtx);

	return i;
}

static void vme_free_bus_num(int bus)
{
	mutex_lock(&vme_bus_num_mtx);
	vme_bus_numbers &= ~(0x1 << bus);
	mutex_unlock(&vme_bus_num_mtx);
}

int vme_register_bridge(struct vme_bridge *bridge)
{
	struct device *dev;
	int retval;
	int i;

	bridge->num = vme_alloc_bus_num();

	/* This creates 32 vme "slot" devices. This equates to a slot for each
	 * ID available in a system conforming to the ANSI/VITA 1-1994
	 * specification.
	 */
	for (i = 0; i < VME_SLOTS_MAX; i++) {
		dev = &bridge->dev[i];
		memset(dev, 0, sizeof(struct device));

		dev->parent = bridge->parent;
		dev->bus = &vme_bus_type;
		/*
		 * We save a pointer to the bridge in platform_data so that we
		 * can get to it later. We keep driver_data for use by the
		 * driver that binds against the slot
		 */
		dev->platform_data = bridge;
		dev_set_name(dev, "vme-%x.%x", bridge->num, i + 1);

		retval = device_register(dev);
		if (retval)
			goto err_reg;
	}

	return retval;

err_reg:
	while (--i >= 0) {
		dev = &bridge->dev[i];
		device_unregister(dev);
	}
	vme_free_bus_num(bridge->num);
	return retval;
}
EXPORT_SYMBOL(vme_register_bridge);

void vme_unregister_bridge(struct vme_bridge *bridge)
{
	int i;
	struct device *dev;

	for (i = 0; i < VME_SLOTS_MAX; i++) {
		dev = &bridge->dev[i];
		device_unregister(dev);
	}
	vme_free_bus_num(bridge->num);
}
EXPORT_SYMBOL(vme_unregister_bridge);

/* - Driver Registration --------------------------------------------------- */

int vme_register_driver(struct vme_driver *drv)
{
	drv->driver.name = drv->name;
	drv->driver.bus = &vme_bus_type;

	return driver_register(&drv->driver);
}
EXPORT_SYMBOL(vme_register_driver);

void vme_unregister_driver(struct vme_driver *drv)
{
	driver_unregister(&drv->driver);
}
EXPORT_SYMBOL(vme_unregister_driver);

/* - Bus Registration ------------------------------------------------------ */

static int vme_calc_slot(struct device *dev)
{
	struct vme_bridge *bridge;
	int num;

	bridge = dev_to_bridge(dev);

	/* Determine slot number */
	num = 0;
	while (num < VME_SLOTS_MAX) {
		if (&bridge->dev[num] == dev)
			break;

		num++;
	}
	if (num == VME_SLOTS_MAX) {
		dev_err(dev, "Failed to identify slot\n");
		num = 0;
		goto err_dev;
	}
	num++;

err_dev:
	return num;
}

static struct vme_driver *dev_to_vme_driver(struct device *dev)
{
	if (dev->driver == NULL)
		printk(KERN_ERR "Bugger dev->driver is NULL\n");

	return container_of(dev->driver, struct vme_driver, driver);
}

static int vme_bus_match(struct device *dev, struct device_driver *drv)
{
	struct vme_bridge *bridge;
	struct vme_driver *driver;
	int i, num;

	bridge = dev_to_bridge(dev);
	driver = container_of(drv, struct vme_driver, driver);

	num = vme_calc_slot(dev);
	if (!num)
		goto err_dev;

	if (driver->bind_table == NULL) {
		dev_err(dev, "Bind table NULL\n");
		goto err_table;
	}

	i = 0;
	while ((driver->bind_table[i].bus != 0) ||
		(driver->bind_table[i].slot != 0)) {

		if (bridge->num == driver->bind_table[i].bus) {
			if (num == driver->bind_table[i].slot)
				return 1;

			if (driver->bind_table[i].slot == VME_SLOT_ALL)
				return 1;

			if ((driver->bind_table[i].slot == VME_SLOT_CURRENT) &&
				(num == vme_slot_get(dev)))
				return 1;
		}
		i++;
	}

err_dev:
err_table:
	return 0;
}

static int vme_bus_probe(struct device *dev)
{
	struct vme_bridge *bridge;
	struct vme_driver *driver;
	int retval = -ENODEV;

	driver = dev_to_vme_driver(dev);
	bridge = dev_to_bridge(dev);

	if (driver->probe != NULL)
		retval = driver->probe(dev, bridge->num, vme_calc_slot(dev));

	return retval;
}

static int vme_bus_remove(struct device *dev)
{
	struct vme_bridge *bridge;
	struct vme_driver *driver;
	int retval = -ENODEV;

	driver = dev_to_vme_driver(dev);
	bridge = dev_to_bridge(dev);

	if (driver->remove != NULL)
		retval = driver->remove(dev, bridge->num, vme_calc_slot(dev));

	return retval;
}

struct bus_type vme_bus_type = {
	.name = "vme",
	.match = vme_bus_match,
	.probe = vme_bus_probe,
	.remove = vme_bus_remove,
};
EXPORT_SYMBOL(vme_bus_type);

static int __init vme_init(void)
{
	return bus_register(&vme_bus_type);
}

static void __exit vme_exit(void)
{
	bus_unregister(&vme_bus_type);
}

MODULE_DESCRIPTION("VME bridge driver framework");
MODULE_AUTHOR("Martyn Welch <martyn.welch@ge.com");
MODULE_LICENSE("GPL");

module_init(vme_init);
module_exit(vme_exit);


text:
<?xml version="1.0" ?>
<INPUT>

	<MEDALS>
		<MEDAL Id="1" MEDAL_THRESHOLD="52000" TYPE="Gold"/>
		<MEDAL Id="2" MEDAL_THRESHOLD="79000" TYPE="Silver"/>
		<MEDAL Id="3" MEDAL_THRESHOLD="102000" TYPE="Bronze"/>

	</MEDALS>

	<SpeedSettings Default="18" Max="150" Min="0"/>

	<PenaltySettings SpeedLost="0.1" TimeLost="15"/>

	<PROBLEM_SET>
		<PROBLEM_SUBSET>
			<TARGET TYPE="String">
				<ContentSettings string="0.49"/>
			</TARGET>
			<QUESTION INDEX="1">
				<Content TYPE="Fraction">
					<ContentSettings denominator="1000" numerator="17"/>
				</Content>
				<Content TYPE="Fraction">
					<ContentSettings denominator="1000" numerator="430"/>
				</Content>
				<Answer VALUE="2"/>
			</QUESTION>
			<QUESTION INDEX="2">
				<Content TYPE="Fraction">
					<ContentSettings denominator="1000" numerator="751"/>
				</Content>
				<Content TYPE="Fraction">
					<ContentSettings denominator="1000" numerator="805"/>
				</Content>
				<Answer VALUE="0"/>
			</QUESTION>
			<QUESTION INDEX="3">
				<Content TYPE="Fraction">
					<ContentSettings denominator="1000" numerator="2"/>
				</Content>
				<Content TYPE="Fraction">
					<ContentSettings denominator="1000" numerator="373"/>
				</Content>
				<Answer VALUE="2"/>
			</QUESTION>
		</PROBLEM_SUBSET>
		<PROBLEM_SUBSET>
			<TARGET TYPE="String">
				<ContentSettings string="0.467"/>
			</TARGET>
			<QUESTION INDEX="4">
				<Content TYPE="Fraction">
					<ContentSettings denominator="1000" numerator="110"/>
				</Content>
				<Content TYPE="Fraction">
					<ContentSettings denominator="1000" numerator="148"/>
				</Content>
				<Answer VALUE="2"/>
			</QUESTION>
			<QUESTION INDEX="5">
				<Content TYPE="Fraction">
					<ContentSettings denominator="1000" numerator="917"/>
				</Content>
				<Content TYPE="Fraction">
					<ContentSettings denominator="1000" numerator="955"/>
				</Content>
				<Answer VALUE="0"/>
			</QUESTION>
			<QUESTION INDEX="6">
				<Content TYPE="Fraction">
					<ContentSettings denominator="1000" numerator="964"/>
				</Content>
				<Content TYPE="Fraction">
					<ContentSettings denominator="1000" numerator="991"/>
				</Content>
				<Answer VALUE="0"/>
			</QUESTION>
		</PROBLEM_SUBSET>
		<PROBLEM_SUBSET>
			<TARGET TYPE="String">
				<ContentSettings string="0.625"/>
			</TARGET>
			<QUESTION INDEX="7">
				<Content TYPE="Fraction">
					<ContentSettings denominator="8" numerator="2"/>
				</Content>
				<Content TYPE="Fraction">
					<ContentSettings denominator="8" numerator="7"/>
				</Content>
				<Answer VALUE="1"/>
			</QUESTION>
			<QUESTION INDEX="8">
				<Content TYPE="Fraction">
					<ContentSettings denominator="8" numerator="1"/>
				</Content>
				<Content TYPE="Fraction">
					<ContentSettings denominator="8" numerator="2"/>
				</Content>
				<Answer VALUE="2"/>
			</QUESTION>
			<QUESTION INDEX="9">
				<Content TYPE="Fraction">
					<ContentSettings denominator="8" numerator="2"/>
				</Content>
				<Content TYPE="Fraction">
					<ContentSettings denominator="8" numerator="3"/>
				</Content>
				<Answer VALUE="2"/>
			</QUESTION>
		</PROBLEM_SUBSET>
		<PROBLEM_SUBSET>
			<TARGET TYPE="String">
				<ContentSettings string="0.3"/>
			</TARGET>
			<QUESTION INDEX="10">
				<Content TYPE="Fraction">
					<ContentSettings denominator="10" numerator="6"/>
				</Content>
				<Content TYPE="Fraction">
					<ContentSettings denominator="10" numerator="8"/>
				</Content>
				<Answer VALUE="0"/>
			</QUESTION>
			<QUESTION INDEX="11">
				<Content TYPE="Fraction">
					<ContentSettings denominator="10" numerator="1"/>
				</Content>
				<Content TYPE="Fraction">
					<ContentSettings denominator="10" numerator="7"/>
				</Content>
				<Answer VALUE="1"/>
			</QUESTION>
			<QUESTION INDEX="12">
				<Content TYPE="Fraction">
					<ContentSettings denominator="10" numerator="1"/>
				</Content>
				<Content TYPE="Fraction">
					<ContentSettings denominator="10" numerator="4"/>
				</Content>
				<Answer VALUE="1"/>
			</QUESTION>
		</PROBLEM_SUBSET>
		<PROBLEM_SUBSET>
			<TARGET TYPE="String">
				<ContentSettings string="0.322"/>
			</TARGET>
			<QUESTION INDEX="13">
				<Content TYPE="Fraction">
					<ContentSettings denominator="1000" numerator="190"/>
				</Content>
				<Content TYPE="Fraction">
					<ContentSettings denominator="1000" numerator="588"/>
				</Content>
				<Answer VALUE="1"/>
			</QUESTION>
			<QUESTION INDEX="14">
				<Content TYPE="Fraction">
					<ContentSettings denominator="1000" numerator="65"/>
				</Content>
				<Content TYPE="Fraction">
					<ContentSettings denominator="1000" numerator="323"/>
				</Content>
				<Answer VALUE="1"/>
			</QUESTION>
			<QUESTION INDEX="15">
				<Content TYPE="Fraction">
					<ContentSettings denominator="1000" numerator="345"/>
				</Content>
				<Content TYPE="Fraction">
					<ContentSettings denominator="1000" numerator="490"/>
				</Content>
				<Answer VALUE="0"/>
			</QUESTION>
		</PROBLEM_SUBSET>
		<PROBLEM_SUBSET>
			<TARGET TYPE="String">
				<ContentSettings string="0.716"/>
			</TARGET>
			<QUESTION INDEX="16">
				<Content TYPE="Fraction">
					<ContentSettings denominator="1000" numerator="346"/>
				</Content>
				<Content TYPE="Fraction">
					<ContentSettings denominator="1000" numerator="962"/>
				</Content>
				<Answer VALUE="1"/>
			</QUESTION>
			<QUESTION INDEX="17">
				<Content TYPE="Fraction">
					<ContentSettings denominator="1000" numerator="702"/>
				</Content>
				<Content TYPE="Fraction">
					<ContentSettings denominator="1000" numerator="861"/>
				</Content>
				<Answer VALUE="1"/>
			</QUESTION>
			<QUESTION INDEX="18">
				<Content TYPE="Fraction">
					<ContentSettings denominator="1000" numerator="726"/>
				</Content>
				<Content TYPE="Fraction">
					<ContentSettings denominator="1000" numerator="884"/>
				</Content>
				<Answer VALUE="0"/>
			</QUESTION>
		</PROBLEM_SUBSET>

	</PROBLEM_SET>

</INPUT>

redpajama_set_name: RedPajamaGithub


text:
import React, { Component } from 'react';
import Moment from 'moment';
import './WeatherNow.css';

const WeatherNow = (now) => {
  const { cityState,
          currentCondition,
          currentTemp,
          icon,
          today,
          todayCondition,
          todayHigh,
          todayLow,
        } = now;
  const iconUrl = `assets/svg/${icon}.svg`;
  const thisDate = new Moment(today).format('dddd, MMMM Do, YYYY');

  return (

{thisDate}

{cityState}

{currentTemp}℉

{currentCondition}

{todayHigh}℉

{todayLow}℉

{todayCondition}

  );
};

export default WeatherNow;


text:
module EYCli
  class CLI
    def run(args)
      name = (args.shift || 'help').downcase
      command = EYCli.command_manager[name]
      unless command
        EYCli.term.say <<-EOF

Command not available: '#{name}'
Try running `ey_cli help' to get more information about the available commands.
EOF
      else
        command.run(args)
      end
    end
  end
end


text:
@implementation OrgApacheLuceneSearchScorer

- (instancetype)initWithOrgApacheLuceneSearchWeight:(OrgApacheLuceneSearchWeight *)weight {
  OrgApacheLuceneSearchScorer_initWithOrgApacheLuceneSearchWeight_(self, weight);
  return self;
}

- (jfloat)score {
  // can't call an abstract method
  [self doesNotRecognizeSelector:_cmd];
  return 0;
}

- (jint)freq {
  // can't call an abstract method
  [self doesNotRecognizeSelector:_cmd];
  return 0;
}

- (OrgApacheLuceneSearchWeight *)getWeight {
  return weight_;
}

- (id<JavaUtilCollection>)getChildren {
  return JavaUtilCollections_emptyList();
}

- (OrgApacheLuceneSearchTwoPhaseIterator *)asTwoPhaseIterator {
  return nil;
}

- (void)dealloc {
  RELEASE_(weight_);
  [super dealloc];
}

+ (const J2ObjcClassInfo *)__metadata {
  static J2ObjcMethodInfo methods[] = {
    { NULL, NULL, 0x4, -1, 0, -1, -1, -1, -1 },
    { NULL, "F", 0x401, -1, -1, 1, -1, -1, -1 },
    { NULL, "I", 0x401, -1, -1, 1, -1, -1, -1 },
    { NULL, "LOrgApacheLuceneSearchWeight;", 0x1, -1, -1, -1, -1, -1, -1 },
    { NULL, "LJavaUtilCollection;", 0x1, -1, -1, -1, 2, -1, -1 },
    { NULL, "LOrgApacheLuceneSearchTwoPhaseIterator;", 0x1, -1, -1, -1, -1, -1, -1 },
  };
  #pragma clang diagnostic push
  #pragma clang diagnostic ignored "-Wobjc-multiple-method-names"
  #pragma clang diagnostic ignored "-Wundeclared-selector"
  methods[0].selector = @selector(initWithOrgApacheLuceneSearchWeight:);
  methods[1].selector = @selector(score);
  methods[2].selector = @selector(freq);
  methods[3].selector = @selector(getWeight);
  methods[4].selector = @selector(getChildren);
  methods[5].selector = @selector(asTwoPhaseIterator);
  #pragma clang diagnostic pop
  static const J2ObjcFieldInfo fields[] = {
    { "weight_", "LOrgApacheLuceneSearchWeight;", .constantValue.asLong = 0, 0x14, -1, -1, -1, -1 },
  };
  static const void *ptrTable[] = { "LOrgApacheLuceneSearchWeight;", "LJavaIoIOException;", "()Ljava/util/Collection<Lorg/apache/lucene/search/Scorer$ChildScorer;>;", "LOrgApacheLuceneSearchScorer_ChildScorer;" };
  static const J2ObjcClassInfo _OrgApacheLuceneSearchScorer = { "Scorer", "org.apache.lucene.search", ptrTable, methods, fields, 7, 0x401, 6, 1, -1, 3, -1, -1, -1 };
  return &_OrgApacheLuceneSearchScorer;
}

@end

void OrgApacheLuceneSearchScorer_initWithOrgApacheLuceneSearchWeight_(OrgApacheLuceneSearchScorer *self, OrgApacheLuceneSearchWeight *weight) {
  OrgApacheLuceneSearchDocIdSetIterator_init(self);
  JreStrongAssign(&self->weight_, weight);
}

J2OBJC_CLASS_TYPE_LITERAL_SOURCE(OrgApacheLuceneSearchScorer)

@implementation OrgApacheLuceneSearchScorer_ChildScorer

- (instancetype)initWithOrgApacheLuceneSearchScorer:(OrgApacheLuceneSearchScorer *)child
                                       withNSString:(NSString *)relationship {
  OrgApacheLuceneSearchScorer_ChildScorer_initWithOrgApacheLuceneSearchScorer_withNSString_(self, child, relationship);
  return self;
}

- (void)dealloc {
  RELEASE_(child_);
  RELEASE_(relationship_);
  [super dealloc];
}

+ (const J2ObjcClassInfo *)__metadata {
  static J2ObjcMethodInfo methods[] = {
    { NULL, NULL, 0x1, -1, 0, -1, -1, -1, -1 },
  };
  #pragma clang diagnostic push
  #pragma clang diagnostic ignored "-Wobjc-multiple-method-names"
  #pragma clang diagnostic ignored "-Wundeclared-selector"
  methods[0].selector = @selector(initWithOrgApacheLuceneSearchScorer:withNSString:);
  #pragma clang diagnostic pop
  static const J2ObjcFieldInfo fields[] = {
    { "child_", "LOrgApacheLuceneSearchScorer;", .constantValue.asLong = 0, 0x11, -1, -1, -1, -1 },
    { "relationship_", "LNSString;", .constantValue.asLong = 0, 0x11, -1, -1, -1, -1 },
  };
  static const void *ptrTable[] = { "LOrgApacheLuceneSearchScorer;LNSString;", "LOrgApacheLuceneSearchScorer;" };
  static const J2ObjcClassInfo _OrgApacheLuceneSearchScorer_ChildScorer = { "ChildScorer", "org.apache.lucene.search", ptrTable, methods, fields, 7, 0x9, 1, 2, 1, -1, -1, -1, -1 };
  return &_OrgApacheLuceneSearchScorer_ChildScorer;
}

@end

void OrgApacheLuceneSearchScorer_ChildScorer_initWithOrgApacheLuceneSearchScorer_withNSString_(OrgApacheLuceneSearchScorer_ChildScorer *self, OrgApacheLuceneSearchScorer *child, NSString *relationship) {
  NSObject_init(self);
  JreStrongAssign(&self->child_, child);
  JreStrongAssign(&self->relationship_, relationship);
}

OrgApacheLuceneSearchScorer_ChildScorer *new_OrgApacheLuceneSearchScorer_ChildScorer_initWithOrgApacheLuceneSearchScorer_withNSString_(OrgApacheLuceneSearchScorer *child, NSString *relationship) {
  J2OBJC_NEW_IMPL(OrgApacheLuceneSearchScorer_ChildScorer, initWithOrgApacheLuceneSearchScorer_withNSString_, child, relationship)
}

OrgApacheLuceneSearchScorer_ChildScorer *create_OrgApacheLuceneSearchScorer_ChildScorer_initWithOrgApacheLuceneSearchScorer_withNSString_(OrgApacheLuceneSearchScorer *child, NSString *relationship) {
  J2OBJC_CREATE_IMPL(OrgApacheLuceneSearchScorer_ChildScorer, initWithOrgApacheLuceneSearchScorer_withNSString_, child, relationship)
}

J2OBJC_CLASS_TYPE_LITERAL_SOURCE(OrgApacheLuceneSearchScorer_ChildScorer)


text:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
	package="com.kmshack.newsstand"
	android:versionCode="1"
	android:versionName="1.0.0" >

	<uses-sdk
		android:minSdkVersion="17"
		android:targetSdkVersion="21" />

	<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

	<application
		android:allowBackup="true"
		android:icon="@drawable/ic_launcher"
		android:label="@string/app_name"
		android:theme="@style/AppTheme" >
		<activity
			android:name="com.kmshack.newsstand.MainActivity"
			android:configChanges="orientation|screenSize"
			android:label="@string/app_name" >
			<intent-filter>
				<action android:name="android.intent.action.MAIN" />

				<category android:name="android.intent.category.LAUNCHER" />
			</intent-filter>
		</activity>
	</application>

</manifest>


text:
"""IP Availability Info implementations"""

from osc_lib.cli import format_columns
from osc_lib.command import command
from osc_lib import utils

from openstackclient.i18n import _
from openstackclient.identity import common as identity_common

_formatters = {
    'subnet_ip_availability': format_columns.ListDictColumn,
}

def _get_columns(item):
    column_map = {}
    hidden_columns = ['id', 'name', 'location', 'tenant_id']
    return utils.get_osc_show_columns_for_sdk_resource(
        item,
        column_map,
        hidden_columns
    )

# TODO(ankur-gupta-f): Use the SDK resource mapped attribute names once
# the OSC minimum requirements include SDK 1.0.
class ListIPAvailability(command.Lister):
    _description = _("List IP availability for network")

    def get_parser(self, prog_name):
        parser = super(ListIPAvailability, self).get_parser(prog_name)
        parser.add_argument(
            '--ip-version',
            type=int,
            default=4,
            choices=[4, 6],
            metavar='<ip-version>',
            dest='ip_version',
            help=_("List IP availability of given IP version "
                   "networks (default is 4)"),
        )
        parser.add_argument(
            '--project',
            metavar='<project>',
            help=_("List IP availability of given project (name or ID)"),
        )
        identity_common.add_project_domain_option_to_parser(parser)
        return parser

    def take_action(self, parsed_args):
        client = self.app.client_manager.network

        columns = (
            'network_id',
            'network_name',
            'total_ips',
            'used_ips',
        )
        column_headers = (
            'Network ID',
            'Network Name',
            'Total IPs',
            'Used IPs',
        )

        filters = {}
        if parsed_args.ip_version:
            filters['ip_version'] = parsed_args.ip_version

        if parsed_args.project:
            identity_client = self.app.client_manager.identity
            project_id = identity_common.find_project(
                identity_client,
                parsed_args.project,
                parsed_args.project_domain,
            ).id
            filters['project_id'] = project_id
        data = client.network_ip_availabilities(**filters)
        return (column_headers,
                (utils.get_item_properties(
                    s, columns,
                ) for s in data))

class ShowIPAvailability(command.ShowOne):
    _description = _("Show network IP availability details")

    def get_parser(self, prog_name):
        parser = super(ShowIPAvailability, self).get_parser(prog_name)
        parser.add_argument(
            'network',
            metavar="<network>",
            help=_("Show IP availability for a specific network (name or ID)"),
        )
        return parser

    def take_action(self, parsed_args):
        client = self.app.client_manager.network
        network_id = client.find_network(parsed_args.network,
                                         ignore_missing=False).id
        obj = client.find_network_ip_availability(network_id,
                                                  ignore_missing=False)
        display_columns, columns = _get_columns(obj)
        data = utils.get_item_properties(obj, columns, formatters=_formatters)
        return (display_columns, data)


text:
<?php

defined('_JEXEC') or die;
?>

<form action="<?php echo JRoute::_('index.php?option=com_jcomments&view=blacklist&layout=edit&id='.(int) $this->item->id); ?>" method="post" name="adminForm" id="blacklist-form" class="form-validate form-horizontal">
	<?php if(!empty($this->bootstrap)): ?>

<?php echo empty($this->item->id) ? JText::_('A_BLACKLIST_EDIT') : JText::sprintf('A_BLACKLIST_EDIT', $this->item->id);?>

	<?php endif;?>

							<?php echo $this->form->getLabel('ip'); ?>

							<?php echo $this->form->getInput('ip'); ?>

							<?php echo $this->form->getLabel('reason'); ?>

							<?php echo $this->form->getInput('reason'); ?>

							<?php echo $this->form->getLabel('notes'); ?>

							<?php echo $this->form->getInput('notes'); ?>

							<?php echo $this->form->getLabel('created'); ?>

							<?php echo $this->form->getInput('created'); ?>

							<?php echo $this->form->getLabel('id'); ?>

							<?php echo $this->form->getInput('id'); ?>

		<input type="hidden" name="task" value="" />
		<?php echo JHtml::_('form.token'); ?>

</form>


text:
package com.luqili.utils.pub.maven;

import java.io.File;

/**
 * 清理Maven下载失败引起的LastUpdated文件
 *
 * @author luqili
 *
 */
public class MavenClearLastUpdatedFile {

    /**
     * 删除指定后缀的文件。
     *
     * @param file
     */
    public static void delFile(File file, String fileExit) {
        if (file.isFile()) {
            String fileName = file.getName();
            if (fileName.endsWith(fileExit)) {
                file.delete();
                System.out.println("删除匹配文件:" + file.getPath());
            }
        } else {
            File[] lt = file.listFiles();
            if (lt != null && lt.length > 0) {
                for (File child : lt) {
                    delFile(child, fileExit);
                }
            } else {
                file.delete();// 删除空文件夹
                System.out.println("删除空文件夹:" + file.getPath());
            }
        }
    }

    /**
     * 遍历目录,删除指定后缀.lastUpdated的文件,起到清理Maven仓库的作用
     *
     * @param basePath
     */
    public static void deleMavenLastUpdated(String basePath) {
        String fileExit = ".lastUpdated";
        File root = new File(basePath);
        delFile(root, fileExit);
    }

    public static void main(String[] args) {
        String basePath = "/home/luqili/.m2";
        deleMavenLastUpdated(basePath);
    }

}


text:
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <script src="/node_modules/@bugsnag/browser/dist/bugsnag.min.js"></script>
    <script type="text/javascript">
      var NOTIFY = decodeURIComponent(window.location.search.match(/NOTIFY=([^&]+)/)[1])
      var SESSIONS = decodeURIComponent(window.location.search.match(/SESSIONS=([^&]+)/)[1])
      var API_KEY = decodeURIComponent(window.location.search.match(/API_KEY=([^&]+)/)[1])
      Bugsnag.start({
        apiKey: API_KEY,
        endpoints: { notify: NOTIFY, sessions: SESSIONS },
      })
    </script>
  </head>
  <body>
    <script>
      Bugsnag.notify(new Error('sensitive?'), function (event) {
        event.setUser('21')
        event.addMetadata('user', { password: '123456' })
      })
    </script>
  </body>
</html>


text:
Then /^I touch the alert view's "(.*?)" button$/ do |button_mark|
  touch "alertView button marked:'#{button_mark}'"
end


text:
() {
  local private_bundle=scrubs # choose a folder wisely
  local private_functions="$HOME/.$private_bundle/share/zsh/functions"
  [[ -r "$private_functions" ]] && fpath=( "$private_functions" $fpath ) && autoload _$private_bundle # load the launcher named _<bundle>
}


text:
<!DOCTYPE html>

<meta charset="utf-8">
<link rel="stylesheet" href="./resources/js-test-style.css"/>


text:
                  Begin Transaction;
Create  TABLE MAIN.[AircraftReg](
[AircraftID] integer PRIMARY KEY
,[FirstCreated] datetime NOT NULL
,[LastModified] datetime NOT NULL
,[ModeS] varchar(6) UNIQUE NOT NULL
,[ModeSCountry] varchar(24)
,[Country] varchar(24)
,[Registration] varchar(20)
,[CurrentRegDate] varchar(10)
,[PreviousID] varchar(10)
,[FirstRegDate] varchar(10)
,[Status] varchar(10)
,[DeRegDate] varchar(10)
,[Manufacturer] varchar(60)
,[ICAOTypeCode] varchar(10)
,[Type] varchar(40)
,[SerialNo] varchar(30)
,[PopularName] varchar(20)
,[GenericName] varchar(20)
,[AircraftClass] varchar(20)
,[Engines] varchar(40)
,[OwnershipStatus] varchar(10)
,[RegisteredOwners] varchar(100)
,[MTOW] varchar(10)
,[TotalHours] varchar(20)
,[YearBuilt] varchar(4)
,[CofACategory] varchar(30)
,[CofAExpiry] varchar(10)
,[UserNotes] varchar(300)
,[Interested] boolean NOT NULL DEFAULT 0
,[UserTag] varchar(5)
,[InfoURL] varchar(150)
,[PictureURL1] varchar(150)
,[PictureURL2] varchar(150)
,[PictureURL3] varchar(150)
,[UserBool1] boolean NOT NULL DEFAULT 0
,[UserBool2] boolean NOT NULL DEFAULT 0
,[UserBool3] boolean NOT NULL DEFAULT 0
,[UserBool4] boolean NOT NULL DEFAULT 0
,[UserBool5] boolean NOT NULL DEFAULT 0
,[UserString1] varchar(20)
,[UserString2] varchar(20)
,[UserString3] varchar(20)
,[UserString4] varchar(20)
,[UserString5] varchar(20)
,[UserInt1] integer DEFAULT 0
,[UserInt2] integer DEFAULT 0
,[UserInt3] integer DEFAULT 0
,[UserInt4] integer DEFAULT 0
,[UserInt5] integer DEFAULT 0
,[OperatorFlagCode] varchar(20)

) ;

CREATE INDEX AircraftRegAircraftClass ON AircraftReg(AircraftClass);
CREATE INDEX AircraftRegCountry ON AircraftReg(Country);
CREATE INDEX AircraftRegGenericName ON AircraftReg(GenericName);
CREATE INDEX AircraftRegICAOTypeCode ON AircraftReg(ICAOTypeCode);
CREATE INDEX AircraftRegInterested ON AircraftReg(Interested);
CREATE INDEX AircraftRegManufacturer ON AircraftReg(Manufacturer);
CREATE INDEX AircraftRegModeS ON AircraftReg(ModeS);
CREATE INDEX AircraftRegModeSCountry ON AircraftReg(ModeSCountry);
CREATE INDEX AircraftRegPopularName ON AircraftReg(PopularName);
CREATE INDEX AircraftRegRegisteredOwners ON AircraftReg(RegisteredOwners);
CREATE INDEX AircraftRegRegistration ON AircraftReg(Registration);
CREATE INDEX AircraftRegSerialNo ON AircraftReg(SerialNo);
CREATE INDEX AircraftRegType ON AircraftReg(Type);
CREATE INDEX AircraftRegUserTag ON AircraftReg(UserTag);
CREATE INDEX AircraftRegYearBuilt ON AircraftReg(YearBuilt);

Commit Transaction;


text:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="8dp"
    android:background="@color/white"
    android:descendantFocusability="blocksDescendants">

    <LinearLayout
        android:id="@+id/rl_my_bought_item1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <ImageView
            android:id="@+id/imv_my_bought_item"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:scaleType="centerCrop"
            android:src="@drawable/text_xiaoguo" />
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="8dp"
            android:orientation="vertical">

            <TextView
                android:id="@+id/tv_goods_name_my_bought_item"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_margin="4dp"
                android:gravity="center_vertical"
                android:lines="1"
                android:text="商品名"
                android:textSize="15sp" />

            <TextView
                android:id="@+id/tv_goods_money"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="4dp"
                android:text="$100"
                android:textColor="@color/red"
                android:textSize="18sp" />

            <TextView
                android:id="@+id/tv_old_price_goods"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/tv_goods_money"
                android:layout_margin="4dip"
                android:layout_toRightOf="@+id/tv_goods_money"
                android:text="原价:¥100"
                android:textColor="@color/gray" />

            <TextView
                android:id="@+id/tv_goods_condition"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_margin="4dp"
                android:text="商品交易状态"
                android:textSize="12sp" />

        </LinearLayout>
    </LinearLayout>

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"
        android:gravity="center_vertical"
        android:orientation="horizontal">

        <LinearLayout
            android:id="@+id/llConnect2Seller"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:orientation="horizontal"
            android:padding="4dp"
            android:clickable="true"
            android:background="@drawable/list_item_selector">

            <ImageView
                android:id="@+id/imv_contace_customer"
                android:layout_width="23dip"
                android:layout_height="23dip"
                android:src="@drawable/contact_customer_service" />

            <TextView
                android:id="@+id/tv_contace_customer"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:text="@string/text_talk"
                android:textColor="@color/gray"
                android:textSize="16sp" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:gravity="center_vertical">

            <Button
                android:id="@+id/bt_my_bought1"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:text="@string/check_logistics"
                android:textSize="12sp"
                android:focusable="false"
                android:textColor="@color/white"
                android:background="@drawable/submit_button_selector"/>

            <Button
                android:id="@+id/bt_my_bought2"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginRight="5dp"
                android:text="@string/firm_get_goods"
                android:textSize="12sp"
                android:focusable="false"
                android:textColor="@color/white"
                android:layout_margin="4dp"
                android:background="@drawable/submit_button_selector"/>
        </LinearLayout>
    </RelativeLayout>
</LinearLayout>


text:
;(function() {
  /** Caches last successful transport and uses it for following attempts.
   *
   * @param {Strategy} strategy
   * @param {Object} transports
   * @param {Object} options
   */
  function CachedStrategy(strategy, transports, options) {
    this.strategy = strategy;
    this.transports = transports;
    this.ttl = options.ttl || 1800*1000;
    this.encrypted = options.encrypted;
    this.timeline = options.timeline;
  }
  var prototype = CachedStrategy.prototype;

  prototype.isSupported = function() {
    return this.strategy.isSupported();
  };

  prototype.connect = function(minPriority, callback) {
    var encrypted = this.encrypted;
    var info = fetchTransportCache(encrypted);

    var strategies = [this.strategy];
    if (info && info.timestamp + this.ttl >= Pusher.Util.now()) {
      var transport = this.transports[info.transport];
      if (transport) {
        this.timeline.info({
          cached: true,
          transport: info.transport,
          latency: info.latency
        });
        strategies.push(new Pusher.SequentialStrategy([transport], {
          timeout: info.latency * 2 + 1000,
          failFast: true
        }));
      }
    }

    var startTimestamp = Pusher.Util.now();
    var runner = strategies.pop().connect(
      minPriority,
      function cb(error, handshake) {
        if (error) {
          flushTransportCache(encrypted);
          if (strategies.length > 0) {
            startTimestamp = Pusher.Util.now();
            runner = strategies.pop().connect(minPriority, cb);
          } else {
            callback(error);
          }
        } else {
          storeTransportCache(
            encrypted,
            handshake.transport.name,
            Pusher.Util.now() - startTimestamp
          );
          callback(null, handshake);
        }
      }
    );

    return {
      abort: function() {
        runner.abort();
      },
      forceMinPriority: function(p) {
        minPriority = p;
        if (runner) {
          runner.forceMinPriority(p);
        }
      }
    };
  };

  function getTransportCacheKey(encrypted) {
    return "pusherTransport" + (encrypted ? "Encrypted" : "Unencrypted");
  }

  function fetchTransportCache(encrypted) {
    var storage = Pusher.Util.getLocalStorage();
    if (storage) {
      try {
        var serializedCache = storage[getTransportCacheKey(encrypted)];
        if (serializedCache) {
          return JSON.parse(serializedCache);
        }
      } catch (e) {
        flushTransportCache(encrypted);
      }
    }
    return null;
  }

  function storeTransportCache(encrypted, transport, latency) {
    var storage = Pusher.Util.getLocalStorage();
    if (storage) {
      try {
        storage[getTransportCacheKey(encrypted)] = JSON.stringify({
          timestamp: Pusher.Util.now(),
          transport: transport,
          latency: latency
        });
      } catch (e) {
        // catch over quota exceptions raised by localStorage
      }
    }
  }

  function flushTransportCache(encrypted) {
    var storage = Pusher.Util.getLocalStorage();
    if (storage) {
      try {
        delete storage[getTransportCacheKey(encrypted)];
      } catch (e) {
        // catch exceptions raised by localStorage
      }
    }
  }

  Pusher.CachedStrategy = CachedStrategy;
}).call(this);


text:
* Analyse et planification stratégique : diagnostic de l'existant, objectifs, publics cibles, sites concurrents.
  * Cycle developement - phase analyse
    * Objectifs utilisateurs
      * Qu'attendront  les  utilisateurs  de  ce  site? Putting  people's  needs  first  :  http://www.gerrymcgovern.com/new-thinking/putting-people%E2%80%99s-needs-first

* Stratégies de contenus pour le Web et architecture de l'information.

# Links
Growing a Business Website: Fix the Basics First
http://www.useit.com/alertbox/design_priorities.html

Commerce électronique et DCU
http://www.lactualite.com/lactualite-affaires/prendre-le-virage-du-consommateur-pour-emprunter-la-voie-de-lexpansion-mondiale/

L'analyse concurentielle
http://www.ergolab.net/articles/analyse-concurrentielle-ergonomie.html

Exemple d'analyse concurentielle : Comment les opérateurs télécoms ont pensé la page d'accueil de leur site
http://www.journaldunet.com/ebusiness/telecoms-fai/analyse/ergonomie-comment-les-operateurs-telecoms-ont-pense-leur-home-page/comment-les-operateurs-telecoms-ont-pense-leur-home-page.shtml

La petite histoire de la refonte du site HEC Montréal
https://prezi.com/or9q0oglas7m/la-petite-histoire-de-la-refonte-du-site-hec-montreal

The Content Marketing Matrix
http://www.smartinsights.com/content-management/content-marketing-strategy/the-content-marketing-matrix-new-infographic/

Bubbl.us - Outil de création d'arborescences (mind mapping)
https://bubbl.us/

XMind - Outil de création d'arborescences (mind mapping)
https://www.xmind.net/


text:
% A ConTeXt document [master document: joyLoL.tex ]

\usemodule[t-diSimp]

\startDiSimpComponent languages

\usebtxdataset[langugesBib.lua]
\diSimpEnvironment joyLoLConTeXtStartEnv

\part[title=Language CoAlgebras]

\addDocumentDirectory{doc}

\diSimpComponent languagesOverview

\diSimpComponent ../jCF/doc/jCF

\diSimpComponent ../jCoAlg/doc/jCoAlg

\diSimpComponent ../jRM/doc/jRM

\diSimpComponent ../jSExp/doc/jSExp

%% Create the lms file
\addMainDocument{languages.tex}
\compileLmsfile{default}
\prependLmsfileCopyright{PerceptiSys Ltd (Stephen Gaito)}
\startLmsfile
require 'lms.contextDoc'
contextDoc.targets(lpTargets)
recurseTargets{}
\stopLmsfile
\createLmsfileFile%
  {default}%
  {lmsfile}%
  {-- A Lua Make System file}

\diSimpEnvironment joyLoLConTeXtStopEnv

\stopDiSimpComponent


text:
using UnityEngine;
using System.Collections;

public class StartNetworkScript : MonoBehaviour {

	public GUIStyle StyleName;
	public GUISkin SkinName;
	private string TextBoxName = "";
	private int width = 240;
	private int heigth = 40;
	private Rect element1;
	private Rect element2;
	private Rect element3;
	private Rect element4;
	private Rect element5;
	public bool VisibleNetworkSettings = false;
	// Use this for initialization
	void Start ()
	{
		//Debug.Log ("Start Log. User ID: " + UserParametrs.UserID);
		//Debug.Log (UserParametrs.UserName);
		//Debug.Log (UserParametrs.UserPosition);
		//Debug.Log (UserParametrs.UserScore);
		try
		{
			UserParametrs.UserScore = PlayerPrefs.GetInt("Score");
			UserParametrs.UserID = PlayerPrefs.GetInt("ID");
			UserParametrs.UserName = PlayerPrefs.GetString("Name");
			UserParametrs.UserPosition = PlayerPrefs.GetInt("Position");
		}
		catch(UnityException ex)
		{
			Debug.Log(ex.Message);
		}
		//Debug.Log (GameMixerAPI.Methods.GetIDByName(UserParametrs.UserName));
		if(GameMixerAPI.Methods.GetIDByName(UserParametrs.UserName)<=0)
		{
			Debug.Log (GameMixerAPI.Methods.Registration(UserParametrs.UserName,UserParametrs.UserScore));
		}
		element1 = new Rect(GUIParam.ScoreLabel.x,GUIParam.ScoreLabel.y,width,heigth);
		element2 = new Rect(GUIParam.ScoreLabel.x,heigth + GUIParam.ScoreLabel.y,width,heigth);
		element3 = new Rect(GUIParam.ScoreLabel.x,heigth * 2 + GUIParam.ScoreLabel.y,width,heigth);
		element4 = new Rect(GUIParam.ScoreLabel.x,heigth + GUIParam.ScoreLabel.y,width/2,heigth);
		element5 = new Rect((width/2) + GUIParam.ScoreLabel.x,heigth + GUIParam.ScoreLabel.y,width/2,heigth);
	}

	// Update is called once per frame
	void Update () {

	}

	void OnGUI ()
	{
		GUIElement();
	}

	public void GUIElement()
	{
		GUI.skin = SkinName;

		if(VisibleNetworkSettings)
		{
			NetworkElements();
		}

	}
	private void NetworkElements()
	{
		if(System.String.IsNullOrEmpty(UserParametrs.UserName) || UserParametrs.UserID<=0)
		{
			if (GUI.Button (element4, "SignUp"))
			{
				UserParametrs.UserName = TextBoxName;
				UserParametrs.UserID = GameMixerAPI.Methods.Registration(UserParametrs.UserName,UserParametrs.UserScore);
				NetworkConnector.UpdateData();

			}
			if (GUI.Button (element5, "SignIn"))
			{
				UserParametrs.UserName = TextBoxName;
				UserParametrs.UserID = GameMixerAPI.Methods.GetIDByName(UserParametrs.UserName);
				NetworkConnector.UpdateData();
			}
			TextBoxName = GUI.TextField(element1,TextBoxName,10);
		}
		else
		{
			GUI.Label(element1,"Name: " + UserParametrs.UserName,StyleName);
			GUI.Label(element2,"Score: " + UserParametrs.UserScore.ToString(),StyleName);
			GUI.Label(element3,"Rating: " + UserParametrs.UserPosition.ToString(),StyleName);
		}
	}
}


text:
/** @constructor */
JSDOC.SymbolSet = function() {
	this.init();
}

JSDOC.SymbolSet.prototype.init = function() {
	this._index = new Hash();
}

JSDOC.SymbolSet.prototype.keys = function() {
	return this._index.keys();
}

JSDOC.SymbolSet.prototype.hasSymbol = function(alias) {
	return this._index.hasKey(alias);
}

JSDOC.SymbolSet.prototype.addSymbol = function(symbol) {
	if (this.hasSymbol(symbol.alias)) {
		LOG.warn("Overwriting symbol documentation for: "+symbol.alias + ".");
	}
	this._index.set(symbol.alias, symbol);
}

JSDOC.SymbolSet.prototype.getSymbol = function(alias) {
	if (this.hasSymbol(alias)) return this._index.get(alias);
}

JSDOC.SymbolSet.prototype.getSymbolByName = function(name) {
	for (var p = this._index.first(); p; p = this._index.next()) {
		var symbol = p.value;
		if (symbol.name == name) return symbol;
	}
}

JSDOC.SymbolSet.prototype.toArray = function() {
	return this._index.values();
}

JSDOC.SymbolSet.prototype.deleteSymbol = function(alias) {
	if (!this.hasSymbol(alias)) return;
	this._index.drop(alias);
}

JSDOC.SymbolSet.prototype.renameSymbol = function(oldName, newName) {
	// todo: should check if oldname or newname already exist
	this._index.replace(oldName, newName);
	this._index.get(newName).alias = newName;
	return newName;
}

JSDOC.SymbolSet.prototype.relate = function() {
	this.resolveBorrows();
	this.resolveMemberOf();
	this.resolveAugments();
}

JSDOC.SymbolSet.prototype.resolveBorrows = function() {
	for (var p = this._index.first(); p; p = this._index.next()) {
		var symbol = p.value;
		if (symbol.is("FILE") || symbol.is("GLOBAL")) continue;

		var borrows = symbol.inherits;
		for (var i = 0; i < borrows.length; i++) {
			var borrowed = this.getSymbol(borrows[i].alias);
			if (!borrowed) {
				LOG.warn("Can't borrow undocumented "+borrows[i].alias+".");
				continue;
			}

			var borrowAsName = borrows[i].as;
			var borrowAsAlias = borrowAsName;
			if (!borrowAsName) {
				LOG.warn("Malformed @borrow, 'as' is required.");
				continue;
			}

			if (borrowAsName.length > symbol.alias.length && borrowAsName.indexOf(symbol.alias) == 0) {
				borrowAsName = borrowAsName.replace(borrowed.alias, "")
			}
			else {
				var joiner = "";
				if (borrowAsName.charAt(0) != "#") joiner = ".";
				borrowAsAlias = borrowed.alias + joiner + borrowAsName;
			}

			borrowAsName = borrowAsName.replace(/^[#.]/, "");

			if (this.hasSymbol(borrowAsAlias)) continue;

			var clone = borrowed.clone();
			clone.name = borrowAsName;
			clone.alias = borrowAsAlias;
			this.addSymbol(clone);
		}
	}
}

JSDOC.SymbolSet.prototype.resolveMemberOf = function() {
	for (var p = this._index.first(); p; p = this._index.next()) {
		var symbol = p.value;
		if (symbol.is("FILE") || symbol.is("GLOBAL")) continue;

		// the memberOf value was provided in the @memberOf tag
		else if (symbol.memberOf) {

			// like foo.bar is a memberOf foo
			if (symbol.alias.indexOf(symbol.memberOf) == 0) {
				var memberMatch = new RegExp("^("+symbol.memberOf+")[.#-]?(.+)$");
				var aliasParts = symbol.alias.match(memberMatch);

				if (aliasParts) {
					symbol.memberOf = aliasParts[1];
					symbol.name = aliasParts[2];
				}

				var nameParts = symbol.name.match(memberMatch);

				if (nameParts) {
					symbol.name = nameParts[2];
				}
			}
			// like bar is a memberOf foo
			else {
				var joiner = symbol.memberOf.charAt(symbol.memberOf.length-1);
				if (!/[.#-]/.test(joiner)) symbol.memberOf += ".";
				this.renameSymbol(symbol.alias, symbol.memberOf + symbol.name);
			}
		}
		// the memberOf must be calculated
		else {
			var parts = symbol.alias.match(/^(.*[.#-])([^.#-]+)$/);
			if (parts) {
				symbol.memberOf = parts[1];
				symbol.name = parts[2];
			}
		}

		// set isStatic, isInner
		if (symbol.memberOf) {
			switch (symbol.memberOf.charAt(symbol.memberOf.length-1)) {
				case '#' :
					symbol.isStatic = false;
					symbol.isInner = false;
				break;
				case '.' :
					symbol.isStatic = true;
					symbol.isInner = false;
				break;
				case '-' :
					symbol.isStatic = false;
					symbol.isInner = true;
				break;
				default: // memberOf ends in none of the above
					symbol.isStatic = true;
				break;
			}
		}

		// unowned methods and fields belong to the global object
		if (!symbol.is("CONSTRUCTOR") && !symbol.isNamespace && symbol.memberOf == "") {
			symbol.memberOf = "_global_";
		}

		// clean up
		if (symbol.memberOf.match(/[.#-]$/)) {
			symbol.memberOf = symbol.memberOf.substr(0, symbol.memberOf.length-1);
		}
		// add to parent's methods or properties list
		if (symbol.memberOf) {

			var container = this.getSymbol(symbol.memberOf);
			if (!container) {
				if (JSDOC.Lang.isBuiltin(symbol.memberOf)) container = JSDOC.Parser.addBuiltin(symbol.memberOf);
				else {
					LOG.warn("Trying to document "+symbol.name +" as a member of undocumented symbol "+symbol.memberOf+".");
				}
			}

			if (container) container.addMember(symbol);
		}
	}
}

JSDOC.SymbolSet.prototype.resolveAugments = function() {
	for (var p = this._index.first(); p; p = this._index.next()) {
		var symbol = p.value;

		if (symbol.alias == "_global_" || symbol.is("FILE")) continue;
		JSDOC.SymbolSet.prototype.walk.apply(this, [symbol]);
	}
}

JSDOC.SymbolSet.prototype.walk = function(symbol) {
	var augments = symbol.augments;
	for(var i = 0; i < augments.length; i++) {
		var contributer = this.getSymbol(augments[i]);
		if (!contributer && JSDOC.Lang.isBuiltin(''+augments[i])) {
			contributer = new JSDOC.Symbol("_global_."+augments[i], [], augments[i], new JSDOC.DocComment("Built in."));
			contributer.isNamespace = true;
			contributer.srcFile = "";
			contributer.isPrivate = false;
			JSDOC.Parser.addSymbol(contributer);
		}

		if (contributer) {
			if (contributer.augments.length) {
				JSDOC.SymbolSet.prototype.walk.apply(this, [contributer]);
			}

			symbol.inheritsFrom.push(contributer.alias);
			//if (!isUnique(symbol.inheritsFrom)) {
			//	LOG.warn("Can't resolve augments: Circular reference: "+symbol.alias+" inherits from "+contributer.alias+" more than once.");
			//}
			//else {
				var cmethods = contributer.methods;
				var cproperties = contributer.properties;

				for (var ci = 0, cl = cmethods.length; ci < cl; ci++) {
					if (!cmethods[ci].isStatic) symbol.inherit(cmethods[ci]);
				}
				for (var ci = 0, cl = cproperties.length; ci < cl; ci++) {
					if (!cproperties[ci].isStatic) symbol.inherit(cproperties[ci]);
				}
			//}
		}
		else LOG.warn("Can't augment contributer: "+augments[i]+", not found.");
	}
}


text:
namespace v8 {
namespace internal {

void HCanonicalizePhase::Run() {
  const ZoneList<HBasicBlock*>* blocks(graph()->blocks());
  // Before removing no-op instructions, save their semantic value.
  // We must be careful not to set the flag unnecessarily, because GVN
  // cannot identify two instructions when their flag value differs.
  for (int i = 0; i < blocks->length(); ++i) {
    for (HInstructionIterator it(blocks->at(i)); !it.Done(); it.Advance()) {
      HInstruction* instr = it.Current();
      if (instr->IsArithmeticBinaryOperation()) {
        if (instr->representation().IsInteger32()) {
          if (instr->HasAtLeastOneUseWithFlagAndNoneWithout(
                  HInstruction::kTruncatingToInt32)) {
            instr->SetFlag(HInstruction::kAllUsesTruncatingToInt32);
          }
        } else if (instr->representation().IsSmi()) {
          if (instr->HasAtLeastOneUseWithFlagAndNoneWithout(
                  HInstruction::kTruncatingToSmi)) {
            instr->SetFlag(HInstruction::kAllUsesTruncatingToSmi);
          } else if (instr->HasAtLeastOneUseWithFlagAndNoneWithout(
                         HInstruction::kTruncatingToInt32)) {
            // Avoid redundant minus zero check
            instr->SetFlag(HInstruction::kAllUsesTruncatingToInt32);
          }
        }
      }
    }
  }

  // Perform actual Canonicalization pass.
  HRedundantPhiEliminationPhase redundant_phi_eliminator(graph());
  for (int i = 0; i < blocks->length(); ++i) {
    // Eliminate redundant phis in the block first; changes to their inputs
    // might have made them redundant, and eliminating them creates more
    // opportunities for constant folding and strength reduction.
    redundant_phi_eliminator.ProcessBlock(blocks->at(i));
    // Now canonicalize each instruction.
    for (HInstructionIterator it(blocks->at(i)); !it.Done(); it.Advance()) {
      HInstruction* instr = it.Current();
      HValue* value = instr->Canonicalize();
      if (value != instr) instr->DeleteAndReplaceWith(value);
    }
  }
}

} }  // namespace v8::internal


text:
package luckynine.youtell.data;

import android.content.ContentResolver;
import android.content.ContentUris;
import android.net.Uri;
import android.provider.BaseColumns;

/**
 * Created by Weiliang on 6/22/2015.
 */
public class DataContract {

    public final static String CONTENT_AUTHORITY = "luckynine.youtell.app";

    public final static Uri BASE_CONTENT_URI = Uri.parse("content://" + CONTENT_AUTHORITY);

    public final static String PATH_POST = "post";
    public final static String PATH_LOCATION = "location";

    public static final class PostEntry implements BaseColumns {

        public static final Uri CONTENT_URI =
                BASE_CONTENT_URI.buildUpon().appendPath(PATH_POST).build();

        public static final String CONTENT_DIR_TYPE =
                ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_POST;
        public static final String CONTENT_ITEM_TYPE =
                ContentResolver.CURSOR_ITEM_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_POST;

        public static final String TABLE_NAME = PATH_POST;

        public static final String COLUMN_ID = "_id";

        public static final String COLUMN_AUTHOR_ID = "author_id";

        public static final String COLUMN_LOCATION_ID = "location_id";

        public static final String COLUMN_AUTHOR = "author";

        public static final String COLUMN_CONTENT = "content";

        public static final String COLUMN_CREATED_AT = "created_at";

        public static Uri buildPostUriWithId(long id) {
            return ContentUris.withAppendedId(CONTENT_URI, id);
        }

        public static Uri buildPostUriWithLocationId(String locationId){
            return CONTENT_URI.buildUpon().appendPath(locationId).build();
        }

        public static String getLocationIdFromUri(Uri uri){
            return uri.getPathSegments().get(1);
        }
    }

    public static final class LocationEntry implements BaseColumns {

        public static final Uri CONTENT_URI =
                BASE_CONTENT_URI.buildUpon().appendPath(PATH_LOCATION).build();

        public static final String CONTENT_DIR_TYPE =
                ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_LOCATION;
        public static final String CONTENT_ITEM_TYPE =
                ContentResolver.CURSOR_ITEM_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_LOCATION;

        public static final String TABLE_NAME = PATH_LOCATION;

        public static final String COLUMN_ID = "_id";

        public static final String COLUMN_NAME = "name";

        public static final String COLUMN_COUNTRY = "country";

        public static Uri buildLocationUriWithId(long id) {
            return ContentUris.withAppendedId(CONTENT_URI, id);
        }
    }
}


text:
require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'

# --- Instructions ---
# Sort the contents of this file into a Spork.prefork and a Spork.each_run
# block.
#
# The Spork.prefork block is run only once when the spork server is started.
# You typically want to place most of your (slow) initializer code in here, in
# particular, require'ing any 3rd-party gems that you don't normally modify
# during development.
#
# The Spork.each_run block is run each time you run your specs.  In case you
# need to load files that tend to change during development, require them here.
# With Rails, your application modules are loaded automatically, so sometimes
# this block can remain empty.
#
# Note: You can modify files loaded *from* the Spork.each_run block without
# restarting the spork server.  However, this file itself will not be reloaded,
# so if you change any of the code inside the each_run block, you still need to
# restart the server.  In general, if you have non-trivial code in this file,
# it's advisable to move it into a separate file so you can easily edit it
# without restarting spork.  (For example, with RSpec, you could move
# non-trivial code into a file spec/support/my_helper.rb, making sure that the
# spec/support/* files are require'd from inside the each_run block.)
#
# Any code that is left outside the two blocks will be run during preforking
# *and* during each_run -- that's probably not what you want.
#
# These instructions should self-destruct in 10 seconds.  If they don't, feel
# free to delete them.

Spork.prefork do
  # Loading more in this block will cause your tests to run faster. However,
  # if you change any configuration or code from libraries loaded here, you'll
  # need to restart spork for it take effect.

  require 'simplecov'
  SimpleCov.start 'rails' do
    add_filter '/spec/'
    add_filter '/config/'
    add_filter '/lib/'
    add_filter '/vendor/'

    add_group 'Controllers', 'app/controllers'
    add_group 'Models', 'app/models'
    add_group 'Helpers', 'app/helpers'
    add_group 'Mailers', 'app/mailers'
    add_group 'Views', 'app/views'
  end

  ENV["RAILS_ENV"] ||= 'test'
  require File.expand_path("../dummy/config/environment", __FILE__)
  require 'rspec/rails'
  require 'rspec/autorun'
  require 'shoulda-matchers'

  require 'capybara/rspec'
  require 'factory_girl'
  require 'faker'
  require 'timecop'

  require 'database_cleaner'

  # For headless JS testing
  # Requires PhantomJS to be installed:
  # wget http://phantomjs.googlecode.com/files/phantomjs-1.7.0-source.zip
  # unzip -q; cd phantom-1.7 and run ./build.sh
  # ln -s /usr/local/src/phantomjs-1.7.0/bin/phantomjs /usr/local/bin/phantomjs
  require 'capybara/poltergeist'
  Capybara.javascript_driver = :poltergeist
  #Capybara.default_wait_time = 5

  ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')

  # Requires supporting ruby files with custom matchers and macros, etc,
  # in spec/support/ and its subdirectories.
  Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }

  # Require factory files from the factories folder because factories are in a separate directory
  Dir[File.join(ENGINE_RAILS_ROOT, "spec/factories/**/*.rb")].each {|f| require f}

  require 'vcr'

  VCR.configure do |config|
    config.cassette_library_dir = File.join(ENGINE_RAILS_ROOT, "spec", "fixtures", "vcr")
    config.hook_into :webmock
    config.default_cassette_options = { record: :new_episodes }
    #c.stub_with :fakeweb
    #c.filter_sensitive_data('<WSDL>') { "http://www.webservicex.net:80/uszip.asmx?WSDL" }
  end

  RSpec.configure do |config|

    config.filter_run_excluding skip: true

    # Cause all jobs to be performed synchronously
    require 'sucker_punch/testing/inline'

    # Include Factory Girl syntax to simplify calls to factories
    config.include FactoryGirl::Syntax::Methods

    # Add the next line so capybara visit <url_helper> works
    config.include McpCommon::Engine.routes.url_helpers

    # From support/mailer_macros.rb
    # See: http://railscasts.com/episodes/275-how-i-test?view=asciicast
    config.include(MailerMacros)

    # FIX: Include the engine routes so controller and request specs pass
    config.before(:each) {
      @routes = McpCommon::Engine.routes
      reset_email  # See: http://railscasts.com/episodes/275-how-i-test?view=asciicast
    }

    # ## Mock Framework
    #
    # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
    #
    # config.mock_with :mocha
    # config.mock_with :flexmock
    # config.mock_with :rr

    # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
    #  config.fixture_path = "#{::Rails.root}/spec/fixtures"

    # If you're not using ActiveRecord, or you'd prefer not to run each of your
    # examples within a transaction, remove the following line or assign false
    # instead of true.
    # config.use_transactional_fixtures = true

    # rr - Changes to enable request specs with capybara to test JS and accurately report database results
    # See: http://railscasts.com/episodes/257-request-specs-and-capybara?view=asciicast
    config.use_transactional_fixtures = false

    config.before(:suite) do
      DatabaseCleaner.app_root = "#{ENGINE_RAILS_ROOT}spec/dummy"
      DatabaseCleaner.clean_with(:truncation)
    end

    config.before(:each) do
      DatabaseCleaner.strategy = :transaction
    end

    config.before(:each, job: true) do
      DatabaseCleaner.strategy = :truncation
      #DatabaseCleaner.strategy = :deletion
    end

    config.before(:each, js: true) do
      DatabaseCleaner.strategy = :truncation
    end

    config.before(:each) do
      DatabaseCleaner.start
    end

    config.after(:each) do
      DatabaseCleaner.clean
    end

    # If true, the base class of anonymous controllers will be inferred
    # automatically. This will be the default behavior in future versions of
    # rspec-rails.
    config.infer_base_class_for_anonymous_controllers = false
  end

end

# This code will be run each time you run your specs.
Spork.each_run do
  ActiveSupport::Dependencies.clear
  FactoryGirl.reload

  # reload all the models
  Dir[File.join(ENGINE_RAILS_ROOT, "/app/models/**/*.rb")].each do |model|
    load model
  end

  # reload routes
  Rails.application.reload_routes!
end


text:
from boto.exception import BotoServerError

class InvalidDeploymentIdException(BotoServerError):
    pass

class InvalidDeploymentGroupNameException(BotoServerError):
    pass

class DeploymentConfigAlreadyExistsException(BotoServerError):
    pass

class InvalidRoleException(BotoServerError):
    pass

class RoleRequiredException(BotoServerError):
    pass

class DeploymentGroupAlreadyExistsException(BotoServerError):
    pass

class DeploymentConfigLimitExceededException(BotoServerError):
    pass

class InvalidNextTokenException(BotoServerError):
    pass

class InvalidDeploymentConfigNameException(BotoServerError):
    pass

class InvalidSortByException(BotoServerError):
    pass

class InstanceDoesNotExistException(BotoServerError):
    pass

class InvalidMinimumHealthyHostValueException(BotoServerError):
    pass

class ApplicationLimitExceededException(BotoServerError):
    pass

class ApplicationNameRequiredException(BotoServerError):
    pass

class InvalidEC2TagException(BotoServerError):
    pass

class DeploymentDoesNotExistException(BotoServerError):
    pass

class DeploymentLimitExceededException(BotoServerError):
    pass

class InvalidInstanceStatusException(BotoServerError):
    pass

class RevisionRequiredException(BotoServerError):
    pass

class InvalidBucketNameFilterException(BotoServerError):
    pass

class DeploymentGroupLimitExceededException(BotoServerError):
    pass

class DeploymentGroupDoesNotExistException(BotoServerError):
    pass

class DeploymentConfigNameRequiredException(BotoServerError):
    pass

class DeploymentAlreadyCompletedException(BotoServerError):
    pass

class RevisionDoesNotExistException(BotoServerError):
    pass

class DeploymentGroupNameRequiredException(BotoServerError):
    pass

class DeploymentIdRequiredException(BotoServerError):
    pass

class DeploymentConfigDoesNotExistException(BotoServerError):
    pass

class BucketNameFilterRequiredException(BotoServerError):
    pass

class InvalidTimeRangeException(BotoServerError):
    pass

class ApplicationDoesNotExistException(BotoServerError):
    pass

class InvalidRevisionException(BotoServerError):
    pass

class InvalidSortOrderException(BotoServerError):
    pass

class InvalidOperationException(BotoServerError):
    pass

class InvalidAutoScalingGroupException(BotoServerError):
    pass

class InvalidApplicationNameException(BotoServerError):
    pass

class DescriptionTooLongException(BotoServerError):
    pass

class ApplicationAlreadyExistsException(BotoServerError):
    pass

class InvalidDeployedStateFilterException(BotoServerError):
    pass

class DeploymentNotStartedException(BotoServerError):
    pass

class DeploymentConfigInUseException(BotoServerError):
    pass

class InstanceIdRequiredException(BotoServerError):
    pass

class InvalidKeyPrefixFilterException(BotoServerError):
    pass

class InvalidDeploymentStatusException(BotoServerError):
    pass


text:
VCL_TEMPLATE_EXPORT template <class T>
class VNL_EXPORT vnl_file_matrix : public vnl_matrix<T>
{
 private:
  VCL_SAFE_BOOL_DEFINE;
 public:
  vnl_file_matrix(char const* filename);

  operator safe_bool () const
    { return (ok_)? VCL_SAFE_BOOL_TRUE : 0; }
  bool operator!() const
    { return !ok_; }

 private:
  bool ok_;
};

#endif // vnl_file_matrix_h_


text:
' Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.

Imports System.Threading.Tasks
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.KeywordHighlighting

Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.KeywordHighlighting
    Public Class EventDeclarationHighlighterTests
        Inherits AbstractVisualBasicKeywordHighlighterTests

        Friend Overrides Function CreateHighlighter() As IHighlighter
            Return New EventDeclarationHighlighter()
        End Function

        <WpfFact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)>
        Public Async Function TestEventSample1_1() As Task
            Await TestAsync(<Text>
Class C
{|Cursor:[|Public Event|]|} Foo() [|Implements|] I1.Foo
End Class</Text>)
        End Function

        <WpfFact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)>
        Public Async Function TestEventSample1_2() As Task
            Await TestAsync(<Text>
Class C
[|Public Event|] Foo() {|Cursor:[|Implements|]|} I1.Foo
End Class</Text>)
        End Function
    End Class
End Namespace


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NuGetGallery.Operations.Common;

namespace NuGetGallery.Operations.Tasks.Database
{
    [Command("deletesqluser", "Lists SQL Users and access", AltName = "dsu")]
    public class DeleteSqlUser : DatabaseTask
    {
        [Option("Semicolon-separated list of users to delete", AltName="u")]
        public List<string> Users { get; set; }

        public DeleteSqlUser()
        {
            Users = new List<string>();
        }

        public override void ValidateArguments()
        {
            base.ValidateArguments();

            if (!Users.Any())
            {
                Users = null; // Just trigger ArgCheck to fail
            }

            ArgCheck.Required(Users, "Users");
        }

        public override void ExecuteCommand()
        {
            WithConnection((c, db) =>
            {
                foreach (var user in Users)
                {
                    if (db.Query<string>("SELECT name FROM sys.database_principals WHERE name = @n", new { n = user }).Any())
                    {
                        if (!WhatIf)
                        {
                            db.Execute(String.Format("DROP USER [{0}]", user));
                        }
                        Log.Info("Deleted Database User: {0}", user);
                    }
                    else
                    {
                        Log.Info("No DB User found: {0}", user);
                    }
                }
            });

            WithMasterConnection((c, db) =>
            {
                foreach (var user in Users)
                {
                    if (db.Query<string>("SELECT name FROM sys.sql_logins WHERE name = @n", new { n = user }).Any())
                    {
                        if (!WhatIf)
                        {
                            db.Execute(String.Format("DROP LOGIN [{0}]", user));
                        }
                        Log.Info("Deleted SQL Login: {0}", user);
                    }
                    else
                    {
                        Log.Info("No SQL Login found: {0}", user);
                    }
                }
            });
        }
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<animation-list android:oneshot="false"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:duration="150" android:drawable="@drawable/recording_1" />
    <item android:duration="150" android:drawable="@drawable/recording_2" />
    <item android:duration="150" android:drawable="@drawable/recording_3" />
    <item android:duration="150" android:drawable="@drawable/recording_4" />
</animation-list>