Skip to content

Instantly share code, notes, and snippets.

View zhaofeng-shu33's full-sized avatar
🎯
Focusing

赵丰 (Zhao Feng) zhaofeng-shu33

🎯
Focusing
  • Institute of Telecommunication and Navigation Satellite
  • Chinese Academy of Space Technology, Beijing, PR China
View GitHub Profile
#!/bin/bash
#Ubuntu 16.04, user root
add-apt-repository ppa:zhaofeng-shu33/gtest
apt update
apt install libgtest-dev
cat <<EOF >> gtest_example.cpp
#include <gtest/gtest.h>
TEST(MATH, ADD){
EXPECT_EQ(1 + 3, 4);
@zhaofeng-shu33
zhaofeng-shu33 / cpu_limit.sh
Last active October 19, 2019 17:30
cpu limit cron job shell script
#!/bin/bash
# get the top 5 processes
result=1490.0
mapfile -t proc_list < <(ps --no-headers --sort=-pcpu -Ao pid,pcpu | head -n 5)
for i in "${proc_list[@]}"; do
process_cpu_list=($i)
process_id=${process_cpu_list[0]}
cpu_usage_percentage=${process_cpu_list[1]}
compare_result=$(awk 'BEGIN{ print '$cpu_usage_percentage'<'$result' }')
if [ ! "$compare_result" -eq 1 ]; then
@zhaofeng-shu33
zhaofeng-shu33 / update_code.php
Created September 2, 2019 02:21
git webhook pull code
<?php
function exitJson($err, $msg , $result='')
{
echo json_encode(array('err'=>$err, 'msg'=>$msg , 'result'=>$result));
exit();
}
$postdata = file_get_contents("php://input");
$jsondata = json_decode($postdata);
if($jsondata->ref == 'refs/heads/master'){ // only deploy on master branch
$return_val;
@zhaofeng-shu33
zhaofeng-shu33 / CppProperties.json
Created August 28, 2019 10:50
Visual Studio Cygwin Configuration
{
"configurations": [
{
"inheritEnvironments": [
"cygwin_64"
],
"name": "x64-Debug",
"includePath": [
"${env.INCLUDE}",
"${workspaceRoot}\\**"