text:
char* globalG;
uint globalL;

inline int funCompareSuffixes ( const void *a, const void *b){

    uint *ga=(uint*)((globalG-7LLU)+(*((uint*)a)));
    uint *gb=(uint*)((globalG-7LLU)+(*((uint*)b)));

    uint jj=0;
    int  ii=0;
    uint va=0,vb=0;
    uint8 *va1, *vb1;

    while (jj < globalL) {
        va=*(ga-jj);
        vb=*(gb-jj);

        #define has5(v) ((((v)^0x0505050505050505) - 0x0101010101010101) & ~((v)^0x0505050505050505) & 0x8080808080808080)

        if (has5(va) && has5(vb))
        {//there is 5 in the sequence - only compare bytes before 5
            va1=(uint8*) &va;
            vb1=(uint8*) &vb;
            for (ii=7;ii>=0;ii--)
            {
                if (va1[ii]>vb1[ii])
                {
                    return 1;
                } else if (va1[ii]<vb1[ii])
                {
                    return -1;
                } else if (va1[ii]==5)
                {//va=vb at the end of chr
                    if ( *((uint*)a) > *((uint*)b) )
                    {//anti-stable order,since indexes are sorted in the reverse order
                        return  -1;
                    } else
                    {//a cannot be equal to b
                        return 1;
                    };
                };
            };
        } else
        {//no 5, simple comparison
            if (va>vb)
            {
                return 1;
            } else if (va<vb)
            {
                return -1;
            };
        };
        jj++;
    };

    //suffixes are equal up to globalL, no simply compare the indexes
    if ( *((uint*)a) > *((uint*)b) )
    {//anti-stable order,since indexes are sorted in the reverse order
        return  -1;
    } else
    {//a cannot be equal to b
        return 1;
    };
};

inline uint funG2strLocus (uint SAstr, uint const N, char const GstrandBit, uint const GstrandMask) {
    bool strandG = (SAstr>>GstrandBit) == 0;
    SAstr &= GstrandMask;
    if ( !strandG ) SAstr += N;
    return SAstr;
};

void Genome::genomeGenerate() {

    //check parameters
	createDirectory(pGe.gDir, P.runDirPerm, "--genomeDir", P);

	{//move Log.out file into genome directory
		string logfn=pGe.gDir+"Log.out";
		if ( rename( P.outLogFileName.c_str(), logfn.c_str() ) ) {
			warningMessage("Could not move Log.out file from " + P.outLogFileName + " into " + logfn + ". Will keep " + P.outLogFileName +"\n", \
						   std::cerr, P.inOut->logMain, P);
		} else {
			P.outLogFileName=logfn;
		};
	};
    if (sjdbOverhang<=0 && (pGe.sjdbFileChrStartEnd.at(0)!="-" || pGe.sjdbGTFfile!="-")) {
        ostringstream errOut;
        errOut << "EXITING because of FATAL INPUT PARAMETER ERROR: for generating genome with annotations (--sjdbFileChrStartEnd or --sjdbGTFfile options)\n";
        errOut << "you need to specify >0 --sjdbOverhang\n";
        errOut << "SOLUTION: re-run genome generation specifying non-zero --sjdbOverhang, which ideally should be equal to OneMateLength-1, or could be chosen generically as ~100\n";
        exitWithError(errOut.str(),std::cerr, P.inOut->logMain, EXIT_CODE_INPUT_FILES, P);
    };

    if (pGe.sjdbFileChrStartEnd.at(0)=="-" && pGe.sjdbGTFfile=="-") {
        if (P.parArray.at(P.pGe.sjdbOverhang_par)->inputLevel>0 && sjdbOverhang>0) {
            ostringstream errOut;
            errOut << "EXITING because of FATAL INPUT PARAMETER ERROR: when generating genome without annotations (--sjdbFileChrStartEnd or --sjdbGTFfile options)\n";
            errOut << "do not specify >0 --sjdbOverhang\n";
            errOut << "SOLUTION: re-run genome generation without --sjdbOverhang option\n";
            exitWithError(errOut.str(),std::cerr, P.inOut->logMain, EXIT_CODE_INPUT_FILES, P);
        };
        sjdbOverhang=0;
    };

    //time
    time_t rawTime;
    string timeString;

    time(&rawTime);
    P.inOut->logMain     << timeMonthDayTime(rawTime) <<" ... starting to generate Genome files\n" <<flush;
    *P.inOut->logStdOut  << timeMonthDayTime(rawTime) <<" ... starting to generate Genome files\n" <<flush;

    //define some parameters from input parameters
    genomeChrBinNbases=1LLU << pGe.gChrBinNbits;

    nGenome = genomeScanFastaFiles(P,NULL,false,*this);//first scan the fasta file to find all the sizes
    genomeSequenceAllocate(nGenome, nG1alloc, G, G1);
    genomeScanFastaFiles(P,G,true,*this);    //load the genome sequence

    uint64 nGenomeTrue=0;
    for (auto &cl : chrLength)
    	nGenomeTrue += cl; //nGenomeTrue = sum of chr lengths

    P.inOut->logMain <<"Genome sequence total length = " << nGenomeTrue << "\n";
    P.inOut->logMain <<"Genome size with padding = "<< nGenome <<"\n";

    //consensusSequence(); //replace with consensus allele DEPRECATED

    SjdbClass sjdbLoci; //will be filled in transcriptGeneSJ below
    GTF mainGTF(*this, P, pGe.gDir, sjdbLoci); //this loads exonLoci and gene/transcript metadata only, sjdbLoci is not filled

    Genome::transformGenome(&mainGTF);

    mainGTF.superTranscript(); //this may change the genome into (Super)Transcriptome

    chrBinFill();//chrBin is first used in the transcriptGeneSJ below
    mainGTF.transcriptGeneSJ(pGe.gDir);

    sjdbLoadFromFiles(P,sjdbLoci);//this will not be transformed. TODO prevent this parameter combination

    if (pGe.gSAindexNbases > log2(nGenomeTrue)/2-1) {
        ostringstream warnOut;
        warnOut << "--genomeSAindexNbases " << pGe.gSAindexNbases << " is too large for the genome size=" << nGenomeTrue;
        warnOut << ", which may cause seg-fault at the mapping step. Re-run genome generation with recommended --genomeSAindexNbases " << int(log2(nGenomeTrue)/2-1);
        warningMessage(warnOut.str(),P.inOut->logMain,std::cerr,P);
    };

    //output genome metadata
    writeChrInfo(pGe.gDir);

    //preparing to generate SA
    for (uint ii=0;ii<nGenome;ii++) {//- strand
        //if (G[ii]>5)
        //    cerr << ii <<" "<< G[ii]<<"\n";
        G[2*nGenome-1-ii]=G[ii]<4 ? 3-G[ii] : G[ii];
    };
    nSA=0;
    for (uint ii=0;ii<2*nGenome;ii+=pGe.gSAsparseD) {
        if (G[ii]<4) {
            nSA++;
        };
    };

    // GstrandBit
    GstrandBit = (char) (uint) floor(log(nGenome+P.limitSjdbInsertNsj*sjdbLength)/log(2))+1; //GstrandBit uses P.limitSjdbInsertNsj even if no insertion requested, in case it will be requested at the mapping stage
    if (GstrandBit<32) GstrandBit=32; //TODO: should not this be 31? Need to test for small genomes. TODO: use simple access function for SA
    P.inOut->logMain <<"Estimated genome size with padding and SJs: total=genome+SJ="<<nGenome+P.limitSjdbInsertNsj*sjdbLength<<" = "<<nGenome<<" + "<<P.limitSjdbInsertNsj*sjdbLength<<"\n";
    P.inOut->logMain << "GstrandBit=" << int(GstrandBit) <<"\n";
    GstrandMask = ~(1LLU<<GstrandBit);
    SA.defineBits(GstrandBit+1,nSA);

    if (P.sjdbInsert.yes) {//reserve space for junction insertion
        SApass1.defineBits( GstrandBit+1, nSA+2*sjdbLength*min((uint64)sjdbLoci.chr.size(),P.limitSjdbInsertNsj) );//TODO: this allocation is wasteful, get a better estimate of the number of junctions
    } else {//same as SA
        SApass1.defineBits(GstrandBit+1,nSA);
    };

    P.inOut->logMain  << "Number of SA indices: "<< nSA << "\n"<<flush;

    //sort SA
    time ( &rawTime );
    P.inOut->logMain     << timeMonthDayTime(rawTime) <<" ... starting to sort Suffix Array. This may take a long time...\n" <<flush;
    *P.inOut->logStdOut  << timeMonthDayTime(rawTime) <<" ... starting to sort Suffix Array. This may take a long time...\n" <<flush;

//     if (false)
    {//sort SA chunks

        for (uint ii=0;ii<nGenome;ii++) {//re-fill the array backwards for sorting
            swap(G[2*nGenome-1-ii],G[ii]);
        };
        globalG=G;
        globalL=pGe.gSuffixLengthMax/sizeof(uint);
        //count the number of indices with 4nt prefix
        uint indPrefN=1LLU << 16;
        uint* indPrefCount = new uint [indPrefN];
        memset(indPrefCount,0,indPrefN*sizeof(indPrefCount[0]));
        nSA=0;
        for (uint ii=0;ii<2*nGenome;ii+=pGe.gSAsparseD) {
            if (G[ii]<4) {
                uint p1=(G[ii]<<12) + (G[ii-1]<<8) + (G[ii-2]<<4) + G[ii-3];
                indPrefCount[p1]++;
                nSA++;
            };
        };

        uint saChunkSize=(P.limitGenomeGenerateRAM-nG1alloc)/8/P.runThreadN; //number of SA indexes per chunk
        saChunkSize=saChunkSize*6/10; //allow extra space for qsort
        //uint saChunkN=((nSA/saChunkSize+1)/P.runThreadN+1)*P.runThreadN;//ensure saChunkN is divisible by P.runThreadN
        //saChunkSize=nSA/saChunkN+100000;//final chunk size
        if (P.runThreadN>1) saChunkSize=min(saChunkSize,nSA/(P.runThreadN-1));
        uint saChunkN = nSA / saChunkSize + 1;//estimate
        uint* indPrefStart = new uint [saChunkN*2]; //start and stop, *2 just in case
        uint* indPrefChunkCount = new uint [saChunkN*2];
        indPrefStart[0]=0;
        saChunkN=0;//start counting chunks
        uint chunkSize1=indPrefCount[0];
        for (uint ii=1; ii<indPrefN; ii++) {
            chunkSize1 += indPrefCount[ii];
            if (chunkSize1 > saChunkSize) {
                saChunkN++;
                indPrefStart[saChunkN]=ii;
                indPrefChunkCount[saChunkN-1]=chunkSize1-indPrefCount[ii];
                chunkSize1=indPrefCount[ii];
            };
        };
        saChunkN++;
        indPrefStart[saChunkN]=indPrefN+1;
        indPrefChunkCount[saChunkN-1]=chunkSize1;

        P.inOut->logMain  << "Number of chunks: " << saChunkN <<";   chunks size limit: " << saChunkSize*8 <<" bytes\n" <<flush;

        time ( &rawTime );
        P.inOut->logMain     << timeMonthDayTime(rawTime) <<" ... sorting Suffix Array chunks and saving them to disk...\n" <<flush;
        *P.inOut->logStdOut  << timeMonthDayTime(rawTime) <<" ... sorting Suffix Array chunks and saving them to disk...\n" <<flush;

        #pragma omp parallel for num_threads(P.runThreadN) ordered schedule(dynamic,1)
        for (int iChunk=0; iChunk < (int) saChunkN; iChunk++) {//start the chunk cycle: sort each chunk with qsort and write to a file
            uint* saChunk=new uint [indPrefChunkCount[iChunk]];//allocate local array for each chunk
            for (uint ii=0,jj=0;ii<2*nGenome;ii+=pGe.gSAsparseD) {//fill the chunk with SA indices
                if (G[ii]<4) {
                    uint p1=(G[ii]<<12) + (G[ii-1]<<8) + (G[ii-2]<<4) + G[ii-3];
                    if (p1>=indPrefStart[iChunk] && p1<indPrefStart[iChunk+1]) {
                        saChunk[jj]=ii;
                        jj++;
                    };
                    //TODO: if (jj==indPrefChunkCount[iChunk]) break;
                };
            };

            //sort the chunk
            qsort(saChunk,indPrefChunkCount[iChunk],sizeof(saChunk[0]),funCompareSuffixes);
            for (uint ii=0;ii<indPrefChunkCount[iChunk];ii++) {
                saChunk[ii]=2*nGenome-1-saChunk[ii];
            };
            //write files
            string chunkFileName=pGe.gDir+"/SA_"+to_string( (uint) iChunk);
            ofstream & saChunkFile = ofstrOpen(chunkFileName,ERROR_OUT, P);
            fstreamWriteBig(saChunkFile, (char*) saChunk, sizeof(saChunk[0])*indPrefChunkCount[iChunk],chunkFileName,ERROR_OUT,P);
            saChunkFile.close();
            delete [] saChunk;
            saChunk=NULL;
        };

        time ( &rawTime );
        P.inOut->logMain     << timeMonthDayTime(rawTime) <<" ... loading chunks from disk, packing SA...\n" <<flush;
        *P.inOut->logStdOut  << timeMonthDayTime(rawTime) <<" ... loading chunks from disk, packing SA...\n" <<flush;

        //read chunks and pack into full SA
        SApass1.allocateArray();
        SA.pointArray(SApass1.charArray + SApass1.lengthByte-SA.lengthByte); //SA is shifted to have space for junction insertion
        uint N2bit= 1LLU << GstrandBit;
        uint packedInd=0;

        #define SA_CHUNK_BLOCK_SIZE 10000000
        uint* saIn=new uint[SA_CHUNK_BLOCK_SIZE]; //TODO make adjustable

        #ifdef genenomeGenerate_SA_textOutput
                ofstream SAtxtStream ((pGe.gDir + "/SAtxt").c_str());
        #endif

        for (uint iChunk=0;iChunk<saChunkN;iChunk++) {//load files one by one and convert to packed
            ostringstream saChunkFileNameStream("");
            saChunkFileNameStream<< pGe.gDir << "/SA_" << iChunk;
            ifstream saChunkFile(saChunkFileNameStream.str().c_str());
            while (! saChunkFile.eof()) {//read blocks from each file
                uint chunkBytesN=fstreamReadBig(saChunkFile,(char*) saIn,SA_CHUNK_BLOCK_SIZE*sizeof(saIn[0]));
                for (uint ii=0;ii<chunkBytesN/sizeof(saIn[0]);ii++) {
                    SA.writePacked( packedInd+ii, (saIn[ii]<nGenome) ? saIn[ii] : ( (saIn[ii]-nGenome) | N2bit ) );

                    #ifdef genenomeGenerate_SA_textOutput
                        SAtxtStream << saIn[ii] << "\n";
                    #endif
                };
                packedInd += chunkBytesN/sizeof(saIn[0]);
            };
            saChunkFile.close();
            remove(saChunkFileNameStream.str().c_str());//remove the chunk file
        };

        #ifdef genenomeGenerate_SA_textOutput
                SAtxtStream.close();
        #endif
        delete [] saIn;

        if (packedInd != nSA ) {//
            ostringstream errOut;
            errOut << "EXITING because of FATAL problem while generating the suffix array\n";
            errOut << "The number of indices read from chunks = "<<packedInd<<" is not equal to expected nSA="<<nSA<<"\n";
            errOut << "SOLUTION: try to re-run suffix array generation, if it still does not work, report this problem to the author\n"<<flush;
            exitWithError(errOut.str(),std::cerr, P.inOut->logMain, EXIT_CODE_INPUT_FILES, P);
        };

        //DONE with suffix array generation

        for (uint ii=0;ii<nGenome;ii++) {//return to normal order for future use
            swap(G[2*nGenome-1-ii],G[ii]);
        };
        delete [] indPrefCount;
        delete [] indPrefStart;
        delete [] indPrefChunkCount;
    };

    time ( &rawTime );
    timeString=asctime(localtime ( &rawTime ));
    timeString.erase(timeString.end()-1,timeString.end());
    P.inOut->logMain     << timeMonthDayTime(rawTime) <<" ... finished generating suffix array\n" <<flush;
    *P.inOut->logStdOut  << timeMonthDayTime(rawTime) <<" ... finished generating suffix array\n" <<flush;

    genomeSAindex(G, SA, P, SAi, *this);

    sjdbN=0;
    if (P.sjdbInsert.yes) {//insert junctions
        P.sjdbInsert.outDir=pGe.gDir;
        P.twoPass.pass2=false;

        Genome genome1(*this); //create copy here, *this will be changed by sjdbInsertJunctions
        sjdbInsertJunctions(P, *this, genome1, sjdbLoci);
    };

    pGe.gFileSizes.clear();
    pGe.gFileSizes.push_back(nGenome);
    pGe.gFileSizes.push_back(SA.lengthByte);

    //write genome parameters file
    genomeParametersWrite(pGe.gDir+("/genomeParameters.txt"), P, ERROR_OUT, *this);

    //write genome to disk
    time ( &rawTime );
    P.inOut->logMain     << timeMonthDayTime(rawTime) <<" ... writing Genome to disk ...\n" <<flush;
    *P.inOut->logStdOut  << timeMonthDayTime(rawTime) <<" ... writing Genome to disk ...\n" <<flush;

    writeGenomeSequence(pGe.gDir);

    //write SA
    time ( &rawTime );
    P.inOut->logMain  << "SA size in bytes: "<<SA.lengthByte << "\n"<<flush;

    P.inOut->logMain     << timeMonthDayTime(rawTime) <<" ... writing Suffix Array to disk ...\n" <<flush;
    *P.inOut->logStdOut  << timeMonthDayTime(rawTime) <<" ... writing Suffix Array to disk ...\n" <<flush;

    ofstream & SAout = ofstrOpen(pGe.gDir+"/SA",ERROR_OUT, P);
    fstreamWriteBig(SAout,(char*) SA.charArray, (streamsize) SA.lengthByte,pGe.gDir+"/SA",ERROR_OUT,P);
    SAout.close();

    //write SAi
    time(&rawTime);
    P.inOut->logMain    << timeMonthDayTime(rawTime) <<" ... writing SAindex to disk\n" <<flush;
    *P.inOut->logStdOut << timeMonthDayTime(rawTime) <<" ... writing SAindex to disk\n" <<flush;

    //write SAi to disk
    ofstream & SAiOut = ofstrOpen(pGe.gDir+"/SAindex",ERROR_OUT, P);

    fstreamWriteBig(SAiOut, (char*) &pGe.gSAindexNbases, sizeof(pGe.gSAindexNbases),pGe.gDir+"/SAindex",ERROR_OUT,P);
    fstreamWriteBig(SAiOut, (char*) genomeSAindexStart, sizeof(genomeSAindexStart[0])*(pGe.gSAindexNbases+1),pGe.gDir+"/SAindex",ERROR_OUT,P);
    fstreamWriteBig(SAiOut,  SAi.charArray, SAi.lengthByte,pGe.gDir+"/SAindex",ERROR_OUT,P);
    SAiOut.close();

    SApass1.deallocateArray();

    time(&rawTime);
    timeString=asctime(localtime ( &rawTime ));
    timeString.erase(timeString.end()-1,timeString.end());

    time(&rawTime);
    P.inOut->logMain    << timeMonthDayTime(rawTime) << " ..... finished successfully\n" <<flush;
    *P.inOut->logStdOut << timeMonthDayTime(rawTime) << " ..... finished successfully\n" <<flush;
};

