text:
#ifndef NN_STOPWATCH_INCLUDED
#define NN_STOPWATCH_INCLUDED

#include "err.h"
#include "int.h"

/*  Check whether measured time is the expected time (in microseconds).
    The upper tolerance is 50ms so that the test doesn't fail even on
    very slow or very loaded systems.  Likewise on some systems we can
    wind up firing up to a single tick early (Windows), so the lower bound
    is pretty low.  The consequence of this is that programs which  specify
    a timeout should be a little more pessimistic (at least 10ms) then they
    might otherwise think they need to be. */
#define time_assert(actual,expected) \
    nn_assert (actual > ((expected) - 10000) && actual < ((expected) + 50000));

/*  Measures time interval in microseconds. */

struct nn_stopwatch {
    uint64_t start;
};

void nn_stopwatch_init (struct nn_stopwatch *self);
uint64_t nn_stopwatch_term (struct nn_stopwatch *self);

#endif

redpajama_set_name: RedPajamaGithub


text:
using System;
using Esb.Message;

namespace Esb.Transport
{
    /// <summary>
    /// Used to receive a message over the transportation layer
    /// </summary>
    public interface IReceiver
    {
        void Receive(Envelope messageEnvelope);
        Action<Envelope> MessageArrived { get; set; }
    }
}


text:
import React from 'react';
import PropTypes from 'prop-types';
import Slot from 'rsg-components/Slot';
import SectionHeadingRenderer from 'rsg-components/SectionHeading/SectionHeadingRenderer';

interface SectionHeadingProps {
	children?: React.ReactNode;
	id: string;
	slotName: string;
	slotProps: Record<string, unknown>;
	depth: number;
	href?: string;
	deprecated?: boolean;
	pagePerSection?: boolean;
}

const SectionHeading: React.FunctionComponent<SectionHeadingProps> = ({
	slotName,
	slotProps,
	children,
	id,
	href,
	...rest
}) => {
	return (
		<SectionHeadingRenderer
			toolbar={<Slot name={slotName} props={slotProps} />}
			id={id}
			href={href}
			{...rest}
		>
			{children}
		</SectionHeadingRenderer>
	);
};

SectionHeading.propTypes = {
	children: PropTypes.node,
	id: PropTypes.string.isRequired,
	slotName: PropTypes.string.isRequired,
	slotProps: PropTypes.any.isRequired,
	depth: PropTypes.number.isRequired,
	deprecated: PropTypes.bool,
	pagePerSection: PropTypes.bool,
};

export default SectionHeading;


text:
CREATE TABLE t1(a,b);
    INSERT INTO t1 VALUES(1,'abcdefgh');
    INSERT INTO t1 SELECT a+1, b||b FROM t1;
    INSERT INTO t1 SELECT a+2, b||b FROM t1;
    INSERT INTO t1 SELECT a+4, b||b FROM t1;
    SELECT count(*), max(length(b)) FROM t1;


text:
<?php
namespace Payum\Payex\Request\Api;

use Payum\Core\Request\BaseModelRequest;

class AutoPayAgreementRequest extends BaseModelRequest
{
}


text:
package org.hcjf.layers.plugins;

import org.hcjf.utils.Version;

import java.nio.ByteBuffer;

/**
 * @author javaito
 */
public class Plugin {

    private final String groupName;
    private final String name;
    private final Version version;
    private final ByteBuffer jarBuffer;

    public Plugin(String groupName, String name, Version version, ByteBuffer jarBuffer) {
        this.groupName = groupName;
        this.name = name;
        this.version = version;
        this.jarBuffer = jarBuffer;
    }

    /**
     * Return the group name.
     * @return Group name.
     */
    public String getGroupName() {
        return groupName;
    }

    /**
     * Return the plugin name.
     * @return Plugin name.
     */
    public String getName() {
        return name;
    }

    /**
     * Return the plugin version.
     * @return Plugin version.
     */
    public Version getVersion() {
        return version;
    }

    /**
     * Return the in-memory jar file.
     * @return In-memory jar file.
     */
    public ByteBuffer getJarBuffer() {
        return jarBuffer;
    }

    @Override
    public String toString() {
        return groupName + ", " + name + ", " + version.toString();
    }
}


text:
export const disable = (element:JQuery<Element>):void =>{
	element.addClass('is-disabled').prop('disabled', true)
}

export const enable = (element:JQuery<Element>):void =>{
	element.removeClass('is-disabled').prop('disabled', false)
}


text:
<resources>

    <!-- Base application theme. -->
    <style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">

        <!-- Changes statusBarColor when app visible-->
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:statusBarColor">@color/material_blue_700</item>

        <!-- ActionBar color on recents screen-->
        <item name="colorPrimary">@color/material_blue_500</item>
        <!-- Status bar color  -->
        <item name="colorPrimaryDark">@color/material_blue_700</item>

    </style>

    <style name="AppTheme" parent="AppTheme.Base"/>
</resources>


text:
#include "arm_math.h"
/**
 * @ingroup groupFilters
 */

/**
 * @addtogroup LMS
 * @{
 */

 /**
 * @brief Processing function for Q31 LMS filter.
 * @param[in]  *S points to an instance of the Q15 LMS filter structure.
 * @param[in]  *pSrc points to the block of input data.
 * @param[in]  *pRef points to the block of reference data.
 * @param[out] *pOut points to the block of output data.
 * @param[out] *pErr points to the block of error data.
 * @param[in]  blockSize number of samples to process.
 * @return     none.
 *
 * \par Scaling and Overflow Behavior:
 * The function is implemented using an internal 64-bit accumulator.
 * The accumulator has a 2.62 format and maintains full precision of the intermediate
 * multiplication results but provides only a single guard bit.
 * Thus, if the accumulator result overflows it wraps around rather than clips.
 * In order to avoid overflows completely the input signal must be scaled down by
 * log2(numTaps) bits.
 * The reference signal should not be scaled down.
 * After all multiply-accumulates are performed, the 2.62 accumulator is shifted
 * and saturated to 1.31 format to yield the final result.
 * The output signal and error signal are in 1.31 format.
 *
 * \par
 * 	In this filter, filter coefficients are updated for each sample and the updation of filter cofficients are saturted.
 */

