Skip to content

Instantly share code, notes, and snippets.

var mqtt = require('mqtt');
//{'topicName':[clientObj,clientObj ..]}
var subscribeTopics={};
//创建服务器对象
var server = mqtt.createServer(function(client) {
//建立连接时触发
client.on('connect', function(packet) {
1001 git init
1003 git remote add origin git@github.com:YourUserName/ProjectName.git
1004 git fetch origin
1006 git checkout master

如何追加公钥到目标服务器

命令:

cat id_rsa.pub | ssh target_host "sudo tee -a /home/tom/.ssh/authorized_keys"
@MarshalW
MarshalW / spec.json
Created August 21, 2020 08:25
Vega 5 hello world
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"width": 400,
"height": 200,
"data": [
{
"name": "table",
"values": [
{"date": "2020-08-01", "count": 2109},
{"date": "2020-08-02", "count": 1201},
@MarshalW
MarshalW / spec.json
Created August 21, 2020 09:44
Vega-Lite spec from Fri Aug 21 2020
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {
"values":[
{"date": "2020-08-01", "retention":2341},
{"date": "2020-08-02", "retention":1234},
{"date": "2020-08-03", "retention":1101},
{"date": "2020-08-04", "retention":998},
{"date": "2020-08-05", "retention":543},
{"date": "2020-08-06", "retention":589},
@MarshalW
MarshalW / iperf3.md
Last active October 27, 2020 01:42
iperf3 测试内网节点间速度

服务器端:

iperf3 -s

客户端:

iperf3 -u -c tank -b 100M
@MarshalW
MarshalW / README.md
Created November 22, 2020 10:12
ansible-playbook将a服务器ssh key设置到b服务器

ansible-playbook将a服务器ssh key设置到b服务器

playbook.yml:

---
- hosts: a
  gather_facts: no
  tasks:
 - name: get ssh key
@MarshalW
MarshalW / README.md
Last active November 22, 2020 10:22
使用ssh实现socks5代理

使用ssh实现socks5代理

在linux和macOS下此命令有效:

ssh -D 1337 -q -C -N your_server
  • 假设本地用户ssh key已经设置到your_server
  • 本地1337端口即socks5代理的端口
@MarshalW
MarshalW / README.md
Created November 24, 2020 01:14
清除所有screen session的命令

清除所有screen session的命令

以下命令,macos下测试有效:

screen -ls | grep Detached | cut -d. -f1 | awk '{print $1}' | xargs kill
@MarshalW
MarshalW / README.md
Last active November 24, 2020 01:27
华为S5700交换机忘记密码和恢复出厂设置

华为S5700交换机恢复出厂设置

连接设备

需要连接上一条免驱动的console rj45转usb的连接线。

查看设备:

ls /dev/ | grep usb