text:
_XTRACE_LVM=$(set +o | grep xtrace)
set +o xtrace

# Defaults
# --------
# Name of the lvm volume groups to use/create for iscsi volumes
VOLUME_GROUP_NAME=${VOLUME_GROUP_NAME:-opensds-volumes}
FILE_GROUP_NAME=${FILE_GROUP_NAME:-opensds-files}
FILE_VOLUME_GROUP_NAME=${VOLUME_GROUP_NAME:-opensds-files}
DEFAULT_VOLUME_GROUP_NAME=$VOLUME_GROUP_NAME-default
FILE_DEFAULT_VOLUME_GROUP_NAME=$FILE_GROUP_NAME-default

# Name of lvm nvme volume group to use/create for nvme volumes
NVME_VOLUME_GROUP_NAME=$VOLUME_GROUP_NAME-nvme
# Backing file name is of the form $VOLUME_GROUP$BACKING_FILE_SUFFIX
BACKING_FILE_SUFFIX=-backing-file
# Default volume size
VOLUME_BACKING_FILE_SIZE=${VOLUME_BACKING_FILE_SIZE:-20G}
LVM_DIR=$OPT_DIR/lvm
DATA_DIR=$LVM_DIR
mkdir -p $LVM_DIR

FILE_LVM_DIR=$OPT_DIR/nfs
FILE_DATA_DIR=$FILE_LVM_DIR
mkdir -p $FILE_LVM_DIR

# nvme dir
NVME_DIR=/opt/opensdsNvme
# nvme device
LVM_DEVICE=/dev/nvme0n1

osds::lvm::pkg_install(){
    sudo apt-get install -y lvm2 tgt open-iscsi ibverbs-utils
}

osds::nfs::pkg_install(){
    sudo apt-get install -y nfs-kernel-server
}

osds::lvm::pkg_uninstall(){
    sudo apt-get purge -y lvm2 tgt open-iscsi ibvverbs-utils
}

osds::lvm::nvmeofpkginstall(){
    # nvme-cli utility for nvmeof initiator
    wget https://github.com/linux-nvme/nvme-cli/archive/v1.8.1.tar.gz -O /opt/nvmecli-1.8.1.tar.gz
    sudo tar -zxvf /opt/nvmecli-1.8.1.tar.gz -C /opt/
    cd /opt/nvme-cli-1.8.1 && sudo make && sudo make install
    # nvme kernel
    sudo modprobe nvmet
    sudo modprobe nvme-tcp
    sudo modprobe nvmet-tcp
    sudo modprobe nvme-rdma
    sudo modprobe nvmet-rdma
    sudo modprobe nvme-fc
    sudo modprobe nvmet-fc
}

osds::lvm::nvmeofpkguninstall(){
    sudo nvme disconnect-all
    sudo modprobe -r nvme-rdma
    sudo modprobe -r nvmet-rdma
    sudo modprobe -r nvme-tcp
    sudo modprobe -r nvmet-tcp
    sudo modprobe -r nvme-fc
    sudo modprobe -r nvmet-fc
    sudo modprobe -r nvmet
}

osds::lvm::create_volume_group(){
    local vg=$1
    local size=$2

    local backing_file=$DATA_DIR/$vg$BACKING_FILE_SUFFIX
    if ! sudo vgs $vg; then
        # Only create if the file doesn't already exists
        [[ -f $backing_file ]] || truncate -s $size $backing_file
        local vg_dev
        vg_dev=`sudo losetup -f --show $backing_file`

        # Only create volume group if it doesn't already exist
        if ! sudo vgs $vg; then
            sudo vgcreate $vg $vg_dev
        fi
    fi
}

osds::lvm::create_volume_group_for_file(){
    local fvg="opensds-files-default"
    local size=$2

    local backing_file=$FILE_DATA_DIR/$fvg$BACKING_FILE_SUFFIX
    if ! sudo vgs $fvg; then
        # Only create if the file doesn't already exists
        [[ -f $backing_file ]] || truncate -s $size $backing_file
        local vg_dev
        vg_dev=`sudo losetup -f --show $backing_file`

        # Only create volume group if it doesn't already exist
        if ! sudo vgs $fvg; then
            sudo vgcreate $fvg $vg_dev
        fi
    fi
}

osds::lvm::create_nvme_vg(){
    local vg=$1
    local size=$2
    cap=$(parted $LVM_DEVICE unit GB print free | grep 'Free Space' | tail -n1 | awk '{print $3}')
    if [ cap > '$size' ];then
        # Only create if the file doesn't already exists
        # create volume group and prepare kernel module
        sudo mkdir -p $NVME_DIR/$vg
        sudo mount $LVM_DEVICE $NVME_DIR/$vg
        local backing_file=$NVME_DIR/$vg/$vg$BACKING_FILE_SUFFIX
        if ! sudo vgs $vg; then
            # Only create if the file doesn't already exists
            [[ -f $backing_file ]] || truncate -s $size $backing_file
            local vg_dev
            vg_dev=`sudo losetup -f --show $backing_file`

            # Only create physical volume if it doesn't already exist
            if ! sudo pvs $vg_dev; then
                sudo pvcreate $vg_dev
            fi

            # Only create volume group if it doesn't already exist
            if ! sudo vgs $vg; then
                sudo vgcreate $vg $vg_dev
            fi
        fi
    else
        echo "disk $LVM_DEVICE does not have enough space"
    fi
}

osds::lvm::set_configuration(){
cat > $OPENSDS_DRIVER_CONFIG_DIR/lvm.yaml << OPENSDS_LVM_CONFIG_DOC
tgtBindIp: $HOST_IP
tgtConfDir: /etc/tgt/conf.d
pool:
  $DEFAULT_VOLUME_GROUP_NAME:
    diskType: NL-SAS
    availabilityZone: default
    multiAttach: true
    storageType: block
    extras:
      dataStorage:
        provisioningPolicy: Thin
        compression: false
        deduplication: false
      ioConnectivity:
        accessProtocol: iscsi
        maxIOPS: 7000000
        maxBWS: 600
        minIOPS: 1000000
        minBWS: 100
        latency: 100
      advanced:
        diskType: SSD
        latency: 5ms
OPENSDS_LVM_CONFIG_DOC

cat >> $OPENSDS_CONFIG_DIR/opensds.conf << OPENSDS_LVM_GLOBAL_CONFIG_DOC
[lvm]
name = lvm
description = LVM Test
driver_name = lvm
config_path = /etc/opensds/driver/lvm.yaml

OPENSDS_LVM_GLOBAL_CONFIG_DOC
}

osds::lvm::set_configuration_for_file(){
cat > $OPENSDS_DRIVER_CONFIG_DIR/nfs.yaml << OPENSDS_FILE_CONFIG_DOC
tgtBindIp: $HOST_IP
tgtConfDir: /etc/tgt/conf.d
pool:
  $FILE_DEFAULT_VOLUME_GROUP_NAME:
    diskType: NL-SAS
    availabilityZone: default
    multiAttach: true
    storageType: file
    extras:
      dataStorage:
        provisioningPolicy: Thin
        compression: false
        deduplication: false
        storageAccessCapability:
         - Read
         - Write
         - Execute
      ioConnectivity:
        accessProtocol: nfs
        maxIOPS: 7000000
        maxBWS: 600
        minIOPS: 1000000
        minBWS: 100
        latency: 100
      advanced:
        diskType: SSD
        latency: 5ms
OPENSDS_FILE_CONFIG_DOC

cat >> $OPENSDS_CONFIG_DIR/opensds.conf << OPENSDS_FILE_GLOBAL_CONFIG_DOC
[nfs]
name = nfs
description = NFS LVM TEST
driver_name = nfs
config_path = /etc/opensds/driver/nfs.yaml

OPENSDS_FILE_GLOBAL_CONFIG_DOC
}

osds::lvm::set_nvme_configuration(){
cat >> $OPENSDS_DRIVER_CONFIG_DIR/lvm.yaml << OPENSDS_LVM_CONFIG_DOC

  $NVME_VOLUME_GROUP_NAME:
    diskType: NL-SAS
    availabilityZone: default
    multiAttach: true
    storageType: block
    extras:
      dataStorage:
        provisioningPolicy: Thin
        compression: false
        deduplication: false
      ioConnectivity:
        accessProtocol: nvmeof
        maxIOPS: 7000000
        maxBWS: 600
        minIOPS: 1000000
        minBWS: 100
        latency: 100
      advanced:
        diskType: SSD
        latency: 20us
OPENSDS_LVM_CONFIG_DOC
}

osds::lvm::remove_volumes() {
    local vg=$1

    # Clean out existing volumes
    sudo lvremove -f $vg
}

osds::lvm::remove_volume_group() {
    local vg=$1

    # Remove the volume group
    sudo vgremove -f $vg
}
osds::lvm::remove_volume_group_for_file() {
    local fvg="opensds-files-default"
    # Remove the volume group
    sudo vgremove -f $fvg
}

osds::lvm::clean_backing_file() {
    local backing_file=$1
    # If the backing physical device is a loop device, it was probably setup by DevStack
    if [[ -n "$backing_file" ]] && [[ -e "$backing_file" ]]; then
        local vg_dev
        vg_dev=$(sudo losetup -j $backing_file | awk -F':' '/'$BACKING_FILE_SUFFIX'/ { print $1}')
        if [[ -n "$vg_dev" ]]; then
            sudo losetup -d $vg_dev
        fi
        rm -f $backing_file
    fi
}

osds::lvm::clean_volume_group_for_file() {
    local fvg="opensds-files-default"
    osds::lvm::remove_volume_group_for_file $fvg
    # if there is no logical volume left, it's safe to attempt a cleanup
    # of the backing file
    if [[ -z "$(sudo lvs --noheadings -o lv_name $fvg 2>/dev/null)" ]]; then
        osds::lvm::clean_backing_file $FILE_DATA_DIR/$fvg$BACKING_FILE_SUFFIX
    fi
}

osds::lvm::clean_volume_group() {
    local vg=$1
    osds::lvm::remove_volumes $vg
    osds::lvm::remove_volume_group $vg
    osds::lvm::remove_volume_group_for_file $fvg
    # if there is no logical volume left, it's safe to attempt a cleanup
    # of the backing file
    if [[ -z "$(sudo lvs --noheadings -o lv_name $vg 2>/dev/null)" ]]; then
        osds::lvm::clean_backing_file $DATA_DIR/$vg$BACKING_FILE_SUFFIX
    fi
}