void Genome::writeChrInfo(const string dirOut)
{//write chr information
    ofstream & chrN = ofstrOpen(dirOut+"/chrName.txt",ERROR_OUT, P);
    ofstream & chrS = ofstrOpen(dirOut+"/chrStart.txt",ERROR_OUT, P);
    ofstream & chrL = ofstrOpen(dirOut+"/chrLength.txt",ERROR_OUT, P);
    ofstream & chrNL = ofstrOpen(dirOut+"/chrNameLength.txt",ERROR_OUT, P);

    for (uint ii=0;ii<nChrReal;ii++) {//output names, starts, lengths
        chrN<<chrName[ii]<<"\n";
        chrS<<chrStart[ii]<<"\n";
        chrL<<chrLength.at(ii)<<"\n";
        chrNL<<chrName[ii]<<"\t"<<chrLength.at(ii)<<"\n";
    };
    chrS<<chrStart[nChrReal]<<"\n";//size of the genome
    chrN.close();chrL.close();chrS.close(); chrNL.close();
};
void Genome::writeGenomeSequence(const string dirOut)
{//write genome sequence
    ofstream &genomeOut = ofstrOpen(dirOut+"/Genome",ERROR_OUT, P);
    fstreamWriteBig(genomeOut,G,nGenome,dirOut+"/Genome",ERROR_OUT,P);
    genomeOut.close();
};


text:
package com.ddu.icore.ui.widget;

import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.LinearInterpolator;
import androidx.core.content.ContextCompat;
import com.ddu.icore.R;

public class ClockLoadingView extends View {

    private final static float MIN_PIN_MAX_ANGLE = (float) (2 * Math.PI);
    private final static float HOUR_PIN_ANGLE_INTERVAL = (float) (2 * Math.PI / 12);
    private final static int COLOR_BG = R.color.loading_clock_bg;
    private final static int COLOR_PIN = R.color.loading_clock_pin;
    private float borderCircleRadius;
    private Path borderCirclePath;
    private Path insideCirclePath;
    private Paint borderCirclePaint;
    private Paint insideCirclePaint;
    private Paint hourHandPaint;
    private Paint minHandPaint;
    private ValueAnimator valueAnimator;
    private long animatorPlayTime;
    private float centerX;
    private float centerY;
    private float currentMinHandAngle = 0;
    private float currentHourHandAngle = 0;

    public ClockLoadingView(Context context) {
        this(context, null);
    }

