text:
package com.smart.cloud.fire.mvp.recordProject;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RadioButton;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.p2p.core.P2PHandler;
import com.p2p.core.P2PValue;
import com.smart.cloud.fire.adapter.DateNumericAdapter;
import com.smart.cloud.fire.global.ConstantValues;
import com.smart.cloud.fire.global.Contact;
import com.smart.cloud.fire.ui.ApMonitorActivity;
import com.smart.cloud.fire.utils.Utils;
import com.smart.cloud.fire.view.WheelView;

import fire.cloud.smart.com.smartcloudfire.R;

public class RecordProjectActivity extends Activity implements View.OnClickListener,
        View.OnTouchListener  {
    private Context mContext;
    private Contact contact;
    private boolean isRegFilter = false;

    RelativeLayout change_record_time, change_plan_time;
    LinearLayout record_type_radio, record_time_radio, time_picker,ontime_lin;
    ProgressBar progressBar_record_time,
            progressBar_plan_time;
    RadioButton radio_one, radio_two, radio_three;
    RadioButton radio_one_time, radio_two_time, radio_three_time;
    TextView time_text,tv_control_record;
    WheelView hour_from, minute_from, hour_to, minute_to;
    String cur_modify_plan_time;
    int cur_modify_record_type;
    int cur_modify_record_time;

    RelativeLayout change_record, change_pre_record;
    ProgressBar progressBar_record, progressBar_pre_record;
    ImageView record_img, pre_record_img;
    TextView record_text, pre_record_text;
    RelativeLayout scroll_view;
    Button bt_plan_time;
    int recordState;
    int last_record;
    int last_modify_record;
    boolean isOpenPreRecord = false;
    int last_pre_record;
    int last_modify_pre_record;
    boolean isSupportPreRecored = false;
    int type;
    String idOrIp;

    String command;
    int SDcardId;
    int sdId;
    int usbId;
    boolean isSDCard;
    int count = 0;
    boolean isDropDown=false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_record_project);
        mContext = this;
        contact = (Contact) getIntent().getSerializableExtra("contact");
        idOrIp=contact.contactId;
        if(contact.ipadressAddress!=null){
            String mark=contact.ipadressAddress.getHostAddress();
            String ip=mark.substring(mark.lastIndexOf(".")+1,mark.length());
            if(!ip.equals("")&&ip!=null){
                idOrIp=ip;
            }
        }
        initComponent();
        regFilter();

        showProgress_record_type();
        P2PHandler.getInstance()
                .getNpcSettings(idOrIp, contact.contactPassword);
        command=createCommand("80", "0", "00");
        P2PHandler.getInstance().getSdCardCapacity(idOrIp, contact.contactPassword,command);
    }

    public void initComponent() {
        scroll_view = (RelativeLayout) findViewById(R.id.scroll_view);
        record_type_radio = (LinearLayout) findViewById(R.id.record_type_radio);
        radio_one = (RadioButton) findViewById(R.id.radio_one);
        radio_two = (RadioButton) findViewById(R.id.radio_two);
        radio_three = (RadioButton) findViewById(R.id.radio_three);

        change_record_time = (RelativeLayout) findViewById(R.id.change_record_time);
        record_time_radio = (LinearLayout) findViewById(R.id.record_time_radio);
        progressBar_record_time = (ProgressBar) findViewById(R.id.progressBar_record_time);

        radio_one_time = (RadioButton) findViewById(R.id.radio_one_time);
        radio_two_time = (RadioButton) findViewById(R.id.radio_two_time);
        radio_three_time = (RadioButton) findViewById(R.id.radio_three_time);

        change_plan_time = (RelativeLayout) findViewById(R.id.change_plan_time);
        ontime_lin = (LinearLayout) findViewById(R.id.ontime_lin);
        progressBar_plan_time = (ProgressBar) findViewById(R.id.progressBar_plan_time);
        time_picker = (LinearLayout)findViewById(R.id.time_picker);
        time_text = (TextView) findViewById(R.id.time_text);
        tv_control_record = (TextView) findViewById(R.id.tv_control_record);
        tv_control_record.setText(contact.contactName);
        initTimePicker();
        bt_plan_time = (Button) findViewById(R.id.bt_plan_time);

        bt_plan_time.setOnClickListener(this);
        radio_one.setOnClickListener(this);
        radio_two.setOnClickListener(this);
        radio_three.setOnClickListener(this);

        radio_one_time.setOnClickListener(this);
        radio_two_time.setOnClickListener(this);
        radio_three_time.setOnClickListener(this);

        change_record = (RelativeLayout) findViewById(R.id.change_record);
        record_img = (ImageView) findViewById(R.id.record_img);
        record_text = (TextView)findViewById(R.id.record_text);
        progressBar_record = (ProgressBar) findViewById(R.id.progressBar_record);

        change_pre_record = (RelativeLayout) findViewById(R.id.change_pre_record);
        pre_record_text = (TextView) findViewById(R.id.pre_record_text);
        pre_record_img = (ImageView)findViewById(R.id.pre_record_img);
        progressBar_pre_record = (ProgressBar) findViewById(R.id.progressBar_pre_record);
        change_record.setOnClickListener(this);
        change_pre_record.setOnClickListener(this);
        change_pre_record.setClickable(false);
    }

    public void initTimePicker() {
        hour_from = (WheelView) findViewById(R.id.hour_from);
        hour_from.setViewAdapter(new DateNumericAdapter(mContext, 0, 23));
        hour_from.setCyclic(true);

        minute_from = (WheelView)findViewById(R.id.minute_from);
        minute_from.setViewAdapter(new DateNumericAdapter(mContext, 0, 59));
        minute_from.setCyclic(true);

        hour_to = (WheelView)findViewById(R.id.hour_to);
        hour_to.setViewAdapter(new DateNumericAdapter(mContext, 0, 23));
        hour_to.setCyclic(true);

        minute_to = (WheelView)findViewById(R.id.minute_to);
        minute_to.setViewAdapter(new DateNumericAdapter(mContext, 0, 59));
        minute_to.setCyclic(true);
        hour_from.setOnTouchListener(this);
        minute_from.setOnTouchListener(this);
        hour_to.setOnTouchListener(this);
        minute_to.setOnTouchListener(this);
    }

    public void regFilter() {
        IntentFilter filter = new IntentFilter();
        filter.addAction(ConstantValues.P2P.ACK_RET_GET_NPC_SETTINGS);

        filter.addAction(ConstantValues.P2P.ACK_RET_SET_RECORD_TYPE);
        filter.addAction(ConstantValues.P2P.RET_SET_RECORD_TYPE);
        filter.addAction(ConstantValues.P2P.RET_GET_RECORD_TYPE);

        filter.addAction(ConstantValues.P2P.ACK_RET_SET_RECORD_TIME);
        filter.addAction(ConstantValues.P2P.RET_SET_RECORD_TIME);
        filter.addAction(ConstantValues.P2P.RET_GET_RECORD_TIME);

        filter.addAction(ConstantValues.P2P.ACK_RET_SET_RECORD_PLAN_TIME);
        filter.addAction(ConstantValues.P2P.RET_SET_RECORD_PLAN_TIME);
        filter.addAction(ConstantValues.P2P.RET_GET_RECORD_PLAN_TIME);

        filter.addAction(ConstantValues.P2P.ACK_RET_SET_REMOTE_RECORD);
        filter.addAction(ConstantValues.P2P.RET_SET_REMOTE_RECORD);
        filter.addAction(ConstantValues.P2P.RET_GET_REMOTE_RECORD);
        filter.addAction(ConstantValues.P2P.RET_GET_PRE_RECORD);
        filter.addAction(ConstantValues.P2P.ACK_RET_SET_PRE_RECORD);
        filter.addAction(ConstantValues.P2P.RET_SET_PRE_RECORD);
        filter.addAction(ConstantValues.P2P.ACK_GET_SD_CARD_CAPACITY);
        filter.addAction(ConstantValues.P2P.RET_GET_SD_CARD_CAPACITY);
        filter.addAction(ConstantValues.P2P.ACK_GET_SD_CARD_FORMAT);
        filter.addAction(ConstantValues.P2P.RET_GET_SD_CARD_FORMAT);
        filter.addAction(ConstantValues.P2P.RET_GET_USB_CAPACITY);
        filter.addAction(ConstantValues.P2P.RET_DEVICE_NOT_SUPPORT);
        mContext.registerReceiver(mReceiver, filter);
        isRegFilter = true;
    }

    private BroadcastReceiver mReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context arg0, Intent intent) {
            if (intent.getAction().equals(
                    ConstantValues.P2P.ACK_RET_GET_NPC_SETTINGS)) {
                int result = intent.getIntExtra("result", -1);
                if (result == ConstantValues.P2P_SET.ACK_RESULT.ACK_PWD_ERROR) {
                    Intent i = new Intent();
                    i.setAction(ConstantValues.Action.CONTROL_SETTING_PWD_ERROR);
                    mContext.sendBroadcast(i);
                } else if (result == ConstantValues.P2P_SET.ACK_RESULT.ACK_NET_ERROR) {
                    Log.e("my", "net error resend:get npc settings");
                    P2PHandler.getInstance().getNpcSettings(idOrIp,
                            contact.contactPassword);
                }
            } else if (intent.getAction().equals(
                    ConstantValues.P2P.RET_GET_RECORD_TYPE)) {
                type = intent.getIntExtra("type", -1);
                updateRecordType(type);
                showRecordType();
            } else if (intent.getAction().equals(
                    ConstantValues.P2P.RET_SET_RECORD_TYPE)) {
                int result = intent.getIntExtra("result", -1);
                if (result == ConstantValues.P2P_SET.RECORD_TYPE_SET.SETTING_SUCCESS) {
                    P2PHandler.getInstance().getNpcSettings(idOrIp,
                            contact.contactPassword);
                    // updateRecordType(cur_modify_record_type);
                    // showRecordType();
                    Toast.makeText(mContext, "修改成功", Toast.LENGTH_SHORT).show();
                } else {
                    showRecordType();
                    Toast.makeText(mContext, "操作失败", Toast.LENGTH_SHORT).show();
                }
            } else if (intent.getAction().equals(
                    ConstantValues.P2P.RET_GET_RECORD_TIME)) {
                int time = intent.getIntExtra("time", -1);
                if (time == ConstantValues.P2P_SET.RECORD_TIME_SET.RECORD_TIME_ONE_MINUTE) {
                    radio_one_time.setChecked(true);
                } else if (time == ConstantValues.P2P_SET.RECORD_TIME_SET.RECORD_TIME_TWO_MINUTE) {
                    radio_two_time.setChecked(true);
                } else if (time == ConstantValues.P2P_SET.RECORD_TIME_SET.RECORD_TIME_THREE_MINUTE) {
                    radio_three_time.setChecked(true);
                }
                radio_one_time.setEnabled(true);
                radio_two_time.setEnabled(true);
                radio_three_time.setEnabled(true);
                progressBar_record_time.setVisibility(RelativeLayout.GONE);
            } else if (intent.getAction().equals(
                    ConstantValues.P2P.RET_SET_RECORD_TIME)) {
                int result = intent.getIntExtra("result", -1);
                if (result == 0) {
                    if (cur_modify_record_time == ConstantValues.P2P_SET.RECORD_TIME_SET.RECORD_TIME_ONE_MINUTE) {
                        radio_one_time.setChecked(true);
                    } else if (cur_modify_record_time == ConstantValues.P2P_SET.RECORD_TIME_SET.RECORD_TIME_TWO_MINUTE) {
                        radio_two_time.setChecked(true);
                    } else if (cur_modify_record_time == ConstantValues.P2P_SET.RECORD_TIME_SET.RECORD_TIME_THREE_MINUTE) {
                        radio_three_time.setChecked(true);
                    }
                    radio_one_time.setEnabled(true);
                    radio_two_time.setEnabled(true);
                    radio_three_time.setEnabled(true);
                    progressBar_record_time.setVisibility(RelativeLayout.GONE);
                    Toast.makeText(mContext, "修改成功", Toast.LENGTH_SHORT).show();
                } else {
                    radio_one_time.setEnabled(true);
                    radio_two_time.setEnabled(true);
                    radio_three_time.setEnabled(true);
                    progressBar_record_time.setVisibility(RelativeLayout.GONE);
                    Toast.makeText(mContext, "操作失败", Toast.LENGTH_SHORT).show();
                }
            } else if (intent.getAction().equals(
                    ConstantValues.P2P.RET_GET_RECORD_PLAN_TIME)) {
                String time = intent.getStringExtra("time");
                Log.e("time", time);
                String startTime1 = time.substring(0, 2);
                String startTime2 = time.substring(3, 5);
                String endTime1 = time.substring(6, 8);
                String endTime2 = time.substring(9, 11);
                if (Integer.parseInt(startTime1) < 10) {
                    startTime1 = time.substring(1, 2);
                }
                if (Integer.parseInt(startTime2) < 10) {
                    startTime2 = time.substring(4, 5);
                }
                if (Integer.parseInt(endTime1) < 10) {
                    endTime1 = time.substring(7, 8);
                }
                if (Integer.parseInt(endTime2) < 10) {
                    endTime2 = time.substring(10, 11);
                }
                hour_from.setCurrentItem(Integer.parseInt(startTime1));
                minute_from.setCurrentItem(Integer.parseInt(startTime2));
                hour_to.setCurrentItem(Integer.parseInt(endTime1));
                minute_to.setCurrentItem(Integer.parseInt(endTime2));
                Log.e("time", startTime1 + " " + startTime2);
                Log.e("time", endTime1 + " " + endTime2);
                time_text.setText(time);
                change_plan_time.setEnabled(true);
                progressBar_plan_time.setVisibility(RelativeLayout.GONE);
                time_text.setVisibility(RelativeLayout.VISIBLE);
            } else if (intent.getAction().equals(
                    ConstantValues.P2P.RET_SET_RECORD_PLAN_TIME)) {
                int result = intent.getIntExtra("result", -1);
                if (result == ConstantValues.P2P_SET.RECORD_PLAN_TIME_SET.SETTING_SUCCESS) {
                    time_text.setText(cur_modify_plan_time);
                    change_plan_time.setEnabled(true);
                    progressBar_plan_time.setVisibility(RelativeLayout.GONE);
                    time_text.setVisibility(RelativeLayout.VISIBLE);
                    Toast.makeText(mContext, "修改成功", Toast.LENGTH_SHORT).show();
                } else {
                    change_plan_time.setEnabled(true);
                    progressBar_plan_time.setVisibility(RelativeLayout.GONE);
                    time_text.setVisibility(RelativeLayout.VISIBLE);
                    Toast.makeText(mContext, "操作失败", Toast.LENGTH_SHORT).show();
                }
            } else if (intent.getAction().equals(
                    ConstantValues.P2P.ACK_RET_SET_RECORD_TYPE)) {
                int result = intent.getIntExtra("result", -1);
                if (result == ConstantValues.P2P_SET.ACK_RESULT.ACK_PWD_ERROR) {
                    Intent i = new Intent();
                    i.setAction(ConstantValues.Action.CONTROL_SETTING_PWD_ERROR);
                    mContext.sendBroadcast(i);
                } else if (result == ConstantValues.P2P_SET.ACK_RESULT.ACK_NET_ERROR) {
                    Log.e("my", "net error resend:set npc settings record type");
                    P2PHandler.getInstance().setRecordType(idOrIp,
                            contact.contactPassword, cur_modify_record_type);
                }
            } else if (intent.getAction().equals(
                    ConstantValues.P2P.ACK_RET_SET_RECORD_TIME)) {
                int result = intent.getIntExtra("result", -1);
                if (result == ConstantValues.P2P_SET.ACK_RESULT.ACK_PWD_ERROR) {
                    Intent i = new Intent();
                    i.setAction(ConstantValues.Action.CONTROL_SETTING_PWD_ERROR);
                    mContext.sendBroadcast(i);
                } else if (result == ConstantValues.P2P_SET.ACK_RESULT.ACK_NET_ERROR) {
                    Log.e("my", "net error resend:set npc settings record time");
                    P2PHandler.getInstance().setRecordType(idOrIp,
                            contact.contactPassword, cur_modify_record_type);
                }
            } else if (intent.getAction().equals(
                    ConstantValues.P2P.ACK_RET_SET_RECORD_PLAN_TIME)) {
                int result = intent.getIntExtra("result", -1);
                if (result == ConstantValues.P2P_SET.ACK_RESULT.ACK_PWD_ERROR) {
                    Intent i = new Intent();
                    i.setAction(ConstantValues.Action.CONTROL_SETTING_PWD_ERROR);
                    mContext.sendBroadcast(i);
                } else if (result == ConstantValues.P2P_SET.ACK_RESULT.ACK_NET_ERROR) {
                    Log.e("my",
                            "net error resend:set npc settings record plan time");
                    P2PHandler.getInstance().setRecordPlanTime(idOrIp,
                            contact.contactPassword, cur_modify_plan_time);
                }
            } else if (intent.getAction().equals(
                    ConstantValues.P2P.RET_GET_REMOTE_RECORD)) {
                int state = intent.getIntExtra("state", -1);
                progressBar_record.setVisibility(RelativeLayout.GONE);
                record_img.setVisibility(RelativeLayout.VISIBLE);
                updateRecord(state);
            } else if (intent.getAction().equals(
                    ConstantValues.P2P.RET_SET_REMOTE_RECORD)) {
                int state = intent.getIntExtra("state", -1);
                P2PHandler.getInstance().getNpcSettings(idOrIp,
                        contact.contactPassword);
                // updateRecord(state);
            } else if (intent.getAction().equals(
                    ConstantValues.P2P.ACK_RET_SET_REMOTE_RECORD)) {
                int result = intent.getIntExtra("result", -1);
                if (result == ConstantValues.P2P_SET.ACK_RESULT.ACK_PWD_ERROR) {
                    Intent i = new Intent();
                    i.setAction(ConstantValues.Action.CONTROL_SETTING_PWD_ERROR);
                    mContext.sendBroadcast(i);
                } else if (result == ConstantValues.P2P_SET.ACK_RESULT.ACK_NET_ERROR) {
                    Log.e("my", "net error resend:set remote record");
                    P2PHandler.getInstance().setRemoteRecord(idOrIp,
                            contact.contactPassword, last_modify_record);
                }
            } else if (intent.getAction().equals(
                    ConstantValues.P2P.RET_GET_PRE_RECORD)) {
                int state = intent.getIntExtra("state", -1);
                isSupportPreRecored = true;
                change_pre_record.setClickable(true);
                if (type == ConstantValues.P2P_SET.RECORD_TYPE_SET.RECORD_TYPE_ALARM) {
                    change_pre_record.setVisibility(RelativeLayout.VISIBLE);
                }
                if (state == 1) {
                    pre_record_img
                            .setBackgroundResource(R.drawable.ic_checkbox_on);
                    last_pre_record = ConstantValues.P2P_SET.PRE_RECORD_SET.PRE_RECORD_SWITCH_ON;
                } else if (state == 0) {
                    pre_record_img
                            .setBackgroundResource(R.drawable.ic_checkbox_off);
                    last_pre_record = ConstantValues.P2P_SET.PRE_RECORD_SET.PRE_RECORD_SWITCH_OFF;
                }
                showPreRecordImg();
            } else if (intent.getAction().equals(
                    ConstantValues.P2P.ACK_RET_SET_PRE_RECORD)) {
                int result = intent.getIntExtra("state", -1);
                if (result == ConstantValues.P2P_SET.ACK_RESULT.ACK_PWD_ERROR) {
                    Intent i = new Intent();
                    i.setAction(ConstantValues.Action.CONTROL_SETTING_PWD_ERROR);
                    mContext.sendBroadcast(i);
                } else if (result == ConstantValues.P2P_SET.ACK_RESULT.ACK_NET_ERROR) {
                    Log.e("my", "net error resend:set npc settings record type");
                    P2PHandler.getInstance().setPreRecord(idOrIp,
                            contact.contactPassword, last_modify_pre_record);
                }
            } else if (intent.getAction().equals(
                    ConstantValues.P2P.RET_SET_PRE_RECORD)) {
                int result = intent.getIntExtra("result", -1);
                if (result == 0) {
                    P2PHandler.getInstance().getNpcSettings(idOrIp,
                            contact.contactPassword);
                    Toast.makeText(mContext, "修改成功", Toast.LENGTH_SHORT).show();
                } else if (result == 83) {
                    Toast.makeText(mContext, "操作失败", Toast.LENGTH_SHORT).show();
                }
            }else if (intent.getAction().equals(
                    ConstantValues.P2P.ACK_GET_SD_CARD_CAPACITY)) {
                int result = intent.getIntExtra("result", -1);
                if (result == ConstantValues.P2P_SET.ACK_RESULT.ACK_PWD_ERROR) {

                    Intent i = new Intent();
                    i.setAction(ConstantValues.Action.CONTROL_SETTING_PWD_ERROR);
                    mContext.sendBroadcast(i);

                } else if (result == ConstantValues.P2P_SET.ACK_RESULT.ACK_NET_ERROR) {
                    Log.e("my", "net error resend:get npc time");
                    P2PHandler.getInstance().getSdCardCapacity(idOrIp,
                            contact.contactPassword, command);
                }
            } else if (intent.getAction().equals(
                    ConstantValues.P2P.RET_GET_SD_CARD_CAPACITY)) {
                Log.e("usb","no sd card");
                int total_capacity = intent.getIntExtra("total_capacity", -1);
                int remain_capacity = intent.getIntExtra("remain_capacity", -1);
                int state = intent.getIntExtra("state", -1);
                SDcardId = intent.getIntExtra("SDcardID", -1);
                String id = Integer.toBinaryString(SDcardId);
                Log.e("id", "msga" + id);
                while (id.length() < 8) {
                    id = "0" + id;
                }
                char index = id.charAt(3);
                Log.e("id", "msgb" + id);
                Log.e("id", "msgc" + index);
                if (state == 1) {
                    if (index == '1') {
                        sdId = SDcardId;
                    } else if (index == '0') {
                        usbId = SDcardId;
                    }
                }
            } else if (intent.getAction().equals(
                    ConstantValues.P2P.ACK_GET_SD_CARD_FORMAT)) {
                int result = intent.getIntExtra("result", -1);
                if (result == ConstantValues.P2P_SET.ACK_RESULT.ACK_PWD_ERROR) {

                    Intent i = new Intent();
                    i.setAction(ConstantValues.Action.CONTROL_SETTING_PWD_ERROR);
                    mContext.sendBroadcast(i);

                } else if (result == ConstantValues.P2P_SET.ACK_RESULT.ACK_NET_ERROR) {
                    Log.e("my", "net error resend:get npc time");
                    P2PHandler.getInstance().setSdFormat(idOrIp,
                            contact.contactPassword, sdId);
                }
            } else if (intent.getAction().equals(
                    ConstantValues.P2P.RET_GET_SD_CARD_FORMAT)) {
                int result = intent.getIntExtra("result", -1);
                if (result == ConstantValues.P2P_SET.SD_FORMAT.SD_CARD_SUCCESS) {
                    Toast.makeText(mContext, "SD卡格式化成功", Toast.LENGTH_SHORT).show();
                } else if (result == ConstantValues.P2P_SET.SD_FORMAT.SD_CARD_FAIL) {
                    Toast.makeText(mContext, "SD卡格式化失败", Toast.LENGTH_SHORT).show();
                } else if (result == ConstantValues.P2P_SET.SD_FORMAT.SD_NO_EXIST) {
                    Toast.makeText(mContext, "SD卡不存在", Toast.LENGTH_SHORT).show();
                }
            } else if (intent.getAction().equals(
                    ConstantValues.P2P.RET_GET_USB_CAPACITY)) {
                Log.e("usb","get usb");
                int total_capacity = intent.getIntExtra("total_capacity", -1);
                int remain_capacity = intent.getIntExtra("remain_capacity", -1);
                int state = intent.getIntExtra("state", -1);
                SDcardId = intent.getIntExtra("SDcardID", -1);
                String id = Integer.toBinaryString(SDcardId);
                Log.e("id", "msga" + id);
                while (id.length() < 8) {
                    id = "0" + id;
                }
                char index = id.charAt(3);
                Log.e("id", "msgb" + id);
                Log.e("id", "msgc" + index);
                if (state == 1) {
                    if (index == '1') {
                        sdId = SDcardId;
                    } else if (index == '0') {
                        usbId = SDcardId;
                    }
                } else {
                    Log.e("usb","no usb");
                    count++;
                    if (contact.contactType == P2PValue.DeviceType.IPC) {
                        if (count == 1) {
                            Intent back = new Intent();
                            back.setAction(ConstantValues.Action.REPLACE_MAIN_CONTROL);
                            mContext.sendBroadcast(back);
                            Toast.makeText(mContext, "SD卡不存在", Toast.LENGTH_SHORT).show();
                        }
                    } else {
                        if (count == 2) {
                            Intent back = new Intent();
                            back.setAction(ConstantValues.Action.REPLACE_MAIN_CONTROL);
                            mContext.sendBroadcast(back);
                            Toast.makeText(mContext, "SD卡不存在", Toast.LENGTH_SHORT).show();
                        }
                        //sd_card_remainning_capacity.setBackgroundResource(R.drawable.tiao_bg_bottom);
                    }
                }
            } else if (intent.getAction().equals(
                    ConstantValues.P2P.RET_DEVICE_NOT_SUPPORT)) {

            }
        }

    };

    public void updateRecord(int state) {
        if (state == ConstantValues.P2P_SET.REMOTE_RECORD_SET.RECORD_SWITCH_ON) {
            last_record = ConstantValues.P2P_SET.REMOTE_RECORD_SET.RECORD_SWITCH_ON;
            record_img.setBackgroundResource(R.drawable.ic_checkbox_on);
        } else {
            last_record = ConstantValues.P2P_SET.REMOTE_RECORD_SET.RECORD_SWITCH_OFF;
            record_img.setBackgroundResource(R.drawable.ic_checkbox_off);
        }
    }

    void updateRecordType(int type) {
        if (type == ConstantValues.P2P_SET.RECORD_TYPE_SET.RECORD_TYPE_MANUAL) {
            radio_one.setChecked(true);
            hideRecordTime();
            hidePlanTime();
            showManual();
        } else if (type == ConstantValues.P2P_SET.RECORD_TYPE_SET.RECORD_TYPE_ALARM) {
            radio_two.setChecked(true);
            hidePlanTime();
            hideManual();
            showRecordTime();
        } else if (type == ConstantValues.P2P_SET.RECORD_TYPE_SET.RECORD_TYPE_TIMER) {
            radio_three.setChecked(true);
            hideRecordTime();
            hideManual();
            showPlanTime();
        }
    }

    public void showRecordType() {
        record_type_radio.setVisibility(RelativeLayout.VISIBLE);
        radio_one.setEnabled(true);
        radio_two.setEnabled(true);
        radio_three.setEnabled(true);
    }

    public void showProgress_record_type() {
        record_type_radio.setVisibility(RelativeLayout.GONE);
    }

    public void showRecordTime() {
        change_record_time.setVisibility(RelativeLayout.VISIBLE);
        record_time_radio.setVisibility(RelativeLayout.VISIBLE);
        progressBar_record_time.setVisibility(RelativeLayout.GONE);
        if (isSupportPreRecored == true) {
            change_pre_record.setVisibility(RelativeLayout.VISIBLE);
        } else {
            change_pre_record.setVisibility(RelativeLayout.GONE);
        }
    }

    public void showProgress_record_time() {
        change_record_time.setVisibility(RelativeLayout.VISIBLE);
        record_time_radio.setVisibility(RelativeLayout.VISIBLE);
        progressBar_record_time.setVisibility(RelativeLayout.VISIBLE);
    }

    public void showPlanTime() {
        change_pre_record.setVisibility(RelativeLayout.GONE);
        change_record.setVisibility(RelativeLayout.GONE);
//		time_picker.setVisibility(RelativeLayout.VISIBLE);
//		change_plan_time.setVisibility(RelativeLayout.VISIBLE);
        ontime_lin.setVisibility(RelativeLayout.VISIBLE);
//		progressBar_plan_time.setVisibility(RelativeLayout.GONE);
        time_text.setVisibility(RelativeLayout.VISIBLE);

    }

    public void showProgress_plan_time() {
        time_picker.setVisibility(RelativeLayout.VISIBLE);
        change_plan_time.setVisibility(RelativeLayout.VISIBLE);
        //change_plan_time.setEnabled(false);
        progressBar_plan_time.setVisibility(RelativeLayout.VISIBLE);
        time_text.setVisibility(RelativeLayout.GONE);
    }

    public void showManual() {
        change_record.setVisibility(RelativeLayout.VISIBLE);
        change_pre_record.setVisibility(RelativeLayout.GONE);
    }

    public void showPreRecordProgress() {
        progressBar_pre_record.setVisibility(ProgressBar.VISIBLE);
        pre_record_img.setVisibility(ImageView.GONE);
    }

    public void showPreRecordImg() {
        progressBar_pre_record.setVisibility(ProgressBar.GONE);
        pre_record_img.setVisibility(ImageView.VISIBLE);
    }

    public void hideRecordTime() {
        change_record_time.setVisibility(RelativeLayout.GONE);
        record_time_radio.setVisibility(RelativeLayout.GONE);
    }

    public void hidePlanTime() {
        ontime_lin.setVisibility(RelativeLayout.GONE);
    }

    public void hideManual() {
        change_record.setVisibility(RelativeLayout.GONE);
    }

    public void showRecordSwitchProgress() {
        progressBar_record.setVisibility(RelativeLayout.VISIBLE);
        record_img.setVisibility(RelativeLayout.GONE);
    }

    public void showRecordSwitchImg() {
        progressBar_record.setVisibility(RelativeLayout.GONE);
        record_img.setVisibility(RelativeLayout.VISIBLE);
    }

    public String createCommand(String bCommandType, String bOption,
                                String SDCardCounts) {
        return bCommandType + bOption + SDCardCounts;
    }

    @Override
    public boolean onTouch(View arg0, MotionEvent arg1) {
        // TODO Auto-generated method stub
        if (arg1.getAction() == MotionEvent.ACTION_UP) {
            scroll_view.requestDisallowInterceptTouchEvent(false);
        } else {
            scroll_view.requestDisallowInterceptTouchEvent(true);
        }
        return false;
    }

    @Override
    public void onClick(View arg0) {
        // TODO Auto-generated method stub
        switch (arg0.getId()) {
            case R.id.change_record:
                progressBar_record.setVisibility(RelativeLayout.VISIBLE);
                record_img.setVisibility(RelativeLayout.GONE);
                if (last_record == ConstantValues.P2P_SET.REMOTE_RECORD_SET.RECORD_SWITCH_ON) {
                    last_modify_record = ConstantValues.P2P_SET.REMOTE_RECORD_SET.RECORD_SWITCH_OFF;
                    P2PHandler.getInstance().setRemoteRecord(idOrIp,
                            contact.contactPassword, last_modify_record);
                } else {
                    last_modify_record = ConstantValues.P2P_SET.REMOTE_RECORD_SET.RECORD_SWITCH_ON;
                    P2PHandler.getInstance().setRemoteRecord(idOrIp,
                            contact.contactPassword, last_modify_record);
                }
                break;
            case R.id.radio_one:
                radio_one.setEnabled(false);
                radio_two.setEnabled(false);
                radio_three.setEnabled(false);
                cur_modify_record_type = ConstantValues.P2P_SET.RECORD_TYPE_SET.RECORD_TYPE_MANUAL;
                showRecordSwitchProgress();
                P2PHandler.getInstance().setRecordType(idOrIp,
                        contact.contactPassword, cur_modify_record_type);
                break;
            case R.id.radio_two:
                radio_one.setEnabled(false);
                radio_two.setEnabled(false);
                radio_three.setEnabled(false);
                cur_modify_record_type = ConstantValues.P2P_SET.RECORD_TYPE_SET.RECORD_TYPE_ALARM;
                showPreRecordProgress();
                P2PHandler.getInstance().setRecordType(idOrIp,
                        contact.contactPassword, cur_modify_record_type);
                break;
            case R.id.radio_three:
                radio_one.setEnabled(false);
                radio_two.setEnabled(false);
                radio_three.setEnabled(false);
                cur_modify_record_type = ConstantValues.P2P_SET.RECORD_TYPE_SET.RECORD_TYPE_TIMER;
                P2PHandler.getInstance().setRecordType(idOrIp,
                        contact.contactPassword, cur_modify_record_type);
                break;
            case R.id.radio_one_time:
                progressBar_record_time.setVisibility(RelativeLayout.VISIBLE);
                radio_one_time.setEnabled(false);
                radio_two_time.setEnabled(false);
                radio_three_time.setEnabled(false);
                cur_modify_record_time = ConstantValues.P2P_SET.RECORD_TIME_SET.RECORD_TIME_ONE_MINUTE;
                P2PHandler.getInstance().setRecordTime(idOrIp,
                        contact.contactPassword, cur_modify_record_time);
                break;
            case R.id.radio_two_time:
                progressBar_record_time.setVisibility(RelativeLayout.VISIBLE);
                radio_one_time.setEnabled(false);
                radio_two_time.setEnabled(false);
                radio_three_time.setEnabled(false);
                cur_modify_record_time = ConstantValues.P2P_SET.RECORD_TIME_SET.RECORD_TIME_TWO_MINUTE;
                P2PHandler.getInstance().setRecordTime(idOrIp,
                        contact.contactPassword, cur_modify_record_time);
                break;
            case R.id.radio_three_time:
                progressBar_record_time.setVisibility(RelativeLayout.VISIBLE);
                radio_one_time.setEnabled(false);
                radio_two_time.setEnabled(false);
                radio_three_time.setEnabled(false);
                cur_modify_record_time = ConstantValues.P2P_SET.RECORD_TIME_SET.RECORD_TIME_THREE_MINUTE;
                P2PHandler.getInstance().setRecordTime(idOrIp,
                        contact.contactPassword, cur_modify_record_time);
                break;
            case R.id.change_pre_record:
                // 1.开启
                showPreRecordProgress();
                if (last_pre_record == ConstantValues.P2P_SET.PRE_RECORD_SET.PRE_RECORD_SWITCH_ON) {
                    last_modify_pre_record = ConstantValues.P2P_SET.PRE_RECORD_SET.PRE_RECORD_SWITCH_OFF;
                    P2PHandler.getInstance().setPreRecord(idOrIp,
                            contact.contactPassword, last_modify_pre_record);
                    isOpenPreRecord = false;
                } else if (last_pre_record == ConstantValues.P2P_SET.PRE_RECORD_SET.PRE_RECORD_SWITCH_OFF) {
                    last_modify_pre_record = ConstantValues.P2P_SET.PRE_RECORD_SET.PRE_RECORD_SWITCH_ON;
                    P2PHandler.getInstance().setPreRecord(idOrIp,
                            contact.contactPassword, last_modify_pre_record);
                    isOpenPreRecord = true;
                }
                break;
            case R.id.bt_plan_time:
                showProgress_plan_time();

                cur_modify_plan_time = Utils.convertPlanTime(
                        hour_from.getCurrentItem(), minute_from.getCurrentItem(),
                        hour_to.getCurrentItem(), minute_to.getCurrentItem());
                P2PHandler.getInstance().setRecordPlanTime(idOrIp,
                        contact.contactPassword, cur_modify_plan_time);
                break;
        }
    }

    @Override
    public void onDestroy() {
        if (isRegFilter) {
            mContext.unregisterReceiver(mReceiver);
            isRegFilter = false;
        }
        Intent it = new Intent();
        it.setAction(ConstantValues.Action.CONTROL_BACK);
        mContext.sendBroadcast(it);
        super.onDestroy();
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        // TODO Auto-generated method stub
        if (keyCode == KeyEvent.KEYCODE_BACK){
            Intent i = new Intent(mContext,ApMonitorActivity.class);
            i.putExtra("contact", contact);
            startActivity(i);
            finish();
        }
        return super.onKeyDown(keyCode, event);
    }
}


