2023年7月4日 星期二

powerline

20230704 powerline

ref: link

$ pip3 install --user powerline-status
$ git clone https://github.com/powerline/fonts.git
$ cd fonts; ./install.sh
$ cd -
$ rm -rf fonts
$ python3 -m site --user-site
  • output as ${PYTHON_SITE_PACKAGE_PATH}
$ cd ${PYTHON_SITE_PACKAGE_PATH}
$ mkdir -p scripts
$ cp ../../../bin/* ./scripts/
  • add to ~/.bash_profile
POWERLINE_PATH=`python3 -m site --user-site`
POWERLINE_SCRIPT=$POWERLINE_PATH/powerline/bindings/bash/powerline.sh
if [ -f $POWERLINE_SCRIPT ]; then
$POWERLINE_PATH/scripts/powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
source $POWERLINE_SCRIPT
fi

設定

  • ~/.config/powerline/config.json
{
"ext": {
"shell": {
"theme": "elvis"
}
}
}
  • ~/.config/powerline/themes/shell/main.json
{
"segment_data": {
"hostname": {
"args": {
"only_if_ssh": true
}
},
"cwd": {
"args": {
"dir_limit_depth": 10
}
}
}
}
  • ~/.config/powerline/themes/shell/elvis.json
{
"segments": {
"left": [
{
"function": "powerline.segments.common.net.hostname",
"priority": 10
},
{
"function": "powerline.segments.common.env.user",
"priority": 30
},
{
"function": "powerline.segments.common.time.date",
"args": {
"format": "%H:%M",
"istime": true
},
"priority": 50
},
{
"function": "powerline.segments.common.vcs.branch",
"priority": 40
},
{
"function": "powerline.segments.common.env.virtualenv",
"priority": 50
},
{
"function": "powerline.segments.shell.cwd",
"priority": 10
},
{
"function": "powerline.segments.shell.jobnum",
"priority": 20
},
{
"function": "powerline.segments.shell.last_status",
"priority": 10
}
]
}
}

vim

安裝 vim-airline

  • ~/.vimrc
let g:Powerline_symbols = 'fancy'
let g:airline_powerline_fonts = 1

2020年10月26日 星期一

Access k8s inside NAT

scp ${SERVERIP}:~/.kube/config ./ciconfig
  • add insecure-skip-tls-verify: true
  • remove certificate-authority-data in cluster
apiVersion: v1
clusters:
- cluster:
insecure-skip-tls-verify: true
server: https://{IP}:6443
name: cluster.local

2020年10月8日 星期四

kubernetes 1.18 glusterfs Crash loop

glusterfs cannot be launched in time to reach it's readiness
i.e. systemctl status glusterd.service cannot be ready in 3 seconds.

solution: modify the initial delay seconds to much longer value

diff --git a/contrib/network-storage/heketi/roles/provision/templates/glusterfs-daemonset.json.j2 b/contrib/network-storage/heketi/roles/provision/templates/glusterfs-daemonset.json.j2
index 8934fa92..62ae94a4 100644
--- a/contrib/network-storage/heketi/roles/provision/templates/glusterfs-daemonset.json.j2
+++ b/contrib/network-storage/heketi/roles/provision/templates/glusterfs-daemonset.json.j2
@@ -74,7 +74,7 @@
},
"readinessProbe": {
"timeoutSeconds": 3,
- "initialDelaySeconds": 3,
+ "initialDelaySeconds": 600,
"exec": {
"command": [
"/bin/bash",
@@ -85,7 +85,7 @@
},
"livenessProbe": {
"timeoutSeconds": 3,
- "initialDelaySeconds": 10,
+ "initialDelaySeconds": 600,
"exec": {
"command": [
"/bin/bash",

2019年11月5日 星期二

Icinga2 http check failure

莫名奇妙搞了很久的設定

object Host Dev {
import "generic-host"
address = "dev.examplexxx.com"
vars.http_vhosts["http"] = {
+ http_vhost = "dev.examplexxx.com"
http_verbose = true
http_port = 443
http_uri = "/login"
http_sni = true
http_ssl_force_tlsv1_2_or_higher = true
}
- check_command = "hostalive"
+ check_command = "hostalive4"
}
  1. 可能是我 server 有經過 cloudfront 的關係
    不加 http_vhost 會出問題
    Error message
CRITICAL - Cannot make SSL connection.
23112094376384:error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:../ssl/record/rec_layer_s3.c:1528:SSL alert number 40
SSL initialized
  1. 沒有 ipv6 要改用 hostalive4
    Error message
CRITICAL - Network Unreachable (dev.examplexxx.com)

2018年7月5日 星期四

App Transport Security 測試

客戶的網站設定怪怪的
React Native Webview 沒辦法 load 出他的網頁

找到一篇 SSL certificate Error with App Transport Security

$ nscurl --ats-diagnostics --verbose https://XXX.XXXX.XXX

可以試出來可用的組合

TLSv1.0 with PFS disabled and insecure HTTP allowed
ATS Dictionary:
{
NSExceptionDomains = {
"XXX.XXXX.XXX" = {
NSExceptionAllowsInsecureHTTPLoads = true;
NSExceptionMinimumTLSVersion = "TLSv1.0";
NSExceptionRequiresForwardSecrecy = false;
};
};
}
Result : PASS

再把這些東西設進 plist 就好了

2017年9月22日 星期五

Xcode 9 code signing

20170922 Xcode 9 signing

Xcode9 又把 exportOption 改掉了

平常用的 script

xcodebuild -exportArchive -archivePath ./release/output.xcarchive -exportOptionsPlist ios/export_ship.plist -exportPath ./release

要修改一下 ios/

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>app-store</string>
<key>teamID</key>
<string>XXXXXXXXXX</string>
<key>signingStyle</key>
<string>manual</string>
<key>signingCertificate</key>
<string>iOS Distribution</string>
<key>provisioningProfiles</key>
<dict>
<key>com.your.bundle.id</key>
<string>ProvisioningProfiles name</string>
</dict>
</dict>
</plist>

這次新增了

  • signingStyle
  • signingCertificate
  • provisioningProfiles
    • 這個從 XXXXXX.xcodeproj/project.pbxproj 去找出名字

詳細的選項可以參考 Code Signing Updates in Xcode 9

2017年8月31日 星期四

brew install older keg && watchman issue

20170831 brew install older keg && watchman issue

watchman 卡住怪怪的, 試著裝回舊版

暫時改用舊版

$ cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
  • 找到 4.9.0 的 commit e253d29d759d8e00b46a573d9724ac4d397f5c67
$ git revert e253d29d759d8e00b46a573d9724ac4d397f5c67
  • 重新安裝 watchman 就會從 4.9.0 回 4.7.0 了
$ brew uninstall watchman
$ brew install watchman

再回復 homebrew 原來的 git repo

$ gir reset --hard @~1

結果解決不了 -__-

後來發現 watchman 卡住跑不起來的解法

$ rm -rf /usr/local/var/run/watchman

在 tmux 外重跑

$ brew reinstall watchman
$ watchman version

2016年11月3日 星期四

Netinfo in React Native

20161103 Netinfo in React Native

React Native 判斷 NetInfo 這部份的 API 在兩個平台上不大相容

變得有點奇怪

參考這裡面的作法

src/actions/network.js

setIsConnected: (isConnected: boolean): Action => ({
type: 'setIsConnected',
isConnected,
}),
setConnectType: (connectType: string): Action => ({
type: 'setConnectType',
connectType,
}),

src/reducer/network.js

add corresponding reducer

src/entry.js

constructor(props) {
super(props);
// force reset otherwise could be a problem in persist storage
this.props.actions.setIsConnected(false);
this.props.actions.setConnectType(undefined);
}
componentDidMount() {
NetInfo.addEventListener('change', this.dispatchConnected);
// iOS doesn't have to do this
NetInfo.fetch().done(
connectType => this.dispatchConnected(connectType)
);
}
componentWillUnmount() {
NetInfo.removeEventListener('change', this.dispatchConnected);
}
dispatchConnected = (connectType) => {
let isConnected = false;
if (connectType.toLowerCase() !== 'none' && connectType.toLowerCase() !== 'unknown') {
isConnected = true;
}
this.props.actions.setIsConnected(isConnected);
this.props.actions.setConnectType(connectType);
};

Usage

store.network.isConnect boolean
store.network.connectType string

it could be undefined

2016年7月22日 星期五

build iphone app by command line

20160722 build iphone app by commandline

如果沒使用 CocoaPods 的話, -workspace 可以不用指定

假設 project 名字是 hello

$ cd ios && xcodebuild -workspace hello.xcworkspace -scheme hello -destination generic/platform=iOS -configuration Release -derivedDataPath build
$ ios-deploy -b build/Build/Products/Release-iphoneos/hello.app

然後安裝 ios-deploy

這邊要注意的是 build 成 Release才能獨立執行
如果是 Debug 版需要
修改路徑 Release-iphoneos 成 Debug-iphoneos
而且要使用 --debug 去執行

$ ios-deploy --debug -b build/Build/Products/Debug-iphoneos/hello.app