text:
package org.codehaus.groovy.classgen.asm;

import java.util.HashMap;
import java.util.Map;

import org.codehaus.groovy.ast.ClassHelper;
import org.codehaus.groovy.ast.ClassNode;
import org.codehaus.groovy.ast.DynamicVariable;
import org.codehaus.groovy.ast.Variable;
import org.codehaus.groovy.ast.expr.BinaryExpression;
import org.codehaus.groovy.ast.expr.Expression;
import org.codehaus.groovy.ast.expr.PropertyExpression;
import org.codehaus.groovy.ast.expr.VariableExpression;
import org.codehaus.groovy.classgen.AsmClassGenerator;
import org.codehaus.groovy.runtime.BytecodeInterface8;

import static org.codehaus.groovy.ast.ClassHelper.*;
import static org.codehaus.groovy.syntax.Types.*;
import static org.codehaus.groovy.ast.tools.WideningCategories.*;

/**
 * This class is for internal use only!
 * This class will dispatch to the right type adapters according to the
 * kind of binary expression that is provided.
 * @author Jochen "blackdrag" Theodorou
 * @author Roshan Dawrani
 */
public class BinaryExpressionMultiTypeDispatcher extends BinaryExpressionHelper {

    private static class BinaryCharExpressionHelper extends BinaryIntExpressionHelper {
        public BinaryCharExpressionHelper(WriterController wc) {
            super(wc, charArraySet, charArrayGet);
        }
        private static final MethodCaller
            charArrayGet = MethodCaller.newStatic(BytecodeInterface8.class, "cArrayGet"),
            charArraySet = MethodCaller.newStatic(BytecodeInterface8.class, "cArraySet");
        @Override protected ClassNode getArrayGetResultType() { return ClassHelper.char_TYPE; }
    }

    private static class BinaryByteExpressionHelper extends BinaryIntExpressionHelper {
        public BinaryByteExpressionHelper(WriterController wc) {
            super(wc, byteArraySet, byteArrayGet);
        }
        private static final MethodCaller
            byteArrayGet = MethodCaller.newStatic(BytecodeInterface8.class, "bArrayGet"),
            byteArraySet = MethodCaller.newStatic(BytecodeInterface8.class, "bArraySet");
        @Override protected ClassNode getArrayGetResultType() { return ClassHelper.byte_TYPE; }
    }

    private static class BinaryShortExpressionHelper extends BinaryIntExpressionHelper {
        public BinaryShortExpressionHelper(WriterController wc) {
            super(wc, shortArraySet, shortArrayGet);
        }
        private static final MethodCaller
            shortArrayGet = MethodCaller.newStatic(BytecodeInterface8.class, "sArrayGet"),
            shortArraySet = MethodCaller.newStatic(BytecodeInterface8.class, "sArraySet");
        @Override protected ClassNode getArrayGetResultType() { return ClassHelper.short_TYPE; }
    }

    protected BinaryExpressionWriter[] binExpWriter = initializeDelegateHelpers();

    protected BinaryExpressionWriter[] initializeDelegateHelpers() {
        return new BinaryExpressionWriter[]{
                /* 0: dummy  */ new BinaryObjectExpressionHelper(getController()),
                /* 1: int    */ new BinaryIntExpressionHelper(getController()),
                /* 2: long   */ new BinaryLongExpressionHelper(getController()),
                /* 3: double */ new BinaryDoubleExpressionHelper(getController()),
                /* 4: char   */ new BinaryCharExpressionHelper(getController()),
                /* 5: byte   */ new BinaryByteExpressionHelper(getController()),
                /* 6: short  */ new BinaryShortExpressionHelper(getController()),
                /* 7: float  */ new BinaryFloatExpressionHelper(getController()),
                /* 8: bool   */ new BinaryBooleanExpressionHelper(getController()),
        };
    }

    public static Map<ClassNode,Integer> typeMap = new HashMap<ClassNode,Integer>(14);
    static {
        typeMap.put(int_TYPE,       1); typeMap.put(long_TYPE,          2);
        typeMap.put(double_TYPE,    3); typeMap.put(char_TYPE,          4);
        typeMap.put(byte_TYPE,      5); typeMap.put(short_TYPE,         6);
        typeMap.put(float_TYPE,     7); typeMap.put(boolean_TYPE,       8);
    }
    public static final String[] typeMapKeyNames = {"dummy", "int", "long", "double", "char", "byte", "short", "float", "boolean"};

    public BinaryExpressionMultiTypeDispatcher(WriterController wc) {
        super(wc);
    }

    private int getOperandConversionType(ClassNode leftType, ClassNode rightType) {
        if (isIntCategory(leftType) && isIntCategory(rightType)) return 1;
        if (isLongCategory(leftType) && isLongCategory(rightType)) return 2;
        if (isBigDecCategory(leftType) && isBigDecCategory(rightType)) return 0;
        if (isDoubleCategory(leftType) && isDoubleCategory(rightType)) return 3;
        return 0;
    }

    protected int getOperandType(ClassNode type) {
        Integer ret = typeMap.get(type);
        if (ret==null) return 0;
        return ret;
    }

    @Deprecated
    protected boolean doPrimtiveCompare(ClassNode leftType, ClassNode rightType, BinaryExpression binExp) {
        return doPrimitiveCompare(leftType, rightType, binExp);
    }

    protected boolean doPrimitiveCompare(ClassNode leftType, ClassNode rightType, BinaryExpression binExp) {
        Expression leftExp = binExp.getLeftExpression();
        Expression rightExp = binExp.getRightExpression();
        int operation = binExp.getOperation().getType();

        int operationType = getOperandConversionType(leftType,rightType);
        BinaryExpressionWriter bew = binExpWriter[operationType];

        if (!bew.write(operation, true)) return false;

        AsmClassGenerator acg = getController().getAcg();
        OperandStack os = getController().getOperandStack();
        leftExp.visit(acg);
        os.doGroovyCast(bew.getNormalOpResultType());
        rightExp.visit(acg);
        os.doGroovyCast(bew.getNormalOpResultType());
        bew.write(operation, false);

        return true;
    }

    @Override
    protected void evaluateCompareExpression(final MethodCaller compareMethod, BinaryExpression binExp) {
        ClassNode current =  getController().getClassNode();
        TypeChooser typeChooser = getController().getTypeChooser();
        int operation = binExp.getOperation().getType();

        Expression leftExp = binExp.getLeftExpression();
        ClassNode leftType = typeChooser.resolveType(leftExp, current);
        Expression rightExp = binExp.getRightExpression();
        ClassNode rightType = typeChooser.resolveType(rightExp, current);

        if (!doPrimitiveCompare(leftType, rightType, binExp)) {
            super.evaluateCompareExpression(compareMethod, binExp);
        }
    }

    @Override
    protected void evaluateBinaryExpression(final String message, BinaryExpression binExp) {
        int operation = removeAssignment(binExp.getOperation().getType());
        ClassNode current =  getController().getClassNode();

        Expression leftExp = binExp.getLeftExpression();
        ClassNode leftTypeOrig = getController().getTypeChooser().resolveType(leftExp, current);
        ClassNode leftType = leftTypeOrig;
        Expression rightExp = binExp.getRightExpression();
        ClassNode rightType = getController().getTypeChooser().resolveType(rightExp, current);

        AsmClassGenerator acg = getController().getAcg();
        OperandStack os = getController().getOperandStack();

        if (operation==LEFT_SQUARE_BRACKET) {
            leftType = leftTypeOrig.getComponentType();
            int operationType = getOperandType(leftType);
            BinaryExpressionWriter bew = binExpWriter[operationType];
            if (    leftTypeOrig.isArray() && isIntCastableType(rightExp) &&
                    bew.arrayGet(operation, true))
            {
                leftExp.visit(acg);
                os.doGroovyCast(leftTypeOrig);
                rightExp.visit(acg);
                os.doGroovyCast(int_TYPE);
                bew.arrayGet(operation, false);
                os.replace(bew.getArrayGetResultType(),2);
            } else {
                super.evaluateBinaryExpression(message, binExp);
            }
        } else if (operation == DIVIDE) {
            int operationType = getOperandType(getController().getTypeChooser().resolveType(binExp, current));
            BinaryExpressionWriter bew = binExpWriter[operationType];
            if (bew.writeDivision(true)) {
                leftExp.visit(acg);
                os.doGroovyCast(bew.getDevisionOpResultType());
                rightExp.visit(acg);
                os.doGroovyCast(bew.getDevisionOpResultType());
                bew.writeDivision(false);
            } else {
                super.evaluateBinaryExpression(message, binExp);
            }
        } else {
            int operationType = getOperandConversionType(leftType,rightType);
            BinaryExpressionWriter bew = binExpWriter[operationType];

            if ( isShiftOperation(operation) && isIntCastableType(rightExp) &&
                 bew.write(operation, true))
            {
                leftExp.visit(acg);
                os.doGroovyCast(bew.getNormalOpResultType());
                rightExp.visit(acg);
                os.doGroovyCast(int_TYPE);
                bew.write(operation, false);
            } else if (bew.write(operation, true)) {
                leftExp.visit(acg);
                os.doGroovyCast(bew.getNormalOpResultType());
                rightExp.visit(acg);
                os.doGroovyCast(bew.getNormalOpResultType());
                bew.write(operation, false);
            } else {
                super.evaluateBinaryExpression(message, binExp);
            }
        }
    }

    private boolean isIntCastableType(Expression rightExp) {
        ClassNode type = getController().getTypeChooser().resolveType(rightExp, getController().getClassNode());
        return isNumberCategory(type);
    }

    private boolean isShiftOperation(int operation) {
        return  operation==LEFT_SHIFT   ||
                operation==RIGHT_SHIFT  ||
                operation==RIGHT_SHIFT_UNSIGNED;
    }

    private boolean isAssignmentToArray(BinaryExpression binExp) {
        Expression leftExpression = binExp.getLeftExpression();
        if (!(leftExpression instanceof BinaryExpression)) return false;
        BinaryExpression leftBinExpr = (BinaryExpression) leftExpression;
        if (leftBinExpr.getOperation().getType() != LEFT_SQUARE_BRACKET) return false;
        return true;
    }

