Skip to content

Instantly share code, notes, and snippets.

View lixingcong's full-sized avatar
😂
Face With Tears of Joy...

Lixingcong lixingcong

😂
Face With Tears of Joy...
View GitHub Profile
@lixingcong
lixingcong / main-nowcoder.cpp
Last active April 14, 2024 08:51
牛客网、力扣CPP本机demo
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
//#include <cmath>
#include <cstdio>
//#include <limits>
#include <stack>
#include <queue>
@lixingcong
lixingcong / remove-first-line-of-markdown.py
Created October 26, 2023 05:58
从Notion导出的markdown删掉第一行的同名标题
from pathlib import Path
# /tmp/1.txt获取方式
# find /path/to/dir -type f -name '*.md' > /tmp/1.txt
with open("/tmp/1.txt", 'r') as mdList:
for md in mdList:
filepath = md.strip()
filename = Path(md).stem
#print(filename)
@lixingcong
lixingcong / Makefile
Last active January 13, 2023 01:51
C/C++ Makefile template
# Get top dir
# https://github.com/imp/dnsmasq/blob/master/Makefile
TOP_DIR != pwd
TOP_DIR ?= $(CURDIR)
BIN_DIR := $(TOP_DIR)/bin
TARGET := $(BIN_DIR)/SimulateServer
OBJ_DIR := $(TOP_DIR)/obj
OBJECTS := $(patsubst %.cpp, %.o, $(wildcard *.cpp))
@lixingcong
lixingcong / Employee.cpp
Created December 29, 2022 09:09
Qt implicitly shared class demo 隐式共享
#include "Employee.h"
#include <QString>
class EmployeeData : public QSharedData
{
public:
EmployeeData()
: id(-1)
{}
@lixingcong
lixingcong / dl_move_files_to_test.py
Last active June 18, 2022 16:07
深度学习,递归地移动某目录下所有文件到别处,用于划分测试集
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# 递归移动某个文件夹下的所有文件到另一个文件,作为深度学习划分测试集
# 2022-06-18
#
# 参数:
# python3 main.py -s <SRC-DIR> -d <DEST-DIR> -p <MOVE-PERCENT>
# 例子:
# python3 main.py E:\image-src E:\image-dest -p 90
@lixingcong
lixingcong / fetchUrl_gzip.php
Created February 8, 2021 14:09 — forked from mgng/fetchUrl_gzip.php
file_get_contents で Accept-Encoding:gzip 指定
<?php
function fetchUrl( $url, $gzip = false ) {
$raw = file_get_contents( $url, false, $context = stream_context_create( array(
'http' => array(
'method' => 'GET',
'header' => 'Accept-Encoding:' . ( $gzip ? 'gzip,deflate' : 'identity' ) . "\r\n",
)
) ) );
if ( $raw === false ) {
@lixingcong
lixingcong / delete_git_submodule.md
Created December 30, 2020 05:59 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@lixingcong
lixingcong / php-client_get.php
Last active July 5, 2021 08:04
PHP测试POST/GET/JSON解析ECHO的demo
<?php
function get($url, $hostname, $data=NULL)
{
$fullUrl=$url;
if(NULL!==$data){
$fullUrl.= '?'.http_build_query($data);
}
@lixingcong
lixingcong / validator.h
Created April 23, 2020 02:00
QLineEdit validator for IP and Port
class MyIPValidator : public QRegularExpressionValidator
{
// https://www.qtcentre.org/threads/6228-Ip-Address-Validation
public:
MyIPValidator(const QString& defaultString, QObject* parent = Q_NULLPTR)
: QRegularExpressionValidator(
QRegularExpression("^0*(2(5[0-5]|[0-4]\\d)|1?\\d{1,2})(\\.0*(2(5[0-5]|[0-4]\\d)|1?\\d{1,2})){3}$"), parent)
, m_defaultString(defaultString)
{}

The following table provides the details of standard integer types with their storage sizes and value ranges

Type Storage size Value range
char 1 byte -128 to 127 or
0 to 255
unsigned char 1 byte 0 to 255
signed char 1 byte -128 to 127
int 2 bytes or
4 bytes
-32768 to 32767 or
-2147483648 to 2147483647
unsigned int 2 bytes or
4 bytes
0 to 65535 or
0 to 4294967295
short 2 bytes -32768 to 32767