osds::lvm::clean_nvme_volume_group(){
    local nvmevg=$1
    echo "nvme pool ${nvmevg}"
    osds::lvm::remove_volumes $nvmevg
    osds::lvm::remove_volume_group $nvmevg
    # if there is no logical volume left, it's safe to attempt a cleanup
    # of the backing file
    if [[ -z "$(sudo lvs --noheadings -o lv_name $nvmevg 2>/dev/null)" ]]; then
        osds::lvm::clean_backing_file $NVME_DIR/$nvmevg/$nvmevg$BACKING_FILE_SUFFIX
    fi
    ## umount nvme disk and remove corresponding dir
    for i in {1..10}
    do
	# 'umount -l' can umount even if target is busy
	sudo umount -l $NVME_DIR/$nvmevg
	if [ $? -eq 0 ]; then
		sudo rmdir $NVME_DIR/$nvmevg
		sudo rmdir $NVME_DIR
		echo "umount & removement succeed"
		return 0
	fi
	sleep 1
    done
    echo "umount failed after retry 10 times"
    echo "please check if there are any remaining attachments and umount dir ${NVME_DIRi}/${nvmevg} manually"
}

# osds::lvm::clean_lvm_filter() Remove the filter rule set in set_lvm_filter()

osds::lvm::clean_lvm_filter() {
    sudo sed -i "s/^.*# from devsds$//" /etc/lvm/lvm.conf
}

# osds::lvm::set_lvm_filter() Gather all devices configured for LVM and
# use them to build a global device filter
# osds::lvm::set_lvm_filter() Create a device filter
# and add to /etc/lvm.conf.  Note this uses
# all current PV's in use by LVM on the
# system to build it's filter.
osds::lvm::set_lvm_filter() {
    local filter_suffix='"r|.*|" ]  # from devsds'
    local filter_string="global_filter = [ "
    local pv
    local vg
    local line

    for pv_info in $(sudo pvs --noheadings -o name); do
        pv=$(echo -e "${pv_info}" | sed 's/ //g' | sed 's/\/dev\///g')
        new="\"a|$pv|\", "
        filter_string=$filter_string$new
    done
    filter_string=$filter_string$filter_suffix

    osds::lvm::clean_lvm_filter
    sudo sed -i "/# global_filter = \[.*\]/a\    $global_filter$filter_string" /etc/lvm/lvm.conf
    osds::echo_summary "set lvm.conf device global_filter to: $filter_string"
}

osds::lvm::install() {
    local vg=$DEFAULT_VOLUME_GROUP_NAME
    local fvg=$FILE_DEFAULT_VOLUME_GROUP_NAME
    local size=$VOLUME_BACKING_FILE_SIZE

    # Install lvm relative packages.
    osds::lvm::pkg_install
    osds::nfs::pkg_install
    osds::lvm::create_volume_group_for_file $fvg $size
    osds::lvm::create_volume_group $vg $size

    # Remove iscsi targets
    sudo tgtadm --op show --mode target | awk '/Target/ {print $3}' | sudo xargs -r -n1 tgt-admin --delete
    # Remove volumes that already exist.
    osds::lvm::remove_volumes $vg
    osds::lvm::set_configuration
    osds::lvm::set_configuration_for_file

    # Check nvmeof prerequisites
    local nvmevg=$NVME_VOLUME_GROUP_NAME
    if [[ -e "$LVM_DEVICE" ]]; then
        #phys_port_cnt=$(ibv_devinfo |grep -Eow hca_id |wc -l)
        #echo "The actual quantity of RDMA ports is $phys_port_cnt"
	#nvmetcpsupport=$(sudo modprobe nvmet-tcp)
        #if [[ "$phys_port_cnt" < '1' ]] && [ $nvmetcpsupport -ne 0 ] ; then
        #    echo "RDMA card not found , and kernel version can not support nvme-tcp "
        #else
        osds::lvm::create_nvme_vg $nvmevg $size
        osds::lvm::nvmeofpkginstall
        # Remove volumes that already exist
        osds::lvm::remove_volumes $nvmevg
        osds::lvm::set_nvme_configuration
        #fi
    fi
    osds::lvm::set_lvm_filter
}

osds::lvm::cleanup(){
    osds::lvm::clean_volume_group $DEFAULT_VOLUME_GROUP_NAME
    osds::lvm::clean_volume_group_for_file $FILE_DEFAULT_VOLUME_GROUP_NAME
    osds::lvm::clean_lvm_filter
    local nvmevg=$NVME_VOLUME_GROUP_NAME
    if vgs $nvmevg ; then
    	osds::lvm::clean_nvme_volume_group $nvmevg
    fi
}

osds::lvm::uninstall(){
    : # do nothing
}

osds::lvm::uninstall_purge(){
    echo osds::lvm::pkg_uninstall
    echo osds::lvm::nvmeofpkguninstall
}

# Restore xtrace
$_XTRACE_LVM


text:
FOUNDATION_EXPORT double Pods_VOneVersionNumber;
FOUNDATION_EXPORT const unsigned char Pods_VOneVersionString[];

redpajama_set_name: RedPajamaGithub


text:
#ifndef Scatterer_h
#define Scatterer_h

#include "Vec3.h"
#include "Mat3.h"
#include "geom3D.h"
#include "raytrace.h"
#include "CMesh.h"

#include "TriangleRayTracer.h"

#include "Lingebra.h"

//#include "fastmath.h"

// See:
//
//
//   coupling probability
//  p_hit =  cross.dot(rd);
//  thick =  thick.dot(rd);
//  scatterOnSite( thick, freq, amp );  // store scattered rays into bins

/*

Theory:
=======

We work with bunches of particles (photons, neutrons) with some distribution in phase space defined by position and direction (p,d)
There are two fundamental processes and therefore two views of the problem:
1) through space flight ( where the spatial size of bunch spread due ot its finite spread in angular space ), this is problem of geometric optics
2) On-site scattering where the ray is scattered from one direction to an other.

1) flux disribution in ements element

*/

struct HalfRay{
    double width; // angular spread of the channel, how large the complementary elements seem from this point of view
    // area/(4*pi*distance^2)
};

struct FluxRay{
    //int i,j; // scattering elements between which the flux is
    HalfRay left;
    HalfRay right;
    Vec3d  dir;
    double flux;
    double Kgeom; //  through space gemetric coupling |  ToDo : how it should be normalized? How to choose angular width ?
}

struct ScatterElem{

// the Scatterer scatter flux between rays attached to the node
// scheme 2 - assume there is external matrix "rays" which store flux along

    Vec3d pos;     // position in space
    Mat3d rot;     // rotation of main axes (elipsoide maping)
    Vec3d thicks;  // thickness along main axes
    Vec3d areas;   // crossection area along mains axes
    double beta;   // decay exponent

    //double project(const Vec3d& dir, const Vec3d& property){
    //    rot.dot
    //    return property.dot(V);
    //}

    double scatter( Vec3d h0, Vec3d h1, double  ){
        // this scattering function has to be normalized so that sum of flux scattered oto all channels is = 1

        // to-do - this can be precomputed for each ray
        Vec3d cs0,cs1;
        rot.dot_to( h0, cs0); // decomposition of direction 1 in eigen direction of scatterer
        rot.dot_to( h1, cs1); // ---,,---      of direstion 2
        double thick0 = cs0.dot(thicks);
        double thick1 = cs1.dot(thicks);
        double area0  = cs0.dot(areas );
        double area1  = cs2.dot(areas );

        //double thick  = thick0 + thick1;
        double cosa     = h0.dot(h1);
        return exp( beta*cosa*(thick0 + thick1) ); // ToDo: scattering probabilities should depend on width of channels between which it scatters
    }

}

class ScatterElement{ public:

    Vec3d pos;     //= Vec3dZero;

    int nfreq = 0; // number of frequeny(energy) spectrum subdivision
    int n     = 0; // number of subdivision per u,v axis
    int ndir  = 0;
    int ntot  = 0; // total number of rays stored
    //double* cross =0; // store projection of element crossection in different directions  ( to evaluate hit probability )
    //double* thick =0; // store projection of element thickness in different directions    ( to evaluate intercation probability )

    Vec2d dsamp;
    int ia=0,ib=0,iface=0;

    Mat3d cross;
    Mat3d thick;

    double* rays  =0; // store population of rays in particular direction

    // ==== Methods

    //Vec3d getDir(int idir){
    //    int iface = idir&7;
    //    int ip    = idir>>3;
    //};

    inline void getDir(int ia, int ib, int iface, Vec3d& h ){
        //Vec3d h;
        h.a = dsamp.a*ia;
        h.b = dsamp.b*ib;
        h.c = 1-h.a-h.b;
        h.octDir(iface);
        h.normalize_taylor3();
    };

    inline void getNextDir( Vec3d& h ){
        ia++;
        if(ia>=n){ia=0;ib++;}
        if(ib>=n){ib=0;iface++;}
        getDir(ia,ib,iface, h );
        //if(iface>=8){iface=0;iface++;}
        //idir++;
    };

    inline double scatterFunc(double cosa, double thick){
        // it is basically diffusion
        // exp(2*cos(x)-2)   ~=~   exp(-x^2)
        return exp( 2*(cosa-1)/thick );
    };

    void scatterCoefs_elastic( Vec3d dir, double thick, double Apre, double* coefs ){
        double sum = 0;
        ia=0;ib=0;iface=0;
        for(int i=0; i<ndir; i++){
            Vec3d   hi;
            getNextDir(hi);
            double cosa = dir.dot(hi);
            double amp  = scatterFunc(cosa,thick) * Apre;
            sum += amp;
            coefs[i]    += amp * Apre;
        }
        // ToDo : check sum == 1.0   !!!
    };

};

class Scattering : public TriangleRayTracer, public LinSolver { public:
    double couplingTrashold  = 1e-8;

    //int nObstacles=0;
    //Triangle3D* obstacles=0;

    double* coupling =0; // geometric-compling matrix between elements in space (depending on distance)
    double* rays     =0; // flux stored in each coupling (channel)

    // work arrays
    double* vals=0;    // a
    double* sources=0; //

    inline void allocateWork(int n){
        _realloc(vals   ,n);
        _realloc(sources,n);
    }

    inline void prepare(){
        int n = elements.size();
        allocateWork( n );
        setLinearProblem( n, vals, sources );
    }

    inline int makeCouplingMatrix(){
        int n = elements.size();
        _realloc(M,n*n);
        for(int i=0; i<n; i++) M[i*n+i] = 0.0;
        //for(int i=0; i<n; i++) M[i*n+i] = 1.0;
        for(int i=0; i<n; i++){
            SurfElement& eli = elements[i];
            for(int j=0; j<i; j++){
                SurfElement& elj = elements[j];
                //if( eli.isurf == elj.isurf ){ M[i*n+j]=0.0; continue; }

                double coupling = eli.geomCoupling( elj );
                /*
                Vec3d  d = elj.pos - eli.pos;
                //double r = d.normalize();
                double r2 = d.normalize();
                double coupling = d.dot(eli.normal)*d.dot(elj.normal)/r2;
                if( fabs(coupling) < couplingTrashold ){ M[i*n+j]=0.0; continue; };
                coupling /= ( r2 + eli.area + elj.area );
                */

                //coupling *=  eli.area * elj.area;
                coupling *= 2* eli.area/(4*M_PI);

                double occlusion = getOcclusion( eli.pos, d, sqrt(r2), eli.isurf, elj.isurf );

                coupling*=(1-occlusion);

                coupling = fabs( coupling );
                if( occlusion <0.5 ){
                    Draw3D::drawLine( eli.pos, elj.pos );
                    //printf( " %i %i %g \n", i, j, coupling );
                }

                M[i*n+j] = coupling;
                M[j*n+i] = coupling;
            }
        }
    }

