text 更新iserp生成器包

.txt
vagrant@generator01d:/opt/projects/iserps-generator/current$ composer dump-autoload

text Generar crear小部件

generar crear widgets
<?php 

add_action( 'widgets_init', function(){
    register_widget( 'Nombre_De_Clase_ID_Class' );
});

class Nombre_De_Clase_ID_Class extends WP_Widget {

    #Sets up the widgets name etc

    public function __construct() {
        $widget_ops = array(
            'classname' => 'Nombre_De_Clase_ID_Class',
            'description' => 'description',
        );
        parent::__construct( 'Nombre_De_Clase_ID_Class', 'nombre', $widget_ops );
    }


    # Display frontend

    public function widget( $argus, $instance ) {
 
        echo $argus['before_widget'];
        if ( ! empty( $instance['title'] ) ) {
            echo $argus['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $argus['after_title'];
        } ?>

		<!-- Añadir contenido -->
        
        <?php echo $argus['after_widget'];
    }


    #Parameters Form of Widget
    public function form( $instance ) {
        $title = ! empty( $instance['title'] ) ? $instance['title'] : __( '', 'text_domain' );
        ?>
            <p>
            <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
            <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
            </p>
        <?php
    }


    #Save Data
    public function update( $new_instance, $old_instance ) {
        // processes widget options to be saved
        foreach( $new_instance as $key => $value )
        {
            $updated_instance[$key] = sanitize_text_field($value);
        }

        return $updated_instance;
    }
}

text 使用C#等待async而不是Unity coroutine

using C await async instead of Unity coroutine
    async Task GetName()
    {
        // Delay 方法来自于.net 4.5
        await Task.Delay(1000);  // 返回值前面加 async 之后,方法里面就可以用await了
        Debug.Log("Current Thread Id :"+ Thread.CurrentThread.ManagedThreadId);
        Debug.Log("In antoher thread.....");
    }
    
