Skip to content

Instantly share code, notes, and snippets.

@MarshalW
MarshalW / io.js
Created January 11, 2017 11:31
dd命令在nodejs中的调用
// from http://stackoverflow.com/questions/36934749/how-to-get-the-output-of-a-spawned-child-process-in-node-js
var spawn = require('child_process').spawn;
// Create a child process
var child = spawn('dd', ['if=/dev/zero','of=/tmp/test1.img','bs=100m','count=1','conv=noerror,sync']);
child.stdout.on('data',
function(data) {
console.log('ls command output: ' + data);
});
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
Last active December 24, 2020 09:11
在 Raspbian 监控 cpu温度

在 Raspbian 监控 cpu温度

命令行:

watch 'head -n 1 /sys/class/thermal/thermal_zone0/temp | xargs -I{} awk "BEGIN {printf \"%.2f\n\", {}/1000}"'

或者:

@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 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
Created November 24, 2020 01:14
清除所有screen session的命令

清除所有screen session的命令

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

screen -ls | grep Detached | cut -d. -f1 | awk '{print $1}' | xargs kill