    private int removeAssignment(int op) {
        switch (op) {
            case PLUS_EQUAL: return PLUS;
            case MINUS_EQUAL: return MINUS;
            case MULTIPLY_EQUAL: return MULTIPLY;
            case LEFT_SHIFT_EQUAL: return LEFT_SHIFT;
            case RIGHT_SHIFT_EQUAL: return RIGHT_SHIFT;
            case RIGHT_SHIFT_UNSIGNED_EQUAL: return RIGHT_SHIFT_UNSIGNED;
            case LOGICAL_OR_EQUAL: return LOGICAL_OR;
            case LOGICAL_AND_EQUAL: return LOGICAL_AND;
            case MOD_EQUAL: return MOD;
            case DIVIDE_EQUAL: return DIVIDE;
            case INTDIV_EQUAL: return INTDIV;
            case POWER_EQUAL: return POWER;
            case BITWISE_OR_EQUAL: return BITWISE_OR;
            case BITWISE_AND_EQUAL: return BITWISE_AND;
            case BITWISE_XOR_EQUAL: return BITWISE_XOR;
            default: return op;
        }
    }

    private boolean doAssignmentToArray(BinaryExpression binExp) {
        if (!isAssignmentToArray(binExp)) return false;
        // we need to handle only assignment to arrays combined with an operation
        // special here. e.g x[a] += b

        int operation = removeAssignment(binExp.getOperation().getType());
        ClassNode current =  getController().getClassNode();

        Expression leftExp = binExp.getLeftExpression();
        ClassNode leftType = getController().getTypeChooser().resolveType(leftExp, current);
        Expression rightExp = binExp.getRightExpression();
        ClassNode rightType = getController().getTypeChooser().resolveType(rightExp, current);

        int operationType = getOperandType(leftType);
        BinaryExpressionWriter bew = binExpWriter[operationType];

        boolean simulationSuccess = bew.arrayGet(LEFT_SQUARE_BRACKET, true);
        simulationSuccess = simulationSuccess && bew.write(operation, true);
        simulationSuccess = simulationSuccess && bew.arraySet(true);
        if (!simulationSuccess) return false;

        AsmClassGenerator acg = getController().getAcg();
        OperandStack operandStack = getController().getOperandStack();
        CompileStack compileStack = getController().getCompileStack();

        // for x[a] += b we have the structure:
        //   x = left(left(binExp))), b = right(binExp), a = right(left(binExp)))
        // for array set we need these values on stack: array, index, right
        // for array get we need these values on stack: array, index
        // to eval the expression we need x[a] = x[a]+b
        // -> arraySet(x,a, x[a]+b)
        // -> arraySet(x,a, arrayGet(x,a,b))
        // --> x,a, x,a, b as operands
        // --> load x, load a, DUP2, call arrayGet, load b, call operation,call arraySet
        // since we cannot DUP2 here easily we will save the subscript and DUP x
        // --> sub=a, load x, DUP, load sub, call arrayGet, load b, call operation, load sub, call arraySet

        BinaryExpression arrayWithSubscript = (BinaryExpression) leftExp;
        Expression subscript = arrayWithSubscript.getRightExpression();

        // load array index: sub=a [load x, DUP, load sub, call arrayGet, load b, call operation, load sub, call arraySet]
        subscript.visit(acg);
        operandStack.doGroovyCast(int_TYPE);
        int subscriptValueId = compileStack.defineTemporaryVariable("$sub", ClassHelper.int_TYPE, true);

        // load array: load x and DUP [load sub, call arrayGet, load b, call operation, load sub, call arraySet]
        arrayWithSubscript.getLeftExpression().visit(acg);
        operandStack.doGroovyCast(leftType.makeArray());
        operandStack.dup();

        // array get: load sub, call arrayGet [load b, call operation, load sub, call arraySet]
        operandStack.load(ClassHelper.int_TYPE, subscriptValueId);
        bew.arrayGet(LEFT_SQUARE_BRACKET, false);
        operandStack.replace(leftType, 2);

        // complete rhs: load b, call operation [load sub, call arraySet]
        binExp.getRightExpression().visit(acg);
        if (! (bew instanceof BinaryObjectExpressionHelper)) {
            // in primopts we convert to the left type for supported binary operations
            operandStack.doGroovyCast(leftType);
        }
        bew.write(operation, false);

        // let us save that value for the return
        operandStack.dup();
        int resultValueId = compileStack.defineTemporaryVariable("$result", rightType, true);

        // array set: load sub, call arraySet []
        operandStack.load(ClassHelper.int_TYPE, subscriptValueId);
        operandStack.swap();
        bew.arraySet(false);
        operandStack.remove(3); // 3 operands, the array, the index and the value!

        // load return value
        operandStack.load(rightType, resultValueId);

        // cleanup
        compileStack.removeVar(resultValueId);
        compileStack.removeVar(subscriptValueId);
        return true;
    }

    @Override
    protected void evaluateBinaryExpressionWithAssignment(String method, BinaryExpression binExp) {
        if (doAssignmentToArray(binExp)) return;
        if (doAssignmentToLocalVariable(method, binExp)) return;
        super.evaluateBinaryExpressionWithAssignment(method, binExp);
    }

    private boolean doAssignmentToLocalVariable(String method, BinaryExpression binExp) {
        Expression left = binExp.getLeftExpression();
        if (left instanceof VariableExpression) {
            VariableExpression ve = (VariableExpression) left;
            Variable v = ve.getAccessedVariable();
            if (v instanceof DynamicVariable) return false;
            if (v instanceof PropertyExpression) return false;
            /* field and declaration we don't return false */
        } else {
            return false;
        }

        evaluateBinaryExpression(method, binExp);
        getController().getOperandStack().dup();
        getController().getCompileStack().pushLHS(true);
        binExp.getLeftExpression().visit(getController().getAcg());
        getController().getCompileStack().popLHS();

        return true;
    }

    @Override
    protected void assignToArray(Expression orig, Expression receiver, Expression index, Expression rhsValueLoader) {
        ClassNode current = getController().getClassNode();
        ClassNode arrayType = getController().getTypeChooser().resolveType(receiver, current);
        ClassNode arrayComponentType = arrayType.getComponentType();
        int operationType = getOperandType(arrayComponentType);
        BinaryExpressionWriter bew = binExpWriter[operationType];
        AsmClassGenerator acg = getController().getAcg();

        if (bew.arraySet(true) && arrayType.isArray()) {
            OperandStack operandStack   =   getController().getOperandStack();

            // load the array
            receiver.visit(acg);
            operandStack.doGroovyCast(arrayType);

            // load index
            index.visit(acg);
            operandStack.doGroovyCast(int_TYPE);

            // load rhs
            rhsValueLoader.visit(acg);
            operandStack.doGroovyCast(arrayComponentType);

            // store value in array
            bew.arraySet(false);

            // load return value && correct operand stack stack
            operandStack.remove(3);
            rhsValueLoader.visit(acg);
        } else {
            super.assignToArray(orig, receiver, index, rhsValueLoader);
        }
    }

    @Override
    protected void writePostOrPrefixMethod(int op, String method,  Expression expression, Expression orig) {
        ClassNode type = getController().getTypeChooser().resolveType(orig, getController().getClassNode());
        int operationType = getOperandType(type);
        BinaryExpressionWriter bew = binExpWriter[operationType];
        if (bew.writePostOrPrefixMethod(op,true)) {
            OperandStack operandStack   =   getController().getOperandStack();
            // at this point the receiver will be already on the stack
            operandStack.doGroovyCast(type);
            bew.writePostOrPrefixMethod(op,false);
            operandStack.replace(bew.getNormalOpResultType());
        } else {
            super.writePostOrPrefixMethod(op, method, expression, orig);
        }
    }
}


text:
package play.learn.java.design.dirtyflag;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class DataFetcher {

	  private final String filename = "world.txt";
	  private long lastFetched;

	  public DataFetcher() {
	    this.lastFetched = -1;
	  }

	  private boolean isDirty(long fileLastModified) {
	    if (lastFetched != fileLastModified) {
	      lastFetched = fileLastModified;
	      return true;
	    }
	    return false;
	  }

	  /**
	   * Fetches data/content from raw file.
	   *
	   * @return List of strings
	   */
	  public List<String> fetch() {
	    ClassLoader classLoader = getClass().getClassLoader();
	    File file = new File(classLoader.getResource(filename).getFile());

	    if (isDirty(file.lastModified())) {
	      System.out.println(filename + " is dirty! Re-fetching file content...");

	      List<String> data = new ArrayList<String>();
	      try (BufferedReader br = new BufferedReader(new FileReader(file))) {
	        String line;
	        while ((line = br.readLine()) != null) {
	          data.add(line);
	        }
	      } catch (IOException e) {
	        e.printStackTrace();
	      }
	      return data;
	    }

	    return new ArrayList<String>();
	  }

}

redpajama_set_name: RedPajamaGithub


text:
#undef ICK_DEBUG

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <pthread.h>
#include <sys/time.h>

#include "ickutils.h"
#include "fifo.h"

/*=========================================================================*\
	Global symbols
\*=========================================================================*/
// none

/*=========================================================================*\
	Private symbols
\*=========================================================================*/
struct _fifo {
  char            *name;

  // Actual buffer
  size_t           size;
  char            *buffer;
  volatile char   *readp;          // pointer to next read
  volatile char   *writep;         // pointer to next write
  volatile bool    isFull;         // if readp==writep buffer is either empty or full
  volatile bool    isDraining;

  // Access arbitration
  size_t           lowWatermark;   // freeSize<lowWatermark  -> isWritable
  size_t           highWatermark;  // freeSize>highWatermark -> isReadable
  pthread_mutex_t  mutex;
  pthread_cond_t   condIsWritable;
  pthread_cond_t   condIsDrained;
  pthread_cond_t   condIsReadable;
};

#define FifoIsEmpty(fifo) ((fifo)->readp==(fifo)->writep)
#define FifoIsWritable(fifo) (fifoGetSize((fifo),FifoTotalUsed)<(fifo)->lowWatermark)
#define FifoIsReadable(fifo) (fifoGetSize((fifo),FifoTotalUsed)>(fifo)->highWatermark)

