text:
/**
 *  @file MolarityIonicVPSSTP.h
 *   Header for intermediate ThermoPhase object for phases which
 *   employ Gibbs excess free energy based formulations
 *  (see \ref thermoprops
 * and class \link Cantera::MolarityIonicVPSSTP MolarityIonicVPSSTP\endlink).
 *
 * Header file for a derived class of ThermoPhase that handles
 * variable pressure standard state methods for calculating
 * thermodynamic properties that are further based upon activities
 * based on the molarity scale.  In this class, we expect that there are
 * ions, but they are treated on the molarity scale.
 */
/*
 * Copyright (2006) Sandia Corporation. Under the terms of
 * Contract DE-AC04-94AL85000 with Sandia Corporation, the
 * U.S. Government retains certain rights in this software.
 */

#ifndef CT_MOLARITYIONICVPSSTP_H
#define CT_MOLARITYIONICVPSSTP_H

#include "GibbsExcessVPSSTP.h"

namespace Cantera
{

/**
 * @ingroup thermoprops
 */

/*!
 *  MolarityIonicVPSSTP is a derived class of GibbsExcessVPSSTP that handles
 *  variable pressure standard state methods for calculating
 *  thermodynamic properties that are further based on
 *  expressing the Excess Gibbs free energy as a function of
 *  the mole fractions (or pseudo mole fractions) of the constituents.
 *  This category is the workhorse for describing ionic systems which are not on the molality scale.
 *
 *  This class adds additional functions onto the ThermoPhase interface
 *  that handles the calculation of the excess Gibbs free energy. The ThermoPhase
 *  class includes a member function, ThermoPhase::activityConvention()
 *  that indicates which convention the activities are based on. The
 *  default is to assume activities are based on the molar convention.
 *  That default is used here.
 *
 *  All of the Excess Gibbs free energy formulations in this area employ
 *  symmetrical formulations.
 *
 *  This layer will massage the mole fraction vector to implement
 *  cation and anion based mole numbers in an optional manner, such that
 *  it is expected that there exists a charge balance at all times.
 *  One of the ions must be a "special ion" in the sense that its' thermodynamic
 *  functions are set to zero, and the thermo functions of all other
 *  ions are based on a valuation relative to that special ion.
 */
class MolarityIonicVPSSTP : public GibbsExcessVPSSTP
{
public:
    /// Constructor
    /*!
     * This doesn't do much more than initialize constants with
     * default values for water at 25C. Water molecular weight
     * comes from the default elements.xml file. It actually
     * differs slightly from the IAPWS95 value of 18.015268. However,
     * density conservation and therefore element conservation
     * is the more important principle to follow.
     */
    MolarityIonicVPSSTP();

    //! Construct and initialize a MolarityIonicVPSSTP ThermoPhase object
    //! directly from an XML input file
    /*!
     * @param inputFile Name of the input file containing the phase XML data
     *                  to set up the object
     * @param id        ID of the phase in the input file. Defaults to the
     *                  empty string.
     */
    MolarityIonicVPSSTP(const std::string& inputFile, const std::string& id = "");

    //! Construct and initialize a MolarityIonicVPSSTP ThermoPhase object
    //! directly from an XML database
    /*!
     *  @param phaseRef XML phase node containing the description of the phase
     *  @param id     id attribute containing the name of the phase.
     *                (default is the empty string)
     */
    MolarityIonicVPSSTP(XML_Node& phaseRef, const std::string& id = "");

    //! Copy constructor
    /*!
     * @param b class to be copied
     */
    MolarityIonicVPSSTP(const MolarityIonicVPSSTP& b);

    /// Assignment operator
    /*!
     * @param b class to be copied.
     */
    MolarityIonicVPSSTP& operator=(const MolarityIonicVPSSTP& b);

    //! Duplication routine for objects which inherit from ThermoPhase.
    /*!
     *  This virtual routine can be used to duplicate ThermoPhase objects
     *  inherited from ThermoPhase even if the application only has
     *  a pointer to ThermoPhase to work with.
     */
    virtual ThermoPhase* duplMyselfAsThermoPhase() const;

    /**
     * @name Activities, Standard States, and Activity Concentrations
     *
     * The activity \f$a_k\f$ of a species in solution is
     * related to the chemical potential by \f[ \mu_k = \mu_k^0(T)
     * + \hat R T \log a_k. \f] The quantity \f$\mu_k^0(T,P)\f$ is
     * the chemical potential at unit activity, which depends only
     * on temperature and pressure.
     * @{
     */

    //! Get the array of non-dimensional molar-based ln activity coefficients at
    //! the current solution temperature, pressure, and solution concentration.
    /*!
     * @param lnac Output vector of ln activity coefficients. Length: m_kk.
     */
    virtual void getLnActivityCoefficients(doublereal* lnac) const;

    //@}
    /// @name  Partial Molar Properties of the Solution
    //@{

    //! Get the species chemical potentials. Units: J/kmol.
    /*!
     * This function returns a vector of chemical potentials of the
     * species in solution at the current temperature, pressure
     * and mole fraction of the solution.
     *
     * @param mu  Output vector of species chemical
     *            potentials. Length: m_kk. Units: J/kmol
     */
    virtual void getChemPotentials(doublereal* mu) const;

    /**
     * Get the species electrochemical potentials.
     * These are partial molar quantities.
     * This method adds a term \f$ Fz_k \phi_k \f$ to the
     * to each chemical potential.
     *
     * Units: J/kmol
     *
     * @param mu     output vector containing the species electrochemical potentials.
     *               Length: m_kk.
     */
    void getElectrochemPotentials(doublereal* mu) const;

    //! Returns an array of partial molar enthalpies for the species
    //! in the mixture.
    /*!
     * Units (J/kmol)
     *
     * For this phase, the partial molar enthalpies are equal to the
     * standard state enthalpies modified by the derivative of the
     * molality-based activity coefficient wrt temperature
     *
     *  \f[
     *   \bar h_k(T,P) = h^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
     *  \f]
     *
     * @param hbar  Vector of returned partial molar enthalpies
     *              (length m_kk, units = J/kmol)
     */
    virtual void getPartialMolarEnthalpies(doublereal* hbar) const;

    //! Returns an array of partial molar entropies for the species
    //! in the mixture.
    /*!
     * Units (J/kmol)
     *
     * For this phase, the partial molar enthalpies are equal to the
     * standard state enthalpies modified by the derivative of the
     * activity coefficient wrt temperature
     *
     *  \f[
     *   \bar s_k(T,P) = s^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
     *                              - R \ln( \gamma_k X_k)
     *                              - R T \frac{d \ln(\gamma_k) }{dT}
     *  \f]
     *
     * @param sbar  Vector of returned partial molar entropies
     *              (length m_kk, units = J/kmol/K)
     */
    virtual void getPartialMolarEntropies(doublereal* sbar) const;

    //! Returns an array of partial molar entropies for the species
    //! in the mixture.
    /*!
     * Units (J/kmol)
     *
     * For this phase, the partial molar enthalpies are equal to the
     * standard state enthalpies modified by the derivative of the
     * activity coefficient wrt temperature
     *
     *  \f[
     *   ???????????????
     *   \bar s_k(T,P) = s^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
     *                              - R \ln( \gamma_k X_k)
     *                              - R T \frac{d \ln(\gamma_k) }{dT}
     *   ???????????????
     *  \f]
     *
     * @param cpbar  Vector of returned partial molar heat capacities
     *              (length m_kk, units = J/kmol/K)
     */
    virtual void getPartialMolarCp(doublereal* cpbar) const;

