Monday, 14 January 2019

Publish Vuejs to gitlab pages tutorial

Vue.js is a highly acknowledged web application development framework competing against Google Angular and Facebook React. Gitlab is a git-repository website like github. It has been doing a lot engineering work to make integration easier between repository and static pages deployment for startups and community since Microsoft acquired github in 2018.

In this tutorial, we will walk you through deploying compiled Vue.js file to gitlab pages. Vuejs 3.0 or above is used. Lower version also works but with different config file and option(s). Please refer to Vuejs documentation.

As for gitlab pages, we use project page instead of personal/organizational page. Gitlab supports third party domain name, so it really does not makes big difference from engineering perspective.

We are starting from gitlab repository setup as following steps. And for your information, the example git repository is shared to you here.

1): Create a gitlab repository. Assume you are "hawwah"(Eve). So your gitlab user name is it as well. and the your repository name is applegarden.

2):Create a new file .gitlab-ci.yml in this repository through gitlab web page. This is a simple tutorial, so we are not going to maintain more complex CI/CD script in this file and it will be in the list of ".gitignore".
YML:
# This file is a template, and might need editing before it works on your project.
# Full project: https://gitlab.com/pages/plain-html
  pages:
    stage: deploy
    script:
    - mkdir .public
    - cp -r * .public
    - mv .public public
    artifacts:
      paths:
      - public
    only:
    - master



3): We now clone it locally as below.

Bourne Shell:
  git clone https://gitlab.com/hawwah/applegarden /path/to/localAppleGarden

4): Goto your Vue project directory and edit the package.json file
Bourne Shell:
  cd /path/to/vueproject
  nano package.json


Find section "script" and add a new line in it so as the section like below:
Javascript code:
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "publishGitlab": "vue-cli-service build --dest /path/to/localAppleGarden",
    "lint": "vue-cli-service lint",
  }



Create a file in your Vue project directory with name "vue.config.js" which contain below source.
Javascript code:
  module.exports = {
    publicPath: "/applegarden"
  }


5): Then you build the project by below command
Bourne Shell:

  npm run publishGitlab


6): Now we go to compiled source and push them to gitlab origin.

Bourne Shell:

  git add --all
  git commit -m "Blahblahblah"
  git push origin master


7): At last, we can goto gitlab.com and the CI/CD as below screen shot.

Click the running status link, below screen shot showing that gitlab is copying the files to the "pubic" directory of a docker machine. Also you can goto serveless or kubernetes in GCP and got $300 credit directly through the native integration with GCP Kubernetes engine. Fantastic job, gitlab!


Finally, we can check deployed pages at "https://gitlab.io/hawwah/applegarden".

That's all. And you can further customize the page URL to your own domain. Even accelerate by deploying to cloudflare.com, free! But it is different topic we are going to cover it next blog. Then I will update here a link. Stay tune!

Saturday, 8 December 2018

Is the rule of applying Long Arm Jurisdiction Statue broken?

The case against Ms. Meng Wanzhou is an application of Long Arm Jurisdiction Statue(LAJS). According to the accusation from Eastern NewYork (EDNY) court, the alleged fact breaking US law happened in Hongkong and the defendent is not a US citizen.

According to multiple authoritative sources[1], In Asahi Metal Industry Co. v. Superior Court, 480 U.S. 102 (1987), the Supreme Court clarified that even when the defendant has a minimum contact, a court's asserting jurisdiction over the defendant may still be improper as it would be unfair to the defendant. LAJS applicability here can be a subject which shall be retrospected seriously.

1): The legal basis of the accusation is possibly be either US domestic or UN resolution. But Eastern Newyork court is a US legal branch and not likely to be authorized by UN, we can safely assume it is US domestic law. To verify the statement, the original EDNY record needs to be obtained. A PACER account could be helpful if you have a credit card.

2): Even if the legal basis is a UN resolution, EDNY needs to follow a UN process to issue a warrant and request Canadian's extradition. If such a process is there for EDNY is out the discussion scope, so the assumption that this is a US domestic legal action is legitimate and reasonable.

3): So the fundamental purpose of the legal action is the national interests of US, even if Huawei's business is considered as a critical threaten to national security. It is unavoidable that there are conflicts each other between different countries such as China and US. Many of us has a opinion that Human Rights is superior to national sovereignty. If such a domestic legal action is viewed as part of national sovereignty, at least it shall respect Human Rights when applying LAJS.
  
4): The accusation against Ms Meng is not likely delivered to her before the Warrant is requested to Canadian legal organization. At least, Ms Meng is not aware of the accusation before her being arrested. Then before the judgement, it might take days, months, even years for legal process. It is obviously unfair to Ms Meng.

 5): Canadian's extradition to US for LAJS rationality shall be specifically considered and carefully reviewed. Unfortunately, I am not a legal professional and is not able to obtain historical case details and not so much public discussion going around main stream public media.