void arm_lms_q31(
  const arm_lms_instance_q31 * S,
  q31_t * pSrc,
  q31_t * pRef,
  q31_t * pOut,
  q31_t * pErr,
  uint32_t blockSize)
{
  q31_t *pState = S->pState;                     /* State pointer */
  uint32_t numTaps = S->numTaps;                 /* Number of filter coefficients in the filter */
  q31_t *pCoeffs = S->pCoeffs;                   /* Coefficient pointer */
  q31_t *pStateCurnt;                            /* Points to the current sample of the state */
  q31_t mu = S->mu;                              /* Adaptive factor */
  q31_t *px;                                     /* Temporary pointer for state */
  q31_t *pb;                                     /* Temporary pointer for coefficient buffer */
  uint32_t tapCnt, blkCnt;                       /* Loop counters */
  q63_t acc;                                     /* Accumulator */
  q31_t e = 0;                                   /* error of data sample */
  q31_t alpha;                                   /* Intermediate constant for taps update */
  q31_t coef;                                    /* Temporary variable for coef */
  q31_t acc_l, acc_h;                            /*  temporary input */
  uint32_t uShift = ((uint32_t) S->postShift + 1u);
  uint32_t lShift = 32u - uShift;                /*  Shift to be applied to the output */

  /* S->pState points to buffer which contains previous frame (numTaps - 1) samples */
  /* pStateCurnt points to the location where the new input data should be written */
  pStateCurnt = &(S->pState[(numTaps - 1u)]);

  /* Initializing blkCnt with blockSize */
  blkCnt = blockSize;

#ifndef ARM_MATH_CM0_FAMILY

  /* Run the below code for Cortex-M4 and Cortex-M3 */

  while(blkCnt > 0u)
  {
    /* Copy the new input sample into the state buffer */
    *pStateCurnt++ = *pSrc++;

    /* Initialize state pointer */
    px = pState;

    /* Initialize coefficient pointer */
    pb = pCoeffs;

    /* Set the accumulator to zero */
    acc = 0;

    /* Loop unrolling.  Process 4 taps at a time. */
    tapCnt = numTaps >> 2;

    while(tapCnt > 0u)
    {
      /* Perform the multiply-accumulate */
      /* acc +=  b[N] * x[n-N] */
      acc += ((q63_t) (*px++)) * (*pb++);

      /* acc +=  b[N-1] * x[n-N-1] */
      acc += ((q63_t) (*px++)) * (*pb++);

      /* acc +=  b[N-2] * x[n-N-2] */
      acc += ((q63_t) (*px++)) * (*pb++);

      /* acc +=  b[N-3] * x[n-N-3] */
      acc += ((q63_t) (*px++)) * (*pb++);

      /* Decrement the loop counter */
      tapCnt--;
    }

    /* If the filter length is not a multiple of 4, compute the remaining filter taps */
    tapCnt = numTaps % 0x4u;

    while(tapCnt > 0u)
    {
      /* Perform the multiply-accumulate */
      acc += ((q63_t) (*px++)) * (*pb++);

      /* Decrement the loop counter */
      tapCnt--;
    }

    /* Converting the result to 1.31 format */
    /* Calc lower part of acc */
    acc_l = acc & 0xffffffff;

    /* Calc upper part of acc */
    acc_h = (acc >> 32) & 0xffffffff;

    acc = (uint32_t) acc_l >> lShift | acc_h << uShift;

    /* Store the result from accumulator into the destination buffer. */
    *pOut++ = (q31_t) acc;

    /* Compute and store error */
    e = *pRef++ - (q31_t) acc;

    *pErr++ = (q31_t) e;

    /* Compute alpha i.e. intermediate constant for taps update */
    alpha = (q31_t) (((q63_t) e * mu) >> 31);

    /* Initialize state pointer */
    /* Advance state pointer by 1 for the next sample */
    px = pState++;

    /* Initialize coefficient pointer */
    pb = pCoeffs;

    /* Loop unrolling.  Process 4 taps at a time. */
    tapCnt = numTaps >> 2;

    /* Update filter coefficients */
    while(tapCnt > 0u)
    {
      /* coef is in 2.30 format */
      coef = (q31_t) (((q63_t) alpha * (*px++)) >> (32));
      /* get coef in 1.31 format by left shifting */
      *pb = clip_q63_to_q31((q63_t) * pb + (coef << 1u));
      /* update coefficient buffer to next coefficient */
      pb++;

      coef = (q31_t) (((q63_t) alpha * (*px++)) >> (32));
      *pb = clip_q63_to_q31((q63_t) * pb + (coef << 1u));
      pb++;

      coef = (q31_t) (((q63_t) alpha * (*px++)) >> (32));
      *pb = clip_q63_to_q31((q63_t) * pb + (coef << 1u));
      pb++;

      coef = (q31_t) (((q63_t) alpha * (*px++)) >> (32));
      *pb = clip_q63_to_q31((q63_t) * pb + (coef << 1u));
      pb++;

      /* Decrement the loop counter */
      tapCnt--;
    }

    /* If the filter length is not a multiple of 4, compute the remaining filter taps */
    tapCnt = numTaps % 0x4u;

    while(tapCnt > 0u)
    {
      /* Perform the multiply-accumulate */
      coef = (q31_t) (((q63_t) alpha * (*px++)) >> (32));
      *pb = clip_q63_to_q31((q63_t) * pb + (coef << 1u));
      pb++;

      /* Decrement the loop counter */
      tapCnt--;
    }

    /* Decrement the loop counter */
    blkCnt--;
  }

  /* Processing is complete. Now copy the last numTaps - 1 samples to the
     satrt of the state buffer. This prepares the state buffer for the
     next function call. */

  /* Points to the start of the pState buffer */
  pStateCurnt = S->pState;

  /* Loop unrolling for (numTaps - 1u) samples copy */
  tapCnt = (numTaps - 1u) >> 2u;

  /* copy data */
  while(tapCnt > 0u)
  {
    *pStateCurnt++ = *pState++;
    *pStateCurnt++ = *pState++;
    *pStateCurnt++ = *pState++;
    *pStateCurnt++ = *pState++;

    /* Decrement the loop counter */
    tapCnt--;
  }

  /* Calculate remaining number of copies */
  tapCnt = (numTaps - 1u) % 0x4u;

  /* Copy the remaining q31_t data */
  while(tapCnt > 0u)
  {
    *pStateCurnt++ = *pState++;

    /* Decrement the loop counter */
    tapCnt--;
  }

#else

  /* Run the below code for Cortex-M0 */

  while(blkCnt > 0u)
  {
    /* Copy the new input sample into the state buffer */
    *pStateCurnt++ = *pSrc++;

    /* Initialize pState pointer */
    px = pState;

    /* Initialize pCoeffs pointer */
    pb = pCoeffs;

    /* Set the accumulator to zero */
    acc = 0;

    /* Loop over numTaps number of values */
    tapCnt = numTaps;

    while(tapCnt > 0u)
    {
      /* Perform the multiply-accumulate */
      acc += ((q63_t) (*px++)) * (*pb++);

      /* Decrement the loop counter */
      tapCnt--;
    }

    /* Converting the result to 1.31 format */
    /* Store the result from accumulator into the destination buffer. */
    /* Calc lower part of acc */
    acc_l = acc & 0xffffffff;

    /* Calc upper part of acc */
    acc_h = (acc >> 32) & 0xffffffff;

    acc = (uint32_t) acc_l >> lShift | acc_h << uShift;

    *pOut++ = (q31_t) acc;

    /* Compute and store error */
    e = *pRef++ - (q31_t) acc;

    *pErr++ = (q31_t) e;

    /* Weighting factor for the LMS version */
    alpha = (q31_t) (((q63_t) e * mu) >> 31);

    /* Initialize pState pointer */
    /* Advance state pointer by 1 for the next sample */
    px = pState++;

    /* Initialize pCoeffs pointer */
    pb = pCoeffs;

    /* Loop over numTaps number of values */
    tapCnt = numTaps;

    while(tapCnt > 0u)
    {
      /* Perform the multiply-accumulate */
      coef = (q31_t) (((q63_t) alpha * (*px++)) >> (32));
      *pb = clip_q63_to_q31((q63_t) * pb + (coef << 1u));
      pb++;

      /* Decrement the loop counter */
      tapCnt--;
    }

    /* Decrement the loop counter */
    blkCnt--;
  }

  /* Processing is complete. Now copy the last numTaps - 1 samples to the
     start of the state buffer. This prepares the state buffer for the
     next function call. */

  /* Points to the start of the pState buffer */
  pStateCurnt = S->pState;

  /*  Copy (numTaps - 1u) samples  */
  tapCnt = (numTaps - 1u);

  /* Copy the data */
  while(tapCnt > 0u)
  {
    *pStateCurnt++ = *pState++;

    /* Decrement the loop counter */
    tapCnt--;
  }

#endif /*   #ifndef ARM_MATH_CM0_FAMILY */

}

/**
   * @} end of LMS group
   */


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

namespace LifxNet
{
	public class DeviceStateVersionResponse : LifxResponseBase
	{
		public DeviceStateVersionResponse(byte[] payload) : base()
		{
			Vendor = BitConverter.ToUInt32(payload, 0);
			Product = BitConverter.ToUInt32(payload, 4);
			Version = BitConverter.ToUInt32(payload, 8);
		}
		/// <summary>
		/// Vendor ID
		/// </summary>
		public UInt32 Vendor { get; private set; }
		/// <summary>
		/// Product ID
		/// </summary>
		public UInt32 Product { get; private set; }
		/// <summary>
		/// Hardware version
		/// </summary>
		public UInt32 Version { get; private set; }
	}
}


text:
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright 2016 Snehankur Chakraborty
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@color/primary2_home">

    <TextView
        android:id="@+id/tvContent"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_marginTop="5dp"
        android:layout_marginBottom="5dp"
        android:ellipsize="end"
        android:singleLine="true"
        android:text="2500"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textColor="@android:color/white"
        android:textSize="12dp"/>

</RelativeLayout>


text:
typedef NS_OPTIONS(unsigned int, PBPebbleKitLogFlag) {
  PBPebbleKitLogFlagError      = (1 << 0), // 0...00001
  PBPebbleKitLogFlagWarning    = (1 << 1), // 0...00010
  PBPebbleKitLogFlagInfo       = (1 << 2), // 0...00100
  PBPebbleKitLogFlagDebug      = (1 << 3), // 0...01000
  PBPebbleKitLogFlagVerbose    = (1 << 4)  // 0...10000
};