/*=========================================================================*\
      Create a ring buffer
        name is optional and might be NULL
        returns NULL on error
\*=========================================================================*/
Fifo *fifoCreate( const char *name, size_t size )
{
  Fifo                *fifo;

/*------------------------------------------------------------------------*\
    Allocate and init header
\*------------------------------------------------------------------------*/
  fifo = calloc( 1, sizeof(Fifo) );
  if( !fifo ) {
    logerr( "fifoCreate: out of memory!" );
    return NULL;
  }
  if( name ) {
    fifo->name = strdup( name );
    if( !fifo->name ) {
      Sfree( fifo );
      logerr( "fifoCreate: out of memory!" );
      return NULL;
    }
  }

/*------------------------------------------------------------------------*\
    Allocate buffer and init pointers
\*------------------------------------------------------------------------*/
  fifo->size          = size;
  fifo->lowWatermark  = size;
  fifo->highWatermark = 0;
  fifo->buffer = malloc( size );
  if( !fifo->buffer ) {
    Sfree( fifo->name );
    Sfree( fifo );
    logerr( "fifoCreate: out of memory!" );
    return NULL;
  }
  fifo->readp  = fifo->buffer;
  fifo->writep = fifo->buffer;
  fifo->isFull = false;

/*------------------------------------------------------------------------*\
    Init mutex and conditions
\*------------------------------------------------------------------------*/
  ickMutexInit( &fifo->mutex );
  pthread_cond_init( &fifo->condIsWritable, NULL );
  pthread_cond_init( &fifo->condIsDrained, NULL );
  pthread_cond_init( &fifo->condIsReadable, NULL );

/*------------------------------------------------------------------------*\
    That's all
\*------------------------------------------------------------------------*/
  DBGMSG( "Fifo \"%s\" initialized (%ld bytes): %p",
                     name?name:"<unknown>", (long)size, fifo );
  return fifo;
}

/*=========================================================================*\
      Free a ring buffer ressource
\*=========================================================================*/
void fifoDelete( Fifo *fifo )
{
  DBGMSG( "Fifo %p (%s, %ld bytes) freed", fifo,
                     fifo->name?fifo->name:"<unknown>", (long)fifo->size );

/*------------------------------------------------------------------------*\
    Delete mutex and conditions
\*------------------------------------------------------------------------*/
  pthread_mutex_destroy( &fifo->mutex );
  pthread_cond_destroy( &fifo->condIsWritable );
  pthread_cond_destroy( &fifo->condIsDrained );
  pthread_cond_destroy( &fifo->condIsReadable );

/*------------------------------------------------------------------------*\
    Free buffer, name (if any) and header
\*------------------------------------------------------------------------*/
  Sfree( fifo->buffer );
  Sfree( fifo->name );
  Sfree( fifo );
}

/*=========================================================================*\
      Reset fifo
\*=========================================================================*/
void fifoReset( Fifo *fifo )
{
  int perr;

  DBGMSG( "Fifo %p (%s, %ld bytes) reset", fifo,
                     fifo->name?fifo->name:"<unknown>", (long)fifo->size );

/*------------------------------------------------------------------------*\
    Lock fifo
\*------------------------------------------------------------------------*/
  perr = pthread_mutex_lock( &fifo->mutex );
  if( perr )
    logerr( "fifoReset: locking fifo mutex: %s", strerror(perr) );

/*------------------------------------------------------------------------*\
    reset pointers and state
\*------------------------------------------------------------------------*/
  fifo->readp  = fifo->buffer;
  fifo->writep = fifo->buffer;
  fifo->isFull = false;

/*------------------------------------------------------------------------*\
    Unlock fifo
\*------------------------------------------------------------------------*/
  perr = pthread_mutex_unlock( &fifo->mutex );
  if( perr )
    logerr( "fifoReset: unlocking fifo mutex: %s", strerror(perr) );
}

/*=========================================================================*\
      Lock fifo to avoid concurrent modifications
\*=========================================================================*/
void fifoLock( Fifo *fifo )
{
  int perr;
  DBGMSG( "Fifo (%p,%s): lock.", fifo, fifo->name?fifo->name:"<unknown>" );
  perr = pthread_mutex_lock( &fifo->mutex );
  if( perr )
    logerr( "fifoLock: %s", strerror(perr) );

}

/*=========================================================================*\
      Lock fifo and wait for writable (usedSize<lowWatermark) condition
        timeout is in ms, 0 or a negative values are treated as infinity
        bytes is minimum size required (might be 0)
        returns 0 and locks fifo, if condition is met
                std. errode (ETIMEDOUT in case of timeout) and no locking otherwise
\*=========================================================================*/
int fifoLockWaitWritable( Fifo *fifo, int timeout, size_t bytes )
{
  struct timeval  now;
  struct timespec abstime;
  int             err = 0;
  int             perr;

/*------------------------------------------------------------------------*\
    Check limit
\*------------------------------------------------------------------------*/
  if( bytes>fifo->size ) {
    logerr( "fifoLockWaitWritable: requested size (%ld) is larger then fifo (%ld).",
        bytes, fifo->size );
  }

/*------------------------------------------------------------------------*\
    Lock mutex
\*------------------------------------------------------------------------*/
   perr = pthread_mutex_lock( &fifo->mutex );
   if( perr )
     logerr( "fifoLockWaitWritable: locking fifo mutex: %s", strerror(perr) );

   DBGMSG( "Fifo (%p,%s): waiting for writable: used=%ld <? low mark=%ld, timeout %dms, requested=%ld <? free=%ld",
           fifo, fifo->name?fifo->name:"<unknown>",
           (long)fifoGetSize(fifo,FifoTotalUsed), (long)fifo->lowWatermark, timeout,
           (long)bytes, (long)fifoGetSize(fifo,FifoTotalFree) );

/*------------------------------------------------------------------------*\
    Get absolute timestamp for timeout
\*------------------------------------------------------------------------*/
  if( timeout>0 ) {
    gettimeofday( &now, NULL );
    abstime.tv_sec  = now.tv_sec + timeout/1000;
    abstime.tv_nsec = now.tv_usec*1000UL +(timeout%1000)*1000UL*1000UL;
    if( abstime.tv_nsec>1000UL*1000UL*1000UL ) {
      abstime.tv_nsec -= 1000UL*1000UL*1000UL;
      abstime.tv_sec++;
    }
  }

/*------------------------------------------------------------------------*\
    Loop while condition is not met (cope with "spurious wakeups")
\*------------------------------------------------------------------------*/
  while( !FifoIsWritable(fifo) || (bytes&&fifoGetSize(fifo,FifoTotalFree)<bytes) ) {

    // wait for condition
    err = timeout>0 ? pthread_cond_timedwait( &fifo->condIsWritable, &fifo->mutex, &abstime )
                    : pthread_cond_wait( &fifo->condIsWritable, &fifo->mutex );

    // Break on errors
    if( err )
      break;
  }

/*------------------------------------------------------------------------*\
    In case of error: unlock mutex
\*------------------------------------------------------------------------*/
  if( err ) {
    perr = pthread_mutex_unlock( &fifo->mutex );
    if( perr )
      logerr( "fifoLockWaitWritable: unlocking fifo mutex: %s", strerror(perr) );
    if( FifoIsReadable(fifo) )
      pthread_cond_signal( &fifo->condIsReadable );
  }

/*------------------------------------------------------------------------*\
    That's it
\*------------------------------------------------------------------------*/
  DBGMSG( "Fifo (%p,%s): waiting for writable: %s",
          fifo, fifo->name?fifo->name:"<unknown>", err?strerror(err):"Locked" );
  return err;
}

/*=========================================================================*\
      Lock fifo and wait for empty condition
        timeout is in ms, 0 or a negative values are treated as infinity
        returns 0 and locks fifo, if condition is met
                std. errode (ETIMEDOUT in case of timeout) and no locking otherwise
\*=========================================================================*/
int fifoLockWaitDrained( Fifo *fifo, int timeout )
{
  struct timeval  now;
  struct timespec abstime;
  int             err = 0;
  int             perr;

  DBGMSG( "Fifo (%p,%s): waiting for drained: used=%ld, timeout %dms",
          fifo, fifo->name?fifo->name:"<unknown>",
          (long)fifoGetSize(fifo,FifoTotalUsed), timeout );

/*------------------------------------------------------------------------*\
    We're draining
\*------------------------------------------------------------------------*/
  fifo->isDraining = true;

/*------------------------------------------------------------------------*\
    Lock mutex
\*------------------------------------------------------------------------*/
   perr = pthread_mutex_lock( &fifo->mutex );
   if( perr )
     logerr( "fifoLockWaitDrained: locking fifo mutex: %s", strerror(perr) );

/*------------------------------------------------------------------------*\
    Get absolute timestamp for timeout
\*------------------------------------------------------------------------*/
  if( timeout>0 ) {
    gettimeofday( &now, NULL );
    abstime.tv_sec  = now.tv_sec + timeout/1000;
    abstime.tv_nsec = now.tv_usec*1000UL +(timeout%1000)*1000UL*1000UL;
    if( abstime.tv_nsec>1000UL*1000UL*1000UL ) {
      abstime.tv_nsec -= 1000UL*1000UL*1000UL;
      abstime.tv_sec++;
    }
  }

/*------------------------------------------------------------------------*\
    Loop while condition is not met (cope with "spurious  wakeups")
\*------------------------------------------------------------------------*/
  while( !FifoIsEmpty(fifo) ) {

    // wait for condition
    err = timeout>0 ? pthread_cond_timedwait( &fifo->condIsDrained, &fifo->mutex, &abstime )
                    : pthread_cond_wait( &fifo->condIsDrained, &fifo->mutex );

    // Break on errors
    if( err )
      break;
  }

/*------------------------------------------------------------------------*\
    In case of error: unlock mutex
\*------------------------------------------------------------------------*/
  if( err ) {
    perr = pthread_mutex_unlock( &fifo->mutex );
    if( perr )
      logerr( "fifoLockWaitDrained: unlocking fifo mutex: %s", strerror(perr) );
    if( FifoIsReadable(fifo) )
      pthread_cond_signal( &fifo->condIsReadable );
  }

/*------------------------------------------------------------------------*\
    That's it
\*------------------------------------------------------------------------*/
  fifo->isDraining = false;
  DBGMSG( "Fifo (%p,%s): waiting for draining: %s",
          fifo, fifo->name?fifo->name:"<unknown>", err?strerror(err):"Locked" );
  return err;
}

