Wayde's Blog

知识源于积累


  • 首页

  • 关于

  • 分类

  • 标签

  • 个人收藏

  • 归档

  • 搜索

Git tag命令

发表于 2017-11-15 | 分类于 Git
  1. 创建 tag

    git tag -a v1.0 -m '1.0'

  2. 查看 tag

    git tag

    git tag -l 'v1.*'

  3. 推送 tag

    git push origin v1.0

    git push --tags

    git push origin --tags

参考资料:
Git 基础 - 打标签

PostgreSQL ltree扩展

发表于 2017-11-15 | 分类于 PostgreSQL
  1. 查看是否已安装

    select * from pg_extension;

  2. 安装

    create extension ltree;

Linux ln命令

发表于 2017-11-15 | 分类于 Linux

默认情况下,ln命令产生硬链接。

ln [-s] source target

  • 硬链接(Hard Link)

    硬连接指通过索引节点来进行连接。

    在Linux的文件系统中,保存在磁盘分区中的文件不管是什么类型都给它分配一个编号,称为索引节点号(Inode Index)。在Linux中,多个文件名指向同一索引节点是存在的。一般这种连接就是硬连接。

    硬连接的作用是允许一个文件拥有多个有效路径名,这样用户就可以建立硬连接到重要文件,以防止“误删”的功能。其原因如上所述,因为对应该目录的索引节点有一个以上的连接。只删除一个连接并不影响索引节点本身和其它的连接,只有当最后一个连接被删除后,文件的数据块及目录的连接才会被释放。

    也就是说,文件真正删除的条件是与之相关的所有硬连接文件均被删除。

    硬连接的2个限制:

    1. 不允许给目录创建硬链接
    2. 只有在同一文件系统中的文件之间才能创建链接。 即不同硬盘分区上的两个文件之间不能够建立硬链接。这是因为硬链接是通过结点指向原始文件的,而文件的i-结点在不同的文件系统中可能会不同。
  • 符号链接(Symbolic Link)

    软链接文件有类似于Windows的快捷方式。它实际上是一个特殊的文件。在符号连接中,文件实际上是一个文本文件,其中包含的有另一文件的位置信息。

    ​ 这就允许符号链接(经常简写为symlinks)指向位于其他分区、甚至是其他网络硬盘上的某个文件

参考资料:
linux硬链接与软链接

Nginx 监听多ip端口

发表于 2017-11-15 | 分类于 Nginx
1
2
3
4
5
6
server {
listen 10.11.26.3:80;
listen 127.0.0.1:80;
server_name www.domain.com;
...
}

参考资料:
nginx docs

PostgreSQL 显示/隐式提交

发表于 2017-11-15 | 分类于 PostgreSQL
  1. 查看当前是否自动提交

    \echo :AUTOCOMMIT

  2. 关闭/开启自动提交

    \set AUTOCOMMIT off/on

  3. 手动处理事务

    begin;

    do dml...

    rollback;

    end; or commit;

Ubuntu 添加开机启动脚本

发表于 2017-11-03 | 分类于 Ubuntu
  1. rc.local脚本

    sudo vim /etc/rc.local

    在exit 0之前添加命令或者shell脚本

  2. update-rc.d增加开机启动服务

    touch /etc/init.d/wayde_service

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    #!/bin/bash

    ### BEGIN INIT INFO
    # Provides: wayde
    # Required-Start: $network $local_fs $remote_fs
    # Required-Stop: $network $local_fs $remote_fs
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Custom startup items for wayde
    # Description: Rt

    ### END INIT INFO

    # for openvpn
    /usr/sbin/openvpn --config /etc/openvpn/config/server.conf --daemon

    exit 0

    chmod +x wayde_service

  3. 添加到启动脚本

    update-rc.d wayde_service defaults 90

  4. 移除启动脚本

    update-rc.d -f wayde_service remove

  5. 通过service命令管理脚本

    sudo service wayde_service status
    ​sudo service wayde_service start
    ​sudo service wayde_service stop
    ​sudo service wayde_service restart

  6. 在/etc/init.d/下新建启动脚本,在 /etc/rc2.d/ 下用软链接,链接此脚本即可。

    /etc 下有 rc0.d – rc6.d

    分别代表不同的级别:

    0: 关闭计算机
    1: 单用户模式
    2: 无网络多用户模式
    3: 有网络多用户模式
    4: 保留作自定义,否则同运行级 3
    5: 同运行级 4,一般用于图形界面(GUI)登录(如 X的 xdm 或 KDE的 kdm)
    6: 重启动计算机

