回国见闻

出国整整3.5年, 真的是豪无意外的生疏了国内的各种规则.

五一黄金周

五一假期的每一天都不适合出游, 注意是每一天, 甚至是最后一天.

我是5月4号抵达香港的, 当时以为是最后2天了, 人应该没有那么多了. 结果证明是自己 too young too naive 了. 那天跑了4家银行, 很多银行门口都是各种办港卡的人, 他们繁忙的在手机上点来点去. 去问银行柜台, 要么被告知今天名额满了, 要么只能办100W资产以上的银行卡.

工银亚洲门口的保安老大爷提示我们可以去某处“远程见证开户”. 于是我风尘仆仆的跑到第一个远程开户点, 发现只有1台机器可以”远程见证开户”, 且人已经排队到网点大门外了. 排了半小时队, 里面终于有1位同胞完成了见证开户出来了. 同胞说, 进去以后系统排队至少还要1小时起, 即使排上了, 办卡业务也得持续1小时起. 于是放弃, 坐港铁来到了第2个可以远程见证开户的点, 幸运的是这里居然没有人排队, 而且有2台机器可以”见证开户”, 于是排队了1小时以后, 终于有了1台空机器, 我进去又排了半小时, 机器终于接通了远程客服. 一顿提交资料, 期间甚至提交了加拿大银行超过百万人民币等值资产的证明. 结果, 竟然被客服告知开户申请被拒了. 此时又过去了整整1个小时.

这天, 抽空下载了汇丰, 中银的App, 尝试在App上申请开户. 汇丰提交成功了, 说是几个工作日以后给出结果. 中银App甚至没有走到最后一步系统就直接提示不满足开户要求. 我TM.

回去的路上, 我暗暗告诉自己, 以后再也不会去办工银亚洲和中银的卡.

人际沟通

很多年前, 跟朋友约饭的时候, 我都会说一句”避开牛蛙和海鲜, 其它我都可以”. 然后吃饭一直都比较开心的. 出国几年以后, 我忘记了这一点.

那晚抵达广州, 朋友擅作主张的选了一家火到不行的必吃榜餐厅, 一去的时候门口就坐满了各种排队的人, 可想而知它家的火爆. 但当真正点餐的时候, 我傻眼了, 它家榜上有名的菜几乎全是海鲜.

结果可想而知, 我尴尬了吃了几只炸虾, 就借口吃饱了. 那晚明明没吃饱, 却只能饿着肚子去朋友家. 路上看到各种小笼包, 各种大排档, 口水都快流出来了.

人口素质

这一点, 真的是国内国外一个样了. 我在香港机场转机的时候, 看到不远处有一个空的坐椅, 于是走过去准备坐下. 但就当我距离那个坐位仅剩2米且低头看了一下手机的时候, 一个大姐以超光速冲到那里并坐了下去. 然后大姐立即用手指的方式告诉不远处的朋友那里还有一个空位置. 当时很无语, 也知道这大姐豪无疑问的是中国人. 因为早有心理预期, 心里上也告诉自己别为了这种事情生气.

随后回到了国内, 也辗转了好几个地方, 发现国内有素质的人还是很多, 甚至是一点也不比国外少.

Read More

Set up self-hosted runners for Github Actions

Add and Install a new runner on our host

Highly recommand run self-hosted runner as a systemd service

# Save settings
./config.cmd --url https://github.com/XXX/MyApp --token XXXXXXXXX

# Lets's deploy a systemd service
# Refer: https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/configuring-the-self-hosted-runner-application-as-a-service
sudo ./svc.sh install

Then, we will see these below

Run as user: zhang3
Run as uid: 1000
gid: 1000
Created symlink /etc/systemd/system/multi-user.target.wants/actions.runner.XXX.service → /etc/systemd/system/actions.runner.XXX.service.

Set up the workflow for our Github Actions

Official Document

https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/adding-self-hosted-runners

https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/configuring-the-self-hosted-runner-application-as-a-service

Read More

Javascript Array

Handle element in an Array

const hobbies = ["sports", "cooking", "reading"];

console.log(hobbies[0]);       # Get single element

hobbies.push("surfing");       # Add new element to the end
hobbies.unshift("movies");     # Add new element to th start

hobbies.pop();                 # remove the last element
hobbies.shift();               # remove the first element

Find element

const index = hobbies.findIndex((item) => {
    return item === "reading"
});
console.log(index);

A shorter code:

const index = hobbies.findIndex((item) => item === "reading");
console.log(index);

// Result
2

Find an element in Object

const inventory = [
  { name: "apples", quantity: 2 },
  { name: "bananas", quantity: 0 },
  { name: "cherries", quantity: 5 },
];