    public ClockLoadingView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public ClockLoadingView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    private void init(Context context) {
        borderCirclePath = new Path();
        insideCirclePath = new Path();

        borderCirclePaint = new Paint();
        borderCirclePaint.setAntiAlias(true);
        borderCirclePaint.setColor(ContextCompat.getColor(context, COLOR_BG));
        borderCirclePaint.setStyle(Paint.Style.STROKE);

        insideCirclePaint = new Paint();
        insideCirclePaint.setAntiAlias(true);
        insideCirclePaint.setColor(ContextCompat.getColor(context, COLOR_BG));
        insideCirclePaint.setStyle(Paint.Style.FILL);

        hourHandPaint = new Paint();
        hourHandPaint.setAntiAlias(true);
        hourHandPaint.setStrokeCap(Paint.Cap.ROUND);
        hourHandPaint.setColor(ContextCompat.getColor(context, COLOR_PIN));

        minHandPaint = new Paint();
        minHandPaint.setAntiAlias(true);
        minHandPaint.setStrokeCap(Paint.Cap.ROUND);
        minHandPaint.setColor(ContextCompat.getColor(context, COLOR_PIN));
        setRotation(-90);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        int modeWidth = MeasureSpec.getMode(widthMeasureSpec);
        int modeHeight = MeasureSpec.getMode(heightMeasureSpec);

        if (modeWidth == MeasureSpec.AT_MOST && modeHeight == MeasureSpec.AT_MOST) {
            ViewGroup.LayoutParams layoutParams = getLayoutParams();
            layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
            layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT;
            setLayoutParams(layoutParams);
        }
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        stop();
        int minSize = Math.min(w, h);
        //外边框的线的宽度
        float borderCircleStrokeWidth = minSize / 16f;
        //指针的线的宽度
        float pinStrokeWidth = minSize / 10f;

        borderCirclePaint.setStrokeWidth(borderCircleStrokeWidth);
        hourHandPaint.setStrokeWidth(pinStrokeWidth);
        minHandPaint.setStrokeWidth(pinStrokeWidth);
        //外圆半径
        borderCircleRadius = minSize / 2 - borderCircleStrokeWidth;

        centerX = w / 2;
        centerY = h / 2;

        borderCirclePath.reset();
        borderCirclePath.addCircle(w / 2, h / 2, borderCircleRadius, Path.Direction.CW);
        insideCirclePath.addCircle(w / 2, h / 2, borderCircleRadius - pinStrokeWidth, Path.Direction.CW);
        setupAnimator();
    }

    /**
     * 目前分针1s一圈,时针12s一圈
     */
    private void setupAnimator() {
        valueAnimator = ValueAnimator.ofFloat(0, MIN_PIN_MAX_ANGLE);
        valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                currentMinHandAngle = (float) animation.getAnimatedValue();
                if (currentHourHandAngle > 2 * Math.PI) {
                    currentHourHandAngle = 0;
                } else {
                    currentHourHandAngle = currentHourHandAngle + (float) (Math.PI / (60 * 6));
                }
                invalidate();
            }
        });
        valueAnimator.setInterpolator(new LinearInterpolator());
        valueAnimator.setDuration(1000);
        valueAnimator.setRepeatCount(ValueAnimator.INFINITE);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.drawPath(borderCirclePath, borderCirclePaint);
        canvas.drawPath(insideCirclePath, insideCirclePaint);
        float minEndX = (float) ((borderCircleRadius * 0.5) * Math.cos(currentMinHandAngle) + centerX);
        float minEndY = (float) ((borderCircleRadius * 0.5) * Math.sin(currentMinHandAngle) + centerY);

        float hourEndX = (float) ((borderCircleRadius * 0.5) * Math.cos(currentHourHandAngle) + centerX);
        float hourEndY = (float) ((borderCircleRadius * 0.5) * Math.sin(currentHourHandAngle) + centerY);

        canvas.drawLine(centerX, centerY, hourEndX, hourEndY, hourHandPaint);
        canvas.drawLine(centerX, centerY, minEndX, minEndY, minHandPaint);
    }

    public void start() {
        if (valueAnimator != null && !valueAnimator.isRunning()) {
            //valueAnimator.setCurrentPlayTime(animatorPlayTime);
            //每次都从头执行
            currentMinHandAngle = 0;
            currentHourHandAngle = 0;
            valueAnimator.start();
        }
    }

    public void stop() {
        if (valueAnimator != null && valueAnimator.isRunning()) {
            //animatorPlayTime = valueAnimator.getCurrentPlayTime();
            valueAnimator.cancel();
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
package rpc

import (
	"context"
	"io"
	"sync"

	"github.com/libp2p/go-libp2p-core/host"
	"github.com/libp2p/go-libp2p-core/peer"
	"github.com/libp2p/go-libp2p-core/protocol"

	stats "github.com/libp2p/go-libp2p-gorpc/stats"
)

// ClientOption allows for functional setting of options on a Client.
type ClientOption func(*Client)

// WithClientStatsHandler provides an implementation of stats.Handler to be
// used by the Client.
func WithClientStatsHandler(h stats.Handler) ClientOption {
	return func(c *Client) {
		c.statsHandler = h
	}
}

// Client represents an RPC client which can perform calls to a remote
// (or local, see below) Server.
type Client struct {
	host         host.Host
	protocol     protocol.ID
	server       *Server
	statsHandler stats.Handler
}

// NewClient returns a new Client which uses the given LibP2P host
// and protocol ID, which must match the one used by the server.
// The Host must be correctly configured to be able to open streams
// to the server (addresses and keys in Peerstore etc.).
//
// The client returned will not be able to run any local requests
// if the Server is sharing the same LibP2P host. See NewClientWithServer
// if this is a usecase.
func NewClient(h host.Host, p protocol.ID, opts ...ClientOption) *Client {
	c := &Client{
		host:     h,
		protocol: p,
	}

	for _, opt := range opts {
		opt(c)
	}

	return c
}

// NewClientWithServer takes an additional RPC Server and returns a Client.
// Unlike the normal client, this one will be able to perform any requests to
// itself by using the given Server.Call() directly. It is assumed that Client
// and Server share the same LibP2P host.
func NewClientWithServer(h host.Host, p protocol.ID, s *Server, opts ...ClientOption) *Client {
	c := NewClient(h, p, opts...)
	c.server = s
	return c
}

// ID returns the peer.ID of the host associated with this client.
func (c *Client) ID() peer.ID {
	if c.host == nil {
		return ""
	}
	return c.host.ID()
}

// Call performs an RPC call to a registered Server service and blocks until
// completed. If dest is empty ("") or matches the Client's host ID, it will
// attempt to use the local configured Server when possible.
func (c *Client) Call(
	dest peer.ID,
	svcName, svcMethod string,
	args, reply interface{},
) error {
	ctx := context.Background()
	return c.CallContext(ctx, dest, svcName, svcMethod, args, reply)
}

// CallContext performs a Call() with a user provided context. This gives
// the user the possibility of cancelling the operation at any point.
func (c *Client) CallContext(
	ctx context.Context,
	dest peer.ID,
	svcName, svcMethod string,
	args, reply interface{},
) error {
	done := make(chan *Call, 1)
	call := newCall(ctx, dest, svcName, svcMethod, args, reply, done)
	go c.makeCall(call)
	<-done
	return call.getError()
}

// Go performs an RPC call asynchronously. The associated Call will be placed
// in the provided channel upon completion, holding any Reply or Errors.
//
// The provided done channel must be nil, or have capacity for 1 element
// at least, or a panic will be triggered.
//
// If dest is empty ("") or matches the Client's host ID, it will
// attempt to use the local configured Server when possible.
func (c *Client) Go(
	dest peer.ID,
	svcName, svcMethod string,
	args, reply interface{},
	done chan *Call,
) error {
	ctx := context.Background()
	return c.GoContext(ctx, dest, svcName, svcMethod, args, reply, done)
}

// GoContext performs a Go() call with the provided context, allowing
// the user to cancel the operation. See Go() documentation for more
// information.
//
// The provided done channel must be nil, or have capacity for 1 element
// at least, or a panic will be triggered.
func (c *Client) GoContext(
	ctx context.Context,
	dest peer.ID,
	svcName, svcMethod string,
	args, reply interface{},
	done chan *Call,
) error {
	if done == nil {
		done = make(chan *Call, 1)
	} else {
		if cap(done) == 0 {
			panic("done channel has no capacity")
		}
	}
	call := newCall(ctx, dest, svcName, svcMethod, args, reply, done)
	go c.makeCall(call)
	return nil
}

// MultiCall performs a CallContext() to multiple destinations, using the same
// service name, method and arguments. It will not return until all calls have
// done so. The contexts, destinations and replies must match in length and
// will be used in order (ctxs[i] is used for dests[i] which obtains
// replies[i] and error[i]).
//
// The calls will be triggered in parallel (with one goroutine for each).
func (c *Client) MultiCall(
	ctxs []context.Context,
	dests []peer.ID,
	svcName, svcMethod string,
	args interface{},
	replies []interface{},
) []error {

	ok := checkMatchingLengths(
		len(ctxs),
		len(dests),
		len(replies),
	)

	if !ok {
		panic("ctxs, dests and replies must match in length")
	}

	var wg sync.WaitGroup
	errs := make([]error, len(dests))

	for i := range dests {
		wg.Add(1)
		go func(i int) {
			defer wg.Done()
			err := c.CallContext(
				ctxs[i],
				dests[i],
				svcName,
				svcMethod,
				args,
				replies[i])
			errs[i] = err
		}(i)
	}
	wg.Wait()
	return errs
}

// MultiGo performs a GoContext() call to multiple destinations, using the same
// service name, method and arguments. MultiGo will return as right after
// performing all the calls. See the Go() documentation for more information.
//
// The provided done channels must be nil, or have capacity for 1 element
// at least, or a panic will be triggered.
//
// The contexts, destinations, replies and done channels  must match in length
// and will be used in order (ctxs[i] is used for dests[i] which obtains
// replies[i] with dones[i] signalled upon completion).
func (c *Client) MultiGo(
	ctxs []context.Context,
	dests []peer.ID,
	svcName, svcMethod string,
	args interface{},
	replies []interface{},
	dones []chan *Call,
) error {

	ok := checkMatchingLengths(
		len(ctxs),
		len(dests),
		len(replies),
		len(dones),
	)
	if !ok {
		panic("ctxs, dests, replies and dones must match in length")
	}

	for i := range ctxs {
		c.GoContext(
			ctxs[i],
			dests[i],
			svcName,
			svcMethod,
			args,
			replies[i],
			dones[i],
		)
	}

	return nil
}

func checkMatchingLengths(l ...int) bool {
	if len(l) <= 1 {
		return true
	}

	for i := 1; i < len(l); i++ {
		if l[i-1] != l[i] {
			return false
		}
	}
	return true
}

// makeCall decides if a call can be performed. If it's a local
// call it will use the configured server if set.
func (c *Client) makeCall(call *Call) {
	logger.Debugf(
		"makeCall: %s.%s",
		call.SvcID.Name,
		call.SvcID.Method,
	)

	// Handle local RPC calls
	if call.Dest == "" || c.host == nil || call.Dest == c.host.ID() {
		logger.Debugf(
			"local call: %s.%s",
			call.SvcID.Name,
			call.SvcID.Method,
		)
		if c.server == nil {
			err := &clientError{"Cannot make local calls: server not set"}
			call.doneWithError(err)
			return
		}
		err := c.server.Call(call)
		call.doneWithError(err)
		return
	}

	// Handle remote RPC calls
	if c.host == nil {
		panic("no host set: cannot perform remote call")
	}
	if c.protocol == "" {
		panic("no protocol set: cannot perform remote call")
	}
	c.send(call)
}

// send makes a REMOTE RPC call by initiating a libP2P stream to the
// destination and waiting for a response.
func (c *Client) send(call *Call) {
	logger.Debug("sending remote call")

	s, err := c.host.NewStream(call.ctx, call.Dest, c.protocol)
	if err != nil {
		call.doneWithError(newClientError(err))
		return
	}

	go call.watchContextWithStream(s)
	sWrap := wrapStream(s)

	logger.Debugf(
		"sending RPC %s.%s to %s",
		call.SvcID.Name,
		call.SvcID.Method,
		call.Dest,
	)
	if err := sWrap.enc.Encode(call.SvcID); err != nil {
		call.doneWithError(newClientError(err))
		s.Reset()
		return
	}
	if err := sWrap.enc.Encode(call.Args); err != nil {
		call.doneWithError(newClientError(err))
		s.Reset()
		return
	}

	if err := sWrap.w.Flush(); err != nil {
		call.doneWithError(newClientError(err))
		s.Reset()
		return
	}
	err = receiveResponse(sWrap, call)
	if err != nil {
		s.Reset()
		return
	}
	s.Close()
}

// receiveResponse reads a response to an RPC call
func receiveResponse(s *streamWrap, call *Call) error {
	logger.Debugf(
		"waiting response for %s.%s to %s",
		call.SvcID.Name,
		call.SvcID.Method,
		call.Dest,
	)
	var resp Response
	if err := s.dec.Decode(&resp); err != nil {
		call.doneWithError(newClientError(err))
		return err
	}

	defer call.done()
	if e := resp.Error; e != "" {
		call.setError(responseError(resp.ErrType, e))
	}

	// Even on error we sent the reply so it needs to be
	// read
	if err := s.dec.Decode(call.Reply); err != nil && err != io.EOF {
		call.setError(newClientError(err))
		return err
	}
	return nil
}


text:
import settings
import board
from engine import Engine
from notation import Notation
from piece import Piece
from validation import Validation
import errors

class GameBase:
    def __init__(self):
        self.board = board.Board()
        self.analyse_board = board.Board()
        self.clear_history()

    def parse_fen(self, fen):
        if not Validation.is_fen(fen):
            print(settings.MSG['invalid_fen'])
            return False

        self.fen, to_move, self.castles, self.en_passant, self.half_moves, \
            self.num_moves = fen.split(' ')
        self.num_moves = int(self.num_moves)
        self.half_moves = int(self.half_moves)
        self.board._arrange_pieces(self.fen)
        self.to_move = 0 if to_move == 'w' else 1
        self.setup()

    def other_color(self, color):
        return 1 - color

    def switch_side(self):
        if self.to_move: self.num_moves += 1
        self.to_move = self.other_color(self.to_move)
        self.setup()

    def _encode_pieces(self):
        fen = ''
        i = 0
        pieces = dict((p.location, p.code) for p in self.pieces_in_play())
        for square in Notation.all_squares(True):
            if square in pieces:
                if i > 0:
                    fen += str(i)
                    i = 0
                fen += pieces[square]
            else:
                i += 1
            if square[0] == 'h':
                if i > 0:
                    fen += str(i)
                    i = 0
                fen += '/'
        return fen[:-1]

    def list_moves(self):
        return set('{}-{}'.format(piece.location,  moves) for piece in \
            self.pieces_by_color(self.to_move) for moves in piece.moves)

class PieceSelector(GameBase):
    def piece_on(self, notation):
        return self.board[notation].piece

    def moves_by_color(self, color):
        pieces = self.pieces_by_color(color)
        moves = set()
        for piece in pieces:
            moves.update(piece.moves)
        return moves

    def pieces_by_color(self, color):
        return [x.piece for x in self._find(
            ['K', 'Q', 'R', 'B', 'N', 'P'], color)]

    def pieces_in_play(self):
        return [x.piece for x in self.board.squares if x.is_occupied()]

    def pieces_by(self, char, color):
        return [x.piece for x in self._find(char, color)]

    def pieces_by_char(self, char):
        white = [x.piece for x in self._find(char, 0)]
        black = [x.piece for x in self._find(char, 1)]
        return white + black

    def first_piece(self, char, color):
        return next(self._find(char, color)).piece

    def _find(self, char, color):
        return filter(lambda x: x.is_occupied() and \
            x.piece.char in char and x.piece.color == color,
                self.board.squares)

    def get_enemies(self, color):
        return self.pieces_by_color(self.other_color(color))

class PositionValidation(PieceSelector):
    def is_valid_position(self):
        return self.are_kings_legally_placed()

    def are_kings_legally_placed(self):
        my_king = self.first_piece(['K'], self.to_move)
        enemy_king = self.first_piece(['K'], self.other_color(self.to_move))
        return not self.is_under_attack(enemy_king)

    def is_legal_castle(self, color, short_castle=True):
        king = self.first_piece(['K'], color)
        enemy_color = self.other_color(color)

        if short_castle:
            squares = ['f8', 'g8'] if color else ['f1', 'g1']
            code = king.code
        else:
            squares = ['c8', 'd8', 'b8'] if color else ['c1', 'd1', 'b1']
            code = 'q' if color else 'Q'

        return not self.is_under_attack(king) and code in self.castles \
            and self.are_available(squares) and not self.is_attacked(
            squares[0], enemy_color) and not self.is_attacked(
            squares[1], enemy_color)

    def are_available(self, squares):
        for square in squares:
            if self.board[square].is_occupied(): return False
        return True

    def is_attacked(self, square, color):
        enemies = self.pieces_by_color(color)
        return any(square in enemy.attacks for enemy in enemies)

    def is_protected(self, piece):
        for alias in self.pieces_by_color(piece.color):
            if piece.location in alias.attacks: return True
        return False

    def is_under_attack(self, piece):
        return piece.location in self.all_attacks(self.other_color(piece.color))

class PieceMove(PositionValidation):
    def all_attacks(self, color):
        squares = set()
        pieces = self.pieces_by_color(color)
        for piece in pieces:
            squares.update(piece.attacks)
        return squares

    def promotion(self, pawn, char):
        new_piece = settings.CHESS_SET[char.upper()](
            pawn.color, pawn.location)

        self.board[pawn.location] = new_piece
        return True

    def undo_last_move(self):
        if not len(self.last_position): return False
        last_position = self.last_position.pop()
        self.parse_fen(last_position)
        return True

    def set_en_passant(self, piece, location):
        if piece.char == 'P' and abs(
            Notation.row(location) - Notation.row(piece.location)) == 2:
                self.en_passant = location[0] + '6' if piece.color else location[0] + '3'
        else:
            self.en_passant = '-'

    def setup(self, legalization=True):
        for piece in self.pieces_in_play():
            piece.moves = set()
            piece.attacks, piece.all_moves = self._get_all_attacks(piece)

        if legalization:
            for piece in self.pieces_by_color(self.to_move):
                piece.moves = self._validated_moves(piece)

    def _get_all_attacks(self, piece):
        moves = self._get_moves(piece)
        attacks = self._get_pawn_captures(piece) if piece.char == 'P' else moves
        all_moves = moves if piece.color == self.to_move else set()
        return [attacks, all_moves]

    def _validated_moves(self, piece, code=0):
        kings = self.pieces_by_char('K')
        color, opp_color = piece.color, self.other_color(piece.color)
        location = piece.location
        all_moves = set(move for move in piece.all_moves \
            if not self.board[move].is_occupied() or not piece.is_alias(
            self.piece_on(move)))
        enemies = self.pieces_by_color(opp_color)
        enemy_attacks = set()

        if piece.char == 'P':
            front_square = '{}{}'.format(
                location[0], Notation.row(location) + piece.directions[1][0][0])
            if piece.is_pawn_first_move() and self.board[front_square].is_occupied():
                all_moves -= set(move for move in all_moves if
                    move[0] == location[0])

            all_moves = set(move for move in all_moves \
                if move == self.en_passant or (
                    move[0] != location[0] and self.board[move].is_occupied()
                    and not piece.is_alias(self.piece_on(move))) or (
                    move[0] == location[0] and not self.board[move].is_occupied()))

            promoting_pieces = {'R', 'Q', 'B', 'N'}
            for move in set(all_moves):
                if move[1] == '1' or move[1] == '8':
                    all_moves.update(set('{}={}'.format(
                        move, x) for x in promoting_pieces ))
                    all_moves.remove(move)

        if piece.char == 'K':
            self.board[piece.location] = None
            for enemy in enemies:
                attacks, moves = self._get_all_attacks(enemy)
                enemy_attacks.update(attacks)
            self.board[location] = kings[color]
            all_moves -= set(
                move for move in all_moves if self.board[move].is_occupied() and
                    self.is_protected(self.piece_on(move)))

            if self.is_legal_castle(piece.color):
                all_moves.add('G8') if piece.color else all_moves.add('G1')

            if self.is_legal_castle(piece.color, False):
                all_moves.add('C8') if piece.color else all_moves.add('C1')

            return all_moves - enemy_attacks

        if not self.is_under_attack(kings[color]): return all_moves
        king_attackers = set(
            enemy for enemy in enemies if kings[color].location in enemy.attacks)

        if len(king_attackers) > 1: return set()
        if not len(king_attackers): return all_moves
        attacker = king_attackers.pop()
        return all_moves & Notation.squares_between(
            attacker.location, kings[color].location)

    def _get_pawn_captures(self, pawn):
        location = pawn.location
        x, y = Notation.str_to_coords(location)
        captures = [[c[0][0] + x, c[0][1] + y] for c in pawn.directions[2:]]
        captures = [Notation.coords_to_str(x) for x in captures]
        return set(x for x in captures if x)

    def _get_moves(self, piece):
        step = 0
        if piece.char == 'P' and not piece.is_pawn_first_move():
            step = 1

        dirs = piece.directions[step:]

        x, y = Notation.str_to_coords(piece.location)
        moves = protects = set()

        for direction in dirs:
            for coords in direction:
                new_x, new_y = coords[0] + x, coords[1] + y
                if new_x not in range(8) or new_y not in range(8): break
                square = Notation.coords_to_str([new_x, new_y])
                moves.update({square})
                if self.board[square].is_occupied(): break
        return moves

    def remove_piece(self, piece):
        self.board[piece.location] = None
        del piece

    def play(self, start, end):
        piece = self.piece_on(start)
        if piece is None:
            print(settings.MSG['no_piece_on_sq'])
            return False
        if piece.color != self.to_move:
            print(settings.MSG['opp_piece'])
            return False
        if end not in piece.moves and end.upper() not in piece.moves:
            print(settings.MSG['illegal_move'])
            return False
        self.old_en_passant = str(self.en_passant)
        self.last_position.append(self.save_position())

        end, *prom = end.split('=')
        self.make_the_move(piece, end.lower())
        if prom: self.promotion(piece, prom[0])

        self.switch_side()

    def simple_move(self, piece, location):
        start = str(piece.location)

        self.board[location] = piece
        self.board[start] = None

    def make_the_move(self, piece, location):
        self.set_en_passant(piece, location)

        if location.upper() in piece.moves:
            rook_moves = settings.ROOK_MOVE_ON_CASTLE[location]
            self.simple_move(self.piece_on(rook_moves[0]), rook_moves[1])

        self.half_moves = 0 if self.board[location].is_occupied() \
            or piece.char == 'P' else self.half_moves + 1

        self.simple_move(piece, location)
        self.remove_victim_on_en_passant(piece, location)
        self.disable_castles(piece)

    def disable_castles(self, piece):
        if piece.color:
            castles = 'kq'
            rank = 8
        else:
            castles = 'KQ'
            rank = 1

        if self.castles == '-' or castles not in self.castles: return

        if piece.char == 'K':
            self.castles = self.castles.replace(castles[0], '')
            self.castles = self.castles.replace(castles[1], '')

        rook_locations = ['h' + str(rank), 'a' + str(rank)]

        if piece.old_location == rook_locations[0] or piece.location == rook_locations[0]:
            self.castles = self.castles.replace(castles[0], '')

        if piece.old_location == rook_locations[1] or piece.location == rook_locations[1]:
            self.castles = self.castles.replace(castles[1], '')

        if not self.castles: self.castles = '-'

    def remove_victim_on_en_passant(self, piece, location):
        if location == self.old_en_passant and piece.char == 'P':
            row = 4 if piece.color else 5
            self.board['{}{}'.format(self.old_en_passant[0], row)] = None

    def save_position(self):
        return '{} {} {} {} {} {}'.format(
            self._encode_pieces(), Notation.side_to_char(self.to_move),
            self.castles, self.en_passant, self.half_moves, self.num_moves)

class Game(PieceMove):
    def __init__(self, fen=settings.START_POS_FEN):
        super().__init__()
        self.parse_fen(fen)

    def clear_history(self):
        self.last_position = []

    def is_stalemate(self):
        king = self.first_piece(['K'], self.to_move)
        return self.has_no_moves() and not self.is_under_attack(king)

    def has_no_moves(self):
        return not len(self.list_moves())

    def is_checkmate(self):
        king = self.first_piece(['K'], self.to_move)
        return self.has_no_moves() and self.is_under_attack(king)

    def is_fifty_move_draw(self):
        return self.half_moves >= 50

    def is_treefold_draw(self):
        positions = [''.join(x.split(' ')[:-2]) for x in self.last_position]
        return any(positions.count(x) >= 3 for x in set(positions))

    def is_impossible_to_checkmate(self):
        pieces = self.pieces_in_play()
        total_points = sum(piece.points for piece in pieces)
        return len(pieces) == 2 or (
            len(pieces) == 3 and 2001 < total_points <= 2003)

    def is_draw(self):
        if self.is_checkmate(): return False
        return self.is_stalemate() or self.is_impossible_to_checkmate() \
            or self.is_treefold_draw() or self.is_fifty_move_draw()

    def is_game_over(self):
        return self.is_draw() or self.is_checkmate()

    def set_CPU_params(self, colors, strength):
        self.cpu = {'color': colors, 'strength': strength}

    def start_game(self, color, strength=2):
        self.set_CPU_params(color, strength)
        while True:
            if self.is_game_over():
                if self.is_draw():
                    msg = 'Draw by '
                    if self.is_stalemate():
                        msg += 'stalemate'
                    elif self.is_treefold_draw():
                        msg += 'treefold repetition'
                    elif self.is_fifty_move_draw():
                        msg += '50 move rule'
                    else:
                        msg += 'insufficient material'
                else:
                    msg = 'White' if self.to_move else 'Black'
                    msg += ' wins'
                print('Game over! ' + msg)
                break

            if self.to_move in self.cpu['color']:
                print('CPU is calculating...')
                best_line = Engine.get_reply(self.save_position(), self.cpu['strength'])
                print("...and plays " + best_line)
                self.play(*best_line.split('-'))
            else:
                print(self)
                cmd = input(settings.MSG['your_turn'])
                if Validation.is_move(cmd):
                    self.play(*cmd.split('-'))
                else:
                    print(settings.MSG['invalid_move'])

    def __repr__(self):
        output = "\n"
        for char in settings.Y_LABELS:
            output += char + ' '
        output += "\n"
        for square in Notation.all_squares(True):
            piece = self.piece_on(square)
            if piece is None:
                output += settings.UNICODE_PIECES['blank']
            else:
                output += settings.UNICODE_PIECES[piece.code]

            output += " "

            if square.startswith('h'):
                output += "{}\n".format(square[1])

        return output


text:
function g = priorGradient(prior, params)

% PRIORGRADIENT Gradient of the prior with respect to its variables
% FORMAT
% DESC wrapper function that computes the gradient of the prior with
% respect to its parameters.
% ARG prior : the prior structure for which the gradients are being
% computed.
% ARG params : the parameter locations for which the gradients are being
% computed.
% RETURN g : gradients of the prior with respect to the parameters.
%
% SEEALSO : priorCreate
%
% COPYRIGHT : Neil D. Lawrence, 2003

% PRIOR

fhandle = str2func([prior.type 'PriorGradient']);
g = fhandle(prior, params);


text:
module Magnetik
  module Rails
    class Routes
      class Mapping
        attr_accessor :controllers, :as, :skips

        def initialize
          @controllers = {
            credit_cards: 'magnetik/credit_cards',
          }

          @as = {}
          @skips = []
        end

        def [](routes)
          {
            controllers: @controllers[routes],
            as: @as[routes]
          }
        end

        def skipped?(controller)
          @skips.include?(controller)
        end
      end
    end
  end
end


text:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="CoreNLP-to-HTML.xsl" type="text/xsl"?>
<root>
  <document>
    <sentences>
      <sentence id="1">
        <tokens>
          <token id="1">
            <word>For</word>
            <lemma>for</lemma>
            <CharacterOffsetBegin>0</CharacterOffsetBegin>
            <CharacterOffsetEnd>3</CharacterOffsetEnd>
            <POS>IN</POS>
          </token>
          <token id="2">
            <word>example</word>
            <lemma>example</lemma>
            <CharacterOffsetBegin>4</CharacterOffsetBegin>
            <CharacterOffsetEnd>11</CharacterOffsetEnd>
            <POS>NN</POS>
          </token>
          <token id="3">
            <word>,</word>
            <lemma>,</lemma>
            <CharacterOffsetBegin>11</CharacterOffsetBegin>
            <CharacterOffsetEnd>12</CharacterOffsetEnd>
            <POS>,</POS>
          </token>
          <token id="4">
            <word>with</word>
            <lemma>with</lemma>
            <CharacterOffsetBegin>13</CharacterOffsetBegin>
            <CharacterOffsetEnd>17</CharacterOffsetEnd>
            <POS>IN</POS>
          </token>
          <token id="5">
            <word>regard</word>
            <lemma>regard</lemma>
            <CharacterOffsetBegin>18</CharacterOffsetBegin>
            <CharacterOffsetEnd>24</CharacterOffsetEnd>
            <POS>NN</POS>
          </token>
          <token id="6">
            <word>to</word>
            <lemma>to</lemma>
            <CharacterOffsetBegin>25</CharacterOffsetBegin>
            <CharacterOffsetEnd>27</CharacterOffsetEnd>
            <POS>TO</POS>
          </token>
          <token id="7">
            <word>our</word>
            <lemma>we</lemma>
            <CharacterOffsetBegin>28</CharacterOffsetBegin>
            <CharacterOffsetEnd>31</CharacterOffsetEnd>
            <POS>PRP$</POS>
          </token>
          <token id="8">
            <word>aid</word>
            <lemma>aid</lemma>
            <CharacterOffsetBegin>32</CharacterOffsetBegin>
            <CharacterOffsetEnd>35</CharacterOffsetEnd>
            <POS>NN</POS>
          </token>
          <token id="9">
            <word>to</word>
            <lemma>to</lemma>
            <CharacterOffsetBegin>36</CharacterOffsetBegin>
            <CharacterOffsetEnd>38</CharacterOffsetEnd>
            <POS>TO</POS>
          </token>
          <token id="10">
            <word>Mediterranean</word>
            <lemma>mediterranean</lemma>
            <CharacterOffsetBegin>39</CharacterOffsetBegin>
            <CharacterOffsetEnd>52</CharacterOffsetEnd>
            <POS>JJ</POS>
          </token>
          <token id="11">
            <word>countries</word>
            <lemma>country</lemma>
            <CharacterOffsetBegin>53</CharacterOffsetBegin>
            <CharacterOffsetEnd>62</CharacterOffsetEnd>
            <POS>NNS</POS>
          </token>
          <token id="12">
            <word>,</word>
            <lemma>,</lemma>
            <CharacterOffsetBegin>62</CharacterOffsetBegin>
            <CharacterOffsetEnd>63</CharacterOffsetEnd>
            <POS>,</POS>
          </token>
          <token id="13">
            <word>we</word>
            <lemma>we</lemma>
            <CharacterOffsetBegin>64</CharacterOffsetBegin>
            <CharacterOffsetEnd>66</CharacterOffsetEnd>
            <POS>PRP</POS>
          </token>
          <token id="14">
            <word>have</word>
            <lemma>have</lemma>
            <CharacterOffsetBegin>67</CharacterOffsetBegin>
            <CharacterOffsetEnd>71</CharacterOffsetEnd>
            <POS>VBP</POS>
          </token>
          <token id="15">
            <word>a</word>
            <lemma>a</lemma>
            <CharacterOffsetBegin>72</CharacterOffsetBegin>
            <CharacterOffsetEnd>73</CharacterOffsetEnd>
            <POS>DT</POS>
          </token>
          <token id="16">
            <word>backlog</word>
            <lemma>backlog</lemma>
            <CharacterOffsetBegin>74</CharacterOffsetBegin>
            <CharacterOffsetEnd>81</CharacterOffsetEnd>
            <POS>NN</POS>
          </token>
          <token id="17">
            <word>which</word>
            <lemma>which</lemma>
            <CharacterOffsetBegin>82</CharacterOffsetBegin>
            <CharacterOffsetEnd>87</CharacterOffsetEnd>
            <POS>WDT</POS>
          </token>
          <token id="18">
            <word>has</word>
            <lemma>have</lemma>
            <CharacterOffsetBegin>88</CharacterOffsetBegin>
            <CharacterOffsetEnd>91</CharacterOffsetEnd>
            <POS>VBZ</POS>
          </token>
          <token id="19">
            <word>accumulated</word>
            <lemma>accumulate</lemma>
            <CharacterOffsetBegin>92</CharacterOffsetBegin>
            <CharacterOffsetEnd>103</CharacterOffsetEnd>
            <POS>VBN</POS>
          </token>
          <token id="20">
            <word>over</word>
            <lemma>over</lemma>
            <CharacterOffsetBegin>104</CharacterOffsetBegin>
            <CharacterOffsetEnd>108</CharacterOffsetEnd>
            <POS>IN</POS>
          </token>
          <token id="21">
            <word>many</word>
            <lemma>many</lemma>
            <CharacterOffsetBegin>109</CharacterOffsetBegin>
            <CharacterOffsetEnd>113</CharacterOffsetEnd>
            <POS>JJ</POS>
          </token>
          <token id="22">
            <word>years</word>
            <lemma>year</lemma>
            <CharacterOffsetBegin>114</CharacterOffsetBegin>
            <CharacterOffsetEnd>119</CharacterOffsetEnd>
            <POS>NNS</POS>
          </token>
          <token id="23">
            <word>of</word>
            <lemma>of</lemma>
            <CharacterOffsetBegin>120</CharacterOffsetBegin>
            <CharacterOffsetEnd>122</CharacterOffsetEnd>
            <POS>IN</POS>
          </token>
          <token id="24">
            <word>budgets</word>
            <lemma>budget</lemma>
            <CharacterOffsetBegin>123</CharacterOffsetBegin>
            <CharacterOffsetEnd>130</CharacterOffsetEnd>
            <POS>NNS</POS>
          </token>
          <token id="25">
            <word>.</word>
            <lemma>.</lemma>
            <CharacterOffsetBegin>130</CharacterOffsetBegin>
            <CharacterOffsetEnd>131</CharacterOffsetEnd>
            <POS>.</POS>
          </token>
        </tokens>
        <parse>(ROOT (S (PP (IN For) (NP (NN example))) (, ,) (PP (IN with) (S (VP (NN regard) (PP (TO to) (NP (PRP$ our) (NN aid))) (PP (TO to) (NP (JJ Mediterranean) (NNS countries)))))) (, ,) (NP (PRP we)) (VP (VBP have) (NP (NP (DT a) (NN backlog)) (SBAR (WHNP (WDT which)) (S (VP (VBZ has) (VP (VBN accumulated) (PP (IN over) (NP (NP (JJ many) (NNS years)) (PP (IN of) (NP (NNS budgets))))))))))) (. .))) </parse>
        <dependencies type="basic-dependencies">
          <dep type="root">
            <governor idx="0">ROOT</governor>
            <dependent idx="14">have</dependent>
          </dep>
          <dep type="prep">
            <governor idx="14">have</governor>
            <dependent idx="1">For</dependent>
          </dep>
          <dep type="pobj">
            <governor idx="1">For</governor>
            <dependent idx="2">example</dependent>
          </dep>
          <dep type="prep">
            <governor idx="14">have</governor>
            <dependent idx="4">with</dependent>
          </dep>
          <dep type="pcomp">
            <governor idx="4">with</governor>
            <dependent idx="5">regard</dependent>
          </dep>
          <dep type="prep">
            <governor idx="5">regard</governor>
            <dependent idx="6">to</dependent>
          </dep>
          <dep type="poss">
            <governor idx="8">aid</governor>
            <dependent idx="7">our</dependent>
          </dep>
          <dep type="pobj">
            <governor idx="6">to</governor>
            <dependent idx="8">aid</dependent>
          </dep>
          <dep type="prep">
            <governor idx="5">regard</governor>
            <dependent idx="9">to</dependent>
          </dep>
          <dep type="amod">
            <governor idx="11">countries</governor>
            <dependent idx="10">Mediterranean</dependent>
          </dep>
          <dep type="pobj">
            <governor idx="9">to</governor>
            <dependent idx="11">countries</dependent>
          </dep>
          <dep type="nsubj">
            <governor idx="14">have</governor>
            <dependent idx="13">we</dependent>
          </dep>
          <dep type="det">
            <governor idx="16">backlog</governor>
            <dependent idx="15">a</dependent>
          </dep>
          <dep type="dobj">
            <governor idx="14">have</governor>
            <dependent idx="16">backlog</dependent>
          </dep>
          <dep type="nsubj">
            <governor idx="19">accumulated</governor>
            <dependent idx="17">which</dependent>
          </dep>
          <dep type="aux">
            <governor idx="19">accumulated</governor>
            <dependent idx="18">has</dependent>
          </dep>
          <dep type="rcmod">
            <governor idx="16">backlog</governor>
            <dependent idx="19">accumulated</dependent>
          </dep>
          <dep type="prep">
            <governor idx="19">accumulated</governor>
            <dependent idx="20">over</dependent>
          </dep>
          <dep type="amod">
            <governor idx="22">years</governor>
            <dependent idx="21">many</dependent>
          </dep>
          <dep type="pobj">
            <governor idx="20">over</governor>
            <dependent idx="22">years</dependent>
          </dep>
          <dep type="prep">
            <governor idx="22">years</governor>
            <dependent idx="23">of</dependent>
          </dep>
          <dep type="pobj">
            <governor idx="23">of</governor>
            <dependent idx="24">budgets</dependent>
          </dep>
        </dependencies>
        <dependencies type="collapsed-dependencies">
          <dep type="root">
            <governor idx="0">ROOT</governor>
            <dependent idx="14">have</dependent>
          </dep>
          <dep type="prep_for">
            <governor idx="14">have</governor>
            <dependent idx="2">example</dependent>
          </dep>
          <dep type="poss">
            <governor idx="8">aid</governor>
            <dependent idx="7">our</dependent>
          </dep>
          <dep type="prep_with_regard_to">
            <governor idx="14">have</governor>
            <dependent idx="8">aid</dependent>
          </dep>
          <dep type="amod">
            <governor idx="11">countries</governor>
            <dependent idx="10">Mediterranean</dependent>
          </dep>
          <dep type="prep_to">
            <governor idx="14">have</governor>
            <dependent idx="11">countries</dependent>
          </dep>
          <dep type="nsubj">
            <governor idx="14">have</governor>
            <dependent idx="13">we</dependent>
          </dep>
          <dep type="det">
            <governor idx="16">backlog</governor>
            <dependent idx="15">a</dependent>
          </dep>
          <dep type="dobj">
            <governor idx="14">have</governor>
            <dependent idx="16">backlog</dependent>
          </dep>
          <dep type="nsubj">
            <governor idx="19">accumulated</governor>
            <dependent idx="17">which</dependent>
          </dep>
          <dep type="aux">
            <governor idx="19">accumulated</governor>
            <dependent idx="18">has</dependent>
          </dep>
          <dep type="rcmod">
            <governor idx="16">backlog</governor>
            <dependent idx="19">accumulated</dependent>
          </dep>
          <dep type="amod">
            <governor idx="22">years</governor>
            <dependent idx="21">many</dependent>
          </dep>
          <dep type="prep_over">
            <governor idx="19">accumulated</governor>
            <dependent idx="22">years</dependent>
          </dep>
          <dep type="prep_of">
            <governor idx="22">years</governor>
            <dependent idx="24">budgets</dependent>
          </dep>
        </dependencies>
        <dependencies type="collapsed-ccprocessed-dependencies">
          <dep type="root">
            <governor idx="0">ROOT</governor>
            <dependent idx="14">have</dependent>
          </dep>
          <dep type="prep_for">
            <governor idx="14">have</governor>
            <dependent idx="2">example</dependent>
          </dep>
          <dep type="poss">
            <governor idx="8">aid</governor>
            <dependent idx="7">our</dependent>
          </dep>
          <dep type="prep_with_regard_to">
            <governor idx="14">have</governor>
            <dependent idx="8">aid</dependent>
          </dep>
          <dep type="amod">
            <governor idx="11">countries</governor>
            <dependent idx="10">Mediterranean</dependent>
          </dep>
          <dep type="prep_to">
            <governor idx="14">have</governor>
            <dependent idx="11">countries</dependent>
          </dep>
          <dep type="nsubj">
            <governor idx="14">have</governor>
            <dependent idx="13">we</dependent>
          </dep>
          <dep type="det">
            <governor idx="16">backlog</governor>
            <dependent idx="15">a</dependent>
          </dep>
          <dep type="dobj">
            <governor idx="14">have</governor>
            <dependent idx="16">backlog</dependent>
          </dep>
          <dep type="nsubj">
            <governor idx="19">accumulated</governor>
            <dependent idx="17">which</dependent>
          </dep>
          <dep type="aux">
            <governor idx="19">accumulated</governor>
            <dependent idx="18">has</dependent>
          </dep>
          <dep type="rcmod">
            <governor idx="16">backlog</governor>
            <dependent idx="19">accumulated</dependent>
          </dep>
          <dep type="amod">
            <governor idx="22">years</governor>
            <dependent idx="21">many</dependent>
          </dep>
          <dep type="prep_over">
            <governor idx="19">accumulated</governor>
            <dependent idx="22">years</dependent>
          </dep>
          <dep type="prep_of">
            <governor idx="22">years</governor>
            <dependent idx="24">budgets</dependent>
          </dep>
        </dependencies>
      </sentence>
      <sentence id="2">
        <tokens>
          <token id="1">
            <word>hot</word>
            <lemma>hot</lemma>
            <CharacterOffsetBegin>132</CharacterOffsetBegin>
            <CharacterOffsetEnd>135</CharacterOffsetEnd>
            <POS>JJ</POS>
          </token>
          <token id="2">
            <word>countries</word>
            <lemma>country</lemma>
            <CharacterOffsetBegin>136</CharacterOffsetBegin>
            <CharacterOffsetEnd>145</CharacterOffsetEnd>
            <POS>NNS</POS>
          </token>
          <token id="3">
            <word>with</word>
            <lemma>with</lemma>
            <CharacterOffsetBegin>146</CharacterOffsetBegin>
            <CharacterOffsetEnd>150</CharacterOffsetEnd>
            <POS>IN</POS>
          </token>
          <token id="4">
            <word>bad</word>
            <lemma>bad</lemma>
            <CharacterOffsetBegin>151</CharacterOffsetBegin>
            <CharacterOffsetEnd>154</CharacterOffsetEnd>
            <POS>JJ</POS>
          </token>
          <token id="5">
            <word>budgeting</word>
            <lemma>budgeting</lemma>
            <CharacterOffsetBegin>155</CharacterOffsetBegin>
            <CharacterOffsetEnd>164</CharacterOffsetEnd>
            <POS>NN</POS>
          </token>
        </tokens>
        <parse>(ROOT (NP (NP (JJ hot) (NNS countries)) (PP (IN with) (NP (JJ bad) (NN budgeting))))) </parse>
        <dependencies type="basic-dependencies">
          <dep type="root">
            <governor idx="0">ROOT</governor>
            <dependent idx="2">countries</dependent>
          </dep>
          <dep type="amod">
            <governor idx="2">countries</governor>
            <dependent idx="1">hot</dependent>
          </dep>
          <dep type="prep">
            <governor idx="2">countries</governor>
            <dependent idx="3">with</dependent>
          </dep>
          <dep type="amod">
            <governor idx="5">budgeting</governor>
            <dependent idx="4">bad</dependent>
          </dep>
          <dep type="pobj">
            <governor idx="3">with</governor>
            <dependent idx="5">budgeting</dependent>
          </dep>
        </dependencies>
        <dependencies type="collapsed-dependencies">
          <dep type="root">
            <governor idx="0">ROOT</governor>
            <dependent idx="2">countries</dependent>
          </dep>
          <dep type="amod">
            <governor idx="2">countries</governor>
            <dependent idx="1">hot</dependent>
          </dep>
          <dep type="amod">
            <governor idx="5">budgeting</governor>
            <dependent idx="4">bad</dependent>
          </dep>
          <dep type="prep_with">
            <governor idx="2">countries</governor>
            <dependent idx="5">budgeting</dependent>
          </dep>
        </dependencies>
        <dependencies type="collapsed-ccprocessed-dependencies">
          <dep type="root">
            <governor idx="0">ROOT</governor>
            <dependent idx="2">countries</dependent>
          </dep>
          <dep type="amod">
            <governor idx="2">countries</governor>
            <dependent idx="1">hot</dependent>
          </dep>
          <dep type="amod">
            <governor idx="5">budgeting</governor>
            <dependent idx="4">bad</dependent>
          </dep>
          <dep type="prep_with">
            <governor idx="2">countries</governor>
            <dependent idx="5">budgeting</dependent>
          </dep>
        </dependencies>
      </sentence>
    </sentences>
  </document>
</root>


text:
class CreateVotes < ActiveRecord::Migration[5.0]
  def change
    create_table :votes do |t|
      t.references :user, foreign_key: true
      t.references :rental, foreign_key: true
      t.integer :vote

      t.timestamps
    end
  end
end


text:
#include <UnitTest++/UnitTest++.h>

#include <vector>
#include <array>
#include <algorithm>

#include "../vector.h"

namespace
{
  SUITE(test_vector)
  {
    static const size_t SIZE = 10;

    typedef etl::vector<int, SIZE>  Data;
    typedef std::vector<int>        Compare_Data;

    Compare_Data initial_data;
    Compare_Data less_data;
    Compare_Data greater_data;
    Compare_Data shorter_data;
    Compare_Data different_data;
    Compare_Data insert_data;

    //*************************************************************************
    struct SetupFixture
    {
      SetupFixture()
      {
        int n[]         = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
        int n_insert[]  = { 11, 12, 13 };
        int n_less[]    = { 0, 1, 2, 3, 3, 5, 6, 7, 8, 9 };
        int n_greater[] = { 0, 1, 2, 4, 4, 5, 6, 7, 8, 9 };

        initial_data.assign(std::begin(n), std::end(n));
        insert_data.assign(std::begin(n_insert), std::end(n_insert));
        less_data.assign(std::begin(n_less), std::end(n_less));
        greater_data.assign(std::begin(n_greater), std::end(n_greater));
        shorter_data.assign(std::begin(n_greater), std::end(n_greater) - 1);
        different_data.assign(initial_data.rbegin(), initial_data.rend());
      }
    };

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_default_constructor)
    {
      Data data;

      CHECK_EQUAL(data.size(), size_t(0));
      CHECK(data.empty());
      CHECK_EQUAL(data.capacity(), SIZE);
      CHECK_EQUAL(data.max_size(), SIZE);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_constructor_size)
    {
      const size_t INITIAL_SIZE = 5;
      Data data(INITIAL_SIZE);

      CHECK(data.size() == INITIAL_SIZE);
      CHECK(!data.empty());
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_constructor_size_value)
    {
      const size_t INITIAL_SIZE = 5;
      const int INITIAL_VALUE = 1;

      std::array<int, INITIAL_SIZE> compare_data;
      compare_data.fill(INITIAL_VALUE);

      Data data(INITIAL_SIZE, INITIAL_VALUE);

      CHECK(data.size() == INITIAL_SIZE);
      CHECK(!data.empty());

      bool is_equal = std::equal(data.begin(),
                                data.end(),
                                compare_data.begin());

      CHECK(is_equal);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_constructor_size_excess)
    {
      CHECK_THROW(Data data(SIZE + 1), etl::vector_full);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_constructor_range)
    {
      Compare_Data compare_data(initial_data.begin(), initial_data.end());

      Data data(compare_data.begin(), compare_data.end());

      CHECK(data.size() == SIZE);
      CHECK(!data.empty());
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_assignment)
    {
      Data data(initial_data.begin(), initial_data.end());
      Data other_data;

      other_data = data;

      bool is_equal = std::equal(data.begin(),
                                data.end(),
                                other_data.begin());

      CHECK(is_equal);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_self_assignment)
    {
      Data data(initial_data.begin(), initial_data.end());
      Data other_data(data);

      other_data = other_data;

      bool is_equal = std::equal(data.begin(),
                                data.end(),
                                other_data.begin());

      CHECK(is_equal);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_begin)
    {
      Data data(10);
      const Data constData(10);

      CHECK_EQUAL(&data[0], data.begin());
      CHECK_EQUAL(&constData[0], constData.begin());
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_end)
    {
      Data data(10);
      const Data constData(10);

      CHECK_EQUAL(&data[10], data.end());
      CHECK_EQUAL(&constData[10], constData.end());
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_resize_up)
    {
      const size_t INITIAL_SIZE = 5;
      const size_t NEW_SIZE = 8;

      Data data(INITIAL_SIZE);
      data.resize(NEW_SIZE);

      CHECK_EQUAL(data.size(), NEW_SIZE);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_resize_up_value)
    {
      const size_t INITIAL_SIZE = 5;
      const size_t NEW_SIZE = 8;
      const int INITIAL_VALUE = 1;

      Data data(INITIAL_SIZE, INITIAL_VALUE);
      data.resize(NEW_SIZE, INITIAL_VALUE);

      std::array<int, NEW_SIZE> compare_data;
      compare_data.fill(INITIAL_VALUE);

      bool is_equal = std::equal(data.begin(), data.end(), compare_data.begin());

      CHECK(is_equal);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_resize_excess)
    {
      const size_t INITIAL_SIZE = 5;
      const size_t NEW_SIZE = SIZE + 1;

      Data data(INITIAL_SIZE);

      CHECK_THROW(data.resize(NEW_SIZE), etl::vector_full);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_resize_down)
    {
      const size_t INITIAL_SIZE = 5;
      const size_t NEW_SIZE = 2;

      Data data(INITIAL_SIZE);
      data.resize(NEW_SIZE);

      CHECK_EQUAL(data.size(), NEW_SIZE);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_empty)
    {
      Data data;
      data.resize(data.max_size());

      CHECK(data.full());
      CHECK(!data.empty());
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_full)
    {
      Data data;

      CHECK(!data.full());
      CHECK(data.empty());
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_index)
    {
      Compare_Data compare_data(initial_data.begin(), initial_data.end());

      Data data(compare_data.begin(), compare_data.end());

      for (size_t i = 0; i < data.size(); ++i)
      {
        CHECK_EQUAL(data[i], compare_data[i]);
      }
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_index_const)
    {
      const Compare_Data compare_data(initial_data.begin(), initial_data.end());

      const Data data(compare_data.begin(), compare_data.end());

      for (size_t i = 0; i < data.size(); ++i)
      {
        CHECK_EQUAL(data[i], compare_data[i]);
      }
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_at)
    {
      Compare_Data compare_data(initial_data.begin(), initial_data.end());
      Data data(initial_data.begin(), initial_data.end());

      for (size_t i = 0; i < data.size(); ++i)
      {
        CHECK_EQUAL(data.at(i), compare_data.at(i));
      }

      CHECK_THROW(data.at(data.size()), etl::vector_out_of_bounds);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_at_const)
    {
      const Compare_Data compare_data(initial_data.begin(), initial_data.end());
      const Data data(initial_data.begin(), initial_data.end());

      for (size_t i = 0; i < data.size(); ++i)
      {
        CHECK_EQUAL(data.at(i), compare_data.at(i));
      }

      CHECK_THROW(data.at(data.size()), etl::vector_out_of_bounds);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_front)
    {
      Compare_Data compare_data(initial_data.begin(), initial_data.end());
      Data data(initial_data.begin(), initial_data.end());

      CHECK(data.front() == compare_data.front());
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_front_const)
    {
      const Compare_Data compare_data(initial_data.begin(), initial_data.end());
      const Data data(initial_data.begin(), initial_data.end());

      CHECK(data.front() == compare_data.front());
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_back)
    {
      Compare_Data compare_data(initial_data.begin(), initial_data.end());
      Data data(initial_data.begin(), initial_data.end());

      CHECK(data.back() == compare_data.back());
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_back_const)
    {
      const Compare_Data compare_data(initial_data.begin(), initial_data.end());
      const Data data(initial_data.begin(), initial_data.end());

      CHECK(data.back() == compare_data.back());
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_data)
    {
      Compare_Data compare_data(initial_data.begin(), initial_data.end());

      Data data(compare_data.begin(), compare_data.end());

      bool is_equal = std::equal(data.data(),
        data.data() + data.size(),
        compare_data.begin());

      CHECK(is_equal);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_data_const)
    {
      Compare_Data compare_data(initial_data.begin(), initial_data.end());

      const Data data(compare_data.begin(), compare_data.end());

      bool is_equal = std::equal(data.data(),
                                data.data() + data.size(),
                                compare_data.begin());

      CHECK(is_equal);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_assign_range)
    {
      Compare_Data compare_data(initial_data.begin(), initial_data.end());

      Data data;

      data.assign(compare_data.begin(), compare_data.end());

      bool is_equal = std::equal(data.begin(),
                                data.end(),
                                compare_data.begin());

      CHECK(is_equal);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_assign_size_value)
    {
      const size_t INITIAL_SIZE = 5;
      const int INITIAL_VALUE = 1;
      std::array<int, INITIAL_SIZE> compare_data;
      compare_data.fill(INITIAL_VALUE);

      Data data;
      data.assign(INITIAL_SIZE, INITIAL_VALUE);

      bool is_equal = std::equal(data.begin(),
                                data.end(),
                                compare_data.begin());

      CHECK(is_equal);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_assign_size_value_excess)
    {
      const size_t INITIAL_SIZE = SIZE;
      const size_t EXCESS_SIZE = SIZE + 1;
      const int INITIAL_VALUE = 1;
      std::array<int, INITIAL_SIZE> compare_data;
      compare_data.fill(INITIAL_VALUE);

      Data data;

      CHECK_THROW(data.assign(EXCESS_SIZE, INITIAL_VALUE), etl::vector_full);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_push_back)
    {
      Compare_Data compare_data;
      Data data;

      for (size_t i = 0; i < SIZE; ++i)
      {
        compare_data.push_back(i);
      }

      for (size_t i = 0; i < SIZE; ++i)
      {
        data.push_back(i);
      }

      bool is_equal = std::equal(data.begin(),
                                data.end(),
                                compare_data.begin());

      CHECK(is_equal);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_push_back_null)
    {
      Compare_Data compare_data;
      Data data;

      compare_data.push_back(1);

      data.push_back();
      data[0] = 1;

      bool is_equal = std::equal(data.begin(),
                                data.end(),
                                compare_data.begin());

      CHECK(is_equal);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_push_back_excess)
    {
      Data data;

      for (size_t i = 0; i < SIZE; ++i)
      {
        data.push_back(i);
      }

      CHECK_THROW(data.push_back(SIZE), etl::vector_full);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_pop_back)
    {
      Compare_Data compare_data(initial_data.begin(), initial_data.end());
      Data data(initial_data.begin(), initial_data.end());

      compare_data.pop_back();
      compare_data.pop_back();

      data.pop_back();
      data.pop_back();

      bool is_equal = std::equal(data.begin(),
                                data.end(),
                                compare_data.begin());

      CHECK(is_equal);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_insert_position_value)
    {
      const size_t INITIAL_SIZE = 5;
      const int INITIAL_VALUE   = 1;

      for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset)
      {
        Compare_Data compare_data;
        Data data;

        data.assign(initial_data.begin(), initial_data.begin() + INITIAL_SIZE);
        compare_data.assign(initial_data.begin(), initial_data.begin() + INITIAL_SIZE);

        data.insert(data.begin() + offset, INITIAL_VALUE);
        compare_data.insert(compare_data.begin() + offset, INITIAL_VALUE);

        bool is_equal = std::equal(data.begin(),
                                   data.end(),
                                  compare_data.begin());

        CHECK(is_equal);
      }
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_insert_position_value_excess)
    {
      const size_t INITIAL_SIZE     = SIZE;
      const int INITIAL_VALUE       = 1;
      const int UNINITIALISED_VALUE = -1;

      Data data(INITIAL_SIZE, INITIAL_VALUE);

      size_t offset = 2;

      CHECK_THROW(data.insert(data.begin() + offset, INITIAL_VALUE), etl::vector_full);

      offset = 0;

      CHECK_THROW(data.insert(data.begin() + offset, INITIAL_VALUE), etl::vector_full);

      offset = data.size();

      CHECK_THROW(data.insert(data.begin() + offset, INITIAL_VALUE), etl::vector_full);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_insert_position_n_value)
    {
      const size_t INITIAL_SIZE     = 5;
      const size_t INSERT_SIZE      = 3;
      const int INITIAL_VALUE       = 11;

      for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset)
      {
        Compare_Data compare_data;
        Data data;

        data.assign(initial_data.begin(), initial_data.begin() + INITIAL_SIZE);
        compare_data.assign(initial_data.begin(), initial_data.begin() + INITIAL_SIZE);
        data.insert(data.begin() + offset, INSERT_SIZE, INITIAL_VALUE);
        compare_data.insert(compare_data.begin() + offset, INSERT_SIZE, INITIAL_VALUE);

        bool is_equal = std::equal(data.begin(),
                                   data.end(),
                                   compare_data.begin());

        CHECK(is_equal);
      }
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_insert_position_n_value_excess)
    {
      const size_t INITIAL_SIZE = SIZE;
      const size_t INSERT_SIZE  = 4;
      const int INITIAL_VALUE   = 1;

      Data data(INITIAL_SIZE, INITIAL_VALUE);

      size_t offset = 0;

      CHECK_THROW(data.insert(data.begin() + offset, INSERT_SIZE, INITIAL_VALUE), etl::vector_full);

      offset = 2;

      CHECK_THROW(data.insert(data.begin() + offset, INSERT_SIZE, INITIAL_VALUE), etl::vector_full);

      offset = 4;

      CHECK_THROW(data.insert(data.begin() + offset, INSERT_SIZE, INITIAL_VALUE), etl::vector_full);

      offset = data.size();

      CHECK_THROW(data.insert(data.begin() + offset, INSERT_SIZE, INITIAL_VALUE), etl::vector_full);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_insert_position_range)
    {
      const size_t INITIAL_SIZE = 5;
      const int INITIAL_VALUE   = 1;

      for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset)
      {
        Compare_Data compare_data;
        Data data;

        data.assign(initial_data.begin(), initial_data.begin() + INITIAL_SIZE);
        compare_data.assign(initial_data.begin(), initial_data.begin() + INITIAL_SIZE);
        data.insert(data.begin() + offset, insert_data.begin(), insert_data.end());
        compare_data.insert(compare_data.begin() + offset, insert_data.begin(), insert_data.end());

        bool is_equal = std::equal(data.begin(),
                                   data.end(),
                                   compare_data.begin());

        CHECK(is_equal);
      }
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_insert_position_range_excess)
    {
      const size_t INITIAL_SIZE = 5;
      const int INITIAL_VALUE   = 1;

      Data data(INITIAL_SIZE, INITIAL_VALUE);

      size_t offset = 0;

      CHECK_THROW(data.insert(data.begin() + offset, initial_data.begin(), initial_data.end()), etl::vector_full);

      offset = 2;

      CHECK_THROW(data.insert(data.begin() + offset, initial_data.begin(), initial_data.end()), etl::vector_full);

      offset = 4;

      CHECK_THROW(data.insert(data.begin() + offset, initial_data.begin(), initial_data.end()), etl::vector_full);

      offset = data.size();

      CHECK_THROW(data.insert(data.begin() + offset, initial_data.begin(), initial_data.end()), etl::vector_full);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_erase_single)
    {
      Compare_Data compare_data(initial_data.begin(), initial_data.end());
      Data data(initial_data.begin(), initial_data.end());

      compare_data.erase(compare_data.begin() + 2);

      data.erase(data.begin() + 2);

      bool is_equal = std::equal(data.begin(),
                                data.end(),
                                compare_data.begin());

      CHECK(is_equal);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_erase_range)
    {
      Compare_Data compare_data(initial_data.begin(), initial_data.end());
      Data data(initial_data.begin(), initial_data.end());

      compare_data.erase(compare_data.begin() + 2, compare_data.begin() + 4);

      data.erase(data.begin() + 2, data.begin() + 4);

      bool is_equal = std::equal(data.begin(),
                                data.end(),
                                compare_data.begin());

      CHECK(is_equal);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_clear)
    {
      Compare_Data compare_data(initial_data.begin(), initial_data.end());

      Data data(compare_data.begin(), compare_data.end());
      data.clear();

      CHECK_EQUAL(data.size(), size_t(0));
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_iterator)
    {
      Compare_Data compare_data(initial_data.begin(), initial_data.end());

      Data data(compare_data.begin(), compare_data.end());

      bool is_equal = std::equal(data.begin(),
                                data.end(),
                                compare_data.begin());

      CHECK(is_equal);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_const_iterator)
    {
      Compare_Data compare_data(initial_data.begin(), initial_data.end());

      Data data(compare_data.begin(), compare_data.end());

      bool is_equal = std::equal(data.cbegin(),
                                data.cend(),
                                compare_data.cbegin());

      CHECK(is_equal);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_reverse_iterator)
    {
      Compare_Data compare_data(initial_data.begin(), initial_data.end());

      Data data(compare_data.begin(), compare_data.end());

      bool is_equal = std::equal(data.rbegin(),
                                data.rend(),
                                compare_data.rbegin());

      CHECK(is_equal);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_const_reverse_iterator)
    {
      Compare_Data compare_data(initial_data.begin(), initial_data.end());

      Data data(compare_data.begin(), compare_data.end());

      bool is_equal = std::equal(data.crbegin(),
                                data.crend(),
                                compare_data.crbegin());

      CHECK(is_equal);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_equal)
    {
      const Data initial1(initial_data.begin(), initial_data.end());
      const Data initial2(initial_data.begin(), initial_data.end());

      CHECK(initial1 == initial2);

      const Data different(different_data.begin(), different_data.end());

      CHECK(!(initial1 == different));

      const Data shorter(shorter_data.begin(), shorter_data.end());

      CHECK(!(shorter == initial1));
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_not_equal)
    {
      const Data initial1(initial_data.begin(), initial_data.end());
      const Data initial2(initial_data.begin(), initial_data.end());

      CHECK(!(initial1 != initial2));

      const Data different(different_data.begin(), different_data.end());

      CHECK(initial1 != different);

      const Data shorter(shorter_data.begin(), shorter_data.end());

      CHECK(shorter != initial1);
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_less_than)
    {
      const Data less(less_data.begin(), less_data.end());
      const Data initial(initial_data.begin(), initial_data.end());

      CHECK((less < initial) == (less_data < initial_data));

      const Data greater(greater_data.begin(), greater_data.end());

      CHECK((greater < initial) == (greater_data < initial_data));

      const Data shorter(shorter_data.begin(), shorter_data.end());

      CHECK((shorter < initial) == (shorter_data < initial_data));
      CHECK((initial < shorter) == (initial_data < shorter_data));
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_less_than_or_equal)
    {
      const Data less(less_data.begin(), less_data.end());
      const Data initial(initial_data.begin(), initial_data.end());

      CHECK((less <= initial) == (less_data <= initial_data));

      const Data greater(greater_data.begin(), greater_data.end());

      CHECK((greater <= initial) == (greater_data <= initial_data));

      const Data shorter(shorter_data.begin(), shorter_data.end());

      CHECK((shorter <= initial) == (shorter_data <= initial_data));
      CHECK((initial <= shorter) == (initial_data <= shorter_data));

      const Data initial2(initial_data.begin(), initial_data.end());
      CHECK((initial <= initial2) == (initial_data <= initial_data));
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_greater_than)
    {
      const Data less(less_data.begin(), less_data.end());
      const Data initial(initial_data.begin(), initial_data.end());

      CHECK((less > initial) == (less_data > initial_data));

      const Data greater(greater_data.begin(), greater_data.end());

      CHECK((greater > initial) == (greater_data > initial_data));

      const Data shorter(shorter_data.begin(), shorter_data.end());

      CHECK((shorter > initial) == (shorter_data > initial_data));
      CHECK((initial > shorter) == (initial_data > shorter_data));
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_greater_than_or_equal)
    {
      const Data less(less_data.begin(), less_data.end());
      const Data initial(initial_data.begin(), initial_data.end());

      CHECK((less >= initial) == (less_data >= initial_data));

      const Data greater(greater_data.begin(), greater_data.end());

      CHECK((greater >= initial) == (greater_data >= initial_data));

      const Data shorter(shorter_data.begin(), shorter_data.end());

      CHECK((shorter >= initial) == (shorter_data >= initial_data));
      CHECK((initial >= shorter) == (initial_data > shorter_data));

      const Data initial2(initial_data.begin(), initial_data.end());
      CHECK((initial >= initial2) == (initial_data >= initial_data));
    }

    //*************************************************************************
    TEST_FIXTURE(SetupFixture, test_allocated_size)
    {
      const size_t INITIAL_SIZE = 5;

      Data data(INITIAL_SIZE);

      size_t a = sizeof(Data);
      size_t b = SIZE * sizeof(int);
      size_t c = sizeof(etl::vector_base);
      size_t d = sizeof(etl::ivector<int>);

      size_t expected_size = (SIZE * sizeof(int)) + (2 * sizeof(size_t)) + sizeof(int*);

      CHECK_EQUAL(expected_size, sizeof(Data));
    }
  };
}


