下雪了

【Flash】关于在Windows10上重新启用Flash的方法

1.方法汇总①创建 mms.cfg 文件(Flash配置文件,默认情况下安装完Flash是没有这个文件的,需要自己创建来强制配置Flash)

该文件用文本编辑器打开,里面内容如下,意思是配置 允许本机使用Flash打开的站点

EnableAllowList=1AllowListUrlPattern=http://192.168.1.1/

AllowListUrlPattern=https://www.xxx.com/cn

②将编辑好的 mms.cfg 文件,放到以下Flash插件目录下:

C:\Windows\System32\Macromed\Flash\ (32位)

C:\Windows\SysWOW64\Macromed\Flash\ (64位)

③重新打开需要使用Flash插件的站点或者地址,Flash变为可用。

转自:http://www.360doc.com/content/21/0401/05/13253171_970025362.shtml

【Linux】一个简单的makefile模板

CXX = g++
CXXFLAGS = -std=c++17 -Wall -g

HEADERS = -I./include
SRC = ./src
LIBS = -lSDL -lSDL_draw -lSDL_image -lSDL_gfx
OBJS = $(wildcard $(SRC)/*.cpp )


TARGER = main

all:$(TARGER)

main: $(OBJS)
$(CXX) $(CXXFLAGS) $(HEADERS) $(OBJS) -o $(TARGER) $(LIBS)

clean:
rm -rf $(TARGER)

配合一下文件目录结构使用

-projectName

–include

—xxx.h

–src

—xxx.cpp

–makefile

【Qt】窗口拖动代码

来自网上的博客,是通过鼠标相关的事件来实现的,封装起来很方便。

//Widget.h 
#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>

class QMouseEvent;
class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = 0);
    ~Widget();

protected:
    //拖拽窗口
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);

private:
    bool        m_bDrag;
    QPoint      mouseStartPoint;
    QPoint      windowTopLeftPoint;
};

#endif // WIDGET_H
//Widget.cpp
#include <QMouseEvent>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , m_bDrag(false)
{
    setWindowTitle("窗口拖拽移动");
    setFixedSize(640, 480);
}

Widget::~Widget()
{

}

/* QPoint QMouseEvent::pos() const
    Returns the position of the mouse cursor, relative to the widget that received the event.
    If you move the widget as a result of the mouse event, use the global position returned by globalPos() to avoid a shaking motion.
 */

//拖拽操作
void Widget::mousePressEvent(QMouseEvent *event)
{
    if(event->button() == Qt::LeftButton)
    {
        m_bDrag = true;
        //获得鼠标的初始位置
        mouseStartPoint = event->globalPos();
        //mouseStartPoint = event->pos();
        //获得窗口的初始位置
        windowTopLeftPoint = this->frameGeometry().topLeft();
    }
}

void Widget::mouseMoveEvent(QMouseEvent *event)
{
    if(m_bDrag)
    {
        //获得鼠标移动的距离
        QPoint distance = event->globalPos() - mouseStartPoint;
        //QPoint distance = event->pos() - mouseStartPoint;
        //改变窗口的位置
        this->move(windowTopLeftPoint + distance);
    }
}

void Widget::mouseReleaseEvent(QMouseEvent *event)
{
    if(event->button() == Qt::LeftButton)
    {
        m_bDrag = false;
    }
}

 

【Boost】发送/接收HTML请求(Get/Post)

头文件:

#include <boost/asio.hpp>
#include <boost/beast.hpp>
#include <boost/locale.hpp>

具体步骤:

void conn()
{

    try
    {
        //三个基础参数
        string host="zofz.cf";
        string port="80";
        string target="/123/";

        //http版本
        int version = 11;

        //建立基础IO接口,并初始化resolver和socket
        boost::asio::io_service io_se;
        boost::asio::ip::tcp::resolver resolver{ io_se };
        boost::asio::ip::tcp::socket socket{ io_se };

        //设定GET/POST请求
        boost::asio::streambuf request;
        std::ostream request_stream(&request);

        //创建http头,注意格式
        request_stream << "GET " << target << " HTTP/1.1 \r\n";
        request_stream << "Host: " << host << "\r\n";
        request_stream << "Accept: application/json \r\n";
        request_stream << "Accept-Encoding: gzip, deflate, br \r\n";
        request_stream << "Conection: keep-alive \r\n";
        request_stream << "Content-Type: application/x-www-form-urlencoded \r\n";
        request_stream << "User-Agent: " << ua << " \r\n";

        // 发送request
        write(socket, request);

        //声明一个容器来保存响应
        boost::beast::flat_buffer buf;
        response<string_body> resp;
        stringstream ss;

        //接收容器
        read(socket, buf, resp);
        
        //遍历Header
        for(auto &i:resp)
        {
            cout<<i.name()<<i.value()<<endl;
        }
        
        //输出body
        cout<<resp.body()<<endl;
    }
    catch (std::exception const& e)
    {
        //输出错误
        cout<< e.what()<<);
    }
}

 

【Boost】对JSON的操作

头文件:

#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>

用法:

void encode()
{
    /*
    将形如:
    {
        "data":
        {
            "key":"value";
        }
    }
    的JSON文本转为string字符串
    */
    
    ptree root, data;
    stringstream ss;
    
    //创建data
    data.put("key", "value");
    
    //放入data
    root.put_child("data", data);
    
    //将JSON文本写入字符流
    write_json(ss, root);
    
    //读出字符串
    string json = ss.str();
}



void decode(string json)
{
    /*
    解析形如
    {
        "data":
        {
            "key":"value";
        }
    }
    的JSON文本到string中
    */
    ptree root, data;
    
    //将字符串读入字符流
    stringstream ss(json);
    
    //读出JSON格式的文本
    read_json(ss, root);
    
    //分离出data
    data = root.get_child("data");
    
    //分离出key,value
    string value = data.get & lt; string& gt; ("key");
}