    //! Return an array of partial molar volumes for the
    //! species in the mixture. Units: m^3/kmol.
    /*!
     *  Frequently, for this class of thermodynamics representations,
     *  the excess Volume due to mixing is zero. Here, we set it as
     *  a default. It may be overridden in derived classes.
     *
     *  @param vbar   Output vector of species partial molar volumes.
     *                Length = m_kk. units are m^3/kmol.
     */
    virtual void getPartialMolarVolumes(doublereal* vbar) const;

    //@}

    //! Calculate pseudo binary mole fractions
    virtual void calcPseudoBinaryMoleFractions() const;

    /// @name Initialization
    /// The following methods are used in the process of constructing
    /// the phase and setting its parameters from a specification in an
    /// input file. They are not normally used in application programs.
    /// To see how they are used, see importPhase().
    /// @{

    /*!
     * @internal Initialize. This method is provided to allow
     * subclasses to perform any initialization required after all
     * species have been added. For example, it might be used to
     * resize internal work arrays that must have an entry for
     * each species.  The base class implementation does nothing,
     * and subclasses that do not require initialization do not
     * need to overload this method.  When importing a CTML phase
     * description, this method is called just prior to returning
     * from function importPhase().
     */
    virtual void initThermo();

    /**
     *   Import and initialize a ThermoPhase object
     *
     * @param phaseNode This object must be the phase node of a
     *             complete XML tree
     *             description of the phase, including all of the
     *             species data. In other words while "phase" must
     *             point to an XML phase object, it must have
     *             sibling nodes "speciesData" that describe
     *             the species in the phase.
     * @param id   ID of the phase. If nonnull, a check is done
     *             to see if phaseNode is pointing to the phase
     *             with the correct id.
     */
    void initThermoXML(XML_Node& phaseNode, const std::string& id);
    //! @}

    //! returns a summary of the state of the phase as a string
    /*!
     * @param show_thermo If true, extra information is printed out
     *                    about the thermodynamic state of the system.
     * @param threshold   Show information about species with mole fractions
     *                    greater than *threshold*.
     */
    virtual std::string report(bool show_thermo=true,
                               doublereal threshold=1e-14) const;

private:
    //! Initialize lengths of local variables after all species have been identified.
    void initLengths();

    //! Process an XML node called "binaryNeutralSpeciesParameters"
    /*!
     * This node contains all of the parameters necessary to describe
     * the Redlich-Kister model for a particular binary interaction.
     * This function reads the XML file and writes the coefficients
     * it finds to an internal data structures.
     *
     * @param xmlBinarySpecies  Reference to the XML_Node named "binaryNeutralSpeciesParameters"
     *                          containing the binary interaction
     */
    void readXMLBinarySpecies(XML_Node& xmlBinarySpecies);

    //! Update the activity coefficients
    /*!
     * This function will be called to update the internally stored
     * natural logarithm of the activity coefficients
     */
    void s_update_lnActCoeff() const;

    //! Update the derivative of the log of the activity coefficients wrt T
    /*!
     * This function will be called to update the internally stored
     * derivative of the natural logarithm of the activity coefficients
     * wrt temperature.
     */
    void s_update_dlnActCoeff_dT() const;

    //! Internal routine that calculates the derivative of the activity coefficients wrt
    //! the mole fractions.
    /*!
     *  This routine calculates the the derivative of the activity coefficients wrt to mole fraction
     *  with all other mole fractions held constant. This is strictly not permitted. However, if the
     *  resulting matrix is multiplied by a permissible deltaX vector then everything is ok.
     *
     *  This is the natural way to handle concentration derivatives in this routine.
     */
    void s_update_dlnActCoeff_dX_() const;

protected:
    // Pseudobinary type
    /*!
     *  - `PBTYPE_PASSTHROUGH` - All species are passthrough species
     *  - `PBTYPE_SINGLEANION` - there is only one anion in the mixture
     *  - `PBTYPE_SINGLECATION` - there is only one cation in the mixture
     *  - `PBTYPE_MULTICATIONANION` - Complex mixture
     */
    int PBType_;

    //! Number of pseudo binary species
    size_t numPBSpecies_;

    //! index of special species
    size_t indexSpecialSpecies_;

    mutable vector_fp PBMoleFractions_;

    //! Vector of cation indices in the mixture
    std::vector<size_t> cationList_;

    std::vector<size_t> anionList_;

    std::vector<size_t> passThroughList_;
    size_t neutralPBindexStart;

    mutable vector_fp moleFractionsTmp_;
};

#define PBTYPE_PASSTHROUGH 0
#define PBTYPE_SINGLEANION 1
#define PBTYPE_SINGLECATION 2
#define PBTYPE_MULTICATIONANION 3

}

#endif


text:
@echo off
echo +++
echo +++ building %*+++
echo +++

setlocal ENABLEEXTENSIONS

set PLATFORM=%1
set CONFIG=%2
set OutDir=%3
set VCInstallDir=%4
set ProjectDir=%5
set SolutionDir=%6
set Action=%7

echo +++ PLATFORM     = %PLATFORM%
echo +++ CONFIG       = %CONFIG%
echo +++ OutDir       = %OutDir%
echo +++ VCInstallDir = %VCInstallDir%
echo +++ ProjectDir   = %ProjectDir%
echo +++ SolutionDir  = %SolutionDir%
echo +++ Action       = %Action%
echo +++
echo.

@echo on
cd %PROJECTDIR%..\..\..\openssl
set BUILD=0
if %ACTION% == rebuild set BUILD=build
if NOT EXIST %SolutionDir%bin\%PLATFORM%\%CONFIG%\ssleay32.lib set BUILD=build
if NOT EXIST %SolutionDir%bin\%PLATFORM%\%CONFIG%\libeay32.lib set BUILD=build
if %BUILD% == 0 GOTO POSTPROCESS

set SHARED=shared
if %CONFIG% == Debug     set SHARED=no-shared
if %CONFIG% == Release   set SHARED=no-shared

if NOT EXIST                 %SolutionDir%bin\%PLATFORM%\%CONFIG%\           mkdir %SolutionDir%bin\%PLATFORM%\%CONFIG%\

                      copy/y %ProjectDir%..\openssl\%PLATFORM%\%CONFIG%\lib\*.lib  %SolutionDir%bin\%PLATFORM%\%CONFIG%\
if %SHARED% == shared copy/y %ProjectDir%..\openssl\%PLATFORM%\%CONFIG%\bin\*.dll  %SolutionDir%bin\%PLATFORM%\%CONFIG%\

:POSTPROCESS

set ERRORLEVEL=0
echo OK
goto EOF

:ERROR
set ERRORLEVEL=911

:EOF
rem That's all Folks
rem ----------------

redpajama_set_name: RedPajamaGithub


text:
<?php
namespace Helloworld\Controller;

use Zend\Mvc\Controller\AbstractRestfulController;
use Zend\View\Model\JsonModel;

class ProductController extends AbstractRestfulController
{
    private $products = array(
        array(
            'name' => 'Boxfresh SPARKO 4 Sneaker',
            'price' => 84.95
        ),
        array(
            'name' => 'adidas Originals Samba',
            'price' => 64.95
        )
    );

    public function getList()
    {
        return new JsonModel(
            $this->products
        );
    }

	public function get($id)
    {
	    // [..]
    }

	public function create($data)
    {
        // [..]
    }

	public function update($id, $data)
    {
        // [..]
    }

