文章90
标签1
分类38

创建窗口,批量执行语句

for i in {1..15}; do
tmux split-window -h
tmux select-layout tiled
done
tmux select-pane -t 0
for i in {1..4}; do
for j in {1..4}; do
tmux split-window -v
tmux select-layout tiled
done
tmux select-pane -t $((i*4))
done
tmux attach -t 名字
tmux select-layout tiled
for i in {0..15}; do
tmux select-pane -t $i
tmux send-keys C-c # Ctrl+C
tmux send-keys Enter
done
tmux attach -t 名字
tmux attach -t 名字
tmux select-layout tiled
for i in {0..15}; do
tmux select-pane -t $i
tmux send-keys "cd 路径$((i+1))" Enter
done
tmux attach -t 名字
tmux attach -t 名字
tmux select-layout tiled
for i in {0..15}; do
tmux select-pane -t $i
tmux send-keys "python main.py" Enter
sleep 3
tmux send-keys "120" Enter
sleep 3
tmux send-keys "1" Enter
sleep 3
done
tmux attach -t 名字

内部重启执行fuction,setInterval()

结构setInterval(functionnname,时间) //时间毫秒为单位

function jiafa(b){
    a=0
    a+=1
    console.log(a);
    console.log(b);
}
setInterval(jiafa,1000)
// 1
// undefined
// 1
// undefined
// 1
// undefined

// 每一次都素重启,不会连续执行


// 可以命名为赋值给其他参数,以至于可以停止
const function1=setInterval(jiafa,1000)
setTimeout(function(){
    clearInterval(function1)
},5000)
//定时5s后停止



// 如果需要传参数,那么就调用的时候
b=3
const function2=setInterval(function(){
    jiafa(b)
},1000)

// 1
// 3
// 1
// 3
// 1
// 3

nodejs includes用法

// 注意字符串定义的时候使用 ` `
const text1=`如果再给我一次机会`
const text2=`我会重新选择`

//这里就查看有没有`机会`这个词语
function ifinclude(text){
if(text.includes("机会"))
{
    console.log("包含机会:"+text);
}                        }
ifinclude(text1)
//包含机会:如果再给我一次机会
ifinclude(text2)
//无返回内容


// 数组里是否含一个元素
const arry=["red","blue"]
console.log(arry.includes("red"));
//返回布尔 true
console.log(arry.includes("green"));
 //返回布尔 false
[字符串includes][1]
 [数组includes][2]

Nodejs获取本地时间Date()

    console.log(Date());
    //返回的是一个字符串,包括所有属性
    //Wed Jul 26 2023 23:22:31 GMT+0800 (中国标准时间)

    //前面加个new,==>new Date() 返回一个表示当前日期和时间的日期对象。可以单独返回日期,星期....
    console.log(new Date());
    //2023-07-26T15:23:41.186Z

    //将他时间格式化就所有toLocaleString()
    console.log(new Date().toLocaleString());
    // 2023/7/26 15:23:41

    //返回年份.getFullYear()
    console.log(new Date().getFullYear());

将时间戳转换为本地时间使用new Date(时间戳)

const timestamp = 1690033752000;
console.log(new Date(timestamp));
//2023-07-22T13:49:12.000Z
console.log(new Date(timestamp).toLocaleString());
// 2023/7/22 21:49:12

获取当前的时间戳

使用getTime()
console.log(new Date().getTime());
console.log(new Date(new Date().getTime()));
// 1690392074150
// 2023-07-26T17:21:14.153Z

多少时间前的时间轴

一般为毫秒结尾
那么3分钟前就可以这样找

console.log('现在时间戳:'+new Date().getTime());
console.log('3分钟前时间戳:'+(new Date().getTime()-3*60*1000));//记住秒 * 1000(毫秒时间戳)
// 这里+后面如果计算后需要使用()取值再返回给console.log !括号来确保优先级
// 现在时间戳:1690393652833
// 3分钟前时间戳:1690393472836

更多教程Date()

ndoejs数据库操作

1.插入数据库

👉🏻这篇文章连接数据库就使用pool表示后面
Snipaste_2023-07-24_00-15-13.png

插入操作//query返回数据库给他再操作

    //这里【字段1,字段2,字段3】必须对应,如果插入的数据默认的 
    //话,可以不写进来字段,但是数据库必须设置默认值
      //这里如果使用??传递内容那么后面就括在[里面]==[插入内容对字段1,插入内容对字段2,插入内容对字段3]
   pool.query("INSERT INTO 表名(字段1,字段2,字段3) VALUES(?,?,?)", 
    [插入内容对字段1,插入内容对字段2,插入内容对字段3],function(error,result){     
      if (error) {
         console.log(error);
     }else{
        console.log(result);
     }
  })
 }

插入详细教程

根据某个值查询对于数据,查找数据

Snipaste_2023-07-26_22-17-26.png

pool.query("SELECT 需要查找的字段 FROM 表名 WHERE 条件",function(error,result){
    if (error) {
        console.log(error);
    }else{
    console.log(result);//注意结果是数组表示,如果取第一个就result[0]
    }
})
// 需要查找的字段(如果全部的话就只写一个* 如果需要查找多个的话就逗号隔开[字段1,字段2...])
// 条件{字段对于值[如:id=1,如果多个条件,那么使用'AND'连接->(ID=1 AND NAME=XIAOBAI....)]}
//可以将对于值使用?代替,在外免使用一个[值1,值2]装下,占据一个位置,如下   只占据一个位置
pool.query("SELECT allpay FROM 表名 WHERE id=? AND balance=?",[110,26],function(error,result){
    if (error) {
        console.log(error);
    }else{
    console.log(result);//注意结果是数组表示,如果取第一个就result[0]
    }
})

一般查询条件

时间条件:
//假如查询间隔时间在当前时间在x分钟内的数据使用DATE_SUB函数,NOW()代表当前时间
//DATE_SUB(从什么时间开始查询,INTERVAL 数字 MINUTE..),这个函数是查询从【从什么时间开始查询】到间隔【数字 MINUTE】前的数据,INTERVAL是间隔的意思

DATE_SUB具体教程看我

//我们要查询间隔时间在当前时间在x分钟内的数据就TIME>=DATE_SUB(从什么时间开始查询,INTERVAL 数字 MINUTE..)就可以了
pool.query("SELECT allpay FROM 表名 WHERE  TIME>=DATE_SUB(NOW(),INTERVAL 5 MINUTE)",....)

更新数据

UPDATE 表名 SET 需要更新的字段=? WHERE 条件
//这里的【需要更新的字段=?使用比较运算,如:id=id+1 就是原始数据+1】

UPDATE详细教程

筛选数据

                            【排序字段:筛选的数据就和它排序一致】
"SELECT *FROM 表名 WHERE ueserid=值 ORDER BY 排序字段 DESC LIMIT 数据个数"
                                                    【DESC:降序的意思】【LIMIT:限制几条】
 "SELECT * FROM table LIMIT 数据个数"

更多排序方式

多条件的话括号括起来,避免混淆 这里如果不括起来,那么就是前后2条件了

          "SELECT *FROM 表名 WHERE (id=值 or NAME=XIAO)  ORDER BY 排序字段 DESC LIMIT 数据个数"


">