text:
package main

import (
	"os"
	"strings"
	"time"

	"github.com/kataras/iris"
	"github.com/kataras/iris/middleware/logger"
)

const deleteFileOnExit = true

func main() {
	app := iris.New()
	r, close := newRequestLogger()
	defer close()

	app.Use(r)
	app.OnAnyErrorCode(r, func(ctx iris.Context) {
		ctx.HTML("
 Error: Please try  this  instead.
")
	})

	h := func(ctx iris.Context) {
		ctx.Writef("Hello from %s", ctx.Path())
	}

	app.Get("/", h)

	app.Get("/1", h)

	app.Get("/2", h)

	// http://localhost:8080
	// http://localhost:8080/1
	// http://localhost:8080/2
	// http://lcoalhost:8080/notfoundhere
	app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed))
}

// get a filename based on the date, file logs works that way the most times
// but these are just a sugar.
func todayFilename() string {
	today := time.Now().Format("Jan 02 2006")
	return today + ".txt"
}

func newLogFile() *os.File {
	filename := todayFilename()
	// open an output file, this will append to the today's file if server restarted.
	f, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
	if err != nil {
		panic(err)
	}

	return f
}

var excludeExtensions = [...]string{
	".js",
	".css",
	".jpg",
	".png",
	".ico",
	".svg",
}