	public function delete($id)
    {
        // [..]
    }
}


text:
<resources>
    <string name="app_name">ZhiHuDaily</string>
</resources>


text:
// 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.

import { Field } from '../schema.js';
import { DataBufferBuilder } from './buffer.js';
import { Builder, BuilderOptions } from '../builder.js';
import { Union, SparseUnion, DenseUnion } from '../type.js';

export interface UnionBuilderOptions<T extends Union = any, TNull = any> extends BuilderOptions<T, TNull> {
    valueToChildTypeId?: (builder: UnionBuilder<T, TNull>, value: any, offset: number) => number;
}

/** @ignore */
export abstract class UnionBuilder<T extends Union, TNull = any> extends Builder<T, TNull> {

    protected _typeIds: DataBufferBuilder<Int8Array>;

    constructor(options: UnionBuilderOptions<T, TNull>) {
        super(options);
        this._typeIds = new DataBufferBuilder(new Int8Array(0), 1);
        if (typeof options['valueToChildTypeId'] === 'function') {
            this._valueToChildTypeId = options['valueToChildTypeId'];
        }
    }

    public get typeIdToChildIndex() { return this.type.typeIdToChildIndex; }

    public append(value: T['TValue'] | TNull, childTypeId?: number) {
        return this.set(this.length, value, childTypeId);
    }

    public set(index: number, value: T['TValue'] | TNull, childTypeId?: number) {
        if (childTypeId === undefined) {
            childTypeId = this._valueToChildTypeId(this, value, index);
        }
        if (this.setValid(index, this.isValid(value))) {
            this.setValue(index, value, childTypeId);
        }
        return this;
    }

    public setValue(index: number, value: T['TValue'], childTypeId?: number) {
        this._typeIds.set(index, childTypeId!);
        const childIndex = this.type.typeIdToChildIndex[childTypeId!];
        const child = this.children[childIndex];
        child?.set(index, value);
    }

    public addChild(child: Builder, name = `${this.children.length}`) {
        const childTypeId = this.children.push(child);
        const { type: { children, mode, typeIds } } = this;
        const fields = [...children, new Field(name, child.type)];
        this.type = <T>new Union(mode, [...typeIds, childTypeId], fields);
        return childTypeId;
    }

    /** @ignore */
    // @ts-ignore
    protected _valueToChildTypeId(builder: UnionBuilder<T, TNull>, value: any, offset: number): number {
        throw new Error(`Cannot map UnionBuilder value to child typeId. \
Pass the \`childTypeId\` as the second argument to unionBuilder.append(), \
or supply a \`valueToChildTypeId\` function as part of the UnionBuilder constructor options.`);
    }
}

/** @ignore */
export class SparseUnionBuilder<T extends SparseUnion, TNull = any> extends UnionBuilder<T, TNull> { }
/** @ignore */
export class DenseUnionBuilder<T extends DenseUnion, TNull = any> extends UnionBuilder<T, TNull> {

    protected _offsets: DataBufferBuilder<Int32Array>;

    constructor(options: UnionBuilderOptions<T, TNull>) {
        super(options);
        this._offsets = new DataBufferBuilder(new Int32Array(0));
    }

    /** @ignore */
    public setValue(index: number, value: T['TValue'], childTypeId?: number) {
        const id = this._typeIds.set(index, childTypeId!).buffer[index];
        const child = this.getChildAt(this.type.typeIdToChildIndex[id])!;
        const denseIndex = this._offsets.set(index, child.length).buffer[index];
        child?.set(denseIndex, value);
    }
}


text:
namespace caffe2 {

template <typename C>
void get_back_mean_tensor(const Tensor<C>& tensor, Tensor<C>& mean, int count) {
  auto dims = tensor.dims();
  auto size = 1;
  while (count--) {
    size *= dims.back();
    dims.pop_back();
  }
  mean.Resize(dims);
  auto data = tensor.template data<float>();
  auto mean_data = mean.template mutable_data<float>();
  auto mean_end = mean_data + mean.size();
  for (auto e = data + tensor.size(); data != e && mean_data != mean_end;
       mean_data++) {
    auto sum = 0.f;
    for (auto g = data + size; data != g; data++) {
      sum += *data;
    }
    *mean_data = sum / size;
  }
}

template <typename C>
void set_back_mean_tensor(Tensor<C>& tensor, const Tensor<C>& mean, int count) {
  auto dims = tensor.dims();
  auto size = 1;
  while (count--) {
    size *= dims.back();
    dims.pop_back();
  }
  auto data = tensor.template mutable_data<float>();
  auto mean_data = mean.template data<float>();
  auto mean_end = mean_data + mean.size();
  for (auto e = data + tensor.size(); data != e && mean_data != mean_end;
       mean_data++) {
    auto d = *mean_data / size;
    for (auto g = data + size; data != g; data++) {
      *data = d;
    }
  }
}

template <>
bool BackMeanOp<float, CPUContext>::RunOnDevice() {
  auto& X = Input(0);
  auto* Y = Output(0);
  get_back_mean_tensor(X, *Y, count_);
  return true;
}

template <>
bool BackMeanGradientOp<float, CPUContext>::RunOnDevice() {
  auto& X = Input(0);
  auto& dY = Input(1);
  auto* dX = Output(0);
  dX->ResizeLike(X);
  set_back_mean_tensor(*dX, dY, count_);
  return true;
}

REGISTER_CPU_OPERATOR(BackMean, BackMeanOp<float, CPUContext>);
REGISTER_CPU_OPERATOR(BackMeanGradient, BackMeanGradientOp<float, CPUContext>);

OPERATOR_SCHEMA(BackMean)
    .NumInputs(1)
    .NumOutputs(1)
    .SetDoc(R"DOC(
The operator takes the mean values over the last dimensions.
)DOC")
    .Arg("count", "Number of dimensions to reduce")
    .Input(0, "input", "The input data as N-D Tensor<float>.")
    .Output(0, "output", "The mean values in a (N-count)-D Tensor.");

OPERATOR_SCHEMA(BackMeanGradient).NumInputs(2).NumOutputs(1);

class GetBackMeanGradient : public GradientMakerBase {
  using GradientMakerBase::GradientMakerBase;
  vector<OperatorDef> GetGradientDefs() override {
    return SingleGradientDef(def_.type() + "Gradient", "",
                             vector<string>{I(0), GO(0)},
                             vector<string>{GI(0)});
  }
};
REGISTER_GRADIENT(BackMean, GetBackMeanGradient);

}  // namespace caffe2


text:
package com.aelns.core.utils.concurrent.threadpool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;

import org.apache.commons.lang3.Validate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.aelns.core.utils.base.annotation.NotNull;
import com.aelns.core.utils.base.annotation.Nullable;

import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.ThreadFactoryBuilder;

/**
 * 线程池工具集
 *
 * 1. 优雅关闭线程池的(via guava)
 *
 * 2. 创建可自定义线程名的ThreadFactory(via guava)
 *
 * 3. 防止第三方Runnable未捕捉异常导致线程跑飞
 *
 * @author calvin
 *
 */
public class ThreadPoolUtil {

