text:
/*
  Copyright 2009  Dean Camera (dean [at] fourwalledcubicle [dot] com)

  Permission to use, copy, modify, and distribute this software
  and its documentation for any purpose and without fee is hereby
  granted, provided that the above copyright notice appear in all
  copies and that both that the copyright notice and this
  permission notice and warranty disclaimer appear in supporting
  documentation, and that the name of the author not be used in
  advertising or publicity pertaining to distribution of the
  software without specific, written prior permission.

  The author disclaim all warranties with regard to this
  software, including all implied warranties of merchantability
  and fitness.  In no event shall the author be liable for any
  special, indirect or consequential damages or any damages
  whatsoever resulting from loss of use, data or profits, whether
  in an action of contract, negligence or other tortious action,
  arising out of or in connection with the use or performance of
  this software.
*/

#include "../../HighLevel/USBMode.h"
#if defined(USB_CAN_BE_HOST)

#define  INCLUDE_FROM_RNDIS_CLASS_HOST_C
#include "RNDIS.h"

uint8_t RNDIS_Host_ConfigurePipes(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo, uint16_t ConfigDescriptorSize,
                                void* ConfigDescriptorData)
{
	uint8_t FoundEndpoints = 0;

	memset(&RNDISInterfaceInfo->State, 0x00, sizeof(RNDISInterfaceInfo->State));

	if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration)
	  return RNDIS_ENUMERROR_InvalidConfigDescriptor;

	if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
	                              DComp_RNDIS_Host_NextRNDISControlInterface) != DESCRIPTOR_SEARCH_COMP_Found)
	{
		return RNDIS_ENUMERROR_NoRNDISInterfaceFound;
	}

	RNDISInterfaceInfo->State.ControlInterfaceNumber = DESCRIPTOR_CAST(ConfigDescriptorData, USB_Descriptor_Interface_t).InterfaceNumber;

	while (FoundEndpoints != (RNDIS_FOUND_NOTIFICATION_IN | RNDIS_FOUND_DATAPIPE_IN | RNDIS_FOUND_DATAPIPE_OUT))
	{
		if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
		                              DComp_RNDIS_Host_NextRNDISInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
		{
			if (FoundEndpoints & RNDIS_FOUND_NOTIFICATION_IN)
			{
				if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
				                              DComp_RNDIS_Host_NextRNDISDataInterface) != DESCRIPTOR_SEARCH_COMP_Found)
				{
					return RNDIS_ENUMERROR_NoRNDISInterfaceFound;
				}
			}
			else
			{
				FoundEndpoints = 0;

				Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataINPipeNumber);
				Pipe_DisablePipe();
				Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataOUTPipeNumber);
				Pipe_DisablePipe();
				Pipe_SelectPipe(RNDISInterfaceInfo->Config.NotificationPipeNumber);
				Pipe_DisablePipe();

				if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
				                              DComp_RNDIS_Host_NextRNDISControlInterface) != DESCRIPTOR_SEARCH_COMP_Found)
				{
					return RNDIS_ENUMERROR_NoRNDISInterfaceFound;
				}
			}

			if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
			                              DComp_RNDIS_Host_NextRNDISInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
			{
				return RNDIS_ENUMERROR_EndpointsNotFound;
			}
		}

		USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);

		if ((EndpointData->Attributes & EP_TYPE_MASK) == EP_TYPE_INTERRUPT)
		{
			if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
			{
				Pipe_ConfigurePipe(RNDISInterfaceInfo->Config.NotificationPipeNumber, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN,
								   EndpointData->EndpointAddress, EndpointData->EndpointSize,
								   RNDISInterfaceInfo->Config.NotificationPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
				RNDISInterfaceInfo->State.NotificationPipeSize = EndpointData->EndpointSize;

				Pipe_SetInterruptPeriod(EndpointData->PollingIntervalMS);

				FoundEndpoints |= RNDIS_FOUND_NOTIFICATION_IN;
			}
		}
		else
		{
			if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
			{
				if (Pipe_IsEndpointBound(EndpointData->EndpointAddress))
				{
					RNDISInterfaceInfo->State.BidirectionalDataEndpoints = true;
					Pipe_DisablePipe();
				}

				Pipe_ConfigurePipe(RNDISInterfaceInfo->Config.DataINPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_IN,
				                   EndpointData->EndpointAddress, EndpointData->EndpointSize,
				                   RNDISInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
				RNDISInterfaceInfo->State.DataINPipeSize = EndpointData->EndpointSize;

				FoundEndpoints |= RNDIS_FOUND_DATAPIPE_IN;
			}
			else
			{
				if (Pipe_IsEndpointBound(EndpointData->EndpointAddress))
				{
					RNDISInterfaceInfo->State.BidirectionalDataEndpoints = true;
				}
				else
				{
					Pipe_ConfigurePipe(RNDISInterfaceInfo->Config.DataOUTPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_OUT,
					                   EndpointData->EndpointAddress, EndpointData->EndpointSize,
					                   RNDISInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
				}

				RNDISInterfaceInfo->State.DataOUTPipeSize = EndpointData->EndpointSize;

				FoundEndpoints |= RNDIS_FOUND_DATAPIPE_OUT;
			}
		}
	}

	RNDISInterfaceInfo->State.IsActive = true;
	return RNDIS_ENUMERROR_NoError;
}

static uint8_t DComp_RNDIS_Host_NextRNDISControlInterface(void* const CurrentDescriptor)
{
	if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
	{
		USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
		                                                                USB_Descriptor_Interface_t);

		if ((CurrentInterface->Class    == RNDIS_CONTROL_CLASS)    &&
		    (CurrentInterface->SubClass == RNDIS_CONTROL_SUBCLASS) &&
			(CurrentInterface->Protocol == RNDIS_CONTROL_PROTOCOL))
		{
			return DESCRIPTOR_SEARCH_Found;
		}
	}

	return DESCRIPTOR_SEARCH_NotFound;
}

static uint8_t DComp_RNDIS_Host_NextRNDISDataInterface(void* const CurrentDescriptor)
{
	if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
	{
		USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
		                                                                USB_Descriptor_Interface_t);

		if ((CurrentInterface->Class    == RNDIS_DATA_CLASS)    &&
		    (CurrentInterface->SubClass == RNDIS_DATA_SUBCLASS) &&
			(CurrentInterface->Protocol == RNDIS_DATA_PROTOCOL))
		{
			return DESCRIPTOR_SEARCH_Found;
		}
	}

	return DESCRIPTOR_SEARCH_NotFound;
}

static uint8_t DComp_RNDIS_Host_NextRNDISInterfaceEndpoint(void* const CurrentDescriptor)
{
	if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
	{
		USB_Descriptor_Endpoint_t* CurrentEndpoint = DESCRIPTOR_PCAST(CurrentDescriptor,
		                                                              USB_Descriptor_Endpoint_t);

		uint8_t EndpointType = (CurrentEndpoint->Attributes & EP_TYPE_MASK);

		if ((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT))
		{
			return DESCRIPTOR_SEARCH_Found;
		}
	}
	else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
	{
		return DESCRIPTOR_SEARCH_Fail;
	}

	return DESCRIPTOR_SEARCH_NotFound;
}

void RNDIS_Host_USBTask(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo)
{
	(void)RNDISInterfaceInfo;
}

static uint8_t RNDIS_SendEncapsulatedCommand(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo,
                                             void* Buffer, uint16_t Length)
{
	USB_ControlRequest = (USB_Request_Header_t)
		{
			.bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),
			.bRequest      = REQ_SendEncapsulatedCommand,
			.wValue        = 0,
			.wIndex        = RNDISInterfaceInfo->State.ControlInterfaceNumber,
			.wLength       = Length,
		};

	Pipe_SelectPipe(PIPE_CONTROLPIPE);
	return USB_Host_SendControlRequest(Buffer);
}

static uint8_t RNDIS_GetEncapsulatedResponse(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo,
                                             void* Buffer, uint16_t Length)
{
	USB_ControlRequest = (USB_Request_Header_t)
		{
			.bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),
			.bRequest      = REQ_GetEncapsulatedResponse,
			.wValue        = 0,
			.wIndex        = RNDISInterfaceInfo->State.ControlInterfaceNumber,
			.wLength       = Length,
		};

	Pipe_SelectPipe(PIPE_CONTROLPIPE);
	return USB_Host_SendControlRequest(Buffer);
}

uint8_t RNDIS_Host_SendKeepAlive(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo)
{
	uint8_t ErrorCode;

	RNDIS_KeepAlive_Message_t  KeepAliveMessage;
	RNDIS_KeepAlive_Complete_t KeepAliveMessageResponse;

	KeepAliveMessage.MessageType     = REMOTE_NDIS_KEEPALIVE_MSG;
	KeepAliveMessage.MessageLength   = sizeof(RNDIS_KeepAlive_Message_t);
	KeepAliveMessage.RequestId       = RNDISInterfaceInfo->State.RequestID++;

	if ((ErrorCode = RNDIS_SendEncapsulatedCommand(RNDISInterfaceInfo, &KeepAliveMessage,
	                                               sizeof(RNDIS_KeepAlive_Message_t))) != HOST_SENDCONTROL_Successful)
	{
		return ErrorCode;
	}

	if ((ErrorCode = RNDIS_GetEncapsulatedResponse(RNDISInterfaceInfo, &KeepAliveMessageResponse,
	                                               sizeof(RNDIS_KeepAlive_Complete_t))) != HOST_SENDCONTROL_Successful)
	{
		return ErrorCode;
	}

	return HOST_SENDCONTROL_Successful;
}

uint8_t RNDIS_Host_InitializeDevice(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo)
{
	uint8_t ErrorCode;

	RNDIS_Initialize_Message_t  InitMessage;
	RNDIS_Initialize_Complete_t InitMessageResponse;

	InitMessage.MessageType     = REMOTE_NDIS_INITIALIZE_MSG;
	InitMessage.MessageLength   = sizeof(RNDIS_Initialize_Message_t);
	InitMessage.RequestId       = RNDISInterfaceInfo->State.RequestID++;

	InitMessage.MajorVersion    = REMOTE_NDIS_VERSION_MAJOR;
	InitMessage.MinorVersion    = REMOTE_NDIS_VERSION_MINOR;
	InitMessage.MaxTransferSize = RNDISInterfaceInfo->Config.HostMaxPacketSize;

	if ((ErrorCode = RNDIS_SendEncapsulatedCommand(RNDISInterfaceInfo, &InitMessage,
	                                               sizeof(RNDIS_Initialize_Message_t))) != HOST_SENDCONTROL_Successful)
	{
		return ErrorCode;
	}

	if ((ErrorCode = RNDIS_GetEncapsulatedResponse(RNDISInterfaceInfo, &InitMessageResponse,
	                                               sizeof(RNDIS_Initialize_Complete_t))) != HOST_SENDCONTROL_Successful)
	{
		return ErrorCode;
	}

	if (InitMessageResponse.Status != REMOTE_NDIS_STATUS_SUCCESS)
	  return RNDIS_COMMAND_FAILED;

	RNDISInterfaceInfo->State.DeviceMaxPacketSize = InitMessageResponse.MaxTransferSize;

	return HOST_SENDCONTROL_Successful;
}

uint8_t RNDIS_Host_SetRNDISProperty(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo, uint32_t Oid, void* Buffer, uint16_t Length)
{
	uint8_t ErrorCode;

	struct
	{
		RNDIS_Set_Message_t SetMessage;
		uint8_t             ContigiousBuffer[Length];
	} SetMessageData;

	RNDIS_Set_Complete_t SetMessageResponse;

	SetMessageData.SetMessage.MessageType    = REMOTE_NDIS_SET_MSG;
	SetMessageData.SetMessage.MessageLength  = sizeof(RNDIS_Set_Message_t) + Length;
	SetMessageData.SetMessage.RequestId      = RNDISInterfaceInfo->State.RequestID++;

	SetMessageData.SetMessage.Oid            = Oid;
	SetMessageData.SetMessage.InformationBufferLength = Length;
	SetMessageData.SetMessage.InformationBufferOffset = (sizeof(RNDIS_Set_Message_t) - sizeof(RNDIS_Message_Header_t));
	SetMessageData.SetMessage.DeviceVcHandle = 0;

	memcpy(&SetMessageData.ContigiousBuffer, Buffer, Length);

	if ((ErrorCode = RNDIS_SendEncapsulatedCommand(RNDISInterfaceInfo, &SetMessageData,
	                                               SetMessageData.SetMessage.MessageLength)) != HOST_SENDCONTROL_Successful)
	{
		return ErrorCode;
	}

	if ((ErrorCode = RNDIS_GetEncapsulatedResponse(RNDISInterfaceInfo, &SetMessageResponse,
	                                               sizeof(RNDIS_Set_Complete_t))) != HOST_SENDCONTROL_Successful)
	{
		return ErrorCode;
	}

	if (SetMessageResponse.Status != REMOTE_NDIS_STATUS_SUCCESS)
	  return RNDIS_COMMAND_FAILED;

	return HOST_SENDCONTROL_Successful;
}

