Skip to content

Instantly share code, notes, and snippets.

View BriFuture's full-sized avatar
🏠
Working from home

周家未 BriFuture

🏠
Working from home
View GitHub Profile
@BriFuture
BriFuture / multimap_msvc.cpp
Created June 22, 2020 15:13
MSVC can not automatically convert value type
#pragma once
#include <type_traits>
#include <variant>
#include <string>
#include <vector>
#include <map>
#include <optional>
namespace gpds
@BriFuture
BriFuture / QtFileMap.cpp
Created March 24, 2019 07:11
QFile map file into memory
#include <QCoreApplication>
#include <QFile>
#include <QDir>
#define Size 150 * 2096
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QDir dir;
dir.mkdir("video");
@BriFuture
BriFuture / sim.py
Created March 14, 2019 10:54
模拟MCU通过网络与上位机交互的小程序,使用装饰器动态添加多种数据
import logging
logger = logging.getLogger("compass")
from simulator import McuSimulator
simulator = McuSimulator()
# data protocol: nmea0183
@simulator.route_cmd("PING")
def cmd_none(msg: bytes):
simulator.send( b'#ID?*hh' )
"""by BriFuture
根据 http://neuralnetworksanddeeplearning.com/chap1.html 中的内容学习编写 Network,为了理解 Network,
自己根据文中的内容编写 Network 的代码,而不是简单的抄写文中的示例代码
"""
import numpy as np
def sigmiod(z):
"""z: [0, 1]
"""
#pragma execution_character_set("utf-8")
#include "cameradatapool.h"
#include <QDebug>
template<class T>
DataObjPool<T>::DataObjPool(int size)
{
T *pt;
pool.reserve(size);
@BriFuture
BriFuture / BroadCast.py
Last active March 17, 2020 15:05
查找局域网中的可用设备,相应机器上应该以 server 模式运行该脚本,查找机器上以 local 模式运行该脚本
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
## 如何查找特定设备的 IP
有几种方法在局域网中找到某个设备(设为设备 A)的 IP 地址:
1. 在设备 A 上运行一段程序,该程序每隔一段时间向局域网中发送广播包(UDP 广播包),(设备 B)上运行另一个程序监听相应的端口,当接收到特定格式的消息时认为收到正确的消息,此时在命令行中打印出来的的远程设备的 IP 地址即为需要的 IP。
2. 在设备 A 上运行一段程序,该程序监听预先约定好的端口,在设备 B 上向所有 IP 地址的该端口(广播)发送消息,远程设备回复时即可得到对应的 IP。
注意发送 UDP 的广播包时,将 IP 地址设为 "255.255.255.255" 即可广播到整个网络,设为 "192.168.0.255" 可广播到 "192.168.0.0/24" 的网络。如果设为其他的 IP 地址如 “192.168.255.255” 则程序运行时会报错。
## 代码地址:
@BriFuture
BriFuture / qtStatement.py
Last active February 23, 2019 03:42
批量在文件中插入语句或删除语句,新增:修改文件编码
#!/usr/bin/python
# -*- coding: utf-8 -*-
from pathlib import Path
mod_suffix = ('.cpp', '.h')
import os
statement = """#pragma execution_character_set("utf-8")\n"""
statement_len = len(statement)
src_encode = "utf-8"
module.exports = {
devServer: {
index: 'home.html',
// user: 'user.html',
proxy: {
'/api': {
target: 'http://127.0.0.1:5050/api/',
changeOrigin: true,
pathRewrite: {
'^/api': ''