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

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
@lixingcong
lixingcong / qdatastream_overload.cpp
Created November 6, 2019 09:13
重载QDataStream<<和>>运算符序列化和反序列化
#include <QDataStream>
#include <QString>
#include <QDebug>
struct Data1
{
bool isOk;
int value;
QString str;
};
@lixingcong
lixingcong / cpp11_std_forward.cpp
Last active October 22, 2019 03:03
C++11的右值引用:移动语义+完美转发
#include <iostream>
#include <memory>
#include <utility>
// 源码已稍作修改,出自:https://en.cppreference.com/w/cpp/utility/forward
struct A
{
A(int&& n) { std::cout << "rvalue overload, n=" << n << "\n"; }
A(int& n) { std::cout << "lvalue overload, n=" << n << "\n"; }
};
@lixingcong
lixingcong / random.hpp
Created October 5, 2019 12:10
生成随机数C++
#ifndef MYRANDOM_HPP
#define MYRANDOM_HPP
// 源码:https://evileg.com/en/post/306
#include <random>
namespace details
{
/// True if type T is applicable by a std::uniform_int_distribution
@lixingcong
lixingcong / q_invokable.h
Created April 24, 2019 12:45
Q_INVOKABLE宏的简单用法
#include <QObject>
#include <QDebug>
class MyClass : public QObject
{
Q_OBJECT
public:
explicit MyClass(QObject *parent = nullptr):QObject(parent){}
Q_INVOKABLE void printHello(const QString& text)
@lixingcong
lixingcong / Label.cpp
Created April 15, 2019 07:50
qt5的Q_D宏和Q_Q宏封装pimp
#include "Label.h"
#include "Label_p.h"
Label::Label(const QString& text, QWidget *parent) : QLabel(text, parent),
d_ptr(new LabelPrivate(this))
{
}
QString Label::myGetText()
{
@lixingcong
lixingcong / build-shadowsocks.sh
Last active March 17, 2021 10:20
静态编译ss
#!/bin/bash
# Update: 2021-03-17
# Modified by lixingcong
# Fork from https://github.com/necan/shadowsocks-libev-static-build
# Attention: modified from https://github.com/shadowsocks/shadowsocks-libev/blob/master/docker/mingw/build.sh
# The script does not need to run as root
@lixingcong
lixingcong / GitBashHere.reg
Last active October 18, 2024 09:50
添加"git bash"到右键菜单
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\background\shell\git_shell]
@="Git Ba&sh Here"
"Icon"="D:\\Program_Files\\Git\\git-bash.exe"
[HKEY_CLASSES_ROOT\Directory\background\shell\git_shell\command]
@="\"D:\\Program_Files\\Git\\git-bash.exe\" \"--cd=%v.\""
[HKEY_CLASSES_ROOT\Directory\shell\git_shell]
@lixingcong
lixingcong / sysctl.conf
Last active May 21, 2025 07:12
适用于个人的Linux VPS内核调优
# source from phuslu
# https://phus.lu/sysctl.conf
# bbr
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr
net.ipv4.tcp_retries2 = 8
# 系统所有进程一共可以打开的文件数量, 每个套接字也占用一个文件描述字
@lixingcong
lixingcong / Person.cpp
Created August 18, 2018 06:33
C++的pimpl机制demo
#include "Person.h"
#include "PersonPrivate.h"
#include "cpp14_pointers.h"
Person::Person(std::string name):
pimpl(std::make_unique<PersonPrivate>(name))
{
}
Person::~Person()