    inline void processTriangles( int ntri, Triangle3D* tris, double sz ){
        //nObstacles=ntri;
        //obstacles = tris;

        for(int i=0; i<ntri; i++){
            int nsamp = 5; // TODO :  automatially determine element size
            //trinagleToElements( {nsamp,nsamp}, tris[i], i );
            //trinagleToElements( nsamp, tris[i], i );
        }
        makeCouplingMatrix();
    }

    virtual void dotFunc( int n, double * x, double * Ax ) override {
        for(int i=0; i<n; i++){
            double Axi = 0.0;
            for(int j=0; j<n; j++){
                Axi += M[i*n+j] * x[j];
            }
            Ax[i]=Axi;
        }
    }

    inline void step_Direct(){
        for(int i=0; i<n; i++){
            double Axi = 0.0;
            for(int j=0; j<n; j++){
                Axi += M[i*n+j] * ( vals[j] + sources[j] );
            }
            vals[i] = Axi; // - sources[i];
        }
    }

    inline void step_Direct(){
        for(int i=0; i<n; i++){
            double Axi = 0.0;
            for(int j=0; j<n; j++){
                Axi += M[i*n+j] * ( vals[j] + sources[j] );
            }
            vals[i] = Axi; // - sources[i];
        }
    }

};

#endif


text:
using System.Numerics;
using ShaderGen;

[assembly: ShaderSet("PositionColorTextureGL", "RenderOpenGl.Shaders.PositionColorTextureGL.VS", "RenderOpenGl.Shaders.PositionColorTextureGL.FS")]

namespace RenderOpenGl.Shaders
{
	public class PositionColorTextureGL
	{
		[ResourceSet(0)]
		public Matrix4x4 Projection;
		[ResourceSet(0)]
		public Matrix4x4 View;

		[VertexShader]
		public FragmentInput VS(VertexInput input)
		{
			FragmentInput output;
			output.SystemPosition = new Vector4(input.Position.X, input.Position.Y, 0, 1);
			output.Color = input.Color;

			return output;
		}

		[FragmentShader]
		public Vector4 FS(FragmentInput input)
		{
			return input.Color;
		}

		public struct VertexInput
		{
			[PositionSemantic] public Vector2 Position;
			[ColorSemantic] public Vector4 Color;
		}

		public struct FragmentInput
		{
			[SystemPositionSemantic] public Vector4 SystemPosition;
			[ColorSemantic] public Vector4 Color;
		}
	}
}


text:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="1"
    tools:context=".ActivityMain">

    <include layout="@layout/layout_status" />

    <LinearLayout
        android:id="@+id/ll_privacy"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingBottom="10dp"
        android:paddingTop="20dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TextView
                style="?attr/text_view_title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/title_privacy" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="3"
            android:orientation="horizontal"
            android:padding="10dp"
            android:weightSum="3">

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="2"
                android:orientation="vertical"
                android:weightSum="2">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:orientation="horizontal"
                    android:weightSum="3">

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1.2"
                        android:text="@string/privacy_status"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/textViewPrivacyStatus"
                        style="?attr/text_view_primary_color"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1.8"
                        android:textStyle="bold" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:weightSum="3">

                    <TextView
                        android:id="@+id/textViewPrivacyOptionTitle"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1.2"
                        android:text="@string/privacy_option"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/textViewPrivacyOption"
                        style="?attr/text_view_primary_color"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1.8" />
                </LinearLayout>
            </LinearLayout>

            <Button
                android:id="@+id/button_privacy"
                style="?attr/button"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/configure" />

        </LinearLayout>

    </LinearLayout>

    <LinearLayout
        android:id="@+id/ll_cerebralcortex"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.52"
        android:orientation="vertical"
        android:paddingBottom="10dp"
        android:paddingTop="20dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TextView
                style="?attr/text_view_title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/title_cerebralcortex" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="3.92"
            android:orientation="horizontal"
            android:padding="10dp"
            android:weightSum="3">

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="2"
                android:orientation="vertical"
                android:weightSum="2">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:orientation="horizontal"
                    android:weightSum="3">

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1.2"
                        android:text="@string/cerebralcortex_status"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/textViewcerebralcortexStatus"
                        style="?attr/text_view_primary_color"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1.8"
                        android:textStyle="bold" />
                </LinearLayout>

            </LinearLayout>

            <Button
                android:id="@+id/button_cerebralcortex"
                style="?attr/button"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/toggle" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:weightSum="3">

            <TextView
                android:id="@+id/textViewcerebralcortexMessage"
                android:layout_width="match_parent"
                android:layout_height="75dip"
                android:textStyle="bold" />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>


text:
// -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2019 MIT, All rights reserved
// Released under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0

package com.google.appinventor.client.editor.simple.components;

import com.google.appinventor.client.Ode;
import com.google.appinventor.client.editor.simple.SimpleEditor;

import com.google.appinventor.client.utils.MessageDialog;

import com.google.gwt.core.client.GWT;

import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.ui.Image;

import static com.google.appinventor.client.Ode.MESSAGES;

/**
 * Mock for the non-visible FusionTablesControl component. This needs
 * a separate mock so we can provide a warning message about Google
 * shutting down the service on December 3, 2019.
 *
 * Cribbed from MockFirebaseDB.java
 *
 * @author jis@mit.edu (Jeffrey I. Schiller)
 */
public class MockFusionTablesControl extends MockNonVisibleComponent {

  public static final String TYPE = "FusiontablesControl";
  private static boolean warningGiven = false; // Whether or not we have given the
                                               // deprecation warning

  /**
   * Creates a new instance of a non-visible component whose icon is
   * loaded dynamically (not part of the icon image bundle)
   *
   * @param editor
   * @param type
   * @param iconImage
   */
  public MockFusionTablesControl(SimpleEditor editor, String type, Image iconImage) {
    super(editor, type, iconImage);
  }

  /**
   * Generate a dialog box indicating that the FusiontablesControl is
   * deprecated.
   */

  @Override
  protected void onAttach() {
    super.onAttach();
    if (!warningGiven) {
      warningGiven = true;
      DeferredCommand.addCommand(new Command() {
          @Override
          public void execute() {
            Ode.getInstance().genericWarning(MESSAGES.FusionTablesDeprecated());
          }
        });
    }
  }

  /**
   * Called when the component is dropped in the Designer window
   * we give a warning that FusiontablesControl is deprecated
   */

  @Override
  public void onCreateFromPalette() {
    if (!warningGiven) {
      warningGiven = true;
      MessageDialog.messageDialog(MESSAGES.warningDialogTitle(),
        MESSAGES.FusionTablesDeprecated(),
        MESSAGES.okButton(), null, null);
    }
  }

  public static void resetWarning() {
    warningGiven = false;
  }

}


