GraphQL 笔记

GitHub GraphQL API

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
{
  user(login: "laijingwei") {
    starredRepositories(last: 5) {
      nodes {
        name
        url
      }
    }
  }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
query SearchMostTop10Star($queryString: String!) {
  search(query: $queryString, type: REPOSITORY, first: 10) {
    repositoryCount
    edges {
      node {
        ... on Repository {
          name
          descriptionHTML
          stargazers {
            totalCount
          }
          forks {
            totalCount
          }
          updatedAt
        }
      }
    }
  }
}

Webstorm 增加 Chrome 支持

https://bsgoalsmartcloud.oss-cn-shenzhen.aliyuncs.com/uPic/image-20210918113046927.png

nrm

NPM registry manager

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
yarn global add nrm

$ nrm ls

* npm ------- https://registry.npmjs.org/
  yarn ------ https://registry.yarnpkg.com
  tencent --- https://mirrors.cloud.tencent.com/npm/
  cnpm ------ http://r.cnpmjs.org/
  taobao ---- https://registry.npm.taobao.org/
  nj -------- https://registry.nodejitsu.com/
  skimdb ---- https://skimdb.npmjs.com/registry

$ nrm use cnpm  //switch registry to cnpm

    Registry has been set to: http://r.cnpmjs.org/

concurrently

node.js 并发库

1
2
yarn add -D concurrently
npx concurrently "command1 arg" "command2 arg"

In package.json, escape quotes:

1
"start": "concurrently \"command1 arg\" \"command2 arg\""

git filemode 关闭

有时候会遇到因为 chmod 权限变化导致文件无修改却显示全部文件有变动

1
2
3
4
5
6
7
8
9
# 全局配置列表
git config --global --list

# 当前仓库配置列表
git config --list
git config --edit

# 修改如下选项
core.filemode=false

showdoc

1
2
3
mkdir ./showdoc_data/html
chmod -R 777 ./showdoc_data
docker run -itd --name showdoc --restart always -p 8140:80 -v ~/WWW/docker/showdoc/showdoc_data/html:/var/www/html/ star7th/showdoc

linux 文本倒序排列

1
sed -i '' '1!G;h;$!d' test.md

webpack 编译内存不足

1
export NODE_OPTIONS=--max_old_space_size=4096

strapi docker

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# sqlite
docker run -itd --name strapi -p 1337:1337 --restart always -v `pwd`/app:/srv/app strapi/strapi:alpine

# mysql
docker run -itd \
  --name strapi \
  --restart always \
  -e DATABASE_CLIENT=mysql \
  -e DATABASE_NAME=strapi \
  -e DATABASE_HOST=192.168.110.165 \
  -e DATABASE_PORT=3306 \
  -e DATABASE_USERNAME=strapi \
  -e DATABASE_PASSWORD=AAs3WnNZSKseRKGt \
  -p 1337:1337 \
  -v `pwd`/app:/srv/app \
  strapi/strapi:alpine

strapi 连接公网数据库,需在根目录创建 .env 配置文件

1
2
3
4
5
6
7
# tencent cloud database
docker run -itd \
  --name strapi \
  --restart always \
  -p 1337:1337 \
  -v `pwd`/app:/srv/app \
  strapi/strapi:alpine

VirtualBox 命令行添加端口转发

1
2
3
4
5
6
7
8
# 虚拟机关闭状态下
vboxmanage modifyvm "kubesphere_default_1628589687327_98836" --natpf1 "kubesphere,tcp,,30880,,30880"

# 虚拟机运行状态下
vboxmanage controlvm "kubesphere_default_1628589687327_98836" natpf1 "kubesphere,tcp,,30880,,30880"

# 列出虚拟机下所有端口转发列表
vboxmanage showvminfo "kubesphere_default_1628589687327_98836" --machinereadable | awk -F '[",]' '/^Forwarding/ { printf ("Rule %s host port %d forwards to guest port %d\n", $2, $5, $7); }'

docker 修改 hosts方法

使用docker run运行一个新的容器的时候,通过参数 --add-host来添加域名和IP信息到容器的/etc/hosts文件中。例如:

1
docker run -it --name test --add-host=myhostname:10.180.8.1 debian

注意:--add-host参数最好在--name后面,避免启动报错

在docker-compose.yml文件中,通过配置参数extra_hosts实现。例如:

1
2
3
extra_hosts:
 - "somehost:162.242.195.82"
 - "otherhost:50.31.209.229"

docker 配置文件

1
2
echo '{ "insecure-registries":["docker.local.laijw.com"] }' > /etc/docker/daemon.json
echo '192.168.110.19 mysql' >> /etc/hosts

docker 查看容器日志

1
2
docker logs rap2-server
docker exec -it rap2-server sh

docker portainer 更新

1
2
3
docker pull portainer/portainer-ce
docker stop portainer && docker rm portainer
docker run -d -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce

mac 重置启动台图标

1
defaults write com.apple.dock ResetLaunchPad -bool true && killall Dock

KubeSphere

面向云原生应用的 容器混合云

1
2
3
4
5
6
7
curl -sfL https://get-kk.kubesphere.io | VERSION=v1.1.1 sh -
chmod +x kk
yum install -y conntrack-tools
./kk create cluster --with-kubernetes v1.20.4 --with-kubesphere v3.1.1

# 查看管理后台入口
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f

CSS 黑暗模式

1
2
3
html {
  filter: invert(1);
}

CentOS 初始化

1
2
3
4
yum install -y net-tools git vim
curl -fsSL https://get.docker.com | bash -s docker --mirror aliyun
curl -L "https://github.91chifun.workers.dev/https://github.com//docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose && ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

Nginx alias

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
        server {
            listen       10081;
            server_name  localhost;
            location / {
                root   /home/data/site/smart_coloud_fe_common_html/;
                index  index.html index.htm;
            }
            location /download {
                alias  /home/data/site/smart_coloud_fe_common_download/;
                index  index.html index.htm;
            }
            location /weapp {
                alias  /home/data/site/smart_coloud_fe_common_weapp/;
                index  index.html index.htm;
            }
   location ~* ^/(parking-service|parking|lightpole|deviceaccess|faceRecognition|passageway|organization|passageway|elevator|operate|config|deviceinfo|operational-services|operate-service|transmission|owner|door-service|auth|logout|user-service|owner-service|organization-service|base-info-service|baseinfo|gateway|operational-services|organization-service|owner-app-service|owner-service|passageway-service|property-service|smart-cloud-open-service|user-service|authserver|base-info-service|datatran-service|device-info-service|device-service|door-service|elevator-service|door|property|deviceaccess-service) {
                        proxy_pass http://127.0.0.1:8888;
                        proxy_connect_timeout 120s;
                        proxy_send_timeout 120s;
                        proxy_read_timeout 120s;
                        proxy_set_header X-Real-IP $remote_addr;
                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                }
#           error_page   500 502 503 504  /50x.html;
#           location = /50x.html {
#               root   html;
#           }
        }

JavaScript 短语法

1
2
3
console.log(maybeSomething ?? "Nothing found")
console.log(student?.address?.ZIPCode)
isReady && doSomething();

transfer.sh

transfer.sh, Easy and fast file sharing from the command-line.

1
docker run -d --restart always --name transfer -p 8120:8080 -v ~/WWW/docker/nas/oss:/tmp dutchcoders/transfer.sh:latest --provider local --basedir /tmp/

上传文件

1
curl --upload-file ./logo.png http://oss.local.laijw.com

Jetbrains youtrack

youtrack, 为敏捷团队打造的项目管理工具

1
2
3
4
5
6
7
docker run -itd --restart always --name jetbrains-youtrack \
    -v "$(pwd)/data:/opt/youtrack/data" \
    -v "$(pwd)/conf:/opt/youtrack/conf" \
    -v "$(pwd)/logs:/opt/youtrack/logs" \
    -v "$(pwd)/backups:/opt/youtrack/backups" \
    -p 8500:8080 \
    jetbrains/youtrack:2021.3.21051