/*=========================================================================*\
      Lock fifo and wait for readable (usedSize>highWatermark) condition
        timeout is in ms, 0 or a negative values are treated as infinity
        returns 0 and locks fifo, if condition is met
                std. errode (ETIMEDOUT in case of timeout) and no locking otherwise
\*=========================================================================*/
int fifoLockWaitReadable( Fifo *fifo, int timeout )
{
  struct timeval  now;
  struct timespec abstime;
  int             err = 0;
  int             perr;

  DBGMSG( "Fifo (%p,%s): waiting for readable: used=%ld >? high mark=%ld, timeout %dms",
          fifo, fifo->name?fifo->name:"<unknown>",
          (long)fifoGetSize(fifo,FifoTotalUsed), (long)fifo->highWatermark, timeout );

/*------------------------------------------------------------------------*\
    Lock mutex
\*------------------------------------------------------------------------*/
   perr = pthread_mutex_lock( &fifo->mutex );
   if( perr )
     logerr( "fifoLockWaitReadable: locking fifo mutex: %s", strerror(perr) );

/*------------------------------------------------------------------------*\
    Get absolut timestamp for timeout
\*------------------------------------------------------------------------*/
  if( timeout>0 ) {
    gettimeofday( &now, NULL );
    abstime.tv_sec  = now.tv_sec + timeout/1000;
    abstime.tv_nsec = now.tv_usec*1000UL +(timeout%1000)*1000UL*1000UL;
    if( abstime.tv_nsec>1000UL*1000UL*1000UL ) {
      abstime.tv_nsec -= 1000UL*1000UL*1000UL;
      abstime.tv_sec++;
    }
  }

/*------------------------------------------------------------------------*\
    Loop while condtion is not met (cope with "spurious  wakeups")
\*------------------------------------------------------------------------*/
  while( !FifoIsReadable(fifo) ) {

    // wait for condition
    err = timeout>0 ? pthread_cond_timedwait( &fifo->condIsReadable, &fifo->mutex, &abstime )
                    : pthread_cond_wait( &fifo->condIsReadable, &fifo->mutex );

    // Break on errors
    if( err )
      break;
  }

/*------------------------------------------------------------------------*\
    In case of error: unlock mutex
\*------------------------------------------------------------------------*/
  if( err ) {
    perr = pthread_mutex_unlock( &fifo->mutex );
    if( perr )
      logerr( "fifoLockWaitReadable: unlocking fifo mutex: %s", strerror(perr) );
    if( fifo->isDraining ) {
      if( FifoIsEmpty(fifo) )
        pthread_cond_signal( &fifo->condIsDrained );
    }
    else if( FifoIsWritable(fifo) )
      pthread_cond_signal( &fifo->condIsWritable );
  }

  DBGMSG( "Fifo (%p,%s): waiting for readable: %s",
          fifo, fifo->name?fifo->name:"<unknown>", err?strerror(err):"Locked" );

/*------------------------------------------------------------------------*\
    That's it
\*------------------------------------------------------------------------*/
  return err;
}

/*=========================================================================*\
      Unlock fifo to avoid concurrent modifications
\*=========================================================================*/
void fifoUnlock( Fifo *fifo )
{
  int perr;
  DBGMSG( "Fifo (%p,%s): unlock.", fifo, fifo->name?fifo->name:"<unknown>" );
  perr = pthread_mutex_unlock( &fifo->mutex );
  if( perr )
    logerr( "fifoUnlock: %s", strerror(perr) );
}

/*=========================================================================*\
      Unlock after data was consumed
\*=========================================================================*/
void fifoUnlockAfterRead( Fifo *fifo, size_t size )
{
  int perr;
  DBGMSG( "Fifo (%p,%s): unlocked after read of %ld byte: %s %s (used=%ld)",
                      fifo, fifo->name?fifo->name:"<unknown>", (long) size,
                      FifoIsWritable(fifo) ? "isWritable" : "",
                      FifoIsReadable(fifo) ? "isReadable" : "",
                      (long)fifoGetSize(fifo,FifoTotalUsed)  );

/*------------------------------------------------------------------------*\
    Adjust pointers
\*------------------------------------------------------------------------*/
  fifoDataConsumed( fifo, size );

/*------------------------------------------------------------------------*\
    Release mutex
\*------------------------------------------------------------------------*/
  perr = pthread_mutex_unlock( &fifo->mutex );
  if( perr )
    logerr( "fifoUnlockAfterRead: %s", strerror(perr) );

/*------------------------------------------------------------------------*\
    Check for conditions: write/draining first
\*------------------------------------------------------------------------*/
  if( fifo->isDraining ) {
    if( FifoIsEmpty(fifo) )
      pthread_cond_signal( &fifo->condIsDrained );
  }
  else if( FifoIsWritable(fifo) )
    pthread_cond_signal( &fifo->condIsWritable );
  if( FifoIsReadable(fifo) )
    pthread_cond_signal( &fifo->condIsReadable );
}

/*=========================================================================*\
      Unlock after data was written
\*=========================================================================*/
void fifoUnlockAfterWrite( Fifo *fifo, size_t size )
{
  int perr;
  DBGMSG( "Fifo (%p,%s): unlocked after write of %ld bytes: %s %s (used=%ld)",
                      fifo, fifo->name?fifo->name:"<unknown>", (long) size,
                      FifoIsWritable(fifo) ? "isWritable" : "",
                      FifoIsReadable(fifo) ? "isReadable" : "",
                      (long)fifoGetSize(fifo,FifoTotalUsed) );

/*------------------------------------------------------------------------*\
    This is an error!
\*------------------------------------------------------------------------*/
  if( fifo->isDraining )
    logerr( "Fifo (%s): wrote %ld bytes in draining mode.",
        fifo, fifo->name?fifo->name:"<unknown>", (long) size );

/*------------------------------------------------------------------------*\
    Adjust pointers
\*------------------------------------------------------------------------*/
  fifoDataWritten( fifo, size );

/*------------------------------------------------------------------------*\
    Release mutex
\*------------------------------------------------------------------------*/
  perr = pthread_mutex_unlock( &fifo->mutex );
  if( perr )
    logerr( "fifoUnlockAfterRead: %s", strerror(perr) );

/*------------------------------------------------------------------------*\
    Check for conditions: read first
\*------------------------------------------------------------------------*/
  if( FifoIsReadable(fifo) )
    pthread_cond_signal( &fifo->condIsReadable );
  if( fifo->isDraining ) {
    if( FifoIsEmpty(fifo) )
      pthread_cond_signal( &fifo->condIsDrained );
  }
  else if( FifoIsWritable(fifo) )
    pthread_cond_signal( &fifo->condIsWritable );
}

/*=========================================================================*\
    Copy data to fifo and unlock - caller has to lock fifo first
      returns the data actually copied
\*=========================================================================*/
size_t fifoFillAndUnlock( Fifo *fifo, const char *src, size_t bytes )
{
  size_t space;
  size_t written = 0;
  int    perr;
  DBGMSG( "Fifo (%p,%s): fill with %ld bytes",
                      fifo, fifo->name?fifo->name:"<unknown>", (long)bytes );

/*------------------------------------------------------------------------*\
    This is an error!
\*------------------------------------------------------------------------*/
  if( fifo->isDraining )
    logerr( "Fifo (%s): writing %ld bytes in draining mode.",
        fifo, fifo->name?fifo->name:"<unknown>", (long) bytes );

/*------------------------------------------------------------------------*\
    Get size of first trunk (up to end) and
    check if there is actually something to do
\*------------------------------------------------------------------------*/
  space = fifoGetSize( fifo, FifoNextWritable );
  if( space && bytes ) {

/*------------------------------------------------------------------------*\
    All data fits in as one piece
\*------------------------------------------------------------------------*/
    if( bytes<=space ) {

      // Copy data and increment write pointer
      memcpy( (char*)fifo->writep, src, bytes );
      written       = bytes;
      fifo->writep += written;

      // wrapping?
      if( fifo->writep>=fifo->buffer+fifo->size )
        fifo->writep = fifo->buffer;
    }

/*------------------------------------------------------------------------*\
    Need to split data in two parts
\*------------------------------------------------------------------------*/
    else {

      // Copy first part till end of buffer, wrap write pointer
      memcpy( (char*)fifo->writep, src, space );
      written = space;
      bytes  -= space;
      src    += space;
      fifo->writep = fifo->buffer;

      // Copy second part
      space = MIN( bytes, fifoGetSize(fifo,FifoNextWritable) );
      memcpy( (char*)fifo->writep, src, space );
      written      += space;
      fifo->writep += space;
    }

/*------------------------------------------------------------------------*\
    Is buffer full?
\*------------------------------------------------------------------------*/
    fifo->isFull = (fifo->writep==fifo->readp);
  }

/*------------------------------------------------------------------------*\
    Release mutex
\*------------------------------------------------------------------------*/
  perr = pthread_mutex_unlock( &fifo->mutex );
  if( perr )
    logerr( "fifoFillAndUnlock: %s", strerror(perr) );

/*------------------------------------------------------------------------*\
    Check for conditions: read first
\*------------------------------------------------------------------------*/
  if( FifoIsReadable(fifo) )
    pthread_cond_signal( &fifo->condIsReadable );
  if( fifo->isDraining ) {
    if( FifoIsEmpty(fifo) )
      pthread_cond_signal( &fifo->condIsDrained );
  }
  else if( FifoIsWritable(fifo) )
    pthread_cond_signal( &fifo->condIsWritable );

/*------------------------------------------------------------------------*\
    Return number of bytes written
\*------------------------------------------------------------------------*/
  return written;
}

/*=========================================================================*\
      Get ring buffer sizes
        Note: the maximum fill size is size -1
              (else wp==rp would indicate the empty condition)
\*=========================================================================*/
size_t fifoGetSize( Fifo *fifo, FifoSizeMode mode )
{
  char *endp = fifo->buffer+fifo->size;

/*------------------------------------------------------------------------*\
    Return size as requested by mode
\*------------------------------------------------------------------------*/
  switch( mode ) {

    // Ring buffer size
    case FifoTotal:
      return fifo->size;

    // Used size
    case FifoTotalUsed:
      if( fifo->isFull )
        return fifo->size;
      if( fifo->readp<=fifo->writep )
        return fifo->writep-fifo->readp;
      return (endp-fifo->readp) + (fifo->writep-fifo->buffer);

    // Free size
    case FifoTotalFree:
      if( fifo->isFull )
        return 0;
      if( fifo->readp<=fifo->writep )
        return (fifo->readp-fifo->buffer) + (endp-fifo->writep);
      return fifo->readp - fifo->writep;

    // Size of next readable chunk (takes wrapping into account)
    case FifoNextReadable:
      if( fifo->isFull || fifo->readp>fifo->writep )
        return endp - fifo->readp;
      return fifo->writep - fifo->readp;

    // Size of next writable chunk (takes wrapping into account)
    case FifoNextWritable:
      if( fifo->isFull || fifo->readp>fifo->writep )
        return fifo->readp - fifo->writep;
      return endp - fifo->writep;

  }

/*------------------------------------------------------------------------*\
    Unknown mode
\*------------------------------------------------------------------------*/
  logerr( "Fifo (%s): unknown getSize mode %d",
           fifo->name?fifo->name:"<unknown>", mode );
  return -1;
}