	/**
	 * 按照ExecutorService JavaDoc示例代码编写的Graceful Shutdown方法.
	 *
	 * 先使用shutdown, 停止接收新任务并尝试完成所有已存在任务.
	 *
	 * 如果1/2超时时间后, 则调用shutdownNow,取消在workQueue中Pending的任务,并中断所有阻塞函数.
	 *
	 * 如果1/2超时仍然超時,則強制退出.
	 *
	 * 另对在shutdown时线程本身被调用中断做了处理.
	 *
	 * 返回线程最后是否被中断.
	 *
	 * 使用了Guava的工具类
	 * @see MoreExecutors#shutdownAndAwaitTermination(ExecutorService, long, TimeUnit)
	 */
	public static boolean gracefulShutdown(@Nullable ExecutorService threadPool, int shutdownTimeoutMills) {
		return threadPool != null
				? MoreExecutors.shutdownAndAwaitTermination(threadPool, shutdownTimeoutMills, TimeUnit.MILLISECONDS)
				: true;
	}

	/**
	 * @see gracefulShutdown
	 */
	public static boolean gracefulShutdown(@Nullable ExecutorService threadPool, int shutdownTimeout,
			TimeUnit timeUnit) {
		return threadPool != null ? MoreExecutors.shutdownAndAwaitTermination(threadPool, shutdownTimeout, timeUnit)
				: true;
	}

	/**
	 * 创建ThreadFactory,使得创建的线程有自己的名字而不是默认的"pool-x-thread-y"
	 *
	 * 使用了Guava的工具类
	 *
	 * @see ThreadFactoryBuilder#build()
	 */
	public static ThreadFactory buildThreadFactory(@NotNull String threadNamePrefix) {
		return new ThreadFactoryBuilder().setNameFormat(threadNamePrefix + "-%d").build();
	}

	/**
	 * 可设定是否daemon, daemon线程在主线程已执行完毕时, 不会阻塞应用不退出, 而非daemon线程则会阻塞.
	 *
	 * @see buildThreadFactory
	 */
	public static ThreadFactory buildThreadFactory(@NotNull String threadNamePrefix, @NotNull boolean daemon) {
		return new ThreadFactoryBuilder().setNameFormat(threadNamePrefix + "-%d").setDaemon(daemon).build();
	}

	/**
	 * 防止用户没有捕捉异常导致中断了线程池中的线程, 使得SchedulerService无法继续执行.
	 *
	 * 在无法控制第三方包的Runnable实现时,调用本函数进行包裹.
	 */
	public static Runnable safeRunnable(@NotNull Runnable runnable) {
		return new SafeRunnable(runnable);
	}

	/**
	 * 保证不会有Exception抛出到线程池的Runnable包裹类,防止用户没有捕捉异常导致中断了线程池中的线程, 使得SchedulerService无法执行. 在无法控制第三方包的Runnalbe实现时,使用本类进行包裹.
	 */
	public static class SafeRunnable implements Runnable {

		private static Logger logger = LoggerFactory.getLogger(SafeRunnable.class);

		private Runnable runnable;

		public SafeRunnable(Runnable runnable) {
			Validate.notNull(runnable);
			this.runnable = runnable;
		}

		@Override
		public void run() {
			try {
				runnable.run();
			} catch (Throwable e) {
				// catch any exception, because the scheduled thread will break if the exception thrown to outside.
				logger.error("Unexpected error occurred in task", e);
			}
		}
	}
}


text:
package org.apereo.cas.web.flow;

import org.apereo.cas.api.PasswordlessUserAccountStore;
import org.apereo.cas.web.support.WebUtils;

import lombok.val;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletContext;
import org.springframework.test.context.TestPropertySource;
import org.springframework.webflow.context.servlet.ServletExternalContext;
import org.springframework.webflow.core.collection.LocalAttributeMap;
import org.springframework.webflow.execution.Action;
import org.springframework.webflow.execution.Event;
import org.springframework.webflow.test.MockRequestContext;

import static org.junit.jupiter.api.Assertions.*;

/**
 * This is {@link DisplayBeforePasswordlessAuthenticationActionTests}.
 *
 * @author Misagh Moayyed
 * @since 5.3.0
 */
@TestPropertySource(properties = "cas.authn.passwordless.accounts.groovy.location=classpath:PasswordlessAccount.groovy")
public class DisplayBeforePasswordlessAuthenticationActionTests extends BasePasswordlessAuthenticationActionTests {
    @Autowired
    @Qualifier("displayBeforePasswordlessAuthenticationAction")
    private Action displayBeforePasswordlessAuthenticationAction;

    @Autowired
    @Qualifier("passwordlessUserAccountStore")
    private PasswordlessUserAccountStore passwordlessUserAccountStore;

    @Test
    public void verifyAction() throws Exception {
        val context = new MockRequestContext();
        context.setCurrentEvent(new Event(this, "processing"));
        val request = new MockHttpServletRequest();
        context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
        request.addParameter("username", "casuser");
        assertEquals("success", displayBeforePasswordlessAuthenticationAction.execute(context).getId());
    }

    @Test
    public void verifyError() throws Exception {
        val context = new MockRequestContext();
        val attributes = new LocalAttributeMap("error", new IllegalArgumentException("Bad account"));
        context.setCurrentEvent(new Event(this, "processing", attributes));
        val request = new MockHttpServletRequest();
        context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
        WebUtils.putPasswordlessAuthenticationAccount(context, passwordlessUserAccountStore.findUser("casuser").get());
        assertEquals("success", displayBeforePasswordlessAuthenticationAction.execute(context).getId());
    }
}


text:
#include <iostream>
#include <string>
#include <vector>


text:
import './bootstrap.js';

import Echo from 'laravel-echo';
import Vue from 'vue';

import CurrentTime from './components/CurrentTime';
import GithubFile from './components/GithubFile';
import GoogleCalendar from './components/GoogleCalendar';
import InternetConnection from './components/InternetConnection';
import LastFm from './components/LastFm';
import RainForecast from './components/RainForecast';
import PackagistStatistics from './components/PackagistStatistics';

new Vue({

    el: '#dashboard',

    components: {
        CurrentTime,
        GithubFile,
        GoogleCalendar,
        InternetConnection,
        LastFm,
        RainForecast,
        PackagistStatistics
    },

    created() {
        this.echo = new Echo({
            broadcaster: 'pusher',
            key: window.pusherKey,
        });
    },
});


text:
module Lolita
  module Extensions
    module Authentication

      class DefaultAdapter
        def initialize context, options={}
        end

        def current_user
          nil
        end

        def user_signed_in?
          false
        end

        def authenticate_user!
          true
        end
      end

    end
  end
end


text:
//MIT, 2015-present, brezza92, EngineKit and contributors

using System;
using System.Collections.Generic;
namespace SharpConnect.MySql.Internal
{
    static class ConnectionPool
    {
        static readonly ConnectionPoolAgent s_connPoolAgent = new ConnectionPoolAgent();
        static readonly object s_queueLock = new object();
        public static Connection GetConnection(MySqlConnectionString connstr)
        {
            lock (s_queueLock)
            {
                return s_connPoolAgent.GetConnection(connstr);
            }
        }
        public static void ReleaseConnection(MySqlConnectionString connstr, Connection conn)
        {
            lock (s_queueLock)
            {
                s_connPoolAgent.ReleaseConnection(connstr, conn);
            }
        }
        public static void ClearConnectionPool()
        {
            lock (s_queueLock)
            {
                s_connPoolAgent.ClearAllConnections();
            }
        }

        class ConnectionPoolAgent : IDisposable
        {
            static Dictionary<int, Queue<Connection>> s_connQueue = new Dictionary<int, Queue<Connection>>();
            static readonly object s_connLock = new object();

            public ConnectionPoolAgent()
            {
            }
            public void Dispose()
            {
                ClearAllConnections();
            }