text:
YUI.add('array-extras-test', function (Y) {

var Assert       = Y.Assert,
    ArrayAssert  = Y.ArrayAssert,
    A            = Y.Array,
    ObjectAssert = Y.ObjectAssert,

    suite;

suite = new Y.Test.Suite('Collection');

suite.add(new Y.Test.Case({
    name: "General",

    setUp: function () {
        this.data = [1, 2, 3, 4, 5];
    },

    tearDown: function () {
        delete this.data;
    },

    testLastIndexOf: function () {
        var data = ['a', 'a', null, 'c', 'c', 'd'];

        Assert.areSame(1, A.lastIndexOf(data, 'a'));
        Assert.areSame(2, A.lastIndexOf(data, null));
        Assert.areSame(-1, A.lastIndexOf(data, false));
        Assert.areSame(4, A.lastIndexOf(data, 'c'));
        Assert.areSame(5, A.lastIndexOf(data, 'd'));
        Assert.areSame(-1, A.lastIndexOf(data, 'x'));
        Assert.areSame(-1, A.lastIndexOf([], 'x'));
    },

    testLastIndexOf_fromIndex: function () {
        var data = ['a', 'a', null, 'c', 'c', 'd'];

        Assert.areSame(1, A.lastIndexOf(data, 'a', 20));
        Assert.areSame(1, A.lastIndexOf(data, 'a', -3));
        Assert.areSame(-1, A.lastIndexOf(data, 'c', -4));
        Assert.areSame(3, A.lastIndexOf(data, 'c', -3));
        Assert.areSame(-1, A.lastIndexOf(data, 'a', -10));
        Assert.areSame(-1, A.lastIndexOf([], 'a', -10));
    },

    'lastIndexOf() should handle sparse arrays correctly': function () {
        var array = ['a'];

        array[1] = undefined;
        array[3] = 'd';

        Y.Assert.areSame(1, A.lastIndexOf(array, undefined));
    },

    testMap: function () {
        var data = this.data;
        var results = A.map(data, function (item, i, array) {
            Assert.isNumber(item);
            Assert.isNumber(i);
            Assert.areSame(data, array);
            return item * 2;
        });
        Assert.isArray(results);
        ArrayAssert.itemsAreEqual([2, 4, 6, 8, 10], results);
    },

    testMapContext: function() {
        var data = this.data;
        var results = A.map(data, function(item) {
            Assert.areEqual(5, this.x);
            Assert.areNotEqual(6, this.x);
        }, { x: 5 });
    },

    'map() should handle sparse arrays correctly': function () {
        var calls = 0,
            foo   = Array(5);

        foo.push('foo');

        Y.Array.map(foo, function () {
            calls += 1;
        });

        Assert.areSame(1, calls);
    },

    'map() should work on array-like objects': function () {
        var calls = 0;

        (function () {
            var results = Y.Array.map(arguments, function () {
                    calls += 1;
                    return 'z';
                });

            Y.ArrayAssert.itemsAreSame(['z', 'z', 'z'], results);
        }('a', 'b', 'c'));

        Assert.areSame(3, calls);
    },

    testReduce: function () {
        var obj = {};

        Assert.areSame(15, A.reduce(this.data, 0, function (sum, item, i, array) {
            Assert.isNumber(item);
            Assert.isNumber(i);
            Assert.isArray(array);
            if (Y.config.win) {
                Assert.areSame(Y.config.win, this);
            }
            return sum + item;
        }));

        A.reduce([1], 0, function () {
            Assert.areSame(obj, this);
        }, obj);
    },

    testReduceContext: function() {
        var data = this.data;
        var result = A.reduce(data, 0, function (sum, item) {
            Assert.areEqual("asdf", this.y);
        }, { y: "asdf" });
    },

    'reduce() should handle sparse arrays correctly': function () {
        var calls = 0,
            foo   = Array(5);

        foo.push('foo');

        Y.Array.reduce(foo, true, function () {
            calls += 1;
            return true;
        });

        Assert.areSame(1, calls);
    },

    'reduce() should work on array-like objects': function () {
        var calls = 0;

        (function () {
            Y.Array.reduce(arguments, true, function () {
                calls += 1;
                return true;
            });
        }('a', 'b', 'c'));

        Assert.areSame(3, calls);
    },

    testFind: function () {
        var data = this.data;
        var result = A.find(data, function (item) {
            return item % 2 == 0;
        });
        Assert.areEqual(2, result);
    },

    testFindNoMatch: function () {
        var data = this.data;
        var result = A.find(data, function (item) {
            return item % 7 == 0;
        });
        Assert.areEqual(null, result);
    },

    testFindFirst: function () {
        var data = this.data;
        var result = A.find(data, function(item) {
            return item % 2 == 1;
        });
        Assert.areEqual(1, result, 'First item not found!');
    },

    testFindLast: function () {
        var data = this.data;
        var result = A.find(data, function(item) {
            return item % 5 == 0;
        });
        Assert.areEqual(5, result, 'Last item not found!');
    },

    'find() should handle sparse arrays correctly': function () {
        var calls = 0,
            foo   = Array(5);

        foo.push('foo');

        Y.Array.find(foo, function () {
            calls += 1;
        });

        Assert.areSame(1, calls);
    },

    testFilter: function () {
        var data   = this.data,
            obj    = {},
            result = A.filter(data, function (item, i, array) {
                Assert.isNumber(item);
                Assert.isNumber(i);
                Assert.areSame(data, array);
                if (Y.config.win) {
                    Assert.areSame(this, Y.config.win);
                }

                return item % 2 == 0;
            });

        Assert.isArray(result);
        ArrayAssert.itemsAreEqual([2, 4], result);

        A.filter(data, function () {
            Assert.areSame(obj, this);
        }, obj);
    },

    testFilterNoMatch: function () {
        var data = this.data;
        var result = A.filter(data, function (item) {
            return item % 7 == 0;
        });
        Assert.isArray(result);
        ArrayAssert.isEmpty(result);
    },

    'filter() should handle sparse arrays correctly': function () {
        var calls = 0,
            foo   = Array(5);

        foo.push('foo');

        Y.Array.filter(foo, function () {
            calls += 1;
        });

        Assert.areSame(1, calls);
    },

    'filter() should work on array-like objects': function () {
        var calls = 0;

        (function () {
            var results = Y.Array.filter(arguments, function (value) {
                    calls += 1;
                    return value === 'a';
                });

            Y.ArrayAssert.itemsAreSame(['a'], results);
        }('a', 'b', 'c'));

        Assert.areSame(3, calls);
    },

    testReject: function () {
        var data = this.data;
        var result = A.reject(data, function (item) {
            return item % 2 == 0;
        });
        Assert.isArray(result);
        ArrayAssert.itemsAreEqual([1, 3, 5], result);
    },

    testRejectNoMatch: function () {
        var data = this.data;
        var result = A.reject(data, function (item) {
            return item % 7 == 0;
        });
        Assert.isArray(result);
        ArrayAssert.itemsAreEqual(data, result);
    },

    testGrepMatches: function () {
        var data = ['ruby', 'perl', 'python'];
        var results = A.grep(data, /p(erl|ython)/);
        Assert.isArray(results);
        ArrayAssert.itemsAreEqual(['perl', 'python'], results);
    },

    testGrepNoMatches: function () {
        var data = ['ruby', 'perl', 'python'];
        var results = A.grep(data, /j(ruby|ython)/);
        Assert.isArray(results);
        ArrayAssert.isEmpty(results);
    },

    testPartition: function () {
        var data = this.data;
        var results = A.partition(data, function (item) {
            return item % 2 == 0;
        });
        Assert.isArray(results.matches);
        ArrayAssert.itemsAreEqual([2, 4], results.matches);
        Assert.isArray(results.rejects);
        ArrayAssert.itemsAreEqual([1, 3, 5], results.rejects);
    },

    testZip: function () {
        var results = A.zip([1, 2, 3], ['a', 'b', 'c']);
        var expected = [[1, 'a'], [2, 'b'], [3, 'c']];
        Assert.isArray(results);
        A.each(expected, function (item, index) {
            Assert.isArray(item);
            ArrayAssert.itemsAreEqual(item, results[index]);
        });
    },

    testEvery: function() {
        var data = [5, 10, 20, 540];
        var result = A.every(data, function(item, i, a) {
            return item % 5 == 0;
        });

        Assert.isTrue(result);
    },

    testEveryNoMatches: function() {
        var data = [5, 10, 20, 541];
        var result = A.every(data, function(item, i, a) {
            return item % 5 == 0;
        });

        Assert.isFalse(result);
    },

    'every() should handle sparse arrays correctly': function () {
        var calls = 0,
            foo   = Array(5);

        foo.push('foo');

        Y.Array.every(foo, function () {
            calls += 1;
            return true;
        });

        Assert.areSame(1, calls);
    },

    'every() should work on array-like objects': function () {
        var calls = 0;

        (function () {
            var result = Y.Array.every(arguments, function (value) {
                    calls += 1;
                    return value === 'a';
                });

            Assert.isFalse(result);
        }('a', 'b', 'c'));

        Assert.areSame(2, calls);
    },

    'unique() should return a copy of an array with duplicate items removed': function() {
        var array = [],
            obj   = {};

        Assert.areNotSame(array, A.unique(array), 'returned array should be a copy');

        ArrayAssert.itemsAreSame(
            [2, 1, 3, 5, 4],
            A.unique([2, 1, 2, 3, 5, 4, 4])
        );

        ArrayAssert.itemsAreSame(
            ['foo', null, obj, undefined, false],
            A.unique(['foo', 'foo', null, null, obj, obj, undefined, false, false])
        );
    },

    'unique() should support a custom test function': function () {
        var obj    = {},
            values = [{value: 'a'}, {value: 'a'}, {value: 'b'}],
            results;

        results = A.unique(values, function (a, b, index, array) {
            Assert.isObject(a, '`a` should be an object');
            Assert.isObject(b, '`b` should be an object');
            Assert.isNumber(index, '`index` should be a number');
            Assert.areSame(values, array, '`array` should be the input array');
            Assert.areSame(values, this, '`this` should be the input array');

            return a.value === b.value;
        });

        Assert.areSame(2, results.length);
        Assert.areSame('a', results[0].value);
        Assert.areSame('b', results[1].value);
    },

    'flatten() should flatten nested arrays into a single-level array': function () {
        Assert.isArray(A.flatten());
        Assert.isArray(A.flatten(null));

        ArrayAssert.itemsAreSame(
            ['foo', 'bar', null],
            A.flatten(['foo', 'bar', null])
        );

        ArrayAssert.itemsAreSame(
            ['foo', 'bar', null],
            A.flatten(['foo', ['bar', null]])
        );

        ArrayAssert.itemsAreSame(
            ['foo', 'bar', null],
            A.flatten([[['foo', ['bar', null]]]])
        );

        ArrayAssert.itemsAreSame(
            ['foo', 'bar', null],
            A.flatten([[[[['foo']], [['bar'], [null]]]]])
        );
    }
}));

Y.Test.Runner.add(suite);

}, '3.5.0', {
    requires: ['array-extras', 'test']
});


text:
import { LabelFormat } from './LabelFormat';
import { TPrintCustomCode } from './PrintCustomCode';

/**
 * Shipments can have a variety of additional options which you can specify when creating a shipment.
 * The Options object can be populated with the keys below.
 *
 * @see https://www.easypost.com/docs/api/node#options-object
 */
export declare interface IOptions {
  /**
   * Setting this option to true, will add an additional handling charge.
   * An Additional Handling charge may be applied to the following:
   *  - Any article that is encased in an outside shipping container made of metal or wood.
   *  - Any item, such as a barrel, drum, pail or tire, that is not fully encased in a corrugated cardboard shipping container.
   *  - Any package with the longest side exceeding 60 inches or its second longest side exceeding 30 inches.
   *  - Any package with an actual weight greater than 70 pounds.
   */
  additional_handling?: boolean | null;

  /**
   * Setting this option to "0", will allow the minimum amount of address information to pass the validation check.
   * Only for USPS postage.
   */
  address_validation_level?: string | null;

  /**
   * Set this option to true if your shipment contains alcohol.
   *  - UPS - only supported for US Domestic shipments
   *  - FedEx - only supported for US Domestic shipments
   *  - Canada Post - Requires adult signature 19 years or older. If you want adult signature 18 years or older, instead use delivery_confirmation: ADULT_SIGNATURE
   */
  alcohol?: boolean | null;

  /**
   * Setting this option to true will indicate to the carrier to prefer delivery by drone, if the carrier supports drone delivery.
   */
  by_drone?: boolean | null;

  /**
   * Setting this to true will add a charge to reduce carbon emissions.
   */
  carbon_neutral?: boolean | null;

  /**
   * Adding an amount will have the carrier collect the specified amount from the recipient.
   */
  cod_amount?: string | null;

  /**
   * Method for payment. "CASH", "CHECK", "MONEY_ORDER"
   */
  cod_method?: 'CASH' | 'CHECK' | 'MONEY_ORDER' | null;

  /**
   * The ID of the Address to which the COD payment should be returned.
   * Defaults to the origin address.
   * Only available on FedEx shipments.
   */
  cod_address_id?: string | null;

  /**
   * Which currency this shipment will show for rates if carrier allows.
   */
  currency?: string | null;

  /**
   * If you want to request a signature, you can pass "ADULT_SIGNATURE" or "SIGNATURE".
   * You may also request "NO_SIGNATURE" to leave the package at the door.
   *  - All - some options may be limited for international shipments
   *  - FedEx - "INDIRECT_SIGNATURE" is also an option
   *  - USPS - additional options
   *    - "ADULT_SIGNATURE_RESTRICTED"
   *    - "SIGNATURE_RESTRICTED"
   */
  delivery_confirmation?:
    | 'ADULT_SIGNATURE'
    | 'SIGNATURE'
    | 'NO_SIGNATURE'
    | 'INDIRECT_SIGNATURE'
    | 'ADULT_SIGNATURE_RESTRICTED'
    | 'SIGNATURE_RESTRICTED'
    | null;

  /**
   * Method the customer will use to transfer the package to the carrier.
   * "REGULAR_PICKUP", "SCHEDULED_PICKUP", "RETAIL_LOCATION", "STATION" or "DROP_BOX".
   * Supported carriers and their corresponding carrier dropoff codes:
   *  - FedEx
   *    - "REGULAR_PICKUP" - "REGULAR_PICKUP" (default)
   *    - "SCHEDULED_PICKUP" - "REQUEST_COURIER"
   *    - "RETAIL_LOCATION" - "BUSINESS_SERVICE_CENTER"
   *    - "STATION" - "STATION"
   *    - "DROP_BOX" - "DROP_BOX"
   */
  dropoff_type?:
    | 'REGULAR_PICKUP'
    | 'SCHEDULED_PICKUP'
    | 'RETAIL_LOCATION'
    | 'STATION'
    | 'DROP_BOX'
    | 'REQUEST_COURIER'
    | 'BUSINESS_SERVICE_CENTER'
    | null;