uint8_t RNDIS_Host_QueryRNDISProperty(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo, uint32_t Oid, void* Buffer, uint16_t MaxLength)
{
	uint8_t ErrorCode;

	RNDIS_Query_Message_t QueryMessage;

	struct
	{
		RNDIS_Query_Complete_t QueryMessageResponse;
		uint8_t                ContigiousBuffer[MaxLength];
	} QueryMessageResponseData;

	QueryMessage.MessageType    = REMOTE_NDIS_QUERY_MSG;
	QueryMessage.MessageLength  = sizeof(RNDIS_Query_Message_t);
	QueryMessage.RequestId      = RNDISInterfaceInfo->State.RequestID++;

	QueryMessage.Oid            = Oid;
	QueryMessage.InformationBufferLength = 0;
	QueryMessage.InformationBufferOffset = 0;
	QueryMessage.DeviceVcHandle = 0;

	if ((ErrorCode = RNDIS_SendEncapsulatedCommand(RNDISInterfaceInfo, &QueryMessage,
	                                               sizeof(RNDIS_Query_Message_t))) != HOST_SENDCONTROL_Successful)
	{
		return ErrorCode;
	}

	if ((ErrorCode = RNDIS_GetEncapsulatedResponse(RNDISInterfaceInfo, &QueryMessageResponseData,
	                                               sizeof(QueryMessageResponseData))) != HOST_SENDCONTROL_Successful)
	{
		return ErrorCode;
	}

	if (QueryMessageResponseData.QueryMessageResponse.Status != REMOTE_NDIS_STATUS_SUCCESS)
	  return RNDIS_COMMAND_FAILED;

	memcpy(Buffer, &QueryMessageResponseData.ContigiousBuffer, MaxLength);

	return HOST_SENDCONTROL_Successful;
}

bool RNDIS_Host_IsPacketReceived(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo)
{
	bool PacketWaiting;

	if ((USB_HostState != HOST_STATE_Configured) || !(RNDISInterfaceInfo->State.IsActive))
	  return false;

	Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataINPipeNumber);
	Pipe_SetPipeToken(PIPE_TOKEN_IN);

	Pipe_Unfreeze();

	PacketWaiting = Pipe_IsINReceived();

	Pipe_Freeze();

	return PacketWaiting;
}

