Skip to content

Instantly share code, notes, and snippets.

extension Character {
var asciiValue: UInt32? {
return String(self).unicodeScalars.filter{$0.isASCII}.first?.value
}
}
func sort(str: String, isReversed: Bool) -> String {
if (isReversed) {
return String(str.characters.sorted(by: compareCharactersReversed))
}
ssh-keygen -t rsa
# Enter file in which to save the key (/home/ivan/.ssh/id_rsa):
# key 儲存位置, 如果沒有特別要改地方, 按Enter即可
# Enter passphrase (empty for no passphrase):
# 是否要設定key的密碼, 不用的話按Enter即可
# Enter same passphrase again:
# 再次設定密碼, 上一部沒有設定的話按Enter即可
@griiid
griiid / _.bash
Last active March 18, 2021 08:34
MODE=development
DBHOST=localhost
DBPORT=5432
DBCONN_STR=${DBHOST}:${DBPORT}
MODE=development
DBHOST=localhost
DBPORT=5432
export DBHOST=localhost
export DBPORT=5432
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
os.getenv('DBCONN_STR')
@griiid
griiid / _.py
Last active March 18, 2021 13:33
# 對齊開頭分隔符號
foo = long_function_name(var_one, var_two,
var_three, var_four)
# 要多縮排一次來區分
def long_function_name(
var_one, var_two, var_three,
var_four):
print(var_one)
@griiid
griiid / _.py
Last active March 18, 2021 13:35
# 沒有垂直對齊時,第一行不應該有參數
foo = long_function_name(var_one, var_two,
var_three, var_four)
# 其他行要多縮一次縮排,不然沒辦法跟再下一層的內容分開
def long_function_name(
var_one, var_two, var_three,
var_four):
print(var_one)
# 不額外做縮排
if (this_is_one_thing and
that_is_another_thing):
do_something()
# 加入註解,可以在支援語法凸顯的編輯器中將兩者區分開來
if (this_is_one_thing and
that_is_another_thing):
# Since both conditions are true, we can frobnicate.
do_something()