    private async void Update()
    {
        if(Input.GetKeyUp(KeyCode.A))
        {
            Debug.Log($"main thread id:{Thread.CurrentThread.ManagedThreadId}");
            await GetName();
//             new Thread(Go).Start();  // .NET 1.0开始就有的
//             Task.Factory.StartNew(Go); // .NET 4.0 引入了 TPL
             await Task.Run(Go);
                                       //             Debug.Log("111 balabala. My Thread ID is :" + Thread.CurrentThread.ManagedThreadId);
                                       //             AsyncMethod();
                                       //             
                                       //             Debug.Log("222 balabala. My Thread ID is :" + Thread.CurrentThread.ManagedThreadId);
        }
        //Debug.Log(Time.realtimeSinceStartup);
    }

text 计数小号字符串中有多少牛逼子序列

输入:S =“babgbag”,T =“bag”<br/>输出:5

dfs-bfs
static int num = 0 ;
public static boolean isSubseq(String t,String s) {
		//判断t是否是s的子序列
		if(t==null) return true;
		if(t.length()==1 && s.contains(t)) return true;
		Map<Character,List> map = new HashMap<>();
		for(int i = 0 ; i < s.length(); i++) {
			if(map.get(s.charAt(i))==null)
				map.put(s.charAt(i), new ArrayList<Integer>());
			map.get(s.charAt(i)).add(i);
		}
		boolean res = isSubseqRecurse(t,s,map,0,-1);
		return res;
	}
	public static boolean isSubseqRecurse(String t,String s,Map<Character,List> map,int cur_pos,int last_pos) {
		if(cur_pos==t.length()){
		  num++;return true;
		}
		List<Integer> list = map.get(t.charAt(cur_pos));
		if(list==null) return false;
		boolean flag = false;
		for(int i = 0 ;  i < list.size(); i++) {
			int cur = list.get(i);
			if(cur<=last_pos) continue;
			else flag |= isSubseqRecurse(t,s,map,cur_pos+1,cur);
		}
		return flag;
	}
dp
看到有关字符串的子序列或者配准类的问题,首先应该考虑的就是用动态规划 Dynamic Programming 来求解,这个应成为条件反射。而所有 DP 问题的核心就是找出状态转移方程,想这道题就是递推一个二维的 dp 数组,其中 dp[i][j] 表示s中范围是 [0, i] 的子串中能组成t中范围是 [0, j] 的子串的子序列的个数。下面我们从题目中给的例子来分析,这个二维 dp 数组应为:
  Ø r a b b b i t
Ø 1 1 1 1 1 1 1 1
r 0 1 1 1 1 1 1 1
a 0 0 1 1 1 1 1 1
b 0 0 0 1 2 3 3 3
b 0 0 0 0 1 3 3 3
i 0 0 0 0 0 0 3 3
t 0 0 0 0 0 0 0 3
首先,若原字符串和子序列都为空时,返回1,因为空串也是空串的一个子序列。若原字符串不为空,而子序列为空,也返回1,因为空串也是任意字符串的一个子序列。而当原字符串为空,子序列不为空时,返回0,因为非空字符串不能当空字符串的子序列。理清这些,二维数组 dp 的边缘便可以初始化了,下面只要找出状态转移方程,就可以更新整个 dp 数组了。我们通过观察上面的二维数组可以发现,当更新到 dp[i][j] 时,dp[i][j] >= dp[i][j - 1] 总是成立,再进一步观察发现,当 T[i - 1] == S[j - 1] 时,dp[i][j] = dp[i][j - 1] + dp[i - 1][j - 1],若不等, dp[i][j] = dp[i][j - 1],所以,综合以上,递推式为:
dp[i][j] = dp[i][j - 1] + (T[i - 1] == S[j - 1] ? dp[i - 1][j - 1] : 0)

text 桌面入口

postman
[Desktop Entry]
Name=Postman
Type=Application
Exec=/home/vitaliy/soft/Postman/app/Postman
Terminal=false
Icon=/home/vitaliy/soft/Postman/app/resources/app/assets/icon.png
NoDisplay=false
Name[en]=Postman

text test_on_air_report_script

toar_script

BEGIN
INSERT INTO FlatTableOnAirTracker

SELECT 
R.WF_ID
,M.WF_MILESTONE_ID
,(CASE WHEN r.PARENT_WF_ID IS NOT NULL THEN (SELECT WF_NUMBER FROM dbo.WORKFLOW_RECORD WHERE dbo.WORKFLOW_RECORD.WF_ID=r.PARENT_WF_ID) 
ELSE r.WF_NUMBER END)AS [WorkflowRecord], 
LM.SiteCode, 
LM.SiteName, 
R.ProjectName, 
LM.SiteAddress, 
P.PROJECT_NAME AS WRType,
LP.Band, 
R.PONo, 
M.MILESTONE_NAME AS MilestoneName, 
UM.USERFULLNAME AS MilestoneUser, 
m.MILESTONE_E_DATE, 
COALESCE(RV.resevationNumber,ER.ReservationNumber, RM.ReservationMuxNumber) AS ReservationNumber
FROM 
WF_PROJECT_DEFINITION P 
INNER JOIN WORKFLOW_RECORD R ON P.PROJECT_ID=R.PROJECT_ID 
INNER JOIN WORKFLOW_MILESTONE M ON R.WF_ID=M.WF_ID
AND R.PROJECT_ID NOT IN (7)
AND R.WF_STATUS <>'Rejected' 
AND M.MILESTONE_STATUS='DONE'
AND M.MILESTONE_ROLE_ID IN (9,47,12) 
AND M.MILESTONE_PROJECT_REL_ID IN (	
,40 -- On air - 1--BTS GSM 900 Own Build
,67 -- On air - 2--BTS GSM 1800
,126 -- On air - 3--BTS GSM 900 Sharing
,168 -- On air - 4--3G Rollout
,584 -- On Air - 5--MW Link Installation & Commissioning PDH
,605 -- On Air - 6--MW Link Installation & Commissioning SDH
,248 -- On air - 8--BTS and NodeB Relocation
,381 -- On Air_RO - 9--GSM/WCDMA/LTE Optimization
,388 -- On Air_ANR - 9--GSM/WCDMA/LTE Optimization
,287 -- On air - 10--4th Cell Addition
,328 -- On air - 11--BTS and NodeB Relocation Sharing
,341 -- On Air - 12--TRX Relocation RO
,353 -- On Air - 13--TRX Relocation ANR
,371 -- On Air - 14--Hardware Addition ANR
,362 -- On Air - 15--Hardware Addition RO
,398 -- On Air - 16--Hardware Deletion ANR
,407 -- On Air - 17--Hardware Deletion RO
,466 -- On air - 20--New BSC
,492 -- On Air - 21--MW Link Swap
,527 -- On air - 22--Cabinet Relocation
,637 -- On air - 24--2G3G4G Cell Addition
,655 -- INP Check & On Air - 26--GB Expansion
,724 -- Swap Completed, Call Test & On Air - 28--BTS Swap
,862 -- On air - 33--IBS
,898 -- On air - 34--Repeater
,917 -- On air - 35--PSY Upgradation
,981 -- On air - 37--Event Management
,1027 -- On air - 38--3G New Site (Own Build)
,1071 -- Swap Completed, Call Test & On Air - 40--3G Swap
,1115 -- On air - 41--4G Rollout
,1146 -- On air - 42--U900
,1189 -- On air - 43--3G New Site (Sharing)
,1243 -- On air - 44--Small Cell (Own Build)
,1287 -- On air - 46--Small Cell (Sharing)
)

INNER JOIN LocationSelection S ON R.WF_ID = S.WFId_ProjectRequestId AND S.IsSource=0 
LEFT JOIN LocationMaster LM ON LM.LocationMasterId=S.LocationMasterId AND (LM.IsDismantled IS NULL OR LM.IsDismantled=0) 
----LEFT JOIN LocationMaster LM ON LM.SiteCode=RIGHT(R.SiteCode,7)
LEFT JOIN LocationProject LP ON LP.LocationProjectId=S.LocationProjectId AND LP.ProjectStatus<>'REJECTED'
LEFT JOIN USER_MASTER UM ON UM.EMPLID=M.LAST_MODIFIED_USER 
LEFT JOIN Reservation RV ON RV.WFId_ProjectRequestId=R.WF_ID 
LEFT JOIN EquipmentReceiveReservation ER ON ER.WF_ID=R.WF_ID
LEFT JOIN ReservationMux RM ON RM.WFId_ProjectRequestId=R.WF_ID
LEFT JOIN FlatTableOnAirTracker FONAIR ON FONAIR.WF_ID=R.WF_ID

WHERE FONAIR.WF_ID IS NULL
END

End

text 项目脚本

project_script


select R.PROJECT_ID,P.PROJECT_NAME,R.MILESTONE_PROJECT_REL_ID,R.MILESTONE_NAME
,','+CAST(R.MILESTONE_PROJECT_REL_ID AS VARCHAR)+' -- ' +R.MILESTONE_NAME+' - '+CAST(R.PROJECT_ID AS VARCHAR)+'--'+P.PROJECT_NAME
from wf_milestone_project_rel R
INNER JOIN WF_PROJECT_DEFINITION P ON R.PROJECT_ID=P.PROJECT_ID
WHERE MILESTONE_NAME LIKE '%ON AIR%'
AND MILESTONE_NAME NOT LIKE '%Test on Air%'
ORDER BY PROJECT_ID ASC

text android7.0及以上TelephonyManager.getDeviceId()返回空值解决方案

android7.0TelephonyManager.getDeviceIdnull
android7.0及以上TelephonyManager.getDeviceId()返回null解决方案
2018.04.26 13:48:22
字数39
阅读3075
在android7.0及以上的系统下发现TelephonyManager.getDeviceId()在权限允许的情况下取得返回值也为null,解决方法如下:

    /**
     * 获取设备的id
     * @return
     */
    private String getDeviceId(){
        TelephonyManager  telephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
        String deviceId = telephonyManager.getDeviceId();
        if (deviceId==null){
            //android.provider.Settings;
            deviceId= Settings.Secure.getString(getApplicationContext().getContentResolver(), Settings.Secure.ANDROID_ID);
        }
        return deviceId;
    }

text grep linux

grep.sh
# will check which string in file2 was not found on file1
# note: if file1 contains a string that is not found on file2, nothing will be shown on scree
grep -vFxf file1 file2

# output
# danny
file1
yaniv
yaron
alon
file2
alon
yaniv
yaron
danny

text 办公室DNS

dd
10.1.0.252