参考资料:
Ubuntu 16.04设置rc.local开机启动命令/脚本的方法
什么是 LSB
linux (debian) 设置开机自启动

Ubuntu 重启搜狗输入法

发表于 2017-11-03 | 分类于 Ubuntu
  1. 强制kill进程

    ps -ef | grep 'sogou-qimpanel' | awk '{print $2}' | xargs kill -9

  2. 启动服务

    fcitx

Windows 通过Putty+SSH代理

发表于 2017-11-03 | 分类于 Windows
  1. 下载putty

  2. 配置putty:Connection->SSH->Tunnels

    在Putty的登录设置中配置tunnel,目标设置为Dynamic,添加一个端口7070,点击Add,一个动态转发端口就实现了。

    然后用相应帐号SHH登录后:除了登录的终端窗口以外,本地的7070连服务器的22端口之间就有了一个SSH加密的转发通道了。

  3. Chrome插件 SwitchyOmega

参考资料:
利用PuTTY+SSH端口转发实现加密代理上网

Python 判断字符串是否数字

发表于 2017-11-02 | 分类于 Python
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
num = "1"  #unicode
num.isdigit() # True
num.isdecimal() # True
num.isnumeric() # True

num = "1" # 全角
num.isdigit() # True
num.isdecimal() # True
num.isnumeric() # True

num = b"1" # byte
num.isdigit() # True
num.isdecimal() # AttributeError 'bytes' object has no attribute 'isdecimal'
num.isnumeric() # AttributeError 'bytes' object has no attribute 'isnumeric'

num = "IV" # 罗马数字
num.isdigit() # True
num.isdecimal() # False
num.isnumeric() # True

num = "四" # 汉字
num.isdigit() # False
num.isdecimal() # False
num.isnumeric() # True

===================
isdigit()
True: Unicode数字,byte数字(单字节),全角数字(双字节),罗马数字
False: 汉字数字
Error: 无

isdecimal()
True: Unicode数字,,全角数字(双字节)
False: 罗马数字,汉字数字
Error: byte数字(单字节)

isnumeric()
True: Unicode数字,全角数字(双字节),罗马数字,汉字数字
False: 无
Error: byte数字(单字节)

================
import unicodedata

unicodedata.digit("2") # 2
unicodedata.decimal("2") # 2
unicodedata.numeric("2") # 2.0

unicodedata.digit("2") # 2
unicodedata.decimal("2") # 2
unicodedata.numeric("2") # 2.0

unicodedata.digit(b"3") # TypeError: must be str, not bytes
unicodedata.decimal(b"3") # TypeError: must be str, not bytes
unicodedata.numeric(b"3") # TypeError: must be str, not bytes

unicodedata.digit("Ⅷ") # ValueError: not a digit
unicodedata.decimal("Ⅷ") # ValueError: not a decimal
unicodedata.numeric("Ⅷ") # 8.0

unicodedata.digit("四") # ValueError: not a digit
unicodedata.decimal("四") # ValueError: not a decimal
unicodedata.numeric("四") # 4.0

#"〇","零","一","壱","二","弐","三","参","四","五","六","七","八","九","十","廿","卅","卌","百","千","万","万","亿"

参考资料:
python中str函数isdigit、isdecimal、isnumeric的区别

创建pyenv virtualenv项目环境

发表于 2017-11-02 | 分类于 Python

pyenv : Python版本管理器

virtualenv : Python虚拟环境

  1. 安装python

    pyenv install 3.5.3 -v

    pyenv rehash

  2. 创建虚拟环境

    pyenv virtualenv 3.5.3 env_box_server_py3

  3. 设置环境

    pyenv local env_box_server_py3

  4. 安装python依赖包

    pip3 install -r requirements.txt

1…101112…14
Wayde

Wayde

140 日志
14 分类
112 标签
GitHub StackOverflow Instagram
© 2012–2022 Wayde
粤ICP备2020135844号