然後發現 .. 我忘記 grafana dashboard 的密碼了 Orz
我的 grafana-server 版本是:
1 | ~$ grafana-server -v |
1 | ~$ sudo sqlite3 /var/lib/grafana/grafana.db |
這樣就可以重置 username 的 password
還蠻 .. 暴力的 XD
筆記一下在 Ubuntu 18.04 上手 Lua 的過程。
Ubuntu 18.04 可以安裝到最新的 Lua 版本是 Lua 5.3
1 | ~$ sudo apt install lua5.3 |
不過要注意的是 Redis 中的 EVAL
版本是 5.1[1]
1 | ~$ sudo apt install libreadline-dev |
1 | ~$ lua |
1 | ~$ vim helloworld.lua |
1 | function helloWorld(name) |
1 | ~$ lua helloworld.lua |
要在 Lua 寫 Unit Test 的話,根據 Unit Testing - lua-users wiki 的範例是使用 bluebird75/luaunit。
1 | ~$ lua -v | awk '{print $2}' |
1 | lua5.3 -v | awk '{print $2}' |
1 | module = {} |
1 | luaUnit = require("luaunit") |
1 | ~$ lua test_helloworld.lua -v |
1 | module = {} |
1 | luaUnit = require("luaunit") |
1 | ~$ lua test_helloworld.lua -v |
1 | snap install microk8s --classic |
1 | microk8s.start |
1 | ~$ sudo snap alias microk8s.kubectl kubectl |
1 | ~$ source <(kubectl completion zsh) |
##
~$ microk8s.kubectl config view --raw > $HOME/.kube/config~$ microk8s.config## kubernetes dashboard: Not enough data to create auth info structure.> kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')
]]>直到 Cloud 9 被 AWS 收購之後,免費方案仍然佛心的維持了一段時間,不過該來的總是要來,最近 c9.io 宣佈將會在 2019 年底停止 c9.io 的服務 :
Cloud9 workspaces will be disabled in 13 days (June 30th, 2019). You will still be able to download and migrate your workspaces until December 31st, 2019.
we plan to discontinue the ability to create new or to use existing workspaces on c9.io on June 30, 2019 and to discontinue all access on December 31, 2019
除了感謝 c9.io 提供這麼好的 cloud IDE 之外,也物色了 c9.io 的替代方案,最終決定落腳 - Codenvy。
Codenvy 是由大名鼎鼎的 Red Hat 提供的 cloud IDE 服務,他是基於 Eclipse Che建構的 SaaS 服務。
平心而論還是 c9.io 用的比較順手、提供的機器運算速度也比較快,不過好消息是 Red Hat 很大方的提供 Codenvy 免費方案 (HOSTED @ CODENVY.IO for DEVELOPER) 總共 3GB RAM (所有建立的 workspace 共享)。
煩惱 c9.io 即將停止服務可以參考 Codenvy :)
或者 AWS Cloud9,同時 c9.io 也有 open source 他們的 core,有動手能力的可以嘗試 c9/core - GitHub
最後也感謝 c9.io 以及 Red Hat 提供的如此優質的 cloud IDE 服務 :)
]]>1 | ~$ sudo /usr/bin/apt update |
My environment is Ubuntu 18.04 (bionic)
1 | ~$ sudo apt install libgtest-dev |
Please refer to the following link:
https://github.com/iwdmb/maxmin-googletest-sample
1 | version=$(go version) |
1 | function funcGoVersion { |
1 | ~$ touch chapsecrets |
1 | Secrets for authentication using PAP |
1 | ~$ sudo docker pull mobtitude/vpn-pptp |
1 | touch vpn.env |
vpn.env reference: https://github.com/hwdsl2/docker-ipsec-vpn-server/blob/master/vpn.env.example
1 | ~$ sudo modprobe af_key |
1 | ~$ vim setup.py |
1 | #!/usr/bin/env python3 |
1 | ~$ vim ~/.pypirc |
1 | [distutils] |
1 | ~$ python3 -m venv ./venv |
解決方法很簡單也很困難,簡單之處在於安裝 gcin-qt5-immodule,難也難在安裝 gcin-qt5-immodule
1 | ~$ sudo apt-get install gcin-qt5-immodule |
輸入之後,會出現錯誤:
1 | ~$ sudo apt-get install gcin-qt5-immodule |
之前裝 LinuxMint 18 的時候有解過一次這個問題。
解決方法如下
1 | sudo apt download gcin-qt5-immodule |
將 tarfile::./control
中的 Depends
由
Depends: gcin-im-client (>= 2.8.6+eliu-0), libc6 (>= 2.4), libgcc1 (>= 1:3.0), libqt5core5a (>= 5.0.2), libqt5gui5 (>= 5.4.1) | libqt5gui5-gles (>= 5.4.1), qtbase-abi-5-5-1
改為:
Depends: gcin-im-client (>= 2.8.6+eliu-0), libc6 (>= 2.4), libgcc1 (>= 1:3.0), libqt5core5a (>= 5.0.2), libqt5gui5 (>= 5.4.1) | libqt5gui5-gles (>= 5.4.1)
wq 儲存
1 | ar r gcin-qt5-immodule_2.8.6+eliu-0_amd64.deb control.tar.gz |
重新執行 gcin 即可。
也可以直接下載我包好的:Download
1 | ~$ md5sum gcin-qt5-immodule_2.8.6+eliu-0_amd64.deb |
索性昨天把系統重新裝成 Kubuntu 18.04 (真心很喜歡 KDE Plasma),不得不說重裝 Unix-like 系統感覺真的超好,重裝 / 保留 /home 的情況,Firefox / Chrome / Opera 全部都不需要重新設定 (設定檔保留於 /home)。
不過裝完 vim 8 之後,遇到一個很大的問題,一直在使用的 vim-copycat(georgefs/vim-copycat)
E319: Sorry, the command isn’t available in this version: python
vim-copycat(georgefs/vim-copycat) 是用於同步系統跟 vim 的剪貼板 (clipboard)
輸入指令:
1 | ~$ vim --version | grep python |
顯示:
1 | +comments +libcall -python +vreplace |
在 Kubuntu 18.04 使用 apt-get 安裝 Ubuntu repository 中的 vim 已經拿掉了 Python 2 的支援,導致 .vim/bundle/vim-copycat/plugin/copycat.vim 使用 Python 2 出現問題
例如:
1 | Error detected while processing /home/ming/.vim/bundle/vim-copycat/plugin/copycat.vim: |
我決定採用解決方式是將 Python 2 的代碼改成 Python 3,下面將一步一步紀錄這個過程。
事前準備:
1 | sudo pip3 install copycat-clipboard |
首先最直觀的根據錯誤紀錄將 .vim/bundle/vim-copycat/plugin/copycat.vim 中的 python 全部取代為 python 3
1 | \:1,$ s/python/python3/g |
儲存之後,接下來打開 vim 錯誤變成:
1 | Error detected while processing /home/ming/.vim/bundle/vim-copycat/plugin/copycat.vim: |
很明顯是 Python 2 的 print 用法,解決的方法很簡單,將所有 copycat.py 中的 print “” 改成 print(“”)
1 | :1,$ s/python/python3/g |
接下來錯誤變成
1 | Error detected while processing function <SNR>36_push_into_clip: |
一樣是 copycat.py,將 copycat.py 中的 smart_str 函數改為:
1 | 19 def smart_str(s, encoding='utf-8', errors='strict'): |
錯誤變成:
1 | Error detected while processing function <SNR>36_push_into_clip: |
將 copycat.py 中的 copy 函數改成:
1 | def copy(value=None, name=None): |
copy 函數正常後,現在已經可以正常複製,接下來 paste 錯誤訊息:
1 | Error detected while processing function <SNR>36_pop_from_clip: |
將 copycat.py 中的 paste 函數修改為:
1 | def paste(name=None): |
打開 copycat_plugin.py 將 set_to_vim 函數改成:
1 | def set_to_vim(name, value): |
完成!
如果不想要手動改的話,可以參考:
https://github.com/iwdmb/vim-copycat
https://github.com/iwdmb/copycat
我 fork 了 vim-copycat and copycat(copycat-clipboard) 使其支援 Python 3 : )
copycat-clipboard3 pypi repository url:https://pypi.org/project/copycat-clipboard3/
]]>1 | /etc/my.cnf |
1 | SELECT user, host, plugin FROM mysql.user; |
1 | mysql > CREATE USER 'username'@'hostname' IDENTIFIED WITH mysql_native_password BY 'password'; |
sort.Ints, sort.Strings, sort.Float64s
sort.SearchInts
sort.SearchStrings
sort.SearchFloat64s
背後是 Binary Search。
int(uint(i+j) >> 1
n == len(slice), f 有點類似 C++ STL std::find_if 的 Predicate。
1 | func Search(n int, f func(int) bool) int { |
1 | func SearchInts(a []int, x int) int { |
思路其實很簡單,由於 VSCode 的設定、插件 .. 等都會在 ~/.vscode
中,所以可以直接移除掉 Portable 的所有檔案,並且下載最新版本移動過去。
有時間可以加上初步比對版本,比較 /VSCode-linux-x64/resources/app/package.json
以及 https://github.com/Microsoft/vscode/releases
的 latest releases 資訊去判斷是否要更新。
vscodePath
是 Visual Studio Code 的路徑。
1 |
|
後來確實使用了不少其它編輯軟體、IDE (Atom, Sublime, VSCode, IDEA),都可以找到 Vim plugin,不需要再重新適應每套軟體各自的快捷鍵。
這篇文章紀錄一下一些 Vim 使用過程中的小 tips,幫助自己快速查閱。
eg. 重複貼 30 行 30p
需要在 VISUAL LINE model 使用
1,$ s/old/new/g
csw"
Hello world! -> “Hello” world!yss"
Hello, world! -> “Hello, world!”
<leader>cc
加注释<leader>cu
解开注释
<leader>c<space>
加上/解开注释, 智能判断<leader>cy
先复制, 再注解(p可以进行黏贴)
會有這篇筆記是因為從國小開始就常常需要幫別人安裝、重灌 Windows 系統,每次都要重新思考需要幫對方安裝哪些軟體,而且很容易就有疏漏因而有了這篇筆記,算是一份 SOP 吧,文章列的軟體基本上是安裝系統必備。
LINE
Skype
Garena Platform
Twitch Curse
重要的兩個 repository
OpenShift Cartridge for Nginx and PHP 7
Custom cartridge for OpenShift providing MySQL 5.7.17
Add Application ...
-> Search by keyword or tag
輸入 openshift-cartridge-nginx-php7
完成之後,進入 application overview 畫面,選 Or, see the entire list of cartridges you can add
在 Install your own cartridge
中輸入 https://raw.githubusercontent.com/icflorescu/openshift-cartridge-mysql/master/metadata/manifest.yml
取得 MySQL Host IP and Port
1 | ~$ echo $OPENSHIFT_MYSQL_DB_HOST |
取得 PHP IP
1 | ~$ echo $OPENSHIFT_PHP_IP |
設定 MySQL
1 | ${OPENSHIFT_DATA_DIR}.mysql/bin/mysql --socket=${TMP}mysql.sock -u root |
1 | ~$ git clone **Source Code ssh url** |
1 | ~$ wget -q -O - https://wordpress.org/latest.tar.gz | tar xz && mv ./wordpress/* ./ && rm -rf ./wordpress |
如果需要上傳附件,需要修改 client_max_body_size 的大小
1 | # Handle any other URI |
1 | ~$ git add -A |
需要修改 php.ini 設定的話
1 | ~$ cd config/php.d |
如果需要上傳附件,要修改 PHP upload_max_filesize
、post_max_size
的大小(PHP7 預設為 2M),例如要將以前的 WordPress Import。
1 | upload_max_filesize = 15M |
1 | ~$ git add -A |
完成之後就可以 git push
到 OpenShift 的 repository 上面。
1 | ~$ git push |
接著打開 Application URL 就可以進行 WordPress 安裝。
比較需要注意的是 Database 的設定,位置請填寫下面指令的結果。
1 | ~$ echo $OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT |
如果要開啟 WordPress FORCE_SSL_ADMIN
1 | ~$ vim app-root/repo/www/wp-config.php |
hexo
這個 blog framework(Static Site Generators)記得之前剛開始使用 hexo
的時候就會遇到一個問題
當標題出現 :
[]
冒號跟括號的時候,在 hexo generate
的時候會有問題
直到在 hexo
的 GitHub Issues 中看到了
開這個 issue 的網友有遇到一樣的問題
Hexo uses directly js-yaml (after some tabulator escaping).
var yaml = require(‘js-yaml’),
escape = require(‘../../util’).escape.yaml;module.exports = function(data){
return yaml.load(escape(data.text));
};
In my eyes, you have two choices:a) use quotation marks, as in title: “my title : with colon” to simply escape the title. There are some more to find in the YAML specs
b) extend the js-yaml library
You wrote “He tried escaping the colon within the title, but doing so had no effect.”… hmm what exactly have you tried? For me option a) worked in a quick test. Following the specs “title: my title : with colon” should work, too, but I didn’t test this one.
sergiolepore 提到:
]]>Use quotation marks. Take a look at this:
透過 ESXi 直接開啟(不透過 ssh),發現一直卡在 initramfs
直接 reboot 沒有用,重新開機還是會直接進到 initramfs,
仔細看一下錯誤訊息,其中
1 | /dev/sda1: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY. |
還好進入 initramfs 模式中還有 busybox-initramfs 可以使用
可以透過 fsck
(file system consistency check) 指令
1 | fsck -y */dev/sda1* |
針對檔案系統進行修復,reboot
之後就正常了。