text:
The `termios` crate provides safe bindings for the Rust programming language to the [terminal I/O
interface](http://pubs.opengroup.org/onlinepubs/009695399/basedefs/termios.h.html) implemented by
Unix operating systems. The safe bindings are a small wrapper around the raw C functions, which
converts integer return values to `std::io::Result` to indicate success or failure.

* [Documentation](http://dcuddeback.github.io/termios-rs/termios/)

## Project Status

This is a very low-maintenance project. The termios API is decades old. This isn't an area that you
should expect to see daily commits, so don't be put off if you don't see commits for several years.
This just means that the project is stable. That's a good thing. :)

If, however, you see old patches that you'd like to see land, please see
[`CONTRIBUTING.md`](CONTRIBUTING.md) to see how you can help.

## Dependencies & Compatibility

In order to use the `termios` crate, you must have a native `libc` library that implements the
termios API. This should be available on any Unix operating system. This library contains the
termios definitions for the following platforms:

* Linux (x86_64, armv6l)
* Android (x86)
* OS X (x86_64)
* FreeBSD (amd64)
* OpenBSD (amd64)
* NetBSD (amd64)
* DragonFly BSD (x86_64)
* illumos (x86_64)

If you're interested in a platform that's not listed here, please see
[`CONTRIBUTING.md`](CONTRIBUTING.md) to see how you can help.

## Usage

Add `termios` as a dependency in `Cargo.toml`:

```toml
[dependencies]
termios = "0.3"
```

Import the `termios` crate and any symbols needed from `termios`. You may also need
`std::os::unix::io::RawFd` for file descriptors and `std::io::Result` to propagate errors.

```rust
extern crate termios;

use std::io;
use std::os::unix::io::RawFd;

use termios::*;

fn setup_fd(fd: RawFd) -> io::Result<()> {
  let mut termios = try!(Termios::from_fd(fd));

  termios.c_iflag = IGNPAR | IGNBRK;
  termios.c_oflag = 0;
  termios.c_cflag = CS8 | CREAD | CLOCAL;
  termios.c_lflag = 0;

  try!(cfsetspeed(&mut termios, B9600));
  try!(tcsetattr(fd, TCSANOW, &termios));
  try!(tcflush(fd, TCIOFLUSH));

  Ok(())
}
```

## License

Copyright © 2015 David Cuddeback

Distributed under the [MIT License](LICENSE).


text:
<?php
/**
 * Created by Suley.
 * User: suley
 * Date: 1/21/14
 * Time: 2:06 AM
 */

class VisaOrder extends CActiveRecord{
    public $id,$customer_agency_id,$customer_ids, $status,$country,$predict_date, $type,$amount,$price,$depart_date,$source,$contact_name,$contact_phone,$contact_address,$memo,$material,$is_pay,$create_time, $user_id,$accountant_id ,$pay_cert,$op_id ,$op_comment ,$op_time ,$sent_id ,$sent_comment ,$sent_time ,$issue_id ,$issue_comment,$issue_time,$back_id,$back_comment,$back_time, $sent_agency_source, $search_customer, $delete_time, $delete_id, $delete_comment;
    public $_old;
    public $notInList;
    public $agencyIdNotNull = false;
    public $start_time, $end_time;
    public $pagination = array('pageSize'=>25);
    /* Total Status */
    const STATUS_SALES_ORDER = 'sales_ordered';
    const STATUS_OP_CONFIRM = 'op_confirm';
    const STATUS_PARTIAL_SENT = "visa_partial_sent";
    const STATUS_SENTOUT = 'visa_sent';
    const STAUTS_ISSUE_VISA = 'issue_visa';
    const STATUS_SENTBACK = 'visa_back';
    const STATUS_RECEIVED = 'received';
    const STATUS_COMPLETE = 'complete';
    const STATUS_DELETE = 'delete';
    //Status Decode
    public static $statusIntl = array(
        self::STATUS_SALES_ORDER => '操作待确认',
        self::STATUS_OP_CONFIRM => '待送签',
        self::STATUS_PARTIAL_SENT => "部分送签",
        self::STATUS_SENTOUT => '已送签',
        self::STAUTS_ISSUE_VISA => '已出签',
        self::STATUS_SENTBACK => '已寄回',
        self::STATUS_RECEIVED => '已接受',
        self::STATUS_COMPLETE => '订单完结',
        self::STATUS_DELETE => '订单已删除'
    );

    /* Sub Sent Status */
    const SENT_NO = 'no';
    const SENT_PARTIAL = 'partial';
    const SENT_ALL = 'all';

    /* Sub Issue Status */

    public function attributeLabels(){
        return array(
            'status' => '状态',
            'country' => '国家',
            'customer_agency_id'=>'送签渠道',
            'predict_date' => '预测出签', 'type' => '类型','amount' => '人数','price' => '价格','depart_date' => '出发日期','source' => '订单来源','contact_name' => '联系人姓名','contact_phone' => '电话','contact_address' => '地址','memo' => '备注','material' => '材料','is_pay' => '支付状态','create_time' => '下单时间', 'user_id' => '下单人','accountant_id' => '财务审核','pay_cert' => '支付凭证','op_id' => '操作人','op_comment' => '操作备注','op_time' => '操作时间','sent_id' => '送签人','sent_comment' => '送签备注','sent_time' => '送签时间','issue_id' => '出签人','issue_comment' => '出签备注','issue_time' => '出签时间','back_id' => '物流操作','back_comment' => '物流信息','back_time'=>'物流时间','customer'=>'客户信息', 'order_type'=>'订单信息','sent_agency_source'=>'送签旅行社','delete_id'=>'删除人员', 'delete_comment'=>'删除理由', 'delete_time'=>'删除时间'
        );
    }
    public static function model($className = __CLASS__){
        return parent::model($className);
    }
    public function tableName(){
        return 'visa_order';
    }
    public function beforeSave(){
        if(is_array($this->material)){
            $this->material = implode(',', $this->material);
        }
        if(!is_numeric($this->depart_date)){
            $this->depart_date = strtotime($this->depart_date);
        }
        //if(!is_numeric($this->predict_date)){
        //    $this->predict_date = strtotime($this->predict_date);
        //}
        if($this->isNewRecord){
            $this->create_time = strtotime('now');
        }else{
            if($this->is_pay == 1){
                $oldRecord = self::model()->findByPk($this->id);
                if($oldRecord->is_pay == 0){
                    $this->accountant_id = Yii::app()->user->id;
                    $this->memo = $this->memo."\n".User::getUserRealname(Yii::app()->user->id)."于".date("Y-m-d H:i")."更新了订单:订单状态更改为已支付。";
                    foreach($this->customer as $customer){
                        $customer->is_pay = 1;
                        $customer->save();
                    }
                }
            }elseif($this->is_pay == 0){
                $oldRecord = self::model()->findByPk($this->id);
                if($oldRecord->is_pay == 1){
                    $this->accountant_id = Yii::app()->user->id;
                    $this->memo = $this->memo."\n".User::getUserRealname(Yii::app()->user->id)."于".date("Y-m-d H:i")."更新了订单:订单状态变更为未支付。";
                }
            }
        }

        if(isset($this->_old)){
            if($this->_old->status != $this->status){
                $message = new PanelMessage();
                $message->addMessage('订单状态修改', 'createUrl('panel/visa/update', array('id'=>$this->id)).'\'>订单#'.$this->id.' 状态从['.self::$statusIntl[$this->_old->status].']变更为['.self::$statusIntl[$this->status].']', PanelMessage::TYPE_NOTICE, $this->user_id);
            }
            if($this->_old->is_pay == 1 && $this->is_pay == 0){
                $this->is_pay = 1;
            }
        }

        $this->need_pay_out_amount = VisaOrder::sumCustomerVal($this->customer);

        return parent::beforeSave();
    }
    public function afterFind(){
        $this->material = explode(',', $this->material);
        if(is_numeric($this->depart_date)){
            $this->depart_date = date('Y-m-d',$this->depart_date);
        }
        if(intval($this->total_price) == 0){
            $this->total_price = floatval($this->price * $this->amount);
        }
        $this->_old = clone $this;
        return parent::afterFind();
    }
    public function relations(){
        //TODO: add condition to both $on statement.
        $on = '(customer.status IS NULL OR customer.status != '.VisaOrderCustomer::STATUS_DELETED.') ';
        if(!empty($this->customer_agency_id)){
            $on = 'customer.agency_id = '.$this->customer_agency_id.' AND customer.status != '.VisaOrderCustomer::STATUS_DELETED;;
        }
        if(!empty($this->customer_ids) && is_array($this->customer_ids)){
            $on = 'customer.id IN ('.implode(',', $this->customer_ids).')';
        }
        return array(
            'customer'=>array(self::HAS_MANY, 'VisaOrderCustomer','visa_order_id', 'on'=>$on),
            'order_source' => array(self::BELONGS_TO, 'OrderSource', 'source'),
            'order_type' => array(self::BELONGS_TO, 'VisaType', 'type'),
            'country_source' => array(self::BELONGS_TO, 'Address', 'country'),
            'agency_source' => array(self::BELONGS_TO, 'OrderSource', 'sent_agency_source'),
            'agency' => array(self::BELONGS_TO, 'VisaTypeAgency', 'agency_id'),
            'financeRecord'=>array(self::HAS_ONE, 'FinanceItems', 'vid', 'on'=>'financeRecord.type = "'.FinanceItems::TYPE_VISA_ORDER.'"'),
            'stat_cost_price'=>array(self::STAT, 'VisaOrderCustomer', 'visa_order_id', 'select'=>'SUM(cost_price)' ),
            'stat_price'=>array(self::STAT, 'VisaOrderCustomer', 'visa_order_id', 'select'=>'SUM(price)' ),
        );
    }
    public function rules(){
        return array(
            //array('id, status,country,predict_date,type,amount,price,depart_date,source,contact_name,contact_phone,contact_address,memo,material,is_pay,create_time, user_id,accountant_id ,pay_cert,op_id ,op_comment ,op_time ,sent_id ,sent_comment ,sent_time ,issue_id ,issue_comment,issue_time,back_id,back_comment,back_time','safe',),
            array('_old,customer_agency_id, agencyIdNotNull, total_price, predict_date, id, status,depart_date,memo,create_time, single_price, user_id,accountant_id ,pay_cert,op_id ,op_comment ,op_time ,sent_id ,sent_comment ,sent_time ,issue_id ,issue_comment,issue_time,back_id,back_comment,back_time,is_pay,sent_agency_source, delete_id, delete_comment, delete_time, start_time, end_time, agency_id, is_pay_out','safe'),
            array('price,country,type,amount,source,contact_name,contact_phone,material,amount', 'required'),
            array('country', 'numerical'),
            array('type', 'numerical'),
            array('amount', 'numerical'),
            array('price', 'numerical'),
            array('source', 'numerical'),
            array('contact_name', 'length', 'min'=> 2, 'max'=> 10),
            array('contact_phone', 'length', 'min'=> 7, 'max'=> 15),
            array('contact_address', 'length', 'min'=> 10, 'max'=> 255),
            array('is_pay', 'numerical')
        );
    }
    public static function translateStatus($status){
        if(!empty(self::$statusIntl[$status]))
            return self::$statusIntl[$status];
        else
            return '';
    }
    public static function allLists(){
        $criteria = new CDbCriteria;
        //$criteria->compare('id', $this->id);
        return new CActiveDataProvider('VisaOrder', array(
            'criteria' => $criteria,
        ));
    }

    public function getSearchCriteria()
    {
        $criteria = new CDbCriteria;
        $criteria->with = array('customer'=>array('select'=>'customer.*','together'=>true));
        $criteria->alias = 'order';
        $criteria->compare('order.id', $this->id);
        if(!empty($this->notInList) && is_array($this->notInList)){
            $criteria->addNotInCondition('order.id', $this->notInList);
        }
        $criteria->compare('order.is_pay_out', $this->is_pay_out);
        $criteria->compare('order.country', $this->country);
        $criteria->compare('order.is_pay', $this->is_pay);
        $criteria->compare('order.amount', $this->amount);
        $criteria->compare('order.user_id', $this->user_id);
        $criteria->compare('order.source', $this->source);
        if(empty($this->status)){
            $criteria->addNotInCondition('order.status', array(VisaOrder::STATUS_DELETE));
        }elseif(is_array($this->status)){
            $criteria->addInCondition('order.status', $this->status);
        }else{
            $criteria->addInCondition('order.status', array($this->status));
        }
        if(!empty($this->start_time) && !empty($this->end_time)){
            $criteria->addBetweenCondition('order.create_time', strtotime($this->start_time), strtotime($this->end_time." +1 days"));
        }
        /*

        if(!empty($_GET['customer_name'])){
            $this->search_customer = trim($_GET['customer_name']);
            $criteria->compare('customer.name', $this->search_customer, true);
            $criteria->with = array('customer'=>array('select'=>'customer.name','together'=>true));
            //$criteria->join = 'visa_order_customer';
        }*/

        if(!empty($this->customer_agency_id)){
            $criteria2 = new CDbCriteria;
            $criteria2->addCondition('agency_id = '.$this->customer_agency_id);
            $agencyResult = VisaTypeAgency::model()->findAll($criteria2);
            $agencyKeys= array();
            foreach($agencyResult as $agency){
                array_push($agencyKeys, $agency->id);
            }
            $criteria->addInCondition('customer.agency_id', $agencyKeys);
            //$criteria->compare('customer.is_pay_out', 0, false);
            $criteria->with = array('customer'=>array('select'=>'customer.*','together'=>true));
            //$criteria->join = 'visa_order_customer';
        }
        if(is_array($this->customer_ids)){
            $criteria->addInCondition('customer.id', $this->customer_ids);
            $criteria->with = array('customer'=>array('select'=>'customer.*','together'=>false));
        }

        return $criteria;
    }

    public function getUnpaidAmount(){
        $criteria = new CDbCriteria();
        $criteria->addCondition('is_pay = 0');
        $criteria->addCondition('status != "'.VisaOrder::STATUS_DELETE.'"');
        $criteria->select = "SUM(total_price)";
        return $this->commandBuilder->createFindCommand($this->getTableSchema(),$criteria)->queryScalar();
    }

    public function getUnpayoutAmount(){
        $criteria = new CDbCriteria();
        $criteria->addCondition('is_pay_out != 1 AND need_pay_out_amount > 0');
        $criteria->addCondition('status != "'.VisaOrder::STATUS_DELETE.'"');
        $criteria->select = "SUM(need_pay_out_amount-pay_out_amount)";
        return $this->commandBuilder->createFindCommand($this->getTableSchema(),$criteria)->queryScalar();
    }

    public function getTotals()
    {
        $criteria = $this->getSearchCriteria();
        $criteria->select = "SUM(amount*price)";
        return $this->commandBuilder->createFindCommand($this->getTableSchema(),$criteria)->queryScalar();
    }

    public function getCollectionTotals()
    {
        $criteria = $this->getSearchCriteria();
        $result = self::model()->findAll($criteria);
        $totalVal = 0.00;
        foreach($result as $key=>$val){
            if(!empty($val->financeRecord)){
                $totalVal += $val->financeRecord->transaction_value;
            }

        }
        return $totalVal;
    }

    public function getOrderTotals(){
        $criteria = $this->getSearchCriteria();
        return self::model()->count($criteria);
    }

    public function getSentTotals(){
        $criteria = $this->getSearchCriteria();
        $result = self::model()->findAll($criteria);
        $totalVal = 0;
        foreach($result as $key=>$val){
            $totalVal += count($val->customer);

        }
        return $totalVal;
    }

    public function getPayTotals()
    {
        $criteria = $this->getSearchCriteria();
        $result = self::model()->findAll($criteria);
        $totalVal = 0.00;
        foreach($result as $key=>$val){
            if(!empty($val->stat_cost_price)){
                $totalVal += $val->stat_cost_price;
            }

        }
        return $totalVal;
    }

    public function getPriceTotals()
    {
        $criteria = $this->getSearchCriteria();
        $result = self::model()->findAll($criteria);
        $totalVal = 0.00;
        foreach($result as $key=>$val){
            if(!empty($val->stat_price)){
                $totalVal += $val->stat_price;
            }

        }
        return $totalVal;
    }
    public function getCostPriceTotals()
    {
        $criteria = $this->getSearchCriteria();
        $result = self::model()->findAll($criteria);
        $totalVal = 0.00;
        foreach($result as $key=>$val){
            if(!empty($val->stat_price)){
                $totalVal += $val->stat_cost_price;
            }

        }
        return $totalVal;
    }
    //TODO: Fix this function
    public function getCostPriceUnpaidTotals()
    {
        $criteria = $this->getSearchCriteria();
        $result = self::model()->findAll($criteria);
        $totalVal = 0.00;
        foreach($result as $key=>$val){
            if(!empty($val->stat_price)){
                $totalVal += $val->stat_cost_price;
            }

        }
        return $totalVal;
    }

    public function getCountryTotals()
    {
        $criteria = $this->getSearchCriteria();
        $criteria->select = "SUM(amount*price)";
        return $this->commandBuilder->createFindCommand($this->getTableSchema(),$criteria)->queryScalar();
    }

    public function getAmountTotals()
    {
        $criteria = $this->getSearchCriteria();
        $criteria->with = array('customer'=>array('select'=>'customer.*','together'=>true));
        $criteria->select = "SUM(amount)";
        return $this->commandBuilder->createFindCommand($this->getTableSchema(),$criteria)->queryScalar();
    }

    public function search($params = array('order'=>'order.create_time DESC', 'pagination'=>array('pageSize'=>'25'))){
        $criteria = new CDbCriteria;
        $criteria->alias = 'order';
        $criteria->compare('order.id', $this->id);
        if(!empty($this->notInList) && is_array($this->notInList)){
            $criteria->addNotInCondition('order.id', $this->notInList);
        }
        $criteria->compare('order.is_pay_out', $this->is_pay_out);
        $criteria->compare('order.country', $this->country);
        $criteria->compare('order.is_pay', $this->is_pay);
        $criteria->compare('order.amount', $this->amount);
        $criteria->compare('order.user_id', $this->user_id);
        $criteria->compare('order.source', $this->source);

        if(empty($this->status)){
            $criteria->addNotInCondition('order.status', array(VisaOrder::STATUS_DELETE));
        }elseif(is_array($this->status)){
            $criteria->addInCondition('order.status', $this->status);
        }else{
            $criteria->addInCondition('order.status', array($this->status));
        }
        if(!empty($this->start_time) && !empty($this->end_time)){
            $criteria->addBetweenCondition('order.create_time', strtotime($this->start_time), strtotime($this->end_time." +1 days"));
        }

        if(!empty($_GET['customer_name'])){
            $this->search_customer = trim($_GET['customer_name']);
            $mergeCriteria = new CDbCriteria;
            $mergeCriteria->compare('customer.name', $this->search_customer, true, "OR");
            $mergeCriteria->compare("customer.passport", $this->search_customer, true, "OR");
            $mergeCriteria->with = array('customer'=>array('select'=>'customer.name','together'=>true));
            $criteria->mergeWith($mergeCriteria);
        }

        if(!empty($this->customer_agency_id)){
            $criteria2 = new CDbCriteria;
            $criteria2->addCondition('agency_id = '.$this->customer_agency_id);
            $agencyResult = VisaTypeAgency::model()->findAll($criteria2);
            $agencyKeys= array();
            foreach($agencyResult as $agency){
                array_push($agencyKeys, $agency->id);
            }
            $criteria->addInCondition('customer.agency_id', $agencyKeys);
            $criteria->addNotInCondition('customer.status', array(VisaOrderCustomer::STATUS_DELETED, VisaOrderCustomer::STATUS_DEFAULT));
            if(!isset($criteria->with['customer'])){
                $criteria->with = array('customer'=>array('select'=>'customer.*','together'=>true));
            }
        }

        if(count($this->customer_ids) >= 1 && is_array($this->customer_ids)){
            $criteria->addInCondition('customer.id', $this->customer_ids);
            if(!isset($criteria->with['customer'])){
                $criteria->with = array('customer'=>array('select'=>'customer.*','together'=>true));
            }

        }

        $pagination = empty($params['pagination']) ? false : array('pageSize'=>25);

        if($this->agencyIdNotNull){
            $result = VisaOrder::model()->findAll($criteria);
            foreach($result as $key=>$item){
                if(count($item->customer) == 0){
                    unset($result[$key]);
                }
            }
            return new CArrayDataProvider($result);
        }else{
            return new CActiveDataProvider('VisaOrder', array(
                'criteria' => $criteria,
                'sort' => array(
                    'defaultOrder'=>$params['order']
                ),
                'pagination' => $pagination
            ));
        }

    }

    public function searchForReport($returnType = 'DataProvider'){
        if(!empty($_POST['start_date'])){
            $startTime = strtotime($_POST['start_date']);
            $endTime = strtotime($_POST['start_date']." + 1 days");

        }else{
            $startTime = strtotime('now - 1 years');
            $endTime = strtotime("now + 1 years");
        }
        $data = VisaOrder::model()->findAll('status = :status AND sent_time BETWEEN :start_time AND :end_time ', array(':status'=>VisaOrder::STATUS_SENTOUT,':start_time'=>$startTime, ':end_time'=>$endTime));

        $compareDuplicate = array();
        foreach($data as $key=>&$records){
            $tempKey = "country".$records->country."sent_agency_source".$records->sent_agency_source."type";
            if(array_key_exists($tempKey, $compareDuplicate)){
                $compareDuplicate[$tempKey]['amount'] += $records->amount;
                $compareDuplicate[$tempKey]['customers'] = array_merge($compareDuplicate[$tempKey]['customers'], (array)$records->customer);
            }else{
                $compareDuplicate[$tempKey]['key'] = $records->id;
                $compareDuplicate[$tempKey]['amount'] = $records->amount;
                $compareDuplicate[$tempKey]['customers'] = (array)$records->customer;
            }
        }

        foreach($data as $key=>&$records){
            $tempKey = "country".$records->country."sent_agency_source".$records->sent_agency_source."type";
            if(array_key_exists($tempKey, $compareDuplicate) && $compareDuplicate[$tempKey]['key'] != $records->id){
               unset($records);
            }else{
                $records->amount = $compareDuplicate[$tempKey]['amount'];
                $records->customer = (object)$compareDuplicate[$tempKey]['customers'];
            }
        }
        if($returnType == 'DataProvider'){
            $data = new CArrayDataProvider($data, array(
                'pagination'=>array(
                    'pageSize' => 10000
                )
            ));
        }

        return $data;
    }

    public function beforeDelete(){
        $name = Yii::app()->user->name;
        $id = Yii::app()->user->id;

        parent::beforeDelete();
        return true;
    }

    public function afterDelete(){
        parent::afterDelete();
        VisaOrderCustomer::model()->deleteAllByAttributes(array('visa_order_id'=>$this->id));
        return true;
    }

    public static function deleteVisaRecord($id){
        self::model()->deleteByPk($id);

        return true;
    }
    public static function translateMaterial($material){
        $mat_base = array('photo'=>'照片', 'passport'=>'护照', 'residence'=>'户口本', 'financeproof'=>'财力证明', 'id'=>'身份证');
        return $mat_base[$material];
    }

    public static function findOutStatus($type){
        switch($type){
            case 'op':
                $status = self::STATUS_OP_CONFIRM;
                break;
            case 'sent':
                $status = self::STATUS_SENTOUT;
                break;
            case 'issue':
                $status = self::STAUTS_ISSUE_VISA;
                break;
            case 'back':
                $status = self::STATUS_SENTBACK;
                break;
        }
        return $status;
    }

    public static function findOutCurrentStatus($id){

    }

    public static function stat(){
        $count = array();
        $count['complete'] = self::model()->countByAttributes(array('status'=>self::STATUS_COMPLETE));
        $count['not_sent'] = self::model()->countByAttributes(array('status'=>array(self::STATUS_OP_CONFIRM, self::STATUS_SALES_ORDER)));
        $count['ongoing'] = self::model()->count('status != :status', array(':status'=>self::STATUS_COMPLETE));
        $count['wait_for_issue'] = self::model()->countByAttributes(array('status'=>self::STATUS_SENTOUT));
        $count['is_not_paid'] = self::model()->count('is_pay = :pay', array(':pay'=>0));
        $tempAmount = Yii::app()->db->createCommand('SELECT sum(price) as sum FROM visa_order WHERE is_pay = 0')->queryScalar();;
        $count['total_amount'] = $tempAmount;
        return $count;
    }

    public static function joinCustomer($data){
        $cutomer = array();
        foreach($data as $v){
            $customerInstance = VisaOrderCustomer::model()->findByPk($v->id);
            array_push($cutomer, $v->name."(".$customerInstance->passport.")");
        }
        return implode('
', $cutomer);
    }

    public static function joinCustomerByHiddenInput($data, $id){
        $cutomer = array();
        foreach($data as $v){
            array_push($cutomer, $v->id);
        }
        return CHtml::hiddenField('VisaOrderCustomerIds['.$id.']', implode(',', $cutomer));
    }

    /*
     * Find order and customer filter by customer id and order id
     * @param $cId array
     * @param $oId array
     */
    public function complexOrderProcessByCustomersAndAgency($cId, $oId){
        if(is_array($cId) && is_array($oId)){
            $this->unsetAttributes();
            $this->customer_ids = $cId;
            $this->id = $oId;
            $orders = $this->search();
            return $orders;
        }
        return false;
    }

    public static function joinCustomerByNewLine($data){
        $cutomer = array();
        foreach($data as $v){
            array_push($cutomer, $v->name."[护照号:".$v->passport."]");
        }
        return implode('|', $cutomer);
    }

    public static function getFirstCustomer($data){
        $customer = array();
        foreach($data as $v){
            array_push($customer, $v->name);
        }
        $firstCustomer = '';
        if(isset($customer[0])){
            if(count($customer) > 1){
                $firstCustomer = $customer[0]."等";
            }else{
                $firstCustomer = $customer[0];
            }

        }
        return $firstCustomer;
    }

    public static function sumCustomerVal($customers){
        $total_price = 0.00;
        foreach($customers as $customer){
            if(!empty($customer->cost_price)){
                $total_price += floatval($customer->cost_price);
            }
        }
        return $total_price;
    }
    public static function getCustomerPayMethod($customers){
        $method = array();
        foreach($customers as $customer){
            if(!empty($customer->financeRecord->record)){
                if(!array_key_exists($customer->financeRecord->record->charge_account_id, $method)){
                    $method[$customer->financeRecord->record->charge_account_id] = $customer->financeRecord->record->charge_account->name;
                }
            }
        }
        if(count($method > 1)){
            return implode("
", $method);
        }else{
            return $method[0];
        }
    }

    public static function compareStatus($current, $compare){
        $status = self::$statusIntl;
        if(array_key_exists($current,$status) && array_key_exists($compare, $status)){
            $counter = 0;
            $compareIndex = 0;
            $currentIndex = 0;
            foreach($status as $key=>$val){
                if($key == $current){
                    $currentIndex = $counter;
                }
                if($key == $compare){
                    $compareIndex = $counter;
                }
                $counter++;
            }
            if($currentIndex >= $compareIndex){
                return true;
            }else{
                return false;
            }
        }
        return false;
    }

}

redpajama_set_name: RedPajamaGithub


text:
import test from 'blue-tape'

import xargs from '../src'

test('plugin-xargs: export', async (t) => {
  t.equals(
    typeof xargs,
    'function',
    'must be a function'
  )
})


text:
package net.safedata.spring.data.jdbc.service;

import net.safedata.spring.data.jdbc.domain.entity.Product;
import net.safedata.spring.data.jdbc.domain.repository.ProductRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ProductService {

    private final ProductRepository productRepository;

    @Autowired
    public ProductService(final ProductRepository productRepository) {
        this.productRepository = productRepository;
    }

    public Iterable<Product> findAll() {
        return productRepository.findAll();
    }
}


text:
layout: bt_wiki
title: Offline Guide
category: Guides
publish: true
abstract: Configuring Cloudify to work in an offline environment
pageord: 800

---
{{% gsSummary %}}

# Overview

This guide will quickly explain how to bootstrap and install a simple blueprint using an Offline OpenStack environment.

We will create a PyPi mirror and an HTTP server with relevant files, that will serve our Cloudify manager and agents.

We will be using [Bandersnatch](https://pypi.python.org/pypi/bandersnatch) as a PyPi mirror and [NGINX](http://nginx.org/) as an HTTP server for Cloudify and proxy to Bandersnatch.

{{% gsNote title="Note" %}}
For initial setup of our PyPi mirror / HTTP server we will need an internet connection.
{{% /gsNote %}}

# Step By Step Tutorial

## Setup the PyPi mirror and HTTP server

### Step 1 - Launch an instance

Launch an Ubuntu instance in OpenStack on a particular network (should be connected to the external network for now) and attach a floating ip to it.
This instance will serve as our PyPi mirror and HTTP server.
This instance will have to store a full PyPi copy, so consider your disk size.

### Step 2 - Install and configure Bandersnatch and NGINX

- Copy the following files to the instance that you have just created:

    - [provision.sh](https://raw.githubusercontent.com/cloudify-cosmo/cloudify-packager/7e7ee9c9422b4fe91cba54adcd2ca339b23e8ab9/offline-configuration/provision.sh)
    - [nginx.conf](https://raw.githubusercontent.com/cloudify-cosmo/cloudify-packager/7e7ee9c9422b4fe91cba54adcd2ca339b23e8ab9/offline-configuration/nginx.conf)
    - [bandersnatch.conf](https://raw.githubusercontent.com/cloudify-cosmo/cloudify-packager/7e7ee9c9422b4fe91cba54adcd2ca339b23e8ab9/offline-configuration/bandersnatch.conf)

- Configure the `HOME_FOLDER` and `FILES_DIR` variables in `provision.sh` to point at the user's home folder and to a folder that stores these files, accordingly.
- Run `provision.sh` , note that this script starts a `nohup` process that clones PyPi (100 GB+), so this process might take some time, depending on your network connection and PyPi.

After this process has finished we have a PyPi mirror and an HTTP server up and running.

### Step 3 - Adding relevant files to our HTTP server
Now we need to **recursively** add to the HTTP server all the files that will be used by our Blueprint, in order to make them available to Cloudify.
In our `bandersnatch.conf` file we have configured the following:

    location /cloudify/ {
        root /srv/;
    }

This means that nginx will serve the files located under `/srv/cloudify` on `<server-ip>:<server-port>/cloudify`. So we need to make every file that is used in our blueprint available under /srv/cloudify.
For example have a look at the [Hello-World example](https://github.com/cloudify-cosmo/cloudify-hello-world-example). In `blueprint.yaml` we import `http://www.getcloudify.org/spec/openstack-plugin/1.2/plugin.yaml`, but you can see that [plugin.yaml](http://www.getcloudify.org/spec/openstack-plugin/1.2/plugin.yaml) is using `https://github.com/cloudify-cosmo/cloudify-openstack-plugin/archive/1.2.zip`. So we must make [plugin.yaml](http://www.getcloudify.org/spec/openstack-plugin/1.2/plugin.yaml) as well as [1.2.zip](https://github.com/cloudify-cosmo/cloudify-openstack-plugin/archive/1.2.zip) available on our HTTP server.

### Step 4 - Creating a template image for Cloudify
In order to configure pip and Easy-install to use our PyPi mirror instead of the PyPi central repository by default we will have to create a template image with configuration files for pip and Easy-install.
In order to do so we will launch an instance and pre-configure it.
You can choose any base image that matches the required manager image as described in the [prerequisites](getting-started-prerequisites.html#prerequisites) section. We will be using ubuntu precise.
After launcing an instance you will have to:

- Download [pip.conf](https://raw.githubusercontent.com/cloudify-cosmo/cloudify-packager/7e7ee9c9422b4fe91cba54adcd2ca339b23e8ab9/offline-configuration/pip.conf) and save it under `$HOME/.pip`. Configure `<PyPi-mirror-ip>` to point at the IP of your PyPi mirror / HTTP server.
- Download [.pydistutils](https://raw.githubusercontent.com/cloudify-cosmo/cloudify-packager/7e7ee9c9422b4fe91cba54adcd2ca339b23e8ab9/offline-configuration/.pydistutils) and save it under `$HOME`. Configure `<PyPi-mirror-ip>` to point at the IP of your PyPi mirror / HTTP server.
- Remove your public key from `~/.ssh` in order to allow other users to connect to this image.

Create a Snapshot from this image and call it `cfy-template`.

# Test drive your offline configuration

We will be using our configuration to bootstrap Cloudify manager and install the Hello-World Blueprint.

### Step 1 - Launch a client instance

Launch an instance in OpenStack, connect it to the same network as the HTTP server.

### Step 2 - Install Cloudify CLI

Install the CLI package as described in the [installation guide](installation-cli.html) on the client instance that you have just started.

### Step 3 - Download the Hello-World example

Download the Hello-World example to the client instance.
You can either download the zip file from the [hello-World repo](https://github.com/cloudify-cosmo/cloudify-hello-world-example)
or `git clone https://github.com/cloudify-cosmo/cloudify-hello-world-example.git`

### Step 4 - Upload the relevant files to the HTTP Server

We need to make all the files required by the Blueprint available in our HTTP server. To do this we will check `blueprint.yaml` for external files **recursively**.
`blueprint.yaml` is using the following external files:

- [types.yaml](http://www.getcloudify.org/spec/cloudify/3.2/types.yaml)
- [plugin.yaml](http://www.getcloudify.org/spec/openstack-plugin/1.2/plugin.yaml)

`types.yaml` is using the following external files:

- [threshold.clj](https://raw.githubusercontent.com/cloudify-cosmo/cloudify-manager/master/resources/rest-service/cloudify/policies/threshold.clj)
- [host_failure.clj](https://raw.githubusercontent.com/cloudify-cosmo/cloudify-manager/master/resources/rest-service/cloudify/policies/host_failure.clj)
- [execute_workflow.clj](https://raw.githubusercontent.com/cloudify-cosmo/cloudify-manager/master/resources/rest-service/cloudify/triggers/execute_workflow.clj)

`plugin.yaml` is using the following external files:

- [1.2.zip](https://github.com/cloudify-cosmo/cloudify-openstack-plugin/archive/1.2.zip)

We need to make all of these files available under `/srv/cloudify` in our HTTP server. A best practice would be to make each file available under its full path. For example store `http://www.getcloudify.org/spec/cloudify/3.2/types.yaml` under `/srv/cloudify/spec/cloudify/3.2/types.yaml` etc.

Also note that the location of `types.yaml` has just changed to `<HTTP-server-IP>:<HTTP-server-port>/cloudify/spec/cloudify/3.2/types.yaml` so we will have to change it in our `blueprint.yaml` file as well.
We need to repeat this process for each of the files that are used by our `blueprint.yaml`, **recursively**.

### Step 5 - Bootstrap, upload a blueprint, create a deployment and install it
Everything is ready for the final step:

Follow the instructions under the [bootstrapping guide](getting-started-bootstrapping.html). Use the `cfy-template` snapshot that you have created before as the image for the Cloudify management machine.
Then
{{< gsHighlight  bash  >}} cfy blueprints upload -p <PATH-TO-BLUEPRINT> -b hello-offline
{{< /gsHighlight >}}
in order to upload the blueprint to the management server.

{{< gsHighlight  bash  >}} cfy deployments create -b hello-offline -d hello-offline -i <PATH-TO-INPUTS-FILE>
{{< /gsHighlight >}}
In order to create a deployment.

{{% gsNote title="Note" %}}
You might want to consult the [inputs reference](dsl-spec-inputs.html), as the Hello-World blueprint requires using inputs.
{{% /gsNote %}}

{{< gsHighlight  bash  >}} cfy executions start -d hello-offline -w install
{{< /gsHighlight >}}
In order to install the deployment.

When the installation of the deployment is finished, you'll have an installed Hello-World app in an offline environment.


text:
package de.hpi.bpmn2xpdl;

import java.util.Arrays;
import java.util.Map.Entry;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.xmappr.Attribute;
import org.xmappr.RootElement;

@RootElement("Association")
public class XPDLAssociation extends XPDLThingConnectorGraphics {

	@Attribute("Direction")
	protected String direction;
	@Attribute("Source")
	protected String source;
	@Attribute("Target")
	protected String target;

	public static boolean handlesStencil(String stencil) {
		String[] types = {
			"Association_Undirected",
			"Association_Unidirectional",
			"Association_Bidirectional"};
		return Arrays.asList(types).contains(stencil);
	}

	public String getDirection() {
		return direction;
	}

	public String getSource() {
		return source;
	}

	public String getTarget() {
		return target;
	}

	public void readJSONdirection(JSONObject modelElement) {
		setDirection(modelElement.optString("direction"));
	}

	public void readJSONresourceId(JSONObject modelElement) throws JSONException {
		super.readJSONresourceId(modelElement);
		findSourceId(getResourceId());
	}

	public void readJSONsource(JSONObject modelElement) throws JSONException {
	}

	public void readJSONtarget(JSONObject modelElement) throws JSONException {
		JSONObject target = modelElement.getJSONObject("target");
		setTarget(target.optString("resourceId"));
	}

	public void setDirection(String directionValue) {
		direction = directionValue;
	}

	public void setSource(String sourceValue) {
		source = sourceValue;
	}

	public void setTarget(String targetValue) {
		target = targetValue;
	}
	public void writeJSONgraphicsinfos(JSONObject modelElement) throws JSONException {
		super.writeJSONgraphicsinfos(modelElement);

		convertFirstAndLastDockerToRelative(getTarget(), getSource(), modelElement);
	}
	public void writeJSONsource(JSONObject modelElement) throws JSONException {
		putProperty(modelElement, "target", "");
	}

	@Override
	public void writeJSONoutgoing(JSONObject modelElement) throws JSONException {
		super.writeJSONoutgoing(modelElement);
		JSONArray outgoing = modelElement.optJSONArray("outgoing");
		outgoing.put(resourceIdToJSONObject(getTarget()));

	}
	public void writeJSONstencil(JSONObject modelElement) throws JSONException {

		String directionValue = getDirection();
		if (directionValue.equals("To")) {
			putProperty(modelElement, "direction", directionValue);
			writeStencil(modelElement, "Association_Unidirectional");
		} else if (directionValue.equals("Both")) {
			putProperty(modelElement, "direction", directionValue);
			writeStencil(modelElement, "Association_Bidirectional");
		} else {
			putProperty(modelElement, "direction", "None");
			writeStencil(modelElement, "Association_Undirected");
		}
	}

	public void writeJSONtarget(JSONObject modelElement) throws JSONException {
		JSONObject target = new JSONObject();
		target.put("resourceId", getTarget());

		modelElement.put("target", target);
	}

	private void findSourceId(String resourceId) throws JSONException{
		for(Entry<String, JSONObject> entry: getResourceIdToShape().entrySet()){
			JSONArray outgoings=entry.getValue().optJSONArray("outgoing");
			if(outgoings!=null){
				for(int i=0; i<outgoings.length();i++){
					String shapeId = outgoings.getJSONObject(i).optString("resourceId");
					if(resourceId.equals(shapeId)) {
						setSource(entry.getKey());
					}
				}
			}
		}
	}
}


text:
using System;

namespace Blargh
{
#if !CSNative
    public static class Utilities
    {
        public static T As<T>(this object o)
        {
            return (T)o;
        }
    }
#endif

    public static class Test
    {
        public static void Main()
        {
            var a = DateTime.Now.As<String>();
            object o = 4;
            var b = (byte)(short)o;
        }
    }
}


text:
package org.jge.events;

public class WindowResizeEvent extends Event
{

	public int width;
	public int height;

	public WindowResizeEvent(int width, int height)
	{
		this.width = width;
		this.height = height;
	}

	public boolean isCancellable()
	{
		return false;
	}

}


text:
package com.github.anba.test262.util;

import static java.util.Objects.requireNonNull;
import static org.hamcrest.Matchers.anything;
import static org.hamcrest.Matchers.not;

import org.hamcrest.Matcher;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;

/**
 * Exception handler like {@link TestRule}
 *
 * @author André Bargull
 *
 */
public abstract class ExceptionHandler implements TestRule {
    private Matcher<?> matcher = not(anything());

    public void match(Matcher<?> matcher) {
        requireNonNull(matcher);
        this.matcher = matcher;
    }

    /**
     * To be implemented by subclasses
     */
    protected abstract void handle(Throwable t);

    @Override
    public Statement apply(final Statement base, final Description description) {
        return new Statement() {
            @Override
            public void evaluate() throws Throwable {
                try {
                    base.evaluate();
                } catch (Throwable t) {
                    if (matcher.matches(t)) {
                        handle(t);
                    } else {
                        throw t;
                    }
                }
            }
        };
    }
}


text:
module Homebrew
  def home
    if ARGV.named.empty?
      exec_browser HOMEBREW_WWW
    else
      exec_browser(*ARGV.formulae.map(&:homepage))
    end
  end
end


text:
@interface FLAssetsLibraryImageAsset : FLAsset<FLImageAsset> {
@private
	FLAssetsLibraryImage* _originalImage;
	FLAssetsLibraryImage* _fullScreenImage;
	FLAssetsLibraryImage* _thumnailImage;
}

- (id) initWithQueuedAsset:(FLQueuedAsset*) asset;

- (id) initWithAssetURL:(NSURL*) url;

- (id) initWithALAsset:(ALAsset*) asset;

@end


text:
declare class HelpCenterArticleVotingHandler extends NSObject implements ZDKHelpCenterArticleRatingHandlerProtocol {

	static alloc(): HelpCenterArticleVotingHandler; // inherited from NSObject

	static new(): HelpCenterArticleVotingHandler; // inherited from NSObject

	readonly debugDescription: string; // inherited from NSObjectProtocol

	readonly description: string; // inherited from NSObjectProtocol

	readonly hash: number; // inherited from NSObjectProtocol

	readonly isProxy: boolean; // inherited from NSObjectProtocol

	readonly superclass: typeof NSObject; // inherited from NSObjectProtocol

	readonly  // inherited from NSObjectProtocol

	constructor(o: { articleId: string; andLocale: string; });

	articleRatingVoteSelectedAtIndex(ratingState: ZDKHelpCenterArticleRatingStateProtocol, index: number): void;

	class(): typeof NSObject;

	conformsToProtocol(aProtocol: any /* Protocol */): boolean;

	currentArticleVote(): number;

	initWithArticleIdAndLocale(articleId: string, locale: string): this;

	isEqual(object: any): boolean;

	isKindOfClass(aClass: typeof NSObject): boolean;

	isMemberOfClass(aClass: typeof NSObject): boolean;

	performSelector(aSelector: string): any;

	performSelectorWithObject(aSelector: string, object: any): any;

	performSelectorWithObjectWithObject(aSelector: string, object1: any, object2: any): any;

	respondsToSelector(aSelector: string): boolean;

	retainCount(): number;

	self(): this;
}

declare class ZDKConstants extends NSObject {

	static alloc(): ZDKConstants; // inherited from NSObject

	static colorForToast(): UIColor;

	static new(): ZDKConstants; // inherited from NSObject
}

declare const enum ZDKContactUsVisibility {

	ArticleListAndArticle = 0,

	ArticleListOnly = 1,

	Off = 2
}

interface ZDKCreateRequestUIDelegate extends NSObjectProtocol {

	createRequestBarButtonImage(): UIImage;

	createRequestBarButtonLocalizedLabel(): string;

	navBarCreateRequestUIType(): ZDKNavBarCreateRequestUIType;
}
declare var ZDKCreateRequestUIDelegate: {

	prototype: ZDKCreateRequestUIDelegate;
};

declare const enum ZDKFileType {

	Png = 0,

	Jpg = 1,

	Pdf = 2,

	Plain = 3,

	Word = 4,

	Excel = 5,

	Powerpoint = 6,

	PowerpointX = 7,

	Keynote = 8,

	Pages = 9,

	Numbers = 10,

	Binary = 11,

	Heic = 12
}

interface ZDKHelpCenterArticleRatingHandlerProtocol extends NSObjectProtocol {

	articleRatingVoteSelectedAtIndex(ratingState: ZDKHelpCenterArticleRatingStateProtocol, index: number): void;

	currentArticleVote(): number;
}
declare var ZDKHelpCenterArticleRatingHandlerProtocol: {

	prototype: ZDKHelpCenterArticleRatingHandlerProtocol;
};

interface ZDKHelpCenterArticleRatingStateProtocol extends NSObjectProtocol {

	updateButtonStatesForButtonAtIndexSelected(index: number): void;
}
declare var ZDKHelpCenterArticleRatingStateProtocol: {

	prototype: ZDKHelpCenterArticleRatingStateProtocol;
};

declare class ZDKHelpCenterAttachmentsDataSource extends ZDKHelpCenterDataSource {

	static alloc(): ZDKHelpCenterAttachmentsDataSource; // inherited from NSObject

	static new(): ZDKHelpCenterAttachmentsDataSource; // inherited from NSObject

	constructor(o: { articleId: number; });

	initWithArticleId(articleId: number): this;
}

interface ZDKHelpCenterConversationsUIDelegate extends NSObjectProtocol {

	active(): ZDKContactUsVisibility;

	conversationsBarButtonImage?(): UIImage;

	conversationsBarButtonLocalizedLabel?(): string;

	navBarConversationsUIType(): ZDKNavBarConversationsUIType;
}
declare var ZDKHelpCenterConversationsUIDelegate: {

	prototype: ZDKHelpCenterConversationsUIDelegate;
};

declare class ZDKHelpCenterDataSource extends NSObject implements UITableViewDataSource {

	static alloc(): ZDKHelpCenterDataSource; // inherited from NSObject

	static cellIdentifierForDataSource(): string;

	static new(): ZDKHelpCenterDataSource; // inherited from NSObject

	readonly hasItems: boolean;

	readonly items: NSArray<any>;

	readonly provider: ZDKHelpCenterProvider;

	readonly debugDescription: string; // inherited from NSObjectProtocol

	readonly description: string; // inherited from NSObjectProtocol

	readonly hash: number; // inherited from NSObjectProtocol

	readonly isProxy: boolean; // inherited from NSObjectProtocol

	readonly superclass: typeof NSObject; // inherited from NSObjectProtocol

	readonly  // inherited from NSObjectProtocol

	class(): typeof NSObject;

	conformsToProtocol(aProtocol: any /* Protocol */): boolean;

	isEqual(object: any): boolean;

	isKindOfClass(aClass: typeof NSObject): boolean;

	isMemberOfClass(aClass: typeof NSObject): boolean;

	itemAtIndexPath(indexPath: NSIndexPath): any;

	numberOfSectionsInTableView(tableView: UITableView): number;

	performSelector(aSelector: string): any;

	performSelectorWithObject(aSelector: string, object: any): any;

	performSelectorWithObjectWithObject(aSelector: string, object1: any, object2: any): any;

	reloadData(): void;

	respondsToSelector(aSelector: string): boolean;

	retainCount(): number;

	sectionIndexTitlesForTableView(tableView: UITableView): NSArray<string>;

	self(): this;

	tableViewCanEditRowAtIndexPath(tableView: UITableView, indexPath: NSIndexPath): boolean;

	tableViewCanMoveRowAtIndexPath(tableView: UITableView, indexPath: NSIndexPath): boolean;

	tableViewCellForRowAtIndexPath(tableView: UITableView, indexPath: NSIndexPath): UITableViewCell;

	tableViewCommitEditingStyleForRowAtIndexPath(tableView: UITableView, editingStyle: UITableViewCellEditingStyle, indexPath: NSIndexPath): void;

	tableViewMoveRowAtIndexPathToIndexPath(tableView: UITableView, sourceIndexPath: NSIndexPath, destinationIndexPath: NSIndexPath): void;

	tableViewNumberOfRowsInSection(tableView: UITableView, section: number): number;

	tableViewSectionForSectionIndexTitleAtIndex(tableView: UITableView, title: string, index: number): number;

	tableViewTitleForFooterInSection(tableView: UITableView, section: number): string;

	tableViewTitleForHeaderInSection(tableView: UITableView, section: number): string;
}

interface ZDKHelpCenterDelegate extends NSObjectProtocol {

	uiDelegate: ZDKHelpCenterConversationsUIDelegate;
}
declare var ZDKHelpCenterDelegate: {

	prototype: ZDKHelpCenterDelegate;
};

declare var ZDKHelpCenterEmptyHelpCenterDescription: string;

declare const enum ZDKHelpCenterError {

	InvalidCategoryIds = 100,

	InvalidSectionIds = 101,

	NoArticlesForLabels = 102,

	EmptyHelpCenter = 103
}

declare var ZDKHelpCenterErrorDomain: string;

declare var ZDKHelpCenterNoArticlesForLabelsDescription: string;

declare var ZDKHelpCenterNoCategoriesLocalisedDescription: string;

declare var ZDKHelpCenterNoSectionsLocalisedDescription: string;

declare class ZDKHelpCenterUi extends NSObject {

	static alloc(): ZDKHelpCenterUi; // inherited from NSObject

	static buildHelpCenterArticle(article: ZDKHelpCenterArticle): UIViewController;

	static buildHelpCenterArticleAndConfigs(article: ZDKHelpCenterArticle, configs: NSArray<ZDKUiConfiguration>): UIViewController;

	static buildHelpCenterArticleWithArticleId(articleId: string): UIViewController;

	static buildHelpCenterArticleWithArticleIdAndConfigs(articleId: string, configs: NSArray<ZDKUiConfiguration>): UIViewController;

	static buildHelpCenterOverview(): UIViewController;

	static buildHelpCenterOverviewWithConfigs(configs: NSArray<ZDKUiConfiguration>): UIViewController;

	static new(): ZDKHelpCenterUi; // inherited from NSObject
}

declare class ZDKHelpCenterUiConfiguration extends NSObject implements ZDKUiConfiguration {

	static alloc(): ZDKHelpCenterUiConfiguration; // inherited from NSObject

	static new(): ZDKHelpCenterUiConfiguration; // inherited from NSObject

	groupIds: NSArray<number>;

	groupType: number;

	hideContactSupport: boolean;

	labels: NSArray<string>;

	readonly overviewContentModel: ZDKHelpCenterOverviewContentModel;

	readonly debugDescription: string; // inherited from NSObjectProtocol

	readonly description: string; // inherited from NSObjectProtocol

	readonly hash: number; // inherited from NSObjectProtocol

	readonly isProxy: boolean; // inherited from NSObjectProtocol

	readonly superclass: typeof NSObject; // inherited from NSObjectProtocol

	readonly  // inherited from NSObjectProtocol

	constructor(); // inherited from ZDKUiConfiguration

	class(): typeof NSObject;

	conformsToProtocol(aProtocol: any /* Protocol */): boolean;

	init(): this;

	isEqual(object: any): boolean;

	isKindOfClass(aClass: typeof NSObject): boolean;

	isMemberOfClass(aClass: typeof NSObject): boolean;

	performSelector(aSelector: string): any;

	performSelectorWithObject(aSelector: string, object: any): any;

	performSelectorWithObjectWithObject(aSelector: string, object1: any, object2: any): any;

	respondsToSelector(aSelector: string): boolean;

	retainCount(): number;

	self(): this;
}

declare class ZDKLayoutGuideApplicator extends NSObject {

	static alloc(): ZDKLayoutGuideApplicator; // inherited from NSObject

	static new(): ZDKLayoutGuideApplicator; // inherited from NSObject

	constructor(o: { viewController: UIViewController; topLevelView: UIView; layoutPosition: ZDKLayoutGuideApplicatorPosition; });

	initWithViewControllerTopLevelViewLayoutPosition(viewController: UIViewController, topLevelView: UIView, position: ZDKLayoutGuideApplicatorPosition): this;
}

declare const enum ZDKLayoutGuideApplicatorPosition {

	Top = 0,

	Bottom = 1
}

declare const enum ZDKNavBarCreateRequestUIType {

	LocalizedLabel = 0,

	Image = 1
}

declare class ZDKRequestAttachment extends NSObject {

	static alloc(): ZDKRequestAttachment; // inherited from NSObject

	static new(): ZDKRequestAttachment; // inherited from NSObject

	readonly data: NSData;

	readonly fileType: ZDKFileType;

	readonly filename: string;

	constructor(o: { filename: string; data: NSData; fileType: ZDKFileType; });

	initWithFilenameDataFileType(filename: string, data: NSData, fileType: ZDKFileType): this;
}

declare class ZDKRequestUi extends NSObject {

	static alloc(): ZDKRequestUi; // inherited from NSObject

	static buildRequestList(): UIViewController;

	static buildRequestListWith(configurations: NSArray<ZDKUiConfiguration>): UIViewController;

	static buildRequestUi(): UIViewController;

	static buildRequestUiWith(configurations: NSArray<ZDKUiConfiguration>): UIViewController;

	static buildRequestUiWithRequestId(requestId: string): UIViewController;

	static buildRequestUiWithRequestIdConfigurations(requestId: string, configurations: NSArray<ZDKUiConfiguration>): UIViewController;

	static new(): ZDKRequestUi; // inherited from NSObject
}

declare class ZDKRequestUiConfiguration extends NSObject implements ZDKUiConfiguration {

	static alloc(): ZDKRequestUiConfiguration; // inherited from NSObject

	static new(): ZDKRequestUiConfiguration; // inherited from NSObject

	fields: NSArray<ZDKCustomField>;

	fileAttachments: NSArray<ZDKRequestAttachment>;

	subject: string;

	tags: NSArray<string>;

	ticketFormID: number;

	readonly debugDescription: string; // inherited from NSObjectProtocol

	readonly description: string; // inherited from NSObjectProtocol

	readonly hash: number; // inherited from NSObjectProtocol

	readonly isProxy: boolean; // inherited from NSObjectProtocol

	readonly superclass: typeof NSObject; // inherited from NSObjectProtocol

	readonly  // inherited from NSObjectProtocol

	constructor(); // inherited from ZDKUiConfiguration

	class(): typeof NSObject;

	conformsToProtocol(aProtocol: any /* Protocol */): boolean;

	init(): this;

	isEqual(object: any): boolean;

	isKindOfClass(aClass: typeof NSObject): boolean;

	isMemberOfClass(aClass: typeof NSObject): boolean;

	performSelector(aSelector: string): any;

	performSelectorWithObject(aSelector: string, object: any): any;

	performSelectorWithObjectWithObject(aSelector: string, object1: any, object2: any): any;

	respondsToSelector(aSelector: string): boolean;

	retainCount(): number;

	self(): this;
}

interface ZDKSpinnerDelegate extends NSObjectProtocol {

	center: CGPoint;

	frame: CGRect;

	hidden: boolean;

	startAnimating(): void;

	stopAnimating(): void;
}
declare var ZDKSpinnerDelegate: {

	prototype: ZDKSpinnerDelegate;
};

declare class ZDKSuasDebugLogger extends NSObject {

	static alloc(): ZDKSuasDebugLogger; // inherited from NSObject

	static new(): ZDKSuasDebugLogger; // inherited from NSObject

	static setEnabled(newValue: boolean): void;

	static enabled: boolean;
}

declare class ZDKSupportAttachmentCell extends UITableViewCell implements UIAppearanceContainer {

	static alloc(): ZDKSupportAttachmentCell; // inherited from NSObject

	static appearance(): ZDKSupportAttachmentCell; // inherited from UIAppearance

	static appearanceForTraitCollection(trait: UITraitCollection): ZDKSupportAttachmentCell; // inherited from UIAppearance

	static appearanceForTraitCollectionWhenContainedIn(trait: UITraitCollection, ContainerClass: typeof NSObject): ZDKSupportAttachmentCell; // inherited from UIAppearance

	static appearanceForTraitCollectionWhenContainedInInstancesOfClasses(trait: UITraitCollection, containerTypes: NSArray<typeof NSObject>): ZDKSupportAttachmentCell; // inherited from UIAppearance

	static appearanceWhenContainedIn(ContainerClass: typeof NSObject): ZDKSupportAttachmentCell; // inherited from UIAppearance

	static appearanceWhenContainedInInstancesOfClasses(containerTypes: NSArray<typeof NSObject>): ZDKSupportAttachmentCell; // inherited from UIAppearance

	static cellIdentifier(): string;

	static new(): ZDKSupportAttachmentCell; // inherited from NSObject

	readonly fileSize: UILabel;

	readonly title: UILabel;

	readonly debugDescription: string; // inherited from NSObjectProtocol

	readonly description: string; // inherited from NSObjectProtocol

	readonly hash: number; // inherited from NSObjectProtocol

	readonly isProxy: boolean; // inherited from NSObjectProtocol

	readonly superclass: typeof NSObject; // inherited from NSObjectProtocol

	readonly  // inherited from NSObjectProtocol

	class(): typeof NSObject;

	conformsToProtocol(aProtocol: any /* Protocol */): boolean;

	isEqual(object: any): boolean;

	isKindOfClass(aClass: typeof NSObject): boolean;

	isMemberOfClass(aClass: typeof NSObject): boolean;

	performSelector(aSelector: string): any;

	performSelectorWithObject(aSelector: string, object: any): any;

	performSelectorWithObjectWithObject(aSelector: string, object1: any, object2: any): any;

	respondsToSelector(aSelector: string): boolean;

	retainCount(): number;

	self(): this;
}

declare class ZDKTheme extends NSObject {

	static alloc(): ZDKTheme; // inherited from NSObject

	static new(): ZDKTheme; // inherited from NSObject

	primaryColor: UIColor;

	static readonly currentTheme: ZDKTheme;
}

declare class ZDKToastViewWrapper extends UIView {

	static alloc(): ZDKToastViewWrapper; // inherited from NSObject

	static appearance(): ZDKToastViewWrapper; // inherited from UIAppearance

	static appearanceForTraitCollection(trait: UITraitCollection): ZDKToastViewWrapper; // inherited from UIAppearance

	static appearanceForTraitCollectionWhenContainedIn(trait: UITraitCollection, ContainerClass: typeof NSObject): ZDKToastViewWrapper; // inherited from UIAppearance

	static appearanceForTraitCollectionWhenContainedInInstancesOfClasses(trait: UITraitCollection, containerTypes: NSArray<typeof NSObject>): ZDKToastViewWrapper; // inherited from UIAppearance

	static appearanceWhenContainedIn(ContainerClass: typeof NSObject): ZDKToastViewWrapper; // inherited from UIAppearance

	static appearanceWhenContainedInInstancesOfClasses(containerTypes: NSArray<typeof NSObject>): ZDKToastViewWrapper; // inherited from UIAppearance

	static new(): ZDKToastViewWrapper; // inherited from NSObject

	readonly isVisible: boolean;

	dismiss(): void;

	hideToastView(hide: boolean): void;

	showErrorInViewControllerWithMessage(viewController: UIViewController, message: string): void;

	showErrorInViewControllerWithMessageButtonTitleAction(viewController: UIViewController, message: string, buttonTitle: string, action: () => void): void;

	showErrorInViewControllerWithMessageDuration(viewController: UIViewController, message: string, duration: number): void;
}

declare class ZDKUIUtil extends NSObject {

	static alloc(): ZDKUIUtil; // inherited from NSObject

	static appearanceValueForClassSelector(viewClass: typeof NSObject, selector: string): any;

	static appearanceValueForClassWhenContainedInSelector(viewClass: typeof NSObject, containerClass: typeof NSObject, selector: string): any;

	static appearanceValueForViewSelector(view: UIView, selector: string): any;

	static buildButtonWithFrameAndTitle(frame: CGRect, title: string): UIButton;

	static currentInterfaceOrientation(): UIInterfaceOrientation;

	static fixOrientationOfImage(image: UIImage): UIImage;

	static isLandscape(): boolean;

	static isNewerVersion(majorVersionNumber: string): boolean;

	static isOlderVersion(majorVersionNumber: string): boolean;

	static isPad(): boolean;

	static isSameVersion(majorVersionNumber: number): boolean;

	static new(): ZDKUIUtil; // inherited from NSObject

	static scaledHeightForSizeConstrainedByWidth(size: CGSize, width: number): number;

	static separatorHeightForScreenScale(): number;

	static shouldEnableAttachments(viewController: UIViewController): boolean;
}

interface ZDKUiConfiguration extends NSObjectProtocol {

	init?(): ZDKUiConfiguration;
}
declare var ZDKUiConfiguration: {

	prototype: ZDKUiConfiguration;
};

declare class ZendeskFabric extends NSObject {

	static alloc(): ZendeskFabric; // inherited from NSObject

	static new(): ZendeskFabric; // inherited from NSObject
}

declare class ZendeskWrapperUIX extends NSObject {

	static alloc(): ZendeskWrapperUIX; // inherited from NSObject

	static new(): ZendeskWrapperUIX; // inherited from NSObject

	static setupActionHandlers(): void;
}


text:
<?xml version="1.0" encoding="UTF-8"?>

<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
	xmlns:android="http://schemas.android.com/apk/res/android"
	id="com.jacobp100.cordova.plugin.admob"
	version="2.0.4">

    <name>AdMob</name>
	<description>The most popular AdMob plugin for Cordova/PhoneGap, Intel XDK compatible. Support latest Google Play Services for Android, iOS and Windows Phone SDK. </description>
	<author>Liming Xie</author>
	<license>MIT</license>
	<keywords>ad,admob,google,play,services,iad,flurry</keywords>
    <repo>https://github.com/floatinghotpot/cordova-plugin-admob.git</repo>
    <issue>https://github.com/floatinghotpot/cordova-plugin-admob/issues</issue>

	<engines>
	    <engine name="cordova" version=">=2.9" />
	</engines>

    <js-module src="www/AdMob.js" name="AdMob">
        <clobbers target="window.plugins.AdMob" />
    </js-module>

    <!-- android -->
    <platform name="android">
    	<dependency id="com.google.admobsdk-googleplay" version=">=5.0.89"/>
        <config-file target="res/xml/config.xml" parent="/*">
            <feature name="AdMob">
                <param name="android-package" value="com.jacobp100.cordova.plugin.AdMob"/>
            </feature>
        </config-file>
        <source-file src="src/android/AdMob.java" target-dir="src/com/jacobp100/cordova/plugin" />
     </platform>

     <!-- ios -->
     <platform name="ios">
    	<dependency id="com.google.admobsdk-ios" version=">=6.11.1"/>
         <config-file target="config.xml" parent="/*">
             <feature name="AdMob">
                 <param name="ios-package" value="CDVAdMob" />
             </feature>
         </config-file>
         <header-file src="src/ios/CDVAdMob.h" />
         <source-file src="src/ios/CDVAdMob.m" />
	</platform>

  <!-- Windows Phone 8 -->
  <platform name="wp8">
    <dependency id="com.google.admobsdk-wp" version=">=6.5.13"/>
    <config-file target="config.xml" parent="/*">
      <feature name="AdMob">
        <param name="wp-package" value="AdMob"/>
      </feature>
    </config-file>
    <source-file src="src/wp8/AdMob.cs" />
  </platform>

</plugin>


text:
package utils.recyler;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.View;

import utils.utils.UIUtils;

/**
 * QQ 517309507
 * 参考 http://www.jianshu.com/p/e742df6f59e2
 */
public class SpaceItemDecoration extends RecyclerView.ItemDecoration {
    private Paint mDividerPaint = new Paint();
    private DisplayMetrics mDisplayMetrics;
    private int mSpace;
    private int mEdgeSpace;

    public SpaceItemDecoration(Context context) {
        mDisplayMetrics = context.getResources().getDisplayMetrics();
    }

    public SpaceItemDecoration(Context mContext, int space) {
        mDisplayMetrics = mContext.getResources().getDisplayMetrics();
        mSpace = (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, space, mDisplayMetrics) + 0.5f);
    }

    public SpaceItemDecoration(Context mContext, float space) {
        mDisplayMetrics = mContext.getResources().getDisplayMetrics();
        mSpace = UIUtils.dip2Px(space);
    }

    public SpaceItemDecoration setSpace(int space) {
        mSpace = (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, space, mDisplayMetrics) + 0.5f);
        return this;
    }

    public SpaceItemDecoration setEdgeSpace(int edgeSpace) {
        mEdgeSpace = (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, edgeSpace, mDisplayMetrics) + 0.5f);
        return this;
    }

    public SpaceItemDecoration setSpaceColor(int spaceColor) {
        mDividerPaint.setColor(spaceColor);
        return this;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        final RecyclerView.LayoutManager manager = parent.getLayoutManager();
        final int childPosition = parent.getChildAdapterPosition(view);
        final int itemCount = parent.getAdapter().getItemCount();
        if (manager != null) {
            if (manager instanceof GridLayoutManager) {
                setGrid(((GridLayoutManager) manager).getOrientation(), ((GridLayoutManager) manager).getSpanCount(), outRect, childPosition, itemCount);
            } else if (manager instanceof LinearLayoutManager) {
                setLinear(((LinearLayoutManager) manager).getOrientation(), outRect, childPosition, itemCount);
            }
        }
    }

    @Override
    public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
        final RecyclerView.LayoutManager manager = parent.getLayoutManager();
        if (manager != null) {
            if (manager instanceof GridLayoutManager) {
            } else if (manager instanceof LinearLayoutManager) {
                drawLinear(((LinearLayoutManager) manager).getOrientation(), c, parent);
            }
        }
    }

    private void setLinear(int orientation, Rect outRect, int childPosition, int itemCount) {
        if (orientation == LinearLayoutManager.VERTICAL) {
            if (childPosition == 0) {
                outRect.set(0, mEdgeSpace, 0, mSpace);
            } else if (childPosition == itemCount - 1) {
                outRect.set(0, 0, 0, mEdgeSpace);
            } else {
                outRect.set(0, 0, 0, mSpace);
            }
        } else if (orientation == LinearLayoutManager.HORIZONTAL) {
            if (childPosition == 0) {
                outRect.set(mEdgeSpace, 0, mSpace, 0);
            } else if (childPosition == itemCount - 1) {
                outRect.set(0, 0, mEdgeSpace, 0);
            } else {
                outRect.set(0, 0, mSpace, 0);
            }
        }
    }

    private void setGrid(int orientation, int spanCount, Rect outRect, int childPosition, int itemCount) {
        float totalSpace = mSpace * (spanCount - 1) + mEdgeSpace * 2;
        float eachSpace = totalSpace / spanCount;
        int column = childPosition % spanCount;
        int row = childPosition / spanCount;
        float left;
        float right;
        float top;
        float bottom;
        if (orientation == GridLayoutManager.VERTICAL) {
            top = 0;
            bottom = mSpace;
            if (childPosition < spanCount) {
                top = mEdgeSpace;
            }
            if (itemCount % spanCount != 0 && itemCount / spanCount == row ||
                    itemCount % spanCount == 0 && itemCount / spanCount == row + 1) {
                bottom = mEdgeSpace;
            }
            if (spanCount == 1) {
                left = mEdgeSpace;
                right = left;
            } else {
                left = column * (eachSpace - mEdgeSpace - mEdgeSpace) / (spanCount - 1) + mEdgeSpace;
                right = eachSpace - left;
            }
        } else {
            left = 0;
            right = mSpace;
            if (childPosition < spanCount) {
                left = mEdgeSpace;
            }
            if (itemCount % spanCount != 0 && itemCount / spanCount == row ||
                    itemCount % spanCount == 0 && itemCount / spanCount == row + 1) {
                right = mEdgeSpace;
            }
            if (spanCount == 1) {
                top = mEdgeSpace;
                top = 0;
                bottom = top;
            } else {
                top = column * (eachSpace - mEdgeSpace - mEdgeSpace) / (spanCount - 1) + mEdgeSpace;
                top = 0;
                bottom = eachSpace - top;
            }
        }
        outRect.set((int) left, (int) top, (int) right, (int) bottom);
    }

    private void drawLinear(int orientation, Canvas c, RecyclerView parent) {
        if (orientation == LinearLayoutManager.VERTICAL) {
            final int left = parent.getPaddingLeft();
            final int right = parent.getWidth() - parent.getPaddingRight();
            final int childCount = parent.getChildCount();
            for (int i = 0; i < childCount; i++) {
                final View child = parent.getChildAt(i);
                final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                        .getLayoutParams();
                final int top = child.getBottom() + params.bottomMargin +
                        Math.round(ViewCompat.getTranslationY(child));
//                final int bottom = top + mSpace;
                final int bottom = top;
                c.drawRect(left, top, right, bottom, mDividerPaint);
            }
        } else if (orientation == LinearLayoutManager.HORIZONTAL) {
            final int top = parent.getPaddingTop();
            final int bottom = parent.getHeight() - parent.getPaddingBottom();
            final int childCount = parent.getChildCount();
            for (int i = 0; i < childCount; i++) {
                final View child = parent.getChildAt(i);
                final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                        .getLayoutParams();
                final int left = child.getRight() + params.rightMargin +
                        Math.round(ViewCompat.getTranslationX(child));
                final int right = left + mSpace;
                c.drawRect(left, top, right, bottom, mDividerPaint);
            }
        }
    }
}


text:
/**
 * (created at 2011-5-18)
 */
package fm.liu.timo.parser.recognizer.mysql.syntax;

import java.sql.SQLSyntaxErrorException;
import org.junit.Assert;
import fm.liu.timo.parser.ast.stmt.dml.DMLInsertStatement;
import fm.liu.timo.parser.recognizer.mysql.MySQLToken;
import fm.liu.timo.parser.recognizer.mysql.lexer.MySQLLexer;
import fm.liu.timo.parser.recognizer.mysql.syntax.MySQLDMLInsertParser;
import fm.liu.timo.parser.recognizer.mysql.syntax.MySQLExprParser;

/**
 * @author QIU Shuo
 */
public class MySQLDMLInsertParserTest extends AbstractSyntaxTest {

    public void testInsert() throws SQLSyntaxErrorException {
        String sql = "insErt HIGH_PRIORITY intO test.t1 seT t1.id1=?, id2 := '123'";
        MySQLLexer lexer = new MySQLLexer(sql);
        MySQLDMLInsertParser parser = new MySQLDMLInsertParser(lexer, new MySQLExprParser(lexer));
        DMLInsertStatement insert = parser.insert();
        parser.match(MySQLToken.EOF);
        String output = output2MySQL(insert, sql);
        Assert.assertNotNull(insert);
        Assert.assertEquals("INSERT HIGH_PRIORITY INTO test.t1 (t1.id1, id2) VALUES (?, '123')",
                output);

        sql = "insErt  IGNORE test.t1 seT t1.id1:=? oN dupLicatE key UPDATE ex.col1=?, col2=12";
        lexer = new MySQLLexer(sql);
        parser = new MySQLDMLInsertParser(lexer, new MySQLExprParser(lexer));
        insert = parser.insert();
        parser.match(MySQLToken.EOF);
        output = output2MySQL(insert, sql);
        Assert.assertEquals(
                "INSERT IGNORE INTO test.t1 (t1.id1) VALUES (?) ON DUPLICATE KEY UPDATE ex.col1 = ?, col2 = 12",
                output);

        sql = "insErt t1 value (123,?) oN dupLicatE key UPDATE ex.col1=?";
        lexer = new MySQLLexer(sql);
        parser = new MySQLDMLInsertParser(lexer, new MySQLExprParser(lexer));
        insert = parser.insert();
        parser.match(MySQLToken.EOF);
        output = output2MySQL(insert, sql);
        Assert.assertEquals("INSERT INTO t1 VALUES (123, ?) ON DUPLICATE KEY UPDATE ex.col1 = ?",
                output);

        sql = "insErt LOW_PRIORITY t1 valueS (12e-2,1,2), (?),(default)";
        lexer = new MySQLLexer(sql);
        parser = new MySQLDMLInsertParser(lexer, new MySQLExprParser(lexer));
        insert = parser.insert();
        parser.match(MySQLToken.EOF);
        output = output2MySQL(insert, sql);
        Assert.assertEquals("INSERT LOW_PRIORITY INTO t1 VALUES (0.12, 1, 2), (?), (DEFAULT)",
                output);

        sql = "insErt LOW_PRIORITY t1 select id from t1";
        lexer = new MySQLLexer(sql);
        parser = new MySQLDMLInsertParser(lexer, new MySQLExprParser(lexer));
        insert = parser.insert();
        parser.match(MySQLToken.EOF);
        output = output2MySQL(insert, sql);
        Assert.assertEquals("INSERT LOW_PRIORITY INTO t1 SELECT id FROM t1", output);

        sql = "insErt delayed t1 select id from t1";
        lexer = new MySQLLexer(sql);
        parser = new MySQLDMLInsertParser(lexer, new MySQLExprParser(lexer));
        insert = parser.insert();
        parser.match(MySQLToken.EOF);
        output = output2MySQL(insert, sql);
        Assert.assertEquals("INSERT DELAYED INTO t1 SELECT id FROM t1", output);

        sql = "insErt LOW_PRIORITY t1 (select id from t1) oN dupLicatE key UPDATE ex.col1=?, col2=12";
        lexer = new MySQLLexer(sql);
        parser = new MySQLDMLInsertParser(lexer, new MySQLExprParser(lexer));
        insert = parser.insert();
        parser.match(MySQLToken.EOF);
        output = output2MySQL(insert, sql);
        Assert.assertEquals(
                "INSERT LOW_PRIORITY INTO t1 SELECT id FROM t1 ON DUPLICATE KEY UPDATE ex.col1 = ?, col2 = 12",
                output);

        sql = "insErt LOW_PRIORITY t1 (t1.col1) valueS (123),('12''34')";
        lexer = new MySQLLexer(sql);
        parser = new MySQLDMLInsertParser(lexer, new MySQLExprParser(lexer));
        insert = parser.insert();
        parser.match(MySQLToken.EOF);
        output = output2MySQL(insert, sql);
        Assert.assertEquals("INSERT LOW_PRIORITY INTO t1 (t1.col1) VALUES (123), ('12\\'34')",
                output);

        sql = "insErt LOW_PRIORITY t1 (col1, t1.col2) VALUE (123,'123\\'4') oN dupLicatE key UPDATE ex.col1=?";
        lexer = new MySQLLexer(sql);
        parser = new MySQLDMLInsertParser(lexer, new MySQLExprParser(lexer));
        insert = parser.insert();
        parser.match(MySQLToken.EOF);
        output = output2MySQL(insert, sql);
        Assert.assertEquals(
                "INSERT LOW_PRIORITY INTO t1 (col1, t1.col2) VALUES (123, '123\\'4') ON DUPLICATE KEY UPDATE ex.col1 = ?",
                output);

        sql = "insErt LOW_PRIORITY t1 (col1, t1.col2) select id from t3 oN dupLicatE key UPDATE ex.col1=?";
        lexer = new MySQLLexer(sql);
        parser = new MySQLDMLInsertParser(lexer, new MySQLExprParser(lexer));
        insert = parser.insert();
        parser.match(MySQLToken.EOF);
        output = output2MySQL(insert, sql);
        Assert.assertEquals(
                "INSERT LOW_PRIORITY INTO t1 (col1, t1.col2) SELECT id FROM t3 ON DUPLICATE KEY UPDATE ex.col1 = ?",
                output);

        sql = "insErt LOW_PRIORITY IGNORE intO t1 (col1) ( select id from t3) ";
        lexer = new MySQLLexer(sql);
        parser = new MySQLDMLInsertParser(lexer, new MySQLExprParser(lexer));
        insert = parser.insert();
        parser.match(MySQLToken.EOF);
        output = output2MySQL(insert, sql);
        Assert.assertEquals("INSERT LOW_PRIORITY IGNORE INTO t1 (col1) SELECT id FROM t3", output);

    }
}


text:
using namespace midnight::http;

void ofApp::setup(){
	mIsComplete = false;
	mHttpClient = HttpClient::make();

	std::map<std::string, std::string> requestParameters;
	requestParameters["foo"] = "bar baz";

	std::printf("Loading GET request...\n");

	HttpRequest Get;
	Get.mUrl = "http://www.httpbin.org/get";
	Get.mMethod = HTTP_GET;
	Get.mCallback = [=](HttpResponse* response, HttpClient* curl) { std::printf("Request complete with code %d; response is %s\n", response->mResponseCode, curl->jsonToString(response->mBody).c_str()); };
	mHttpClient->addHttpRequest(Get);

	std::printf("Loading POST request...\n");

	HttpRequest Post;
	Post.mUrl = "http://www.httpbin.org/post";
	Post.mMethod = HTTP_POST;
	Post.mCallback = [=](HttpResponse* response, HttpClient* curl) { std::printf("Request complete with code %d; response is %s\n", response->mResponseCode, curl->jsonToString(response->mBody).c_str()); };
	mHttpClient->addHttpRequest(Post);

	std::printf("Loading PUT request...\n");

	HttpRequest Put;
	Put.mUrl = "http://www.httpbin.org/put";
	Put.mMethod = HTTP_PUT;
	Put.mCallback = [=](HttpResponse* response, HttpClient* curl) { std::printf("Request complete with code %d; response is %s\n", response->mResponseCode, curl->jsonToString(response->mBody).c_str()); };
	mHttpClient->addHttpRequest(Put);

	std::printf("Loading DELETE request...\n");

	HttpRequest Delete;
	Delete.mUrl = "http://www.httpbin.org/delete";
	Delete.mMethod = HTTP_DELETE;
	Delete.mCallback = [=](HttpResponse* response, HttpClient* curl) { std::printf("Request complete with code %d; response is %s\n", response->mResponseCode, curl->jsonToString(response->mBody).c_str()); };
	mHttpClient->addHttpRequest(Delete);

	std::printf("Loading HEAD request...\n");

	HttpRequest Head;
	Head.mUrl = "http://www.httpbin.org/headers";
	Head.mMethod = HTTP_HEADERS;
	Head.mCallback = [=](HttpResponse* response, HttpClient* curl) { std::printf("Request complete with code %d; response is %s\n", response->mResponseCode, curl->jsonToString(response->mBody).c_str()); }; mHttpClient->addHttpRequest(Head);

}

//--------------------------------------------------------------
void ofApp::update(){
	if (mHttpClient->getNumberOfRequests() > 0) {
		std::printf("Waiting for %d responses...\n", mHttpClient->getNumberOfRequests());
	}
	else {
		if (!mIsComplete) {
			std::printf("Done!");
			mIsComplete = true;
		}
	}
}

//--------------------------------------------------------------
void ofApp::draw(){

}

//--------------------------------------------------------------
void ofApp::keyPressed(int key){

}

//--------------------------------------------------------------
void ofApp::keyReleased(int key){

}

//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){

}

//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mouseEntered(int x, int y){

}

//--------------------------------------------------------------
void ofApp::mouseExited(int x, int y){

}

//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){

}

//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){

}

//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){

}


text:
include T('default/module')

def init
  super
  sections.place(:subclasses).before(:children)
  sections.place(:constructor_details, [T('method_details')]).before(:methodmissing)
end

def constructor_details
  ctors = object.meths(:inherited => true, :included => true)
  return unless @ctor = ctors.find {|o| o.name == :initialize }
  return if prune_method_listing([@ctor]).empty?
  erb(:constructor_details)
end

def subclasses
  return if object.path == "Object" # don't show subclasses for Object
  unless globals.subclasses
    globals.subclasses = {}
    list = run_verifier Registry.all(:class)
    list.each do |o|
      (globals.subclasses[o.superclass.path] ||= []) << o if o.superclass
    end
  end

  @subclasses = globals.subclasses[object.path]
  return if @subclasses.nil? || @subclasses.empty?
  @subclasses = @subclasses.sort_by {|o| o.path }.map do |child|
    name = child.path
    if object.namespace
      name = object.relative_path(child)
    end
    [name, child]
  end
  erb(:subclasses)
end


text:
#include "tests/validation/fixtures/UNIT/QueueFixture.h"

#include "arm_compute/AclOpenClExt.h"
#include "src/gpu/cl/ClQueue.h"

namespace arm_compute
{
namespace test
{
namespace validation
{
TEST_SUITE(CL)
TEST_SUITE(UNIT)
TEST_SUITE(Queue)

EMPTY_BODY_FIXTURE_TEST_CASE(CreateQueueWithInvalidContext, CreateQueueWithInvalidContextFixture, framework::DatasetMode::ALL)
EMPTY_BODY_FIXTURE_TEST_CASE(CreateQueuerWithInvalidOptions, CreateQueuerWithInvalidOptionsFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL)
EMPTY_BODY_FIXTURE_TEST_CASE(DestroyInvalidQueue, DestroyInvalidQueueFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL)
EMPTY_BODY_FIXTURE_TEST_CASE(SimpleQueue, SimpleQueueFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL)

TEST_CASE(KhrQueuePriorities, framework::DatasetMode::ALL)
{
    acl::StatusCode err = acl::StatusCode::Success;

    acl::Context ctx(acl::Target::GpuOcl, &err);
    ARM_COMPUTE_ASSERT(err == acl::StatusCode::Success);

    acl::Queue queue(ctx, &err);
    ARM_COMPUTE_ASSERT(err == acl::StatusCode::Success);

    cl_device_id cl_dev;
    auto         status = AclGetClDevice(ctx.get(), &cl_dev);
    ARM_COMPUTE_ASSERT(status == AclSuccess);

    std::string extensions = cl::Device(cl_dev).getInfo<CL_DEVICE_EXTENSIONS>();
    if(extensions.find("cl_khr_priority_hints") != std::string::npos)
    {
        cl_int error = CL_SUCCESS;

        cl_context cl_ctx;
        auto       status = AclGetClContext(ctx.get(), &cl_ctx);
        ARM_COMPUTE_ASSERT(status == AclSuccess);

        /* Check a queue with high priority */
        cl_queue_properties queue_properties[] = { CL_QUEUE_PRIORITY_KHR, CL_QUEUE_PRIORITY_HIGH_KHR, 0 };
        cl_command_queue    priority_queue     = clCreateCommandQueueWithProperties(cl_ctx, cl_dev, queue_properties, &error);
        ARM_COMPUTE_ASSERT(error == CL_SUCCESS);

        clReleaseCommandQueue(priority_queue);
    }
}

TEST_SUITE_END() // Queue
TEST_SUITE_END() // UNIT
TEST_SUITE_END() // CL
} // namespace validation
} // namespace test
} // namespace arm_compute