text:
function EscapeArg
{
    param([string]$argVal)

    $argVal = $argVal.Replace('"', '""');
    $argVal = '"' + $argVal + '"';

    return $argVal;
}

# Set a variable in a property bag that is accessible by all steps
# To retrieve the variable use $val = Get-Variable $distributedTaskContext "varName"
function SetTaskContextVariable
{
    param([string][ValidateNotNullOrEmpty()]$varName,
          [string]$varValue)

    Write-Host "##vso[task.setvariable variable=$varName;]$varValue"
}

function GetTaskContextVariable()
{
	param([string][ValidateNotNullOrEmpty()]$varName)
	return Get-TaskVariable -Context $distributedTaskContext -Name $varName
}

#
# Helper that informs if a "filePath" has been specified. The platform will return the root of the repo / workspace if the user enters nothing.
#
function IsFilePathSpecified
{
     param([string]$path)

     if ([String]::IsNullOrWhiteSpace($path))
     {
        return $false
     }

     return ![String]::Equals(
                [System.IO.Path]::GetFullPath($path).TrimEnd([System.IO.Path]::DirectorySeparatorChar, [System.IO.Path]::AltDirectorySeparatorChar),
                [System.IO.Path]::GetFullPath($env:BUILD_SOURCESDIRECTORY).TrimEnd([System.IO.Path]::DirectorySeparatorChar, [System.IO.Path]::AltDirectorySeparatorChar),
                [StringComparison]::OrdinalIgnoreCase)
}

#
# Retry a specific command until it completes without exceptions. Throws if the command didn't complete successfully after the specified number of retries. Usage:
#
#   $command = { InvokeGetRestMethod "/api/projects"}
#   Retry $command -maxRetries 30 -retryDelay 1 -Verbose
#
function Retry
{
    [CmdletBinding()]
    param (
    [Parameter(ValueFromPipeline,Mandatory)]$command,
    [int]$maxRetries = 3,
    [int]$retryDelay = 1)

    $success = $false
    $attemptNumber = 1

    while (!$success)
    {
        try
        {
            Write-Verbose "Calling $command"
            $result = & $command
            $success = $true
        }
        catch
        {
            if ($attemptNumber -ige $maxRetries)
            {
                Write-Verbose "Calling $command failed after $attemptNumber retries"
                throw
            }
            else
            {
                Write-Verbose "Calling $command failed. Attempt number $attemptNumber. Retrying after $retryDelay seconds..."
                Start-Sleep $retryDelay
                $attemptNumber++
            }
        }
    }

    return $result
}

#
# Retry a specific command until the results is true. Returns true if the command succeded. Timeout and retry delay are in seconds. Usage:
#
#   $command = { GetStatus -eq "Complete" }
#   RetryUntilTrue $command -timeout 60 -retryDelay 1 -Verbose
#
#
function RetryUntilTrue
{
    param (
        [Parameter(ValueFromPipeline,Mandatory)]$command,
        [int]$timeout = 60,
        [int]$retryDelay = 1)

    $sw =  New-Object -TypeName "System.Diagnostics.Stopwatch"
    $sw.Start()
    $success = $false

    while (!$success)
    {

       Write-Verbose "Calling $command"
       $success = & $command

       if (!$success)
       {
            $elapsedTime = $sw.Elapsed.TotalSeconds;

            if ($elapsedTime -gt $timeout)
            {
                 Write-Verbose "Calling $command failed after $elapsedTime seconds"
                 return $false;
            }
            else
            {
                Write-Verbose "Calling $command failed. Elapsed time $elapsedTime seconds. Retrying after $retryDelay seconds..."
                Start-Sleep $retryDelay
            }
       }
    }

    return $true;
}

function InvokeGetRestMethod
{
    param (
        [Parameter(Mandatory=$true)][string]$query,
        [bool]$useAuth=$false)

    $sonarQubeHostUrl = GetTaskContextVariable "MSBuild.SonarQube.HostUrl"
    $sonarQubeHostUrl  = $sonarQubeHostUrl.TrimEnd("/");

    Assert (![System.String]::IsNullOrWhiteSpace($sonarQubeHostUrl)) "Could not retrieve the SonarQube host url"

    $request = $sonarQubeHostUrl + $query;

    if ($useAuth)
    {
       $authHeader = CreateBasicAuthHeaderFromEndpoint

       if (![String]::IsNullOrWhiteSpace($authHeader))
       {
            $allheaders = @{Authorization = $authHeader}
       }

    }

    $response = Invoke-RestMethod -Uri $request -Method Get -Headers $allheaders

    return $response
}

#
# Creates a basic authentication header using the credentials specified in the generic endpoint in the begin task.
#
function CreateBasicAuthHeaderFromEndpoint
{
    $user = GetTaskContextVariable "MSBuild.SonarQube.ServerUsername"
    $password = GetTaskContextVariable "MSBuild.SonarQube.ServerPassword"

    if ($user -or $password)
    {
        $pair = "$($user):$($password)"

        $encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
        $basicAuthValue = "Basic $encodedCreds"
    }

    return $basicAuthValue
}

#
# C# like assert based on a condition. Note that PowerShell does not support actual assertions so
#
function Assert
{
    param ([bool]$condition, [string]$message)

    if (!$condition)
    {
        throw $message
    }
}

#
# Returns true if this build was triggered in response to a PR
#
# Remark: this logic is temporary until the platform provides a more robust way of deteriming PR builds
#
function IsPrBuild
{
    $sourceBranch = $env:Build_SourceBranch

    if ([string]::IsNullOrWhiteSpace($sourceBranch))
    {
        throw "Could not determine the source branch, please log a bug"
    }

    return $sourceBranch.StartsWith("refs/pull/", [StringComparison]::OrdinalIgnoreCase)
}

function GetSonarQubeBuildDirectory
{
    $agentBuildDirectory = GetTaskContextVariable "Agent.BuildDirectory"
	if (!$agentBuildDirectory)
	{
		throw "Could not retrieve the Agent.BuildDirectory variable";
	}

	return [System.IO.Path]::Combine($agentBuildDirectory, ".sonarqube");
}

function GetSonarQubeOutDirectory
{
    $sqBuildDir = GetSonarQubeBuildDirectory

    return [System.IO.Path]::Combine($sqBuildDir, "out");
}

function GetSonarScannerDirectory
{
    $sqBuildDir = GetSonarQubeOutDirectory

    return [System.IO.Path]::Combine($sqBuildDir, ".sonar");
}


text:
//this source code was auto-generated by tolua#, do not modify it
using System;
using LuaInterface;