func newRequestLogger() (h iris.Handler, close func() error) {
	close = func() error { return nil }

	c := logger.Config{
		Status:  true,
		IP:      true,
		Method:  true,
		Path:    true,
		Columns: true,
	}

	logFile := newLogFile()
	close = func() error {
		err := logFile.Close()
		if deleteFileOnExit {
			err = os.Remove(logFile.Name())
		}
		return err
	}

	c.LogFunc = func(now time.Time, latency time.Duration, status, ip, method, path string, message interface{}, headerMessage interface{}) {
		output := logger.Columnize(now.Format("2006/01/02 - 15:04:05"), latency, status, ip, method, path, message, headerMessage)
		logFile.Write([]byte(output))
	}

	//	we don't want to use the logger
	// to log requests to assets and etc
	c.AddSkipper(func(ctx iris.Context) bool {
		path := ctx.Path()
		for _, ext := range excludeExtensions {
			if strings.HasSuffix(path, ext) {
				return true
			}
		}
		return false
	})

	h = logger.New(c)

	return
}

redpajama_set_name: RedPajamaGithub


text:
package com.tngtech.archunit.example.layers.controller;

public @interface ComplexControllerAnnotation {
    SimpleControllerAnnotation simpleControllerAnnotation();
}


text:
package com.tobedevoured.modelcitizen.callback.internal;