/*=========================================================================*\
    Get pointer to read position
\*=========================================================================*/
const char *fifoGetReadPtr( Fifo *fifo )
{
  return (const char *) fifo->readp;
}

/*=========================================================================*\
    Get pointer to write position
\*=========================================================================*/
char *fifoGetWritePtr( Fifo *fifo )
{
  return (char *) fifo->writep;
}

/*=========================================================================*\
      New data was written, adjust write pointer
        fifo should be locked
        return 0 on success, -1 on error (boundary check)
\*=========================================================================*/
int fifoDataWritten( Fifo *fifo, size_t size )
{
  volatile char *eptr;
  DBGMSG( "Fifo (%p,%s): %ld bytes written.",
          fifo, fifo->name?fifo->name:"<unknown>", (long)size );

/*------------------------------------------------------------------------*\
    Check for boundary violation
\*------------------------------------------------------------------------*/
  eptr = (fifo->writep>=fifo->readp) ? fifo->buffer+fifo->size : fifo->readp;
  if( fifo->writep+size>eptr ) {
    logerr( "Fifo (%s): data written beyond boundary (by %ld bytes)",
                     fifo->name?fifo->name:"<unknown>",
                     (long) (fifo->writep-eptr+size) );
    return -1;
  }

/*------------------------------------------------------------------------*\
    Increment read pointer modulo buffer size
\*------------------------------------------------------------------------*/
  fifo->writep += size;
  if( fifo->writep>=fifo->buffer+fifo->size )
    fifo->writep = fifo->buffer;

/*------------------------------------------------------------------------*\
    Is buffer full?
\*------------------------------------------------------------------------*/
  if( size )
    fifo->isFull = (fifo->writep==fifo->readp);

/*------------------------------------------------------------------------*\
    That's all
\*------------------------------------------------------------------------*/
  return 0;
}

/*=========================================================================*\
      Data was consumed, adjust read pointer
        fifo should be locked
        return 0 on success, -1 on error (boundary check)
\*=========================================================================*/
int fifoDataConsumed( Fifo *fifo, size_t size )
{
  volatile char *eptr;
  DBGMSG( "Fifo (%p,%s): %ld bytes consumed.",
          fifo, fifo->name?fifo->name:"<unknown>", (long)size );

/*------------------------------------------------------------------------*\
    Check for boundary violation
\*------------------------------------------------------------------------*/
  eptr = (fifo->readp>=fifo->writep) ? fifo->buffer+fifo->size : fifo->writep;
  if( fifo->readp+size>eptr ) {
    logerr( "Fifo (%s): data consumed beyond boundary (%ld bytes)",
                     fifo->name?fifo->name:"<unknown>",
                     (long) (fifo->readp+size-eptr) );
    return -1;
  }

/*------------------------------------------------------------------------*\
    Increment read pointer modulo buffer size
\*------------------------------------------------------------------------*/
  fifo->readp += size;
  if( fifo->readp>=fifo->buffer+fifo->size )
    fifo->readp = fifo->buffer;

/*------------------------------------------------------------------------*\
    Is buffer full?
\*------------------------------------------------------------------------*/
  if( size )
    fifo->isFull = false;

/*------------------------------------------------------------------------*\
    That's all
\*------------------------------------------------------------------------*/
  return 0;
}

/*=========================================================================*\
                                    END OF FILE
\*=========================================================================*/


text:
<?php

namespace Landing\Pages\CoreBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class LandingPagesCoreBundle extends Bundle
{
}


text:
package org.ofbiz.base.util;

import java.util.Collection;
import java.util.List;

/**
 * SCIPIO: Interface for exceptions that allow passing around a PropertyMessage representing the
 * main exception message in PropertyMessage form, and additionally a separate list
 * of property messages that behaves like and is meant to be used like a services
 * errorMessageList or successMessageList.
 *

 * NOTE: The message list is meant to be user-friendly like services message lists.
 * If the exception needs to pass a list of more "exception-like" error messages,
 * it should manage a separate list of such messages.
 */
public interface PropertyMessageEx {

    /**
     * Returns a PropertyMessage representation of the exception main detail message.
     * To simplify client code, THIS MUST NEVER RETURN NULL, even if the main detail message
     * is null. In such case, it can return a StaticPropertyMessage that returns null.
     */
    PropertyMessage getPropertyMessage();

    /**
     * Returns a separate additional property message list, separate from the main exception detail message.
     */
    List<PropertyMessage> getPropertyMessageList();

    /**
     * Setter methods for property message and lists, for exceptions that choose to
     * support this separate from the constructor.
     *

     * This is needed because changing the exception constructor hierarchies is prohibitively
     * intrusive, despite that modifying exceptions post-constructors is not very common
     * (but is not disallowed).
     */
    public interface SettablePropertyMessageEx extends PropertyMessageEx {
        /**
         * SCIPIO: Setter for property message.
         * Workaround for massive constructor inheritance.
         * Returns the exception so that can be easily chained in a throw statement.
         */
        public SettablePropertyMessageEx setPropertyMessage(PropertyMessage propertyMessage);

        /**
         * SCIPIO: Setter for property messages, which may be in the form of any type
         * convertible to PropertyMessage including simple Strings.
         * Workaround for massive constructor inheritance.
         * Returns the exception so that can be easily chained in a throw statement.
         *

         * DEV NOTE: For implementation, simply pass the messageList to
         * {@link PropertyMessageExUtil#makePropertyMessageList(Collection)} and store result
         * in the instance.
         */
        public SettablePropertyMessageEx setPropertyMessageList(Collection<?> messageList);
    }
}


text:
#region Apache License, Version 2.0
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//  http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.
#endregion

//using System.IO;
//using System.IO.IsolatedStorage;
//using System.Windows;
//using System.Windows.Interactivity;
//using System.Windows.Media.Imaging;
//using Microsoft.Phone.Controls;
//using Microsoft.Phone.Tasks;
//using Microsoft.Xna.Framework.Media;
//using System;

//namespace SaveAndPlay.UI.Behaviors
//{
//    public class ScreenShotBehavior : Behavior<PhoneApplicationPage>
//    {
//#if DEBUG
//        protected override void OnAttached()
//        {
//            base.OnAttached();

//            AssociatedObject.DoubleTap += AssociatedObject_DoubleTap;

//        }

//        void AssociatedObject_DoubleTap(object sender, System.Windows.Input.GestureEventArgs e)
//        {

//            if (sender is PhoneApplicationPage)
//            {
//                var page = sender as PhoneApplicationPage;
//                var bmp = new WriteableBitmap((int)page.ActualWidth, (int)page.ActualHeight);
//                bmp.Render(page, null);
//                bmp.Invalidate();

//                string tempJpeg = "Screenshot " + DateTime.Now.ToString("MM.dd.yy H-mm-ss") + ".jpg";

//                using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
//                {
//                    if (isoStore.FileExists(tempJpeg))
//                    {
//                        isoStore.DeleteFile(tempJpeg);
//                    }

//                    using (var myFileStream = isoStore.CreateFile(tempJpeg))
//                    {
//                        bmp.SaveJpeg(myFileStream, bmp.PixelWidth, bmp.PixelHeight, 0, 85);
//                    }
//                }
//            }
//        }

//        protected override void OnDetaching()
//        {
//            base.OnDetaching();
//            AssociatedObject.DoubleTap -= AssociatedObject_DoubleTap;
//        }
//#endif
//    }
//}


text:
        Projects
        Lab
        Blog

        About


