Skip to content

Instantly share code, notes, and snippets.

Avatar
😂
Face With Tears of Joy...

Lixingcong lixingcong

😂
Face With Tears of Joy...
View GitHub Profile
@lixingcong
lixingcong / fetchUrl_gzip.php
Created Feb 8, 2021 — forked from mgng/fetchUrl_gzip.php
file_get_contents で Accept-Encoding:gzip 指定
View fetchUrl_gzip.php
<?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 Dec 30, 2020 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.
View delete_git_submodule.md

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 Jul 5, 2021
PHP测试POST/GET/JSON解析ECHO的demo
View php-client_get.php
<?php
function get($url, $hostname, $data=NULL)
{
$fullUrl=$url;
if(NULL!==$data){
$fullUrl.= '?'.http_build_query($data);
}
@lixingcong
lixingcong / validator.h
Created Apr 23, 2020
QLineEdit validator for IP and Port
View validator.h
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)
{}
View IntegerTypesRange.md

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 Nov 6, 2019
重载QDataStream<<和>>运算符序列化和反序列化
View qdatastream_overload.cpp
#include <QDataStream>
#include <QString>
#include <QDebug>
struct Data1
{
bool isOk;
int value;
QString str;
};
@lixingcong
lixingcong / cpp11_std_forward.cpp
Last active Oct 22, 2019
C++11的右值引用:移动语义+完美转发
View cpp11_std_forward.cpp
#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 Oct 5, 2019
生成随机数C++
View random.hpp
#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 Apr 24, 2019
Q_INVOKABLE宏的简单用法
View q_invokable.h
#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 Apr 15, 2019
qt5的Q_D宏和Q_Q宏封装pimp
View Label.cpp
#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()
{