const result = inventory.find(({ name,quantity }) => name === "cherries");

console.log(result); 

// Result:
 { name: 'cherries', quantity: 5 }

find() method ONLY returns the first element in the provided array that satisfies the provided testing function

Filter

const words = ['spray', 'elite', 'exuberant', 'destruction', 'present'];
const result = words.filter((word) => word.length > 6);

// Result:
["exuberant", "destruction", "present"]

Iterate Array

const newHobbies = hobbies.map((item) => item + "!");
consoloe.log(newHobbies);

// Result
(3) ["sports!", "cooking!", "reading!"]

Combine Array

const numbers = [1,2,4,5];
const all = [...hobbies, ...numbers];
console.log(all);

// Result
(7) ["sports", "cooking", "reading", 1, 2, 4, 5]

Destruct an Array

const userName = ["John", "Ted"];

// Old School Way
// const firstName = userName[0];
// const lastName = userName[1];

// New Way
const [firstName, lastName] = ["John", "Ted"];
console.log(firstName);
console.log(lastName);

// Result:
John
Ted

We can also destruct an Object like this:

const {name,quantity} = { name: "apples", quantity: 2 };
console.log(name);
console.log(quantity);

// Result:
apples
2
Read More

Get Ubuntu release code name in Script

$ lsb_release -h
Usage: lsb_release [options]

Options:
  -h, --help         show this help message and exit
  -v, --version      show LSB modules this system supports
  -i, --id           show distributor ID
  -d, --description  show description of this distribution
  -r, --release      show release number of this distribution
  -c, --codename     show code name of this distribution
  -a, --all          show all of the above information
  -s, --short        show requested information in short format


$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.3 LTS
Release:	22.04
Codename:	jammy


$ lsb_release -sc
jammy

$ lsb_release -sr
22.04

Use it in Shell Script

echo "deb http://apt.kubernetes.io/ kubernetes-$(lsb_release -sc) main kubernetes-$(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
Read More

大学回忆录之2023

真不敢相信, 今天是我在这所大学的 last day.

好像昨天还是刚刚入学的日子一样, 时间, 过的真是快啊.

同学们陆陆续续的散去, 这个陕小的教室也终于安静下来了

我是这么的不愿意离开, 这里的回忆简直太多了

初见

那个好看的尼泊尔同学, 名字叫Dipesh, 每次从我身边经过的时候, 我都会偷偷打量他. 每次都在作业的 due date 前一天, 他也会准时在whats app上找我帮忙, 我也很乐意帮忙, 谁叫人家长的好看呢

坐在对角的哥伦比亚大龄同学, 每次路过我的座位的时候, 都要双掌合十, 然后喊我一句”master”

还有我前面那位印度大胡子同学, 叫什么Pavit的, 每次回头看我, 嘴里都要哼着一句我听不懂的印度歌曲, 好像叫什么faya kun的, 这位大胡子同学每次课堂上咳嗽的时候, 嘴里也会小声说一句sorry.

另外一位尼泊尔的同学, 自从我教会了他 how to say fuck you in chinese 以后, 每次见面, 他都要说一句”草拟”…

哦对了, 那位哥伦比亚同学, 也教过我 how to say fuck you in spanish, 好像是什么类似于 ‘budha’ 的发音. 有一次我在休息区说了一句 budha, 他们吓的全跑开了, 也不知道为啥

还有一次, 我记得那是一节 Programming basic 课程, 一个胖胖的男老师, 虽然很胖, 但是眼神里却透露着一股子凶恶的感觉. 那次, 也不知道讲到哪个知识点了, 大胡子 Pavit 同学当场拿着 ChatGPT 的结果上去提出了疑问… 结果, 课间的 Break time 之后, 这位”凶恶”的男老师再也没有回来了…. 后来还是教学主任出马, 把他请了回来. 当然, 不是请回了教室, 只是改为了远程上课了…

还有那个高贵冷艳的 Indigeneous 女生, 平时也懒得搭理我的, 最后的 e-commerce project 却跟她分到了一组, 当时觉得天都塌了, 没想到在做 Project 的时候, 她竟然异常的热情…

太多的回忆了, 数都数不过来…

自己一直是个极其怀旧的人, 大家都走了, 我还一个人坐在这个空荡荡的教室里, 舍不得离开

在这间教室的一年, 是我人生中技术领域进步最快的一年了

也许上北美的老师都很负责吧, 又或者同学们都太努力了, 这一年在各种 Project + Assignment + Quiz 的轮翻轰炸下, 我也算是入了前端的门了. 虽然还是很菜, 但至少, 现在有了能自己写 WordPress 主题的能力了, 也能写出一个简单的 CMS 了. 收获还是大大滴.

Read More