uint8_t RNDIS_Host_ReadPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo, void* Buffer, uint16_t* PacketLength)
{
	uint8_t ErrorCode;

	if ((USB_HostState != HOST_STATE_Configured) || !(RNDISInterfaceInfo->State.IsActive))
	  return PIPE_READYWAIT_DeviceDisconnected;

	Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataINPipeNumber);
	Pipe_SetPipeToken(PIPE_TOKEN_IN);
	Pipe_Unfreeze();

	if (!(Pipe_IsReadWriteAllowed()))
	{
		*PacketLength = 0;
		Pipe_Freeze();
		return PIPE_RWSTREAM_NoError;
	}

	RNDIS_Packet_Message_t DeviceMessage;

	if ((ErrorCode = Pipe_Read_Stream_LE(&DeviceMessage, sizeof(RNDIS_Packet_Message_t),
	                                     NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
	{
		return ErrorCode;
	}

	*PacketLength = (uint16_t)DeviceMessage.DataLength;

	Pipe_Discard_Stream(DeviceMessage.DataOffset - (sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t)),
	                    NO_STREAM_CALLBACK);

	Pipe_Read_Stream_LE(Buffer, *PacketLength, NO_STREAM_CALLBACK);
	Pipe_ClearIN();

	Pipe_Freeze();

	return PIPE_RWSTREAM_NoError;
}

uint8_t RNDIS_Host_SendPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo, void* Buffer, uint16_t PacketLength)
{
	uint8_t ErrorCode;

	if ((USB_HostState != HOST_STATE_Configured) || !(RNDISInterfaceInfo->State.IsActive))
	  return PIPE_READYWAIT_DeviceDisconnected;

	if (RNDISInterfaceInfo->State.BidirectionalDataEndpoints)
	{
		Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataINPipeNumber);
		Pipe_SetPipeToken(PIPE_TOKEN_OUT);
	}
	else
	{
		Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataOUTPipeNumber);
	}

	Pipe_Unfreeze();

	RNDIS_Packet_Message_t DeviceMessage;

	DeviceMessage.MessageType = REMOTE_NDIS_PACKET_MSG;
	DeviceMessage.MessageLength = (sizeof(RNDIS_Packet_Message_t) + PacketLength);
	DeviceMessage.DataOffset = (sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t));
	DeviceMessage.DataLength = PacketLength;

	if ((ErrorCode = Pipe_Write_Stream_LE(&DeviceMessage, sizeof(RNDIS_Packet_Message_t),
	                                      NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
	{
		return ErrorCode;
	}

	Pipe_Write_Stream_LE(Buffer, PacketLength, NO_STREAM_CALLBACK);
	Pipe_ClearOUT();

	Pipe_Freeze();

	if (RNDISInterfaceInfo->State.BidirectionalDataEndpoints)
	  Pipe_SetPipeToken(PIPE_TOKEN_IN);

	return PIPE_RWSTREAM_NoError;
}

#endif


text:
(function(){
    'use strict';

    angular.module('validationrule').directive('vr-match', [
        function () {
            return {
                require: 'ngModel',
                restrict: 'A',
                scope: {
                    match: '='
                },
                link: function (scope, elem, attrs, ctrl) {
                    scope.$watch(function () {
                        var modelValue = ctrl.$modelValue || ctrl.$$invalidModelValue;
                        return (ctrl.$pristine && angular.isUndefined(modelValue)) || scope.match === modelValue;
                    }, function (currentValue) {
                        ctrl.$setValidity('match', currentValue);
                    });
                }
            };
        }
    ]);

}).call(this);

redpajama_set_name: RedPajamaGithub


text:
package com.baidu.unbiz.multitask.task.thread;

import java.util.Map;
import java.util.concurrent.CompletionService;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.baidu.unbiz.multitask.exception.TaskTimeoutException;

/**
 * 一组工作单元,可视为一组原子操作
 *
 * @author wangchongjie
 * @since 2015-12-3 下午3:56:36
 */
public class WorkUnit {

    private static final Log LOG = LogFactory.getLog(TaskManager.class);

    private CompletionService<Void> completion;
    private Map<Future<?>, Runnable> futureMap = new ConcurrentHashMap<Future<?>, Runnable>();
    private int taskCount;
    private Thread parentThread;

    /**
     * 构造函数,线程池委托给调用方
     *
     * @param pool
     */
    public WorkUnit(Executor pool) {
        parentThread = Thread.currentThread();
        completion = new ExecutorCompletionService<Void>(pool);
    }

    /**
     * 提交可并行的任务
     *
     * @param runnable
     */
    public void submit(Runnable runnable) {
        futureMap.put(completion.submit(runnable, null), runnable);
        taskCount++;
    }

    /**
     * 等待结果返回,带默认超时时间
     */
    public void waitForCompletion() {
        this.waitForCompletion(TaskManager.config().taskTimeoutMillSeconds());
    }

    /**
     * 等待结果返回,显示指定超时时间,若超时则取消任务并释放资源
     */
    public void waitForCompletion(long timeoutMillSeconds) {
        for (int i = 0; i < taskCount; i++) {
            Future<Void> future;
            try {
                long timeout =
                        timeoutMillSeconds > 0 ? timeoutMillSeconds : TaskManager.config().taskTimeoutMillSeconds();
                future = completion.poll(timeout, TimeUnit.MILLISECONDS);
            } catch (InterruptedException e) {
                LOG.error("wait for execute completion failed,e=" + e, e);
                throw new TaskTimeoutException(e);
            }

            if (future == null) {
                this.cancelAllTask();
                String errMsg = "wait for execute completion timeout: ";
                LOG.error(errMsg + this.futureInfo());
                this.cleanResource();
                throw new TaskTimeoutException(errMsg);
            } else {
                futureMap.remove(future);
            }
        }
        // 此处将Java引用置为null,JVM GC时能尽快回收,非操作系统层面的资源释放。
        // 未调用或未调用成功对系统及资源释放无影响,当前线程执行完后,JVM仍可回收。
        this.cleanResource();
    }

    /**
     * 取消所有任务
     */
    private void cancelAllTask() {
        for (Future<?> future : futureMap.keySet()) {
            boolean isCancel = future.cancel(true);
            LOG.info("cancel task success: " + isCancel + ": " + futureMap.get(future));
        }
    }

    /**
     * 任务信息,供异常时打印堆栈信息
     *
     * @return 全部任务信息
     */
    private String futureInfo() {
        StringBuilder sb = new StringBuilder();
        for (Runnable task : futureMap.values()) {
            sb.append(task.toString());
        }
        return sb.toString();
    }

    /**
     * 释放资源,供JVM回收
     */
    private void cleanResource() {
        this.futureMap = null;
        this.completion = null;
    }

}


text:
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/tcp.h>

#include "local.h"
#include "socks5.h"

#define ADDR_STR_LEN 512

#define SAVED_STR_LEN 512

char _server[SAVED_STR_LEN];
char _remote_port[SAVED_STR_LEN];
char _method[SAVED_STR_LEN];
char _password[SAVED_STR_LEN];

int setnonblocking(int fd) {
    int flags;
    if (-1 ==(flags = fcntl(fd, F_GETFL, 0)))
        flags = 0;
    return fcntl(fd, F_SETFL, flags | O_NONBLOCK);
}

int create_and_bind(const char *port) {
    struct addrinfo hints;
    struct addrinfo *result, *rp;
    int s, listen_sock = 0;

    memset(&hints, 0, sizeof(struct addrinfo));
    hints.ai_family = AF_UNSPEC; /* Return IPv4 and IPv6 choices */
    hints.ai_socktype = SOCK_STREAM; /* We want a TCP socket */

    s = getaddrinfo("127.0.0.1", port, &hints, &result);
    if (s != 0) {
        NSLog(@"getaddrinfo: %s", gai_strerror(s));
        return -1;
    }

    for (rp = result; rp != NULL; rp = rp->ai_next) {
        listen_sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
        int opt = 1;
        setsockopt(listen_sock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
        setsockopt(listen_sock, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(opt));
        setsockopt(listen_sock, SOL_SOCKET, SO_NOSIGPIPE, &opt, sizeof(opt));
        if (listen_sock == -1)
            continue;

        s = bind(listen_sock, rp->ai_addr, rp->ai_addrlen);
        if (s == 0) {
            /* We managed to bind successfully! */
            break;
        } else {
            perror("bind");
        }

        close(listen_sock);
    }

    if (rp == NULL) {
        NSLog(@"Could not bind");
        return -1;
    }

    freeaddrinfo(result);

    return listen_sock;
}

static void server_recv_cb (EV_P_ ev_io *w, int revents) {
	struct server_ctx *server_recv_ctx = (struct server_ctx *)w;
	struct server *server = server_recv_ctx->server;
	struct remote *remote = server->remote;
//    NSLog(@"server_recv_cb %d", server?server->stage:-1);

    if (remote == NULL) {
        close_and_free_server(EV_A_ server);
        return;
    }

    char *buf = remote->buf;
    size_t *buf_len = &remote->buf_len;
    if (server->stage != 5) {
        buf = server->buf;
        buf_len = &server->buf_len;
    }

    ssize_t r = recv(server->fd, buf, BUF_SIZE, 0);

    if (r == 0) {
        // connection closed
        *buf_len = 0;
        close_and_free_server(EV_A_ server);
        if (remote != NULL) {
            ev_io_start(EV_A_ &remote->send_ctx->io);
        }
        return;
    } else if(r < 0) {
        if (errno == EAGAIN || errno == EWOULDBLOCK) {
            // no data
            // continue to wait for recv
            return;
        } else {
            perror("server recv");
            close_and_free_server(EV_A_ server);
            close_and_free_remote(EV_A_ remote);
            return;
        }
    }

    // local socks5 server
    if (server->stage == 5) {
        encrypt_buf(&(remote->send_encryption_ctx), (unsigned char *)remote->buf, (size_t *)&r);
        ssize_t w = send(remote->fd, remote->buf, (size_t)r, 0);
        if(w == -1) {
            if (errno == EAGAIN || errno == EWOULDBLOCK) {
                remote->buf_len = (size_t)r;
                // no data, wait for send
                ev_io_stop(EV_A_ &server_recv_ctx->io);
                ev_io_start(EV_A_ &remote->send_ctx->io);
                return;
            } else {
                perror("send");
                close_and_free_server(EV_A_ server);
                close_and_free_remote(EV_A_ remote);
                return;
            }
        } else if(w < r) {
            char *pt = remote->buf;
            char *et = pt + r;
            while (pt + w < et) {
                *pt = *(pt + w);
                pt++;
            }
            remote->buf_len = (size_t)r - w;
            ev_io_stop(EV_A_ &server_recv_ctx->io);
            ev_io_start(EV_A_ &remote->send_ctx->io);
            return;
        }
    } else if (server->stage == 0) {
        struct method_select_response response;
        response.ver = SOCKS_VERSION;
        response.method = 0;
        char *send_buf = (char *)&response;
        send(server->fd, send_buf, sizeof(response), 0);
        server->stage = 1;
        return;
    } else if (server->stage == 1) {
        struct socks5_request *request = (struct socks5_request *)server->buf;

        if (request->cmd != SOCKS_CMD_CONNECT) {
            NSLog(@"unsupported cmd: %d\n", request->cmd);
            struct socks5_response response;
            response.ver = SOCKS_VERSION;
            response.rep = SOCKS_CMD_NOT_SUPPORTED;
            response.rsv = 0;
            response.atyp = SOCKS_IPV4;
            char *send_buf = (char *)&response;
            send(server->fd, send_buf, 4, 0);
            close_and_free_server(EV_A_ server);
            close_and_free_remote(EV_A_ remote);
            return;
        }

        char addr_to_send[ADDR_STR_LEN];
        size_t addr_len = 0;
        addr_to_send[addr_len++] = request->atyp;

        char addr_str[ADDR_STR_LEN];
        // get remote addr and port
        if (request->atyp == SOCKS_IPV4) {

            // IP V4
            size_t in_addr_len = sizeof(struct in_addr);
            memcpy(addr_to_send + addr_len, server->buf + 4, in_addr_len + 2);
            addr_len += in_addr_len + 2;
//                addr_to_send[addr_len] = 0;

            // now get it back and print it
            inet_ntop(AF_INET, server->buf + 4, addr_str, ADDR_STR_LEN);

//#if !TARGET_OS_IPHONE
            NSLog(@"Connecting an IPv4 address, please configure your browser to use hostname instead: https://github.com/clowwindy/shadowsocks/wiki/Troubleshooting");
//#endif
        } else if (request->atyp == SOCKS_DOMAIN) {
            // Domain name
            unsigned char name_len = *(unsigned char *)(server->buf + 4);
            addr_to_send[addr_len++] = name_len;
            memcpy(addr_to_send + addr_len, server->buf + 4 + 1, name_len);
            memcpy(addr_str, server->buf + 4 + 1, name_len);
            addr_str[name_len] = '\0';
            addr_len += name_len;

            // get port
            addr_to_send[addr_len++] = *(unsigned char *)(server->buf + 4 + 1 + name_len);
            addr_to_send[addr_len++] = *(unsigned char *)(server->buf + 4 + 1 + name_len + 1);
//                addr_to_send[addr_len] = 0;

//#if !TARGET_OS_IPHONE
            char temp[256];
            memcpy(temp, server->buf + 4 + 1, name_len);
            temp[name_len] = '\0';
            NSLog(@"Connecting %@", [NSString stringWithCString:addr_str encoding:NSUTF8StringEncoding]);
//#endif
        } else {
            NSLog(@"unsupported addrtype: %d\n", request->atyp);
            close_and_free_server(EV_A_ server);
            close_and_free_remote(EV_A_ remote);
            return;
        }

        int n = send_encrypt(&(remote->send_encryption_ctx), remote->fd, (unsigned char *)addr_to_send, &addr_len, 0);
        if (n != addr_len) {
            NSLog(@"header not completely sent: n != addr_len: n==%d, addr_len==%d", n, (int)addr_len);
            close_and_free_remote(EV_A_ remote);
            close_and_free_server(EV_A_ server);
            return;
        }

        // Fake reply
        struct socks5_response response;
        response.ver = SOCKS_VERSION;
        response.rep = 0;
        response.rsv = 0;
        response.atyp = SOCKS_IPV4;

        struct in_addr sin_addr;
        inet_aton("0.0.0.0", &sin_addr);

        memcpy(server->buf, &response, 4);
        memcpy(server->buf + 4, &sin_addr, sizeof(struct in_addr));
        *((unsigned short *)(server->buf + 4 + sizeof(struct in_addr)))
            = (unsigned short) htons(atoi(_remote_port));

        size_t reply_size = 4 + sizeof(struct in_addr) + sizeof(unsigned short);
        ssize_t r = send(server->fd, server->buf, reply_size, 0);
        if (r < reply_size) {
            NSLog(@"header not complete sent\n");
            close_and_free_remote(EV_A_ remote);
            close_and_free_server(EV_A_ server);
            return;
        }

        ev_io_start(EV_A_ &remote->recv_ctx->io);

        server->stage = 5;
	}
}

static void server_send_cb (EV_P_ ev_io *w, int revents) {
	struct server_ctx *server_send_ctx = (struct server_ctx *)w;
	struct server *server = server_send_ctx->server;
	struct remote *remote = server->remote;
	if (server->buf_len == 0) {
		// close and free
		close_and_free_server(EV_A_ server);
		close_and_free_remote(EV_A_ remote);
		return;
	} else {
		// has data to send
		ssize_t r = send(server->fd, server->buf,
				server->buf_len, 0);
		if (r < 0) {
			if (errno != EAGAIN && errno != EWOULDBLOCK) {
                perror("send");
				close_and_free_server(EV_A_ server);
				close_and_free_remote(EV_A_ remote);
				return;
			}
			return;
		}
		if (r < server->buf_len) {
			// partly sent, move memory, wait for the next time to send
			char *pt = server->buf;
            char *et = pt + server->buf_len;
            while (pt + r < et) {
				*pt = *(pt + r);
                pt++;
			}
			server->buf_len -= r;
			return;
		} else {
			// all sent out, wait for reading
            server->buf_len = 0;
			ev_io_stop(EV_A_ &server_send_ctx->io);
			if (remote != NULL) {
				ev_io_start(EV_A_ &remote->recv_ctx->io);
			} else {
				close_and_free_server(EV_A_ server);
				close_and_free_remote(EV_A_ remote);
				return;
			}
		}
	}

}

static void remote_recv_cb (EV_P_ ev_io *w, int revents) {
	struct remote_ctx *remote_recv_ctx = (struct remote_ctx *)w;
	struct remote *remote = remote_recv_ctx->remote;
	struct server *server = remote->server;
	if (server == NULL) {
		close_and_free_remote(EV_A_ remote);
		return;
	}
    ssize_t r = recv(remote->fd, server->buf, BUF_SIZE, 0);

    if (r == 0) {
        // connection closed
        server->buf_len = 0;
        close_and_free_remote(EV_A_ remote);
        if (server != NULL) {
            ev_io_start(EV_A_ &server->send_ctx->io);
        }
        return;
    } else if(r < 0) {
        if (errno == EAGAIN || errno == EWOULDBLOCK) {
            // no data
            // continue to wait for recv
            return;
        } else {
            perror("remote recv");
            close_and_free_server(EV_A_ server);
            close_and_free_remote(EV_A_ remote);
            return;
        }
    }
    decrypt_buf(&(remote->recv_encryption_ctx), (unsigned char *)server->buf, (size_t*)&r);
    ssize_t s = send(server->fd, server->buf, (size_t)r, 0);
    if(s == -1) {
        if (errno == EAGAIN || errno == EWOULDBLOCK) {
            server->buf_len = (size_t)r;
            // no data, wait for send
            ev_io_stop(EV_A_ &remote_recv_ctx->io);
            ev_io_start(EV_A_ &server->send_ctx->io);
            return;
        } else {
            perror("send");
            close_and_free_server(EV_A_ server);
            close_and_free_remote(EV_A_ remote);
            return;
        }
    } else if(s < r) {
        char *pt = server->buf;
        char *et = pt + r;
        while (pt + s < et) {
            *pt = *(pt + s);
            pt++;
        }
        server->buf_len = (size_t)r - s;
        ev_io_stop(EV_A_ &remote_recv_ctx->io);
        ev_io_start(EV_A_ &server->send_ctx->io);
        return;
    }
}

static void remote_send_cb (EV_P_ ev_io *w, int revents) {
	struct remote_ctx *remote_send_ctx = (struct remote_ctx *)w;
	struct remote *remote = remote_send_ctx->remote;
	struct server *server = remote->server;

	if (!remote_send_ctx->connected) {

		socklen_t len;
		struct sockaddr_storage addr;
		len = sizeof addr;
		int r = getpeername(remote->fd, (struct sockaddr*)&addr, &len);
		if (r == 0) {
			remote_send_ctx->connected = 1;
			ev_io_stop(EV_A_ &remote_send_ctx->io);
			ev_io_start(EV_A_ &server->recv_ctx->io);
		} else {
			perror("getpeername");
			// not connected
			close_and_free_remote(EV_A_ remote);
			close_and_free_server(EV_A_ server);
			return;
		}
	} else {
		if (remote->buf_len == 0) {
			// close and free
			close_and_free_remote(EV_A_ remote);
			close_and_free_server(EV_A_ server);
			return;
		} else {
			// has data to send
			ssize_t r = send(remote->fd, remote->buf,
					remote->buf_len, 0);
			if (r < 0) {
				if (errno != EAGAIN && errno != EWOULDBLOCK) {
                    perror("send");
					// close and free
					close_and_free_remote(EV_A_ remote);
					close_and_free_server(EV_A_ server);
					return;
				}
				return;
			}
			if (r < remote->buf_len) {
				// partly sent, move memory, wait for the next time to send
                char *pt = remote->buf;
                char *et = pt + remote->buf_len;
                while (pt + r < et) {
                    *pt = *(pt + r);
                    pt++;
                }
				remote->buf_len -= r;
				return;
			} else {
				// all sent out, wait for reading
				ev_io_stop(EV_A_ &remote_send_ctx->io);
				if (server != NULL) {
					ev_io_start(EV_A_ &server->recv_ctx->io);
				} else {
					close_and_free_remote(EV_A_ remote);
					close_and_free_server(EV_A_ server);
					return;
				}
			}
		}

	}
}

struct remote* new_remote(int fd) {
	struct remote *remote;
	remote = malloc(sizeof(struct remote));
	remote->fd = fd;
    remote->buf_len = 0;
	remote->recv_ctx = malloc(sizeof(struct remote_ctx));
	remote->send_ctx = malloc(sizeof(struct remote_ctx));
	ev_io_init(&remote->recv_ctx->io, remote_recv_cb, fd, EV_READ);
	ev_io_init(&remote->send_ctx->io, remote_send_cb, fd, EV_WRITE);
	remote->recv_ctx->remote = remote;
	remote->recv_ctx->connected = 0;
	remote->send_ctx->remote = remote;
	remote->send_ctx->connected = 0;
    remote->server = NULL;
    init_encryption(&(remote->recv_encryption_ctx));
    init_encryption(&(remote->send_encryption_ctx));
	return remote;
}
void free_remote(struct remote *remote) {
	if (remote != NULL) {
		if (remote->server != NULL) {
			remote->server->remote = NULL;
		}
		free(remote->recv_ctx);
		free(remote->send_ctx);
        cleanup_encryption(&(remote->recv_encryption_ctx));
        cleanup_encryption(&(remote->send_encryption_ctx));
		free(remote);
	}
}
void close_and_free_remote(EV_P_ struct remote *remote) {
	if (remote != NULL) {
		ev_io_stop(EV_A_ &remote->send_ctx->io);
		ev_io_stop(EV_A_ &remote->recv_ctx->io);
		close(remote->fd);
		free_remote(remote);
	}
}
struct server* new_server(int fd) {
	struct server *server;
	server = malloc(sizeof(struct server));
	server->fd = fd;
    server->buf_len = 0;
	server->recv_ctx = malloc(sizeof(struct server_ctx));
	server->send_ctx = malloc(sizeof(struct server_ctx));
	ev_io_init(&server->recv_ctx->io, server_recv_cb, fd, EV_READ);
	ev_io_init(&server->send_ctx->io, server_send_cb, fd, EV_WRITE);
	server->recv_ctx->server = server;
	server->recv_ctx->connected = 0;
	server->send_ctx->server = server;
	server->send_ctx->connected = 0;
    server->stage = 0;
    server->remote = NULL;
	return server;
}
void free_server(struct server *server) {
	if (server != NULL) {
		if (server->remote != NULL) {
			server->remote->server = NULL;
		}
		free(server->recv_ctx);
		free(server->send_ctx);
		free(server);
	}
}
void close_and_free_server(EV_P_ struct server *server) {
	if (server != NULL) {
		ev_io_stop(EV_A_ &server->send_ctx->io);
		ev_io_stop(EV_A_ &server->recv_ctx->io);
		close(server->fd);
		free_server(server);
	}
}
static void accept_cb (EV_P_ ev_io *w, int revents)
{
	struct listen_ctx *listener = (struct listen_ctx *)w;
	int serverfd;
	while (1) {
		serverfd = accept(listener->fd, NULL, NULL);
		if (serverfd == -1) {
            if (errno != EAGAIN && errno != EWOULDBLOCK) {
                perror("accept");
            }
			break;
		}
		setnonblocking(serverfd);
        int opt = 1;
        setsockopt(serverfd, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(opt));
        setsockopt(serverfd, SOL_SOCKET, SO_NOSIGPIPE, &opt, sizeof(opt));
		struct server *server = new_server(serverfd);
		struct addrinfo hints, *res;
		int sockfd;
		memset(&hints, 0, sizeof hints);
		hints.ai_family = AF_UNSPEC;
		hints.ai_socktype = SOCK_STREAM;
		int r = getaddrinfo(_server, _remote_port, &hints, &res);
        if (r) {
            fprintf(stderr, "getaddrinfo: %s", gai_strerror(r));
			free_server(server);
			continue;
        }
		sockfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
        setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(opt));
        setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, &opt, sizeof(opt));
		if (sockfd < 0) {
			perror("socket");
			close(sockfd);
			free_server(server);
			continue;
		}
		setnonblocking(sockfd);
		struct remote *remote = new_remote(sockfd);
		server->remote = remote;
		remote->server = server;
		connect(sockfd, res->ai_addr, res->ai_addrlen);
		freeaddrinfo(res);
		// listen to remote connected event
		ev_io_start(EV_A_ &remote->send_ctx->io);
		break;
	}
}

void set_config(const char *server, const char *remote_port, const char* password, const char* method) {
    assert(strlen(server) < SAVED_STR_LEN);
    assert(strlen(remote_port) < SAVED_STR_LEN);
    assert(strlen(password) < SAVED_STR_LEN);
    assert(strlen(method) < SAVED_STR_LEN);
    strcpy(_server, server);
    strcpy(_remote_port, remote_port);
    strcpy(_password, password);
    strcpy(_method, method);
#ifdef DEBUG
    NSLog(@"calculating ciphers");
#endif
    // TODO move to encrypt.m
    config_encryption(password, method);
}

static ev_io *current_io;
int listenfd;

int local_main (const char *port)
{
    listenfd = create_and_bind(port);
    if (listenfd < 0) {
#ifdef DEBUG
        NSLog(@"bind() error..");
#endif
        return 1;
    }
    if (listen(listenfd, SOMAXCONN) == -1) {
        NSLog(@"listen() error.");
        return 1;
    }
#ifdef DEBUG
    NSLog(@"server listening at port %s\n", "41080");
#endif

    setnonblocking(listenfd);
    struct listen_ctx listen_ctx;
    listen_ctx.fd = listenfd;
    struct ev_loop *loop = EV_DEFAULT;
    ev_io_init (&listen_ctx.io, accept_cb, listenfd, EV_READ);
    current_io = &listen_ctx.io;
    ev_io_start (loop, current_io);
    ev_run (loop, 0);
    current_io = NULL;
    return 0;
}

void sd_cancel() {
    if (listenfd >= 0) {
        close(listenfd);
    }
    if (current_io) {
        ev_io_stop(EV_DEFAULT, current_io);
    }
}


text:
assert(not pcall(function() name(mpz(10)) end))
assert(not pcall(function() name(function() return 1 end) end))
assert(Const{"x", name("y", 1), 1}:fields() == name("x", "y", 1, 1))
assert(not pcall(function() Const({"x", function() return 1 end}) end))
assert(name("x", 1):hash() == name("x", 1):hash())


text:
ui-autocomplete {
    cursor: text;
    position: relative;
    display: block;
}
ui-autocomplete .ui-autocomplete-suggestions {
    max-height: 20vh;
    overflow: auto;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1;
}
ui-autocomplete .ui-autocomplete-suggestions.ng-enter {
    opacity: 0;
    transition: none;
    max-height: 0;
}
ui-autocomplete .ui-autocomplete-suggestions.ng-leave {
    transition: 300ms ease-in-out;
}
ui-autocomplete .ui-autocomplete-suggestions.ng-leave {
    opacity: 0;
    max-height: 0;
}


text:
fitbit-api-client provides access to Fitbit API. fitbit-api-client supports OAuth 2.0.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'fitbit-api-client', require: 'fitbit'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install fitbit-api-client

## Usage

```ruby
client = Fitbit::Client.new(
  client_id: Settings.fitbit.client_id,
  client_secret: Settings.fitbit.client_secret,
  token: current_user.token,
  refresh_token: current_user.refresh_token,
  expires_at: current_user.expires_at)

p client.activity
```

If token is expired, client uses refresh_token and update tokens.

```ruby
# This client token is expired and refreshed automatically.
p client.activity

# Updated tokens
client.access_token.token
client.access_token.refresh_token
client.access_token.expires_at
```

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/kaorumori/fitbit-api-ruby-client.


text:
import os
import requests
from flask import Flask
from flask import render_template, send_file, send_from_directory
from flask import request
from trello import TrelloApi
from openpyxl import Workbook
from openpyxl.cell import get_column_letter
from openpyxl.style import Color, Fill

app = Flask(__name__)
app.config.from_pyfile('settings.py')
TRELLO_APP_KEY = app.config["TRELLO_APP_KEY"]

@app.route('/test')
def test():
    return app.root_path

@app.route('/')
def index():
    return render_template('index.html', TRELLO_APP_KEY=TRELLO_APP_KEY)

@app.route('/export/', methods=['POST','GET'])
def export():

    token = request.form["token"]
    board_id = request.form["board_id"]

    # Get board lists
    LIST_URL = "https://api.trello.com/1/boards/%s/lists/?key=%s&token=%s" % (board_id, TRELLO_APP_KEY, token)
    r = requests.get(LIST_URL)
    lists_json = r.json()

    #call trello and get cards for the selected board
    # /1/boards/[board_id]/cards/visible
    CARD_URL = "https://api.trello.com/1/boards/%s/cards/visible?members=true&fields=idShort,idList,name,desc,labels,dateLastActivity,shortUrl&member_fields=fullName,username&key=%s&token=%s" % (board_id, TRELLO_APP_KEY, token)
    r = requests.get(CARD_URL)
    cards_json = r.json()

    #start xlsx file
    wb = Workbook(optimized_write = False)
    ws = wb.active
    ws.page_setup.orientation = ws.ORIENTATION_LANDSCAPE
    ws.add_print_title(1)

    #write header row dateLastActivity, shortUrl
    ws.append(["Id", "Status", "Name", "Description", "Labels", "Members", "Updated", "Link"])

    # format headers
    for cell in ws.range("A1:H1")[0]:
        cell.style.font.bold = True

        ws.column_dimensions["A"].width = 6.0
        ws.column_dimensions["B"].width = 15.0
        ws.column_dimensions["C"].width = 30.0
        ws.column_dimensions["D"].width = 30.0
        ws.column_dimensions["E"].width = 10.0
        ws.column_dimensions["F"].width = 30.0
        ws.column_dimensions["G"].width = 14.0
        ws.column_dimensions["H"].width = 27.0

    for card in cards_json:

        ws.append([
            card["idShort"],
            namefromid(card["idList"], lists_json),
            card["name"],
            card["desc"],
            labels(card),
            members(card),
            humandate(card["dateLastActivity"]),
            card["shortUrl"]])

    # store file and send it
    wb.save("%s/temp/trello_board_%s.xlsx" % (app.root_path, board_id))
    return send_from_directory(app.root_path + "/temp","trello_board_%s.xlsx" % board_id, as_attachment=True)

def namefromid(id, list):
    item = [el for el in list if el["id"] == id][0]
    return item["name"]

def members(card):
    return ", ".join([member["fullName"] for member in card["members"]])

def labels(card):
    return ", ".join([label["name"] for label in card["labels"]])

def humandate(iso_date):
    return "%s %s" % (iso_date.split("T")[0], iso_date.split("T")[1][0:5])

if __name__ == '__main__':
    app.run(debug=False)


text:
namespace v8 {
namespace internal {

const char* StringRepeatBuiltinsFromDSLAssembler::kBuiltinName() {
  compiler::CodeAssemblerParameterizedLabel<> block0(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
    ca_.Goto(&block0);

    ca_.Bind(&block0);
return "String.prototype.repeat";
}

TF_BUILTIN(StringRepeat, CodeStubAssembler) {
  compiler::CodeAssemblerState* state_ = state();  compiler::CodeAssembler ca_(state());
  TNode<Context> parameter0 = UncheckedCast<Context>(Parameter(Descriptor::kContext));
  USE(parameter0);
  compiler::TNode<String> parameter1 = UncheckedCast<String>(Parameter(Descriptor::kString));
  USE(parameter1);
  compiler::TNode<Smi> parameter2 = UncheckedCast<Smi>(Parameter(Descriptor::kCount));
  USE(parameter2);
  compiler::CodeAssemblerParameterizedLabel<Context, String, Smi> block0(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, String, Smi> block2(&ca_, compiler::CodeAssemblerLabel::kDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, String, Smi> block1(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, String, Smi> block4(&ca_, compiler::CodeAssemblerLabel::kDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, String, Smi> block3(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, String, Smi, String, String, IntPtrT> block7(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, String, Smi, String, String, IntPtrT> block5(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, String, Smi, String, String, IntPtrT> block8(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, String, Smi, String, String, IntPtrT> block9(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, String, Smi, String, String, IntPtrT> block10(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, String, Smi, String, String, IntPtrT> block11(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, String, Smi, String, String, IntPtrT> block6(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
    ca_.Goto(&block0, parameter0, parameter1, parameter2);

  if (block0.is_used()) {
    compiler::TNode<Context> tmp0;
    compiler::TNode<String> tmp1;
    compiler::TNode<Smi> tmp2;
    ca_.Bind(&block0, &tmp0, &tmp1, &tmp2);
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 10);
    compiler::TNode<Smi> tmp3;
    USE(tmp3);
    tmp3 = ca_.UncheckedCast<Smi>(BaseBuiltinsFromDSLAssembler(state_).FromConstexpr5ATSmi17ATconstexpr_int31(0));
    compiler::TNode<BoolT> tmp4;
    USE(tmp4);
    tmp4 = ca_.UncheckedCast<BoolT>(CodeStubAssembler(state_).SmiGreaterThanOrEqual(compiler::TNode<Smi>{tmp2}, compiler::TNode<Smi>{tmp3}));
    ca_.Branch(tmp4, &block1, &block2, tmp0, tmp1, tmp2);
  }

  if (block2.is_used()) {
    compiler::TNode<Context> tmp5;
    compiler::TNode<String> tmp6;
    compiler::TNode<Smi> tmp7;
    ca_.Bind(&block2, &tmp5, &tmp6, &tmp7);
    CodeStubAssembler(state_).FailAssert("Torque assert \'count >= 0\' failed", "../../src/builtins/string-repeat.tq", 10);
  }

  if (block1.is_used()) {
    compiler::TNode<Context> tmp8;
    compiler::TNode<String> tmp9;
    compiler::TNode<Smi> tmp10;
    ca_.Bind(&block1, &tmp8, &tmp9, &tmp10);
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 11);
    compiler::TNode<String> tmp11;
    USE(tmp11);
    tmp11 = BaseBuiltinsFromDSLAssembler(state_).kEmptyString();
    compiler::TNode<BoolT> tmp12;
    USE(tmp12);
    tmp12 = ca_.UncheckedCast<BoolT>(CodeStubAssembler(state_).WordNotEqual(compiler::TNode<Object>{tmp9}, compiler::TNode<HeapObject>{tmp11}));
    ca_.Branch(tmp12, &block3, &block4, tmp8, tmp9, tmp10);
  }

  if (block4.is_used()) {
    compiler::TNode<Context> tmp13;
    compiler::TNode<String> tmp14;
    compiler::TNode<Smi> tmp15;
    ca_.Bind(&block4, &tmp13, &tmp14, &tmp15);
    CodeStubAssembler(state_).FailAssert("Torque assert \'string != kEmptyString\' failed", "../../src/builtins/string-repeat.tq", 11);
  }

  if (block3.is_used()) {
    compiler::TNode<Context> tmp16;
    compiler::TNode<String> tmp17;
    compiler::TNode<Smi> tmp18;
    ca_.Bind(&block3, &tmp16, &tmp17, &tmp18);
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 13);
    compiler::TNode<String> tmp19;
    USE(tmp19);
    tmp19 = BaseBuiltinsFromDSLAssembler(state_).kEmptyString();
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 14);
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 15);
    compiler::TNode<IntPtrT> tmp20;
    USE(tmp20);
    tmp20 = ca_.UncheckedCast<IntPtrT>(BaseBuiltinsFromDSLAssembler(state_).Convert8ATintptr5ATSmi(compiler::TNode<Smi>{tmp18}));
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 17);
    ca_.Goto(&block7, tmp16, tmp17, tmp18, tmp19, tmp17, tmp20);
  }

  if (block7.is_used()) {
    compiler::TNode<Context> tmp21;
    compiler::TNode<String> tmp22;
    compiler::TNode<Smi> tmp23;
    compiler::TNode<String> tmp24;
    compiler::TNode<String> tmp25;
    compiler::TNode<IntPtrT> tmp26;
    ca_.Bind(&block7, &tmp21, &tmp22, &tmp23, &tmp24, &tmp25, &tmp26);
    compiler::TNode<BoolT> tmp27;
    USE(tmp27);
    tmp27 = ca_.UncheckedCast<BoolT>(BaseBuiltinsFromDSLAssembler(state_).FromConstexpr6ATbool16ATconstexpr_bool(true));
    ca_.Branch(tmp27, &block5, &block6, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26);
  }

  if (block5.is_used()) {
    compiler::TNode<Context> tmp28;
    compiler::TNode<String> tmp29;
    compiler::TNode<Smi> tmp30;
    compiler::TNode<String> tmp31;
    compiler::TNode<String> tmp32;
    compiler::TNode<IntPtrT> tmp33;
    ca_.Bind(&block5, &tmp28, &tmp29, &tmp30, &tmp31, &tmp32, &tmp33);
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 18);
    compiler::TNode<IntPtrT> tmp34;
    USE(tmp34);
    tmp34 = ca_.UncheckedCast<IntPtrT>(BaseBuiltinsFromDSLAssembler(state_).FromConstexpr8ATintptr17ATconstexpr_int31(1));
    compiler::TNode<IntPtrT> tmp35;
    USE(tmp35);
    tmp35 = ca_.UncheckedCast<IntPtrT>(CodeStubAssembler(state_).WordAnd(compiler::TNode<IntPtrT>{tmp33}, compiler::TNode<IntPtrT>{tmp34}));
    compiler::TNode<IntPtrT> tmp36;
    USE(tmp36);
    tmp36 = ca_.UncheckedCast<IntPtrT>(BaseBuiltinsFromDSLAssembler(state_).FromConstexpr8ATintptr17ATconstexpr_int31(1));
    compiler::TNode<BoolT> tmp37;
    USE(tmp37);
    tmp37 = ca_.UncheckedCast<BoolT>(CodeStubAssembler(state_).WordEqual(compiler::TNode<IntPtrT>{tmp35}, compiler::TNode<IntPtrT>{tmp36}));
    ca_.Branch(tmp37, &block8, &block9, tmp28, tmp29, tmp30, tmp31, tmp32, tmp33);
  }

  if (block8.is_used()) {
    compiler::TNode<Context> tmp38;
    compiler::TNode<String> tmp39;
    compiler::TNode<Smi> tmp40;
    compiler::TNode<String> tmp41;
    compiler::TNode<String> tmp42;
    compiler::TNode<IntPtrT> tmp43;
    ca_.Bind(&block8, &tmp38, &tmp39, &tmp40, &tmp41, &tmp42, &tmp43);
    compiler::TNode<String> tmp44;
    USE(tmp44);
    tmp44 = ca_.UncheckedCast<String>(BaseBuiltinsFromDSLAssembler(state_).StringAdd(compiler::TNode<Context>{tmp38}, compiler::TNode<String>{tmp41}, compiler::TNode<String>{tmp42}));
    ca_.Goto(&block9, tmp38, tmp39, tmp40, tmp44, tmp42, tmp43);
  }

  if (block9.is_used()) {
    compiler::TNode<Context> tmp45;
    compiler::TNode<String> tmp46;
    compiler::TNode<Smi> tmp47;
    compiler::TNode<String> tmp48;
    compiler::TNode<String> tmp49;
    compiler::TNode<IntPtrT> tmp50;
    ca_.Bind(&block9, &tmp45, &tmp46, &tmp47, &tmp48, &tmp49, &tmp50);
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 20);
    compiler::TNode<IntPtrT> tmp51;
    USE(tmp51);
    tmp51 = ca_.UncheckedCast<IntPtrT>(BaseBuiltinsFromDSLAssembler(state_).FromConstexpr8ATintptr17ATconstexpr_int31(1));
    compiler::TNode<IntPtrT> tmp52;
    USE(tmp52);
    tmp52 = ca_.UncheckedCast<IntPtrT>(CodeStubAssembler(state_).WordSar(compiler::TNode<IntPtrT>{tmp50}, compiler::TNode<IntPtrT>{tmp51}));
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 21);
    compiler::TNode<IntPtrT> tmp53;
    USE(tmp53);
    tmp53 = ca_.UncheckedCast<IntPtrT>(BaseBuiltinsFromDSLAssembler(state_).FromConstexpr8ATintptr17ATconstexpr_int31(0));
    compiler::TNode<BoolT> tmp54;
    USE(tmp54);
    tmp54 = ca_.UncheckedCast<BoolT>(CodeStubAssembler(state_).WordEqual(compiler::TNode<IntPtrT>{tmp52}, compiler::TNode<IntPtrT>{tmp53}));
    ca_.Branch(tmp54, &block10, &block11, tmp45, tmp46, tmp47, tmp48, tmp49, tmp52);
  }

  if (block10.is_used()) {
    compiler::TNode<Context> tmp55;
    compiler::TNode<String> tmp56;
    compiler::TNode<Smi> tmp57;
    compiler::TNode<String> tmp58;
    compiler::TNode<String> tmp59;
    compiler::TNode<IntPtrT> tmp60;
    ca_.Bind(&block10, &tmp55, &tmp56, &tmp57, &tmp58, &tmp59, &tmp60);
    ca_.Goto(&block6, tmp55, tmp56, tmp57, tmp58, tmp59, tmp60);
  }

  if (block11.is_used()) {
    compiler::TNode<Context> tmp61;
    compiler::TNode<String> tmp62;
    compiler::TNode<Smi> tmp63;
    compiler::TNode<String> tmp64;
    compiler::TNode<String> tmp65;
    compiler::TNode<IntPtrT> tmp66;
    ca_.Bind(&block11, &tmp61, &tmp62, &tmp63, &tmp64, &tmp65, &tmp66);
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 23);
    compiler::TNode<String> tmp67;
    USE(tmp67);
    tmp67 = ca_.UncheckedCast<String>(BaseBuiltinsFromDSLAssembler(state_).StringAdd(compiler::TNode<Context>{tmp61}, compiler::TNode<String>{tmp65}, compiler::TNode<String>{tmp65}));
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 17);
    ca_.Goto(&block7, tmp61, tmp62, tmp63, tmp64, tmp67, tmp66);
  }

  if (block6.is_used()) {
    compiler::TNode<Context> tmp68;
    compiler::TNode<String> tmp69;
    compiler::TNode<Smi> tmp70;
    compiler::TNode<String> tmp71;
    compiler::TNode<String> tmp72;
    compiler::TNode<IntPtrT> tmp73;
    ca_.Bind(&block6, &tmp68, &tmp69, &tmp70, &tmp71, &tmp72, &tmp73);
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 26);
    CodeStubAssembler(state_).Return(tmp71);
  }
}

TF_BUILTIN(StringPrototypeRepeat, CodeStubAssembler) {
  compiler::CodeAssemblerState* state_ = state();  compiler::CodeAssembler ca_(state());
  TNode<Context> parameter0 = UncheckedCast<Context>(Parameter(Descriptor::kContext));
  USE(parameter0);
  compiler::TNode<Object> parameter1 = UncheckedCast<Object>(Parameter(Descriptor::kReceiver));
  USE(parameter1);
  compiler::TNode<Object> parameter2 = UncheckedCast<Object>(Parameter(Descriptor::kCount));
  USE(parameter2);
  compiler::CodeAssemblerParameterizedLabel<Context, Object, Object> block0(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, Object, Object, String, Number, Number> block10(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, Object, Object, String, Number, Number, Smi> block9(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, Object, Object, String, Number, Smi> block11(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, Object, Object, String, Number, Smi> block12(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, Object, Object, String, Number, Smi> block15(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, Object, Object, String, Number, Smi> block13(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, Object, Object, String, Number, Smi> block14(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, Object, Object, String, Number, Smi> block16(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, Object, Object, String, Number, Smi> block17(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, Object, Object, String, Number> block8(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, Object, Object, String, Number, HeapNumber> block19(&ca_, compiler::CodeAssemblerLabel::kDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, Object, Object, String, Number, HeapNumber> block18(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, Object, Object, String, Number, HeapNumber, Float64T> block22(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, Object, Object, String, Number, HeapNumber, Float64T> block20(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, Object, Object, String, Number, HeapNumber, Float64T> block21(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, Object, Object, String, Number, HeapNumber, Float64T> block23(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, Object, Object, String, Number, HeapNumber, Float64T> block24(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, Object, Object, String> block6(&ca_, compiler::CodeAssemblerLabel::kNonDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, Object, Object, String> block4(&ca_, compiler::CodeAssemblerLabel::kDeferred);
  compiler::CodeAssemblerParameterizedLabel<Context, Object, Object, String> block2(&ca_, compiler::CodeAssemblerLabel::kDeferred);
    ca_.Goto(&block0, parameter0, parameter1, parameter2);

  if (block0.is_used()) {
    compiler::TNode<Context> tmp0;
    compiler::TNode<Object> tmp1;
    compiler::TNode<Object> tmp2;
    ca_.Bind(&block0, &tmp0, &tmp1, &tmp2);
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 34);
    compiler::TNode<String> tmp3;
    USE(tmp3);
    tmp3 = ca_.UncheckedCast<String>(BaseBuiltinsFromDSLAssembler(state_).FromConstexpr6String18ATconstexpr_string(StringRepeatBuiltinsFromDSLAssembler(state_).kBuiltinName()));
    compiler::TNode<String> tmp4;
    USE(tmp4);
    tmp4 = ca_.UncheckedCast<String>(CodeStubAssembler(state_).ToThisString(compiler::TNode<Context>{tmp0}, compiler::TNode<Object>{tmp1}, compiler::TNode<String>{tmp3}));
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 38);
    compiler::TNode<Number> tmp5;
    USE(tmp5);
    tmp5 = ca_.UncheckedCast<Number>(CodeStubAssembler(state_).ToInteger_Inline(compiler::TNode<Context>{tmp0}, compiler::TNode<Object>{tmp2}, CodeStubAssembler::ToIntegerTruncationMode::kTruncateMinusZero));
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 39);
    compiler::TNode<Smi> tmp6;
    USE(tmp6);
    compiler::CodeAssemblerLabel label0(&ca_);
    tmp6 = BaseBuiltinsFromDSLAssembler(state_).Cast5ATSmi(compiler::TNode<Object>{tmp5}, &label0);
    ca_.Goto(&block9, tmp0, tmp1, tmp2, tmp4, tmp5, tmp5, tmp6);
    if (label0.is_used()) {
      ca_.Bind(&label0);
      ca_.Goto(&block10, tmp0, tmp1, tmp2, tmp4, tmp5, tmp5);
    }
  }

  if (block10.is_used()) {
    compiler::TNode<Context> tmp7;
    compiler::TNode<Object> tmp8;
    compiler::TNode<Object> tmp9;
    compiler::TNode<String> tmp10;
    compiler::TNode<Number> tmp11;
    compiler::TNode<Number> tmp12;
    ca_.Bind(&block10, &tmp7, &tmp8, &tmp9, &tmp10, &tmp11, &tmp12);
    ca_.Goto(&block8, tmp7, tmp8, tmp9, tmp10, tmp11);
  }

  if (block9.is_used()) {
    compiler::TNode<Context> tmp13;
    compiler::TNode<Object> tmp14;
    compiler::TNode<Object> tmp15;
    compiler::TNode<String> tmp16;
    compiler::TNode<Number> tmp17;
    compiler::TNode<Number> tmp18;
    compiler::TNode<Smi> tmp19;
    ca_.Bind(&block9, &tmp13, &tmp14, &tmp15, &tmp16, &tmp17, &tmp18, &tmp19);
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 41);
    compiler::TNode<Smi> tmp20;
    USE(tmp20);
    tmp20 = ca_.UncheckedCast<Smi>(BaseBuiltinsFromDSLAssembler(state_).FromConstexpr5ATSmi17ATconstexpr_int31(0));
    compiler::TNode<BoolT> tmp21;
    USE(tmp21);
    tmp21 = ca_.UncheckedCast<BoolT>(CodeStubAssembler(state_).SmiLessThan(compiler::TNode<Smi>{tmp19}, compiler::TNode<Smi>{tmp20}));
    ca_.Branch(tmp21, &block11, &block12, tmp13, tmp14, tmp15, tmp16, tmp17, tmp19);
  }

  if (block11.is_used()) {
    compiler::TNode<Context> tmp22;
    compiler::TNode<Object> tmp23;
    compiler::TNode<Object> tmp24;
    compiler::TNode<String> tmp25;
    compiler::TNode<Number> tmp26;
    compiler::TNode<Smi> tmp27;
    ca_.Bind(&block11, &tmp22, &tmp23, &tmp24, &tmp25, &tmp26, &tmp27);
    ca_.Goto(&block4, tmp22, tmp23, tmp24, tmp25);
  }

  if (block12.is_used()) {
    compiler::TNode<Context> tmp28;
    compiler::TNode<Object> tmp29;
    compiler::TNode<Object> tmp30;
    compiler::TNode<String> tmp31;
    compiler::TNode<Number> tmp32;
    compiler::TNode<Smi> tmp33;
    ca_.Bind(&block12, &tmp28, &tmp29, &tmp30, &tmp31, &tmp32, &tmp33);
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 44);
    compiler::TNode<Smi> tmp34;
    USE(tmp34);
    tmp34 = ca_.UncheckedCast<Smi>(BaseBuiltinsFromDSLAssembler(state_).FromConstexpr5ATSmi17ATconstexpr_int31(0));
    compiler::TNode<BoolT> tmp35;
    USE(tmp35);
    tmp35 = ca_.UncheckedCast<BoolT>(CodeStubAssembler(state_).SmiEqual(compiler::TNode<Smi>{tmp33}, compiler::TNode<Smi>{tmp34}));
    ca_.Branch(tmp35, &block13, &block15, tmp28, tmp29, tmp30, tmp31, tmp32, tmp33);
  }

  if (block15.is_used()) {
    compiler::TNode<Context> tmp36;
    compiler::TNode<Object> tmp37;
    compiler::TNode<Object> tmp38;
    compiler::TNode<String> tmp39;
    compiler::TNode<Number> tmp40;
    compiler::TNode<Smi> tmp41;
    ca_.Bind(&block15, &tmp36, &tmp37, &tmp38, &tmp39, &tmp40, &tmp41);
    compiler::TNode<Uint32T> tmp42;
    USE(tmp42);
    tmp42 = ca_.UncheckedCast<Uint32T>(CodeStubAssembler(state_).LoadStringLengthAsWord32(compiler::TNode<String>{tmp39}));
    compiler::TNode<Uint32T> tmp43;
    USE(tmp43);
    tmp43 = ca_.UncheckedCast<Uint32T>(BaseBuiltinsFromDSLAssembler(state_).FromConstexpr8ATuint3217ATconstexpr_int31(0));
    compiler::TNode<BoolT> tmp44;
    USE(tmp44);
    tmp44 = ca_.UncheckedCast<BoolT>(CodeStubAssembler(state_).Word32Equal(compiler::TNode<Uint32T>{tmp42}, compiler::TNode<Uint32T>{tmp43}));
    ca_.Branch(tmp44, &block13, &block14, tmp36, tmp37, tmp38, tmp39, tmp40, tmp41);
  }

  if (block13.is_used()) {
    compiler::TNode<Context> tmp45;
    compiler::TNode<Object> tmp46;
    compiler::TNode<Object> tmp47;
    compiler::TNode<String> tmp48;
    compiler::TNode<Number> tmp49;
    compiler::TNode<Smi> tmp50;
    ca_.Bind(&block13, &tmp45, &tmp46, &tmp47, &tmp48, &tmp49, &tmp50);
    ca_.Goto(&block6, tmp45, tmp46, tmp47, tmp48);
  }

  if (block14.is_used()) {
    compiler::TNode<Context> tmp51;
    compiler::TNode<Object> tmp52;
    compiler::TNode<Object> tmp53;
    compiler::TNode<String> tmp54;
    compiler::TNode<Number> tmp55;
    compiler::TNode<Smi> tmp56;
    ca_.Bind(&block14, &tmp51, &tmp52, &tmp53, &tmp54, &tmp55, &tmp56);
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 46);
    compiler::TNode<Smi> tmp57;
    USE(tmp57);
    tmp57 = ca_.UncheckedCast<Smi>(BaseBuiltinsFromDSLAssembler(state_).FromConstexpr5ATSmi17ATconstexpr_int31(String::kMaxLength));
    compiler::TNode<BoolT> tmp58;
    USE(tmp58);
    tmp58 = ca_.UncheckedCast<BoolT>(CodeStubAssembler(state_).SmiGreaterThan(compiler::TNode<Smi>{tmp56}, compiler::TNode<Smi>{tmp57}));
    ca_.Branch(tmp58, &block16, &block17, tmp51, tmp52, tmp53, tmp54, tmp55, tmp56);
  }

  if (block16.is_used()) {
    compiler::TNode<Context> tmp59;
    compiler::TNode<Object> tmp60;
    compiler::TNode<Object> tmp61;
    compiler::TNode<String> tmp62;
    compiler::TNode<Number> tmp63;
    compiler::TNode<Smi> tmp64;
    ca_.Bind(&block16, &tmp59, &tmp60, &tmp61, &tmp62, &tmp63, &tmp64);
    ca_.Goto(&block2, tmp59, tmp60, tmp61, tmp62);
  }

  if (block17.is_used()) {
    compiler::TNode<Context> tmp65;
    compiler::TNode<Object> tmp66;
    compiler::TNode<Object> tmp67;
    compiler::TNode<String> tmp68;
    compiler::TNode<Number> tmp69;
    compiler::TNode<Smi> tmp70;
    ca_.Bind(&block17, &tmp65, &tmp66, &tmp67, &tmp68, &tmp69, &tmp70);
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 50);
    compiler::TNode<String> tmp71;
    tmp71 = TORQUE_CAST(CodeStubAssembler(state_).CallBuiltin(Builtins::kStringRepeat, tmp65, tmp68, tmp70));
    USE(tmp71);
    CodeStubAssembler(state_).Return(tmp71);
  }

  if (block8.is_used()) {
    compiler::TNode<Context> tmp72;
    compiler::TNode<Object> tmp73;
    compiler::TNode<Object> tmp74;
    compiler::TNode<String> tmp75;
    compiler::TNode<Number> tmp76;
    ca_.Bind(&block8, &tmp72, &tmp73, &tmp74, &tmp75, &tmp76);
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 52);
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 53);
    compiler::TNode<BoolT> tmp77;
    USE(tmp77);
    tmp77 = ca_.UncheckedCast<BoolT>(CodeStubAssembler(state_).IsNumberNormalized(compiler::TNode<Number>{ca_.UncheckedCast<HeapNumber>(tmp76)}));
    ca_.Branch(tmp77, &block18, &block19, tmp72, tmp73, tmp74, tmp75, tmp76, ca_.UncheckedCast<HeapNumber>(tmp76));
  }

  if (block19.is_used()) {
    compiler::TNode<Context> tmp78;
    compiler::TNode<Object> tmp79;
    compiler::TNode<Object> tmp80;
    compiler::TNode<String> tmp81;
    compiler::TNode<Number> tmp82;
    compiler::TNode<HeapNumber> tmp83;
    ca_.Bind(&block19, &tmp78, &tmp79, &tmp80, &tmp81, &tmp82, &tmp83);
    CodeStubAssembler(state_).FailAssert("Torque assert \'IsNumberNormalized(heapNum)\' failed", "../../src/builtins/string-repeat.tq", 53);
  }

  if (block18.is_used()) {
    compiler::TNode<Context> tmp84;
    compiler::TNode<Object> tmp85;
    compiler::TNode<Object> tmp86;
    compiler::TNode<String> tmp87;
    compiler::TNode<Number> tmp88;
    compiler::TNode<HeapNumber> tmp89;
    ca_.Bind(&block18, &tmp84, &tmp85, &tmp86, &tmp87, &tmp88, &tmp89);
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 54);
    compiler::TNode<Float64T> tmp90;
    USE(tmp90);
    tmp90 = ca_.UncheckedCast<Float64T>(BaseBuiltinsFromDSLAssembler(state_).LoadHeapNumberValue(compiler::TNode<HeapNumber>{tmp89}));
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 58);
    compiler::TNode<Float64T> tmp91;
    USE(tmp91);
    tmp91 = ca_.UncheckedCast<Float64T>(BaseBuiltinsFromDSLAssembler(state_).FromConstexpr9ATfloat6419ATconstexpr_float64(V8_INFINITY));
    compiler::TNode<BoolT> tmp92;
    USE(tmp92);
    tmp92 = ca_.UncheckedCast<BoolT>(CodeStubAssembler(state_).Float64Equal(compiler::TNode<Float64T>{tmp90}, compiler::TNode<Float64T>{tmp91}));
    ca_.Branch(tmp92, &block20, &block22, tmp84, tmp85, tmp86, tmp87, tmp88, tmp89, tmp90);
  }

  if (block22.is_used()) {
    compiler::TNode<Context> tmp93;
    compiler::TNode<Object> tmp94;
    compiler::TNode<Object> tmp95;
    compiler::TNode<String> tmp96;
    compiler::TNode<Number> tmp97;
    compiler::TNode<HeapNumber> tmp98;
    compiler::TNode<Float64T> tmp99;
    ca_.Bind(&block22, &tmp93, &tmp94, &tmp95, &tmp96, &tmp97, &tmp98, &tmp99);
    compiler::TNode<Float64T> tmp100;
    USE(tmp100);
    tmp100 = ca_.UncheckedCast<Float64T>(BaseBuiltinsFromDSLAssembler(state_).FromConstexpr9ATfloat6417ATconstexpr_int31(0.0));
    compiler::TNode<BoolT> tmp101;
    USE(tmp101);
    tmp101 = ca_.UncheckedCast<BoolT>(CodeStubAssembler(state_).Float64LessThan(compiler::TNode<Float64T>{tmp99}, compiler::TNode<Float64T>{tmp100}));
    ca_.Branch(tmp101, &block20, &block21, tmp93, tmp94, tmp95, tmp96, tmp97, tmp98, tmp99);
  }

  if (block20.is_used()) {
    compiler::TNode<Context> tmp102;
    compiler::TNode<Object> tmp103;
    compiler::TNode<Object> tmp104;
    compiler::TNode<String> tmp105;
    compiler::TNode<Number> tmp106;
    compiler::TNode<HeapNumber> tmp107;
    compiler::TNode<Float64T> tmp108;
    ca_.Bind(&block20, &tmp102, &tmp103, &tmp104, &tmp105, &tmp106, &tmp107, &tmp108);
    ca_.Goto(&block4, tmp102, tmp103, tmp104, tmp105);
  }

  if (block21.is_used()) {
    compiler::TNode<Context> tmp109;
    compiler::TNode<Object> tmp110;
    compiler::TNode<Object> tmp111;
    compiler::TNode<String> tmp112;
    compiler::TNode<Number> tmp113;
    compiler::TNode<HeapNumber> tmp114;
    compiler::TNode<Float64T> tmp115;
    ca_.Bind(&block21, &tmp109, &tmp110, &tmp111, &tmp112, &tmp113, &tmp114, &tmp115);
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 61);
    compiler::TNode<Uint32T> tmp116;
    USE(tmp116);
    tmp116 = ca_.UncheckedCast<Uint32T>(CodeStubAssembler(state_).LoadStringLengthAsWord32(compiler::TNode<String>{tmp112}));
    compiler::TNode<Uint32T> tmp117;
    USE(tmp117);
    tmp117 = ca_.UncheckedCast<Uint32T>(BaseBuiltinsFromDSLAssembler(state_).FromConstexpr8ATuint3217ATconstexpr_int31(0));
    compiler::TNode<BoolT> tmp118;
    USE(tmp118);
    tmp118 = ca_.UncheckedCast<BoolT>(CodeStubAssembler(state_).Word32Equal(compiler::TNode<Uint32T>{tmp116}, compiler::TNode<Uint32T>{tmp117}));
    ca_.Branch(tmp118, &block23, &block24, tmp109, tmp110, tmp111, tmp112, tmp113, tmp114, tmp115);
  }

  if (block23.is_used()) {
    compiler::TNode<Context> tmp119;
    compiler::TNode<Object> tmp120;
    compiler::TNode<Object> tmp121;
    compiler::TNode<String> tmp122;
    compiler::TNode<Number> tmp123;
    compiler::TNode<HeapNumber> tmp124;
    compiler::TNode<Float64T> tmp125;
    ca_.Bind(&block23, &tmp119, &tmp120, &tmp121, &tmp122, &tmp123, &tmp124, &tmp125);
    ca_.Goto(&block6, tmp119, tmp120, tmp121, tmp122);
  }

  if (block24.is_used()) {
    compiler::TNode<Context> tmp126;
    compiler::TNode<Object> tmp127;
    compiler::TNode<Object> tmp128;
    compiler::TNode<String> tmp129;
    compiler::TNode<Number> tmp130;
    compiler::TNode<HeapNumber> tmp131;
    compiler::TNode<Float64T> tmp132;
    ca_.Bind(&block24, &tmp126, &tmp127, &tmp128, &tmp129, &tmp130, &tmp131, &tmp132);
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 63);
    ca_.Goto(&block2, tmp126, tmp127, tmp128, tmp129);
  }

  if (block6.is_used()) {
    compiler::TNode<Context> tmp133;
    compiler::TNode<Object> tmp134;
    compiler::TNode<Object> tmp135;
    compiler::TNode<String> tmp136;
    ca_.Bind(&block6, &tmp133, &tmp134, &tmp135, &tmp136);
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 68);
    compiler::TNode<String> tmp137;
    USE(tmp137);
    tmp137 = BaseBuiltinsFromDSLAssembler(state_).kEmptyString();
    CodeStubAssembler(state_).Return(tmp137);
  }

  if (block4.is_used()) {
    compiler::TNode<Context> tmp138;
    compiler::TNode<Object> tmp139;
    compiler::TNode<Object> tmp140;
    compiler::TNode<String> tmp141;
    ca_.Bind(&block4, &tmp138, &tmp139, &tmp140, &tmp141);
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 71);
    CodeStubAssembler(state_).ThrowRangeError(compiler::TNode<Context>{tmp138}, MessageTemplate::kInvalidCountValue, compiler::TNode<Object>{tmp140});
  }

  if (block2.is_used()) {
    compiler::TNode<Context> tmp142;
    compiler::TNode<Object> tmp143;
    compiler::TNode<Object> tmp144;
    compiler::TNode<String> tmp145;
    ca_.Bind(&block2, &tmp142, &tmp143, &tmp144, &tmp145);
    ca_.SetSourcePosition("../../src/builtins/string-repeat.tq", 74);
    CodeStubAssembler(state_).CallRuntime(Runtime::kThrowInvalidStringLength, tmp142);
    CodeStubAssembler(state_).Unreachable();
  }
}

}  // namespace internal
}  // namespace v8


text:
<?php

namespace ProxyManager\GeneratorStrategy;

use ProxyManager\Exception\FileNotWritableException;
use ProxyManager\FileLocator\FileLocatorInterface;
use Zend\Code\Generator\ClassGenerator;

/**
 * Generator strategy that writes the generated classes to disk while generating them
 *
 * {@inheritDoc}
 *
 * @author Marco Pivetta <ocramius@gmail.com>
 * @license MIT
 */
class FileWriterGeneratorStrategy implements GeneratorStrategyInterface
{
    /**
     * @var \ProxyManager\FileLocator\FileLocatorInterface
     */
    protected $fileLocator;

    /**
     * @var callable
     */
    private $emptyErrorHandler;

    /**
     * @param \ProxyManager\FileLocator\FileLocatorInterface $fileLocator
     */
    public function __construct(FileLocatorInterface $fileLocator)
    {
        $this->fileLocator       = $fileLocator;
        $this->emptyErrorHandler = function () {
        };
    }

    /**
     * Write generated code to disk and return the class code
     *
     * {@inheritDoc}
     */
    public function generate(ClassGenerator $classGenerator)
    {
        $className     = trim($classGenerator->getNamespaceName(), '\\')
            . '\\' . trim($classGenerator->getName(), '\\');
        $generatedCode = $classGenerator->generate();
        $fileName      = $this->fileLocator->getProxyFileName($className);

        set_error_handler($this->emptyErrorHandler);

        try {
            $this->writeFile("<?php\n\n" . $generatedCode, $fileName);
        } catch (FileNotWritableException $fileNotWritable) {
            throw $fileNotWritable;
        } finally {
            restore_error_handler();
        }

        return $generatedCode;
    }

    /**
     * Writes the source file in such a way that race conditions are avoided when the same file is written
     * multiple times in a short time period
     *
     * @param string $source
     * @param string $location
     *
     * @throws FileNotWritableException
     */
    private function writeFile($source, $location)
    {
        $tmpFileName   = $location . '.' . uniqid('', true);

        if (! file_put_contents($tmpFileName, $source)) {
            throw FileNotWritableException::fromNonWritableLocation($tmpFileName);
        }

        if (! rename($tmpFileName, $location)) {
            unlink($tmpFileName);

            throw FileNotWritableException::fromInvalidMoveOperation($tmpFileName, $location);
        }
    }
}


text:
package uk.co.bluegecko.core.test.source;

import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;

import org.junit.Before;
import org.junit.Test;

public class WordSequenceSourceTest
{

	private Source< String > source;

	@Before
	public final void setUp()
	{
		source = new WordSequenceSource( 0 );
	}

	@Test
	public void testSequence()
	{
		assertThat( source.next(), is( "Zero" ) );
		assertThat( source.next(), is( "One" ) );
		assertThat( source.next(), is( "Two" ) );
		assertThat( source.next(), is( "Three" ) );
		assertThat( source.next(), is( "Four" ) );
	}

}


text:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layoutDirection="ltr">

    <TextView
        android:id="@+id/wootric_tv_powered_by"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:fontFamily="@font/ibmplexsans"
        android:text="@string/wootric_powered_by"
        android:textColor="@color/wootric_tablet_text_score_color"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:fontFamily="@font/ibmplexsans"
        android:text="@string/wootric"
        android:textColor="@color/wootric_tablet_text_score_color" />

    <TextView
        android:id="@+id/footer_dot_separator"
        android:layout_width="@dimen/wootric_footer_layout_dot_separator_width"
        android:layout_height="@dimen/wootric_footer_layout_dot_separator_height"
        android:gravity="center"
        android:fontFamily="@font/ibmplexsans"
        android:layout_margin="@dimen/wootric_footer_layout_dot_separator_margin"
        android:background="@drawable/footer_dot_separator"
        android:visibility="gone"/>

    <TextView
        android:id="@+id/wootric_btn_opt_out"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/wootric_opt_out"
        android:clickable="true"
        android:fontFamily="@font/ibmplexsans"
        android:textColor="@color/wootric_tablet_text_score_color"
        android:visibility="gone"/>
</LinearLayout>


text:
<!DOCTYPE html>

    <meta charset='utf-8'>
    <meta http-equiv="X-UA-Compatible" content="chrome=1">
    <link rel="alternate" type="application/rss+xml" title="{{ site.name }}" href="{{ site.url }}/feed.xml">
    <link href='https://fonts.googleapis.com/css?family=Lato:900' rel='stylesheet' type='text/css'>
    <link rel="icon" href="favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="stylesheets/pygment_trac.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="stylesheets/print.css" media="print" />
    <link rel="stylesheet" type="text/css" href="stylesheets/recordings.css" media="screen" />

    <title>Talk Recordings and Transcripts - !!Con</title>

          ← go back home.

Talk Recordings and Transcripts

            Hosted on

              GitHub Pages
            .


text:
package corySherman.snake;

import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;

import java.awt.*;

import java.util.*;

class ScorePanel extends JPanel
{
    protected SnakePanel mySnakePanel;

    protected ArrayList<JLabel> myLabels;

    public ScorePanel(SnakePanel sp)
    {
        mySnakePanel = sp;
        myLabels = new ArrayList<JLabel>();
        countLabels();
        mySnakePanel.addChangeListener(new ChangeListener()
        {
            public void stateChanged(ChangeEvent e)
            {
                repaint();
            }
        });
    }

    protected void countLabels()
    {
        if(mySnakePanel.getSnakes().length != myLabels.size())
        {
            myLabels.clear();
            for(Snake snake : mySnakePanel.getSnakes())
            {
                JLabel label = new JLabel("" + snake); //"Player " + snake.getNum() + ": length = " + snake.getLength() + ", score = " + snake.getScore());
                label.setForeground(snake.getColor());
                myLabels.add(label);
            }

            removeAll();
            for(JLabel label : myLabels)
                add(label);
        }
    }

    protected void updateText()
    {
        countLabels();
        for(int i = 0; i < myLabels.size(); i++)
            myLabels.get(i).setText("" + mySnakePanel.getSnakes()[i]);

                /*"Player " + mySnakePanel.getSnakes()[i].getNum() +
                 ": length = " + mySnakePanel.getSnakes()[i].getLength() +
                 ", score = " + mySnakePanel.getSnakes()[i].getScore());*/
    }

    public void paintComponent(Graphics g)
    {
        updateText();
        super.paintComponent(g);
    }

}


text:
<?php

namespace Splash\Local\Objects\ThirdParty;

use Gender;
use Splash\Core\SplashCore      as Splash;
use Splash\Local\Services\LanguagesManager;
use Translate;
use Validate;

/**
 * Access to ThirdParty Main Fields
 */
trait MainTrait
{
    /**
     * Build Customers Main Fields using FieldFactory
     *
     * @return void
     */
    private function buildMainFields()
    {
        //====================================================================//
        // Firstname
        $this->fieldsFactory()->create(SPL_T_VARCHAR)
            ->identifier("firstname")
            ->name(Translate::getAdminTranslation("First name", "AdminCustomers"))
            ->microData("http://schema.org/Person", "familyName")
            ->association("firstname", "lastname")
            ->isReadOnly(isset(Splash::configuration()->PsUseFullCompanyNames))
            ->isRequired()
            ->isListed()
        ;
        //====================================================================//
        // Lastname
        $this->fieldsFactory()->create(SPL_T_VARCHAR)
            ->identifier("lastname")
            ->name(Translate::getAdminTranslation("Last name", "AdminCustomers"))
            ->microData("http://schema.org/Person", "givenName")
            ->association("firstname", "lastname")
            ->isReadOnly(isset(Splash::configuration()->PsUseFullCompanyNames))
            ->isRequired()
            ->isListed()
        ;
        //====================================================================//
        // Company
        $this->fieldsFactory()->create(SPL_T_VARCHAR)
            ->identifier("company")
            ->name(Translate::getAdminTranslation("Company", "AdminCustomers"))
            ->microData("http://schema.org/Organization", "legalName")
            ->isReadOnly(isset(Splash::configuration()->PsUseFullCompanyNames))
            ->isListed()
        ;
        //====================================================================//
        // Full Name
        $this->fieldsFactory()->create(SPL_T_VARCHAR)
            ->identifier("full_name")
            ->name("[C] Full Name")
            ->description("Company | Firstname + Lastname")
            ->microData("http://schema.org/Organization", "alternateName")
            ->isReadOnly()
        ;
        //====================================================================//
        // SIRET
        $this->fieldsFactory()->create(SPL_T_VARCHAR)
            ->identifier("siret")
            ->name(Translate::getAdminTranslation("SIRET", "AdminCustomers"))
            ->microData("http://schema.org/Organization", "taxID")
            ->group("ID")
            ->isNotTested()
        ;
        //====================================================================//
        // APE
        $this->fieldsFactory()->create(SPL_T_VARCHAR)
            ->identifier("ape")
            ->name(Translate::getAdminTranslation("APE", "AdminCustomers"))
            ->microData("http://schema.org/Organization", "naics")
            ->group("ID")
            ->isNotTested()
        ;
        //====================================================================//
        // WebSite
        $this->fieldsFactory()->create(SPL_T_URL)
            ->identifier("website")
            ->name(Translate::getAdminTranslation("Website", "AdminCustomers"))
            ->microData("http://schema.org/Organization", "url")
        ;
    }

    /**
     * Build Customers Main Fields using FieldFactory
     *
     * @return void
     */
    private function buildGenderFields()
    {
        //====================================================================//
        // Gender Name
        $this->fieldsFactory()->create(SPL_T_VARCHAR)
            ->identifier("gender_name")
            ->name(Translate::getAdminTranslation("Social title", "AdminCustomers"))
            ->microData("http://schema.org/Person", "honorificPrefix")
            ->isReadOnly()
        ;
        //====================================================================//
        // Gender Type
        $desc = Translate::getAdminTranslation("Social title", "AdminCustomers");
        $desc .= " ; 0 => Male // 1 => Female // 2 => Neutral";
        $this->fieldsFactory()->create(SPL_T_INT)
            ->identifier("gender_type")
            ->name(Translate::getAdminTranslation("Social title", "AdminCustomers")." (ID)")
            ->microData("http://schema.org/Person", "gender")
            ->description($desc)
            ->group(Translate::getAdminTranslation("Meta", "AdminThemes"))
            ->addChoices(array("0" => "Male", "1" => "female"))
            ->isNotTested()
        ;
    }

    /**
     * Read requested Field
     *
     * @param string $key       Input List Key
     * @param string $fieldName Field Identifier / Name
     *
     * @return void
     */
    private function getMainFields(string $key, string $fieldName): void
    {
        //====================================================================//
        // READ Fields
        switch ($fieldName) {
            case 'passwd':
            case 'siret':
            case 'ape':
            case 'website':
                $this->getSimple($fieldName);

                break;
            default:
                return;
        }
        unset($this->in[$key]);
    }

    /**
     * Read requested Field
     *
     * @param string $key       Input List Key
     * @param string $fieldName Field Identifier / Name
     *
     * @return void
     */
    private function getMainComputedFields(string $key, string $fieldName): void
    {
        //====================================================================//
        // READ Fields
        switch ($fieldName) {
            case 'lastname':
            case 'firstname':
                //====================================================================//
                // Read Only AllInOne Customer Name Mode
                if (isset(Splash::configuration()->PsUseFullCompanyNames)) {
                    $this->out[$fieldName] = " ";

                    break;
                }
                //====================================================================//
                // Generic Mode
                $this->getSimple($fieldName);

                break;
            case 'company':
                $this->out[$fieldName] = $this->getCompanyName();

                break;
            case 'full_name':
                $this->out[$fieldName] = !empty($this->object->company)
                    ? sprintf("%s [%s]", ucfirst($this->object->company), $this->object->id)
                    : sprintf(
                        "%s %s [%s]",
                        ucfirst($this->object->firstname),
                        $this->object->lastname,
                        $this->object->id
                    )
                ;

                break;
            default:
                return;
        }
        unset($this->in[$key]);
    }

    /**
     * Read requested Field
     *
     * @param string $key       Input List Key
     * @param string $fieldName Field Identifier / Name
     *
     * @return void
     */
    private function getGenderFields(string $key, string $fieldName): void
    {
        //====================================================================//
        // READ Fields
        switch ($fieldName) {
            //====================================================================//
            // Gender Name
            case 'gender_name':
                if (empty($this->object->id_gender)) {
                    $this->out[$fieldName] = Splash::trans("Empty");

                    break;
                }
                $gender = new Gender($this->object->id_gender, LanguagesManager::getDefaultLangId());
                if (0 == $gender->type) {
                    $this->out[$fieldName] = $this->spl->l('Male');
                } elseif (1 == $gender->type) {
                    $this->out[$fieldName] = $this->spl->l('Female');
                } else {
                    $this->out[$fieldName] = $this->spl->l('Neutral');
                }

                break;
            //====================================================================//
            // Gender Type
            case 'gender_type':
                if (empty($this->object->id_gender)) {
                    $this->out[$fieldName] = 0;

                    break;
                }
                $gender = new Gender($this->object->id_gender);
                $this->out[$fieldName] = (int) $gender->type;

                break;
            default:
                return;
        }
        unset($this->in[$key]);
    }

    /**
     * Read Customer Company Name
     *
     * @return string Customer Company Name
     */
    private function getCompanyName(): string
    {
        //====================================================================//
        // Read Only AllInOne Customer Name Mode
        if (isset(Splash::configuration()->PsUseFullCompanyNames)) {
            //====================================================================//
            // Customer Core Name
            $fullName = sprintf("%s %s", $this->object->firstname, $this->object->lastname);
            //====================================================================//
            // Customer Company Name
            if (!empty($this->object->company)) {
                $fullName .= " | ".$this->object->company;
            }

            return $fullName;
        }
        //====================================================================//
        // Generic Mode
        if (!empty($this->object->company)) {
            return $this->object->company;
        }
        //====================================================================//
        // Generic FallBack Mode
        return "Prestashop(".$this->object->id.")";
    }

    /**
     * Write Given Fields
     *
     * @param string $fieldName Field Identifier / Name
     * @param mixed  $fieldData Field Data
     *
     * @return void
     */
    private function setMainFields(string $fieldName, $fieldData): void
    {
        //====================================================================//
        // WRITE Fields
        switch ($fieldName) {
            case 'firstname':
            case 'lastname':
            case 'passwd':
            case 'website':
                $this->setSimple($fieldName, $fieldData);

                break;
            case 'company':
                if ($this->object->{$fieldName} == "Prestashop(".$this->object->id.")") {
                    $this->setSimple($fieldName, "");

                    break;
                }
                $this->setSimple($fieldName, $fieldData);

                break;
            default:
                return;
        }
        unset($this->in[$fieldName]);
    }

    /**
     * Write Given Fields
     *
     * @param string $fieldName Field Identifier / Name
     * @param mixed  $fieldData Field Data
     *
     * @return void
     */
    private function setIdentificationFields($fieldName, $fieldData)
    {
        //====================================================================//
        // WRITE Fields
        switch ($fieldName) {
            //====================================================================//
            // Write SIRET With Verification
            case 'siret':
                if (!Validate::isSiret($fieldData)) {
                    Splash::log()->war(
                        "MsgLocalTpl",
                        __CLASS__,
                        __FUNCTION__,
                        "Given SIRET Number is Invalid. Skipped"
                    );

                    break;
                }
                $this->setSimple($fieldName, $fieldData);

                break;
            //====================================================================//
            // Write APE With Verification
            case 'ape':
                if (!Validate::isApe($fieldData)) {
                    Splash::log()->war("MsgLocalTpl", __CLASS__, __FUNCTION__, "Given APE Code is Invalid. Skipped");

                    break;
                }
                $this->setSimple($fieldName, $fieldData);

                break;
            default:
                return;
        }
        unset($this->in[$fieldName]);
    }

    /**
     * Write Given Fields
     *
     * @param string $fieldName Field Identifier / Name
     * @param mixed  $fieldData Field Data
     *
     * @return void
     */
    private function setGenderFields(string $fieldName, $fieldData): void
    {
        //====================================================================//
        // WRITE Fields
        switch ($fieldName) {
            //====================================================================//
            // Gender Type
            case 'gender_type':
                //====================================================================//
                // Identify Gender Type
                $genders = Gender::getGenders(LanguagesManager::getDefaultLangId());
                $genders->where("type", "=", $fieldData);
                /** @var false|Gender */
                $gendertype = $genders->getFirst();
                //====================================================================//
                // Unknown Gender Type => Take First Available Gender
                if ((false == $gendertype)) {
                    $genders = Gender::getGenders(LanguagesManager::getDefaultLangId());
                    /** @var false|Gender */
                    $gendertype = $genders->getFirst();
                    Splash::log()->warTrace("This Gender Type doesn't exist.");
                }
                //====================================================================//
                // Update Gender Type
                if ($gendertype) {
                    $this->setSimple("id_gender", $gendertype->id_gender);
                }

                break;
            default:
                return;
        }
        unset($this->in[$fieldName]);
    }
}


text:
// Code generated by go-swagger; DO NOT EDIT.

package pipeline_upload_service

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"context"
	"net/http"
	"time"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/runtime"
	cr "github.com/go-openapi/runtime/client"

	strfmt "github.com/go-openapi/strfmt"
)

// NewUploadPipelineParams creates a new UploadPipelineParams object
// with the default values initialized.
func NewUploadPipelineParams() *UploadPipelineParams {
	var ()
	return &UploadPipelineParams{

		timeout: cr.DefaultTimeout,
	}
}

// NewUploadPipelineParamsWithTimeout creates a new UploadPipelineParams object
// with the default values initialized, and the ability to set a timeout on a request
func NewUploadPipelineParamsWithTimeout(timeout time.Duration) *UploadPipelineParams {
	var ()
	return &UploadPipelineParams{

		timeout: timeout,
	}
}

// NewUploadPipelineParamsWithContext creates a new UploadPipelineParams object
// with the default values initialized, and the ability to set a context for a request
func NewUploadPipelineParamsWithContext(ctx context.Context) *UploadPipelineParams {
	var ()
	return &UploadPipelineParams{

		Context: ctx,
	}
}

// NewUploadPipelineParamsWithHTTPClient creates a new UploadPipelineParams object
// with the default values initialized, and the ability to set a custom HTTPClient for a request
func NewUploadPipelineParamsWithHTTPClient(client *http.Client) *UploadPipelineParams {
	var ()
	return &UploadPipelineParams{
		HTTPClient: client,
	}
}

/*UploadPipelineParams contains all the parameters to send to the API endpoint
for the upload pipeline operation typically these are written to a http.Request
*/
type UploadPipelineParams struct {

	/*Description*/
	Description *string
	/*Name*/
	Name *string
	/*Uploadfile
	  The pipeline to upload. Maximum size of 32MB is supported.

	*/
	Uploadfile runtime.NamedReadCloser

	timeout    time.Duration
	Context    context.Context
	HTTPClient *http.Client
}

// WithTimeout adds the timeout to the upload pipeline params
func (o *UploadPipelineParams) WithTimeout(timeout time.Duration) *UploadPipelineParams {
	o.SetTimeout(timeout)
	return o
}

// SetTimeout adds the timeout to the upload pipeline params
func (o *UploadPipelineParams) SetTimeout(timeout time.Duration) {
	o.timeout = timeout
}

// WithContext adds the context to the upload pipeline params
func (o *UploadPipelineParams) WithContext(ctx context.Context) *UploadPipelineParams {
	o.SetContext(ctx)
	return o
}

// SetContext adds the context to the upload pipeline params
func (o *UploadPipelineParams) SetContext(ctx context.Context) {
	o.Context = ctx
}

// WithHTTPClient adds the HTTPClient to the upload pipeline params
func (o *UploadPipelineParams) WithHTTPClient(client *http.Client) *UploadPipelineParams {
	o.SetHTTPClient(client)
	return o
}

// SetHTTPClient adds the HTTPClient to the upload pipeline params
func (o *UploadPipelineParams) SetHTTPClient(client *http.Client) {
	o.HTTPClient = client
}

// WithDescription adds the description to the upload pipeline params
func (o *UploadPipelineParams) WithDescription(description *string) *UploadPipelineParams {
	o.SetDescription(description)
	return o
}

// SetDescription adds the description to the upload pipeline params
func (o *UploadPipelineParams) SetDescription(description *string) {
	o.Description = description
}

// WithName adds the name to the upload pipeline params
func (o *UploadPipelineParams) WithName(name *string) *UploadPipelineParams {
	o.SetName(name)
	return o
}

// SetName adds the name to the upload pipeline params
func (o *UploadPipelineParams) SetName(name *string) {
	o.Name = name
}

// WithUploadfile adds the uploadfile to the upload pipeline params
func (o *UploadPipelineParams) WithUploadfile(uploadfile runtime.NamedReadCloser) *UploadPipelineParams {
	o.SetUploadfile(uploadfile)
	return o
}

// SetUploadfile adds the uploadfile to the upload pipeline params
func (o *UploadPipelineParams) SetUploadfile(uploadfile runtime.NamedReadCloser) {
	o.Uploadfile = uploadfile
}

// WriteToRequest writes these params to a swagger request
func (o *UploadPipelineParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {

	if err := r.SetTimeout(o.timeout); err != nil {
		return err
	}
	var res []error

	if o.Description != nil {

		// query param description
		var qrDescription string
		if o.Description != nil {
			qrDescription = *o.Description
		}
		qDescription := qrDescription
		if qDescription != "" {
			if err := r.SetQueryParam("description", qDescription); err != nil {
				return err
			}
		}

	}

	if o.Name != nil {

		// query param name
		var qrName string
		if o.Name != nil {
			qrName = *o.Name
		}
		qName := qrName
		if qName != "" {
			if err := r.SetQueryParam("name", qName); err != nil {
				return err
			}
		}

	}

	// form file param uploadfile
	if err := r.SetFileParam("uploadfile", o.Uploadfile); err != nil {
		return err
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}