public class UnityEngine_FontWrap
{
	public static void Register(LuaState L)
	{
		L.BeginClass(typeof(UnityEngine.Font), typeof(UnityEngine.Object));
		L.RegFunction("GetOSInstalledFontNames", GetOSInstalledFontNames);
		L.RegFunction("CreateDynamicFontFromOSFont", CreateDynamicFontFromOSFont);
		L.RegFunction("HasCharacter", HasCharacter);
		L.RegFunction("RequestCharactersInTexture", RequestCharactersInTexture);
		L.RegFunction("GetMaxVertsForString", GetMaxVertsForString);
		L.RegFunction("GetCharacterInfo", GetCharacterInfo);
		L.RegFunction("New", _CreateUnityEngine_Font);
		L.RegFunction("__eq", op_Equality);
		L.RegFunction("__tostring", ToLua.op_ToString);
		L.RegVar("material", get_material, set_material);
		L.RegVar("fontNames", get_fontNames, set_fontNames);
		L.RegVar("characterInfo", get_characterInfo, set_characterInfo);
		L.RegVar("dynamic", get_dynamic, null);
		L.RegVar("ascent", get_ascent, null);
		L.RegVar("lineHeight", get_lineHeight, null);
		L.RegVar("fontSize", get_fontSize, null);
		L.RegVar("textureRebuilt", get_textureRebuilt, set_textureRebuilt);
		L.EndClass();
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int _CreateUnityEngine_Font(IntPtr L)
	{
		try
		{
			int count = LuaDLL.lua_gettop(L);

			if (count == 0)
			{
				UnityEngine.Font obj = new UnityEngine.Font();
				ToLua.PushSealed(L, obj);
				return 1;
			}
			else if (count == 1)
			{
				string arg0 = ToLua.CheckString(L, 1);
				UnityEngine.Font obj = new UnityEngine.Font(arg0);
				ToLua.PushSealed(L, obj);
				return 1;
			}
			else
			{
				return LuaDLL.luaL_throw(L, "invalid arguments to ctor method: UnityEngine.Font.New");
			}
		}
		catch (Exception e)
		{
			return LuaDLL.toluaL_exception(L, e);
		}
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int GetOSInstalledFontNames(IntPtr L)
	{
		try
		{
			ToLua.CheckArgsCount(L, 0);
			string[] o = UnityEngine.Font.GetOSInstalledFontNames();
			ToLua.Push(L, o);
			return 1;
		}
		catch (Exception e)
		{
			return LuaDLL.toluaL_exception(L, e);
		}
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int CreateDynamicFontFromOSFont(IntPtr L)
	{
		try
		{
			int count = LuaDLL.lua_gettop(L);

			if (count == 2 && TypeChecker.CheckTypes<string[], int>(L, 1))
			{
				string[] arg0 = ToLua.ToStringArray(L, 1);
				int arg1 = (int)LuaDLL.lua_tonumber(L, 2);
				UnityEngine.Font o = UnityEngine.Font.CreateDynamicFontFromOSFont(arg0, arg1);
				ToLua.PushSealed(L, o);
				return 1;
			}
			else if (count == 2 && TypeChecker.CheckTypes<string, int>(L, 1))
			{
				string arg0 = ToLua.ToString(L, 1);
				int arg1 = (int)LuaDLL.lua_tonumber(L, 2);
				UnityEngine.Font o = UnityEngine.Font.CreateDynamicFontFromOSFont(arg0, arg1);
				ToLua.PushSealed(L, o);
				return 1;
			}
			else
			{
				return LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Font.CreateDynamicFontFromOSFont");
			}
		}
		catch (Exception e)
		{
			return LuaDLL.toluaL_exception(L, e);
		}
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int HasCharacter(IntPtr L)
	{
		try
		{
			ToLua.CheckArgsCount(L, 2);
			UnityEngine.Font obj = (UnityEngine.Font)ToLua.CheckObject(L, 1, typeof(UnityEngine.Font));
			char arg0 = (char)LuaDLL.luaL_checknumber(L, 2);
			bool o = obj.HasCharacter(arg0);
			LuaDLL.lua_pushboolean(L, o);
			return 1;
		}
		catch (Exception e)
		{
			return LuaDLL.toluaL_exception(L, e);
		}
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int RequestCharactersInTexture(IntPtr L)
	{
		try
		{
			int count = LuaDLL.lua_gettop(L);

			if (count == 2)
			{
				UnityEngine.Font obj = (UnityEngine.Font)ToLua.CheckObject(L, 1, typeof(UnityEngine.Font));
				string arg0 = ToLua.CheckString(L, 2);
				obj.RequestCharactersInTexture(arg0);
				return 0;
			}
			else if (count == 3)
			{
				UnityEngine.Font obj = (UnityEngine.Font)ToLua.CheckObject(L, 1, typeof(UnityEngine.Font));
				string arg0 = ToLua.CheckString(L, 2);
				int arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
				obj.RequestCharactersInTexture(arg0, arg1);
				return 0;
			}
			else if (count == 4)
			{
				UnityEngine.Font obj = (UnityEngine.Font)ToLua.CheckObject(L, 1, typeof(UnityEngine.Font));
				string arg0 = ToLua.CheckString(L, 2);
				int arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
				UnityEngine.FontStyle arg2 = (UnityEngine.FontStyle)ToLua.CheckObject(L, 4, typeof(UnityEngine.FontStyle));
				obj.RequestCharactersInTexture(arg0, arg1, arg2);
				return 0;
			}
			else
			{
				return LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Font.RequestCharactersInTexture");
			}
		}
		catch (Exception e)
		{
			return LuaDLL.toluaL_exception(L, e);
		}
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int GetMaxVertsForString(IntPtr L)
	{
		try
		{
			ToLua.CheckArgsCount(L, 1);
			string arg0 = ToLua.CheckString(L, 1);
			int o = UnityEngine.Font.GetMaxVertsForString(arg0);
			LuaDLL.lua_pushinteger(L, o);
			return 1;
		}
		catch (Exception e)
		{
			return LuaDLL.toluaL_exception(L, e);
		}
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int GetCharacterInfo(IntPtr L)
	{
		try
		{
			int count = LuaDLL.lua_gettop(L);

			if (count == 3)
			{
				UnityEngine.Font obj = (UnityEngine.Font)ToLua.CheckObject(L, 1, typeof(UnityEngine.Font));
				char arg0 = (char)LuaDLL.luaL_checknumber(L, 2);
				UnityEngine.CharacterInfo arg1;
				bool o = obj.GetCharacterInfo(arg0, out arg1);
				LuaDLL.lua_pushboolean(L, o);
				ToLua.PushValue(L, arg1);
				return 2;
			}
			else if (count == 4)
			{
				UnityEngine.Font obj = (UnityEngine.Font)ToLua.CheckObject(L, 1, typeof(UnityEngine.Font));
				char arg0 = (char)LuaDLL.luaL_checknumber(L, 2);
				UnityEngine.CharacterInfo arg1;
				int arg2 = (int)LuaDLL.luaL_checknumber(L, 4);
				bool o = obj.GetCharacterInfo(arg0, out arg1, arg2);
				LuaDLL.lua_pushboolean(L, o);
				ToLua.PushValue(L, arg1);
				return 2;
			}
			else if (count == 5)
			{
				UnityEngine.Font obj = (UnityEngine.Font)ToLua.CheckObject(L, 1, typeof(UnityEngine.Font));
				char arg0 = (char)LuaDLL.luaL_checknumber(L, 2);
				UnityEngine.CharacterInfo arg1;
				int arg2 = (int)LuaDLL.luaL_checknumber(L, 4);
				UnityEngine.FontStyle arg3 = (UnityEngine.FontStyle)ToLua.CheckObject(L, 5, typeof(UnityEngine.FontStyle));
				bool o = obj.GetCharacterInfo(arg0, out arg1, arg2, arg3);
				LuaDLL.lua_pushboolean(L, o);
				ToLua.PushValue(L, arg1);
				return 2;
			}
			else
			{
				return LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Font.GetCharacterInfo");
			}
		}
		catch (Exception e)
		{
			return LuaDLL.toluaL_exception(L, e);
		}
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int op_Equality(IntPtr L)
	{
		try
		{
			ToLua.CheckArgsCount(L, 2);
			UnityEngine.Object arg0 = (UnityEngine.Object)ToLua.ToObject(L, 1);
			UnityEngine.Object arg1 = (UnityEngine.Object)ToLua.ToObject(L, 2);
			bool o = arg0 == arg1;
			LuaDLL.lua_pushboolean(L, o);
			return 1;
		}
		catch (Exception e)
		{
			return LuaDLL.toluaL_exception(L, e);
		}
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int get_material(IntPtr L)
	{
		object o = null;

		try
		{
			o = ToLua.ToObject(L, 1);
			UnityEngine.Font obj = (UnityEngine.Font)o;
			UnityEngine.Material ret = obj.material;
			ToLua.Push(L, ret);
			return 1;
		}
		catch(Exception e)
		{
			return LuaDLL.toluaL_exception(L, e, o, "attempt to index material on a nil value");
		}
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int get_fontNames(IntPtr L)
	{
		object o = null;

		try
		{
			o = ToLua.ToObject(L, 1);
			UnityEngine.Font obj = (UnityEngine.Font)o;
			string[] ret = obj.fontNames;
			ToLua.Push(L, ret);
			return 1;
		}
		catch(Exception e)
		{
			return LuaDLL.toluaL_exception(L, e, o, "attempt to index fontNames on a nil value");
		}
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int get_characterInfo(IntPtr L)
	{
		object o = null;

		try
		{
			o = ToLua.ToObject(L, 1);
			UnityEngine.Font obj = (UnityEngine.Font)o;
			UnityEngine.CharacterInfo[] ret = obj.characterInfo;
			ToLua.Push(L, ret);
			return 1;
		}
		catch(Exception e)
		{
			return LuaDLL.toluaL_exception(L, e, o, "attempt to index characterInfo on a nil value");
		}
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int get_dynamic(IntPtr L)
	{
		object o = null;

		try
		{
			o = ToLua.ToObject(L, 1);
			UnityEngine.Font obj = (UnityEngine.Font)o;
			bool ret = obj.dynamic;
			LuaDLL.lua_pushboolean(L, ret);
			return 1;
		}
		catch(Exception e)
		{
			return LuaDLL.toluaL_exception(L, e, o, "attempt to index dynamic on a nil value");
		}
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int get_ascent(IntPtr L)
	{
		object o = null;

		try
		{
			o = ToLua.ToObject(L, 1);
			UnityEngine.Font obj = (UnityEngine.Font)o;
			int ret = obj.ascent;
			LuaDLL.lua_pushinteger(L, ret);
			return 1;
		}
		catch(Exception e)
		{
			return LuaDLL.toluaL_exception(L, e, o, "attempt to index ascent on a nil value");
		}
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int get_lineHeight(IntPtr L)
	{
		object o = null;

		try
		{
			o = ToLua.ToObject(L, 1);
			UnityEngine.Font obj = (UnityEngine.Font)o;
			int ret = obj.lineHeight;
			LuaDLL.lua_pushinteger(L, ret);
			return 1;
		}
		catch(Exception e)
		{
			return LuaDLL.toluaL_exception(L, e, o, "attempt to index lineHeight on a nil value");
		}
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int get_fontSize(IntPtr L)
	{
		object o = null;

		try
		{
			o = ToLua.ToObject(L, 1);
			UnityEngine.Font obj = (UnityEngine.Font)o;
			int ret = obj.fontSize;
			LuaDLL.lua_pushinteger(L, ret);
			return 1;
		}
		catch(Exception e)
		{
			return LuaDLL.toluaL_exception(L, e, o, "attempt to index fontSize on a nil value");
		}
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int get_textureRebuilt(IntPtr L)
	{
		ToLua.Push(L, new EventObject(typeof(System.Action<UnityEngine.Font>)));
		return 1;
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int set_material(IntPtr L)
	{
		object o = null;

		try
		{
			o = ToLua.ToObject(L, 1);
			UnityEngine.Font obj = (UnityEngine.Font)o;
			UnityEngine.Material arg0 = (UnityEngine.Material)ToLua.CheckObject<UnityEngine.Material>(L, 2);
			obj.material = arg0;
			return 0;
		}
		catch(Exception e)
		{
			return LuaDLL.toluaL_exception(L, e, o, "attempt to index material on a nil value");
		}
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int set_fontNames(IntPtr L)
	{
		object o = null;

		try
		{
			o = ToLua.ToObject(L, 1);
			UnityEngine.Font obj = (UnityEngine.Font)o;
			string[] arg0 = ToLua.CheckStringArray(L, 2);
			obj.fontNames = arg0;
			return 0;
		}
		catch(Exception e)
		{
			return LuaDLL.toluaL_exception(L, e, o, "attempt to index fontNames on a nil value");
		}
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int set_characterInfo(IntPtr L)
	{
		object o = null;

		try
		{
			o = ToLua.ToObject(L, 1);
			UnityEngine.Font obj = (UnityEngine.Font)o;
			UnityEngine.CharacterInfo[] arg0 = ToLua.CheckStructArray<UnityEngine.CharacterInfo>(L, 2);
			obj.characterInfo = arg0;
			return 0;
		}
		catch(Exception e)
		{
			return LuaDLL.toluaL_exception(L, e, o, "attempt to index characterInfo on a nil value");
		}
	}

	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int set_textureRebuilt(IntPtr L)
	{
		try
		{
			EventObject arg0 = null;

			if (LuaDLL.lua_isuserdata(L, 2) != 0)
			{
				arg0 = (EventObject)ToLua.ToObject(L, 2);
			}
			else
			{
				return LuaDLL.luaL_throw(L, "The event 'UnityEngine.Font.textureRebuilt' can only appear on the left hand side of += or -= when used outside of the type 'UnityEngine.Font'");
			}

			if (arg0.op == EventOp.Add)
			{
				System.Action<UnityEngine.Font> ev = (System.Action<UnityEngine.Font>)arg0.func;
				UnityEngine.Font.textureRebuilt += ev;
			}
			else if (arg0.op == EventOp.Sub)
			{
				System.Action<UnityEngine.Font> ev = (System.Action<UnityEngine.Font>)arg0.func;
				UnityEngine.Font.textureRebuilt -= ev;
			}

			return 0;
		}
		catch (Exception e)
		{
			return LuaDLL.toluaL_exception(L, e);
		}
	}
}

redpajama_set_name: RedPajamaGithub


text:
<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\controllers;

use Yii;
use yii\filters\AccessControl;
use app\components\AccessRule;
//use app\common\models\Customer;
use yii\data\Pagination;
use yii\web\Controller;
use app\models\SalesForm;
use yii\widgets\ActiveForm;
use app\components\GlobalFunction;

/**
 * Description of SalesController
 *
 * @author Muhammad Asif
 */
class SalesController extends Controller {

    const className = 'app\common\models\Sales';

    public function behaviors() {
        return [
            'access' => [
                'class' => AccessControl::className(),
                'ruleConfig' => [
                    'class' => AccessRule::className(),
                ],
                'rules' => [
                    [
                        'actions' => ['index', 'create', 'update', 'delete', 'validation', 'detail'],
                        'allow' => true,
                        'roles' => ['@'],
                    ],
                ],
            ],
        ];
    }

    // index function for listing
    public function actionIndex() {
        $className = self::className;
        $whereParams = $indexS = $nameS = $sort = '';
        $model = new SalesForm();
        $model->scenario = 'create';
        $modelu = new SalesForm();
        $modelu->scenario = 'update';
        if (Yii::$app->request->post()) {                 // create Sale
            $cstmr = true;
            $model->load(Yii::$app->request->post());
            if ($model->customer_type == '1') {
                $customer = new \app\models\CustomerForm();
                $customer->scenario = 'createFromSale';
                $params['CustomerForm'] = ['first_name' => $model->customer_name, 'customer_acc' => $model->customer_acc_no, 'sales_agent' => $model->sale_executive];
                $customer->load($params);
                $ret = $customer->createOrUpdate($params['CustomerForm']);
                if ($ret['msgType'] == 'ERR') {
                    $cstmr = FALSE;
                    return json_encode($ret['msgArr']) . '
------------
' . json_encode($customer->attributes);
                } else {
                    $model->customer_name = $customer->_id;
                }
            }
            if ($cstmr) {
                $retData = $model->createOrUpdate(Yii::$app->request->post('SalesForm'));
                if ($retData['msgType'] == 'ERR') {
                    ;
                } else {
                    $model = new SalesForm();
                }
            }
        }

        if (Yii::$app->request->get('sort')) {
            $sort = Yii::$app->request->get('sort');
        }
        if (Yii::$app->request->get('status')) {
            $whereParams['order_state'] = Yii::$app->request->get('status');
        }
        if (Yii::$app->request->get('indexS')) {
            $whereParams['index_no'] = Yii::$app->request->get('indexS');
        }

        $count = GlobalFunction::getCount(['className' => $className, 'whereParams' => $whereParams, 'nameS' => $nameS]);
        $pagination = new Pagination(['totalCount' => $count, 'pageSize' => Yii::$app->params['pageSize']]);
        $data = GlobalFunction::getListing(['className' => $className, 'pagination' => $pagination, 'whereParams' => $whereParams, 'nameS' => $nameS, 'sort' => $sort, 'selectParams' => ['_id', 'uid', 'index_no', 'sale_executive', 'customer_type', 'order_type', 'customer_acc_no', 'customer_name', 'plan', 'siebel_activity_no', 'require_finance', 'require_account_transfer', 'so_no', 'submitted_to_AT', 'order_state']]);

        return $this->render('index', [
                    'data' => $data,
                    'model' => $model,
                    'modelu' => $modelu,
                    'pagination' => $pagination,
                    'agentList' => GlobalFunction::getAgentList(),
                    'customerTypeList' => GlobalFunction::getCustomerTypes(),
                    'YN' => GlobalFunction::getYN(),
                    'orderTypeList' => GlobalFunction::getOrderTypeList(),
                    'customerList' => GlobalFunction::getCustomerList(),
                    'planList' => GlobalFunction::getPlansList(),
                    'orderStateList' => GlobalFunction::getOrderStateList(),
        ]);
    }

    public function actionValidation($s) {
        $model = new SalesForm();
        $model->scenario = $s;

        if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {//echo json_encode($model->attributes);
            Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
            return ActiveForm::validate($model);
        }
    }

    // update sale
    public function actionUpdate() {
        $model = new SalesForm();
        $model->scenario = 'update';
        if (Yii::$app->request->post()) {
            $model->load(Yii::$app->request->post());
            $retData = $model->createOrUpdate(Yii::$app->request->post('SalesForm'));

            if ($retData['msgType'] == 'ERR') {
                exit(json_encode(['msgType' => 'ERR', 'msgArr' => $retData['msgArr']]));
            } else {
                exit(json_encode(['msgType' => 'SUC']));
            }
        }
    }

    // sales detail
    public function actionDetail($id) {

        $sale = \app\common\models\Sales::findOne($id);
        if (count($sale) > 0) {
            $model = new SalesForm();
            $model->scenario = 'detail';
            $model->attributes = $sale->attributes;

            if (Yii::$app->request->post()) {                 // Detail Update
                $model->load(Yii::$app->request->post());
                $retData = $model->createOrUpdate(Yii::$app->request->post('SalesForm'));

                if ($retData['msgType'] == 'ERR') {
                    exit(json_encode(['msgType' => 'ERR', 'msgArr' => $retData['msgArr']]));
                } else {
                    $this->refresh(); //exit(json_encode(['msgType' => 'SUC']));
                }
            }

            $estData = GlobalFunction::getListing(['className' => 'app\common\models\Values', 'pagination' => '', 'whereParams' => '', 'nameS' => '', 'selectParams' => ['_id', 'name', 'value']]);
            $estList=[];
            foreach ($estData as $value) {
                $estList[$value->name] = $value->value;
            }

            return $this->render('detail', [
                        'model' => $model,
                        'countryList' => GlobalFunction::getCountries(),
                        'agentList' => GlobalFunction::getAgentList(),
                        'customerTypeList' => GlobalFunction::getCustomerTypes(),
                        'YN' => GlobalFunction::getYN(),
                        'orderTypeList' => GlobalFunction::getOrderTypeList(),
                        'customerList' => GlobalFunction::getCustomerList(),
                        'planList' => GlobalFunction::getPlansList(),
                        'planTypeList' => GlobalFunction::getPlanTypeList(),
                        'orderStateList' => GlobalFunction::getOrderStateList(),
                        'states' => GlobalFunction::getSalesDetailStatesList(),
                        'estList' => $estList,
            ]);
        } else {
            return $this->render('detail', [
                        'errmsg' => 'In valid Customer ID',
            ]);
        }
    }

// end class
}


text:
FactoryGirl.define do
  factory :aws_object, :class => ManageIQ::Providers::Amazon::StorageManager::S3::CloudObjectStoreObject.name do |object|
    object.sequence(:key) { |n| "object-key-#{n}" }
  end

  factory :aws_bucket_with_objects,
          :class => ManageIQ::Providers::Amazon::StorageManager::S3::CloudObjectStoreContainer.name do |bucket|
    bucket.sequence(:name) { |n| "stubbed-name-#{n}" }
    bucket.sequence(:ems_ref) { |n| "stubbed-ems-ref-#{n}" }

    after(:create) do |bucket|
      bucket.cloud_object_store_objects = FactoryGirl.create_list(
        :aws_object, 5, :ext_management_system => bucket.ext_management_system
      )
    end
  end
end


text:
package it.geosolutions.jaiext.stats;

import static org.junit.Assert.*;

import java.awt.Rectangle;
import java.awt.image.DataBuffer;
import java.awt.image.Raster;
import java.awt.image.RenderedImage;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import javax.media.jai.ROI;
import javax.media.jai.ROIShape;

import it.geosolutions.jaiext.range.Range;
import it.geosolutions.jaiext.range.RangeFactory;
import it.geosolutions.jaiext.stats.Statistics.StatsType;
import it.geosolutions.jaiext.testclasses.TestBase;
import org.junit.BeforeClass;
import org.junit.Test;

/**
 * This test-class is used for evaluating if the SimpleStatsOpImage class computes correctly the requested statistics. For this purpose 6 methods are
 * created, each one testing a particular case:
 *

 *
Calculation without ROI and No Data.

 *
Calculation with ROI but without No Data.

 *
Calculation with ROI, using a RasterAccessor, but without No Data.

 *
Calculation with NoData but without ROI.

 *
Calculation with ROI and No Data.

 *
Calculation with ROI, using a RasterAccessor, and No Data.

 *

 *
 * All of these cases are tested on all the JAI data types (Byte,Short, Unsigned Short, Integer, Float, Double), and on both 1 and 2 bands. The
 * correct statistics are calculated before the test executions, and then are compared inside all the tests. Every single test call the
 * testStatistics() method which calls the SimpleStatsDescriptor.create() method for returning a new instance of the SimpleStatsOpImage, then
 * calculates the statistics and finally compares them with the initial precalculated values.
 */
public class CompleteStatsTest extends TestBase {
    /** Tolerance value used for comparison between double */
    private final static double TOLERANCE = 0.1d;

    /** Horizontal subsampling parameter */
    private static int xPeriod;

    /** Vertical subsampling parameter */
    private static int yPeriod;

    /** ROI object used for selecting the active area of the image */
    private static ROI roi;

    /** No Data value for Byte */
    private static byte noDataB;

    /** No Data value for UShort */
    private static short noDataU;

    /** No Data value for Short */
    private static short noDataS;

    /** No Data value for Integer */
    private static int noDataI;

    /** No Data value for Float */
    private static float noDataF;

    /** No Data value for Double */
    private static double noDataD;

    /** No Data Range for Byte */
    private static Range noDataByte;

    /** No Data Range for UShort */
    private static Range noDataUShort;

    /** No Data Range for Short */
    private static Range noDataShort;

    /** No Data Range for Integer */
    private static Range noDataInt;

    /** No Data Range for Float */
    private static Range noDataFloat;

    /** No Data Range for Double */
    private static Range noDataDouble;

    /** Array indicating the statistics to calculate */
    private static StatsType[] simpleStats;

    /** Array indicating the statistics to calculate */
    private static StatsType[] complexStats;

    /** Array with only one band index */
    private static int[] band1;

    /** Array with 2 band indexes */
    private static int[] band2;

    /** Source Image array */
    private static RenderedImage[] sourceIMG;

    /**
     * 2-D array containing the results of all the selected statistics calculated manually, the second dimension takes in account if NO DATA or ROI
     * are used
     */
    private static double[][] calculations;

    /** Array containing the number of all samples, every entry indicates takes in account if ROI or No Data */
    private static long[] numSamples;

    /** 2-D array containing the histogram results for each kind of evaluation (With ROI, With NoData, With/Without ROI and NoData) */
    private static double[][] hist;

    /** Array indicating the minimum bounds for each band */
    private static double[] minBound;

    /** Array indicating the maximum bounds for each band */
    private static double[] maxBound;

    /** Array indicating the size of one bin for each band */
    private static double[] binInterval;

    /** Array indicating the number of bins for each band */
    private static int[] numBins;

    /** Array containing the histogram range for each band */
    private static Range[] interval;

    /** List array containing the pixel values lists used for calculating the median for each kind of evaluation */
    private static List<Double>[] listData;

    // Initial static method for preparing all the test data
    @BeforeClass
    public static void initialSetup() {
        // Subsampling params definitions
        xPeriod = 1;

        yPeriod = 1;

        // Definition of the Histogram, Mode and Median parameters
        minBound = new double[] { -3, -3, -3 };
        maxBound = new double[] { 3, 3, 3 };
        numBins = new int[] { 4, 4, 4 };

        double binInterval0 = ((maxBound[0] - minBound[0]) / numBins[0]);

        binInterval = new double[] { binInterval0, binInterval0, binInterval0 };

        interval = new Range[3];

        interval[0] = RangeFactory.create(minBound[0], true, maxBound[0], false, false);
        interval[1] = RangeFactory.create(minBound[1], true, maxBound[1], false, false);
        interval[2] = RangeFactory.create(minBound[2], true, maxBound[2], false, false);

        hist = new double[numBins[0]][4];

        listData = new List[4];

        for (int i = 0; i < listData.length; i++) {
            listData[i] = new ArrayList<Double>();
        }

        // ROI creation
        Rectangle roiBounds = new Rectangle(5, 5, DEFAULT_WIDTH / 4, DEFAULT_HEIGHT / 4);
        roi = new ROIShape(roiBounds);

        // No Data Range creation

        // No Data values
        noDataB = 50;
        noDataU = 50;
        noDataS = 50;
        noDataI = 50;
        noDataF = 50;
        noDataD = 50;

        boolean minIncluded = true;
        boolean maxIncluded = true;

        noDataByte = RangeFactory.create(noDataB, minIncluded, noDataB, maxIncluded);
        noDataUShort = RangeFactory.createU(noDataU, minIncluded, noDataU, maxIncluded);
        noDataShort = RangeFactory.create(noDataS, minIncluded, noDataS, maxIncluded);
        noDataInt = RangeFactory.create(noDataI, minIncluded, noDataI, maxIncluded);
        noDataFloat = RangeFactory.create(noDataF, minIncluded, noDataF, maxIncluded, true);
        noDataDouble = RangeFactory.create(noDataD, minIncluded, noDataD, maxIncluded, true);

        // Statistics types
        simpleStats = new StatsType[] { StatsType.MEAN, StatsType.SUM, StatsType.MAX,
                StatsType.MIN, StatsType.EXTREMA, StatsType.VARIANCE, StatsType.DEV_STD };

        complexStats = new StatsType[] { StatsType.HISTOGRAM, StatsType.MODE, StatsType.MEDIAN };

        // Band array creation
        int[] array1Band = { 0 };
        int[] array2Band = { 0, 2 };

        band1 = array1Band;
        band2 = array2Band;

        // Image creations
        sourceIMG = new RenderedImage[6];

        sourceIMG[0] = createTestImage(DataBuffer.TYPE_BYTE, DEFAULT_WIDTH, DEFAULT_HEIGHT,
                noDataB, false, 3, 64);
        sourceIMG[1] = createTestImage(DataBuffer.TYPE_USHORT, DEFAULT_WIDTH, DEFAULT_HEIGHT,
                noDataU, false, 3, 64);
        sourceIMG[2] = createTestImage(DataBuffer.TYPE_SHORT, DEFAULT_WIDTH, DEFAULT_HEIGHT,
                noDataS, false, 3, 64);
        sourceIMG[3] = createTestImage(DataBuffer.TYPE_INT, DEFAULT_WIDTH, DEFAULT_HEIGHT, noDataI,
                false, 3, 64);
        sourceIMG[4] = createTestImage(DataBuffer.TYPE_FLOAT, DEFAULT_WIDTH, DEFAULT_HEIGHT,
                noDataF, false, 3, 64);
        sourceIMG[5] = createTestImage(DataBuffer.TYPE_DOUBLE, DEFAULT_WIDTH, DEFAULT_HEIGHT,
                noDataD, false, 3, 64);

        // Statistical calculation
        numSamples = new long[4];
        calculations = new double[9][4];

        int minTileX = sourceIMG[0].getMinTileX();
        int minTileY = sourceIMG[0].getMinTileY();
        int maxTileX = minTileX + sourceIMG[0].getNumXTiles();
        int maxTileY = minTileY + sourceIMG[0].getNumYTiles();

        calculations[2][0] = Double.NEGATIVE_INFINITY;
        calculations[2][1] = Double.NEGATIVE_INFINITY;
        calculations[2][2] = Double.NEGATIVE_INFINITY;
        calculations[2][3] = Double.NEGATIVE_INFINITY;

        calculations[3][0] = Double.POSITIVE_INFINITY;
        calculations[3][1] = Double.POSITIVE_INFINITY;
        calculations[3][2] = Double.POSITIVE_INFINITY;
        calculations[3][3] = Double.POSITIVE_INFINITY;

        // Cycle on all pixels of the 6 images
        for (int i = minTileX; i < maxTileX; i++) {
            for (int j = minTileY; j < maxTileY; j++) {
                // Selection of a Raster
                Raster arrayRas = sourceIMG[0].getTile(i, j);

                int minX = arrayRas.getMinX();
                int minY = arrayRas.getMinY();
                int maxX = minX + arrayRas.getWidth();
                int maxY = minY + arrayRas.getHeight();
                // Cycle on the Raster pixels
                for (int x = minX; x < maxX; x++) {
                    for (int y = minY; y < maxY; y++) {
                        byte value = (byte) arrayRas.getSample(x, y, 0);
                        // Cycle for all the 4 cases: No roi and No NoData, only roi, only NoData, both roi and NoData
                        for (int z = 0; z < 4; z++) {
                            switch (z) {
                            case 0:
                                // update of the number of samples
                                numSamples[z]++;
                                // update of the sum of samples
                                calculations[1][z] += value;
                                // update of the squared sum of samples
                                calculations[4][z] += value * value;
                                // update of the minimum and maximum values
                                if (value > calculations[2][z]) {
                                    calculations[2][z] = value;
                                }
                                if (value < calculations[3][z]) {
                                    calculations[3][z] = value;
                                }
                                // update of histogram, mode and median containers
                                if (interval[0].contains((double) value)) {
                                    int index = getIndex(value);
                                    hist[index][z]++;
                                    listData[z].add((double) value);
                                }
                                break;
                            case 1:
                                if (roi.contains(x, y)) {
                                    numSamples[z]++;
                                    calculations[1][z] += value;
                                    calculations[4][z] += value * value;
                                    if (value > calculations[2][z]) {
                                        calculations[2][z] = value;
                                    }
                                    if (value < calculations[3][z]) {
                                        calculations[3][z] = value;
                                    }
                                    if (interval[0].contains((double) value)) {
                                        int index = getIndex(value);
                                        hist[index][z]++;
                                        listData[z].add((double) value);
                                    }
                                }
                                break;
                            case 2:
                                if (!noDataByte.contains(value)) {
                                    numSamples[z]++;
                                    calculations[1][z] += value;
                                    calculations[4][z] += value * value;
                                    if (value > calculations[2][z]) {
                                        calculations[2][z] = value;
                                    }
                                    if (value < calculations[3][z]) {
                                        calculations[3][z] = value;
                                    }
                                    if (interval[0].contains((double) value)) {
                                        int index = getIndex(value);
                                        hist[index][z]++;
                                        listData[z].add((double) value);
                                    }
                                }
                                break;
                            case 3:
                                if (!noDataByte.contains(value) && roi.contains(x, y)) {
                                    numSamples[z]++;
                                    calculations[1][z] += value;
                                    calculations[4][z] += value * value;
                                    if (value > calculations[2][z]) {
                                        calculations[2][z] = value;
                                    }
                                    if (value < calculations[3][z]) {
                                        calculations[3][z] = value;
                                    }
                                    if (interval[0].contains((double) value)) {
                                        int index = getIndex(value);
                                        hist[index][z]++;
                                        listData[z].add((double) value);
                                    }
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }
        // Final calculation
        for (int h = 0; h < 6; h++) {
            for (int z = 0; z < 4; z++) {
                // calculation of the mean
                if(numSamples[z]==1){
                    calculations[0][z] = calculations[1][z] / (numSamples[z]);
                }else{
                    calculations[0][z] = calculations[1][z] / (numSamples[z] - 1);
                }
                // Calculation of the variance
                calculations[5][z] = (calculations[4][z] - (calculations[1][z] * calculations[1][z])
                        / (numSamples[z]))
                        / (numSamples[z] - 1);
                // Calculation of the standard deviation
                calculations[6][z] = Math.sqrt(calculations[5][z]);

                // Calculation of the median
                Collections.sort(listData[z]);
                int listSize = listData[z].size();
                if (listSize == 0) {
                    calculations[8][z] = Double.NaN;
                } else if (listSize == 1) {
                    calculations[8][z] = listData[z].get(0);
                } else {
                    int halfSize = listSize / 2;
                    double halfValue = listData[z].get(halfSize);
                    if (listData[z].size() % 2 == 1) {
                        calculations[8][z] = halfValue;
                    } else {
                        calculations[8][z] = (halfValue + listData[z].get(halfSize + 1)) / 2;
                    }
                }
                // Calculation of the mode
                double max = Double.NEGATIVE_INFINITY;
                double indexMax = 0;
                for (int i = 0; i < numBins[0]; i++) {
                    if (hist[i][z] > max) {
                        max = hist[i][z];
                        indexMax = i;
                    }
                }

                if (max != 0) {
                    indexMax = indexMax + minBound[0];
                }

                calculations[7][z] = indexMax;
            }
        }

    }

    // This test checks if the statistics are correct in absence of No Data and ROI
    @Test
    public void testNoRangeNoRoi() {
        boolean roiUsed = false;
        boolean noDataRangeUsed = false;
        boolean useROIAccessor = false;

        // Byte data Type
        testStatistics(sourceIMG[0], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Ushort data Type
        testStatistics(sourceIMG[1], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Short data Type
        testStatistics(sourceIMG[2], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Integer data Type
        testStatistics(sourceIMG[3], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Float data Type
        testStatistics(sourceIMG[4], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Double data Type
        testStatistics(sourceIMG[5], band1, roiUsed, noDataRangeUsed, useROIAccessor);

        // Byte data Type
        testStatistics(sourceIMG[0], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Ushort data Type
        testStatistics(sourceIMG[1], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Short data Type
        testStatistics(sourceIMG[2], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Integer data Type
        testStatistics(sourceIMG[3], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Float data Type
        testStatistics(sourceIMG[4], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Double data Type
        testStatistics(sourceIMG[5], band2, roiUsed, noDataRangeUsed, useROIAccessor);
    }

    // This test checks if the statistics are correct in absence of No Data but with ROI (ROI RasterAccessor not used)
    @Test
    public void testRoiBounds() {
        boolean roiUsed = true;
        boolean noDataRangeUsed = false;
        boolean useROIAccessor = false;

        // Byte data Type
        testStatistics(sourceIMG[0], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Ushort data Type
        testStatistics(sourceIMG[1], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Short data Type
        testStatistics(sourceIMG[2], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Integer data Type
        testStatistics(sourceIMG[3], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Float data Type
        testStatistics(sourceIMG[4], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Double data Type
        testStatistics(sourceIMG[5], band1, roiUsed, noDataRangeUsed, useROIAccessor);

        // Byte data Type
        testStatistics(sourceIMG[0], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Ushort data Type
        testStatistics(sourceIMG[1], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Short data Type
        testStatistics(sourceIMG[2], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Integer data Type
        testStatistics(sourceIMG[3], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Float data Type
        testStatistics(sourceIMG[4], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Double data Type
        testStatistics(sourceIMG[5], band2, roiUsed, noDataRangeUsed, useROIAccessor);
    }

    // This test checks if the statistics are correct in absence of No Data but with ROI (ROI RasterAccessor used)
    @Test
    public void testRoiAccessor() {
        boolean roiUsed = true;
        boolean noDataRangeUsed = false;
        boolean useROIAccessor = true;

        // Byte data Type
        testStatistics(sourceIMG[0], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Ushort data Type
        testStatistics(sourceIMG[1], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Short data Type
        testStatistics(sourceIMG[2], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Integer data Type
        testStatistics(sourceIMG[3], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Float data Type
        testStatistics(sourceIMG[4], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Double data Type
        testStatistics(sourceIMG[5], band1, roiUsed, noDataRangeUsed, useROIAccessor);

        // Byte data Type
        testStatistics(sourceIMG[0], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Ushort data Type
        testStatistics(sourceIMG[1], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Short data Type
        testStatistics(sourceIMG[2], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Integer data Type
        testStatistics(sourceIMG[3], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Float data Type
        testStatistics(sourceIMG[4], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Double data Type
        testStatistics(sourceIMG[5], band2, roiUsed, noDataRangeUsed, useROIAccessor);
    }

    // This test checks if the statistics are correct in absence of ROI but with No Data
    @Test
    public void testNoData() {
        boolean roiUsed = false;
        boolean noDataRangeUsed = true;
        boolean useROIAccessor = false;

        // Byte data Type
        testStatistics(sourceIMG[0], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Ushort data Type
        testStatistics(sourceIMG[1], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Short data Type
        testStatistics(sourceIMG[2], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Integer data Type
        testStatistics(sourceIMG[3], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Float data Type
        testStatistics(sourceIMG[4], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Double data Type
        testStatistics(sourceIMG[5], band1, roiUsed, noDataRangeUsed, useROIAccessor);

        // Byte data Type
        testStatistics(sourceIMG[0], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Ushort data Type
        testStatistics(sourceIMG[1], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Short data Type
        testStatistics(sourceIMG[2], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Integer data Type
        testStatistics(sourceIMG[3], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Float data Type
        testStatistics(sourceIMG[4], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Double data Type
        testStatistics(sourceIMG[5], band2, roiUsed, noDataRangeUsed, useROIAccessor);
    }

    // This test checks if the statistics are correct in presence of No Data and ROI (ROI RasterAccessor not used)
    @Test
    public void testRoiNoData() {
        boolean roiUsed = true;
        boolean noDataRangeUsed = true;
        boolean useROIAccessor = false;

        // Byte data Type
        testStatistics(sourceIMG[0], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Ushort data Type
        testStatistics(sourceIMG[1], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Short data Type
        testStatistics(sourceIMG[2], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Integer data Type
        testStatistics(sourceIMG[3], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Float data Type
        testStatistics(sourceIMG[4], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Double data Type
        testStatistics(sourceIMG[5], band1, roiUsed, noDataRangeUsed, useROIAccessor);

        // Byte data Type
        testStatistics(sourceIMG[0], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Ushort data Type
        testStatistics(sourceIMG[1], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Short data Type
        testStatistics(sourceIMG[2], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Integer data Type
        testStatistics(sourceIMG[3], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Float data Type
        testStatistics(sourceIMG[4], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Double data Type
        testStatistics(sourceIMG[5], band2, roiUsed, noDataRangeUsed, useROIAccessor);
    }

    // This test checks if the statistics are correct in presence of No Data and ROI (ROI RasterAccessor used)
    @Test
    public void testRoiAccessorNoData() {
        boolean roiUsed = true;
        boolean noDataRangeUsed = true;
        boolean useROIAccessor = true;

        // Byte data Type
        testStatistics(sourceIMG[0], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Ushort data Type
        testStatistics(sourceIMG[1], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Short data Type
        testStatistics(sourceIMG[2], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Integer data Type
        testStatistics(sourceIMG[3], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Float data Type
        testStatistics(sourceIMG[4], band1, roiUsed, noDataRangeUsed, useROIAccessor);
        // Double data Type
        testStatistics(sourceIMG[5], band1, roiUsed, noDataRangeUsed, useROIAccessor);

        // Byte data Type
        testStatistics(sourceIMG[0], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Ushort data Type
        testStatistics(sourceIMG[1], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Short data Type
        testStatistics(sourceIMG[2], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Integer data Type
        testStatistics(sourceIMG[3], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Float data Type
        testStatistics(sourceIMG[4], band2, roiUsed, noDataRangeUsed, useROIAccessor);
        // Double data Type
        testStatistics(sourceIMG[5], band2, roiUsed, noDataRangeUsed, useROIAccessor);
    }

    // This method calculates the statistics with the SimpleStatsOpImage and then compares them with the already calculated values.
    public void testStatistics(RenderedImage source, int[] bands, boolean roiUsed,
            boolean noDataRangeUsed, boolean useRoiAccessor) {
        // The precalculated roi is used, if selected by the related boolean.
        ROI roiData;

        if (roiUsed) {
            roiData = roi;
        } else {
            roiData = null;
        }

        // The precalculated NoData Range is used, if selected by the related boolean.
        Range noDataRange;

        if (noDataRangeUsed) {
            int dataType = source.getSampleModel().getDataType();
            switch (dataType) {
            case DataBuffer.TYPE_BYTE:
                noDataRange = noDataByte;
                break;
            case DataBuffer.TYPE_USHORT:
                noDataRange = noDataUShort;
                break;
            case DataBuffer.TYPE_SHORT:
                noDataRange = noDataShort;
                break;
            case DataBuffer.TYPE_INT:
                noDataRange = noDataInt;
                break;
            case DataBuffer.TYPE_FLOAT:
                noDataRange = noDataFloat;
                break;
            case DataBuffer.TYPE_DOUBLE:
                noDataRange = noDataDouble;
                break;
            default:
                throw new IllegalArgumentException("Wrong data type");
            }
        } else {
            noDataRange = null;
        }
        // Index used for indicating which index of the "calculation" array must be taken for reading the precalculated statistic values
        int statsIndex = 0;

        if (roiUsed && noDataRangeUsed) {
            statsIndex = 3;
        } else if (roiUsed) {
            statsIndex = 1;
        } else if (noDataRangeUsed) {
            statsIndex = 2;
        }

        // Simple statistics
        RenderedImage dstSimple = StatisticsDescriptor.create(source, xPeriod, yPeriod, roiData,
                noDataRange, useRoiAccessor, bands, simpleStats, null);
        // Statistic calculation
        Statistics[][] resultSimple = (Statistics[][]) dstSimple
                .getProperty(Statistics.STATS_PROPERTY);

        // Complex statistics
        RenderedImage dstComplex = StatisticsDescriptor
                .create(source, xPeriod, yPeriod, roiData, noDataRange, useRoiAccessor, bands,
                        complexStats, minBound, maxBound, numBins, null);
        // Statistic calculation
        Statistics[][] resultComplex = (Statistics[][]) dstComplex
                .getProperty(Statistics.STATS_PROPERTY);

        // Control only band 0
        Statistics[] stats0 = resultSimple[0];

        // Control only band 0
        Statistics[] stats02 = resultComplex[0];

        // SIMPLE STATISTICS
        // Test if the calculated values are equal with a tolerance value
        for (int i = 0; i < stats0.length; i++) {
            Statistics stat = stats0[i];
            switch (i) {
            case 0:
            case 1:
            case 2:
            case 3:
            case 5:
            case 6:
                double value = (Double) stat.getResult();
                assertEquals(calculations[i][statsIndex], value, TOLERANCE);
                break;
            case 4:
                double[] extrema = (double[]) stat.getResult();
                double max = extrema[1];
                double min = extrema[0];
                assertEquals(calculations[2][statsIndex], max, TOLERANCE);
                assertEquals(calculations[3][statsIndex], min, TOLERANCE);
                break;
            }
        }

        // COMPLEX STATISTICS
        // Test if the calculated values are equal with a tolerance value
        for (int i = 0; i < stats02.length; i++) {
            Statistics stat = stats02[i];
            switch (i + 7) {
            case 7:
                double[] hist2 = (double[]) (stat.getResult());
                for (int j = 0; j < numBins[0]; j++) {
                    assertEquals(hist[i][statsIndex], hist2[i], TOLERANCE);
                }
                break;
            case 8:
            case 9:
                double value = (Double) stat.getResult();
                assertEquals(calculations[i + 6][statsIndex], value, TOLERANCE);
                break;
            }
        }

    }

    // Private method for calculating the bin/index related to the sample
    private static int getIndex(double sample) {
        int index = (int) ((sample - minBound[0]) / binInterval[0]);
        return index;
    }
}


text:
package org.apache.camel.component.infinispan.processor.idempotent;

import java.util.UUID;

import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.spring.CamelSpringTestSupport;
import org.junit.Test;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringInfinispanIdempotentRepositoryIT extends CamelSpringTestSupport {
    @Override
    protected AbstractApplicationContext createApplicationContext() {
        return new ClassPathXmlApplicationContext("org/apache/camel/component/infinispan/processor/idempotent/SpringInfinispanIdempotentRepositoryIT.xml");
    }

    @Test
    public void testIdempotent() throws Exception {
        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedMessageCount(1);

        String messageId = UUID.randomUUID().toString();
        for (int i = 0; i < 5; i++) {
            template.sendBodyAndHeader("direct:start", UUID.randomUUID().toString(), "MessageId", messageId);
        }

        mock.assertIsSatisfied();
    }
}


text:
#ifndef TCRTRACK_H
#define TCRTRACK_H

#include "dcmtk/config/osconfig.h"
#include "dcmtk/dcmiod/modbase.h"
#include "dcmtk/dcmtract/trctypes.h"

/** Class representing a Track of of the "Tractography Results" IOD. This
 *  is the data contained in the items of the Track Sequence.
 */
class DCMTK_DCMTRACT_EXPORT TrcTrack
: public IODComponent
{

public:

  // Allow read/write functions in DcmIODUtil to access class internals
  friend class DcmIODUtil;

  /** Create TrcTrack object from required data
   *  @param  trackDataPoints The data points of the track. Each point consists
   *          of x,y and z coordinate.
   *  @param  numPoints The number of data points (i.e. number of coordinates
   *          divided by 3!)
   *  @param  colors Optional parameter that defines the recommended display
   *          colors for all points. Each color is defined in CIELab space,
   *          which means "L", "a" and "b" value must be defined for each color.
   *          In DICOM, the value range must be 0 <= value <= 65535.
   *  @param  numColors The number of colors in the colors parameter (i.e. number
   *          of L,a,b components divided by 3!). Alternatively, a single
   *          CIELab color can be provided, independent from the number of
   *          points in the track. In that case the color is used to color
   *          all points in the track. See also
   *         setRecommendedDisplayCIELabValues() for more explanations.
   *  @param  trackSet Returns the resulting TrcTrack object (NULL in case of
   *          any error)
   *  @return EC_Normal if Track could be created, error otherwise
   */
  static OFCondition create(const Float32* trackDataPoints,
                            const size_t numPoints,
                            const Uint16* colors,
                            const size_t numColors,
                            TrcTrack*& trackSet /* result */);

  /** Destructor, frees memory
   */
  virtual ~TrcTrack();

  /** Get name of component
   *  @return Name of the module ("TrackSequenceItem")
   */
  virtual OFString getName() const;

  /** Resets rules to their original values
   */
  virtual void resetRules();

  /** Clear all data
   */
  virtual void clearData();

  /** Check whether this component's data satisfies the underlying
   *  rules
   *  @param  quiet If OFTrue, not error / warning messages will be produced. Only
   *                the returned error code will indicate error or OK. Per default,
   *                logging output is produced (OFFalse).
   *  @result EC_Normal if rules are satisfied, error otherwise
   */
  virtual OFCondition check(const OFBool quiet = OFFalse);

  /** Read attributes from given item into this class
   *  @param source  The source to read from
   *  @param clearOldData If OFTrue, old data is cleared before reading. Otherwise
   *         old data is overwritten (or amended)
   *  @result EC_Normal if reading was successful, error otherwise
   */
  virtual OFCondition read(DcmItem& source,
                           const OFBool clearOldData = OFTrue);

  /** Write attributes from this class into given item
   *  @param  destination The item to write to
   *  @result EC_Normal if writing was successful, error otherwise
   */
  virtual OFCondition write(DcmItem& destination);

   /** Get Track Data
    *  @param data  Pointer to the point data
    *  @return Returns number of points in the track or 0 if no points could
    *          be found.
    *  @return EC_Normal if successful, an error code otherwise
    */
  virtual size_t getTrackData(const Float32*& data) const;

  /** Get Number of data points
   */
  virtual size_t getNumDataPoints();

   /** Get Recommended Display CIELab Value. This will only return a result
    *  if a single value is defined to color the Track. Otherwise
    *  getRecommendedDisplayCIELabValueList() must be used.
    *  @param  L Returns L component of CIELab color
    *  @param  a Returns a component of CIELab color
    *  @param  b Returns b component of CIELab color
    *  @return EC_Normal if successful, an error code otherwise
    */
   virtual OFBool getRecommendedDisplayCIELabValue(Uint16& L,
                                                   Uint16& a,
                                                   Uint16& b);

   /** Get Recommended Display CIELab Value List. This will only return a result
    *  if one color per data point is defined.
    *  @param  colors Returns list of colors, each consisting of
    *          L,a,b components
    *  @return Number of colors (i.e. number of components divided
    *          by 3!). If no colors are defined for data points, 0 is returned.
    */
   size_t getRecommendedDisplayCIELabValueList(const Uint16*& colors);

   /** Returns the coloring mode, i.e. whether color is defined for all points
    *  in the track separately, or defined by a single color for the track, or
    *  if the track does not provide color information in which case the Track
    *  Set must provide a color (note that this is not checked, though).
    *  @return The coloring mode
    */
   TrcTypes::E_TrackColorMode getRecommendedDisplayCIELabMode();

  /** Set Track Data
   *  @param  trackDataPoints Array of values to be set, all points
   *          after another with each point consisting of x, y and z component.
   *  @param  numPoints Number of points in array (one point consists
   *          of x, y, and z coordinates)
   *  @return EC_Normal if successful, an error code otherwise
   */
  virtual OFCondition setTrackData(const Float32* trackDataPoints,
                                   const size_t numPoints);

  /** Set Recommended Display CIELab Value (List)
   *  Depending on how many colors are provided, different DICOM is produced
   *  when writing the Track later:
   *  0: No color information for this Track is stored (i.e. neither "Recommended
   *     Display CIELab Value" is set nor "Recommended Display CIELab Value List".
   *     Thus there must be a color definition on Track Set level instead.
   *  1: The given color (consisting of L,a,b component) is recommended to be
   *     used for coloring every point in this track. This color will got to the
   *     element "Recommended Display CIELab value" for this particular track. In
   *     that case, the related Track Set must not have any color recommendation.
   *  >1: The number of colors must be equal to the number of data points. Each
   *     data point color is separately specified. This setting will lead to the
   *     element "Recommended Display CIELab Value List" to be written later.
   *     The related Track Set must not contain any color recommendation at all
   *     in that case.
   *  Note that if the third option (>1) is chosen, it must be provided for
   *  every track in the related Track Set!
   *  @param  colors Array of color values to be set, all colors one
   *          after another with each color consisting of L, a and b component.
   *  @param  numColors Number of colors in array (one point consists
   *          of x, y, and z coordinates).
   *  @return EC_Normal if successful, an error code otherwise
   */
  virtual OFCondition setRecommendedDisplayCIELabValues(const Uint16* colors,
                                                       const size_t numColors);

protected:

  /** Protected constructor, use create() method to create a new track set
   */
  TrcTrack();

  /** Cut off point data in the end if the number of components is not dividable
   *  by 3 (each point must have x,y and z component)
   *  @return OFTrue if situation is ok (after fixing if applicable), otherwise
   *          OFFalse (e.g. in case of an internal error)
   */
  OFBool fixPointCoordinatesDataVM();

};

#endif // TCRTRACK_H


text:
"""General statistical or mathematical functions."""

import math

def TruncatedMean(data_set, truncate_percent):
  """Calculates the truncated mean of a set of values.

  Note that this isn't just the mean of the set of values with the highest
  and lowest values discarded; the non-discarded values are also weighted
  differently depending how many values are discarded.

  Args:
    data_set: Non-empty list of values.
    truncate_percent: How much of the upper and lower portions of the data set
        to discard, expressed as a value in [0, 1].

  Returns:
    The truncated mean as a float.

  Raises:
    TypeError: The data set was empty after discarding values.
  """
  if len(data_set) > 2:
    data_set = sorted(data_set)

    discard_num_float = len(data_set) * truncate_percent
    discard_num_int = int(math.floor(discard_num_float))
    kept_weight = len(data_set) - discard_num_float * 2

    data_set = data_set[discard_num_int:len(data_set)-discard_num_int]

    weight_left = 1.0 - (discard_num_float - discard_num_int)

    if weight_left < 1:
      # If the % to discard leaves a fractional portion, need to weight those
      # values.
      unweighted_vals = data_set[1:len(data_set)-1]
      weighted_vals = [data_set[0], data_set[len(data_set)-1]]
      weighted_vals = [w * weight_left for w in weighted_vals]
      data_set = weighted_vals + unweighted_vals
  else:
    kept_weight = len(data_set)

  truncated_mean = reduce(lambda x, y: float(x) + float(y),
                          data_set) / kept_weight

  return truncated_mean

def Mean(values):
  """Calculates the arithmetic mean of a list of values."""
  return TruncatedMean(values, 0.0)

def Variance(values):
  """Calculates the sample variance."""
  if len(values) == 1:
    return 0.0
  mean = Mean(values)
  differences_from_mean = [float(x) - mean for x in values]
  squared_differences = [float(x * x) for x in differences_from_mean]
  variance = sum(squared_differences) / (len(values) - 1)
  return variance

def StandardDeviation(values):
  """Calculates the sample standard deviation of the given list of values."""
  return math.sqrt(Variance(values))

def RelativeChange(before, after):
  """Returns the relative change of before and after, relative to before.

  There are several different ways to define relative difference between
  two numbers; sometimes it is defined as relative to the smaller number,
  or to the mean of the two numbers. This version returns the difference
  relative to the first of the two numbers.

  Args:
    before: A number representing an earlier value.
    after: Another number, representing a later value.

  Returns:
    A non-negative floating point number; 0.1 represents a 10% change.
  """
  if before == after:
    return 0.0
  if before == 0:
    return float('nan')
  difference = after - before
  return math.fabs(difference / before)

def PooledStandardError(work_sets):
  """Calculates the pooled sample standard error for a set of samples.

  Args:
    work_sets: A collection of collections of numbers.

  Returns:
    Pooled sample standard error.
  """
  numerator = 0.0
  denominator1 = 0.0
  denominator2 = 0.0

  for current_set in work_sets:
    std_dev = StandardDeviation(current_set)
    numerator += (len(current_set) - 1) * std_dev ** 2
    denominator1 += len(current_set) - 1
    if len(current_set) > 0:
      denominator2 += 1.0 / len(current_set)

  if denominator1 == 0:
    return 0.0

  return math.sqrt(numerator / denominator1) * math.sqrt(denominator2)

# Redefining built-in 'StandardError'
# pylint: disable=W0622
def StandardError(values):
  """Calculates the standard error of a list of values."""
  if len(values) <= 1:
    return 0.0
  std_dev = StandardDeviation(values)
  return std_dev / math.sqrt(len(values))


text:
<?php return [
    'plugin' => [
        'name' => 'FileUploader',
        'description' => 'Set a file uploader in frontend'
    ]
];


text:
@interface MonitorSetting () <ScanQrCodeDelegate>
@property(weak) UIViewController *vc;
@property (nonatomic,copy)NSString *senderResut;
@property NSArray* addressList;
@end

static MonitorSetting *monitorSetting;

@implementation MonitorSetting

+ (MonitorSetting *)getMonitorSetting {
    if (!monitorSetting) {
        monitorSetting = [[MonitorSetting alloc] initWithName:NSLocalizedString(@"add_hd_account_monitor", nil) icon:[UIImage imageNamed:@"scan_button_icon"]];
    }
    return monitorSetting;
}

- (instancetype)initWithName:(NSString *)name icon:(UIImage *)icon {
    self = [super initWithName:name icon:icon];
    if (self) {
        [self configureSetting];
    }
    return self;
}

- (void)configureSetting {
    __weak typeof(self) weakSelf = self;
    [self setSelectBlock:^(UIViewController *controller) {
        weakSelf.vc = controller;
        if ([BTAddressManager instance].watchOnlyAddresses.count >= WATCH_ONLY_COUNT_LIMIT) {
            [weakSelf showMsg:NSLocalizedString(@"watch_only_address_count_limit", nil)];
            return;
        }
        ScanQrCodeTransportViewController *scan = [[ScanQrCodeTransportViewController alloc] initWithDelegate:weakSelf title:NSLocalizedString(@"Scan to watch Bither Cold", nil) pageName:NSLocalizedString(@"Bither Cold Watch Only QR Code", nil)];
        scan.modalPresentationStyle = UIModalPresentationFullScreen;
        [weakSelf.vc presentViewController:scan animated:YES completion:nil];
    }];
}

- (void)handleResult:(NSString *)result byReader:(ScanQrCodeViewController *)reader {
    _senderResut = result;
    self.addressList = nil;
    [reader.presentingViewController dismissViewControllerAnimated:YES completion:^{
        [self handleResult];
    }];
}
- (void)handleResult{
    if ([self checkQrCodeContent:_senderResut]) {
        DialogProgress *dp = [[DialogProgress alloc] initWithMessage:NSLocalizedString(@"Please wait…", nil)];
        [dp showInWindow:self.vc.view.window completion:^{
            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
                [self processQrCodeContent:_senderResut dp:dp];
            });
        }];
    } else {
        if (_senderResut.isValidBitcoinAddress || [StringUtil isValidBitcoinBIP21Address:_senderResut]) {
            [self showMsg:NSLocalizedString(@"add_address_watch_only_scanned_address_warning", nil)];
        } else {
            [self showMsg:NSLocalizedString(@"Monitor Bither Cold failed.", nil)];
        }
    }

}

- (void)showMsg:(NSString *)msg {
    if (self.vc && [self.vc respondsToSelector:@selector(showMsg:)]) {
        [self.vc performSelector:@selector(showMsg:) withObject:msg];
    }
}

- (void)processQrCodeContent:(NSString *)content dp:(DialogProgress *)dp {
    NSArray *strs = [BTQRCodeUtil splitQRCode:content];
    NSMutableArray *addressList = [NSMutableArray new];
    NSMutableArray *addressStrList = [NSMutableArray new];
    for (NSString *temp in strs) {
        BOOL isXRandom = NO;
        NSString *pubStr = temp;
        if ([temp rangeOfString:XRANDOM_FLAG].location != NSNotFound) {
            pubStr = [temp substringFromIndex:1];
            isXRandom = YES;
        }
        BTKey *key = [BTKey keyWithPublicKey:[pubStr hexToData]];
        key.isFromXRandom = isXRandom;
        if (!key.publicKey) {
            dispatch_async(dispatch_get_main_queue(), ^{
                [dp dismissWithCompletion:^{
                    [self showMsg:NSLocalizedString(@"Monitor Bither Cold failed.", nil)];
                }];
            });
            return;
        }
        BTAddress *btAddress = [[BTAddress alloc] initWithKey:key encryptPrivKey:nil isSyncComplete:NO isXRandom:key.isFromXRandom addMode:Other];
        [addressList addObject:btAddress];
        [addressStrList addObject:key.address];
    }
    self.addressList = addressList;
    dispatch_async(dispatch_get_main_queue(), ^{
        [dp dismissWithCompletion:^{
            [[[DialogMonitorAddressValidation alloc]initWithAddresses:addressStrList target:self andOkSelector:@selector(monitorAddressValidationSuccess)] showInWindow:self.vc.view.window];
        }];
    });
}

- (void)monitorAddressValidationSuccess{
    DialogProgress *dp = [[DialogProgress alloc] initWithMessage:NSLocalizedString(@"Please wait…", nil)];
    [dp showInWindow:self.vc.view.window completion:^{
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
            [KeyUtil addAddressList:self.addressList];
            dispatch_async(dispatch_get_main_queue(), ^{
                [dp dismissWithCompletion:^{
                    [self showMsg:NSLocalizedString(@"add_hd_account_monitor_success", nil)];
                    if (self.vc && [self.vc respondsToSelector:@selector(reload)]) {
                        [self.vc performSelector:@selector(reload)];
                    }
                }];
            });
        });
    }];
}

- (BOOL)checkQrCodeContent:(NSString *)content {
    NSArray *strs = [BTQRCodeUtil splitQRCode:content];
    for (NSString *str in strs) {
        BOOL checkCompress = (str.length == 66) || (str.length == 67 && [str rangeOfString:XRANDOM_FLAG].location != NSNotFound);
        BOOL checkUncompress = (str.length == 130) || (str.length == 131 && [str rangeOfString:XRANDOM_FLAG].location != NSNotFound);
        if (!checkCompress && !checkUncompress) {
            return NO;
        }
    }
    return YES;
}

@end


text:
define([
    'jquery',
    'underscore',
    'backbone',
    '../collections/Collection',
    'views/Page',
    'views/StaticPage',
    'views/StoresView'
], function ($, _, Backbone, ApplicationConfigurationCollection, ApplicationConfigurationPageView, ApplicationConfigurationStaticPageView, ApplicationConfigurationStoresView) {

    return Backbone.Router.extend({

        view: null,        // current view instance
        appConfigs: {},            // a map of the app config models associated by groupName
        viewModels: {},

        container: $('body'),

        routes: {
            'config/:id': 'showGroup'
        },

        initialize: function() {
            _.bindAll(this, 'sortAndIndexModels');
            this.collection = new ApplicationConfigurationCollection();
            var me = this;
            //TODO: load with initial models already bootstrapped?
            this.collection.fetch().complete(function() {
                me.sortAndIndexModels();
                me.showGroup('AUDITING');
            });
        },

        cleanup: function () {
            this.view && this.view.remove();
            delete this.view;
        },

        showGroup: function (name) {
            this.cleanup();
            this.collection.fetch();
            switch (name) {
                case "store":
                    this.view = new ApplicationConfigurationStoresView();
                    break;
                default:
                    this.view = new ApplicationConfigurationPageView({ collection: new ApplicationConfigurationCollection() });
                    this.view.appConfigs = this.appConfigs;
                    this.view.collection.reset(this.viewModels[name]);
                    break;
            }
            this.container.append(this.view.el);
        },

        //set appConfigs to model references indexed by code
        //set viewModels to lists of model references indexed by groupName
        sortAndIndexModels: function() {
            this.appConfigs = _.groupBy(this.collection.models, function(m){ return m.get("code"); });
            this.viewModels = _.chain(this.collection.models)
                .sortBy(function(m){ return m.get("id"); })
                .groupBy(function(m){ return m.get("groupName"); })
                .value();
        }

    });
});


text:
package com.ymsino.water.service.archives.waterMeter;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;

/**
 *

 * Java class for getById complex type.
 *
 *

 * The following schema fragment specifies the expected content contained within
 * this class.
 *
 *

 * <complexType name="getById">
 *   <complexContent>
 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       <sequence>
 *         <element name="hardwareId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *       </sequence>
 *     </restriction>
 *   </complexContent>
 * </complexType>
 *

 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "getById", propOrder = { "hardwareId" })
public class GetById {

	protected String hardwareId;

	/**
	 * Gets the value of the hardwareId property.
	 *
	 * @return possible object is {@link String }
	 *
	 */
	public String getHardwareId() {
		return hardwareId;
	}

	/**
	 * Sets the value of the hardwareId property.
	 *
	 * @param value
	 *            allowed object is {@link String }
	 *
	 */
	public void setHardwareId(String value) {
		this.hardwareId = value;
	}

}


text:
/* ecc signature example */
/* In this directory do

       gcc -U __SIZEOF_INT128__ -E ecc-example.c > ../ecc.c

   to obtain a single C file that you can compile with smpcc.

   Here the "-U __SIZEOF_INT128__" causes uECC.c to be compiled
   without support for 128 bit ints, which CIL cannot handle.

   You must use gcc on Linux b/c on Mac OS X you will encounter CIL
   errors.
*/

#include <stdio.h>
#include "uECC.c"

extern unsigned int input(unsigned int);
extern unsigned int num_peers();

unsigned char private_key[32];
uint8_t p_hash[uECC_BYTES];
uint8_t p_signature[uECC_BYTES*2];

int main() {
  for (unsigned int i = 1; i < num_peers(); i++) {
    unsigned char val = input(i);
    private_key[0] ^= val;
  }
  uECC_sign(private_key, p_hash, p_signature);

  printf("Signature:\n");
  for (unsigned int i = 0; i < 64; i++)
  {
    printf("%x ", p_signature[i]);
  }
  printf("\n");

  return 0;
}