import com.tobedevoured.modelcitizen.callback.Callback;

/**
 *  Helper interface to ease the transition to the new callback package
 */
public interface Getable<T> extends Callback {
    T get( Object referenceModel );
}


text:
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>add_service</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<link rel="home" href="../../boost_asio.html" title="Boost.Asio">
<link rel="up" href="../reference.html" title="Reference">
<link rel="prev" href="WriteHandler.html" title="Write handler requirements">
<link rel="next" href="asio_handler_allocate.html" title="asio_handler_allocate">

Home
Libraries
People
FAQ
More

add_service

template<
    typename Service>
void add_service(
    io_service & ios,
    Service * svc);

        This function is used to add a service to the io_service.

        Parameters

ios

              The io_service
              object that owns the service.

svc

              The service object. On success, ownership of the service object is
              transferred to the io_service. When the io_service
              object is destroyed, it will destroy the service object by performing:

delete static_cast<io_service::service*>(svc)

        Exceptions

boost::asio::service_already_exists

              Thrown if a service of the given type is already present in the io_service.

boost::asio::invalid_service_owner

              Thrown if the service's owning io_service is not the io_service
              object specified by the ios parameter.

        Requirements

        Header: boost/asio/io_service.hpp

        Convenience header: boost/asio.hpp

Copyright © 2003-2013 Christopher M. Kohlhoff

        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)


text:
//==================================================================================
// Copyright (c) 2016 , Advanced Micro Devices, Inc.  All rights reserved.
//
/// \author AMD Developer Tools Team
/// \file csAMDKernelDebuggingManager.h
///
//==================================================================================

//------------------------------ csAMDKernelDebuggingManager.h ------------------------------

#ifndef __CSAMDKERNELDEBUGGINGMANAGER_H
#define __CSAMDKERNELDEBUGGINGMANAGER_H

// Forward declarations:
class osCallStack;
class osFilePath;
class csDWARFParser;
struct csDWARFProgram;
struct csDWARFVariable;

// AMD Server Utilities:
#include <AMDTServerUtilities/Include/suIKernelDebuggingManager.h>

// AMD CL Debugging API:
#include <AMDOpenCLDebug.h>

// Infra:
#include <AMDTBaseTools/Include/gtVector.h>
#include <AMDTBaseTools/Include/gtMap.h>
#include <AMDTOSWrappers/Include/osDebugLog.h>
#include <AMDTOSWrappers/Include/osOSDefinitions.h>
#include <AMDTOSAPIWrappers/Include/oaOpenCLIncludes.h>
#include <AMDTAPIClasses/Include/apBreakReason.h>
#include <AMDTAPIClasses/Include/apContextID.h>
#include <AMDTAPIClasses/Include/apKernelDebuggingCommand.h>
#include <AMDTAPIClasses/Include/apMonitoredFunctionId.h>

// ----------------------------------------------------------------------------------
// Class Name:          csAMDKernelDebuggingSession
// General Description: Contains all the information needed for kernel debugging.
//                      This struct is created at kernel enqueuement and is passed
//                      as the kernel debugging function's user data.
// Author:              Uri Shomroni
// Creation Date:       26/4/2011
// ----------------------------------------------------------------------------------
struct csAMDKernelDebuggingSession
{
public:
    enum csAMDKernelDebuggingSessionReason
    {
        CS_STEP_IN_COMMAND,
        CS_KERNEL_FUNCTION_NAME_BREAKPOINT,
        CS_KERNEL_SOURCE_CODE_BREAKPOINT
    };

public:
    csAMDKernelDebuggingSession(oaCLKernelHandle kernel, apMonitoredFunctionId kernelDebuggingFunction, suIKernelDebuggingManager::KernelDebuggingSessionReason reason, unsigned int workDimension, const gtSize_t* globalWorkOffset, const gtSize_t* globalWorkSize, const gtSize_t* localWorkSize);
    ~csAMDKernelDebuggingSession();

public:
    // The DWARF parser:
    csDWARFParser* _pDWARFParser;

    // Used to handle the deletion of this struct, to compensate for the options of synchronous and asynchronous debugging:
    bool _canDebugSessionBeDeleted;

    // The debugging context and kernel:
    apContextID _debuggedKernelComputeContextId;
    oaCLKernelHandle _debuggedKernelHandle;

    // The debugging program
    oaCLProgramHandle _debuggedKernelContainingProgramHandle;
    gtString _debuggedKernelContainingProgramSourceFilePath;

    // The function used to enqueue the kernel:
    apMonitoredFunctionId _debuggingKernelFunction;
    suIKernelDebuggingManager::KernelDebuggingSessionReason _kernelDebuggingReason;

    // The global and local work location:
    int _debuggedKernelGlobalWorkOffset[3];
    int _debuggedKernelGlobalWorkSize[3];
    int _debuggedKernelLocalWorkSize[3];
    int _debuggedKernelTotalGlobalWorkSize;

    // The kernel binary:
    gtUByte* _debuggedKernelBinary;
    gtSize_t _debuggedKernelBinarySize;

    // Details related to the debug API and the client API:
    amdclDebugContext _kernelDebugContext;
    int _lastDebuggedKernelLineNumber;
    bool* _debuggedKernelValidWorkItems;
    int _steppingWorkItem[3];
    amdclDebugPC _debuggedKernelProgramCounter;
    amdclDebugPC _debuggedKernelLastProgramCounter;
    amdclDebugPC _debuggedKernelLastStoppedProgramCounter;
    bool _debuggedKernelFirstCallback;
    bool _debuggedKernelFirstBreakpoint;
    apBreakReason _continuedStepBreakReason;
    gtMap<amdclDebugPC, amdclDebugPC> _debuggedKernelBoundToRequestedBreakpoints;
    gtMap<amdclDebugPC, amdclDebugPC> _debuggedKernelRequestedToBoundBreakpoints;

    // Emulate breakpoints:
    gtVector<amdclDebugPC> _debuggedKernelAllPCsWithLineNumbers;
    gtVector<amdclDebugPC> _debuggedKernelCurrentBreakpoints;
    bool _areStepBreakpointsSet;
    bool _stepBreakpointsSetSuccessfully;

    // The next command we will send to the kernel debugging API:
    amdclDebugCommand _nextDebuggingCommand;
    bool _kernelDebuggingCallbackWaiting;
};

// ----------------------------------------------------------------------------------
// Class Name:          csAMDKernelDebuggingManager
// General Description: Manages connections to the AMD kernel debugging API and DWARF
// Author:              Uri Shomroni
// Creation Date:       21/11/2010
// ----------------------------------------------------------------------------------
class csAMDKernelDebuggingManager : public suIKernelDebuggingManager
{
public:
    csAMDKernelDebuggingManager();
    ~csAMDKernelDebuggingManager();
    static csAMDKernelDebuggingManager& instance();

    // General kernel debugging API functions:
    virtual bool initialize();
    virtual bool terminate();
    virtual bool programBuildFlagsSupported(const char* buildFlags, gtString& failureReason);
    virtual KernelDebuggingManagerType kernelDebuggerType();

    // Functions used in debugging kernels:
    virtual oaCLKernelHandle currentlyDebuggedKernel();
    virtual bool getGlobalWorkGeometry(int& o_workDimensions, int o_globalWorkSize[3], int o_localWorkSize[3], int o_globalWorkOffset[3]);
    virtual void setNextKernelDebuggingCommand(apKernelDebuggingCommand command);
    virtual bool setSteppingWorkItem(const int coordinate[3]);
    virtual bool isWorkItemValid(const int coordinate[3]);
    virtual bool getFirstValidWorkItem(int wavefrontIndex /*= -1*/, int o_coordinate[3]);
    virtual void releaseCallbackToNextCommand();

    // Aid functions:
    virtual bool getCurrentKernelCallStack(const int coordinate[3], osCallStack& kernelStack);
    virtual int getCurrentKernelDebugLineNumber(const int coordinate[3]);
    virtual bool doesVariableExistInCurrentScope(const gtString& variableName, const int coordinate[3]);
    virtual bool getVariableValueString(const gtString& variableName, const int coordinate[3], gtString& valueString, gtString& valueStringHex, gtString& variableType);
    virtual bool getVariableMembers(const gtString& variableName, const int coordinate[3], gtVector<gtString>& memberNames);
    virtual bool getAvailableVariables(const int coordinate[3], gtVector<gtString>& variableNames, bool getLeaves, int stackFrameDepth);
    virtual bool getExecutionMask(bool*& executionMask, int& maskSize);
    virtual bool getAmountOfActiveWavefronts(int& amountOfWavefronts);
    virtual bool getActiveWavefrontID(int wavefrontIndex, int& wavefrontId);
    virtual bool getWavefrontIndex(const int coordinate[3], int& o_wavefrontIndex);
    virtual bool exportVariableValuesToFile(const gtString& variableName, bool& variableTypeSupported, osFilePath& variableDataFilePath);
    virtual bool getKernelSourceBreakpointResolution(oaCLProgramHandle programHandle, int requestedLineNumber, int& resolvedLineNumber);