            public void ClearAllConnections()
            {
                lock (s_connLock)
                {
                    foreach (var q in s_connQueue.Values)
                    {
                        for (int i = s_connQueue.Count - 1; i >= 0; --i)
                        {
                            try
                            {
                                var conn = q.Dequeue();
                                conn.Disconnect();
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                    }
                    s_connQueue.Clear();
                }
            }
            public Connection GetConnection(MySqlConnectionString connstr)
            {
                lock (s_connLock)
                {

                    //not found
                    if (!s_connQueue.TryGetValue(connstr.ConnSignature, out Queue<Connection> found))
                    {
                        return null;
                    }

                    if (found.Count > 0)
                    {
                        Connection conn = found.Dequeue();
                        //TODO: check if conn is valid
                        conn.IsStoredInConnPool = false;
                        return conn.State == ConnectionState.Connected ? conn : null;
                    }
                    else
                    {
                        return null;
                    }
                }

            }
            public void ReleaseConnection(MySqlConnectionString connstr, Connection conn)
            {
                lock (s_connLock)
                {

                    //not found
                    if (!s_connQueue.TryGetValue(connstr.ConnSignature, out Queue<Connection> found))
                    {
                        found = new Queue<Connection>();
                        s_connQueue.Add(connstr.ConnSignature, found);
                    }
                    conn.IsStoredInConnPool = true;
                    found.Enqueue(conn);
                }
            }
        }
    }
}


text:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta charset="utf-8">

    <title>RLP's Blog - My Views On The Future</title>

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

    <link href="../css/default.css" rel="stylesheet">
    <link href="../css/foo.css" rel="stylesheet">

            RLP's Foo Blog

My Views On The Future

Article Info

Last Updated On February  1, 2016.

Originally Posted On November  1, 2015.

Posted in: futurism,
 psychology,
 transhumanism.

Recent Changes

001-title

                   (December 13, 2016)

About

RLP's Other Blogs

About & Contact

Archive

Summary / Recap

I try very hard here to make sure that I start only from things that a decently well-educated layperson already knows, and please do feel free to moo should I fail in that regard. But it's going to take more than one step, and I can't fix that. Please try not to assume I'm crazy ''only'' because the explanation is complicated.

Summary / Recap

So this post came out a tad longer than I intended.

In the recap (tests auto_identifiers)

In the recap (tests auto_identifiers and our header linking code)

some blocked
        cod
cod

(tests backtick_code_blocks )

Tests
Simple
Tables
Default

12
12
12
12

123
123
123
123

1
1
1
1

test_intraword_underscores yeah undescore-emph yeah

futurism (1)
 futurism+psychology (1)
 futurism+psychology+transhumanism (1)
 futurism+transhumanism (1)
 psychology (1)
 psychology+transhumanism (1)
 transhumanism (1)

Copyright © Robin Lee Powell 2020

Site proudly generated by
              Hakyll


text: <title></title>


text:
#include "PerformanceParticleTest.h"

enum {
    kTagInfoLayer = 1,
    kTagMainLayer = 2,
    kTagParticleSystem = 3,
    kTagLabelAtlas = 4,
    kTagMenuLayer = 1000,

    TEST_COUNT = 4,
};

enum {
    kMaxParticles = 14000,
    kNodesIncrease = 500,
};

static int s_nParCurIdx = 0;

////////////////////////////////////////////////////////
//
// ParticleMenuLayer
//
////////////////////////////////////////////////////////
ParticleMenuLayer::ParticleMenuLayer(bool bControlMenuVisible, int nMaxCases, int nCurCase)
: PerformBasicLayer(bControlMenuVisible, nMaxCases, nCurCase)
{

}

void ParticleMenuLayer::showCurrentTest()
{
    ParticleMainScene* pScene = (ParticleMainScene*)getParent();
    int subTest = pScene->getSubTestNum();
    int parNum  = pScene->getParticlesNum();

    ParticleMainScene* pNewScene = NULL;

    switch (m_nCurCase)
    {
    case 0:
        pNewScene = new ParticlePerformTest1;
        break;
    case 1:
        pNewScene = new ParticlePerformTest2;
        break;
    case 2:
        pNewScene = new ParticlePerformTest3;
        break;
    case 3:
        pNewScene = new ParticlePerformTest4;
        break;
    }

    s_nParCurIdx = m_nCurCase;
    if (pNewScene)
    {
        pNewScene->initWithSubTest(subTest, parNum);

        CCDirector::sharedDirector()->replaceScene(pNewScene);
        pNewScene->release();
    }
}

////////////////////////////////////////////////////////
//
// ParticleMainScene
//
////////////////////////////////////////////////////////
void ParticleMainScene::initWithSubTest(int asubtest, int particles)
{
    //sraScutom(0);

    subtestNumber = asubtest;
    CCSize s = CCDirector::sharedDirector()->getWinSize();

    lastRenderedCount = 0;
    quantityParticles = particles;

    CCMenuItemFont::setFontSize(65);
    CCMenuItemFont *decrease = CCMenuItemFont::create(" - ", this, menu_selector(ParticleMainScene::oScutecrease));
    decrease->setColor(ccc3(0,200,20));
    CCMenuItemFont *increase = CCMenuItemFont::create(" + ", this, menu_selector(ParticleMainScene::onIncrease));
    increase->setColor(ccc3(0,200,20));

    CCMenu *menu = CCMenu::create(decrease, increase, NULL);
    menu->alignItemsHorizontally();
    menu->setPosition(ccp(s.width/2, s.height/2+15));
    addChild(menu, 1);

    CCLabelTTF *infoLabel = CCLabelTTF::create("0 nodes", "Marker Felt", 30);
    infoLabel->setColor(ccc3(0,200,20));
    infoLabel->setPosition(ccp(s.width/2, s.height - 90));
    addChild(infoLabel, 1, kTagInfoLayer);

    // particles on stage
    CCLabelAtlas *labelAtlas = CCLabelAtlas::create("0000", "fps_images.png", 12, 32, '.');
    addChild(labelAtlas, 0, kTagLabelAtlas);
    labelAtlas->setPosition(ccp(s.width-66,50));

    // Next Prev Test
    ParticleMenuLayer* pMenu = new ParticleMenuLayer(true, TEST_COUNT, s_nParCurIdx);
    addChild(pMenu, 1, kTagMenuLayer);
    pMenu->release();

    // Sub Tests
    CCMenuItemFont::setFontSize(40);
    CCMenu* pSubMenu = CCMenu::create();
    for (int i = 1; i <= 6; ++i)
    {
        char str[10] = {0};
        sprintf(str, "%d ", i);
        CCMenuItemFont* itemFont = CCMenuItemFont::create(str, this, menu_selector(ParticleMainScene::testNCallback));
        itemFont->setTag(i);
        pSubMenu->addChild(itemFont, 10);

        if (i <= 3)
        {
            itemFont->setColor(ccc3(200,20,20));
        }
        else
        {
            itemFont->setColor(ccc3(0,200,20));
        }
    }
    pSubMenu->alignItemsHorizontally();
    pSubMenu->setPosition(ccp(s.width/2, 80));
    addChild(pSubMenu, 2);

    CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 40);
    addChild(label, 1);
    label->setPosition(ccp(s.width/2, s.height-32));
    label->setColor(ccc3(255,255,40));

    updateQuantityLabel();
    createParticleSystem();