  /**
   * Package contents contain dry ice.
   *  - UPS - Need dry_ice_weight to be set
   *  - UPS MailInnovations - Need dry_ice_weight to be set
   *  - FedEx - Need dry_ice_weight to be set
   */
  dry_ice?: boolean | null;

  /**
   * If the dry ice is for medical use, set this option to true.
   *  - UPS - Need dry_ice_weight to be set
   *  - UPS MailInnovations - Need dry_ice_weight to be set
   */
  dry_ice_medical?: boolean | null;

  /**
   * Weight of the dry ice in ounces.
   *  - UPS - Need dry_ice to be set
   *  - UPS MailInnovations - Need dry_ice to be set
   *  - FedEx - Need dry_ice to be set
   */
  dry_ice_weight?: string | null;

  /**
   * Possible values "ADDRESS_SERVICE_REQUESTED", "FORWARDING_SERVICE_REQUESTED", "CHANGE_SERVICE_REQUESTED", "RETURN_SERVICE_REQUESTED", "LEAVE_IF_NO_RESPONSE"
   */
  endorsement?:
    | 'ADDRESS_SERVICE_REQUESTED'
    | 'FORWARDING_SERVICE_REQUESTED'
    | 'CHANGE_SERVICE_REQUESTED'
    | 'RETURN_SERVICE_REQUESTED'
    | 'LEAVE_IF_NO_RESPONSE'
    | null;

  /**
   * Additional cost to be added to the invoice of this shipment.
   * Only applies to UPS currently.
   */
  freight_charge?: number | null;

  /**
   * This is to designate special instructions for the carrier like "Do not drop!".
   */
  handling_instructions?: string | null;

  /**
   * Dangerous goods indicator.
   * Possible values are "PRIMARY_CONTAINED", "PRIMARY_PACKED", "PRIMARY", "SECONDARY_CONTAINED", "SECONDARY_PACKED", "SECONDARY", "ORMD", "LIMITED_QUANTITY", "LITHIUM".
   * Applies to USPS, FedEx and DHL eCommerce.
   */
  hazmat?:
    | 'PRIMARY_CONTAINED'
    | 'PRIMARY_PACKED'
    | 'PRIMARY'
    | 'SECONDARY_CONTAINED'
    | 'SECONDARY_PACKED'
    | 'SECONDARY'
    | 'ORMD'
    | 'LIMITED_QUANTITY'
    | 'LITHIUM'
    | null;

  /**
   * Package will wait at carrier facility for pickup.
   */
  hold_for_pickup?: boolean | null;

  /**
   * Incoterm negotiated for shipment.
   * Supported values are "EXW", "FCA", "CPT", "CIP", "DAT", "DAP", "DDP", "FAS", "FOB", "CFR", and "CIF".
   * Setting this value to anything other than "DDP" will pass the cost and responsibility of duties on to the recipient of the package(s), as specified by Incoterms rules
   */
  incoterm?:
    | 'EXW'
    | 'FCA'
    | 'CPT'
    | 'CIP'
    | 'DAT'
    | 'DAP'
    | 'DDP'
    | 'FAS'
    | 'FOB'
    | 'CFR'
    | 'CIF'
    | null;

  /**
   * This will print an invoice number on the postage label.
   */
  invoice_number?: string | null;

  /**
   * Set the date that will appear on the postage label.
   * Accepts ISO 8601 formatted string including time zone offset.
   * EasyPost stores all dates as UTC time.
   */
  label_date?: string | null;

  /**
   * Supported label formats include "PNG", "PDF", "ZPL", and "EPL2".
   * "PNG" is the only format that allows for conversion.
   *
   * @see https://www.easypost.com/docs/api#convert-the-label-format-of-a-shipment
   */
  label_format?: LabelFormat | null;

  /**
   * Whether or not the parcel can be processed by the carriers equipment.
   */
  machinable?: boolean | null;

  /**
   * Setting payment type to bill the correct account for purchasing postage.
   */
  payment: {
    /**
     * Supported values are "SENDER", "THIRD_PARTY", "RECEIVER", "COLLECT". Defaults to SENDER.
     */
    type?: 'SENDER' | 'THIRD_PARTY' | 'RECEIVER' | 'COLLECT' | null;

    /**
     * Setting account number.
     * Required for RECEIVER and THIRD_PARTY.
     */
    account?: string | null;

    /**
     * Setting country code that the account is based in.
     * Required for THIRD_PARTY.
     */
    country?: string | null;

    /**
     * Setting postal code that the account is based in.
     * Required for RECEIVER and THIRD_PARTY.
     */
    postal_code?: string | null;
  };

  /**
   * You can optionally print custom messages on labels.
   * The locations of these fields show up on different spots on the carrier's labels.
   */
  print_custom_1?: string | null;

  /**
   * An additional message on the label. Same restrictions as print_custom_1
   */
  print_custom_2?: string | null;

  /**
   * An additional message on the label. Same restrictions as print_custom_1
   */
  print_custom_3?: string | null;

  /**
   * Create a barcode for this custom reference if supported by carrier.
   */
  print_custom_1_barcode?: boolean | null;

  /**
   * Create a barcode for this custom reference if supported by carrier.
   */
  print_custom_2_barcode?: boolean | null;

  /**
   * Create a barcode for this custom reference if supported by carrier.
   */
  print_custom_3_barcode?: boolean | null;

  /**
   * Specify the type of print_custom_1.
   */
  print_custom_1_code?: TPrintCustomCode | null;

  /**
   * Specify the type of print_custom_2.
   */
  print_custom_2_code?: TPrintCustomCode | null;

  /**
   * Specify the type of print_custom_3.
   */
  print_custom_3_code?: TPrintCustomCode | null;

  /**
   * Set this value to true for delivery on Saturday.
   * When setting the saturday_delivery option, you will only get rates for services that are eligible for saturday delivery.
   * If no services are available for saturday delivery, then you will not be returned any rates.
   * You may need to create 2 shipments, one with the saturday_delivery option set on one without to get all your eligible rates.
   */
  saturday_delivery?: boolean | null;

  /**
   * This option allows you to request restrictive rates from USPS.
   * Can set to 'USPS.MEDIAMAIL' or 'USPS.LIBRARYMAIL'.
   */
  special_rates_eligibility?: 'USPS.MEDIAMAIL' | 'USPS.LIBRARYMAIL' | null;

  /**
   * You can use this to override the hub ID you have on your account.
   */
  smartpost_hub?: string | null;

  /**
   * The manifest ID is used to group SmartPost packages onto a manifest for each trailer.
   */
  smartpost_manifest?: string | null;

  /**
   * A reference ID for aggregating DHL eCommerce billing data.
   */
  billing_ref?: string | null;

  /**
   * Certified Mail provides the sender with a mailing receipt and, upon request, electronic verification that an article was delivered or that a delivery attempt was made.
   */
  certified_mail?: boolean | null;

  /**
   * Registered Mail is the most secure service that the USPS offers.
   * It incorporates a system of receipts to monitor the movement of the mail from the point of acceptance to delivery
   */
  registered_mail?: boolean | null;

  /**
   * The value of the package contents
   */
  registered_mail_amount?: number | null;

  /**
   * An electronic return receipt may be purchased at the time of mailing and provides a shipper with evidence of delivery (to whom the mail was delivered and date of delivery), and information about the recipient's actual delivery address.
   * Only applies to the USPS.
   */
  return_receipt?: boolean | null;
}


text:
<?php

namespace SpecShaper\CalendarBundle\Validator\Constraints;

use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use SpecShaper\CalendarBundle\Model\CalendarReoccuranceInterface;
use DateTime;

/**
 * Description of ReoccuranceCompleteValidator
 *
 * @author      Mark Ogilvie <mark.ogilvie@specshaper.com>
 * @copyright   (c) 2015, SpecShaper - All rights reserved
 * @license     http://URL name
 * @version     Release: 1.0.0
 * @since       Available since Release 1.0.0
 */
class LogicalEndDateValidator extends ConstraintValidator {

    public function validate($entity, Constraint $constraint)
    {

    }
}


text:
namespace et {
IpcPairClient::IpcPairClient(shared_ptr<SocketHandler> _socketHandler,
                             const SocketEndpoint& endpoint)
    : IpcPairEndpoint(_socketHandler, -1) {
  for (int retry = 0; retry < 5; retry++) {
    endpointFd = socketHandler->connect(endpoint);
    if (endpointFd < 0) {
      std::this_thread::sleep_for(std::chrono::seconds(1));
    } else {
      return;
    }
  }
  throw std::runtime_error("Connect to IPC failed");
}

}  // namespace et


text:
package de.iss.mv2.tests;

import static org.junit.Assert.*;

import java.io.ByteArrayInputStream;
import java.util.Random;

import org.junit.Test;

import de.iss.mv2.io.ByteBufferDataSource;

/**
 * A test for the {@link ByteBufferDataSource}-class.
 * @author Marcel Singer
 *
 */
public class ByteBufferDataSourceTest {

	/**
	 * Performs the test.
	 * @throws Exception If anything goes wrong.
	 */
	@Test
	public void test() throws Exception {
		ByteBufferDataSource bbds = new ByteBufferDataSource(370);
		byte[] data = new byte[370];
		Random rnd = new Random();
		rnd.nextBytes(data);
		bbds.importData(new ByteArrayInputStream(data));
		byte[] arr = bbds.getBytes();
		assertArrayEquals(data, arr);
	}

}