LAJS is a common practice in international affairs resolution, special interests preference is human weakness. Governments are very strong enforcement existence. So the application of LAJS shall be escalated to international community to prevent the chaos to lead to breaking of peace and harm to  human rights.

Wednesday, 18 April 2018

中美两国政府都已经被操纵民粹的政客控制

美国贸易战禁售芯片,实际是和中国人竞争智商。这是非常愚蠢的行为。民主系统的设计本身就是针对人性弱点的,防止了单纯的智商竞争行为。遗憾的是,民主系统只是国家内部才有强制效力。所以只要大国争霸,这是不可避免的宿命。要美国人放弃MAGA,搞世界大和平,三战不爆发,真的很困难。

关于台湾统独,只是名词而已。举个例子,冰岛是个国家吗?它并没有自己的军队。中国民间应寻求台湾放弃军事,由中国接管,同时中国支持台湾以国家的名义参加联合国。如果能通过这种方式寻找联盟,则有望破冰。

对台湾可以这样,对香港也可以这样,甚至新疆,西藏,都没有什么问题,前提是这些国家如果互相开放,必须互相尊重,制定平等的法律和程序。不可出现今日之香港怪现象,港人随便进出大陆,外国人随便进出香港,大陆人反而需要签证来管理。甚至买奶粉都要限购。

Tuesday, 27 February 2018

修宪背景下的人民,国家,政治

修宪是个大事。所以有必要搞清楚是好事还是坏事,通常这需要价值观和由此而来的评判标准。

最近读了一篇文章,把政府分为专制政府,民主政府。专制政府再分为集中式皇权专制,分散式土豪专制。认为根据中国的历史和文化,从分散式土豪专制,不可能进步到民主政府,集中式皇权专制如果碰到开明“君主”的话,是有可能的。姑且称之为一号开明专制好了。似乎这是中国唯一的出路。

目前中国共产党和中央政府的威权定义中,三权分立等民主制度,似乎不能算民主,至少是不符合国情的民主。那么一号开明专制的目标似乎在很多人眼中就不是民主了,更不用说什么唯一的出路了,那根本就是此路不通。然而,不同的人对民主的定义不同,在公众空间讨论这个,也不能强求共产党接受西方的民主体系。所以多来几回合解构人民,国家,和历史概念,厘清人性和历史的讨论,颇为必要。唯愿神州有识之士能在此多事之秋,搞清楚一号开明专制究竟是否具有开明专制的基因。

按很多人的说法,开明专制是多数的“低端人口”或者“开明人士”在“明君”带领之下,对土豪劣绅的一种对抗。由于其组织方式和人群阶级,相对土豪们的争权夺利,尸位素餐,具有天然的决策效率优势,能够对抗外敌,推进改革,促进社会进步。按照这个定义,当前领导中国政府的人,动辄在大都市驱逐“低端人口”,实在有点匪夷所思。而已习近平为首的开明人士,究竟是否开明,坊间传言甚多,不好下断言。但是某些人的身居高位和腐败,则是显而易见的。

第二,从对国内外小网站黑箱打压,对维基百科,谷歌等外国机构和公司的网络黑箱封锁来看,现政府并没有解放媒体,提升政府透明度的能力和态度。

第三,如果真的关注民主的表决和执行效率,首先要看执行的效果。中国现在的经济总量也许上去了一点,然而环境污染呢?人口受教育程度呢?身体健康状况呢?如果实在单纯关注表决和执行效率的话,中国作为一个种族单一化程度较高的国家,我认为民主制度本身的效率并不是一个顶级难题。

扯到这吧,能力实在有限。咱也算是吃盒饭,操中南海心



Friday, 22 December 2017

提升人文阅读的一个利器

据说谷歌2017年的搜索最常用关键字是how,比如,洪水来临,救灾的时候如何安慰受惊的狗狗。

我自己每天大概要放狗一百次左右,不包括一些通过程序放出去的自动搜索。所以个人估计谷歌全球十亿用户,每天累计一百亿次累计搜索算保守估计。

在这么搜索中,安慰狗狗的搜索能够进入谷歌评估用户心理的法眼,谷歌的评估程序对于人文的精神是如何把握的?值得探讨。

有人问这个问题,有人欣赏这个发问,这样的社会中的人,心中又是有着怎样的幸福,在怎么爱着这个世界?

对比起来,三色幼儿园的新闻就让我非常感慨。这个幼儿老师对着这么可爱的小朋友上班,要是我不用提有多幸福了,怎么动得起那样的心思,下得了那样的狠手?

这人文的精神到哪里去了?我家里穷,又是理工科出身,人到中年才读了些中国的历史书籍,故事。不得不说,人性,有善良,也有罪恶。

个人认为,中国的历史,由于地缘政治造成的战乱,人性在其中的扭曲,是有很多悲剧的。咱们的文学著作中的人性的传承,是出了很多问题的。

三国和水浒都很血腥,红楼中各种歧视,争风吃醋,西游不算现实主义。近代包括鲁迅有很多真正的批判,可惜整个社会的人文并没有准备好接受。而且,排除掉西方文学界的话,也单调了些。

总之,我是很怀疑,我们的公民是否还缺乏一些人文的阅读和修养。我还不是一个有资格作出这样评判的人,即便我有资格,归罪于公民个体也是不公平的。咱们很穷,咱们的个体生存环境勾心斗角。咱们个体的心思只能用到怎么少费力气,多挣钱,实在不行,就是简单的发泄。

但是,我在想,可以做点什么吗?我读到了gutenberg,有文字,有音频,收集了人类历史上基本上得到过承认的经典文学和哲学著作。

我想写个手机软件,让所有人可以免费的读到这些文字和声音。慢点,读不懂怎么办?播放声音的同时,实时显示文字!这成了一个开端,形成了今天的软件,书弦,英文名Boochord。

跨平台,安卓,苹果,统一免费。

如果你和我一样有同样的梦想,让普通人获得高质量的人文阅读,那么和我共同使用这个软件吧。

针对小孩子的绿野仙踪,爱丽丝漫游仙境,小公主,针对历史爱好者的希腊史诗奥德赛,司马法所谓權出於戰,不出於仁,美国的独立宣言,尼采的超越善恶。。。

如果你是一名幼儿教师,建议安排一些故事的阅读,比如伊索预言,其实这个软件的的也可以节省您的很多时间,培养小朋友的阅读兴趣。

或者有人会说,你装什么叉啊,市面上早就有类似软件了,还是非常有名的。我就不说这些公司和产品的名字了,但是他们的收费都非常贵,不够普及。我就是希望这种阅读就像是自来水一样,任何人都伸手可得。就是这样了

Wednesday, 22 November 2017

Is Swift 4 horrible?

The project team of Boochord iOS recently reached the first version milestone for iPhone and is publishing on iOS App store and preparing to utter the joys to sky.

It employs Swift language version 4 as the primary language and the tool of XCode, AppCode, Cocoapods etc. Many people know the "famous" incompatibility between Swift different version and the pet peeves about String processing performance, optional design etc. How does the project team go through all caves and traps to arrive the status today? I would like share some experiences with you.

First, optional design is a good one which helps junior person to avoid many "nil", aka, null dead end problems in java / c environment. But it does not mean nil bugs are fully eliminated since the enforced optional unwrapping is still some times unavoidable. And besides, best practices within a team could vary depends on third party used and member preferences etc. e.g., guard vs if statement. So agreement on early time is always important to avoid the code messing by many ifs.

Second, string processing is kind of pain for those with Java background. Since the indexing is not by integer but String.Index. And String can not be easily converted / processed in the form of charater Arrays. It would be easy to fall into the performance trap considering there are also big difference on low level String functions. String's UnicodeScalar view is indeed useful in some situation but they are always useful. However's by our experiences, a bad design and implementation could be 100 times slower than Android processing. We are using IPhone 7 plus comparing to kind of middle level 3 years aged android brand phone like Xiaomi etc.

Third, XCode is kind of robust but sometimes staggering and slow. The source code is compiled and running but it still shows there are some code error. Sometimes we have to delete the derived data of compilation to get a clean visual world. But the good side is that it is dead seldom while AppCode does although it does better and quicker refactoring job like renaming, moving etc. I cannot see it is a shame of jetbrain because it is performing much better as in Android Studio.

Fourth, Interface builder is the proud of Apple and has very precise and flexible control to place graphical components at right places. Its auto-layout has much better and clear intuitive presentation of constraints than Android GUI designer in my point of view. But be very careful to use XML source view to edit story board / nib file. It is reckless and rude change probably from Apple's point of view. Because you could fail to start Xcode unless you can fix the error by external tool like vi or other text editor.

Fifth, third party integration sometimes out of control. As many as 50 percent cocoapods did not function at first installation and needs some tweaks / work rounds. And Swift package managers is still in infant phase could not provide meaningful help. Manual import in XCode seems the final solution almost in all cases. But the method brings in potential manage risk on package management for many processes that requires automation such as testing, upgrading, merging etc.

Overall speaking, Swift is evolving to a mature language and the version of Boochord is reached in as short as 3 months and passed all the tests with few bugs. Considering it is has many complex components of intensive timer tasks, incorporated many Artifitial Intelligence generated data marks, and many members are junior or with different tech stack experiences and they are confident with Swift now, I would like to say Apple did a good job in last year to make Swift competitive.