    // Note that this only synchronizes with this kernel debugging callback:
    static void synchronizeWithCSKernelDebuggingCallback();

    // The callback function used in debugging:
    static amdclDebugCommand csAMDclDebugCallback(amdclDebugContext debugContext, amdclDebugEvent debugEvent, void* user_data);

private:
    friend class csSingletonsDelete;

private:
    int lineNumberFromKernelProgramCounter(amdclDebugContext debugContext, amdclDebugPC programCounter, gtString& sourceFilePath);
    void kernelProgramCountersFromLineNumber(amdclDebugContext debugContext, const osFilePath& filePath, int lineNumber, gtVector<amdclDebugPC>& programCounters);
    bool getVariableValuesInCurrentLocation(const gtString& variableName, int variableIndex, const void*& variableValues, unsigned int& valueStride, csDWARFVariable& variableData, bool& wasAllocated);
    void releaseVariableValues(const void* variableValues, bool wasAllocated);

    void onKernelDebuggingStartedBreakpoint(amdclDebugContext debugContext);
    void onKernelDebuggingFinishedBreakpoint(amdclDebugContext debugContext);
    void onKernelDebuggingBreakpointHit(amdclDebugContext debugContext, apBreakReason brkReason);
    void cleanupOnKernelDebuggingEnded();

    void updateValidWorkItems();
    bool shouldContinueStepping(apBreakReason brkReason);
    void updateKernelBreakpoints(amdclDebugContext debugContext);
    int currentlyDebuggedKernelWorkDimension();
    const csDWARFVariable* getVariableDetailsInCurrentLocation(const gtString& variableName);

    void emulateStepCommand(amdclDebugCommand& debugCommand, amdclDebugContext debugContext);
    void setBreakpointsOnAllPCs(amdclDebugContext debugContext);
    void setBreakpointsFromCurrentPC(amdclDebugContext debugContext, bool includeCurrentScope);
    void addBreakpointsFromProgram(amdclDebugContext debugContext, const csDWARFProgram& program);
    void restoreRealBreakpoints(amdclDebugContext debugContext);

    static bool debugLastErrorString(amdclDebugContext debugContext, gtString& failureString);

private:
    static csAMDKernelDebuggingManager* _pMySingleInstance;

    // A handle to the module which contains the OpenCL Debugging API:
    osModuleHandle _hCLKernelDebuggingModule;

    // Holds the kernel debugging session while the callback exists:
    csAMDKernelDebuggingSession* _pCurrentKernelDebuggingSession;
};

// This specific global variable should not be used by other classes, we simply declare it privately as extern.
// Note it is initialized in csGlobalVariables.cpp, since it is used to initialize cs_stat_pIKernelDebuggingManager,
// which IS the public API:
extern csAMDKernelDebuggingManager& cs_stat_amdKernelDebuggingManager;

#endif //__CSAMDKERNELDEBUGGINGMANAGER_H


text:
package io.hekate.cluster;

import io.hekate.core.Hekate.State;
import io.hekate.core.HekateBootstrap;
import io.hekate.core.ServiceInfo;
import io.hekate.core.service.Service;
import io.hekate.network.NetworkServiceFactory;
import java.net.InetSocketAddress;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * Provides information about a single cluster node.
 *
 * @see ClusterTopology
 * @see ClusterService
 */
public interface ClusterNode extends Comparable<ClusterNode>, ClusterNodeIdSupport {
    /**
     * Returns the universally unique identifier of this node.
     *
     * @return Universally unique identifier of this node.
     */
    @Override
    ClusterNodeId id();

    /**
     * Returns the name of this node. Returns an empty string if this node doesn't have a configured name.
     *
     *

     * Value of this property can be configured via {@link HekateBootstrap#setNodeName(String)} method.
     *

     *
     * @return Name of this node or an empty string if node name is not configured.
     */
    String name();

    /**
     * Returns {@code true} if this is a local node.
     *
     * @return {@code true} if this is a local node.
     *
     * @see #isRemote()
     */
    boolean isLocal();

    /**
     * Returns {@code true} if this is a remote node.
     *
     * @return {@code true} if this is a remote node.
     *
     * @see #isLocal()
     */
    boolean isRemote();

    /**
     * Returns the network address of this node.
     *
     *

     * Network address can be configured by the following methods:
     *

     *

     *
{@link NetworkServiceFactory#setHost(String)}

     *
{@link NetworkServiceFactory#setPort(int)}

     *

     *
     * @return Network address of this node.
     */
    ClusterAddress address();

    /**
     * Returns the network socket address of this node.
     *
     *

     * This is a shortcut for {@link #address()}.{@link ClusterAddress#socket() getSocket()}
     *

     *
     * @return Network socket address of this node.
     */
    InetSocketAddress socket();

    /**
     * Returns information about the JVM of this node.
     *
     * @return Information about the JVM of this node.
     */
    ClusterNodeRuntime runtime();

    /**
     * Returns the immutable set of roles that are configured for this node. Returns an empty set if roles are not configured for this
     * node.
     *
     *

     * Roles can be configured via {@link HekateBootstrap#setRoles(List)} method.
     *

     *
     * @return Immutable set of node roles aor an empty set if roles are not configured.
     */
    Set<String> roles();

    /**
     * Returns {@code true} if this node has the specified role (see {@link #roles()}).
     *
     * @param role Role.
     *
     * @return {@code true} if this node has the specified role.
     */
    boolean hasRole(String role);

    /**
     * Returns the immutable map of properties that are configured for this node. Returns an empty map if properties are not configured for
     * this node.
     *
     *

     * Properties can be configured via {@link HekateBootstrap#setProperties(Map)} method.
     *

     *
     * @return Immutable map of node properties or an empty map if properties are not configured.
     */
    Map<String, String> properties();

    /**
     * Returns value for the specified property name (see {@link #properties()}).
     *
     * @param name Property name.
     *
     * @return Property value or {@code null} if there is no such property.
     */
    String property(String name);

    /**
     * Returns {@code true} if this node has a property with the specified name (see {@link #properties()}).
     *
     * @param name Property name.
     *
     * @return {@code true} if this node has a property with the specified name.
     */
    boolean hasProperty(String name);

    /**
     * Returns {@code true} if this node has a service of the specified type.
     *
     * @param type Service type (must be an interface that extends {@link Service}).
     *
     * @return {@code true} if this node has a service of the specified type.
     *
     * @see #services()
     */
    boolean hasService(Class<? extends Service> type);

    /**
     * Returns the service information for the specified type.
     *
     * @param type Service type (must be an interface that extends {@link Service}).
     *
     * @return Service instance or {@code null} if there is no such service.
     *
     * @see #services()
     */
    ServiceInfo service(Class<? extends Service> type);

    /**
     * Returns the immutable map of services that are provided by this node, with the {@link ServiceInfo#type() service type} as
     * the key.
     *
     * @return Immutable map of services.
     *
     * @see HekateBootstrap#setServices(List)
     */
    Map<String, ServiceInfo> services();

    /**
     * Returns the cluster join order. Indexing the join order begins with 1, so the first node that joins the cluster has a value of 1,
     * the
     * second node has a value of 2, and so on. The value of this property is initialized only when the node joins the cluster and is NOT
     * updated if the previous (old) node leaves the cluster.
     *
     *

     * Note that the default value for this property is 0 and it is initialized with its actual value only when the node switches to the
     * {@link State#UP} state.
     *

     *
     * @return Cluster join order or 0 if node is not joined yet.
     */
    int joinOrder();

    /**
     * Compares this node with the specified one based on {@link #id()} value.
     *
     * @param o Other node.
     *
     * @return Result of {@link #id()} values comparison.
     */
    @Override
    int compareTo(ClusterNode o);
}


text:
package org.terasology.logic.common.lifespan;

import org.terasology.engine.Time;
import org.terasology.entitySystem.entity.EntityManager;
import org.terasology.entitySystem.entity.EntityRef;
import org.terasology.entitySystem.entity.lifecycleEvents.OnAddedComponent;
import org.terasology.entitySystem.event.ReceiveEvent;
import org.terasology.entitySystem.systems.BaseComponentSystem;
import org.terasology.entitySystem.systems.RegisterMode;
import org.terasology.entitySystem.systems.RegisterSystem;
import org.terasology.entitySystem.systems.UpdateSubscriberSystem;
import org.terasology.registry.In;

/**
 */
@RegisterSystem(RegisterMode.AUTHORITY)
public class LifespanSystem extends BaseComponentSystem implements UpdateSubscriberSystem {

    @In
    private EntityManager entityManager;
    @In
    private Time time;

    @Override
    public void update(float delta) {
        long currentTime = time.getGameTimeInMs();
        for (EntityRef entity : entityManager.getEntitiesWith(LifespanComponent.class)) {
            LifespanComponent lifespan = entity.getComponent(LifespanComponent.class);
            if (lifespan.deathTime < currentTime) {
                entity.destroy();
            }
        }
    }

    @ReceiveEvent
    public void addedLifeSpanComponent(OnAddedComponent event, EntityRef entityRef, LifespanComponent lifespanComponent) {
        lifespanComponent.deathTime = time.getGameTimeInMs() + (long) (lifespanComponent.lifespan * 1000);
        entityRef.saveComponent(lifespanComponent);
    }
}


text:
grid.reset(models)

A way to update the data set for the grid in bulk, or to empty the grid.

Parameters

models (array) - (Optional) A list of data objects to set as the new data collection for the grid..

Returns

(object) - A Doby Grid class instance

Example

// Replace the existing data with a new data set
new DobyGrid(...).reset([{...}, {...}]);

// Empty the grid
new DobyGrid(...).reset();

Demo


text:
package uk.ac.ed.learn9.bb.timetabling.dao.impl;

import java.util.List;
import org.springframework.context.annotation.Scope;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import uk.ac.ed.learn9.bb.timetabling.dao.ModuleDao;
import uk.ac.ed.learn9.bb.timetabling.data.Module;

/**
 * Implementation of {@link ModuleDao}
 */
@Transactional
@Scope("singleton")
@Component("moduleDao")
public class ModuleDaoImpl extends HibernateDaoSupport implements ModuleDao {

    @Override
    public Module getById(final String moduleId) {
        return (Module)this.getSession().get(Module.class, moduleId);
    }

    @Override
    public List<Module> getAll() {
        return this.getSession().createQuery("FROM uk.ac.ed.learn9.bb.timetabling.data.Module").list();
    }

}


text:
/* eslint-disable */

import React, {Component, PropTypes} from 'react'
import { StyleSheet, css } from 'aphrodite'
import createArray from '../../tools/helpers'

const Bundesland = (props) => {

    return (

                    {props.name}

                         {props.schoolCount} Schulen

    )
}

const BundeslandList = (props) => {

    const listSizeArray = createArray(0, props.data.length, 1)

    return (

{ listSizeArray.map((index) =>
            <Bundesland
                key={index.toString()}
                index={index}
                url={props.data[index].url}
                name={props.data[index].name}
                schoolCount={props.data[index].schoolCount} >
        </Bundesland>)}

    )
}

const screenSize = {
  small: '@media all and (max-width: 500px)',
  medium: '@media all and (min-width: 500px) and (max-width: 800px)',
  large: '@media all and (min-width: 800px)'
}

