Other

Freebuds Connnect Problem in the Windows

Problem when you connect to windows platform, the freebus cannot play music. This is because you connect your phone and windows together. Because the bad design at first and the update of windows and android. The music switch between windows and android always has problem. The device will block the play process in other device. Method You can open the setting of sound. and recconnect the sound devie instead of the connection of the bluetooth.

【CSAPP】Optimize Lab

优化任务: 4.1 原始程序及说明: 运行环境:Linux 程序框架部分如下: 说明:生成数组时,令其依次等于 1, 2, ...,这样进行平滑处理后的数组与原数组相同,方便判断程序是否正确运行; const int N = 1920; const int M = 1080; int img[N][M], tmp[M]; // [0, N), [0, M) void init(int A[N][M]) { int c = 0; for (int i=0; i< N; i++) for (int j=0; j< M; j++) A[i][j] = ++c; } bool judge(int A[N][M]) { int c = 0; for (int i=0; i< N; i++) for (int j=0; j< M; j++) if (A[i][j]!

Blazor 组件库 BootstrapBlazor 中Markdown组件介绍

组件介绍Markdown组件是tui.editor的封装,所以所有内容均基于tui.editor。 默认状态下样子如下所示: 其代码如下: <Markdown Language=@Language @bind-Value=@MarkdownString @bind-Html=@HtmlString />我们有两个内容可以绑定,一个是Value,绑定的内容为Markdown字段。一个是Html,绑定的内容为渲染出的Html。 组件的其他属性Height:组件高度,单位为px,默认值为300。 MinHeight:组件最小高度,单位为px,默认值为200。 InitialEditType:初始化的界面,类型为InitialEditType,可选值为Markdown/Wysiwyg,Wysiwyg即所见即所得界面。默认值为Markdown。 PreviewStyle:预览模式,类型为PreviewStyle,可选值为Tab/Vertical,默认为Vertical。 Language:界面语言,默认为en,内置了zh中文模式。 Placeholder:提示信息。 IsViewer:是否以纯浏览器的模式显示。 IsDark:是否使用暗黑主题。 EnableHighlight:是否启用代码高亮插件。 外部操作Markdown数据<Markdown @ref=Markdown></Markdown> <div class=mt-3> <Button OnClickWithoutRender=@(async () => await Markdown.DoMethodAsync(insertText, # test))>插入一行文字</Button> <Button OnClickWithoutRender=@(async () => await Markdown.DoMethodAsync(insertText, ![椰子树](https://i.niupic.com/images/2022/04/01/9Y6T.jpg)))>插入一张图片</Button> <Button OnClickWithoutRender=@(async () => await Markdown.DoMethodAsync(moveCursorToEnd))>光标移动到最后</Button> </div>我们可以使用DoMethodQAsync来从外部对内容进行进一步操作。

LeetCode No398. 随机数索引

题目 给你一个可能含有 重复元素 的整数数组 nums ,请你随机输出给定的目标数字 target 的索引。你可以假设给定的数字一定存在于数组中。 实现 Solution 类: Solution(int[] nums) 用数组 nums 初始化对象。 int pick(int target) 从 nums 中选出一个满足 nums[i] == target 的随机索引 i 。如果存在多个有效的索引,则每个索引的返回概率应当相等。 示例: 输入 [Solution, pick, pick, pick] [[[1, 2, 3, 3, 3]], [3], [1], [3]] 输出 [null, 4, 0, 2] 解释 Solution solution = new Solution([1, 2, 3, 3, 3]); solution.pick(3); // 随机返回索引 2, 3 或者 4 之一。每个索引的返回概率应该相等。 solution.pick(1); // 返回 0 。因为只有 nums[0] 等于 1 。 solution.

NET发布云服务器的时区问题

一劳永逸,解决.NET发布云服务器的时区问题 国内大多数开发者使用的电脑,都是使用的北京时间,日常开发的过程中其实并没有什么不便;不过,等遇到了阿里云等云服务器,系统默认使用的时间大多为UTC时间,这个时候,时区和时间的问题,就是不容忽视的大问题。 概念 首先明确一点,对于一个时刻,不管你用UTC时间还是UTC+8的时间来表示,本质上是一个时刻,就是一样的。我们处理日期和时间的目标,也是为了保证这个时刻不会因为时区的不同出现对不上的情况。 DateTime与DateTimeOffset .NET中表示时刻的数据类型有这两个(新出的Date和Time不作讨论),关于这两个数据类型,已经有同学写的很清楚了,阿里云很多服务器使用的时间为UTC时间,这个时候,如果使用DateTime,是很难说清楚时区(Kind只有UTC、Local还有未指定,不支持特定的某个时区),因此我们应当优先使用DateTimeOffset。 TimeZoneInfo 用于跨时区的情况下,时区的信息是很重要的,.NET中使用TimeZoneInfo这个类表示时区的信息。该类提供了一些静态方法,可以用于查找时区和创建时区等等。最早我是倾向于使用这些方法找到东八区的信息的,但是我发现诸如ConvertTimeBySystemTimeZoneId和FindSystemTimeZoneById的方法,都依赖于系统中的定义,不同的系统可能还不一样,自己定义是比较保险的,于是,我使用了CreateCustomTimeZone来新建一个时区。 Unix时间戳是比较于1970年的UTC标准时间,因此在处理的过程中,DateTime的时间表示应当将它转换为UTC时间,以下的代码,是使用TimeZoneInfo实现时间转换的,使用的是DateTime数据类型。如果改用DateTimeOffset,这个类型对转换为Unix时间戳更加友好。 internal static class DateTimeExtension { private static readonly TimeZoneInfo gmt8 = TimeZoneInfo.CreateCustomTimeZone(GMT+8, TimeSpan.FromHours(8), China Standard Time, (UTC+8)China Standard Time); public static long ToUnixTime(this DateTime datetime) { DateTime dateTimeUtc = datetime; if (datetime.Kind != DateTimeKind.Utc) { dateTimeUtc = datetime.ToUniversalTime(); } if (dateTimeUtc.ToUniversalTime() <= DateTime.UnixEpoch) { return 0; } return (long)(dateTimeUtc - DateTime.UnixEpoch).TotalMilliseconds; } public static DateTime ToDateTime(this long unixTimestamp) { DateTime time = DateTime.

关于cadence系列产品(主要针对板级电路设计)的一些小知识

简单copy下关于cadence系列产品(主要针对板级电路设计)的一些小知识,做下备注 ——————————————————————————————————来自: http://blog.sina.com.cn/s/blog_7177add50100vdw1.html121 AMS Advance Analysis [ AMS仿真分析器]122 AMS Simulator [ AMS仿真器]123 Simulation Accessories [[仿真附件]]131 Magnetic Parts Editor [磁性零件编辑器]132 Model Editor [仿真模型编辑器]133 Simulation Manager [仿真管理器]134 Stimulus Editor [仿真激励源编辑器] 02) PCB Editor Utilities [[ PCB编辑功能模块]] 201 Batch DRC [群组DRC检查] 202 DB Doctor [设计文件修复工具] 203 DFA Spreadsheet Editor [ DFA表格编辑器] 204 DFA Symbol Update [ DFA更新] 205 Environment Editor [用户环境编辑器] 206 OrCAD Layout Translator [ Layout to PCB编辑器] 207 Pad Designer [焊盘设计工具] 208 PADS Translator [ PADS ASCII文件转换] 209 P-Cad Translator [ PDIF文件转换] 210 PCB Editor to PCB Router [ SPECCTRA自动布线] 211 QuickView Update [快速浏览更新]05) Cadence Help [ 在线帮助文件]06) Cadence Switch Release [版本切换]07) Design Entry CIS [对应于以前版本的Capture / Capture CIS ]08) Design Entry HDL [Design Editor: Design Entry HDL允许采用表格、原理图、Verilog HDL设计,[以前的版本是Concept HDL] 09) Design Entry HDL Rules Checker [ Design Entry HDL规则检查工具]10) Layout Plus [原OrCAD的PCB设计工具]11) Layout Plus SmartRoute Calibrate [ Layout Plus的布线工具]12) Library Explorer [数字设计库的管理]13) Model Integrity [模型查看与验证工具]14) Package Designer [高密度IC封装设计和分析]15) PCB Editor [ PCB设计工具,包括:完整的PCB设计工具Allegro PCB Design 220(包括Design Entry HDL、PCB Editor、PCB Router)和Allegro PCB Performance 220以及Allegro PCB Design 610 ]16) PCB Librarian [ Allegro库开发工具]17) PCB Router [ CCT布线工具]18) PCB SI [建立数字PCB系统和集成电路封装设计的集成高速设计和分析环境,够解决电气性能 的相关问题:时序、信号完整性、串扰、电源完整性和EMI ]19) Physical Viewer [ Allegro浏览器模块]20) Project Manager [ Design Entry HDL的项目管理器]21) README PCR22) SigXplorer [网络拓扑的提取和仿真]23) SiP [SiP工具]24) SiP Digital Architect [SiP数字设计工具]25) System Architect [系统设计工具] ----------------------------------------------------------------------------------------------------------------------- Allegro中常见的文件格式: .

两个栈实现队列

class CQueue {public: stack<int> stack1; stack<int> stack2; CQueue() {} void appendTail(int value) { stack1.push(value); } int deleteHead() { if (stack1.empty()) return -1; while (!stack1.empty()){ // 1 -> 2 int tmp = stack1.top(); stack1.pop(); stack2.push(tmp); } // delete head int res = stack2.top(); stack2.pop(); while (!stack2.empty()){ // 1 <- 2 int temp = stack2.top(); stack2.pop(); stack1.push(temp); } return res; }};

前端笔记1:html表格应用

<table></table>标签定义html表格 table 表示表格 tr 行 td 标准单元格 th 表头单元格(在前) border 表格边框 width 表格宽度 <table border=3 width=500px align=center style=border-collapse:collapse;>  <tr align=center valign=top bgcolor=green>  <th>姓名</th>  <th>年龄</th>  <th>爱好</th>  </tr>  <tr align=center valign=top bgcolor=red>  <td>张辰龙</td>  <td>23岁</td>  <td>网络</td>  </tr>  </table> colspan 横向合并 rowspan 纵向合并

ubuntu 安装 nvm

方式一 官方方式 curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash 众所周知的原因,大概率是下载失败的 方式二 压缩包安装 下载nvm在 github 上的release包。 # 解压 tar -zxvf nvm-0.39.1.tar.gz # 进入目录 cd nvm-0.39.1 # 执行 install.sh bash install.sh # 输出 export NVM_DIR=$HOME/.nvm [ -s $NVM_DIR/nvm.sh ] && \. $NVM_DIR/nvm.sh [ -s $NVM_DIR/bash_completion ] && \. $NVM_DIR/bash_completion # 重启当前终端即使用 nvm -v # 输出 0.39.1

protobuf使用

简介 protobuf是google开源的数据传输格式,作用类似于json/xml github地址https://github.com/protocolbuffers/protobuf 效率 由于protobuf采用二进制编码,不同于json/xml,其编码后的格式不便于人为观察,用于对传输效率/网络包等有特殊要求的服务,目前截止发文,已经支持了C++/java/go/js/python等10中语言,下图,换句话说,除了以上语言,其他语言暂时还用不了prototbuf编码. 有利有弊,在牺牲可读性的同时,其可以获取更高的效率,根据这篇博客作者的实际测试,其结果如下 结构体{phone:{phoneName:idol3,price:2000,top:1},watch:{watchName:tcl wtch,top:1,price:1000}} 1个结构体测试 空间效率 Json:107个字节 Protobuf:32个字节 时间效率 Json序列化: 1ms , 反序列化:0ms Protobuf 序列化: 0ms 反序列化:0ms 1000个结构体测试 空间效率 Json:4206个字节 Protobuf:1332个字节 时间效率 Json序列化: 4ms , 反序列化:1ms Protobuf 序列化: 1ms 反序列化:0ms 定义 protobuf最基础的使用就是写一个配置文件,这个文件定义了我要传输的数据是什么样子,比如我要传一个文件大小,还有名字,那么这个文件就可以定义为 syntax = proto2;//可选proto2,proto3 package file; message file { required int32 id = 1; required string name = 2; optional int32 size = 3; } 其中: