存0的情况
- 数值型但是需要统计:比如余额,订单总额
存null的情况
- 外键可以为空:比如admin_user_id)如果为系统操作,可以为null,这时候存0必须取消数据库约束,或者不建外键约束,都不如存null好
存”的情况
- 非必填且填写的字符串可以为空字符串:比如外国人的middle name,存”可以方便的拼接full name,这个时候如果不需要拼接,你还是可以存null.
- 框架不支持修改时自动将null呈现为”,且保存时自动”改为null
A cross-platform GUI library for Rust focused on simplicity and type-safety. Inspired by Elm.
struct Counter {
// The counter value
value: i32,
}
#[derive(Debug, Clone, Copy)]
pub enum Message {
IncrementPressed,
DecrementPressed,
}
use iced::widget::{button, column, text, Column};
impl Counter {
pub fn view(&self) -> Column<Message> {
// We use a column: a simple vertical layout
column![
// The increment button. We tell it to produce an
// `IncrementPressed` message when pressed
button("+").on_press(Message::IncrementPressed),
// We show the value of the counter here
text(self.value).size(50),
// The decrement button. We tell it to produce a
// `DecrementPressed` message when pressed
button("-").on_press(Message::DecrementPressed),
]
}
pub fn update(&mut self, message: Message) {
match message {
Message::IncrementPressed => {
self.value += 1;
}
Message::DecrementPressed => {
self.value -= 1;
}
}
}
}
Dioxus 是一个可移植的、高性能的、符合人体工程学的框架,使用 Rust 语言构建跨平台的用户界面。
fn app(cx: Scope) -> Element {
let mut count = use_state(cx, || 0);
cx.render(rsx! {
h1 { "High-Five counter: {count}" }
button { onclick: move |_| count += 1, "Up high!" }
button { onclick: move |_| count -= 1, "Down low!" }
})
}
Dioxus 可用于生成 网页前端、桌面应用、静态网站、移动端应用、TUI程序、等多类平台应用。
如果你能够熟悉使用 React 框架,那 Dioxus 对你来说将非常简单。
Build smaller, faster, and more secure desktop applications with a web frontend.
egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
ui.heading("My egui Application");
ui.horizontal(|ui| {
ui.label("Your name: ");
ui.text_edit_singleline(&mut name);
});
ui.add(egui::Slider::new(&mut age, 0..=120).text("age"));
if ui.button("Click each year").clicked() {
age += 1;
}
ui.label(format!("Hello '{}', age {}", name, age));
A framework for creating reliable and efficient web applications.
use yew::prelude::*;
#[function_component]
fn App() -> Html {
let counter = use_state(|| 0);
let onclick = {
let counter = counter.clone();
move |_| {
let value = *counter + 1;
counter.set(value);
}
};
html! {
<div>
<button {onclick}>{ "+1" }</button>
<p>{ *counter }</p>
</div>
}
}
fn main() {
yew::Renderer::<App>::new().render();
}
We use the following design goals as a guide when developing Slint:
Rust使用比较多的ORM是SeaORM和Diesel,本文介绍两个轻量级的。
https://github.com/bitlabx/cherry
use cherry::{DataSource, PoolConfig};
pub async fn setup() -> Result<(), Box<dyn Error>> {
let conn = PoolConfig {
url: "mysql://root:12345678@localhost:3306/foo".to_owned(),
..Default::default()
};
Foo::setup(conn).await?;
let result: Option<User> = Foo::select()
.and_where_eq("id", 123)
.fetch()
.await?;
Ok(())
}
pub struct Foo;
impl DataSource for Foo {}
// You can setup more than one DataSources if you need.
// pub struct Bar;
// impl DataSource for Bar {}
https://github.com/wslongchen/akita
fn main() {
let cfg = AkitaConfig::new(String::from("mysql://root:password@localhost:3306/akita"))
.set_connection_timeout(Duration::from_secs(6))
.set_log_level(LogLevel::Info).set_max_size(6);
let akita = Akita::new(cfg).expect("must be ok");
// CRUD with Entity
let model = User::default();
// insert
let insert_id = model.insert::<Option<i32>, _>(&akita).unwrap();
// update
let res = model.update_by_id::<_>(&akita).unwrap();
// delete
let res = model.delete_by_id::<i32,_>(&akita, 1).unwrap();
// list
let list = User::list::<_>(Wrapper::new().eq("name", "Jack"), &akita).unwrap();
// page
let page = User::page::<_>(pageNo, pageSize, Wrapper::new().eq("name", "Jack"), &akita).unwrap();
}
使用其他库存在计算不准确和部分压缩文件不支持问题。
sudo apt install poppler-utils # ubuntu debian
sudo dnf install poppler-utils # centos
composer require "howtomakeaturn/pdfinfo"
$pdf = new PDFInfo('path/to/the/pdf');
echo $pdf->pages;
https://github.com/vbenjs/vue-vben-admin
Vue Vben Admin 是一个免费开源的中后台模版。使用了最新的vue3,vite2,TypeScript等主流技术开发,开箱即用的中后台前端解决方案,也可用于学习参考。
特性
https://github.com/jekip/naive-ui-admin
Naive Ui Admin 完全免费,且可商用,基于 Vue3.0、Vite、 Naive UI、TypeScript 的中后台解决方案,它使用了最新的前端技术栈,并提炼了典型的业务模型,页面,包括二次封装组件、动态菜单、权限校验、粒子化权限控制等功能,它可以帮助你快速搭建企业级中后台项目, 相信不管是从新技术使用还是其他方面,都能帮助到你。
特性
https://github.com/biubiubiu01/vue-antd-admin
vue-antd-admin基于vue-cli4+vuex+ant-design-vue开发的后台管理系统,包括权限管理,布局方式,国际化,动态路由和后台管理系统常用的table表和表单等功能,包含echarts图的各种展示,第一版已完成,有兴趣可以了解下。
之后可能不咋会更新了,准备写一个vue3+ts+vite了.
https://github.com/llyyayx/vue3-antd-admin
使用vue3+ant-design-vue+vite+ts开发的通用后台框架,实现了权限系统、动态菜单、表格集成快速使用等功能,简洁干净开箱即用。
https://github.com/chuzhixin/vue-admin-better
提供收费版本
plugins=(git composer npm pip pyenv virtualenv debian systemd python history-substring-search zsh-autosuggestions zsh-syntax-highlighting last-working-dir wd extract zoxide)
本文一步一步教你如何在小程序中使用最新版的OpenCV
安装基础工具
pacman -S base-devel cmake git
git clone https://github.com/juj/emsdk.git
cd emsdk
./emsdk install 2.0.10
./emsdk activate 2.0.10
source ./emsdk_env.sh
进入 https://opencv.org/releases/ 页面下载opencv最新版源码,并解压缩,并进入解压缩后文件夹
修改platforms/js/opencv_js.config.py
文件根据情况,去掉不用的模块
# white_list = makeWhiteList([core, imgproc, objdetect, video, dnn, features2d, photo, aruco, calib3d])
white_list = makeWhiteList([core, imgproc])
默认OpenCV4会将wasm以base64存到js文件,输出单独wasm文件便于用于微信小程序
打开modules/js/CMakeLists.txt
,去掉 SINGLE_FILE
参数
# set(EMSCRIPTEN_LINK_FLAGS "${EMSCRIPTEN_LINK_FLAGS} -s MODULARIZE=1 -s SINGLE_FILE=1")
set(EMSCRIPTEN_LINK_FLAGS "${EMSCRIPTEN_LINK_FLAGS} -s MODULARIZE=1")
微信小程序不支持eval()
和new Function()
等动态执行函数,在modules/js/CMakeLists.txt
中,增加DYNAMIC_EXECUTION
的编译参数屏蔽这些函数的输出
# set(EMSCRIPTEN_LINK_FLAGS "${EMSCRIPTEN_LINK_FLAGS} -s MODULARIZE=1 -s SINGLE_FILE=1")
set(EMSCRIPTEN_LINK_FLAGS "${EMSCRIPTEN_LINK_FLAGS} -s MODULARIZE=1")
set(EMSCRIPTEN_LINK_FLAGS "${EMSCRIPTEN_LINK_FLAGS} -s DYNAMIC_EXECUTION=0")
emcmake python ./platforms/js/build_js.py -h
emcmake python ./platforms/js/build_js.py build_wasm --build_wasm --build_test
build_wasm\bin
目录生成了opencv.js,opencv_js.wasm,tests.html文件
brotli -o build_wasm/bin/opencv_js.wasm.br build_wasm/bin/opencv_js.wasm
npm i -g http-server
http-server build_wasm/bin/
在浏览器打开 http://127.0.0.1:8080/tests.html
可以查看测试结果
opencv.js
适配微信小程序修改前先将opencv.js
格式化一下,微信小程序不支持通过url获取wasm,修改下instantiateAsync方法的else分支里面的代码,让读小程序项目下的opencv_js.wasm文件
function instantiateAsync() {
if (
!wasmBinary &&
typeof WebAssembly.instantiateStreaming === "function" &&
!isDataURI(wasmBinaryFile) &&
!isFileURI(wasmBinaryFile) &&
typeof fetch === "function"
) {
return fetch(wasmBinaryFile, { credentials: "same-origin" }).then(
function (response) {
var result = WebAssembly.instantiateStreaming(response, info);
return result.then(
receiveInstantiatedSource,
function (reason) {
err("wasm streaming compile failed: " + reason);
err("falling back to ArrayBuffer instantiation");
return instantiateArrayBuffer(receiveInstantiatedSource);
}
);
}
);
} else {
// return instantiateArrayBuffer(receiveInstantiatedSource);
var result = WebAssembly.instantiate("/opencv/opencv_js.wasm.br", info);
return result.then(
receiveInstantiatedSource,
function (reason) {
err("wasm streaming compile failed: " + reason);
err("falling back to ArrayBuffer instantiation");
return instantiateArrayBuffer(receiveInstantiatedSource);
}
);
}
}
这些方法定义在modules\js\src\helpers.js
文件中,修改后重新编译和生成wasm文件即可
OpenCV.js
const app = getApp()
WebAssembly = WXWebAssembly;
let cv = require('../../opencv/opencv.js');
Page({
onLoad: function (options) {
if (cv instanceof Promise) {
cv.then((target) => {
console.log(target);
})
} else {
console.log(cv);
}
}
})
网上资料通常都通过命令行调用sc.exe进行,这里介绍一种通过微软提供API实现的方法。代码更加简单,可控性更好。
static void Main(string[] args)
{
if (args.Length == 0) {
// Run your service normally.
ServiceBase[] ServicesToRun = new ServiceBase[] {new YourService()};
ServiceBase.Run(ServicesToRun);
} else if (args.Length == 1) {
switch (args[0]) {
case "-install":
InstallService();
StartService();
break;
case "-uninstall":
StopService();
UninstallService();
break;
default:
throw new NotImplementedException();
}
}
}
public class ServiceControl
{
const string ServiceName = "MyService";
public static bool IsInstalled()
{
using (ServiceController controller =
new ServiceController(ServiceName))
{
try
{
ServiceControllerStatus status = controller.Status;
}
catch
{
return false;
}
return true;
}
}
public static bool IsRunning()
{
using (ServiceController controller =
new ServiceController(ServiceName))
{
if (!IsInstalled()) return false;
return (controller.Status == ServiceControllerStatus.Running);
}
}
public static AssemblyInstaller GetInstaller()
{
AssemblyInstaller installer = new AssemblyInstaller(
typeof(MyService).Assembly, null);
installer.UseNewContext = true;
return installer;
}
public static void InstallService()
{
if (IsInstalled()) return;
try
{
using (AssemblyInstaller installer = GetInstaller())
{
IDictionary state = new Hashtable();
try
{
installer.Install(state);
installer.Commit(state);
}
catch
{
try
{
installer.Rollback(state);
}
catch { }
throw;
}
}
}
catch
{
throw;
}
}
public static void UninstallService()
{
if (!IsInstalled()) return;
try
{
using (AssemblyInstaller installer = GetInstaller())
{
IDictionary state = new Hashtable();
try
{
installer.Uninstall(state);
}
catch
{
throw;
}
}
}
catch
{
throw;
}
}
public static void StartService()
{
if (!IsInstalled()) return;
using (ServiceController controller =
new ServiceController(ServiceName))
{
try
{
if (controller.Status != ServiceControllerStatus.Running)
{
controller.Start();
controller.WaitForStatus(ServiceControllerStatus.Running,
TimeSpan.FromSeconds(10));
}
}
catch
{
throw;
}
}
}
public static void StopService()
{
if (!IsInstalled()) return;
using (ServiceController controller =
new ServiceController(ServiceName))
{
try
{
if (controller.Status != ServiceControllerStatus.Stopped)
{
controller.Stop();
controller.WaitForStatus(ServiceControllerStatus.Stopped,
TimeSpan.FromSeconds(10));
}
}
catch
{
throw;
}
}
}
}
建立了一个"独立项目交流群",本群主要交流开源项目的运作模式和盈利模式。
大家可以在名字前面加地区,以及熟悉的技能,如“长沙-全栈-ning”,名字建议用昵称。
目前还没有项目启动,大家可以想一想,可以先分享一些开源或者商业案例,慢慢形成讨论氛围。
注意:
微信扫码进群
php -v
输出
PHP 7.4.14 (cli) (built: Jan 5 2021 15:11:43) ( NTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
可以看到PHP版本为7.4,NTS(非线程安全),64位
php_imagick.dll
放入PHP目录下的ext子目录下extension=imagick