const styles = StyleSheet.create({

    list: {
        display: 'flex',
        'flex-direction': 'row',
        'flex-wrap': 'wrap',
        margin: '0',
        padding: '0',
        width: '100%',
        'white-space':'nowrap'
    },

    listItem: {
        border: '10px solid #eee',
        'box-sizing': 'border-box',
        'vertical-align': 'top',
        listStyle: 'none',
        display: 'inline-block',
        height: 'auto',
        backgroundColour:'#fff',
        padding: '10px',
        margin: '0 5px 10px 5px',
        textAlign: 'left',

        ':hover': {
            border: '10px solid #FF751A'
        },

        [screenSize.large]: {
            width: 'calc((100% / 3) - 10px)',
        },
        [screenSize.medium]: {
            width: 'calc((100% / 2) - 10px)',
        },
        [screenSize.small]: {
           width: '100%',
        }
    },

    schoolCount: {
        fontSize: '0.8em',
        color: '#B6B1AF',
        display: 'block',
        margin: '4px 0 0 0'
    },
    url: {
        color: '#666',
        textDecoration: 'none'
    }
})

export default BundeslandList


text:
class CreateQuestionships < ActiveRecord::Migration
  def change
    create_table :questionships do |t|
      t.references :quiz, index: true
      t.references :question, index: true

      t.timestamps null: false
    end
    add_foreign_key :questionships, :quizzes
    add_foreign_key :questionships, :questions
  end
end


text:
namespace Microsoft.DotNet.ProjectModel
{
    public class ProjectReaderSettings
    {
        public string VersionSuffix { get; set; }
        public string AssemblyFileVersion { get; set; }
    }
}


text:
package gcode;

/**
 * Java-GCode - gcode
 * Created by matthew on 20/05/17.
 */
public class InvalidGCodeException extends Exception
{
    public InvalidGCodeException(String s)
    {
        super(s);
    }
}


text:
project_path: /web/_project.yaml
book_path: /web/updates/_book.yaml
description: Local Overrides, accessibility tools, performance and SEO audits, and more.
{% include "web/_shared/machine-translation-start.html" %}

{# wf_updated_on: 2018-03-05 #}
{# wf_published_on: 2018-01-17 #}
{# wf_tags: chrome65,devtools,devtools-whatsnew #}
{# wf_featured_image: /web/updates/images/generic/chrome-devtools.png #}
{# wf_featured_snippet: Local Overrides, accessibility tools, performance and SEO audits, and more. #}
{# wf_blink_components: Platform>DevTools #}

{% include "web/tools/chrome-devtools/_shared/styles.html" %}

# Apa yang Baru Di DevTools (Chrome 65) {: .page-title }

{% include "web/_shared/contributors/kaycebasques.html" %}

Fitur baru yang datang ke DevTools di Chrome 65 meliputi:

* [** Local Overrides **](#overrides)
* [Alat aksesibilitas baru](#a11y)
* [Perubahan ** ** tab](#changes)
* [SEO dan audit kinerja baru](#audits)
* [Rekaman ganda dalam panel ** Performance **](#recordings)
* [Kode yang dapat dipercaya melangkah dengan pekerja dan kode asinkron](#stepping)

Baca terus, atau tonton versi video dari catatan rilis ini, di bawah ini.

Note: Periksa versi Chrome apa yang Anda jalankan di `chrome://version` . Jika Anda menjalankan versi sebelumnya, fitur-fitur ini tidak akan ada. Jika Anda menjalankan versi yang lebih baru, fitur-fitur ini mungkin telah berubah. Pembaruan otomatis Chrome ke versi utama baru setiap 6 minggu.

## Lokal Menggantikan {: #overrides }

** Local Overrides ** memungkinkan Anda membuat perubahan di DevTools, dan menjaga perubahan tersebut di seluruh beban halaman. Sebelumnya, perubahan apa pun yang Anda buat di DevTools akan hilang saat Anda memuat ulang halaman.
** Local Override ** berfungsi untuk sebagian besar jenis file, dengan beberapa pengecualian. Lihat [Keterbatasan](#overrides-limitations).

    Figure 1. Persisting a CSS change across page loads with Local Overrides

</gambar>

Bagaimana itu bekerja:

* Anda menentukan direktori di mana DevTools harus menyimpan perubahan.
* Saat Anda membuat perubahan di DevTools, DevTools menyimpan salinan file yang diubah ke direktori Anda.
* Saat Anda memuat ulang halaman, DevTools melayani file lokal yang dimodifikasi, alih-alih sumber daya jaringan.

Untuk mengatur ** Local Overrides **:

1. Buka panel ** Sources **. 1. Buka tab ** Mengganti **.

         Figure 2. The Overrides tab

1. Klik ** Pengaturan Mengganti **. 1. Pilih direktori mana Anda ingin menyimpan perubahan Anda. 1. Di bagian atas viewport Anda, klik ** Allow ** untuk memberi DevTools akses baca dan tulis ke direktori. 1. Buat perubahan Anda.

### Pembatasan {: #overrides-limitations }

* DevTools tidak menyimpan perubahan yang dibuat di ** DOM Tree ** dari panel ** Elements **. Edit HTML di panel ** Sumber ** sebagai gantinya.
* Jika Anda mengedit CSS di ** Styles ** pane, dan sumber CSS itu adalah file HTML, DevTools tidak akan menyimpan perubahan. Edit file HTML di panel ** Sources **.

### Fitur terkait {: #overrides-related }

* [Ruang Kerja][WS]. DevTools secara otomatis memetakan sumber daya jaringan ke repositori lokal. Setiap kali Anda membuat perubahan di DevTools, perubahan itu juga akan disimpan ke repositori lokal Anda.

[WS]: /web/updates/2017/10/devtools-release-notes#workspaces

## Tab Perubahan {: #changes }

Lacak perubahan yang Anda buat secara lokal di DevTools melalui tab ** Perubahan ** yang baru.

    Figure 3. The Changes tab

</gambar>

## Alat aksesibilitas baru {: #a11y }

Gunakan panel ** Accessibility ** baru untuk memeriksa properti aksesibilitas suatu elemen, dan periksa rasio kontras elemen teks di ** Color Picker ** untuk memastikan bahwa mereka dapat diakses oleh pengguna dengan gangguan penglihatan atau warna rendah -visi kekurangan.

### Panel Aksesibilitas {: #a11y-pane }

Gunakan ** Accessibility ** pane pada panel ** Elements ** untuk menyelidiki properti aksesibilitas dari elemen yang saat ini dipilih.

    Figure 4. The Accessibility pane shows the ARIA attributes
    and computed properties for the element that's currently selected in the DOM Tree on
    the Elements panel, as well as its position in the accessibility tree

</gambar>

Lihat A11ycast Rob Dodson tentang pelabelan di bawah ini untuk melihat panel ** Accessibility ** dalam tindakan.

### Rasio kontras dalam {: #contrast } Color Picker

The [Color Picker][CP] sekarang menunjukkan Anda rasio kontras elemen teks. Meningkatkan rasio kontras elemen teks membuat situs Anda lebih mudah diakses oleh pengguna dengan gangguan penglihatan rendah atau kekurangan penglihatan warna. Lihat [Warna dan kontras][contrast] untuk mempelajari lebih lanjut tentang bagaimana rasio kontras memengaruhi aksesibilitas.

Meningkatkan kontras warna elemen teks Anda membuat situs Anda lebih bermanfaat bagi semua pengguna. Dengan kata lain, jika teks Anda berwarna abu-abu dengan latar belakang putih, sulit bagi siapa pun untuk membaca.

    Figure 5. Inspecting the contrast ratio of the highlighted h1 element

</gambar>

Dalam ** Gambar 5 **, dua tanda centang di samping ** 4,61 ** berarti bahwa elemen ini memenuhi [enhanced recommended contrast ratio (AAA)][enhanced]{:.external}. Jika hanya memiliki satu tanda centang, itu berarti itu memenuhi [rasio kontras yang direkomendasikan minimum (AA)][minimum]{:.external}.

[enhanced]: https://www.w3.org/WAI/WCAG20/quickref/#qr-visual-audio-contrast7
[minimum]: https://www.w3.org/WAI/WCAG20/quickref/#qr-visual-audio-contrast-contrast

Klik ** Tampilkan Lebih Banyak ** ![Tampilkan Lebih Banyak][SM]] {:.cdt-inl} untuk memperluas bagian ** Contrast Ratio **. Garis putih di kotak ** Color Spectrum ** menunjukkan batas antara warna yang memenuhi rasio kontras yang direkomendasikan, dan yang tidak. Misalnya, karena warna abu-abu di
** Gambar 6 ** memenuhi rekomendasi, itu berarti bahwa semua warna di bawah garis putih juga memenuhi rekomendasi.

    Figure 6. The expanded Contrast Ratio section

</gambar>

[CP]: /web/tools/chrome-devtools/css/reference#color-picker
[contrast]: /web/fundamentals/accessibility/accessible-styles#color_and_contrast
[SM]: /web/updates/images/2018/01/show-more.png

#### Fitur terkait {: #contrast-related }

Panel ** Audit ** memiliki audit akses otomatis untuk memastikannya
* setiap elemen * teks pada halaman memiliki rasio kontras yang cukup.

Lihat [Jalankan Lighthouse di Chrome DevTools][audit], atau tonton A11ycast di bawah ini, untuk mempelajari cara menggunakan panel ** Audit ** untuk menguji aksesibilitas.

[audit]: /web/tools/lighthouse/#devtools

## Audit baru {: #audits }

Chrome 65 dikirimkan dengan kategori baru audit SEO, dan banyak audit kinerja baru.

SPCLCLLES0 Panel ** Audit ** didukung oleh [Lighthouse][LH]. Chrome 64 menjalankan Lighthouse versi 2.5. Chrome 65 menjalankan Lighthouse versi 2.8. Jadi bagian ini hanyalah ringkasan pembaruan Lighthouse dari 2.6, 2.7, dan 2.8.

### Audit SEO baru {: #seo }

Memastikan bahwa halaman Anda melewati setiap audit dalam kategori ** SEO ** yang baru dapat membantu meningkatkan peringkat mesin pencari Anda.

    Figure 7. The new SEO category of audits

</gambar>

### Audit kinerja baru {: #performance }

Chrome 65 juga dikirimkan dengan banyak audit kinerja baru:

* Waktu boot-up JavaScript tinggi
* Menggunakan kebijakan cache tidak efisien pada aset statis
* Menghindari pengalihan halaman
* Dokumen menggunakan plugin
* Perkecil CSS
* Meminimalkan JavaScript

 Masalah Perf! Setelah Mynet meningkatkan kecepatan pemuatan halaman mereka sebesar 4X, pengguna menghabiskan 43% lebih banyak waktu di situs, melihat halaman 34% lebih banyak, tingkat bouncing turun 24%, dan pendapatan meningkat 25% per tampilan halaman artikel. Pelajari lebih lanjut .

 Tip! Jika Anda ingin meningkatkan kinerja pemuatan halaman Anda, tetapi tidak tahu harus mulai dari mana, cobalah panel Audit . Anda memberikannya URL, dan itu memberi Anda laporan terperinci tentang berbagai cara Anda dapat meningkatkan halaman itu. Mulai .

### Pembaruan lainnya {: #audits-other }

* [Audit aksesibilitas baru dan manual](/web/updates/2018/01/lighthouse#a11y)
* [Pembaruan pada audit WebP][webp] untuk membuatnya lebih inklusif dari format gambar generasi selanjutnya lainnya
* [Rehaul skor aksesibilitas][a11yscore]
* Jika audit aksesibilitas tidak berlaku untuk suatu halaman, audit itu tidak lagi diperhitungkan terhadap skor aksesibilitas
* Kinerja kini menjadi bagian teratas dalam laporan

[seoaudits]: /web/updates/2018/01/lighthouse#seo
[webp]: /web/updates/2018/01/lighthouse#webp
[a11yscore]: /web/updates/2017/12/lighthouse#a11y
[LH]: /web/tools/lighthouse
[2.6]: /web/updates/2017/12/lighthouse
[2.7]: /web/updates/2018/01/lighthouse

## Kode yang dapat dipercaya melangkah dengan pekerja dan kode asinkron {: #stepping }

Chrome 65 menghadirkan pembaruan ke ** Step Into ** ![Masuk ke][into]] Tombol {:.cdt-inl} saat memasukkan kode yang meneruskan pesan antar utas, dan kode asinkron. Jika Anda menginginkan perilaku loncatan sebelumnya, Anda dapat menggunakan tombol ** Langkah ** ![Langkah][step]] {:.cdt-inl} yang baru.

[into]: /web/tools/chrome-devtools/javascript/imgs/step-into.png
[step]: /web/tools/chrome-devtools/javascript/imgs/step.png

### Masuk ke kode yang melewatkan pesan antar utas {: #workers }

Ketika Anda masuk ke kode yang mengirimkan pesan antar utas, DevTools sekarang menunjukkan apa yang terjadi di setiap utas.

Misalnya, aplikasi dalam ** Gambar 8 ** meneruskan pesan antara utas utama dan utas pekerja. Setelah melangkah ke panggilan `postMessage()` pada utas utama, DevTools berhenti di handler `onmessage` di thread pekerja. Handler `onmessage` itu sendiri mengirim pesan kembali ke utas utama. Masuk ke * bahwa * panggilan berhenti DevTools kembali di utas utama.

    Figure 8. Stepping into message-passing code in Chrome 65

</gambar>

Ketika Anda masuk ke kode seperti ini di versi Chrome sebelumnya, Chrome hanya menunjukkan Anda sisi utas-utama dari kode, seperti yang Anda lihat di ** Gambar 9 **.

    Figure 9. Stepping into message-passing code in Chrome 63

</gambar>

### Masuk ke kode asinkron {: #async }

Ketika melangkah ke kode asynchronous, DevTools sekarang mengasumsikan bahwa Anda ingin berhenti di kode asynchronous yang akhirnya berjalan.

Sebagai contoh, di ** Gambar 10 ** setelah melangkah ke `setTimeout()` , DevTools menjalankan semua kode yang mengarah ke titik di belakang layar, dan kemudian berhenti di fungsi yang diteruskan ke `setTimeout()` .

    Figure 10. Stepping into asynchronous code in Chrome 65

</gambar>

Ketika Anda masuk ke kode seperti ini di Chrome 63, DevTools berhenti dalam kode karena secara kronologis berjalan, seperti yang Anda lihat di ** Gambar 11 **.

    Figure 11. Stepping into asynchronous code in Chrome 63

</gambar>

## Beberapa rekaman dalam panel Kinerja {: #recordings }

Panel ** Performance ** sekarang memungkinkan Anda menyimpan hingga 5 rekaman secara sementara. Rekaman akan dihapus ketika Anda menutup jendela DevTools Anda. Lihat [Memulai dengan Menganalisis Kinerja Runtime][runtime] untuk merasa nyaman dengan panel ** Performance **.

[runtime]: /web/tools/chrome-devtools/evaluate-performance/

    Figure 12. Selecting between multiple recordings in the Performance panel

</gambar>

## Bonus: Mengotomatiskan aksi DevTools dengan Puppeteer 1.0 {: #puppeteer }

Note: Bagian ini tidak terkait dengan Chrome 65.

Versi 1.0 dari Puppeteer, alat otomatisasi browser yang dikelola oleh tim Chrome DevTools, sekarang keluar. Anda dapat menggunakan Puppeteer untuk mengotomatiskan banyak tugas yang sebelumnya hanya tersedia melalui DevTools, seperti menangkap tangkapan layar:

    const puppeteer = require('puppeteer');
    (async () => {
      const browser = await puppeteer.launch();
      const page = await browser.newPage();
      await page.goto('https://example.com');
      await page.screenshot({path: 'example.png'});
      await browser.close();
    })();

Ini juga memiliki API untuk banyak tugas otomatisasi yang umumnya berguna, seperti menghasilkan PDF:

    const puppeteer = require('puppeteer');
    (async () => {
      const browser = await puppeteer.launch();
      const page = await browser.newPage();
      await page.goto('https://news.ycombinator.com', {waitUntil: 'networkidle2'});
      await page.pdf({path: 'hn.pdf', format: 'A4'});
      await browser.close();
    })();

Lihat [Mulai Cepat][quickstart] untuk mempelajari lebih lanjut.

[quickstart]: /web/tools/puppeteer/get-started

Anda juga dapat menggunakan Puppeteer untuk mengekspos fitur DevTools saat menjelajah tanpa pernah secara eksplisit membuka DevTools. Lihat [Menggunakan Fitur DevTools Tanpa Membuka DevTools][without] sebagai contoh.

[without]: /web/updates/2018/01/devtools-without-devtools

## Permintaan dari tim DevTools: pertimbangkan Canary {: #canary }

Jika Anda menggunakan Mac atau Windows, pertimbangkan untuk menggunakan [Chrome Canary][canary] sebagai browser pengembangan default Anda. Jika Anda melaporkan bug atau perubahan yang tidak Anda sukai saat masih ada di Canary, tim DevTools dapat menanggapi umpan balik Anda secara signifikan lebih cepat.

Note: Canary adalah versi Chrome yang mengandung pendarahan. Ini dirilis segera setelah dibangun, tanpa pengujian. Ini berarti bahwa Canary istirahat dari waktu ke waktu, sekitar sebulan sekali, dan biasanya tetap dalam satu hari. Anda dapat kembali menggunakan Chrome Stable saat Canary putus.

[canary]: https://www.google.com/chrome/browser/canary.html

## Masukan {: #feedback }

Tempat terbaik untuk mendiskusikan salah satu fitur atau perubahan yang Anda lihat di sini adalah milis [google-chrome-developer-tools@googlegroups.com][ML]. Anda juga dapat mentweet kami di [@ChromeDevTools](https://twitter.com/chromedevtools) jika Anda kekurangan waktu. Jika Anda yakin telah menemukan bug di DevTools, silakan [buka masalah](https://crbug.com/new).

[ML]: https://groups.google.com/forum/#!forum/google-chrome-developer-tools

## Catatan rilis sebelumnya {: #links }

Lihat tag [devtools-whatsnew][tag] untuk tautan ke semua catatan rilis DevTools sebelumnya.

[tag]: /web/updates/tags/devtools-whatsnew

{% include "web/_shared/rss-widget-updates.html" %}

{% include "web/_shared/translation-end.html" %}


text:
import supriya

def test_01():

    with supriya.SynthDefBuilder(out=0, value=0.5) as builder:
        supriya.ugens.Out.ar(
            bus=builder["out"], source=supriya.ugens.DC.ar(source=builder["value"])
        )
    synthdef_A = builder.build(name="synthdef_A")

    with supriya.SynthDefBuilder(out=0, value=-0.3) as builder:
        supriya.ugens.Out.ar(
            bus=builder["out"], source=supriya.ugens.DC.ar(source=builder["value"])
        )
    synthdef_B = builder.build(name="synthdef_B")

    request = supriya.commands.SynthDefReceiveRequest(
        synthdefs=[synthdef_A],
        callback=supriya.commands.RequestBundle(
            contents=[
                supriya.commands.GroupNewRequest(
                    items=[
                        supriya.commands.GroupNewRequest.Item(
                            node_id=1000, target_node_id=1
                        )
                    ]
                ),
                supriya.commands.SynthNewRequest(
                    node_id=1001, synthdef=synthdef_A, target_node_id=1000
                ),
                supriya.commands.SynthDefReceiveRequest(
                    synthdefs=[synthdef_B],
                    callback=supriya.commands.RequestBundle(
                        contents=[
                            supriya.commands.SynthNewRequest(
                                add_action=supriya.AddAction.ADD_BEFORE,
                                node_id=1002,
                                synthdef=synthdef_B,
                                target_node_id=1001,
                            ),
                            supriya.commands.NodeRunRequest(
                                node_id_run_flag_pairs=[(1002, False)]
                            ),
                        ]
                    ),
                ),
            ]
        ),
    )

    assert list(request._linearize()) == [
        supriya.commands.SynthDefReceiveRequest(synthdefs=(synthdef_A,)),
        supriya.commands.GroupNewRequest(
            items=[
                supriya.commands.GroupNewRequest.Item(
                    add_action=supriya.AddAction.ADD_TO_HEAD,
                    node_id=1000,
                    target_node_id=1,
                )
            ]
        ),
        supriya.commands.SynthNewRequest(
            add_action=supriya.AddAction.ADD_TO_HEAD,
            node_id=1001,
            synthdef=synthdef_A,
            target_node_id=1000,
        ),
        supriya.commands.SynthDefReceiveRequest(synthdefs=(synthdef_B,)),
        supriya.commands.SynthNewRequest(
            add_action=supriya.AddAction.ADD_BEFORE,
            node_id=1002,
            synthdef=synthdef_B,
            target_node_id=1001,
        ),
        supriya.commands.NodeRunRequest(node_id_run_flag_pairs=((1002, False),)),
    ]


text:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Serialization;
using WebApiProxy.Core.Models;

namespace WebApiProxy.Tasks.Models
{
    [XmlRoot("proxy")]
    public class Configuration
    {
        public const string ConfigFileName = "WebApiProxy.config";
        public const string CacheFile = "WebApiProxy.generated.cache";

        private string _clientSuffix = "Client";
        private string _name = "MyWebApiProxy";
        private bool _generateOnBuild = false;
        private string _namespace = "WebApi.Proxies";

        [XmlAttribute("generateOnBuild")]
        public bool GenerateOnBuild
        {
            get
            {
                return this._generateOnBuild;
            }
            set
            {
                this._generateOnBuild = value;
            }
        }

        [XmlAttribute("clientSuffix")]
        public string ClientSuffix
        {
            get
            {
                return _clientSuffix.DefaultIfEmpty("Client");
            }
            set
            {
                _clientSuffix = value;
            }
        }

        [XmlAttribute("namespace")]
        public string Namespace
        {
            get
            {
                return this._namespace;
            }
            set
            {
                this._namespace = value;
            }
        }

        [XmlAttribute("name")]
        public string Name
        {
            get
            {
                return this._name;
            }
            set
            {
                this._name = value;
            }
        }

        [XmlAttribute("endpoint")]
        public string Endpoint { get; set; }

        [XmlIgnore]
        public Metadata Metadata { get; set; }

        public static Configuration Load(string root)
        {
            var fileName = root + Configuration.ConfigFileName;

            if (!File.Exists(fileName))
                throw new ConfigFileNotFoundException(fileName);

            var xml = File.ReadAllText(fileName);
            var serializer = new XmlSerializer(typeof(Configuration), new XmlRootAttribute("proxy"));
            var reader = new StreamReader(fileName);
            var config = (Configuration)serializer.Deserialize(reader);
            reader.Close();
            return config;

        }

    }

}


text:
import React, { PropTypes } from 'react';
import { Column } from 'react-foundation';
import { GoMilestone } from 'react-icons/lib/go';
import Divider from '../../Divider/Divider';

const ProjectMilestones = ({
  project
}) => (
  <Column className="milestones-section" small={12} large={8} isColumn centerOnSmall>

      <GoMilestone />
        {' Milestones '}
      <GoMilestone />

    <Divider />

        {project.milestones.map((milestone, i) =>

              {milestone}

)
        }

  </Column>
);

ProjectMilestones.propTypes = {
  project: PropTypes.object.isRequired
};

export default ProjectMilestones;


text:
var _ = require('lodash'),
    gql = require('ghost-gql'),
    common = require('../../lib/common'),
    filter,
    filterUtils;

filterUtils = {
    /**
     * ## Combine Filters
     * Util to combine the enforced, default and custom filters such that they behave accordingly
     * @param {String|Object} enforced - filters which must ALWAYS be applied
     * @param {String|Object} defaults - filters which must be applied if a matching filter isn't provided
     * @param {...String|Object} [custom] - custom filters which are additional
     * @returns {*}
     */
    combineFilters: function combineFilters(enforced, defaults, custom /* ...custom */) {
        custom = Array.prototype.slice.call(arguments, 2);

        // Ensure everything has been run through the gql parser
        try {
            enforced = enforced ? (_.isString(enforced) ? gql.parse(enforced) : enforced) : null;
            defaults = defaults ? (_.isString(defaults) ? gql.parse(defaults) : defaults) : null;
            custom = _.map(custom, function (arg) {
                return _.isString(arg) ? gql.parse(arg) : arg;
            });
        } catch (err) {
            throw new common.errors.ValidationError({
                err: err,
                property: 'filter',
                context: common.i18n.t('errors.models.plugins.filter.errorParsing'),
                help: common.i18n.t('errors.models.plugins.filter.forInformationRead', {url: 'https://api.ghost.org/v1.22.0/docs/filter'})
            });
        }

        // Merge custom filter options into a single set of statements
        custom = gql.json.mergeStatements.apply(this, custom);

        // if there is no enforced or default statements, return just the custom statements;
        if (!enforced && !defaults) {
            return custom;
        }

        // Reduce custom filters based on enforced filters
        if (custom && !_.isEmpty(custom.statements) && enforced && !_.isEmpty(enforced.statements)) {
            custom.statements = gql.json.rejectStatements(custom.statements, function (customStatement) {
                return gql.json.findStatement(enforced.statements, customStatement, 'prop');
            });
        }

        // Reduce default filters based on custom filters
        if (defaults && !_.isEmpty(defaults.statements) && custom && !_.isEmpty(custom.statements)) {
            defaults.statements = gql.json.rejectStatements(defaults.statements, function (defaultStatement) {
                return gql.json.findStatement(custom.statements, defaultStatement, 'prop');
            });
        }

        // Merge enforced and defaults
        enforced = gql.json.mergeStatements(enforced, defaults);

        if (_.isEmpty(custom.statements)) {
            return enforced;
        }

        if (_.isEmpty(enforced.statements)) {
            return custom;
        }

        return {
            statements: [
                {group: enforced.statements},
                {group: custom.statements, func: 'and'}
            ]
        };
    }
};

filter = function filter(Bookshelf) {
    var Model = Bookshelf.Model.extend({
        // Cached copy of the filters setup for this model instance
        _filters: null,
        // Override these on the various models
        enforcedFilters: function enforcedFilters() {
        },
        defaultFilters: function defaultFilters() {
        },

        preProcessFilters: function preProcessFilters() {
            this._filters.statements = gql.json.replaceStatements(this._filters.statements, {prop: /primary_tag/}, function (statement) {
                statement.prop = 'tags.slug';
                return {
                    group: [
                        statement,
                        {prop: 'posts_tags.sort_order', op: '=', value: 0},
                        {prop: 'tags.visibility', op: '=', value: 'public'}
                    ]
                };
            });

            this._filters.statements = gql.json.replaceStatements(this._filters.statements, {prop: /primary_author/}, function (statement) {
                statement.prop = 'authors.slug';
                return {
                    group: [
                        statement,
                        {prop: 'posts_authors.sort_order', op: '=', value: 0},
                        {prop: 'authors.visibility', op: '=', value: 'public'}
                    ]
                };
            });
        },

        /**
         * ## Post process Filters
         * Post Process filters looking for joins etc
         * @TODO refactor this
         * @param {object} options
         */
        postProcessFilters: function postProcessFilters(options) {
            var joinTables = this._filters.joins;

            if (joinTables && joinTables.indexOf('tags') > -1) {
                // We need to use leftOuterJoin to insure we still include posts which don't have tags in the result
                // The where clause should restrict which items are returned
                this
                    .query('leftOuterJoin', 'posts_tags', 'posts_tags.post_id', '=', 'posts.id')
                    .query('leftOuterJoin', 'tags', 'posts_tags.tag_id', '=', 'tags.id');

                // The order override should ONLY happen if we are doing an "IN" query
                // TODO move the order handling to the query building that is currently inside pagination
                // TODO make the order handling in pagination handle orderByRaw
                // TODO extend this handling to all joins
                if (gql.json.findStatement(this._filters.statements, {prop: /^tags/, op: 'IN'})) {
                    // TODO make this count the number of MATCHING tags, not just the number of tags
                    this.query('orderByRaw', 'count(tags.id) DESC');
                }

                // We need to add a group by to counter the double left outer join
                // TODO improve on the group by handling
                options.groups = options.groups || [];
                options.groups.push('posts.id');
            }

            if (joinTables && joinTables.indexOf('authors') > -1) {
                // We need to use leftOuterJoin to insure we still include posts which don't have tags in the result
                // The where clause should restrict which items are returned
                this
                    .query('leftOuterJoin', 'posts_authors', 'posts_authors.post_id', '=', 'posts.id')
                    .query('leftOuterJoin', 'users as authors', 'posts_authors.author_id', '=', 'authors.id');

                // The order override should ONLY happen if we are doing an "IN" query
                // TODO move the order handling to the query building that is currently inside pagination
                // TODO make the order handling in pagination handle orderByRaw
                // TODO extend this handling to all joins
                if (gql.json.findStatement(this._filters.statements, {prop: /^authors/, op: 'IN'})) {
                    // TODO make this count the number of MATCHING authors, not just the number of authors
                    this.query('orderByRaw', 'count(authors.id) DESC');
                }

                // We need to add a group by to counter the double left outer join
                // TODO improve on the group by handling
                options.groups = options.groups || [];
                options.groups.push('posts.id');
            }

            /**
             * @deprecated: `author`, will be removed in Ghost 2.0
             */
            if (joinTables && joinTables.indexOf('author') > -1) {
                this
                    .query('join', 'users as author', 'author.id', '=', 'posts.author_id');
            }
        },

        /**
         * ## fetchAndCombineFilters
         * Helper method, uses the combineFilters util to apply filters to the current model instance
         * based on options and the set enforced/default filters for this resource
         * @param {Object} options
         * @returns {Bookshelf.Model}
         */
        fetchAndCombineFilters: function fetchAndCombineFilters(options) {
            options = options || {};

            this._filters = filterUtils.combineFilters(
                this.enforcedFilters(options),
                this.defaultFilters(options),
                options.filter,
                options.where
            );

            return this;
        },

        /**
         * ## Apply Filters
         * Method which makes the necessary query builder calls (through knex) for the filters set
         * on this model instance
         * @param {Object} options
         * @returns {Bookshelf.Model}
         */
        applyDefaultAndCustomFilters: function applyDefaultAndCustomFilters(options) {
            var self = this;

            // @TODO figure out a better place/way to trigger loading filters
            if (!this._filters) {
                this.fetchAndCombineFilters(options);
            }

            if (this._filters) {
                if (this.debug) {
                    gql.json.printStatements(this._filters.statements);
                }

                this.preProcessFilters(options);

                this.query(function (qb) {
                    gql.knexify(qb, self._filters);
                });

                // Replaces processGQLResult
                this.postProcessFilters(options);
            }

            return this;
        }
    });

    Bookshelf.Model = Model;
};

/**
 * ## Export Filter plugin
 * @api public
 */
module.exports = filter;


text:
'use strict';

import { EggAppConfig, PowerPartial } from 'egg';

// 提供给 config.{env}.ts 使用
export type DefaultConfig = PowerPartial<EggAppConfig & BizConfig>;

// 应用本身的配置 Scheme
export interface BizConfig {
  news: {
    pageSize: number;
    serverUrl: string;
  };
}

export default () => {
  const config = {} as PowerPartial<EggAppConfig> & BizConfig;

  config.logger = {
    consoleLevel: 'WARN',
    buffer: false,
  };
  return config;
};


text:
@implementation NSArray (OTForgivingFoundation)

+ (void)load
{
    [self jr_swizzleClassMethod:@selector(arrayWithObjects:count:) withClassMethod:@selector(OTForgivingFoundation_arrayWithObjects:count:) error:NULL];
}

+ (instancetype)OTForgivingFoundation_arrayWithObjects:(const id [])objects count:(NSUInteger)cnt
{
    id nonNilObjects[cnt];

    NSUInteger nonNilCount = 0;
    NSUInteger idx = 0;
    while (idx != cnt) {
        id obj = objects[idx++];
        if (obj) {
            nonNilObjects[nonNilCount++] = obj;
        }
    }

    return [self OTForgivingFoundation_arrayWithObjects:nonNilObjects count:nonNilCount];
}

@end


text:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>cloud.dag.test.arimul</groupId>
        <artifactId>arimul-versions</artifactId>
        <version>0.2.0-SNAPSHOT</version>
        <relativePath>../arimul-versions</relativePath>
    </parent>

    <artifactId>arimul-web</artifactId>
    <version>0.4.0-SNAPSHOT</version>

    <packaging>war</packaging>

    <properties>
        <arimul-versions.version>0.2.0-SNAPSHOT</arimul-versions.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>cloud.dag.test.arimul</groupId>
            <artifactId>arimul-core-utils</artifactId>
            <version>0.3.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>cloud.dag.test.arimul</groupId>
            <artifactId>arimul-parallel</artifactId>
            <version>0.5.0-SNAPSHOT</version>
            <type>pom</type>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>deploy</id>
            <properties>
                <shakuntala.skip>true</shakuntala.skip>
            </properties>
            <build>
                <finalName>ROOT</finalName>
                <plugins>
                    <plugin>
                        <groupId>com.sap.cloud</groupId>
                        <artifactId>neo-java-web-maven-plugin</artifactId>
                        <configuration>
                            <!-- Configure proxy -->
                            <consoleHttpProxyHost>proxy</consoleHttpProxyHost>
                            <consoleHttpProxyPort>8080</consoleHttpProxyPort>
                            <consoleHttpsProxyHost>proxy</consoleHttpsProxyHost>
                            <consoleHttpsProxyPort>8080</consoleHttpsProxyPort>
                        </configuration>
                        <executions>
                            <execution>
                                <id>initialize</id>
                                <phase>initialize</phase>
                                <goals>
                                    <goal>install-sdk</goal>
                                </goals>
                                <configuration>
                                    <sdkInstallPath>${project.build.directory}/sdk</sdkInstallPath>
                                </configuration>
                            </execution>
                            <execution>
                                <id>deploy</id>
                                <phase>install</phase>
                                <goals>
                                    <goal>stop</goal>
                                    <goal>deploy</goal>
                                    <goal>start</goal>
                                </goals>
                                <configuration>
                                    <sdkInstallPath>${project.build.directory}/sdk</sdkInstallPath>
                                    <host>hanatrial.ondemand.com</host>
                                    <user>P${HCP_NUMBER}</user>
                                    <password>${HCP_PASSWORD}</password>
                                    <account>p${HCP_NUMBER}trial</account>
                                    <application>arimul</application>
                                    <source>${project.build.directory}/ROOT.war</source>
                                    <synchronous>true</synchronous>
                                    <uriEncoding>UTF-8</uriEncoding>
                                    <compression>on</compression>
                                    <compressibleMimeType>text/html,text/css,text/xml,text/plain,text/javascript,application/javascript,application/json</compressibleMimeType>
                                    <maximumProcesses>2</maximumProcesses>
                                    <javaVersion>8</javaVersion>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>


text:
---
title: CSS3 Nth Child Selector
---
## CSS3 Nth Child Selector

The `nth-child` selector is a css psuedo-class taking a pattern by which to match one or more elements relative to their position amongst siblings.

## Syntax

```css
  a:nth-child(pattern) {
    /* Css goes here */
  }
```

### Pattern

The patterns accepted by `nth-child` can come in the form of keywords or an equation of the form An+B.

#### Keywords

##### Odd

Odd returns all odd elements of a given type.

```css
  a:nth-childe(odd) {
    /* CSS goes here */
  }
```

##### Even

Even returns all even elements of a given type.

```css
  a:nth-childe(even) {
    /* CSS goes here */
  }
```

#### An+B

Returns all elements matching the equation An+B for every positive integer value of n (in addition to 0).

For example, the following will match every 3rd anchor element:
```css
  a:nth-childe(3n) {
    /* CSS goes here */
  }
```

### More Information:

MDN Documentation
CSS Tricks - nth child selector
CSS Tricks - nth child tester
W3Scools - nth child selector