typedef NS_ENUM(unsigned int, PBPebbleKitLogLevel) {
  PBPebbleKitLogLevelOff       = 0,
  PBPebbleKitLogLevelError     = (PBPebbleKitLogFlagError),                                // 0...00001
  PBPebbleKitLogLevelWarning   = (PBPebbleKitLogLevelError   | PBPebbleKitLogFlagWarning), // 0...00011
  PBPebbleKitLogLevelInfo      = (PBPebbleKitLogLevelWarning | PBPebbleKitLogFlagInfo),    // 0...00111
  PBPebbleKitLogLevelDebug     = (PBPebbleKitLogLevelInfo    | PBPebbleKitLogFlagDebug),   // 0...01111
  PBPebbleKitLogLevelVerbose   = (PBPebbleKitLogLevelDebug   | PBPebbleKitLogFlagVerbose), // 0...11111
  PBPebbleKitLogLevelAll       = 0xffffffff                                                // 1...11111 (PBLogLevelVerbose plus any other flags)
};


text:
/*global browser, element, by */
describe('Getting Started E2E Tests', function() {

	// #docregion shared
	var expectedMsg = 'My First Angular 2 App';

	// tests shared across languages
	function sharedTests(basePath) {
		beforeEach(function () {
			browser.get(basePath + 'index.html');
		});

		it('should display: '+ expectedMsg, function() {
			expect(element(by.id('output')).getText()).toEqual(expectedMsg);
		});
	}
	// #enddocregion

	describe('Getting Started in JavaScript', function() {
		sharedTests('gettingstarted/js/');
	});

	describe('Getting Started in TypeScript', function() {
		sharedTests('gettingstarted/ts/');
	});

});


text:
<!--
$Id: antActionSpec.xml 1767 2009-06-24 20:06:18Z saksass $
$HeadURL: https://ncisvn.nci.nih.gov/svn/automation/trunk/software/bda-build-template/software/build/gui-installer/antActionSpec.xml $
-->
<antactions>
	<pack name="download_install">
		<antcall buildfile="$SYSTEM_user_home/${installer.dir}/build.xml"
			order="afterpack"
			verbose="yes"
			logfile="$SYSTEM_user_home/${installer.dir}/download_install-antlog_installer.txt"
			inheritall="false"
			messageid="AntAction.download-install"
			>
			<target name="install"/>
			<property name="install.path" value="$SYSTEM_user_home/${installer.dir}"/>
		</antcall>
	</pack>

	<pack name="download_upgrade">
		<antcall buildfile="$SYSTEM_user_home/${installer.dir}/build.xml"
			order="afterpack"
			verbose="yes"
			logfile="$SYSTEM_user_home/${installer.dir}/download-upgrade-antlog_installer.txt"
			inheritall="false"
			messageid="AntAction.download-upgrade"
			>
			<target name="upgrade"/>
			<property name="install.path" value="$SYSTEM_user_home/${installer.dir}"/>
		</antcall>
	</pack>

	<pack name="convert-install-path">
		<antcall buildfile="$SYSTEM_user_home/${installer.dir}/build.xml"
			order="afterpack"
			verbose="yes"
			logfile="$SYSTEM_user_home/${installer.dir}/convert-install-path-antlog_installer.txt"
			inheritall="false"
			messageid="AntAction.convert-install-path"
			>
			<target name="convert-install-path"/>
			<property name="install.base.path" value="$UserPathPanelVariable"/>
			<property name="install.path" value="$SYSTEM_user_home/${installer.dir}"/>
		</antcall>
	</pack>

	<pack name="convert-upgrade-path">
		<antcall buildfile="$SYSTEM_user_home/${installer.dir}/build.xml"
			order="afterpack"
			verbose="yes"
			logfile="$SYSTEM_user_home/${installer.dir}/convert-upgrade-path-antlog_installer.txt"
			inheritall="false"
			messageid="AntAction.convert-upgrade-path"
			>
			<target name="convert-upgrade-path"/>
			<property name="application.base.path" value="${application.base.path}"/>
			<property name="jboss.home" value="${jboss.home}"/>
			<property name="tomcat.home" value="${tomcat.home}"/>
			<property name="install.path" value="$SYSTEM_user_home/${installer.dir}"/>
		</antcall>
	</pack>

	<pack name="install-application">
		<antcall buildfile="$SYSTEM_user_home/${installer.dir}/build.xml"
			order="afterpacks"
			verbose="yes"
			logfile="$SYSTEM_user_home/${installer.dir}/antlog_installer.txt"
			inheritall="false"
			messageid="AntAction.install-application"
			>
			<target name="install-application"/>
			<property name="install.path" value="$SYSTEM_user_home/${installer.dir}"/>
			<property name="build.file.target" value="${build.file.target}"/>
		</antcall>
	</pack>
</antactions>


text:
<?php

namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;

class DefaultController extends Controller
{
    /**
     * @Route("/appbundle", name="homepage")
     */
    public function indexAction(Request $request)
    {
        // replace this example code with whatever you need
        return $this->render('default/liste_tweet.html.twig', [
            'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
        ]);
    }
}


text:
	<link rel="stylesheet" href="style/foundation.css">
	<link rel="stylesheet" type="text/css" href="style/profilewords.css">
	<link href="http://fonts.googleapis.com/css?family=Patrick+Hand" rel="stylesheet" type="text/css">
	<meta name="viewport" content="width=device-width,initial-scale=1">
	<title>Followers Profile Words</title>

ProfileWords

social biographies

Identity as word clouds

[ no automatic tweets ]


text:
package com.glaf.sms.query;

import java.util.*;
import com.glaf.core.query.DataQuery;

public class SmsVerifyMessageQuery extends DataQuery {
	private static final long serialVersionUID = 1L;
	protected String mobile;
	protected String type;
	protected Date sendTimeGreaterThanOrEqual;
	protected Date sendTimeLessThanOrEqual;
	protected Long sendTimeMs;
	protected Long sendTimeMsGreaterThanOrEqual;
	protected Long sendTimeMsLessThanOrEqual;

	public SmsVerifyMessageQuery() {

	}

	public String getMobile() {
		return mobile;
	}

	public String getOrderBy() {
		if (sortColumn != null) {
			String a_x = " asc ";
			if (sortOrder != null) {
				a_x = sortOrder;
			}

			if ("name".equals(sortColumn)) {
				orderBy = "E.NAME_" + a_x;
			}

			if ("mobile".equals(sortColumn)) {
				orderBy = "E.MOBILE_" + a_x;
			}

			if ("type".equals(sortColumn)) {
				orderBy = "E.TYPE_" + a_x;
			}

			if ("verificationCode".equals(sortColumn)) {
				orderBy = "E.VERIFICATIONCODE_" + a_x;
			}

			if ("status".equals(sortColumn)) {
				orderBy = "E.STATUS_" + a_x;
			}

			if ("sendTime".equals(sortColumn)) {
				orderBy = "E.SENDTIME_" + a_x;
			}

			if ("sendTimeMs".equals(sortColumn)) {
				orderBy = "E.SENDTIMEMS_" + a_x;
			}

			if ("createTime".equals(sortColumn)) {
				orderBy = "E.CREATETIME_" + a_x;
			}

		}
		return orderBy;
	}

	public Date getSendTimeGreaterThanOrEqual() {
		return sendTimeGreaterThanOrEqual;
	}

	public Date getSendTimeLessThanOrEqual() {
		return sendTimeLessThanOrEqual;
	}

	public Long getSendTimeMs() {
		return sendTimeMs;
	}

	public Long getSendTimeMsGreaterThanOrEqual() {
		return sendTimeMsGreaterThanOrEqual;
	}

	public Long getSendTimeMsLessThanOrEqual() {
		return sendTimeMsLessThanOrEqual;
	}

	public String getType() {
		return type;
	}

	@Override
	public void initQueryColumns() {
		super.initQueryColumns();
		addColumn("id", "ID_");
		addColumn("name", "NAME_");
		addColumn("mobile", "MOBILE_");
		addColumn("type", "TYPE_");
		addColumn("verificationCode", "VERIFICATIONCODE_");
		addColumn("status", "STATUS_");
		addColumn("sendTime", "SENDTIME_");
		addColumn("sendTimeMs", "SENDTIMEMS_");
		addColumn("createTime", "CREATETIME_");
	}

	public SmsVerifyMessageQuery mobile(String mobile) {
		if (mobile == null) {
			throw new RuntimeException("mobile is null");
		}
		this.mobile = mobile;
		return this;
	}

	public SmsVerifyMessageQuery sendTimeGreaterThanOrEqual(Date sendTimeGreaterThanOrEqual) {
		if (sendTimeGreaterThanOrEqual == null) {
			throw new RuntimeException("sendTime is null");
		}
		this.sendTimeGreaterThanOrEqual = sendTimeGreaterThanOrEqual;
		return this;
	}

	public SmsVerifyMessageQuery sendTimeLessThanOrEqual(Date sendTimeLessThanOrEqual) {
		if (sendTimeLessThanOrEqual == null) {
			throw new RuntimeException("sendTime is null");
		}
		this.sendTimeLessThanOrEqual = sendTimeLessThanOrEqual;
		return this;
	}

