2019年5月13日 星期一

開源 RISC OS Pi 系統 - 初探





1987 開始發展的RISC OS, 終於在2018年10月以Apache 2.0 License 開源,允許商業使用。

近來忙裡偷閒,用樹梅派最新版本 Raspberry Pi 3 Model B+ 安裝了RISC OS PI ,號稱是ARM 架構下快速也易於客制化的作業系統 (A fast and easily customized operating system for ARM devices)。

初步試用, 它的視窗環境用起來執行程式反應很快(相比Raspbian  based X-Window 來說)。

並試了一些常用工具都有替代的APP可以使用
Ex:
  • Nettle(ssh/telnet client)
  • LanMan (Samba client)
  • NetSurf (Browser) ...


不過還需要更多開源高手投入時間進一步改善。

安裝方式是以NOOBS來安裝 RISC OS PI




小結

待機耗電量約在 2.93W (4.89V, 0.6A)運行較吃CPU資源大約升高到 3.9W (4.89V, 0.8A),以一個迷你作業系統而言,還算省電。有興趣的朋友可以裝起來試玩看看。






參考資料


延伸閱讀

2019年5月9日 星期四

DevOps Tip - Got error - not found aws-iam-authenticator for kubectl using?


Problem

I've got error to run kubectl command with aws-iam-authenticator not found

(venv) ➜  k8s git:(develop) ✗ kubectl get pod
Unable to connect to the server: getting credentials: exec: exec: "aws-iam-authenticator": executable file not found in $PATH


Solutions

Installation tool on OSX Mojave

brew install aws-iam-authenticator

Example of installation

 (venv) ➜  k8s git:(develop) ✗ brew install aws-iam-authenticator
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 3 taps (homebrew/core, homebrew/cask and caskroom/cask).
==> New Formulae
..
==> Downloading https://homebrew.bintray.com/bottles/
aws-iam-authenticator-0.4.0.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/52...
######################################################################## 100.0%
==> Pouring aws-iam-authenticator-0.4.0.mojave.bottle.tar.gz
🍺  /usr/local/Cellar/aws-iam-authenticator/0.4.0: 5 files, 31.1MB

References


2019年4月11日 星期四

Python Tip - Examples of initialize variables with sequence number in different ways

Purpose

It is used to collect sample code for python's coding tips of initialization variables.

A. Variables with constants

test_init_vars.py

#!/usr/bin/env python

a=0
b=1
c=2
d=3
e=4
f=5
print(a, b, c, d, e, f)

B. Use range()

test_init_vars_by_range.py

#!/usr/bin/env python

a, b, c, d, e, f = range(6)

print(a, b, c, d, e, f)

C. Use enum since python 3.4 supported

test_init_vars_by_enum.py

#!/usr/bin/env python3.6

from enum import IntEnum,auto

class Vars(IntEnum):
    a=0
    b=auto()
    c=auto()
    d=auto()
    e=auto()
    f=auto()

print("{}, {}, {}, {}, {}, {}".format(Vars.a, Vars.b, Vars.c, Vars.d, Vars.e, Vars.f))

Result

$ python2.7 test_init_vars.py
(0, 1, 2, 3, 4, 5)
$ python3.6 test_init_vars.py
0 1 2 3 4 5

$ python2.7 test_init_vars_by_range.py
(0, 1, 2, 3, 4, 5)
$ python3.6 test_init_vars_by_range.py
0 1 2 3 4 5

$ python2.7 test_init_vars_by_enum.py
Traceback (most recent call last):
  File "test_init_vars_by_enum.py", line 3, in
    from enum import IntEnum,auto
ImportError: cannot import name auto

$ python3.6 test_init_vars_by_enum.py
0, 1, 2, 3, 4, 5

References

2019年3月14日 星期四

Bash Tip - Run Command with multiple arguments with ssh




This is a note for logging my simple way to use ssh and bash with continuous integration on remote server.

You can execute the following test-cases.sh on your host.

It will execute remote script of the test with correct argument contents.

source code of test-cases.sh on host





directory layout of tester account on test-server



source code of tests.sh on test-server




result of test-cases.sh example

source ./test-cases.sh
➜  ~ run_cases "\"1\"\"" "b'\"" "c'#\"" "\"\"" "\'"
ssh test-server cd test-cases; /bin/bash ./tests.sh  "\"1\"\"" "b\'\"" "c\'\#\"" "\"\"" "\\'"
argv[1]=["1""]
argv[2]=[b\'"]
argv[3]=[c\'\#"]
argv[4]=[""]
argv[5]=[\\']

Notes

printf %q  is use to make safe quote the argument if hashtag(#), quote('), double quote(") and so on.

Appendix



2019年2月22日 星期五

Bash Tip - Use bash to implement like C's argc and argv

Test bash script capacity

I want to show how to write the advanced bash script with shift and array.
Feature:

  • filter the arguments with '-' leading character as options
  • the following inputs are the data arguments


Tested environments: - bash 4.3.48 x86_64-pc-linux-gnu ubuntu-16.04.4 LTS

2019年1月30日 星期三

DevOps Tip - How to use terraform apply without prompt and input yes for CI/CD?

Problem

Took a memo about integration of CI/CD applied by terraform without prompt to input 'yes'
It is annoying to input yes every time if you already make sure already by `terraform plan`.
On the other hand, I need to integrate with different system for CI/CD. I need a way to approve it automatically.
By tests with commands official documents, I found the correct command and arguments.

Tested Solutions


    terraform apply -input=false -auto-approve

or as my test, you can shorten to the following command

    terraform apply -auto-approve

Test Environments

  • Ubuntu 16.04.04 LTS
  • OSX 10.14

Reference:




Extended Reading