Skip to content

Instantly share code, notes, and snippets.

View ityuhui's full-sized avatar

Hui Yu ityuhui

  • Xi'an, China
  • 10:36 (UTC +08:00)
View GitHub Profile
@ityuhui
ityuhui / create_proxy_server.sh
Created September 1, 2022 04:03
Create proxy commands
ssh -L 0.0.0.0:7875:0.0.0.0:7875 root@remote-hostname -Nf
tcptunnel --local-port=12001 --remote-port=12001 --remote-host=remote-hostname --stay-alive &
@ityuhui
ityuhui / boost-test.cpp
Last active March 15, 2022 07:29
boost.test
#include <boost/test/minimal.hpp>
int test_main(int argc, char *argv[])
{
BOOST_ERROR("error");
return 0;
}
@ityuhui
ityuhui / non-block-read-from-stdin.c
Last active April 13, 2021 12:52
C non-block read from stdion
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <memory.h>
#define WSC_ATTACH_STDIN_BUFFER_SIZE 1024
int main()
{
char wsc_attach_stdin_buffer[WSC_ATTACH_STDIN_BUFFER_SIZE] = {0};
@ityuhui
ityuhui / ExeWindowsCmd.c
Created September 20, 2016 08:06
Windows 执行命令行程序并读取输出
static int
ExeWindowsCmd(char *result, int reslen, const char *pszCmd)
{
int rc = 0;
SECURITY_ATTRIBUTES sa = { sizeof(SECURITY_ATTRIBUTES), NULL, TRUE };
HANDLE hRead, hWrite;
if (!CreatePipe(&hRead, &hWrite, &sa, 0))
{
@ityuhui
ityuhui / getInterfaceMTUByMAC.c
Created September 20, 2016 08:06
Windows 根据MAC地址获得MTU
/*
* For Windows Only
* Find the network interface whose MAC address is "macstr", return the MTU size of this interface.
*
* Input parameters:
* ----macstr: IP address
* ----macsize: the buffer size of macstr
*
* Output parameters:
* None
@ityuhui
ityuhui / getMACByIPWindows.c
Created September 20, 2016 08:05
Windows 根据IP地址获得MAC地址
/*
* For Windows Only
* Find the network interface whose IP address is "ipstr", return the MAC address of this interface in output parameter (macstr),
* and the interface name (ifname)
*
* Input parameters:
* ----ipstr: IP address
* ----ipsize: the buffer size of ipstr
*
* Output parameters:
@ityuhui
ityuhui / cpp_libcurl.cpp
Created February 24, 2016 06:42
c++ libcurl 使用
// studyLibCurl.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <curl/curl.h>
#include <iostream>
#include <string>
size_t offset = 0;
@ityuhui
ityuhui / cpp11_multi_thread.cpp
Created February 24, 2016 06:40
C++11 多线程
#include <thread>
#include <iostream>
void thread1_task()
{
std::cout << "thread1" << std::endl;
}
void thread2_task()
{
@ityuhui
ityuhui / stl_vector_sort.cpp
Created February 3, 2016 04:25
C++ STL Vector 排序
#include <algorithm>
int main()
{
int initv[] = {4,2,78,12,3,2,77,34};
std::vector<int> a(initv,initv+sizeof(initv)/sizeof(int));
sort(a.begin(), a.end());
for (auto it = a.begin(); it != a.end(); ++it) {
std::cout << *it << std::endl;
@ityuhui
ityuhui / read_line_from_file.cpp
Last active February 3, 2016 03:31
C++ 读取文本文件
#include <fstream>
#include <iostream>
#include <string>
int main()
{
std::string s;
int count = 0;
std::ifstream in("ConsoleApplication2.cpp");
if (in.is_open()) {