Skip to content

Instantly share code, notes, and snippets.

#include <iostream> // std::cout
enum FruitType
{
Apple,
Pear,
};
int main () {
FruitType enum_type = Pear;
@uhziel
uhziel / cpp_hex2bin.cpp
Last active September 10, 2020 09:17
cpp_hex2bin
void Bin2Hex(const char* buf, size_t len, std::string& out)
{
std::ostringstream ostr;
ostr << std::hex;
ostr.fill('0');
for (size_t i = 0; i < len; i++)
{
unsigned char tmp = buf[i];
ostr << std::setw(2) << static_cast<short>(tmp);
}
#include <iostream>
#include <windows.h>
int main() {
DWORD t1 = 4294967295;
DWORD t2 = 2;
DWORD delta = t2 - t1;
std::cout << "DWORD delta:" << delta << std::endl;
unsigned long long lt1 = 4294967295;
@uhziel
uhziel / cpp-traverse-example.cpp
Last active March 24, 2020 00:50
g++ -g -std=c++11 -o cpp-traverse-example cpp-traverse-example.cpp
#include "traverse.h"
struct Point {
int32_t x;
int32_t y;
};
TRAVERSE_STRUCT(Point, FIELD(x) FIELD(y))
/* Expand to
* void visit(traverse::CoutWriter& visitor, Point& obj) {
@uhziel
uhziel / drop_bin_dir_to_me.bat
Created March 23, 2020 02:47
上传符号到自定义windows符号服务器,把文件夹拖动到此批处理文件上即可
@echo off
rem 脚本传入参数(按顺序): <BIN_DIR>
setlocal EnableDelayedExpansion
rem echo BIN_DIR:%1
rem =========== 配置 ===========
rem SYMSTOREPATH 符号服务器地址
rem PRODUCT 你的产品名
rem VERSION 你产品的版本
rem COMMENT 你想加的注释
@uhziel
uhziel / pack_unpack.lua
Last active March 17, 2020 13:05
lua pack and unpack arguments
--return netpack.filter( queue, msg, sz)
local results = table.pack(netpack.filter( queue, msg, sz))
skynet.error("un", table.unpack(results))
return table.unpack(results)
@uhziel
uhziel / python_socket.py
Created March 12, 2020 02:47
the example of using python socket
# -*- coding: utf-8 -*-
import socket
import struct
import threading
TCP_IP = '192.168.1.133'
TCP_PORT = 31436
BUFFER_SIZE = 102400
#!/bin/bash
function check_url_exist {
# via https://stackoverflow.com/questions/12199059/how-to-check-if-an-url-exists-with-the-shell-and-probably-curl/12199125
url=$1
if curl --output /dev/null --silent --head --fail "$url"; then
echo "URL exists: $url"
#else
#echo "URL does not exist: $url"
fi
@uhziel
uhziel / tsvn_post_commit_hook_tscancode.bat
Last active September 5, 2019 09:37
If you commit codes in the TortoiseSVN, tscancode will to be called for code analysis.
@echo off
rem Tortoise SVN will call this bat with the following parameters
rem after the commit action
rem bat <CHANGESET_PATH> <DEPTH> <MESSAGEFILE> <REVISION> <ERROR> <CWD>
rem set up Post-commit hook: TortoiseSVN_en.chm 4.30.8. Client Side Hook Scripts,
setlocal EnableDelayedExpansion
rem echo CHANGESET_PATH:%1 1>&2
rem type %1 1>&2