	public SmsVerifyMessageQuery sendTimeMs(Long sendTimeMs) {
		if (sendTimeMs == null) {
			throw new RuntimeException("sendTimeMs is null");
		}
		this.sendTimeMs = sendTimeMs;
		return this;
	}

	public SmsVerifyMessageQuery sendTimeMsGreaterThanOrEqual(Long sendTimeMsGreaterThanOrEqual) {
		if (sendTimeMsGreaterThanOrEqual == null) {
			throw new RuntimeException("sendTimeMs is null");
		}
		this.sendTimeMsGreaterThanOrEqual = sendTimeMsGreaterThanOrEqual;
		return this;
	}

	public SmsVerifyMessageQuery sendTimeMsLessThanOrEqual(Long sendTimeMsLessThanOrEqual) {
		if (sendTimeMsLessThanOrEqual == null) {
			throw new RuntimeException("sendTimeMs is null");
		}
		this.sendTimeMsLessThanOrEqual = sendTimeMsLessThanOrEqual;
		return this;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public void setSendTimeGreaterThanOrEqual(Date sendTimeGreaterThanOrEqual) {
		this.sendTimeGreaterThanOrEqual = sendTimeGreaterThanOrEqual;
	}

	public void setSendTimeLessThanOrEqual(Date sendTimeLessThanOrEqual) {
		this.sendTimeLessThanOrEqual = sendTimeLessThanOrEqual;
	}

	public void setSendTimeMs(Long sendTimeMs) {
		this.sendTimeMs = sendTimeMs;
	}

	public void setSendTimeMsGreaterThanOrEqual(Long sendTimeMsGreaterThanOrEqual) {
		this.sendTimeMsGreaterThanOrEqual = sendTimeMsGreaterThanOrEqual;
	}

	public void setSendTimeMsLessThanOrEqual(Long sendTimeMsLessThanOrEqual) {
		this.sendTimeMsLessThanOrEqual = sendTimeMsLessThanOrEqual;
	}

	public void setType(String type) {
		this.type = type;
	}

	public SmsVerifyMessageQuery type(String type) {
		if (type == null) {
			throw new RuntimeException("type is null");
		}
		this.type = type;
		return this;
	}

}


text:
require "blacklist"
require "cmd/doctor"
require "cmd/search"
require "cmd/tap"
require "formula_installer"
require "hardware"

module Homebrew
  def install
    raise FormulaUnspecifiedError if ARGV.named.empty?

    if ARGV.include? '--head'
      raise "Specify `--HEAD` in uppercase to build from trunk."
    end

    ARGV.named.each do |name|
      if !File.exist?(name) && (name =~ HOMEBREW_TAP_FORMULA_REGEX \
                                || name =~ HOMEBREW_CASK_TAP_FORMULA_REGEX)
        install_tap $1, $2
      end
    end unless ARGV.force?

    begin
      formulae = []

      if OS.mac? && ARGV.casks.any?
        brew_cask = Formulary.factory("brew-cask")
        install_formula(brew_cask) unless brew_cask.installed?
        args = []
        args << "--force" if ARGV.force?
        args << "--debug" if ARGV.debug?
        args << "--verbose" if ARGV.verbose?

        ARGV.casks.each do |c|
          cmd = "brew", "cask", "install", c, *args
          ohai cmd.join " "
          system(*cmd)
        end
      end

      ARGV.formulae.each do |f|
        # head-only without --HEAD is an error
        if not ARGV.build_head? and f.stable.nil? and f.devel.nil?
          raise <<-EOS.undent
          #{f.name} is a head-only formula
          Install with `brew install --HEAD #{f.name}`
          EOS
        end

        # devel-only without --devel is an error
        if not ARGV.build_devel? and f.stable.nil? and f.head.nil?
          raise <<-EOS.undent
          #{f.name} is a devel-only formula
          Install with `brew install --devel #{f.name}`
          EOS
        end

        if ARGV.build_stable? and f.stable.nil?
          raise "#{f.name} has no stable download, please choose --devel or --HEAD"
        end

        # --HEAD, fail with no head defined
        if ARGV.build_head? and f.head.nil?
          raise "No head is defined for #{f.name}"
        end

        # --devel, fail with no devel defined
        if ARGV.build_devel? and f.devel.nil?
          raise "No devel block is defined for #{f.name}"
        end

        if f.installed?
          msg = "#{f.name}-#{f.installed_version} already installed"
          msg << ", it's just not linked" unless f.linked_keg.symlink? or f.keg_only?
          opoo msg
        else
          formulae << f
        end
      end

      perform_preinstall_checks

      formulae.each { |f| install_formula(f) }
    rescue FormulaUnavailableError => e
      if (blacklist = blacklisted?(e.name))
        ofail "#{e.message}\n#{blacklist}"
      else
        ofail e.message
        query = query_regexp(e.name)
        puts "Searching formulae..."
        puts_columns(search_formulae(query))
        puts "Searching taps..."
        puts_columns(search_taps(query))
      end
    end
  end

  def check_ppc
    case Hardware::CPU.type when :ppc, :dunno
      abort <<-EOS.undent
        Sorry, Homebrew does not support your computer's CPU architecture.
        For PPC support, see: https://github.com/mistydemeo/tigerbrew
        EOS
    end
  end

  def check_writable_install_location
    raise "Cannot write to #{HOMEBREW_CELLAR}" if HOMEBREW_CELLAR.exist? and not HOMEBREW_CELLAR.writable_real?
    raise "Cannot write to #{HOMEBREW_PREFIX}" unless HOMEBREW_PREFIX.writable_real? or HOMEBREW_PREFIX.to_s == '/usr/local'
  end

  def check_xcode
    checks = Checks.new
    %w[
      check_for_installed_developer_tools
      check_xcode_license_approved
      check_for_osx_gcc_installer
      check_for_bad_install_name_tool
    ].each do |check|
      out = checks.send(check)
      opoo out unless out.nil?
    end
  end

  def check_macports
    unless MacOS.macports_or_fink.empty?
      opoo "It appears you have MacPorts or Fink installed."
      puts "Software installed with other package managers causes known problems for"
      puts "Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again."
    end
  end

  def check_cellar
    FileUtils.mkdir_p HOMEBREW_CELLAR if not File.exist? HOMEBREW_CELLAR
  rescue
    raise <<-EOS.undent
      Could not create #{HOMEBREW_CELLAR}
      Check you have permission to write to #{HOMEBREW_CELLAR.parent}
    EOS
  end

  def perform_preinstall_checks
    check_ppc
    check_writable_install_location
    check_xcode
    check_cellar
  end

  def install_formula f
    f.print_tap_action

    fi = FormulaInstaller.new(f)
    fi.options             = f.build.used_options
    fi.ignore_deps         = ARGV.ignore_deps?
    fi.only_deps           = ARGV.only_deps?
    fi.build_bottle        = ARGV.build_bottle?
    fi.build_from_source   = ARGV.build_from_source?
    fi.force_bottle        = ARGV.force_bottle?
    fi.interactive         = ARGV.interactive?
    fi.git                 = ARGV.git?
    fi.verbose             = ARGV.verbose?
    fi.quieter             = ARGV.quieter?
    fi.debug               = ARGV.debug?
    fi.prelude
    fi.install
    fi.caveats
    fi.finish
  rescue FormulaInstallationAlreadyAttemptedError
    # We already attempted to install f as part of the dependency tree of
    # another formula. In that case, don't generate an error, just move on.
  rescue CannotInstallFormulaError => e
    ofail e.message
  rescue BuildError
    check_macports
    raise
  end
end


text:
<!DOCTYPE html>

	<meta charset="utf-8">

	<title>SIXLSXWorkbook Class Reference</title>

	<link rel="stylesheet" href="../css/style.css">
	<meta name="viewport" content="initial-scale=1, maximum-scale=1.4">
	<meta name="generator" content="appledoc 2.2.1 (build 1334)">

				SIXLSXWriter

				Studio Istanbul Medya Hiz. Tic. Ltd. Sti.

Index

Hierarchy

							On This Page

							<select id="jump-to">
	<option value="top">Jump To…</option>

	<option value="overview">Overview</option>

	<option value="tasks">Tasks</option>

	<optgroup label="Class Methods">

		<option value="//api/name/newWorkbookAtURL:">+ newWorkbookAtURL:</option>

		<option value="//api/name/newWorkbookWithOptions:atURL:">+ newWorkbookWithOptions:atURL:</option>

	</optgroup>