text:
<!DOCTYPE html>

    <meta charset="UTF-8" />
    <title>A Pokémon Calculator</title>
    <link type="text/css" rel="stylesheet" href="./bootstrap.css" />
    <link type="text/css" rel="stylesheet" href="https://cdn.datatables.net/1.10.4/css/jquery.dataTables.min.css" />
    <link type="text/css" rel="stylesheet" href="https://cdn.datatables.net/colvis/1.1.1/css/dataTables.colVis.css" />
    <link type="text/css" rel="stylesheet" href="./select2/select2.css" />
    <link type="text/css" rel="stylesheet" href="./shared_controls.css?" />

        Battle Tree Damage Calculator

            <input class="gen visually-hidden" type="radio" name="gen" value="3" id="gen3" />ADV
            <input class="gen visually-hidden" type="radio" name="gen" value="4" id="gen4" />DPP
            <input class="gen visually-hidden" type="radio" name="gen" value="5" id="gen5" />B/W
            <input class="gen visually-hidden" type="radio" name="gen" value="6" id="gen6" />ORAS
            <input class="gen visually-hidden" type="radio" name="gen" value="7" id="gen7" checked="checked" />USUM

	<input class="mode visually-hidden" type="radio" name="mode" id="one-vs-one" />One vs One
	<input class="mode visually-hidden" type="radio" name="mode" id="one-vs-all" />One vs All
        <input class="mode visually-hidden" type="radio" name="mode" id="all-vs-one" />All vs One

        Check one of All Sets, 40+/Common (DPP/ORAS/USUM), or Maison/Battle Hall), then press Honkalculate:

            <input class="visually-hidden" type="checkbox" name="tier" id="Maison" />All sets
			      <input class="visually-hidden" type="checkbox" name="tier" id="Common" />40+
            <input class="visually-hidden" type="checkbox" name="tier" id="40+" />Maison

        <fieldset class="panel panel-default poke-info" id="p1">
            <legend class="panel-heading panel-title">
                >  Pokemon
            </legend>

                    <input type="text" class="set-selector" />

                            Type
                            <select class="type1 terrain-trigger"></select>
                            <select class="type2 terrain-trigger"></select>

                            Forme
                            <select class="forme calc-trigger"></select>

                            Gender
                            <select class="gender calc-trigger"><option></option><option selected="selected">Male</option><option>Female</option></select>

                            Level
                            <input class="level" value="50" />

                            Foe Level
                            <input id="leveloverride" value="50" />

                            Foe IVs
                            <input id="ivsoverridehonk" value="31" />

                            Foe IVs hidden for making hack work
                            <input class="ivsoverride" id="ivsoverride" value="31" />

                            Weight (kg)
                            <input class="weight" value="10.0" />

                                Base
                                IVs
                                EVs
                                DVs

                                    HP

                                    <input class="base" value="100" />

                                    <input class="ivs" value="31" />

                                    <input class="evs" type="number" min="0" max="252" step="4" value="0" />

                                    <input class="dvs" value="15" disabled="disabled" />

                                341

                                    Attack

                                    <input class="base" value="100" />

                                    <input class="ivs" value="31" />

                                    <input class="evs" type="number" min="0" max="252" step="4" value="0" />

                                    <input class="dvs" value="15" />

                                236

                                    <select class="boost">
                                        <option value="6">+6</option>
                                        <option value="5">+5</option>
                                        <option value="4">+4</option>
                                        <option value="3">+3</option>
                                        <option value="2">+2</option>
                                        <option value="1">+1</option>
                                        <option value="0" selected="selected">--</option>
                                        <option value="-1">-1</option>
                                        <option value="-2">-2</option>
                                        <option value="-3">-3</option>
                                        <option value="-4">-4</option>
                                        <option value="-5">-5</option>
                                        <option value="-6">-6</option>
                                    </select>

                                    Defense

                                    <input class="base" value="100" />

                                    <input class="ivs" value="31" />

                                    <input class="evs" type="number" min="0" max="252" step="4" value="0" />

                                    <input class="dvs" value="15" />

                                236

                                    <select class="boost">
                                        <option value="6">+6</option>
                                        <option value="5">+5</option>
                                        <option value="4">+4</option>
                                        <option value="3">+3</option>
                                        <option value="2">+2</option>
                                        <option value="1">+1</option>
                                        <option value="0" selected="selected">--</option>
                                        <option value="-1">-1</option>
                                        <option value="-2">-2</option>
                                        <option value="-3">-3</option>
                                        <option value="-4">-4</option>
                                        <option value="-5">-5</option>
                                        <option value="-6">-6</option>
                                    </select>

                                    Sp. Atk

                                    <input class="base" value="100" />

                                    <input class="ivs" value="31" />

                                    <input class="evs" type="number" min="0" max="252" step="4" value="0" />

                                    <input class="dvs" value="15" />

                                236

                                    <select class="boost">
                                        <option value="6">+6</option>
                                        <option value="5">+5</option>
                                        <option value="4">+4</option>
                                        <option value="3">+3</option>
                                        <option value="2">+2</option>
                                        <option value="1">+1</option>
                                        <option value="0" selected="selected">--</option>
                                        <option value="-1">-1</option>
                                        <option value="-2">-2</option>
                                        <option value="-3">-3</option>
                                        <option value="-4">-4</option>
                                        <option value="-5">-5</option>
                                        <option value="-6">-6</option>
                                    </select>

                                    Sp. Def

                                    <input class="base" value="100" />

                                    <input class="ivs" value="31" />

                                    <input class="evs" type="number" min="0" max="252" step="4" value="0" />

                                    <input class="dvs" value="15" disabled="disabled" />

                                236

                                    <select class="boost">
                                        <option value="6">+6</option>
                                        <option value="5">+5</option>
                                        <option value="4">+4</option>
                                        <option value="3">+3</option>
                                        <option value="2">+2</option>
                                        <option value="1">+1</option>
                                        <option value="0" selected="selected">--</option>
                                        <option value="-1">-1</option>
                                        <option value="-2">-2</option>
                                        <option value="-3">-3</option>
                                        <option value="-4">-4</option>
                                        <option value="-5">-5</option>
                                        <option value="-6">-6</option>
                                    </select>

                                    Special

                                    <input class="base" value="100" />

                                    <input class="dvs" value="15" />

                                236

                                    <select class="boost">
                                        <option value="6">+6</option>
                                        <option value="5">+5</option>
                                        <option value="4">+4</option>
                                        <option value="3">+3</option>
                                        <option value="2">+2</option>
                                        <option value="1">+1</option>
                                        <option value="0" selected="selected">--</option>
                                        <option value="-1">-1</option>
                                        <option value="-2">-2</option>
                                        <option value="-3">-3</option>
                                        <option value="-4">-4</option>
                                        <option value="-5">-5</option>
                                        <option value="-6">-6</option>
                                    </select>

                                    Speed

                                    <input class="base" value="100" />

                                    <input class="ivs" value="31" />

                                    <input class="evs" type="number" min="0" max="252" step="4" value="0" />

                                    <input class="dvs" value="15" />

                                236

                                    <select class="boost">
                                        <option value="6">+6</option>
                                        <option value="5">+5</option>
                                        <option value="4">+4</option>
                                        <option value="3">+3</option>
                                        <option value="2">+2</option>
                                        <option value="1">+1</option>
                                        <option value="0" selected="selected">--</option>
                                        <option value="-1">-1</option>
                                        <option value="-2">-2</option>
                                        <option value="-3">-3</option>
                                        <option value="-4">-4</option>
                                        <option value="-5">-5</option>
                                        <option value="-6">-6</option>
                                    </select>

                            Nature
                            <select class="nature">
                                <option value="Adamant">Adamant (+Atk, -SpA)</option>
                                <option value="Bashful">Bashful</option>
                                <option value="Bold">Bold (+Def, -Atk)</option>
                                <option value="Brave">Brave (+Atk, -Spe)</option>
                                <option value="Calm">Calm (+SpD, -Atk)</option>
                                <option value="Careful">Careful (+SpD, -SpA)</option>
                                <option value="Docile">Docile</option>
                                <option value="Gentle">Gentle (+SpD, -Def)</option>
                                <option value="Hardy" selected="selected">Hardy</option>
                                <option value="Hasty">Hasty (+Spe, -Def)</option>
                                <option value="Impish">Impish (+Def, -SpA)</option>
                                <option value="Jolly">Jolly (+Spe, -SpA)</option>
                                <option value="Lax">Lax (+Def, -SpD)</option>
                                <option value="Lonely">Lonely (+Atk, -Def)</option>
                                <option value="Mild">Mild (+SpA, -Def)</option>
                                <option value="Modest">Modest (+SpA, -Atk)</option>
                                <option value="Naive">Naive (+Spe, -SpD)</option>
                                <option value="Naughty">Naughty (+Atk, -SpD)</option>
                                <option value="Quiet">Quiet (+SpA, -Spe)</option>
                                <option value="Quirky">Quirky</option>
                                <option value="Rash">Rash (+SpA, -SpD)</option>
                                <option value="Relaxed">Relaxed (+Def, -Spe)</option>
                                <option value="Sassy">Sassy (+SpD, -Spe)</option>
                                <option value="Serious">Serious</option>
                                <option value="Timid">Timid (+Spe, -Atk)</option>
                            </select>

                            Ability
                            <select class="ability terrain-trigger"></select>

                            Item
                            <select class="item terrain-trigger"></select>

                            Status
                            <select class="status">
                                <option value="Healthy">Healthy</option>
                                <option value="Poisoned">Poisoned</option>
                                <option value="Badly Poisoned">Badly Poisoned</option>
                                <option value="Burned">Burned</option>
                                <option value="Paralyzed">Paralyzed</option>
                                <option value="Asleep">Asleep</option>
                                <option value="Frozen">Frozen</option>
                            </select>
                            <select class="toxic-counter hide">
                                <option value="1">1/16</option>
                                <option value="2">2/16</option>
                                <option value="3">3/16</option>
                                <option value="4">4/16</option>
                                <option value="5">5/16</option>
                                <option value="6">6/16</option>
                                <option value="7">7/16</option>
                                <option value="8">8/16</option>
                                <option value="9">9/16</option>
                                <option value="10">10/16</option>
                                <option value="11">11/16</option>
                                <option value="12">12/16</option>
                                <option value="13">13/16</option>
                                <option value="14">14/16</option>
                                <option value="15">15/16</option>
                            </select>

                        Current HP
                        <input class="current-hp" value="341" />/341 (
                        <input class="percent-hp" value="100" />%)

                        Health

                        <select class="move-selector small-select"></select>
                        <input class="move-bp" value="50" />
                        <select class="move-type"></select>
                        <select class="move-cat gen-specific g4 g5 g6 g7">
                            <option value="Physical">Physical</option>
                            <option value="Special">Special</option>
                        </select>
                        <input class="move-crit visually-hidden" type="checkbox" id="critL1" />
                        Crit
                        <input class="move-z visually-hidden" type="checkbox" id="zL1"/>
                        Z
                        <select class="move-hits hide">
                            <option value="2">2 hits</option>
                            <option value="3">3 hits</option>
                            <option value="4">4 hits</option>
                            <option value="5">5 hits</option>
                        </select>
							  <select class="stat-drops calc-trigger hide" title="How many times was this move used in a row?">>
                    			<option value="1">Once</option>
                    			<option value="2">Twice</option>
                    			<option value="3">3 times</option>
                    			<option value="4">4 times</option>
                    			<option value="5">5 times</option>
                		  </select>
							  <select class="metronome calc-trigger hide" title="How many times was this move used while holding Metronome?">
                    			<option value="1">Once</option>
                    			<option value="2">Twice</option>
                    			<option value="3">3 times</option>
                    			<option value="4">4 times</option>
                    			<option value="5">5 times</option>
                		  </select>

                        <select class="move-selector small-select"></select>
                        <input class="move-bp" value="0" />
                        <select class="move-type"></select>
                        <select class="move-cat gen-specific g4 g5 g6 g7">
                            <option value="Physical">Physical</option>
                            <option value="Special">Special</option>
                        </select>
                        <input class="move-crit visually-hidden" type="checkbox" id="critL2" />
                        Crit
                        <input class="move-z visually-hidden" type="checkbox" id="zL2"/>
                        Z
                        <select class="move-hits hide">
                            <option value="2">2 hits</option>
                            <option value="3">3 hits</option>
                            <option value="4">4 hits</option>
                            <option value="5">5 hits</option>
                        </select>
							  <select class="stat-drops calc-trigger hide" title="How many times was this move used in a row?">>
                    			<option value="1">Once</option>
                    			<option value="2">Twice</option>
                    			<option value="3">3 times</option>
                    			<option value="4">4 times</option>
                    			<option value="5">5 times</option>
                		  </select>
							  <select class="metronome calc-trigger hide" title="How many times was this move used while holding Metronome?">
                    			<option value="1">Once</option>
                    			<option value="2">Twice</option>
                    			<option value="3">3 times</option>
                    			<option value="4">4 times</option>
                    			<option value="5">5 times</option>
                		  </select>

                        <select class="move-selector small-select"></select>
                        <input class="move-bp" value="0" />
                        <select class="move-type"></select>
                        <select class="move-cat gen-specific g4 g5 g6 g7">
                            <option value="Physical">Physical</option>
                            <option value="Special">Special</option>
                        </select>
                        <input class="move-crit visually-hidden" type="checkbox" id="critL3" />
                        Crit
                        <input class="move-z visually-hidden" type="checkbox" id="zL3"/>
                        Z
                        <select class="move-hits hide">
                            <option value="2">2 hits</option>
                            <option value="3">3 hits</option>
                            <option value="4">4 hits</option>
                            <option value="5">5 hits</option>
                        </select>
							  <select class="stat-drops calc-trigger hide" title="How many times was this move used in a row?">>
                    			<option value="1">Once</option>
                    			<option value="2">Twice</option>
                    			<option value="3">3 times</option>
                    			<option value="4">4 times</option>
                    			<option value="5">5 times</option>
                		  </select>
							  <select class="metronome calc-trigger hide" title="How many times was this move used while holding Metronome?">
                    			<option value="1">Once</option>
                    			<option value="2">Twice</option>
                    			<option value="3">3 times</option>
                    			<option value="4">4 times</option>
                    			<option value="5">5 times</option>
                		  </select>

                        <select class="move-selector small-select"></select>
                        <input class="move-bp" value="0" />
                        <select class="move-type"></select>
                        <select class="move-cat gen-specific g4 g5 g6 g7">
                            <option value="Physical">Physical</option>
                            <option value="Special">Special</option>
                        </select>
                        <input class="move-crit visually-hidden" type="checkbox" id="critL4" />
                        Crit
                        <input class="move-z visually-hidden" type="checkbox" id="zL4"/>
                        Z
                        <select class="move-hits hide">
                            <option value="2">2 hits</option>
                            <option value="3">3 hits</option>
                            <option value="4">4 hits</option>
                            <option value="5">5 hits</option>
                        </select>
							  <select class="stat-drops calc-trigger hide" title="How many times was this move used in a row?">>
                    			<option value="1">Once</option>
                    			<option value="2">Twice</option>
                    			<option value="3">3 times</option>
                    			<option value="4">4 times</option>
                    			<option value="5">5 times</option>
                		  </select>
							  <select class="metronome calc-trigger hide" title="How many times was this move used while holding Metronome?">
                    			<option value="1">Once</option>
                    			<option value="2">Twice</option>
                    			<option value="3">3 times</option>
                    			<option value="4">4 times</option>
                    			<option value="5">5 times</option>
                		  </select>

        </fieldset>
        <fieldset class="panel panel-default field-info">
            <legend class="panel-heading panel-title">
                >  Field
            </legend>

                    Select the battle format.
                    <input class="visually-hidden calc-trigger" type="radio" name="format" value="Singles" id="singles-format" checked="checked" />
                    Singles
                    <input class="visually-hidden calc-trigger" type="radio" name="format" value="Doubles" id="doubles-format" />
                    Doubles

                    <input class="btn-input terrain-trigger calc-trigger" type="radio" name="terrain" value="" id="noterrain" checked="checked" />None
                    <input class="btn-input terrain-trigger calc-trigger" type="radio" name="terrain" value="Electric" id="electric" />Electric
                    <input class="btn-input terrain-trigger calc-trigger" type="radio" name="terrain" value="Grassy" id="grassy" />Grassy
                    <input class="btn-input terrain-trigger calc-trigger" type="radio" name="terrain" value="Misty" id="misty" />Misty
                    <input class="btn-input terrain-trigger calc-trigger" type="radio" name="terrain" value="Psychic" id="psychic" />Psychic

                    Select the current weather condition.

                        <input class="visually-hidden calc-trigger" type="radio" name="weather" value="" id="clear" checked="checked" />
                        None
                        <input class="visually-hidden calc-trigger" type="radio" name="weather" value="Sun" id="sun" />
                        Sun
                        <input class="visually-hidden calc-trigger" type="radio" name="weather" value="Rain" id="rain" />
                        Rain
                        <input class="visually-hidden calc-trigger" type="radio" name="weather" value="Sand" id="sand" />
                        Sand
                        <input class="visually-hidden calc-trigger" type="radio" name="weather" value="Hail" id="hail" />
                        Hail

                        <input class="visually-hidden calc-trigger" type="radio" name="weather" value="Harsh Sunshine" id="harsh-sunshine" />
                        Harsh Sun
                        <input class="visually-hidden calc-trigger" type="radio" name="weather" value="Heavy Rain" id="heavy-rain" />
                        Heavy Rain
                        <input class="visually-hidden calc-trigger" type="radio" name="weather" value="Strong Winds" id="strong-winds" />
                        Strong Winds

                    Select the current weather condition.
                    <input class="visually-hidden calc-trigger" type="radio" name="gscWeather" value="" id="gscClear" checked="checked" />
                    None
                    <input class="visually-hidden calc-trigger" type="radio" name="gscWeather" value="Sun" id="gscSun" />
                    Sun
                    <input class="visually-hidden calc-trigger" type="radio" name="gscWeather" value="Rain" id="gscRain" />
                    Rain
                    <input class="visually-hidden calc-trigger" type="radio" name="gscWeather" value="Sand" id="gscSand" />
                    Sand

                    Is gravity in effect?
                    <input aria-describedby="gravityInstruction" class="visually-hidden calc-trigger" type="checkbox" id="gravity" />
                    Gravity

                        <input class="btn-input calc-trigger" type="checkbox" id="protectL" />Protect

                        <input class="btn-input calc-trigger" type="checkbox" id="protectR" />Protect

                        <input class="btn-input calc-trigger" type="checkbox" id="srL" />Stealth Rock

                        <input class="btn-input calc-trigger" type="checkbox" id="srR" />Stealth Rock

                        <input class="btn-input calc-trigger" type="radio" name="spikesL" value="0" id="spikesL0" checked="checked" />0
                        <input class="btn-input calc-trigger" type="radio" name="spikesL" value="1" id="spikesL1" />1
                        <input class="btn-input calc-trigger" type="radio" name="spikesL" value="2" id="spikesL2" />2
                        <input class="btn-input calc-trigger" type="radio" name="spikesL" value="3" id="spikesL3" />3 Spikes

                        <input class="btn-input calc-trigger" type="radio" name="spikesR" value="0" id="spikesR0" checked="checked" />0
                        <input class="btn-input calc-trigger" type="radio" name="spikesR" value="1" id="spikesR1" />1
                        <input class="btn-input calc-trigger" type="radio" name="spikesR" value="2" id="spikesR2" />2
                        <input class="btn-input calc-trigger" type="radio" name="spikesR" value="3" id="spikesR3" />3 Spikes

                        <input class="btn-input calc-trigger" type="checkbox" id="gscSpikesL" />Spikes

                        <input class="btn-input calc-trigger" type="checkbox" id="gscSpikesR" />Spikes

                        <input class="btn-input calc-trigger" type="checkbox" id="reflectL" />Reflect
                        <input class="btn-input calc-trigger" type="checkbox" id="lightScreenL" />Light Screen

                        <input class="btn-input calc-trigger" type="checkbox" id="reflectR" />Reflect
                        <input class="btn-input calc-trigger" type="checkbox" id="lightScreenR" />Light Screen

                        <input class="btn-input calc-trigger" type="checkbox" id="auroraVeilL" />Aurora Veil

                        <input class="btn-input calc-trigger" type="checkbox" id="auroraVeilR" />Aurora Veil

                        <input class="btn-input calc-trigger" type="checkbox" id="foresightL" />Foresight

                        <input class="btn-input calc-trigger" type="checkbox" id="foresightR" />Foresight

                        <input class="btn-input calc-trigger" type="checkbox" id="helpingHandL" />Helping Hand

                        <input class="btn-input calc-trigger" type="checkbox" id="helpingHandR" />Helping Hand

                        <input class="btn-input calc-trigger" type="checkbox" id="batteryL" />Battery

                        <input class="btn-input calc-trigger" type="checkbox" id="batteryR" />Battery

                        <input class="btn-input calc-trigger" type="checkbox" id="friendGuardL" />Friend Guard

                        <input class="btn-input calc-trigger" type="checkbox" id="friendGuardR" />Friend Guard

					<input class="btn-input calc-trigger" type="checkbox" id="minimL" />Minimize

					<input class="btn-input calc-trigger" type="checkbox" id="minimR" />Minimize

					<input class="btn-input calc-trigger" type="checkbox" id="StatBoostL" />