    schedule(schedule_selector(ParticleMainScene::step));
}

std::string ParticleMainScene::title()
{
    return "No title";
}

void ParticleMainScene::step(float dt)
{
    CCLabelAtlas *atlas = (CCLabelAtlas*) getChildByTag(kTagLabelAtlas);
    CCParticleSystem *emitter = (CCParticleSystem*) getChildByTag(kTagParticleSystem);

    char str[10] = {0};
    sprintf(str, "%4d", emitter->getParticleCount());
    atlas->setString(str);
}

void ParticleMainScene::createParticleSystem()
{
    CCParticleSystem *particleSystem = NULL;

    /*
    * Tests:
    * 1: Point Particle System using 32-bit textures (PNG)
    * 2: Point Particle System using 16-bit textures (PNG)
    * 3: Point Particle System using 8-bit textures (PNG)
    * 4: Point Particle System using 4-bit textures (PVRTC)

    * 5: Quad Particle System using 32-bit textures (PNG)
    * 6: Quad Particle System using 16-bit textures (PNG)
    * 7: Quad Particle System using 8-bit textures (PNG)
    * 8: Quad Particle System using 4-bit textures (PVRTC)
    */
    removeChildByTag(kTagParticleSystem, true);

    // remove the "fire.png" from the TextureCache cache.
    CCTexture2D *texture = CCTextureCache::sharedTextureCache()->addImage("Images/fire.png");
    CCTextureCache::sharedTextureCache()->removeTexture(texture);

//TODO:     if (subtestNumber <= 3)
//     {
//         particleSystem = new CCParticleSystemPoint();
//     }
//     else
    {
        particleSystem = new CCParticleSystemQuad();
    }

    switch( subtestNumber)
    {
    case 1:
        CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888);
        particleSystem->initWithTotalParticles(quantityParticles);
        particleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png"));
        break;
    case 2:
        CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444);
        particleSystem->initWithTotalParticles(quantityParticles);
        particleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png"));
        break;
    case 3:
        CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_A8);
        particleSystem->initWithTotalParticles(quantityParticles);
        particleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png"));
        break;
//     case 4:
//         particleSystem->initWithTotalParticles(quantityParticles);
//         ////---- particleSystem.texture = [[CCTextureCache sharedTextureCache] addImage:@"fire.pvr"];
//         particleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png"));
//         break;
    case 4:
        CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888);
        particleSystem->initWithTotalParticles(quantityParticles);
        particleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png"));
        break;
    case 5:
        CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444);
        particleSystem->initWithTotalParticles(quantityParticles);
        particleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png"));
        break;
    case 6:
        CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_A8);
        particleSystem->initWithTotalParticles(quantityParticles);
        particleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png"));
        break;
//     case 8:
//         particleSystem->initWithTotalParticles(quantityParticles);
//         ////---- particleSystem.texture = [[CCTextureCache sharedTextureCache] addImage:@"fire.pvr"];
//         particleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png"));
//         break;
    default:
        particleSystem = NULL;
        CCLOG("Shall not happen!");
        break;
    }
    addChild(particleSystem, 0, kTagParticleSystem);
    particleSystem->release();

    doTest();

    // restore the default pixel format
    CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888);
}

void ParticleMainScene::testNCallback(CCObject* pSender)
{
    subtestNumber = ((CCNode*)pSender)->getTag();

    ParticleMenuLayer* pMenu = (ParticleMenuLayer*)getChildByTag(kTagMenuLayer);
    pMenu->restartCallback(pSender);
}

void ParticleMainScene::onIncrease(CCObject* pSender)
{
    quantityParticles += kNodesIncrease;
    if( quantityParticles > kMaxParticles )
        quantityParticles = kMaxParticles;

    updateQuantityLabel();
    createParticleSystem();
}

void ParticleMainScene::oScutecrease(CCObject* pSender)
{
    quantityParticles -= kNodesIncrease;
    if( quantityParticles < 0 )
        quantityParticles = 0;

    updateQuantityLabel();
    createParticleSystem();
}

void ParticleMainScene::updateQuantityLabel()
{
    if( quantityParticles != lastRenderedCount )
    {
        CCLabelTTF *infoLabel = (CCLabelTTF *) getChildByTag(kTagInfoLayer);
        char str[20] = {0};
        sprintf(str, "%u particles", quantityParticles);
        infoLabel->setString(str);

        lastRenderedCount = quantityParticles;
    }
}

////////////////////////////////////////////////////////
//
// ParticlePerformTest1
//
////////////////////////////////////////////////////////
std::string ParticlePerformTest1::title()
{
    char str[20] = {0};
    sprintf(str, "A (%d) size=4", subtestNumber);
    std::string strRet = str;
    return strRet;
}

void ParticlePerformTest1::doTest()
{
    CCSize s = CCDirector::sharedDirector()->getWinSize();
    CCParticleSystem *particleSystem = (CCParticleSystem*)getChildByTag(kTagParticleSystem);

    // duration
    particleSystem->setDuration(-1);

    // gravity
    particleSystem->setGravity(ccp(0,-90));

    // angle
    particleSystem->setAngle(90);
    particleSystem->setAngleVar(0);

    // radial
    particleSystem->setRadialAccel(0);
    particleSystem->setRadialAccelVar(0);

    // speed of particles
    particleSystem->setSpeed(180);
    particleSystem->setSpeedVar(50);

    // emitter position
    particleSystem->setPosition(ccp(s.width/2, 100));
    particleSystem->setPosVar(ccp(s.width/2,0));

    // life of particles
    particleSystem->setLife(2.0f);
    particleSystem->setLifeVar(1);

    // emits per frame
    particleSystem->setEmissionRate(particleSystem->getTotalParticles() /particleSystem->getLife());

    // color of particles
    ccColor4F startColor = {0.5f, 0.5f, 0.5f, 1.0f};
    particleSystem->setStartColor(startColor);

    ccColor4F startColorVar = {0.5f, 0.5f, 0.5f, 1.0f};
    particleSystem->setStartColorVar( startColorVar);

    ccColor4F endColor = {0.1f, 0.1f, 0.1f, 0.2f};
    particleSystem->setendColor(endColor);

    ccColor4F endColorVar = {0.1f, 0.1f, 0.1f, 0.2f};
    particleSystem->setendColorVar(endColorVar);

    // size, in pixels
    particleSystem->setendSize(4.0f);
    particleSystem->setStartSize(4.0f);
    particleSystem->setendSizeVar(0);
    particleSystem->setStartSizeVar(0);

    // additive
    particleSystem->setBlendAdditive(false);
}

////////////////////////////////////////////////////////
//
// ParticlePerformTest2
//
////////////////////////////////////////////////////////
std::string ParticlePerformTest2::title()
{
    char str[20] = {0};
    sprintf(str, "B (%d) size=8", subtestNumber);
    std::string strRet = str;
    return strRet;
}