	<optgroup label="Instance Methods">

		<option value="//api/name/addChartOfType:">- addChartOfType:</option>

		<option value="//api/name/addFormat">- addFormat</option>

		<option value="//api/name/addWorksheetWithTitle:">- addWorksheetWithTitle:</option>

		<option value="//api/name/closeOrError:">- closeOrError:</option>

		<option value="//api/name/initWithURL:">- initWithURL:</option>

		<option value="//api/name/initWithURL:andOptions:">- initWithURL:andOptions:</option>

		<option value="//api/name/setDocumentPropertiesFromDictionary:">- setDocumentPropertiesFromDictionary:</option>

		<option value="//api/name/worksheets">- worksheets</option>

	</optgroup>

</select>

SIXLSXWorkbook Class Reference

	Inherits from
	NSObject

	Declared in
	SIXLSXWriter.h
SIXLSXWriter.m

Overview

SIXLSXWorkbook is the workbook class and therefore the main class for creating a new workbook file.

+ newWorkbookAtURL:

create a new workbook

+ (SIXLSXWorkbook *)newWorkbookAtURL:(NSURL *)fileURL

Parameters

						fileURL

the NSURL where to store this workbook, must not be nil and a valid URL

Return Value

the newly created workbook

Discussion

create a new workbook

Declared In

SIXLSXWriter.h

+ newWorkbookWithOptions:atURL:

creates a new workbook with specific options.

+ (SIXLSXWorkbook *)newWorkbookWithOptions:(SIXLSXWorkbookOptions *)options atURL:(NSURL *)fileURL

Parameters

						options

the options to use for this workbook or nil.

						fileURL

the NSURL where to store this workbook, must not be nil and a valid URL

Return Value

the newly created workbook

Discussion

creates a new workbook with specific options.

See Also

SIXLSXWorkbookOptions

Declared In

SIXLSXWriter.h

– initWithURL:

initializes a new workbook

- (SIXLSXWorkbook *)initWithURL:(NSURL *)fileUrl

Parameters

						fileUrl

fileURL the NSURL where to store this workbook, must not be nil and a valid URL

Return Value

the initialized workbook

Discussion

initializes a new workbook

Declared In

SIXLSXWriter.h

– initWithURL:andOptions:

initializes a new workbook with specific options.

- (SIXLSXWorkbook *)initWithURL:(NSURL *)fileUrl andOptions:(SIXLSXWorkbookOptions *)options

Parameters

						fileUrl

the NSURL where to store this workbook, must not be nil and a valid URL

						options

the options to use for this workbook or nil.

Return Value

the initialized workbook

Discussion

initializes a new workbook with specific options.

Declared In

SIXLSXWriter.h

– addWorksheetWithTitle:

adds a new worksheet to this workbook. The worksheet name must be a valid Excel worksheet name, i.e. it must be less than 32 character and it cannot contain any of the characters:

- (SIXLSXWorksheet *)addWorksheetWithTitle:(NSString *)worksheetTitle

Parameters

						worksheetTitle

the title for the new worksheet or nil.

Return Value

the newly added and initialized worksheet.

Discussion

adds a new worksheet to this workbook. The worksheet name must be a valid Excel worksheet name, i.e. it must be less than 32 character and it cannot contain any of the characters:

/ \ [ ] : * ?

In addition, you cannot use the same, case insensitive, sheetname for more than one worksheet.

Declared In

SIXLSXWriter.h

– addFormat

creates a new format to be used for formatting cells.

- (SIXLSXFormat *)addFormat

Return Value

the newly added format.

Discussion

creates a new format to be used for formatting cells.

Declared In

SIXLSXWriter.h

– addChartOfType:

adds a new chart of the desired type to the existing workbook.

- (SIXLSXChart *)addChartOfType:(SIXLSXChartType)chartType

Parameters

						chartType

type of chart

Return Value

the newly added chart

Discussion

adds a new chart of the desired type to the existing workbook.

Declared In

SIXLSXWriter.h

– closeOrError:

Closes the current workbook.

- (BOOL)closeOrError:(NSError **)error

Parameters

						error

error if operation failes

Return Value

YES if successfull, NO if error occured.

Discussion

Closes the current workbook.

Declared In

SIXLSXWriter.h

– setDocumentPropertiesFromDictionary:

sets document properties from a NSDictionary.

- (BOOL)setDocumentPropertiesFromDictionary:(NSDictionary *)propertiesDictionary

Parameters