+1 All Stats

                        <input class="btn-input calc-trigger" type="checkbox" id="evoL" />
Extreme Evoboost

        </fieldset>

        <fieldset class="panel holder-0">
            <legend class="panel-heading panel-title">Damage Results</legend>

                        Best Move
                        Damage (%)
                        Damage (px)
                        KO Chance
                        Type 1
                        Type 2
                        Ability
                        Item

        </fieldset>


text:
using System;
using System.Xml.Serialization;
using System.Collections;
using System.Collections.Generic;
using Newtonsoft.Json;
using JdSdk.Request;
using JdSdk.Response.Ware;

namespace JdSdk.Request.Ware
{
    public class WareSkuGetRequest : JdRequestBase<WareSkuGetResponse>
    {
        public String SkuId
        {
            get;
            set;
        }

        public String Fields
        {
            get;
            set;
        }

        public override String ApiName
        {
            get{ return "360buy.ware.sku.get"; }
        }

        protected override void PrepareParam(IDictionary<String, Object> paramters)
        {
            paramters.Add("sku_id" ,this.SkuId);
            paramters.Add("fields" ,this.Fields);
        }

    }

}


text:
<?php

/**
 * tag module helper.
 *
 * @package    quehagoporti
 * @subpackage tag
 * @author     Jose Alfredo Alvarez Aldana
 * @version    SVN: $Id: helper.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class tagGeneratorHelper extends BaseTagGeneratorHelper
{
}


text:
import os

if os.path.exists('.env'):
    print('Importing environment from .env...')
    for line in open('.env'):
        var = line.strip().split('=')
        if len(var) == 2:
            os.environ[var[0]] = var[1]

from app import create_app
from flask.ext.script import Manager, Shell

# 通过配置创建 app
app = create_app(os.getenv('FLASK_CONFIG') or 'default')
manager = Manager(app)

def make_shell_context():
    return dict(app=app)

manager.add_command("shell", Shell(make_context=make_shell_context))

@manager.command
def deploy():
    """Run deployment tasks."""
    pass

if __name__ == '__main__':
    manager.run()


text:
#pragma once

#include <QObject>
#include <QString>
#include <QByteArray>
#include <QCryptographicHash>
#include <QUrl>
#include <QUrlQuery>
#include <QJSValue>
#include <QQmlEngine>
#include <QJsEngine>
#include <QUuid>
#include <QDebug>
#include <QColor>

class StringUtils : public QObject
{
    Q_OBJECT
    Q_ENUMS(HashAlgorithm)

    Q_DISABLE_COPY(StringUtils)

public:
    static QObject* provider(QQmlEngine*, QJSEngine* jsengine) { return new StringUtils(jsengine); }
    StringUtils(QJSEngine* engine) { this->engine = engine; }
    ~StringUtils() { }

    enum HashAlgorithm
    {
#ifndef QT_CRYPTOGRAPHICHASH_ONLY_SHA1
        Md4,
        Md5,
#endif
        Sha1 = 2,
#ifndef QT_CRYPTOGRAPHICHASH_ONLY_SHA1
        Sha224,
        Sha256,
        Sha384,
        Sha512,
        Sha3_224,
        Sha3_256,
        Sha3_384,
        Sha3_512
#endif
    };

signals:

public slots:
    QString toHex(const QString& text) { return QString(text.toUtf8().toHex()); }
    QString fromHex(const QString& text) { return QString(QByteArray::fromHex(text.toUtf8())); }
    QString toBase64(const QString& text) { return QString(text.toUtf8().toBase64()); }
    QString fromBase64(const QString& text) { return QString(QByteArray::fromBase64(text.toUtf8())); }
    QString toHash(const QString& text, HashAlgorithm algorithm) { return QString(QCryptographicHash::hash(text.toUtf8(), (QCryptographicHash::Algorithm)algorithm)); }

    QJSValue parseURL(const QString& text)
    {
        QUrl url(text);
        QJSValue result = engine->newObject();
        result.setProperty("authority", QJSValue(url.authority()));
        result.setProperty("fileName", QJSValue(url.fileName()));
        result.setProperty("fragment", QJSValue(url.fragment()));
        result.setProperty("host", QJSValue(url.host()));
        result.setProperty("password", QJSValue(url.password()));
        result.setProperty("path", QJSValue(url.path()));
        result.setProperty("port", QJSValue(url.port()));
        result.setProperty("query", QJSValue(url.query()));
        result.setProperty("scheme", QJSValue(url.scheme()));
        result.setProperty("url", QJSValue(url.url()));
        result.setProperty("userName", QJSValue(url.userName()));
        result.setProperty("userInfo", QJSValue(url.userInfo()));
        return result;
    }

    QJSValue parseURLQuery(const QString& text)
    {
        QUrlQuery query(text);
        QJSValue result = engine->newObject();
        for(auto& item : query.queryItems())
            result.setProperty(item.first, QJSValue(item.second));
        return result;
    }

    QString newGUID() { return QUuid::createUuid().toString(); }

    QJSValue parseColor(const QColor& color)
    {
        QJSValue result = engine->newObject();
        result.setProperty("red", QJSValue(color.red()));
        result.setProperty("green", QJSValue(color.green()));
        result.setProperty("blue", QJSValue(color.blue()));
        result.setProperty("alpha", QJSValue(color.alpha()));
        return result;
    }

    QJSValue parseColorF(const QColor& color)
    {
        QJSValue result = engine->newObject();
        result.setProperty("red", QJSValue(color.redF()));
        result.setProperty("green", QJSValue(color.greenF()));
        result.setProperty("blue", QJSValue(color.blueF()));
        result.setProperty("alpha", QJSValue(color.alphaF()));
        return result;
    }

    QString tempDir() { return "f:/!!!/1"; }

private:
    QJSEngine* engine = nullptr;
};


text:
"""
Tests for the MissingValuesDispersion visualizations.
"""

##########################################################################
## Imports
##########################################################################
import os
from sklearn.datasets import make_classification
from tests.base import VisualTestCase

from yellowbrick.contrib.missing.dispersion import *

try:
    import pandas as pd
except ImportError:
    pd = None

##########################################################################
## Feature Importances Tests
##########################################################################

class MissingValuesDispersionTestCase(VisualTestCase):
    """
    MissingValuesDispersion visualizer
    """
    def setUp(self):
        super(MissingValuesDispersionTestCase, self).setUp()
        self.tol = 0.01
        if os.name == 'nt': # Windows
            self.tol = 5.0

    def test_missingvaluesdispersion_with_pandas(self):
        """
        Integration test of visualizer with pandas
        """
        X, y = make_classification(
            n_samples=400, n_features=20, n_informative=8, n_redundant=8,
            n_classes=2, n_clusters_per_class=4, random_state=854
        )

        # add nan values to a range of values in the matrix
        X[X > 1.5] = np.nan

        X_ = pd.DataFrame(X)
        features = [str(n) for n in range(20)]
        viz = MissingValuesDispersion(features=features)
        viz.fit(X_)
        viz.poof()

        self.assert_images_similar(viz, tol=self.tol)

    def test_missingvaluesdispersion_with_pandas_with_y_targets(self):
        """
        Integration test of visualizer with pandas with y targets
        """
        X, y = make_classification(
            n_samples=400, n_features=20, n_informative=8, n_redundant=8,
            n_classes=2, n_clusters_per_class=4, random_state=854
        )

        # add nan values to a range of values in the matrix
        X[X > 1.5] = np.nan

        X_ = pd.DataFrame(X)
        features = [str(n) for n in range(20)]
        classes = ['Class A', 'Class B']
        viz = MissingValuesDispersion(features=features, classes=classes)
        viz.fit(X_, y=y)
        viz.poof()

        self.assert_images_similar(viz, tol=self.tol)

    def test_missingvaluesdispersion_with_numpy(self):
        """
        Integration test of visualizer with numpy
        """
        X, y = make_classification(
            n_samples=400, n_features=20, n_informative=8, n_redundant=8,
            n_classes=2, n_clusters_per_class=4, random_state=852
        )

        # add nan values to a range of values in the matrix
        X[X > 1.5] = np.nan

        features = [str(n) for n in range(20)]
        viz = MissingValuesDispersion(features=features)
        viz.fit(X)
        viz.poof()

        self.assert_images_similar(viz, tol=self.tol)

    def test_missingvaluesdispersion_with_numpy_with_y_targets(self):
        """
        Integration test of visualizer with numpy with y targets
        """
        X, y = make_classification(
            n_samples=400, n_features=20, n_informative=8, n_redundant=8,
            n_classes=2, n_clusters_per_class=4, random_state=852
        )

        # add nan values to a range of values in the matrix
        X[X > 1.5] = np.nan

        features = [str(n) for n in range(20)]
        classes = ['Class A', 'Class B']
        viz = MissingValuesDispersion(features=features, classes=classes)
        viz.fit(X, y=y)
        viz.poof()

        self.assert_images_similar(viz, tol=self.tol)


text:
'use strict';

angular.module('golosuy.version', [
  'golosuy.version.interpolate-filter',
  'golosuy.version.version-directive'
])

.value('version', '1.0')

.constant('API_END_POINT','http://api.esteem.ws:8080')

.service('APIs', ['$http', '$rootScope', 'API_END_POINT', function ($http, $rootScope, API_END_POINT) {
  'use strict';
  return {
    addPoll: function(poll) {
      return $http.post(API_END_POINT+"/api/polls", {title: poll.title, description: poll.description, choices: poll.choices, preferences: poll.preferences, email: poll.email, chain: "golos"});
    },
    getPoll: function(id) {
      return $http.get(API_END_POINT+"/api/poll/"+id);
    }
  };
}]);


text:
<?php

namespace Oro\Bundle\LayoutBundle\Tests\Unit\Twig\TokenParser;

use Oro\Bundle\LayoutBundle\Twig\Node\BlockThemeNode;
use Oro\Bundle\LayoutBundle\Twig\TokenParser\BlockThemeTokenParser;

class BlockThemeTokenParserTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider getTestsForLayoutTheme
     */
    public function testCompile($source, $expected)
    {
        $env = new \Twig_Environment(
            new \Twig_Loader_String(),
            ['cache' => false, 'autoescape' => false, 'optimizations' => 0]
        );
        $env->addTokenParser(new BlockThemeTokenParser());
        $stream = $env->tokenize($source);
        $parser = new \Twig_Parser($env);

        $this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0));
    }

    public function getTestsForLayoutTheme()
    {
        return [
            [
                '{% block_theme layout "tpl1" %}',
                new BlockThemeNode(
                    new \Twig_Node_Expression_Name('layout', 1),
                    new \Twig_Node_Expression_Array(
                        [
                            new \Twig_Node_Expression_Constant(0, 1),
                            new \Twig_Node_Expression_Constant('tpl1', 1),
                        ],
                        1
                    ),
                    1,
                    'block_theme'
                ),
            ],
            [
                '{% block_theme layout "tpl1" "tpl2" %}',
                new BlockThemeNode(
                    new \Twig_Node_Expression_Name('layout', 1),
                    new \Twig_Node_Expression_Array(
                        [
                            new \Twig_Node_Expression_Constant(0, 1),
                            new \Twig_Node_Expression_Constant('tpl1', 1),
                            new \Twig_Node_Expression_Constant(1, 1),
                            new \Twig_Node_Expression_Constant('tpl2', 1),
                        ],
                        1
                    ),
                    1,
                    'block_theme'
                ),
            ],
            [
                '{% block_theme layout with "tpl1" %}',
                new BlockThemeNode(
                    new \Twig_Node_Expression_Name('layout', 1),
                    new \Twig_Node_Expression_Constant('tpl1', 1),
                    1,
                    'block_theme'
                ),
            ],
            [
                '{% block_theme layout with ["tpl1"] %}',
                new BlockThemeNode(
                    new \Twig_Node_Expression_Name('layout', 1),
                    new \Twig_Node_Expression_Array(
                        [
                            new \Twig_Node_Expression_Constant(0, 1),
                            new \Twig_Node_Expression_Constant('tpl1', 1),
                        ],
                        1
                    ),
                    1,
                    'block_theme'
                ),
            ],
            [
                '{% block_theme layout with ["tpl1", "tpl2"] %}',
                new BlockThemeNode(
                    new \Twig_Node_Expression_Name('layout', 1),
                    new \Twig_Node_Expression_Array(
                        [
                            new \Twig_Node_Expression_Constant(0, 1),
                            new \Twig_Node_Expression_Constant('tpl1', 1),
                            new \Twig_Node_Expression_Constant(1, 1),
                            new \Twig_Node_Expression_Constant('tpl2', 1),
                        ],
                        1
                    ),
                    1,
                    'block_theme'
                ),
            ],
        ];
    }
}