void ParticlePerformTest2::doTest()
{
    CCSize s = CCDirector::sharedDirector()->getWinSize();
    CCParticleSystem *particleSystem = (CCParticleSystem*) getChildByTag(kTagParticleSystem);

    // duration
    particleSystem->setDuration(-1);

    // gravity
    particleSystem->setGravity(ccp(0,-90));

    // angle
    particleSystem->setAngle(90);
    particleSystem->setAngleVar(0);

    // radial
    particleSystem->setRadialAccel(0);
    particleSystem->setRadialAccelVar(0);

    // speed of particles
    particleSystem->setSpeed(180);
    particleSystem->setSpeedVar(50);

    // emitter position
    particleSystem->setPosition(ccp(s.width/2, 100));
    particleSystem->setPosVar(ccp(s.width/2,0));

    // life of particles
    particleSystem->setLife(2.0f);
    particleSystem->setLifeVar(1);

    // emits per frame
    particleSystem->setEmissionRate(particleSystem->getTotalParticles() / particleSystem->getLife());

    // color of particles
    ccColor4F startColor = {0.5f, 0.5f, 0.5f, 1.0f};
    particleSystem->setStartColor(startColor);

    ccColor4F startColorVar = {0.5f, 0.5f, 0.5f, 1.0f};
    particleSystem->setStartColorVar(startColorVar);

    ccColor4F endColor = {0.1f, 0.1f, 0.1f, 0.2f};
    particleSystem->setendColor(endColor);

    ccColor4F endColorVar = {0.1f, 0.1f, 0.1f, 0.2f};
    particleSystem->setendColorVar(endColorVar);

    // size, in pixels
    particleSystem->setendSize(8.0f);
    particleSystem->setStartSize(8.0f);
    particleSystem->setendSizeVar(0);
    particleSystem->setStartSizeVar(0);

    // additive
    particleSystem->setBlendAdditive(false);
}

////////////////////////////////////////////////////////
//
// ParticlePerformTest3
//
////////////////////////////////////////////////////////
std::string ParticlePerformTest3::title()
{
    char str[20] = {0};
    sprintf(str, "C (%d) size=32", subtestNumber);
    std::string strRet = str;
    return strRet;
}

void ParticlePerformTest3::doTest()
{
    CCSize s = CCDirector::sharedDirector()->getWinSize();
    CCParticleSystem *particleSystem = (CCParticleSystem*)getChildByTag(kTagParticleSystem);

    // duration
    particleSystem->setDuration(-1);

    // gravity
    particleSystem->setGravity(ccp(0,-90));

    // angle
    particleSystem->setAngle(90);
    particleSystem->setAngleVar(0);

    // radial
    particleSystem->setRadialAccel(0);
    particleSystem->setRadialAccelVar(0);

    // speed of particles
    particleSystem->setSpeed(180);
    particleSystem->setSpeedVar(50);

    // emitter position
    particleSystem->setPosition(ccp(s.width/2, 100));
    particleSystem->setPosVar(ccp(s.width/2,0));

    // life of particles
    particleSystem->setLife(2.0f);
    particleSystem->setLifeVar(1);

    // emits per frame
    particleSystem->setEmissionRate(particleSystem->getTotalParticles() / particleSystem->getLife());

    // color of particles
    ccColor4F startColor = {0.5f, 0.5f, 0.5f, 1.0f};
    particleSystem->setStartColor(startColor);

    ccColor4F startColorVar = {0.5f, 0.5f, 0.5f, 1.0f};
    particleSystem->setStartColorVar(startColorVar);

    ccColor4F endColor = {0.1f, 0.1f, 0.1f, 0.2f};
    particleSystem->setendColor(endColor);

    ccColor4F endColorVar = {0.1f, 0.1f, 0.1f, 0.2f};
    particleSystem->setendColorVar(endColorVar);

    // size, in pixels
    particleSystem->setendSize(32.0f);
    particleSystem->setStartSize(32.0f);
    particleSystem->setendSizeVar(0);
    particleSystem->setStartSizeVar(0);

    // additive
    particleSystem->setBlendAdditive(false);
}

////////////////////////////////////////////////////////
//
// ParticlePerformTest4
//
////////////////////////////////////////////////////////
std::string ParticlePerformTest4::title()
{
    char str[20] = {0};
    sprintf(str, "D (%d) size=64", subtestNumber);
    std::string strRet = str;
    return strRet;
}

void ParticlePerformTest4::doTest()
{
    CCSize s = CCDirector::sharedDirector()->getWinSize();
    CCParticleSystem *particleSystem = (CCParticleSystem*) getChildByTag(kTagParticleSystem);

    // duration
    particleSystem->setDuration(-1);

    // gravity
    particleSystem->setGravity(ccp(0,-90));

    // angle
    particleSystem->setAngle(90);
    particleSystem->setAngleVar(0);

    // radial
    particleSystem->setRadialAccel(0);
    particleSystem->setRadialAccelVar(0);

    // speed of particles
    particleSystem->setSpeed(180);
    particleSystem->setSpeedVar(50);

    // emitter position
    particleSystem->setPosition(ccp(s.width/2, 100));
    particleSystem->setPosVar(ccp(s.width/2,0));

    // life of particles
    particleSystem->setLife(2.0f);
    particleSystem->setLifeVar(1);

    // emits per frame
    particleSystem->setEmissionRate(particleSystem->getTotalParticles() / particleSystem->getLife());

    // color of particles
    ccColor4F startColor = {0.5f, 0.5f, 0.5f, 1.0f};
    particleSystem->setStartColor(startColor);

    ccColor4F startColorVar = {0.5f, 0.5f, 0.5f, 1.0f};
    particleSystem->setStartColorVar(startColorVar);

    ccColor4F endColor = {0.1f, 0.1f, 0.1f, 0.2f};
    particleSystem->setendColor(endColor);

    ccColor4F endColorVar = {0.1f, 0.1f, 0.1f, 0.2f};
    particleSystem->setendColorVar(endColorVar);

    // size, in pixels
    particleSystem->setendSize(64.0f);
    particleSystem->setStartSize(64.0f);
    particleSystem->setendSizeVar(0);
    particleSystem->setStartSizeVar(0);

    // additive
    particleSystem->setBlendAdditive(false);

}

void runParticleTest()
{
    ParticleMainScene* pScene = new ParticlePerformTest1;
    pScene->initWithSubTest(1, kNodesIncrease);

    CCDirector::sharedDirector()->replaceScene(pScene);
    pScene->release();
}


text:
    <?php
    /*
                    CODIGO DE VALIDAÇÕES
     */

     $this->load->library('form_validation');

    if(validation_errors() !=NULL){        //se tiver erros na validação mostrar essa parada aki
        echo "
";
	echo "
 ";

         if(isset($mensagens)) echo $mensagens;
	echo "
";
    }

    ?>

NOVA CAPACITAÇÃO REALIZADA

        <link rel="stylesheet" href="<?php echo base_url(); ?>assets/izitoast/dist/css/iziToast.min.css">
        <link rel="stylesheet" href="<?php echo base_url(); ?>assets/izitoast/dist/css/icomoon.css">

    <?php

    if(isset($_SESSION['mensagem'])){        //se tiver erros na validação mostrar essa parada aki

            echo "";
    }
?>

        <form  id="form" action="<?php echo base_url(); ?>Cadastro_capacitacao/cadastrar" method="post" enctype="multipart/form-data">

Dados da Capacitação Realizada

                    TEMA *
                    <input type="text" class="form-control" id="tema"  name="tema" placeholder="Título ou tema da capacitação">

                        Data de Início*
                        <input type="date" class="form-control" id="inicioProjeto" name="inicio" placeholder="dd/mm/aaaa" required="">

                        Data de Termino*
                        <input type="date" class="form-control" id="termino" name="termino" placeholder="dd/mm/aaaa" required="">

                    Escola Atendida *
                    <input type="text" class="form-control" id="escola"  name="escola"placeholder="Escola Atendida ">

                    Público Alvo *
                    <input type="text" class="form-control" id="publico_alvo"  name="publico_alvo"placeholder="Público Alvo ">

                    Síntese *

                    <textarea class="form-control" id="descricao" name="sintese" placeholder="BREVE SÍNTESE DA ATIVIDADE MÁXIMO 100 PALAVRAS" rows="6"></textarea>

                    Anexo *
                    <input type="file" class="form-control" id="anexo" name="anexo" >

        <button type="submit" id="salvar" class="btn btn-success" >

            Enviar
        </button>
        <button type="reset" class="btn btn-default">
            Cancelar
        </button>

                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>

