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 / 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 December 29, 2020 10:12
添加"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 December 1, 2023 12:26
适用于个人的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()
@lixingcong
lixingcong / astyle_qt.conf
Created July 18, 2018 11:27
Astyle代码格式文件
--style=kr
--indent=spaces=4
--attach-inlines
--indent-cases
--indent-col1-comments
--break-blocks
--pad-oper
--align-pointer=type
--align-reference=type
--max-code-length=100