						propertiesDictionary

the dictionary of properties to use

Return Value

YES if successfull, NO if error occured.

Discussion

sets document properties from a NSDictionary.

Supported property keys are:

title

subject

author

manager

company

category

keywords

comments

hyperlink_base

All other keys will be added as custom property. Custom properties can be of type NSString, NSDate or NSNumber.

Declared In

SIXLSXWriter.h

– worksheets

all worksheets in this workbook

- (NSArray *)worksheets

Return Value

array of all worksheets

Discussion

all worksheets in this workbook

Declared In

SIXLSXWriter.h

Copyright © 2017 Studio Istanbul Medya Hiz. Tic. Ltd. Sti. All rights reserved. Updated: 2017-02-02

Generated by appledoc 2.2.1 (build 1334).


text:
param(
  [parameter(Position=0)]
  [string] $Command,
  [string] $Proxy,
  [switch] $Verbosity = $false,
  [alias("g")][switch] $Global = $false,
  [alias("p")][switch] $Persistent = $false,
  [alias("f")][switch] $Force = $false,
  [alias("r")][string] $Runtime,
  [switch] $X86 = $false,
  [switch] $Amd64 = $false,
  #deprecated
  [switch] $X64 = $false,
  #deprecated
  [switch] $Svr50 = $false,
  #deprecated
  [switch] $Svrc50 = $false,
  [alias("w")][switch] $Wait = $false,
  [alias("a")]
  [string] $Alias = $null,
  [switch] $NoNative = $false,
  [parameter(Position=1, ValueFromRemainingArguments=$true)]
  [string[]]$Args=@()
)

$selectedArch=$null;
$defaultArch="x86"
$selectedRuntime=$null
$defaultRuntime="CLR"
$userKrePath = $env:USERPROFILE + "\.kre"
$userKrePackages = $userKrePath + "\packages"
$globalKrePath = $env:ProgramFiles + "\KRE"
$globalKrePackages = $globalKrePath + "\packages"
$feed = $env:KRE_NUGET_API_URL

function String-IsEmptyOrWhitespace([string]$str) {
     return [string]::IsNullOrEmpty($str) -or $str.Trim().length -eq 0
}

if (!$feed)
{
    $feed = "https://www.myget.org/F/aspnetvnext/api/v2";
}

$scriptPath = $myInvocation.MyCommand.Definition

function Kvm-Help {
@"
K Runtime Environment Version Manager - Build {{BUILD_NUMBER}}

USAGE: kvm <command> [options]

kvm upgrade [-X86][-Amd64] [-r|-Runtime CLR|CoreCLR] [-g|-Global] [-f|-Force] [-Proxy <ADDRESS>] [-NoNative]
  install latest KRE from feed
  set 'default' alias to installed version
  add KRE bin to user PATH environment variable
  -g|-Global        install to machine-wide location
  -f|-Force         upgrade even if latest is already installed
  -Proxy <ADDRESS>  use given address as proxy when accessing remote server
  -NoNative         Do not generate native images (Effective only for CoreCLR flavors)

kvm install <semver>|<alias>|<nupkg>|latest [-X86][-Amd64] [-r|-Runtime CLR|CoreCLR] [-a|-Alias <alias>] [-g|-Global] [-f|-Force] [-NoNative]
  <semver>|<alias>  install requested KRE from feed
  <nupkg>           install requested KRE from package on local filesystem
  latest            install latest KRE from feed
  add KRE bin to path of current command line
  -p|-Persistent    add KRE bin to PATH environment variables persistently
  -a|-Alias <alias> set alias <alias> for requested KRE on install
  -g|-Global        install to machine-wide location
  -f|-Force         install even if specified version is already installed
  -NoNative         Do not generate native images (Effective only for CoreCLR flavors)

kvm use <semver>|<alias>|none [-X86][-Amd64] [-r|-Runtime CLR|CoreCLR] [-p|-Persistent] [-g|-Global]
  <semver>|<alias>  add KRE bin to path of current command line
  none              remove KRE bin from path of current command line
  -p|-Persistent    add KRE bin to PATH environment variables persistently
  -g|-Global        combined with -p to change machine PATH instead of user PATH

kvm list
  list KRE versions installed

kvm alias
  list KRE aliases which have been defined

kvm alias <alias>
  display value of the specified alias

kvm alias <alias> <semver>|<alias> [-X86][-Amd64] [-r|-Runtime CLR|CoreCLR]
  <alias>            The name of the alias to set
  <semver>|<alias>   The KRE version to set the alias to. Alternatively use the version of the specified alias

kvm unalias <alias>
  remove the specified alias

"@ -replace "`n","`r`n" | Write-Host
}

function Kvm-Global-Setup {
  $kvmBinPath = "$userKrePath\bin"

  If (Needs-Elevation)
  {
    $arguments = "-ExecutionPolicy unrestricted & '$scriptPath' setup -global -wait"
    Start-Process "$psHome\powershell.exe" -Verb runAs -ArgumentList $arguments -Wait
    Write-Host "Adding $kvmBinPath to process PATH"
    Set-Path (Change-Path $env:Path $kvmBinPath ($kvmBinPath))
    Write-Host "Adding $globalKrePath;%USERPROFILE%\.kre to process KRE_HOME"
    $envKreHome = $env:KRE_HOME
    $envKreHome = Change-Path $envKreHome "%USERPROFILE%\.kre" ("%USERPROFILE%\.kre")
    $envKreHome = Change-Path $envKreHome $globalKrePath ($globalKrePath)
    $env:KRE_HOME = $envKreHome
    Write-Host "Setup complete"
    break
  }

  $scriptFolder = [System.IO.Path]::GetDirectoryName($scriptPath)

  Write-Host "Copying file $kvmBinPath\kvm.ps1"
  md $kvmBinPath -Force | Out-Null
  copy "$scriptFolder\kvm.ps1" "$kvmBinPath\kvm.ps1"

  Write-Host "Copying file $kvmBinPath\kvm.cmd"
  copy "$scriptFolder\kvm.cmd" "$kvmBinPath\kvm.cmd"

  Write-Host "Adding $kvmBinPath to process PATH"
  Set-Path (Change-Path $env:Path $kvmBinPath ($kvmBinPath))

  Write-Host "Adding $kvmBinPath to user PATH"
  $userPath = [Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::User)
  $userPath = Change-Path $userPath $kvmBinPath ($kvmBinPath)
  [Environment]::SetEnvironmentVariable("Path", $userPath, [System.EnvironmentVariableTarget]::User)

  Write-Host "Adding $globalKrePath;%USERPROFILE%\.kre to process KRE_HOME"
  $envKreHome = $env:KRE_HOME
  $envKreHome = Change-Path $envKreHome "%USERPROFILE%\.kre" ("%USERPROFILE%\.kre")
  $envKreHome = Change-Path $envKreHome $globalKrePath ($globalKrePath)
  $env:KRE_HOME = $envKreHome

  Write-Host "Adding $globalKrePath;%USERPROFILE%\.kre to machine KRE_HOME"
  $machineKreHome = [Environment]::GetEnvironmentVariable("KRE_HOME", [System.EnvironmentVariableTarget]::Machine)
  $machineKreHome = Change-Path $machineKreHome "%USERPROFILE%\.kre" ("%USERPROFILE%\.kre")
  $machineKreHome = Change-Path $machineKreHome $globalKrePath ($globalKrePath)
  [Environment]::SetEnvironmentVariable("KRE_HOME", $machineKreHome, [System.EnvironmentVariableTarget]::Machine)
}

function Kvm-Global-Upgrade {
  $Persistent = $true
  $Alias="default"
  $versionOrAlias = Kvm-Find-Latest $selectedRuntime $selectedArch
  If (Needs-Elevation) {
    $arguments = "-ExecutionPolicy unrestricted & '$scriptPath' install '$versionOrAlias' -global $(Requested-Switches) -wait"
    Start-Process "$psHome\powershell.exe" -Verb runAs -ArgumentList $arguments -Wait
    Kvm-Set-Global-Process-Path $versionOrAlias
    break
  }
  Kvm-Install $versionOrAlias $true
}

function Kvm-Upgrade {
  $Persistent = $true
  $Alias="default"
  Kvm-Install "latest" $false
}

function Add-Proxy-If-Specified {
param(
  [System.Net.WebClient] $wc
)
  if (!$Proxy) {
    $Proxy = $env:http_proxy
  }
  if ($Proxy) {
    $wp = New-Object System.Net.WebProxy($Proxy)
    $pb = New-Object UriBuilder($Proxy)
    if (!$pb.UserName) {
        $wp.Credentials = [System.Net.CredentialCache]::DefaultCredentials
    } else {
        $wp.Credentials = New-Object System.Net.NetworkCredential($pb.UserName, $pb.Password)
    }
    $wc.Proxy = $wp
  }
}

function Kvm-Find-Latest {
param(
  [string] $platform,
  [string] $architecture
)
  Write-Host "Determining latest version"

  $url = "$feed/GetUpdates()?packageIds=%27KRE-$platform-$architecture%27&versions=%270.0%27&includePrerelease=true&includeAllVersions=false"

  $wc = New-Object System.Net.WebClient
  $wc.Credentials = new-object System.Net.NetworkCredential("aspnetreadonly", "4d8a2d9c-7b80-4162-9978-47e918c9658c")
  Add-Proxy-If-Specified($wc)
  [xml]$xml = $wc.DownloadString($url)

  $version = Select-Xml "//d:Version" -Namespace @{d='http://schemas.microsoft.com/ado/2007/08/dataservices'} $xml

  if (String-IsEmptyOrWhitespace($version)) {
    throw "There are no packages for platform '$platform', architecture '$architecture' in the feed '$feed'"
  }

  return $version
}

function Do-Kvm-Download {
param(
  [string] $kreFullName,
  [string] $packagesFolder
)
  $parts = $kreFullName.Split(".", 2)

  $url = "$feed/package/" + $parts[0] + "/" + $parts[1]
  $kreFolder = Join-Path $packagesFolder $kreFullName
  $kreFile = Join-Path $kreFolder "$kreFullName.nupkg"

  If (Test-Path $kreFolder) {
    if($Force)
    {
      rm $kreFolder -Recurse -Force
    } else {
      Write-Host "$kreFullName already installed."
      return;
    }
  }

  Write-Host "Downloading" $kreFullName "from $feed"

  #Downloading to temp location
  $kreTempDownload = Join-Path $packagesFolder "temp"
  $tempKreFile = Join-Path $kreTempDownload "$kreFullName.nupkg"

  if(Test-Path $kreTempDownload) {
    del "$kreTempDownload\*" -recurse
  } else {
    md $kreTempDownload -Force | Out-Null
  }

  $wc = New-Object System.Net.WebClient
  $wc.Credentials = new-object System.Net.NetworkCredential("aspnetreadonly", "4d8a2d9c-7b80-4162-9978-47e918c9658c")
  Add-Proxy-If-Specified($wc)
  $wc.DownloadFile($url, $tempKreFile)

  Do-Kvm-Unpack $tempKreFile $kreTempDownload

  md $kreFolder -Force | Out-Null
  Write-Host "Installing to $kreFolder"
  mv "$kreTempDownload\*" $kreFolder
  Remove-Item "$kreTempDownload" -Force | Out-Null
}

function Do-Kvm-Unpack {
param(
  [string] $kreFile,
  [string] $kreFolder
)
  Write-Host "Unpacking to" $kreFolder

  $compressionLib = [System.Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem')

  if($compressionLib -eq $null) {
      try {
          # Shell will not recognize nupkg as a zip and throw, so rename it to zip
          $kreZip = [System.IO.Path]::ChangeExtension($kreFile, "zip")
          Rename-Item $kreFile $kreZip
          # Use the shell to uncompress the nupkg
          $shell_app=new-object -com shell.application
          $zip_file = $shell_app.namespace($kreZip)
          $destination = $shell_app.namespace($kreFolder)
          $destination.Copyhere($zip_file.items(), 0x14) #0x4 = don't show UI, 0x10 = overwrite files
      }
      finally {
        # make it a nupkg again
        Rename-Item $kreZip $kreFile
      }
  } else {
      [System.IO.Compression.ZipFile]::ExtractToDirectory($kreFile, $kreFolder)
  }

  If (Test-Path ($kreFolder + "\[Content_Types].xml")) {
    Remove-Item ($kreFolder + "\[Content_Types].xml")
  }
  If (Test-Path ($kreFolder + "\_rels\")) {
    Remove-Item ($kreFolder + "\_rels\") -Force -Recurse
  }
  If (Test-Path ($kreFolder + "\package\")) {
    Remove-Item ($kreFolder + "\package\") -Force -Recurse
  }
}

function Kvm-Install {
param(
  [string] $versionOrAlias,
  [boolean] $isGlobal
)
  if ($versionOrAlias -eq "latest") {
    $versionOrAlias = Kvm-Find-Latest (Requested-Platform $defaultRuntime) (Requested-Architecture $defaultArch)
  }

  if ($versionOrAlias.EndsWith(".nupkg")) {
    $kreFullName = [System.IO.Path]::GetFileNameWithoutExtension($versionOrAlias)
  } else {
    $kreFullName =  Requested-VersionOrAlias $versionOrAlias
  }

  if ($isGlobal) {
    if (Needs-Elevation) {
      $arguments = "-ExecutionPolicy unrestricted & '$scriptPath' install '$versionOrAlias' -global $(Requested-Switches) -wait"
      Start-Process "$psHome\powershell.exe" -Verb runAs -ArgumentList $arguments -Wait
      Kvm-Set-Global-Process-Path $versionOrAlias
      break
    }
    $packageFolder = $globalKrePackages
  } else {
    $packageFolder = $userKrePackages
  }

  if ($versionOrAlias.EndsWith(".nupkg")) {
    Set-Variable -Name "selectedArch" -Value (Package-Arch $kreFullName) -Scope Script
    Set-Variable -Name "selectedRuntime" -Value (Package-Platform $kreFullName) -Scope Script

    $kreFolder = "$packageFolder\$kreFullName"
    $folderExists = Test-Path $kreFolder

    if ($folderExists -and $Force) {
      del $kreFolder -Recurse -Force
      $folderExists = $false;
    }

    if ($folderExists) {
      Write-Host "Target folder '$kreFolder' already exists"
    } else {
      $tempUnpackFolder = Join-Path $packageFolder "temp"
      $tempKreFile = Join-Path $tempUnpackFolder "$kreFullName.nupkg"

      if(Test-Path $tempUnpackFolder) {
          del "$tempUnpackFolder\*" -recurse
      } else {
          md $tempUnpackFolder -Force | Out-Null
      }
      copy $versionOrAlias $tempKreFile

      Do-Kvm-Unpack $tempKreFile $tempUnpackFolder
      md $kreFolder -Force | Out-Null
      Write-Host "Installing to $kreFolder"
      mv "$tempUnpackFolder\*" $kreFolder
      Remove-Item "$tempUnpackFolder" -Force | Out-Null
    }

    $packageVersion = Package-Version $kreFullName

    Kvm-Use $packageVersion
    if (!$(String-IsEmptyOrWhitespace($Alias))) {
        Kvm-Alias-Set $Alias $packageVersion
    }
  }
  else
  {
    Do-Kvm-Download $kreFullName $packageFolder
    Kvm-Use $versionOrAlias
    if (!$(String-IsEmptyOrWhitespace($Alias))) {
        Kvm-Alias-Set "$Alias" $versionOrAlias
    }
  }

  if ($kreFullName.Contains("CoreCLR")) {
    if ($NoNative) {
      Write-Host "Native image generation is skipped"
    }
    else {
      Write-Host "Compiling native images for $kreFullName to improve startup performance..."
      Start-Process "K" -ArgumentList "crossgen" -Wait
      Write-Host "Finished native image compilation."
    }
  }
}

function Kvm-List {
  $kreHome = $env:KRE_HOME
  if (!$kreHome) {
    $kreHome = "$globalKrePath;$userKrePath"
  }

  md ($userKrePath + "\alias\") -Force | Out-Null
  $aliases = Get-ChildItem ($userKrePath + "\alias\") | Select @{label='Alias';expression={$_.BaseName}}, @{label='Name';expression={Get-Content $_.FullName }}

  $items = @()
  foreach($portion in $kreHome.Split(';')) {
    $path = [System.Environment]::ExpandEnvironmentVariables($portion)
    if (Test-Path("$path\packages")) {
      $items += Get-ChildItem ("$path\packages\KRE-*") | List-Parts $aliases
    }
  }

  $items | Sort-Object Version, Runtime, Architecture, Alias | Format-Table -AutoSize -Property @{name="Active";expression={$_.Active};alignment="center"}, "Version", "Runtime", "Architecture", "Location", "Alias"
}

filter List-Parts {
  param($aliases)

  $hasBin = Test-Path($_.FullName+"\bin")
  if (!$hasBin) {
    return
  }
  $active = $false
  foreach($portion in $env:Path.Split(';')) {
    if ($portion.StartsWith($_.FullName)) {
      $active = $true
    }
  }

  $fullAlias=""
  $delim=""

  foreach($alias in $aliases){
    if($_.Name.Split('\', 2) -contains $alias.Name){
        $fullAlias += $delim + $alias.Alias
        $delim = ", "
    }
  }

  $parts1 = $_.Name.Split('.', 2)
  $parts2 = $parts1[0].Split('-', 3)
  return New-Object PSObject -Property @{
    Active = if ($active) { "*" } else { "" }
    Version = $parts1[1]
    Runtime = $parts2[1]
    Architecture = $parts2[2]
    Location = $_.Parent.FullName
    Alias = $fullAlias
  }
}

function Kvm-Global-Use {
param(
  [string] $versionOrAlias
)
  If (Needs-Elevation) {
    $arguments = "-ExecutionPolicy unrestricted & '$scriptPath' use '$versionOrAlias' -global $(Requested-Switches) -wait"
    Start-Process "$psHome\powershell.exe" -Verb runAs -ArgumentList $arguments -Wait
    Kvm-Set-Global-Process-Path $versionOrAlias
    break
  }

  Kvm-Set-Global-Process-Path "$versionOrAlias"

  if ($versionOrAlias -eq "none") {
    if ($Persistent) {
      Write-Host "Removing KRE from machine PATH"
      $machinePath = [Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine)
      $machinePath = Change-Path $machinePath "" ($globalKrePackages, $userKrePackages)
      [Environment]::SetEnvironmentVariable("Path", $machinePath, [System.EnvironmentVariableTarget]::Machine)
    }
    return;
  }

  $kreFullName = Requested-VersionOrAlias "$versionOrAlias"
  $kreBin = Locate-KreBinFromFullName $kreFullName
  if ($kreBin -eq $null) {
    Write-Host "Cannot find $kreFullName, do you need to run 'kvm install $versionOrAlias'?"
    return
  }

  if ($Persistent) {
    Write-Host "Adding $kreBin to machine PATH"
    $machinePath = [Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine)
    $machinePath = Change-Path $machinePath $kreBin ($globalKrePackages, $userKrePackages)
    [Environment]::SetEnvironmentVariable("Path", $machinePath, [System.EnvironmentVariableTarget]::Machine)
  }
}

function Kvm-Set-Global-Process-Path {
param(
  [string] $versionOrAlias
)
  if ($versionOrAlias -eq "none") {
    Write-Host "Removing KRE from process PATH"
    Set-Path (Change-Path $env:Path "" ($globalKrePackages, $userKrePackages))
    return
  }

  $kreFullName = Requested-VersionOrAlias $versionOrAlias
  $kreBin = Locate-KreBinFromFullName $kreFullName
  if ($kreBin -eq $null) {
    Write-Host "Cannot find $kreFullName, do you need to run 'kvm install $versionOrAlias'?"
    return
  }

  Write-Host "Adding" $kreBin "to process PATH"
  Set-Path (Change-Path $env:Path $kreBin ($globalKrePackages, $userKrePackages))
}

function Kvm-Use {
param(
  [string] $versionOrAlias
)
  if ($versionOrAlias -eq "none") {
    Write-Host "Removing KRE from process PATH"
    Set-Path (Change-Path $env:Path "" ($globalKrePackages, $userKrePackages))

    if ($Persistent) {
      Write-Host "Removing KRE from user PATH"
      $userPath = [Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::User)
      $userPath = Change-Path $userPath "" ($globalKrePackages, $userKrePackages)
      [Environment]::SetEnvironmentVariable("Path", $userPath, [System.EnvironmentVariableTarget]::User)
    }
    return;
  }

  $kreFullName = Requested-VersionOrAlias $versionOrAlias

  $kreBin = Locate-KreBinFromFullName $kreFullName
  if ($kreBin -eq $null) {
    Write-Host "Cannot find $kreFullName, do you need to run 'kvm install $versionOrAlias'?"
    return
  }

  Write-Host "Adding" $kreBin "to process PATH"
  Set-Path (Change-Path $env:Path $kreBin ($globalKrePackages, $userKrePackages))

  if ($Persistent) {
    Write-Host "Adding $kreBin to user PATH"
    $userPath = [Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::User)
    $userPath = Change-Path $userPath $kreBin ($globalKrePackages, $userKrePackages)
    [Environment]::SetEnvironmentVariable("Path", $userPath, [System.EnvironmentVariableTarget]::User)
  }
}

function Kvm-Alias-List {
  md ($userKrePath + "\alias\") -Force | Out-Null

  Get-ChildItem ($userKrePath + "\alias\") | Select @{label='Alias';expression={$_.BaseName}}, @{label='Name';expression={Get-Content $_.FullName }} | Format-Table -AutoSize
}

function Kvm-Alias-Get {
param(
  [string] $name
)
  md ($userKrePath + "\alias\") -Force | Out-Null
  $aliasFilePath=$userKrePath + "\alias\" + $name + ".txt"
  if (!(Test-Path $aliasFilePath)) {
    Write-Host "Alias '$name' does not exist"
  } else {
    Write-Host "Alias '$name' is set to" (Get-Content ($userKrePath + "\alias\" + $name + ".txt"))
  }
}

function Kvm-Alias-Set {
param(
  [string] $name,
  [string] $value
)
  $kreFullName = Requested-VersionOrAlias $value
  $aliasFilePath = $userKrePath + "\alias\" + $name + ".txt"
  $action = if (Test-Path $aliasFilePath) { "Updating" } else { "Setting" }
  Write-Host "$action alias '$name' to '$kreFullName'"
  md ($userKrePath + "\alias\") -Force | Out-Null
  $kreFullName | Out-File ($aliasFilePath) ascii
}

function Kvm-Unalias {
param(
  [string] $name
)
  $aliasPath=$userKrePath + "\alias\" + $name + ".txt"
  if (Test-Path -literalPath "$aliasPath") {
      Write-Host "Removing alias $name"
      Remove-Item -literalPath $aliasPath
  } else {
      Write-Host "Cannot remove alias, '$name' is not a valid alias name"
  }
}

function Locate-KreBinFromFullName() {
param(
  [string] $kreFullName
)
  $kreHome = $env:KRE_HOME
  if (!$kreHome) {
    $kreHome = "$globalKrePath;$userKrePath"
  }
  foreach($portion in $kreHome.Split(';')) {
    $path = [System.Environment]::ExpandEnvironmentVariables($portion)
    $kreBin = "$path\packages\$kreFullName\bin"
    if (Test-Path "$kreBin") {
      return $kreBin
    }
  }
  return $null
}

function Package-Version() {
param(
  [string] $kreFullName
)
  return $kreFullName -replace '[^.]*.(.*)', '$1'
}

function Package-Platform() {
param(
  [string] $kreFullName
)
  return $kreFullName -replace 'KRE-([^-]*).*', '$1'
}

function Package-Arch() {
param(
  [string] $kreFullName
)
  return $kreFullName -replace 'KRE-[^-]*-([^.]*).*', '$1'
}

function Requested-VersionOrAlias() {
param(
  [string] $versionOrAlias
)
  If (Test-Path ($userKrePath + "\alias\" + $versionOrAlias + ".txt")) {
    $aliasValue = Get-Content ($userKrePath + "\alias\" + $versionOrAlias + ".txt")
    $parts = $aliasValue.Split('.', 2)
    $pkgVersion = $parts[1]
    $parts =$parts[0].Split('-', 3)
    $pkgPlatform = Requested-Platform $parts[1]
    $pkgArchitecture = Requested-Architecture $parts[2]
  } else {
    $pkgVersion = $versionOrAlias
    $pkgPlatform = Requested-Platform $defaultRuntime
    $pkgArchitecture = Requested-Architecture $defaultArch
  }
  return "KRE-" + $pkgPlatform + "-" + $pkgArchitecture + "." + $pkgVersion
}

function Requested-Platform() {
param(
  [string] $default
)
  if (!(String-IsEmptyOrWhitespace($selectedRuntime))) {return $selectedRuntime}
  return $default
}

function Requested-Architecture() {
param(
  [string] $default
)
  if (!(String-IsEmptyOrWhitespace($selectedArch))) {return $selectedArch}
  return $default
}

function Change-Path() {
param(
  [string] $existingPaths,
  [string] $prependPath,
  [string[]] $removePaths
)
  $newPath = $prependPath
  foreach($portion in $existingPaths.Split(';')) {
    $skip = $portion -eq ""
    foreach($removePath in $removePaths) {
      if ($portion.StartsWith($removePath)) {
        $skip = $true
      }
    }
    if (!$skip) {
      $newPath = $newPath + ";" + $portion
    }
  }
  return $newPath
}

function Set-Path() {
param(
  [string] $newPath
)
  md $userKrePath -Force | Out-Null
  $env:Path = $newPath
@"
SET "PATH=$newPath"
"@ | Out-File ($userKrePath + "\run-once.cmd") ascii
}

function Needs-Elevation() {
  $user = [Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()
  $elevated = $user.IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
  return -NOT $elevated
}

function Requested-Switches() {
  $arguments = ""
  if ($X86) {$arguments = "$arguments -x86"}
  if ($Amd64) {$arguments = "$arguments -amd64"}
  #deprecated
  if ($X64) {$arguments = "$arguments -x64"}
  if ($selectedRuntime) {$arguments = "$arguments -runtime $selectedRuntime"}
  if ($Persistent) {$arguments = "$arguments -persistent"}
  if ($Force) {$arguments = "$arguments -force"}
  if (!$(String-IsEmptyOrWhitespace($Alias))) {$arguments = "$arguments -alias '$Alias'"}
  return $arguments
}

function Validate-And-Santitise-Switches()
{
  if ($Svr50 -and $Runtime) {throw "You cannot select both the -runtime switch and the -svr50 runtimes"}
  if ($Svrc50 -and $Runtime) {throw "You cannot select both the -runtime switch and the -svrc50 runtimes"}
  if ($X86 -and $Amd64) {throw "You cannot select both x86 and amd64 architectures"}
  if ($X86 -and $X64) {throw "You cannot select both x86 and x64 architectures"}
  if ($X64 -and $Amd64) {throw "You cannot select both x64 and amd64 architectures"}

  if ($Runtime) {
    $validRuntimes = "CoreCLR", "CLR", "svr50", "svrc50"
    $match = $validRuntimes | ? { $_ -like $Runtime } | Select -First 1
    if (!$match) {throw "'$runtime' is not a valid runtime"}
    Set-Variable -Name "selectedRuntime" -Value $match -Scope Script
  } elseif ($Svr50) {
    Write-Host "Warning: -svr50 is deprecated, use -runtime CLR for new packages."
    Set-Variable -Name "selectedRuntime" -Value "svr50" -Scope Script
  } elseif ($Svrc50) {
    Write-Host "Warning: -svrc50 is deprecated, use -runtime CoreCLR for new packages."
    Set-Variable -Name "selectedRuntime" -Value "svrc50" -Scope Script
  }

  if ($X64) {
    Write-Host "Warning: -x64 is deprecated, use -amd64 for new packages."
    Set-Variable -Name "selectedArch" -Value "x64" -Scope Script
  } elseif ($Amd64) {
    Set-Variable -Name "selectedArch" -Value "amd64" -Scope Script
  } elseif ($X86) {
    Set-Variable -Name "selectedArch" -Value "x86" -Scope Script
  }
}

try {
  Validate-And-Santitise-Switches
  if ($Global) {
    switch -wildcard ($Command + " " + $Args.Count) {
      "setup 0"           {Kvm-Global-Setup}
      "upgrade 0"         {Kvm-Global-Upgrade}
      "install 1"         {Kvm-Install $Args[0] $true}
      "use 1"             {Kvm-Global-Use $Args[0]}
      default             {throw "Unknown command, or global switch not supported"};
    }
  } else {
    switch -wildcard ($Command + " " + $Args.Count) {
      "setup 0"           {Kvm-Global-Setup}
      "upgrade 0"         {Kvm-Upgrade}
      "install 1"         {Kvm-Install $Args[0] $false}
      "list 0"            {Kvm-List}
      "use 1"             {Kvm-Use $Args[0]}
      "alias 0"           {Kvm-Alias-List}
      "alias 1"           {Kvm-Alias-Get $Args[0]}
      "alias 2"           {Kvm-Alias-Set $Args[0] $Args[1]}
      "unalias 1"         {Kvm-Unalias $Args[0]}
      "help 0"            {Kvm-Help}
      " 0"                {Kvm-Help}
      default             {throw "Unknown command"};
    }
  }
}
catch {
  Write-Host $_ -ForegroundColor Red ;
  Write-Host "Type 'kvm help' for help on how to use kvm."
}
if ($Wait) {
  Write-Host "Press any key to continue ..."
  $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown,AllowCtrlC")
}