Verificar Informações

                    Você Tem certeza que deseja salvar o bosista?

                    <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
                    <button type="button" class="btn btn-primary">Salvar</button>

</form>


text:
package me.bleidi.mars.domain;

import java.awt.Point;
import java.util.Scanner;

import me.bleidi.mars.domain.sonda.Direcao;
import me.bleidi.mars.domain.sonda.Sonda;
import me.bleidi.mars.domain.terreno.Planalto;

public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)){
			int x = scanner.nextInt();
			int y = scanner.nextInt();

			Planalto planalto = new Planalto(x, y);

			while(scanner.hasNext()){
				x = scanner.nextInt();
				y = scanner.nextInt();
				Direcao direcao = Direcao.of(scanner.nextLine().trim().charAt(0));

				Sonda sonda = new Sonda();
				sonda.pousar(new Point(x,y), direcao);

				String fila = scanner.nextLine();
				fila.chars().mapToObj(i -> (char)i).forEach(c -> sonda.executar(c));
				System.out.println(sonda);
			}

		}catch(Exception e){
			e.printStackTrace();
		}
	}
}


text:
package br.com.fuelclub.dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import br.com.fuelclub.entity.Administrador_Sistema;
import br.com.fuelclub.entity.Tipo_Combustivel;

public class TipoCombustivelDao implements InterfaceDao<Tipo_Combustivel>{

	@Override
	public void salvar(Tipo_Combustivel tipoCombustivel) {

		EntityManager em = Conexao.getEntityManager();
		em.getTransaction().begin();
		em.persist(tipoCombustivel);

		em.getTransaction().commit();

	}

	@Override
	public List<Tipo_Combustivel> listas() {

		EntityManager em = Conexao.getEntityManager();
		Query q =em.createQuery("select a from Tipo_Combustivel a");

		return q.getResultList();

	}

	@Override
	public void editar(Tipo_Combustivel tipoCombustivel) {

		EntityManager em = Conexao.getEntityManager();
		em.getTransaction().begin();
		em.merge(tipoCombustivel);

		em.getTransaction().commit();

	}

	@Override
	public Tipo_Combustivel getObjectTById(Long id) {

		EntityManager em = Conexao.getEntityManager();
		return em.find(Tipo_Combustivel.class, id);

	}

	@Override
	public void excluir(Tipo_Combustivel t) {
	}

	public List<Tipo_Combustivel> listar(Tipo_Combustivel tipoCombustivel) {

		EntityManager em = Conexao.getEntityManager();
		Query q =em.createQuery("select a from Tipo_Combustivel a");

		return q.getResultList();

	}

}


text:
import unittest
import os.path
import json

from moniqueio.tests.test_basic import Runner, FIXTURES_DIR

class UnittestSummarizeTests(unittest.TestCase):

    def _run(self, fixture):
        r = Runner()
        try:
            out = r.run('cat %s | {base} unittest_summarize' % os.path.join(FIXTURES_DIR, 'unittest_summarize', fixture))
            print(out)
            return dict(json.loads(out))
        except:
            print('>>> Invalid output:\n%s' % out)
            raise

    def test_junit(self):
        d = self._run('junit__ok')
        self.assertIn('elapsed', d)
        self.assertEqual(1, d['tests'])
        self.assertEqual(0, d['fails'])
        self.assertEqual(0, d['errors'])

    def test_php(self):
        d = self._run('phpunit__ok')
        self.assertIn('elapsed', d)
        self.assertEqual(2, d['tests'])
        self.assertEqual(0, d['fails'])
        self.assertEqual(0, d['errors'])
        self.assertEqual(2, d['asserts'])

        d = self._run('phpunit__ok2')
        self.assertIn('elapsed', d)
        self.assertEqual(0, d['tests'])
        self.assertEqual(0, d['fails'])
        self.assertEqual(0, d['errors'])
        self.assertEqual(0, d['asserts'])

    def test_python(self):
        d = self._run('python__fail')
        self.assertIn('elapsed', d)
        self.assertEqual(78, d['tests'])
        self.assertEqual(1, d['fails'])
        self.assertEqual(1, d['errors'])
        self.assertEqual(0, d['asserts'])
        self.assertEqual(6, d['skipped'])

        d = self._run('python__ok')
        self.assertIn('elapsed', d)
        self.assertEqual(78, d['tests'])
        self.assertEqual(0, d['fails'])
        self.assertEqual(0, d['errors'])
        self.assertEqual(0, d['asserts'])
        self.assertEqual(6, d['skipped'])

        d = self._run('python__ok2')
        self.assertIn('elapsed', d)
        self.assertEqual(78, d['tests'])
        self.assertEqual(0, d['fails'])
        self.assertEqual(0, d['errors'])
        self.assertEqual(0, d['asserts'])
        self.assertEqual(0, d['skipped'])

        d = self._run('python_verbose__fail')
        self.assertIn('elapsed', d)
        self.assertEqual(78, d['tests'])
        self.assertEqual(1, d['fails'])
        self.assertEqual(1, d['errors'])
        self.assertEqual(0, d['asserts'])
        self.assertEqual(6, d['skipped'])

        d = self._run('python_verbose__ok')
        self.assertIn('elapsed', d)
        self.assertEqual(78, d['tests'])
        self.assertEqual(0, d['fails'])
        self.assertEqual(0, d['errors'])
        self.assertEqual(0, d['asserts'])
        self.assertEqual(6, d['skipped'])

    def test_ruby(self):
        d = self._run('ruby__fail')
        self.assertIn('elapsed', d)
        self.assertEqual(3, d['tests'])
        self.assertEqual(1, d['fails'])
        self.assertEqual(0, d['errors'])
        self.assertEqual(4, d['asserts'])
        self.assertEqual(0, d['skipped'])

        d = self._run('ruby__ok')
        self.assertIn('elapsed', d)
        self.assertEqual(1, d['tests'])
        self.assertEqual(0, d['fails'])
        self.assertEqual(0, d['errors'])
        self.assertEqual(2, d['asserts'])
        self.assertEqual(0, d['skipped'])

        d = self._run('ruby__ok2')
        self.assertIn('elapsed', d)
        self.assertEqual(2, d['tests'])
        self.assertEqual(0, d['fails'])
        self.assertEqual(0, d['errors'])
        self.assertEqual(2, d['asserts'])
        self.assertEqual(0, d['skipped'])


text:
using QuranX.Models;
using System.Web.Mvc;

namespace QuranX.Controllers
{
	[OutputCache(Duration = Consts.CacheTimeInSeconds)]
	public class AnalysisController : Controller
	{
		public ActionResult Verse(int chapter, int verse)
		{
			ViewBag.Chapter = chapter;
			ViewBag.Verse = verse;
			var model = new Analysis_Verse(
				chapter: chapter,
				verse: verse
			);
			return View(model);
		}

		public ActionResult Root(string root)
		{
			root = ArabicHelper.LetterNamesToArabic(root);
			var model = new Analysis_Root(root);
			return View(model);
		}

		[HttpPost]
		public ActionResult RedirectToChapterVerse(int chapter, int verse)
		{
			return RedirectToAction("Verse", new
			{
				Chapter = chapter,
				Verse = verse
			});
		}

	}
}