自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(95)
  • 收藏
  • 关注

原创 std::mutex std::recursive_mutex std::shared_mutex

C++11。最简单的互斥锁,1个线程内,不支持重复加锁。

2024-02-05 10:23:25 182

原创 C++ WINDOWS XP系统 读写锁

【代码】C++ WINDOWS XP系统读写锁。

2023-11-07 19:59:57 155

原创 win10 vs2015 构建xp适配

【代码】win10 vs2015 构建xp适配。

2023-11-02 10:53:36 194

原创 严重性 代码 说明 项目 文件 行错误 C2228 “.GetArena”的左边必须有类/结构/联合 (编译源文件 C:\Users\dearw\Desktop\protobuf\src\googl

vs2015有bug,要升级到vs2015的update3。

2023-10-31 15:00:27 260

原创 如何使用cmakelists在windows上构建

需要编写.bat脚本,依赖本地vs的环境。

2023-10-31 11:14:12 209

原创 sizeof和strlen的本质区别

可以是动态数据,也可以是静态数据。就确定了静态数据或类型的大小。strlen:返回以。

2023-05-23 15:09:22 100

转载 You have changed variables that require your cache to be deleted.

大家直接看原文:

2023-03-09 20:54:15 991

原创 std::unique_ptr 简单使用

std::unique_ptr 简单使用

2022-09-28 19:44:35 373

原创 std::string::find 返回值的坑

string::find返回值的坑

2022-08-01 14:23:09 2051

原创 linux 同步远程机器时间(极简)

linux服务器时间同步

2022-07-14 16:17:25 395

原创 C/C++ unix时间转普通日期

#include "iostream"std::string unix2time(int n) { time_t tick = (time_t)n; struct tm* tm; tm = localtime(&tick); char s[100] = {0}; strftime(s, sizeof(s), "%Y%m%d%H%M%S", tm); return std::string(s);}int main() { int stampTime = 1496.

2022-04-22 09:46:13 935

原创 python3: failed with error code 1 in /tmp/pip-build-qp5puacl/Pillow/

pip3 install matplotlib报错:Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-qp5puacl/Pillow/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(cod.

2022-02-24 16:09:35 4367 2

原创 php 按行读取并分割字符串

<?php$fn = fopen("/root/code/php/test.txt","r");$retbuf = "";#按行读取while(!feof($fn)) { $result = fgets($fn); # 去除换行符 $result = str_replace(PHP_EOL, '', $result); $arrLine = explode(":", $result); if (count($arrLine) == 2) .

2022-02-22 11:02:14 1349

原创 C++ 文件读写

#include <fstream>#include <iostream>int main() { std::ofstream outfile; // 以写模式打开文件 outfile.open("afile.dat", std::ios::app); outfile << "hello world" << std::endl; outfile.close();}

2022-01-24 10:18:43 373

原创 shell 字符串截取

cut截取-d 表示使用什么作为分割符,-f 表示截取的偏移。#!/bin/bashtest_str="hello world and hello shell"#使用空格作为分隔符,截取第1、2个字断split=`echo $test_str | cut -d " " -f1,2`echo $split # hello world偏移截取${split,n,m} n表示起始位置,m表示截取多少个字符${split,n,} n表示起始位置,一直到字符串结束#!/bin/b

2022-01-19 15:03:31 689

原创 shell 获取时间

#!/bin/bash# 现在的时间time_now=`date "+%Y:%m:%d %H:%M:%S"`# 一个小时之前的时间time_one_hour_ago=`date -d "1 hour ago"`# 格式化time_one_hour_ago_1=`date -d "1 hour ago" +"%s"`# 另一种格式化time_one_hour_ago_2=`date -d "$time_one_hour_ago" +%s`echo $time_nowecho $time.

2022-01-19 15:00:16 4327

原创 shell 字符串中是否包含任一字符串

#!/bin/bashif [[ $1 =~ ["hello","world"] ]]; then echo "包含hello或者world"else echo "不包含"fi

2022-01-19 14:55:04 870

原创 C++ 动态结构体数组与map

#include <iostream>#include <map>struct test { std::string str1; std::string str2;};int main() { std::map<std::string, test*> mymap; mymap["one"] = new test[8]; // 申请内存 mymap["one"][0].str1 = "test 1"; mymap["two"] = .

2021-12-22 15:56:03 945

原创 linux 命令行美化

vim /etc/bashrc添加下面的代码#PS1#PS1="\[\033[38;5;87m\]\u\[$(tput bold)\]\[$(tput sgr0)\]\[\033[38;5;15m\]@\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;119m\]\h\[$(tput sgr0)\]\[\033[38;5;15m\] [\[$(tput sgr0)\]\[\033[38;5;198m\]\t\[$(tput sgr0)\]\[\0...

2021-11-27 11:06:16 1395

原创 C++11 make_pair和pair

先看这段代码:#include <iostream>int main() { std::string str = "hello world"; auto error = std::make_pair<int, std::string>(0, str); // error auto success = std::pair<int, std::string>(0, str); return 0;}在`make_pair`时会报错:err

2021-09-01 10:23:18 2040 1

原创 C++ 变参模板

#include <iostream>void xprintf(){}template <typename T, typename... Targs>void xprintf(T value, Targs... Fargs){ std::cout << sizeof...(Fargs) << " " << value << std::endl; xprintf(Fargs...);}int main().

2021-07-31 10:41:02 265

原创 fatal error: absl/synchronization/mutex.h: No such file or directory

cp -r grpc/third_party/abseil-cpp/absl /usr/local/include/

2021-07-26 17:38:48 2028 2

原创 linux cmake 快速安装

wget -q -O cmake-linux.sh https://github.com/Kitware/CMake/releases/download/v3.19.6/cmake-3.19.6-Linux-x86_64.shsh cmake-linux.sh -- --skip-license --prefix=.rm cmake-linux.sh然后将当前目录下bin/中的cmake,软连接到/usr/bin/cmakeln -s bin/cmake的绝对路径 /usr/bin/cma.

2021-07-22 11:18:21 280

原创 解决 fatal: unable to access xxx: Encountered end of

方案一:将git clone中的https改为git,如:git clone https://github.com/dapr/cpp-sdk.git # 改为:git clone git://github.com/dapr/cpp-sdk.git方案二:命令行中执行,修改git配置git config --global --unset http.proxy git config --global --unset https.proxy...

2021-07-21 16:02:09 10742 5

原创 -fshort-wchar作用

强制将wchar_t指定成两个字节使用这个字段常常是因为wchar_t类型在Windows和Linux平台下字节大小的不同,但这样做只会改变代码中实现的部分,而内部库或者是第三方库中用到的接口和函数都是没有变的,仍然采用的是4字节编码...

2021-07-19 15:14:47 986

原创 cmake入门

cmake入门github地址Cross platform Make 跨平台自动化建构系统cmake的重点是添加依赖Cmake is great. Don't waste time on other c++ build tools.# 注意事项1 cmake命令不区分大小写,但变量区分2 cmake没有clean,一般工程所在目录和工程编译目录分开,使用build/作为工程编译目录一、cmake入门 hello cmake1.linux版# 目录树hello/|-- CMake.

2021-07-19 13:35:42 670

原创 vscode remote 离线环境搭建

1.下载最新版vscode下载地址:https://code.visualstudio.com/Download2.下载最新版remote插件下载地址:https://marketplace.visualstudio.com/vscode下载以下两个插件:(点击进入,点击Download Extension)3.打开vscode并安装插件4.配置远程服务器地址尝试初次连接,初次连接是会失败的,主要是为了获取commit ID5.通过commit ID下载vscode

2021-07-13 11:12:41 632

原创 C++ 单例设计模式(全局对象的优雅实现)

#include <iostream>#define server() (Singleton::get_instance())class Singleton{public: static Singleton& get_instance() { static Singleton instance; return instance; } void coutHello(){ std::cout << "he.

2021-07-12 16:07:11 668

原创 C++ 动态连接库使用

编译.o为.so,生成libtest.sog++ -g -Wall -o3 -fPIC -I. -DHAVE_CONFIG_H -fPIC -shared -o libtest.so commu.pb.o commu.grpc.pb.o finance_canal_client.o在main.cpp中使用.so文件g++ main.cpp -std=c++14 -o main -L/code_hq...grpc/ -ltest -Wl,--rpath=/code...grpc/ -L/usr

2021-07-05 09:54:07 104

原创 linux git 免密、设置用户用密码

# 执行git config --global credential.helper store# 然后 git clone 输入帐号密码,以后不用输了

2021-06-29 15:20:39 2188 1

原创 《一秒学会C++》异步回调函数(C++11)

创建async_test.cc文件,复制C++代码,执行下面的命令g++ -std=c++11 -o async_test async_test.cc -lpthread#include <future>#include <iostream>#include <string>#include <functional>void func(std::string str){ if (str.compare("Hello World.

2021-06-24 13:36:23 2133

原创 C++11 std::thread std::bind 启动多线程

#include <iostream>#include <thread>class Task{ public: void executeThread(std::string command) { for(int i = 0; i < 5; i++) { std::cout << command << " :: " << i << std::e.

2021-06-22 10:54:57 5133

原创 fatal: unable to access ‘https://github.com/abseil/abseil-cpp.git/‘: Failed connect to github.com:44

git submodule update --init --recursive --remote --force

2021-06-19 17:28:20 1953 2

原创 cmake get_filename_component 使用

DIRECTORY = Directory without file nameNAME = File name without directoryEXT = File name longest extension (.b.c from d/a.b.c)NAME_WE = File name with neither the directory nor the longest extensionLAST_EXT = File name last extension (.c.

2021-06-18 15:25:35 2630

原创 linux cp 复制目录下文件到另一个目录下

#覆盖文件时,给出提示cp -i 源文件目录/源文件文件名 目标目录#覆盖时,不给出提示cp -f 源文件目录/源文件文件名 目标目录

2021-03-01 15:47:43 1927

原创 char*赋值给std::string是深拷贝

char *p = "";std::string strP = p; // 深拷贝delete[] p; // 需要清空内存需要注意下面这种情况:char *p = NULL;std::string strP = p; // string不接受NULL赋值delete[] p;会造成程序崩溃,所以char*赋值给string时,一定要判空:char *p = NULL;if (p == NULL){ return;}std::string strP = p;.

2021-02-19 10:40:01 4516 3

原创 vscode c++ 开发环境搭建(离线、内网)

一、C++基础插件c/c++c++ intellisense二、汉化插件 (选用)chinese (simplified)三、源码阅读bookmarks四、项目管理git historyvscode插件官方下载地址(用于下载安装包,导入到内网等离线环境)离线插件安装办法:ctrl+shift+P 输入vsix,选择下载的插件进行安装...

2021-02-04 13:49:26 848

原创 php 保存json格式数组 json_encode /u 不转义

$allDataStr = json_encode($dataArr, JSON_UNESCAPED_UNICODE);$fileHandle = fopen(_FILELOADPATH . $newFileName, "w");fwrite($fileHandle, $allDataStr);fclose($fileHandle);JSON_UNESCAPED_UNICODE(int)以字面编码多字节 Unicode 字符(默认是编码成 \uXXXX),自 PHP 5.4.0 起生效。..

2021-01-13 15:09:52 428 1

原创 python re 使用

python re 使用#!/usr/bin/pythonimport re line = "Cats are smarter than dogs"; searchObj = re.search( r'(.*) are (.*?) .*', line, re.M|re.I) if searchObj: print "searchObj.group() : ", searchObj.group() print "searchObj.group(1) : ", searchObj.g

2020-12-21 11:29:33 83

原创 linux curl 显示请求耗时和dns解析

curl -w 'time_connect %{time_connect}\ntime_starttransfer %{time_starttransfer}\ntime_total %{time_total}\n' -v www.baidu.com查看更为详细的耗时信息可以查看-w命令的使用,格式也是可以修改的。-v是显示域名解析等详细内容。...

2020-11-11 10:40:48 2116 1

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除