有趣的Shell字符串


 

#!/usr/bin/env bash
str=$1
if [[ "$str" = "" ]]; then
     echo "1 empty"
fi

if [[ "$str" = " " ]]; then
    echo "2 empty"
fi

if [[ "$str" = "0" ]]; then
    echo "3 empty"
fi

if [[ "$str" = "00" ]]; then
    echo "4 empty"
fi

if [[ "$str" -eq 0 ]]; then
    echo "5 empty"
fi

if [[ "$str" -eq 000 ]]; then
    echo "6 empty"
fi

if [[ "$str" -eq '0' ]]; then
    echo "7 empty"
fi

if [[ "$str" -eq '00' ]]; then
    echo "8 empty"
fi
## show results
1 empty
5 empty
6 empty
7 empty
8 empty
Advertisements

Git撤消操作


撤消操作

任何时候,你都有可能需要撤消刚才所做的某些操作。接下来,我们会介绍一些基本的撤消操作相关的命令。请注意,有些撤销操作是不可逆的,所以请务必谨慎小心,一旦失误,就有可能丢失部分工作成果。

Continue reading “Git撤消操作”

Openssl与数字签名


安全相关的开发工作不可避免的会碰到“数字签名”,“数字证书”等概念,无论是数字签名还是数字证书都跟openssl这个超级厉害开源软件有着千丝万缕的联系。笔者在研究安全启动的过程成中被数字证书这套技术折腾得焦头烂额,本文打算从非对称加密算法说起,分析数字签名、数字证书的来龙去脉,同时会介绍一些Openssl关于证书管理等方面的命令。 Continue reading “Openssl与数字签名”

Python container是什么


Some objects contain references to other objects; these are called containers. Examples of containers are tuples, lists and dictionaries. The references are part of a container’s value. In most cases, when we talk about the value of a container, we imply the values, not the identities of the contained objects; however, when we talk about the mutability of a container, only the identities of the immediately contained objects are implied. So, if an immutable container (like a tuple) contains a reference to a mutable object, its value changes if that mutable object is changed.

Continue reading “Python container是什么”

Python 编码错误根因分析


Python编程特别是网页解析时一定遇到过UnicodeEncodeError、UnicodeDecodeError 错误,每当遇到错误我就拿 encode、decode 函数翻来覆去的转换,有时试着试着问题就解决了,有时候怎么试都解决不了,为了避免下次遇到类似的问题重蹈覆辙,所以需要分析清楚 Python 字符编码错误的根因。 Continue reading “Python 编码错误根因分析”