M1 node-sass nvm
nvm 切换node版本
nvm alias default 14
nvm use 14
nodes-sass 安装
npm install --target_arch=x64
nvm 切换node版本
nvm alias default 14
nvm use 14
nodes-sass 安装
npm install --target_arch=x64
1、打开终端,粘贴如下内容,注意加上空格
sudo xattr -rd com.apple.quarantine
2、从访达的应用程序中把App拖到终端执行:
sudo xattr -rd com.apple.quarantine /Applications/Parallels\ Desktop.app
location /api/v1 {
set $is_matched 0;
if ($request_uri ~ /api/v1/user/100001/ ) {
proxy_pass https://127.0.0.1:1001/;
set $is_matched 1;
}
if ($request_uri ~ /api/v1/user/100002/ ) {
proxy_pass https://127.0.0.1:1001/;
set $is_matched 1;
}
# 没有匹配到,跳转到默认页面
if ($is_matched = 0) {
proxy_pass https://127.0.0.1:8080;
}
}
采用最新Java驱动
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>4.3.0</version>
</dependency>
获取数据源及数据库
/**
* @author wizzer@qq.com
*/
public class ZMongoDatabase {
private MongoDatabase db;
public ZMongoDatabase(MongoDatabase db) {
this.db = db;
}
/**
* 获取集合,集合不存在则返回 null
*
* @param name 集合名称
* @return 集合薄封装
*/
public MongoCollection<Document> getCollection(String name) {
if (!this.collectionExists(name)) {
return null;
}
return db.getCollection(name);
}
/**
* 获取一个集合,如果集合不存在,就创建它
*
* @param name 集合名
* @param dropIfExists true 如果存在就清除
* @return 集合薄封装
*/
public MongoCollection<Document> createCollection(String name, boolean dropIfExists) {
// 不存在则创建
if (!this.collectionExists(name)) {
return createCollection(name, null);
}
// 固定清除
else if (dropIfExists) {
db.getCollection(name).drop();
return createCollection(name, null);
}
// 已经存在
return db.getCollection(name);
}
/**
* 获取一个集合,如果集合不存在,就创建它
*
* @param name 集合名
* @param options 集合配置信息
* @param dropIfExists true 如果存在就清除
* @return 集合薄封装
*/
public MongoCollection<Document> createCollection(String name, CreateCollectionOptions options, boolean dropIfExists) {
// 不存在则创建
if (!this.collectionExists(name)) {
return createCollection(name, options);
}
// 固定清除
else if (dropIfExists) {
db.getCollection(name).drop();
return createCollection(name, options);
}
// 已经存在
return db.getCollection(name);
}
/**
* 创建一个集合
*
* @param name 集合名
* @param options 集合配置信息
* @return 集合薄封装
*/
public MongoCollection<Document> createCollection(String name, CreateCollectionOptions options) {
if (this.collectionExists(name)) {
throw Lang.makeThrow("Colection has exists: %s.%s", db.getName(), name);
}
// 创建默认配置信息
if (null == options) {
options = new CreateCollectionOptions().capped(false);
}
db.createCollection(name, options);
return db.getCollection(name);
}
/**
* 判断集合是否存在
*
* @param collectionName 集合名
* @return
*/
public boolean collectionExists(String collectionName) {
return listCollectionNames().contains(collectionName);
}
/**
* @return 当前数据库所有可用集合名称
*/
public List<String> listCollectionNames() {
return db.listCollectionNames().into(new ArrayList<String>());
}
public MongoDatabase getNativeDB() {
return this.db;
}
}
初始化数据库示例
@Inject
private ZMongoDatabase zMongoDatabase;
public void init() {
CreateCollectionOptions collectionOptions = new CreateCollectionOptions();
TimeSeriesOptions timeSeriesOptions = new TimeSeriesOptions("ts");
timeSeriesOptions.metaField("metadata");
timeSeriesOptions.granularity(TimeSeriesGranularity.SECONDS);
collectionOptions.timeSeriesOptions(timeSeriesOptions);
MongoCollection<Document> deviceCollection = zMongoDatabase.createCollection("device", collectionOptions, true);
List<Document> list = new ArrayList<>();
Device device = new Device(Times.now(), 36.7, "0001");
list.add(new Document().append("ts", device.getTs()).append("temperature", device.getTemperature()).append("metadata",
new Document().append("no", device.getNo())));
Device device1 = new Device(Times.now(), 35.2, "0002");
list.add(new Document().append("ts", device1.getTs()).append("temperature", device1.getTemperature()).append("metadata",
new Document().append("no", device1.getNo())));
Device device2 = new Device(Times.now(), 10.7, "0002");
list.add(new Document().append("ts", device2.getTs()).append("temperature", device2.getTemperature()).append("metadata",
new Document().append("no", device2.getNo())));
Device device3 = new Device(Times.nextDay(Times.now(), 1), 30.0, "0002");
list.add(new Document().append("ts", device3.getTs()).append("temperature", device3.getTemperature()).append("metadata",
new Document().append("no", device3.getNo())));
// Document.parse(Json.toJson(new Device()));
InsertManyResult insertManyResult = deviceCollection.insertMany(list);
log.info(Json.toJson(insertManyResult));
}
时序数据求平均值示例
// 官方时序数据统计Demo https://docs.mongodb.com/manual/core/timeseries-collections/
@Ok("json:full")
@At("/avg")
public Object avg(@Param(value = "no", df = "0002") String no) {
List<Bson> bsons = new ArrayList<>();
// 筛选条件
Bson match = Aggregates.match(Filters.eq("metadata.no", no));
// 输出对象
Bson project = Aggregates.project(Projections.fields(
// 日期格式化
Projections.computed("date", new Document("$dateToParts", new Document().append("date", "$ts"))),
Projections.computed("temperature", 1)
));
// 分组统计 平均值
Bson group = Aggregates.group(new Document("date", new Document().append("year", "$date.year").append("month", "$date.month").append("day", "$date.day")),
Accumulators.avg("avgTemp", "$temperature")
);
bsons.add(match);
bsons.add(project);
bsons.add(group);
log.info(Json.toJson(bsons));
return zMongoDatabase.getCollection("device").aggregate(bsons);
}
完整代码:
nutzboot starter 组件
组件使用示例
nutzboot-demo-simple-mongodb-plus
i’am a separator…
1、el-tabs 中放置 el-tree 使用 this.$ref[‘tree’] 获取不到对象
使用 this.$ref[‘tree’][0] 可以取到
2、el-cascader 动态加载行政区划,修改表单时无法初始化选中的值
需要设置属性 :key=”xx” ,在数据加载完成后让 xx ++ 自加1
rpm -ivh TDengine-server-2.0.18.0-Linux-x64.rpm
vi /etc/taos/taos.cfg
加上当前服务器 hostname 主机名# first fully qualified domain name (FQDN) for TDengine system
firstEp wizzer-test:6030
# local fully qualified domain name (FQDN)
fqdn wizzer-test
taos
或 taos -h 127.0.0.1
执行数据库创建命令taos > create database test;
C:\Windows\System32\drivers\etc\hosts
ip wizzer-test
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.budwk</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<nutzboot.version>2.4.2-SNAPSHOT</nutzboot.version>
<jaxb-api.version>2.3.1</jaxb-api.version>
<slf4j.version>1.7.25</slf4j.version>
<logback.version>1.2.3</logback.version>
<taos-jdbcdriver.version>2.0.23</taos-jdbcdriver.version>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutzboot-core</artifactId>
</dependency>
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-nutz-dao</artifactId>
</dependency>
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.taosdata.jdbc</groupId>
<artifactId>taos-jdbcdriver</artifactId>
<version>${taos-jdbcdriver.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutzboot-parent</artifactId>
<version>${nutzboot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<repositories>
<repository>
<id>nutz</id>
<url>http://jfrog.nutz.cn/artifactory/libs-release</url>
</repository>
<repository>
<id>nutz-snapshots</id>
<url>http://jfrog.nutz.cn/artifactory/snapshots</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nutz-snapshots</id>
<url>http://jfrog.nutz.cn/artifactory/snapshots</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
<useIncrementalCompilation>false</useIncrementalCompilation>
</configuration>
</plugin>
<plugin>
<groupId>org.nutz.boot</groupId>
<artifactId>nutzboot-maven-plugin</artifactId>
<version>${nutzboot.version}</version>
</plugin>
</plugins>
</build>
</project>
/**
* 注意 TDengine 表及字段名都为小写字母
*/
@Table("iot_dev")
public class Iot_dev implements Serializable {
private static final long serialVersionUID = 1L;
@Column
@Comment("ID")
@ColDefine(type = ColType.TIMESTAMP)
private Date ts;
@Column("devid") //字段名都为小写字母
@Comment("设备 ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String devId;
@Column("devtype") //字段名都为小写字母
@Comment("设备类型")
@ColDefine(type = ColType.BINARY, width = 32)
private String devType;
@Column
@Comment("状态")
@ColDefine(type = ColType.BOOLEAN)
private Boolean status;
@Column
@Comment("读数 1")
@ColDefine(type = ColType.DOUBLE)
private Double val1;
@Column
@Comment("读数 2")
@ColDefine(type = ColType.INT)
private Integer val2;
@Column
@Comment("读数 3")
@ColDefine(type = ColType.INT,width = 3)
private Integer val3;
@Column
@Comment("读数 4")
@ColDefine(type = ColType.INT,width = 2)
private Integer val4;
}
本插件不同于V5代码生成器插件,无须引入项目中其他jar包,无须事先编译POJO类:
插件下载:
https://gitee.com/budwk/budwk-codegenerator/releases
插件源码:
1、终端设置代理
export http_proxy=socks5://127.0.0.1:1080
export https_proxy=socks5://127.0.0.1:1080
2、安装Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
3、Spotlight 索引占有CPU过高
关闭
sudo mdutil -a -i off
打开
sudo mdutil -a -i on
之前,长期是 ThinkPad 忠实用户,从 X230 、X1 2016直到X1 2019。
X1 2019 太让人失望了(挂闲鱼卖了),首先配置是 i7 10710u + 16G + 1T + 4K,CPU 6核12线程,单核起步频率1.1GHz最高4.7GHz。表现起来还没 X1 2016款来的快,因为它动态调整频率,睿频上下波动。
撸码编译时风扇爆转,吹出的热气烫手,而且风扇口设计不合理,刚好对着鼠标位置的手面吹。夜里稍微多开个任务,那风扇的噪音能把娃吵醒,电池撑死能用两小时,最后20%电量掉电非常快。4K屏幕就是个鸡肋,GPU比较弱,占用资源不说玩LOL掉帧厉害,平时也没啥用途。
用 X1 2019 最悲惨得一次是,死机后SSD硬盘居然坏了,售后免费更换新的,但十几年的数据都丢了(好在部分重要资料有备份),害得我不得不上了群晖 NAS 以保万无一失。自从用 X1 2019, 蓝屏 2 次,死机N次,用得太心累了,提心吊胆的,刚巧看到M1性能评测那么高,下定决心换之。
自从换了 M1,那感受完全不一样,首先性能爆表,编译或玩游戏,CPU占用在10-20%之间,很少超过20%,偶尔一次50%。CPU占用不光低,关键风扇还不转,都不用动一下去散热的!底部外壳冰冷冰冷的,看来也只能通过处理4K视频压CPU来暖手了?
Mac系统上的优势就更不用说了,首先不用去磁盘分区,不用考虑C盘分多少,够不够用啊,D盘分多少?不用关机,X1 2019 Windows 10要等半天电脑才能关掉,有时候很关不掉要强制关机,Mac合上盖子拎起就走。有一次X1睡眠放包里,回到家包里温度很烫都快炸了都感觉,打开一看电量所剩无几,而Mac完全不会。
说到电池,M1的电池非常给力,看两小时视频+浏览一小时网页,玩了一个晚上还剩余82%的电量,以后下班不用带电源线回家了。
软件方面,目前M1用于Java开发足够了,相信后面原生支持M1的应用会越来越多,那时候M1性能可以充分发挥出来。
使用root权限修改文件
sudo vi ~/.bash_profile
vi 操作命令省略,插入如下内容
export MAVEN_HOME=/Users/wizzer/work/server/apache-maven-3.6.3
export PATH=$PATH:$MAVEN_HOME/bin
只读文件强制保存
:wq!
source ~/.bash_profile
解决新窗口和重启找不到mvn命令的问题:
touch ~/.zshrc
open ~/.zshrc
文件内容如下,command+S保存
source ~/.bash_profile