text:
{namespace ehrm=Beech\Ehrm\ViewHelpers}

			<f:render partial="Views/Show/ProfilePhoto"
					  arguments="{photo: person.profilePhoto, width: 150, random: 'TRUE'}"/>
			<ehrm:link.edit controller='ProfilePhoto' action='edit'
							arguments='{party: person}'
							modalSize="small"
							dataReload="reload-current-page"/>

							{person.name.firstName} {person.name.middleName} {person.name.lastName}
							<ehrm:link.edit controller='Person' action='edit' arguments='{person: person, withDetails: false}'
											dataReload="reload-current-page"/>

							<f:if condition="{person.department}">{person.department.name},</f:if>
							{person.age}
							<f:translate id="yearsOld">years old</f:translate>

				<f:if condition="{absence}">

								 Sick

							<f:translate id="absence.startDate">Start date:</f:translate> {absence.startDate -> f:format.date(format: 'd-m-Y')}

							<f:translate id="sickness.estimatedRecoveryDate">Probably recovery on:</f:translate> {absence.estimatedRecoveryDate -> f:format.date(format: 'd-m-Y')}

				</f:if>

					<f:if condition="{person.dateOfBirth}">

								<f:translate id="birthDate">Birth date</f:translate>

							<f:format.date format="d-m-Y">{person.dateOfBirth}</f:format.date>
							<ehrm:link.edit controller='Person' action='edit'
											arguments='{person: person, withDetails: false}'
											dataReload="reload-current-page"/>

					</f:if>

							<f:translate id="nationality">Nationality</f:translate>

						 {person.nationality -> ehrm:format.nationality()}
						<ehrm:link.edit controller='Person' action='edit'
										arguments='{person: person, withDetails: false}'
										dataReload="reload-current-page"/>

					<f:if condition="{person.jobposition}">

								<f:translate id="jobposition">Job position</f:translate>

							 {person.jobposition.name}

					</f:if>
					<f:if condition="{person.manager}">

								<f:translate id="Manager">Manager</f:translate>

							 {person.manager.name}

					</f:if>

							<f:translate id="email">E-mail</f:translate>

						 {person.electronicAddress_email.address}
						<ehrm:link.edit controller='ElectronicAddress' action='list' arguments='{party: person}'
										dataReload="reload-current-page"/>

							<f:translate id="phoneNumber">Phone number</f:translate>

						<f:for each="{phoneNumbers}" as="phoneNumber">
							 {phoneNumber.phoneNumber}

								(
								<f:translate
										id="phoneNumber.phoneNumberType.{phoneNumber.phoneNumberType}"></f:translate>
								)

						</f:for>
						<ehrm:link.edit controller='PhoneNumber' action='list' arguments='{party: person}'
										dataReload="reload-current-page"/>


text:
define(function (require) {
	"use strict";

	var _ = require('underscore'),
//		Backbone = require('backbone'),
		Marionette = require("backbone.marionette"),
		App = require('application');

	var Grid = App.module('Grid', {
		startWithParent: false
	});

	Grid.Controller = Marionette.Controller.extend({
		initialize: function (options) {
			this.region = options.region;
		},

		showGrid: function (id) {
			var indexView = new Grid.ViewMain({});
			this.region.show(indexView);
		}
	});

	Grid.ViewMain = Marionette.Layout.extend({
		template: require('hbs!./tmplIndex')
	});

	Grid.on('before:start', function () {
		this.controller = new Grid.Controller({
			region: App.regionMain
		});
	});

	Grid.on('start', function (id) {
		this.controller.showGrid(id);
	});

	return Grid;
});


text:
#pragma once

#include <gtk/gtk.h>
#include "ng-view.h"

typedef struct _NgWindow NgWindow;

NgWindow *ng_window_init(void);
void ng_window_set_view(NgWindow *win, NgView *view);
void ng_window_destroy(NgWindow *win);
void ng_window_update(NgWindow *win);


text:
package zkselect

import (
	"errors"
	"fmt"
	"log"
	"math/rand"
	"strings"
	"time"

	"github.com/samuel/go-zookeeper/zk"
)

const (
	zRoot         = "/zkselect"
	zQueue        = "/queue"
	zLock         = "/lock"
	zTxn          = "/txn"
	zSelected     = "/selected"
	zParticipants = "/participants"
	zDone         = "/done"
)

var (
	ErrNotConnected     = errors.New("Client not connected")
	ErrAlreadyConnected = errors.New("Client already connected")
	ErrNoSelection      = errors.New("No selection for queue")

	acl = zk.WorldACL(zk.PermAll)
)

type Client struct {
	clientID string
	hosts    []string
	zk       *zk.Conn
	rand     *rand.Rand
}

func New(clientID string, zkHosts []string) *Client {
	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	return &Client{
		clientID: clientID,
		hosts:    zkHosts,
		rand:     r,
	}
}

func (c *Client) Dial() error {
	if c.zk != nil {
		return ErrAlreadyConnected
	}

	conn, _, err := zk.Connect(c.hosts, 3*time.Second)
	if err != nil {
		return err
	}
	c.zk = conn

	if _, err := c.createIfNotExists(zRoot, nil, 0, acl); err != nil {
		c.Close()
		return err
	}
	if _, err := c.createIfNotExists(zRoot+zQueue, nil, 0, acl); err != nil {
		c.Close()
		return err
	}
	if _, err := c.createIfNotExists(zRoot+zLock, nil, 0, acl); err != nil {
		c.Close()
		return err
	}
	if _, err := c.createIfNotExists(zRoot+zTxn, nil, 0, acl); err != nil {
		c.Close()
		return err
	}

	return nil
}

func (c *Client) Close() error {
	if err := c.assertConnected(); err != nil {
		return err
	}
	c.zk.Close()
	c.zk = nil
	return nil
}

func (c *Client) Subscribe(id, queue string) error {
	if err := c.assertConnected(); err != nil {
		return err
	}

	if _, err := c.createIfNotExists(fmt.Sprintf("%s%s/%s", zRoot, zQueue, queue), nil, 0, acl); err != nil {
		return err
	}

	lock := zk.NewLock(c.zk, zRoot+zLock, acl)
	if err := lock.Lock(); err != nil {
		return err
	}
	defer lock.Unlock()

	zNode := fmt.Sprintf("%s%s/%s/%s-%s", zRoot, zQueue, queue, c.clientID, id)
	if _, err := c.createIfNotExists(zNode, nil, zk.FlagEphemeral, acl); err != nil {
		return err
	}

	return nil
}

func (c *Client) Select(queue, msgID string) (string, error) {
	if err := c.assertConnected(); err != nil {
		return "", err
	}

	lock := zk.NewLock(c.zk, zRoot+zLock, acl)
	if err := lock.Lock(); err != nil {
		return "", err
	}
	defer lock.Unlock()

	txnZNode := fmt.Sprintf("%s%s/%s", zRoot, zTxn, msgID)
	if _, err := c.zk.Sync(txnZNode); err != nil {
		return "", err
	}
	exists, _, err := c.zk.Exists(txnZNode)
	if err != nil {
		return "", err
	}

	defer c.mark(msgID)
	if exists {
		return c.getSelected(msgID)
	}

	if err := c.createTxn(queue, msgID); err != nil {
		return "", err
	}

	selected, err := c.selectCandidate(queue)
	if err != nil {
		return "", err
	}

	if _, err := c.zk.Create(fmt.Sprintf("%s%s/%s", txnZNode, zSelected, selected), nil, 0, acl); err != nil {
		return "", err
	}

	clientAndID := strings.Split(selected, "-")
	if clientAndID[0] != c.clientID {
		return "", ErrNoSelection
	}
	return clientAndID[1], nil
}

func (c *Client) createTxn(queue, msgID string) error {
	txnZNode := fmt.Sprintf("%s%s/%s", zRoot, zTxn, msgID)
	if _, err := c.zk.Create(txnZNode, nil, 0, acl); err != nil {
		return err
	}
	if _, err := c.zk.Create(txnZNode+zSelected, nil, 0, acl); err != nil {
		return err
	}
	if _, err := c.zk.Create(txnZNode+zDone, nil, 0, acl); err != nil {
		return err
	}
	if _, err := c.zk.Create(txnZNode+zParticipants, nil, 0, acl); err != nil {
		return err
	}
	candidates, err := c.getCandidates(queue)
	if err != nil {
		return err
	}
	clients := make(map[string]bool)
	for _, candidate := range candidates {
		clients[strings.Split(candidate, "-")[0]] = true
	}
	for client, _ := range clients {
		if _, err := c.zk.Create(fmt.Sprintf("%s%s/%s", txnZNode, zParticipants, client), nil, 0, acl); err != nil {
			return err
		}
	}
	return nil
}

func (c *Client) selectCandidate(queue string) (string, error) {
	candidates, err := c.getCandidates(queue)
	if err != nil {
		return "", err
	}
	if len(candidates) == 0 {
		return "", ErrNoSelection
	}
	return candidates[c.rand.Intn(len(candidates))], nil
}

func (c *Client) getSelected(msgID string) (string, error) {
	txnZNode := fmt.Sprintf("%s%s/%s", zRoot, zTxn, msgID)
	selected, _, err := c.zk.Children(txnZNode + zSelected)
	if err != nil {
		return "", err
	}
	clientAndID := strings.Split(selected[0], "-")
	if clientAndID[0] != c.clientID {
		return "", ErrNoSelection
	}
	return clientAndID[1], nil
}

func (c *Client) mark(msgID string) error {
	if err := c.setDone(msgID); err != nil {
		return err
	}
	done, err := c.isTxnDone(msgID)
	if err != nil {
		return err
	}
	if done {
		log.Println("Deleting txn", msgID)
		txnZNode := fmt.Sprintf("%s%s/%s", zRoot, zTxn, msgID)
		return c.deleteRecursive(txnZNode)
	}
	return nil
}

func (c *Client) setDone(msgID string) error {
	txnZNode := fmt.Sprintf("%s%s/%s", zRoot, zTxn, msgID)
	_, err := c.zk.Create(fmt.Sprintf("%s%s/%s", txnZNode, zDone, c.clientID), nil, 0, acl)
	return err
}

func (c *Client) isTxnDone(msgID string) (bool, error) {
	done, err := c.getDone(msgID)
	if err != nil {
		return false, err
	}
	participants, err := c.getParticipants(msgID)
	if err != nil {
		return false, err
	}
	return len(done) == len(participants), nil
}

func (c *Client) getDone(msgID string) ([]string, error) {
	txnZNode := fmt.Sprintf("%s%s/%s", zRoot, zTxn, msgID)
	done, _, err := c.zk.Children(txnZNode + zDone)
	if err != nil {
		return nil, err
	}
	return done, nil
}

func (c *Client) getParticipants(msgID string) ([]string, error) {
	txnZNode := fmt.Sprintf("%s%s/%s", zRoot, zTxn, msgID)
	participants, _, err := c.zk.Children(txnZNode + zParticipants)
	if err != nil {
		return nil, err
	}
	return participants, nil
}

func (c *Client) getCandidates(queue string) ([]string, error) {
	candidatesZNode := fmt.Sprintf("%s%s/%s", zRoot, zQueue, queue)
	candidates, _, err := c.zk.Children(candidatesZNode)
	if err != nil {
		return nil, err
	}
	return candidates, nil
}

func (c *Client) createIfNotExists(path string, data []byte, flags int32, acl []zk.ACL) (string, error) {
	exists, _, err := c.zk.Exists(path)
	if err != nil {
		return "", err
	}
	if exists {
		return path, nil
	}
	return c.zk.Create(path, data, flags, acl)
}

func (c *Client) deleteRecursive(path string) error {
	children, _, err := c.zk.Children(path)
	if err != nil {
		return err
	}
	for _, child := range children {
		if err := c.deleteRecursive(child); err != nil {
			return err
		}
	}
	return c.zk.Delete(path, -1)
}

func (c *Client) assertConnected() error {
	if c.zk == nil {
		return ErrNotConnected
	}
	return nil
}


text:
@implementation CustomFieldTableViewDelegate

- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView {
	return [dataManager.customFields count];
}

- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex {
    return [[dataManager.customFields objectAtIndex:rowIndex] objectForKey:[aTableColumn identifier]];
}

- (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
    NSMutableDictionary *customField = [dataManager.customFields objectAtIndex:row];
    [customField setObject:object forKey:[tableColumn identifier]];
}

- (void)tableViewSelectionDidChange:(NSNotification *)notification {
    NSTableView *tableView = [notification object];
    if ([tableView selectedRow] >= 0) {
        [postsController.customFieldRemoveButton setEnabled:YES];
    } else {
        [postsController.customFieldRemoveButton setEnabled:NO];
    }
}

@end


text:
package org.dlutcs.nclient_android.view;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import org.dlutcs.nclient_android.R;
import org.dlutcs.nclient_android.activity.NewsDetailActivity;
import org.dlutcs.nclient_android.model.News;
import org.dlutcs.nclient_android.util.AutoScrollHandler;
import org.dlutcs.nclient_android.util.ImageLoader;

import java.util.ArrayList;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * Created by linwei on 15-10-6.
 */
public class NewsListHeaderView extends FrameLayout implements ViewPager.OnPageChangeListener {

    @InjectView(R.id.layout)
    View mLayout;
    @InjectView(R.id.pager)
    HackViewPager mViewPager;
    @InjectView(R.id.dots_view)
    LinearLayout mDotsView;
    @InjectView(R.id.news_title)
    TextView mNewsTitle;

    private ArrayList<News> mNewsList = new ArrayList<>();
    private AutoScrollHandler mAutoScrollHandler;
    private NewsHeaderPagerAdapter mAdapter;

    public NewsListHeaderView(Context context) {
        super(context);
        init();
    }

    private void init() {
        LayoutInflater.from(getContext())
                .inflate(
                        R.layout.view_news_list_header, this, true);
        ButterKnife.inject(this, this);
        mAutoScrollHandler = new AutoScrollHandler(mViewPager);
        mAutoScrollHandler.start();
        mAdapter = new NewsHeaderPagerAdapter();
        mViewPager.setAdapter(mAdapter);
        mViewPager.setOnPageChangeListener(this);
    }

    public void addNews(ArrayList<News> newsList) {
        mNewsList.clear();
        mNewsList.addAll(newsList);
        mAdapter.notifyDataSetChanged();
        if(mNewsList.size() > 0){
            mViewPager.setCurrentItem(0);
            selectIndex(0);
        }
    }

    public void onPause() {
        mAutoScrollHandler.pause();
    }

    public void onResume() {
        mAutoScrollHandler.goOn();
    }

    public void selectIndex(int index) {
        mDotsView.removeAllViews();
        int dotsCount = mNewsList.size();
        int dotSize = getResources().getDimensionPixelSize(R.dimen.dot_size);
        int dotMargin = getResources().getDimensionPixelSize(R.dimen.dot_margin);
        for (int i = 0; i < dotsCount; i++) {
            ImageView imageView = new ImageView(getContext());
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(dotSize, dotSize);
            //最后一个点不需设置右边距
            if (i != dotsCount - 1) {
                params.rightMargin = dotMargin;
            }
            imageView.setLayoutParams(params);
            imageView.setImageResource(R.drawable.promotion_dot_selector);
            if (i == index) {
                imageView.setSelected(true);
            }
            mDotsView.addView(imageView);
        }
        mNewsTitle.setText(mNewsList.get(index).title);
    }

    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

    }

    @Override
    public void onPageSelected(int position) {
        selectIndex(position);
    }

    @Override
    public void onPageScrollStateChanged(int state) {

    }

    public void show(boolean show){
        if(show){
            mLayout.setVisibility(View.VISIBLE);
        }else{
            mLayout.setVisibility(View.GONE);
        }
    }

    private class NewsHeaderPagerAdapter extends PagerAdapter {

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            final News news = mNewsList.get(position);
            View view = LayoutInflater.from(getContext())
                    .inflate(R.layout.view_pager_header,
                            container, false);
            ImageView imageView = (ImageView) view.findViewById(R.id.image_pager);
            ImageLoader.load(news.coverUrl)
                    .into(imageView);
            imageView.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View view) {
                    NewsDetailActivity.startActivity(getContext(), news.id);

                }
            });
            // must use addView()
            container.addView(view);
            return view;
        }

        @Override
        public int getCount() {
            return mNewsList.size();
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            container.removeView((View) object);
        }
    }

}


text:
"""

Copyright (c) 2015 by Patrick Hall, jpatrickhall@gmail.com
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.

-------------------------------------------------------------------------------

SOLUTION TO EXERCISE 3

"""

### Import collections module
import collections

# Determine number of lines in the raw file
nlines = sum(1 for line in open('profiles_raw.txt', 'r'))
print 'The number of lines is:  %i.' % (nlines)

# Clean raw file
# Using list comprehensions
# With progress indicator
with open('profiles_raw.txt', 'r') as in_file:
    with open('profiles_clean.txt', 'w') as out_file:
        for j, line in enumerate(in_file):
            out_file.write(' '.join([word.lower() if (len(word.strip()) >= 4\
                and (word.isalpha() or word.isspace())) else '' for word in\
                line.split()]) + '\n')
            print 'Line %i/%i cleaned ...' % (j+1, nlines)
print 'Done.'

# Create a list of every word in the cleaned profiles
words = []
with open('profiles_clean.txt', 'r') as in_file:
    for line in in_file:
        words += line.split()

# Creates a dictionary of term counts for the entire document
term_counts = collections.Counter(words)
print term_counts

# Creates a set that keeps only terms in the dictionary that occured more that
# ten times
keep_set = set([k for k in term_counts.keys() if term_counts[k] >= 10])

# Create a new file with only these frequently occuring terms
with open('profiles_clean.txt', 'r') as in_file:
    with open('profiles_clean_freq.txt', 'w') as out_file:
        for line in in_file:
            line_list = line.split()
            freq_list = [word for word in line_list if word in keep_set]
            out_file.write(' '.join(freq_list) + '\n')

# Print a dictionary of term counts for each individual cleaned profile
# Which of these profiles looks the most compatible to you?
with open('profiles_clean_freq.txt', 'r') as in_file:
    with open('profiles_term_counts.txt', 'w') as out_file:
        for i, line in enumerate(in_file):
            term_counts = collections.Counter(line.split())
            out_file.write('----------------------------------------\n')
            out_file.write('Profile %i term counts: \n' % (i+1))
            for key in term_counts:
                out_file.write(key + ' ' + str(term_counts[key]) + '\n')


text:
"""Framebuffer objects and renderbuffers.

@author: Stephan Wenger
@date: 2012-02-29
"""

from glitter.framebuffers.framebuffer import *
from glitter.framebuffers.renderbuffer import *


text:
$testdirname = "DumpTestDir";

while ($_ = $ARGV[0],/^-/){
    shift @ARGV;
    last if /^--$/;
    /^-a/ && ($activeonly++);
}

if (!$activeonly){
    &static;
}
&active;

sub static {
    $notok = 1;
    while ( -d $testdirname && $notok){
	if (&yornloop("Can I kill the existing directory $testdirname? ")){
	    $notok = 0;
	}
	else {
	    print "Please give me another name to use for a test directory: ";
	    chop($testdirname = <STDIN>);
	}
    }

    if ($notok) {
	mkdir($testdirname,0755) || die "Cannot create test directory $testdirname";
    }

# We make an output file to keep numbers in for comparison later.
    open(STATFILE,">$testdirname/statfile")||
	die "Cannot create statistics file $testdirname/statfile";

# We make a largish, unexceptional file to slow dump down and get
# stats from...

    open(PLAINFILE,">$testdirname/plainfile") ||
	die "Cannot create plain file $testdirname/plainfile";

    for ($i = 0; $i <= 10000; $i++){
	print PLAINFILE "This is a very dull file.\n";
    }

    ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) =  stat PLAINFILE;

    print STATFILE join("|","plainfile",$dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $block), "\n";

    close PLAINFILE;

# We create a file with a very, very big hole in it.

    open(HOLEYFILE,">$testdirname/filewithbighole") ||
	die "Cannot create file $testdirname/filewithbighole";
    select(HOLEYFILE);
    $| = 1; #unbuffer output to HOLEYFILE;
    select (STDOUT);

    seek(HOLEYFILE,10240000,0);
    print HOLEYFILE "After the hole.\n";

    ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) =  stat HOLEYFILE;

    print STATFILE join("|","filewithbighole",$dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $block), "\n";

    if (!defined($blksize)){
	print "Shoot - stat doesn't provide a blocksize. What do you think the blocksize on this filesystem is? ";
	$blocksize = <STDIN>;
    }
    else{
	$blocksize = $blksize;
    }

    if ($blocks * $blocksize == $size){
	die "My holey file had no holes!";
    }

    close HOLEYFILE;

# We create a file containing what we think is one hole and one hole's
# worth of nulls, the nulls coming first...

    open (DECEPTIVEHOLE, ">$testdirname/deceptivehole") ||
	die "Cannot create $testdirname/deceptivehole";

    select(DECEPTIVEHOLE);
    $| = 1; # Unbuffer output to deceptivehole
    select(STDOUT);

    for ($i = 0; $i < $blksize; $i++){
	print DECEPTIVEHOLE "\000";
    }

    seek(DECEPTIVEHOLE, $blksize, 1);

    print DECEPTIVEHOLE "After the hole.\n";

    ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) =  stat DECEPTIVEHOLE;

    if ($blocks * $blocksize == $size){
	die "My deceptively holey file had no holes!";
    }

    print STATFILE join("|","deceptivehole",$dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $block), "\n";

    close(DECEPTIVEHOLE);

# Now for fun with filenames...

    mkdir("$testdirname/longfilenames",0755);
    mkdir("$testdirname/longlinks", 0755);

    open(LONGNAME,">$testdirname/longfilenames/1");

long:    for ($length = 2; ; $length++){
        $fullength = length("$testdirname/longfilenames/") + $length;
	# increase length until you get ENAMETOOLONG
	close(LONGNAME);
        if ($length > length("$length($fullength)")){
          $name =
            "$length($fullength)"
            . ("x" x ($length - (length("$length($fullength)") + 1))) . "!";
        }
        else {
          $name =
            $length . ("s" x ($length - (length($length) + 1))) . "!";
        }
	if (open(LONGNAME,">$testdirname/longfilenames/$name")){
	    print LONGNAME "This filename is $length characters long.\n";
	    chmod(0557, "$testdirname/longfilenames/$name");
	}
	else {
	    print STDERR "First guess at max component length is " .
($length -1) . "\n";
	    last long;
	}
    }

#and, just to see if we can do it...

    $vlongdir = "d" x ($length - 2);
    $vlongname = $vlongdir;
    while (mkdir("$testdirname/longfilenames/$vlongdir", 0755)){
	$vlongdir = $vlongdir . "/" . $vlongname;
    }

    @vlongdirbits =  split("/",$vlongdir);
    pop @vlongdirbits;
    $vlongdir = join("/",@vlongdirbits);
    open(LONGNAME,">$testdirname/longfilenames/$vlongdir/1");
    chmod(0557, "$testdirname/longfilenames/$vlongdir/1");
    $! = " ";

longer:    for ($length = 2; ; $length++){
        $fullength = length("$testdirname/longfilenames/$vlongdir/") + $length;
	# increase length until you get ENAMETOOLONG
	close(LONGNAME);
        if ($length > length("$length($fullength)")){
          $name =
            "$length($fullength)"
            . ("x" x ($length - (length("$length($fullength)"
) + 1))) . "!";
        }
        else {
          $name =
            $length . ("s" x ($length - (length($length) + 1))) . "!";
        }
	if (open(LONGNAME,">$testdirname/longfilenames/$vlongdir/$name")){
	    print LONGNAME "This filename is $length characters
long.\n";
            chmod(0557, "$testdirname/longfilenames/$vlongfir/$name");
	}
	else {
            print STDERR "max path length appears to be " . (length("$testdirname/longfilenames/$vlongdir/$name")
- 1) . "\n";
	    last longer;
	}
    }

# And now for horrible symlinks...

symlink("1", "$testdirname/longlinks/1");

for ($length = 2; $length <= 1025; $length++){
  $name = $length . ("x" x ($length - (length($length) + 1))) . "!";
  symlink("$name", "$testdirname/longlinks/$length");
}

# We will use odd names to simultaneously test 3 things; handling of
# bizarre characters in various positions in file and directory names,
# handling oodles  of hard links, and handling of symbolic links to
# bizarre places. I ignore error codes right and left, because I know
# that a lot of these are ill-formed

    if (! -d "$testdirname/funnynames"){
	mkdir("$testdirname/funnynames", 0755) ||
	    die "Cannot create directory for weird names";
    }
    if (! -d "$testdirname/hardlinks"){
	mkdir("$testdirname/hardlinks", 0755) ||
	    die	"Cannot create directory for hard links";
    }
    if (! -d "$testdirname/softlinks"){
	mkdir("$testdirname/softlinks", 0755) ||
	    die "Cannot create directory for soft links";
    }

    foreach $pos1 (0 .. 3){
	foreach $pos2 (0 .. 7){
	    foreach $pos3 (1 .. 7){
		# we create a file with a name that has only this character
		eval "open(FUNNYNAME, \"> $testdirname/funnynames/\\$pos1$pos2$pos3\0\");";
		print FUNNYNAME "$pos1$pos2$pos3";
		close(FUNNYNAME);
		# And a hard link to it.
		eval " link (\"$testdirname/funnynames/\\$pos1$pos2$pos3\0\", \"$testdirname/hardlinks/$pos1$pos2$pos3\");";

		# we create a file with a name that ends in this character
		eval "open(FUNNYNAME, \">$testdirname/funnynames/ends\$pos1\$pos2\${pos3}\\$pos1$pos2$pos3\0\");";
		print FUNNYNAME "$pos1$pos2$pos3";
		close(FUNNYNAME);
		# And a hard link to it.
		eval " link (\"$testdirname/funnynames/ends\$pos1\$pos2\${pos3}\\$pos1$pos2$pos3\0\", \"$testdirname/hardlinks/ends\$pos1\$pos2\${pos3}$pos1$pos2$pos3\");";

		# we create a file with a name that begins with this character
		eval "open(FUNNYNAME, \">$testdirname/funnynames/\\$pos1$pos2${pos3}begins\$pos1\$pos2\$pos3\");";
		print FUNNYNAME "$pos1$pos2$pos3";
		close(FUNNYNAME);
		# And a hard link to it.
		eval " link (\"$testdirname/funnynames/\\$pos1$pos2${pos3}begins\$pos1\$pos2\$pos3\", \"$testdirname/hardlinks/$pos1$pos2${pos3}begins\$pos1\$pos2\$pos3\");";

		# we create a directory with this character in the middle
		# of its name
		eval "mkdir(\"$testdirname/funnynames/\$pos1\$pos2\$pos3(\\$pos1$pos2$pos3)dir\", 0755);";

		# and we put 10 files in it.
		foreach $i (1..10){
		    eval "open(FUNNYNAME, \">$testdirname/funnynames/\$pos1\$pos2\$pos3(\\$pos1$pos2$pos3)dir/file$i\");";
		    close (FUNNYNAME);
		    # each with a hard link to it.
		    eval " link (\"$testdirname/funnynames/\$pos1\$pos2\$pos3(\\$pos1$pos2$pos3)dir/file$i\", \"$testdirname/hardlinks/\$pos1\$pos2\$pos3($pos1$pos2$pos3)dir-file$i\");";
		}

		# we create a symbolic link to this character...
		eval "symlink(\"\\$pos1$pos2$pos3\", \"$testdirname/softlinks/\$pos1\$pos2\$pos3\");";
	    }
	}
    }

    foreach $link (1..1024){
	link("$testdirname/plainfile", "$testdirname/hardlinks/plain-$link");
    }

# Fun with permissions

    open(BADPERM,">$testdirname/unreadablefile");
    print BADPERM "You can't read this.\n";
    close(BADPERM);
    chmod(000, "$testdirname/unreadablefile");

    mkdir("$testdirname/unreadabledirectory", 0755);
    open(BADPERM,">$testdirname/unreadabledirectory/readablefile");
    print BADPERM "You can read this.\n";
    close(BADPERM);
    chmod(000, "$testdirname/unreadabledirectory");

    open(BADPERM,">$testdirname/unwriteablefile");
    print BADPERM "You can't write this \n";
    close(BADPERM);
    chmod(0555, "$testdirname/unwriteablefile");

    mkdir("$testdirname/unwriteabledirectory", 0755);
    open(BADPERM, ">$testdirname/unwriteabledirectory/writeablefile");
    print BADPERM "You can write this.\n";
    close(BADPERM);
    chmod(0555, "$testdirname/unwriteabledirectory");

# And a device

    system "/usr/etc/mknod $testdirname/chardevice c 17 2";
    system "/usr/etc/mknod $testdirname/blockdevice b 17 4";

# And a named pipe

    system "/usr/etc/mknod $testdirname/namedpipe p";

    close(STATFILE);
} # End of static sub

sub active {
# Now for some action...

# We make a file
    open(CHANGE,">$testdirname/z.deleted");
    print CHANGE "This file was deleted after the dump began.";
    close(CHANGE);
    open (CHANGE, ">$testdirname/z.becomesdir");
    close(CHANGE);

    mkdir("$testdirname/z.becomesfile", 0755);

    open(LONGER,">$testdirname/z.zgrows");
    open(SLOWLONGER, ">$testdirname/z.slow");
    open(SHORTER,">$testdirname/z.shrinks");
    select(LONGER); $| = 1; select(STDOUT);
    select(SLOWLONGER); $| = 1; select(STDOUT);

    for $i (0..10000){
	print SHORTER ("Shrinking" x 10) . "\n";
	$shortlength = $shortlength + 91;
    }
# This apparently redundant open insures a flush
    open(SHORTER,">$testdirname/z.shrinks");

    print STDOUT "Type a command line which will run a backup program on the dump test directory: \n";
    chop($backupcommand = <STDIN>);

    if ($pid = fork){
	# We are in the parent. We start the backup process here, so we can
	# kill the children that are shrinking and growing files when it
	# finishes.
	$clockstart = time;
	$cpustart = (times)[0];
	system $backupcommand;
	$cpuend = (times)[0];
	$clockend = time;
	kill $pid;
	printf ("Backup took %.2f seconds of clock time and %.2f seconds of cpu time\n", $clockend-$clockstart, $cpuend-$cpustart);

    }
    elsif (defined $pid){
	# We are in child1...
	print "Child 1 \n";
	sleep 5;
	open(CHANGE, ">$testdirname/z.created");
	close(CHANGE);
	unlink("$testdirname/z.deleted");
	unlink("$testdirname/z.becomesdir");
	mkdir("$testdirname/z.becomesdir", 0755);
	rmdir("$testdirname/z.becomesfile");
	open(CHANGE, ">$testdirname/z.becomesfile");
	close(CHANGE);
	while (1){
	    print LONGER "Growing, ";
	    $shortlength--;
	    eval 'truncate(SHORTER,$shortlength);';
	    print LONGER "growing, ";
	    print SLOWLONGER "a";
	    print LONGER "grown.\n";
	}
	exit;
    }
    else {
	warn "Can't fork child: $!\n";
    }
}

sub yornloop { # this subroutine takes a single argument, a string; it
  # prints the string, reads an answer from stdin, returns 1 if the
  # answer begins with y or Y, 0 if it begins with n or N, and asks
  # again if neither is true

  local($question) = $_[0];
  local($answer) = "foo";

  while ($answer !~ /[yYnN]/){

    print $question;
    $answer = <STDIN>;
    if ($answer =~ /[yY]/){
      return (1);
    }
    elsif ($answer =~ /[nN]/){
      return (0);
    }
    else {
      print "Please answer \"yes\" or \"no\"\n";
    }
  }
}


text:
@echo off
setlocal

set REPORTDIR=results
set ERRORSTATUS=

:preclean
rm -rf %REPORTDIR% 2>NUL

for /F "delims=" %%a in ('echo %* ^| grep ".py"') do @set testfiles=%%a
rem echo. testfiles: %testfiles%
if not "%testfiles%" == "" (
	echo. ... running the following user-specified test scripts: [ %* ] ...
	python -m pytest -s -v %*
	if errorlevel 1 (
		set ERRORSTATUS=1
	)
) else (
	echo. ... running all test scripts in the following folder: [ %* ] ...
	python %TOOLCHAIN%\tools\pytestloader.py %*
	if errorlevel 1 (
		set ERRORSTATUS=1
	)
)

rem py.test -s -v %*
rem if "%~x1" == ".py" (
rem     python -m unittest -v "%~n1"
rem ) else (
rem     python -m unittest -v "%1"
rem )

:end
rm -rf __pycache__ 2>NUL
rm -rf *.pyc 2>NUL

if exist %REPORTDIR%\report.html (
	start %REPORTDIR%\report.html
)

endlocal & exit /B %ERRORSTATUS%


text:
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")]


text:
<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2015 Cisco Systems, Inc.
  ~
  ~  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.
  -->

<ParameterInstantiations parameterId="42">
    <HierarchyNode id="1" name="ProdX-East"   levelName="GROUP" />
    <HierarchyNode id="2" name="ProdX-West"   levelName="GROUP" />
    <HierarchyNode id="6" name="ProdX-East-1" levelName="COMPONENT" />
    <HierarchyNode id="9" name="ProdX-East-4" levelName="COMPONENT" />
</ParameterInstantiations>