text:
var chalk = require('chalk');
var fs = require('fs');
var path = require('path');
var readline = require('readline');

var APP_CONFIG_FILE_NAME = path.resolve(__dirname, '..', 'appConfig.json');

var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

console.log(
  chalk.blue('LitHub requires a GitHub access token in order to work.')
);
console.log(
  'Please generate the token via https://github.com/blog/1509-personal-api-tokens (don't choose any token permissions).'
);

rl.question('Then, paste the token here: ', accessToken => {
  fs.writeFileSync(
    APP_CONFIG_FILE_NAME,
    JSON.stringify(
      {
        accessToken: accessToken
      },
      null,
      2
    )
  );
  console.log('Written the token into the ' + APP_CONFIG_FILE_NAME + ' file');
  process.exit(0);
});


text:
class _const:
    class ConstError(TypeError): pass
    def __setattr__(self,name,value):
        if self.__dict__.has_key(name):
            raise self.ConstError, "Can't rebind const(%s)"%name
        self.__dict__[name]=value
import sys
sys.modules[__name__]=_const()

# that's all -- now any client-code can
import const
# and bind an attribute ONCE:
const.magic = 23
# but NOT re-bind it:
const.magic = 88      # raises const.ConstError
# you may also want to add the obvious __delattr__


text:
/*
 *
 *
 *
 */
package com.yhy.medicine.domain;

import java.util.Date;

import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;

/**
 * 链锁店管理表元模型类
 *
 * @author yhy
 * @version 2016-05-22
 * @----------------------------------------------------------------------------------------
 * @updated 修改描述.
 * @updated by yhy
 * @updated at 2016-05-22
 */
@StaticMetamodel(MedicineChain.class)
public class MedicineChain_ {

	public static volatile SingularAttribute<MedicineChain, String> id;
	public static volatile SingularAttribute<MedicineChain, String> creater;
	public static volatile SingularAttribute<MedicineChain, Date> created;
	public static volatile SingularAttribute<MedicineChain, String> modifier;
	public static volatile SingularAttribute<MedicineChain, Date> modified;
	public static volatile SingularAttribute<MedicineChain, Integer> version;
	public static volatile SingularAttribute<MedicineChain, Integer> deletion;
	public static volatile SingularAttribute<MedicineChain, Integer> history;
	public static volatile SingularAttribute<MedicineChain, String> memo;
	public static volatile SingularAttribute<MedicineChain, String> name;

}