Visual Studio Code Rest client extensions

Visual Studio Code Rest client extensions , 是我用開 Visual Studio Code 寫 code 時的一個好常用/adapt的feature。
” Rest client ” extensions其實就好似 Postman (一個chrome extension,用黎mock up去send HTTP request做testing)。
但佢就再簡化d,唔需要UI,而係用text就夠。
即係例如我隨便一個file入面有呢幾行字:

然後我select呢段字,禁ctrl+alt+r,就會mock up send左個request出去,再有一個tab show response (as text),如下:

這個好處是,我能夠用一個text file就儲存好一堆mockup testing request。
需要更改時直接改內容就好。
測試時,也不用import/export到postman,並且不用離開IDE就能直接測試endpoint。

fortel-codex.js – 中國術數基本codex (陰陽/五行/天干/地支)

Project info

Project code: fortel-codex
Type: node.js module
Version: 0.01
Last update date: 2017-03-23

 

Description

A Node.js Library for Chinese Astrology Common Codex. (中國術數基本codex)

Background

I am planning to write a bundle of node.js modules which are related to Chinese Astrology/Divination, including 紫微斗數, 八字, 九宮飛星 ……
And I find that most of Chinese Astrology/Divination system actually sharing some common codex.
So I write this common module to represent the common codex, including 陰陽, 五行, 天干, 地支, 時辰, 生肖, 氣節, 農曆 etc

 

Links

Github: https://github.com/airicyu/fortel-codex
NPM: https://www.npmjs.com/package/fortel-codex

 

Dev Log

  • 2017-03-23: v0.0.1
    • Support features:
      • basic codex for 陰陽, 五行, 天干, 地支, 時辰, 生肖
    • Pending to do:
      • include 氣節, 農曆
      • implement some more utility functions (e.g: check生肖by year)
      • Update API document

ahp-agent-telebot – A Telegram bot agent for AHP

ahp-agent-telebot

‘ahp-agent-telebot’ is a Telegram bot agent who can help you to do Analytic Hierarchy Process(AHP) analysis.

You can find the telegram bot by ID @ahp_agent_bot.
You may just hi it and it will ask you some question to go through the analysis process.

 


Screenshots

Screenshot 1: The openning…

 


 

Screenshot 2: During the conversations, the agent would ask you some questions. Sometimes it would also suggest some quick answers for you to choose instead of manual input.

 


 

Screenshot 3: After the conversations, and all analysis context information is input, you may ask the agent to run the result. It would print the result matrix like below.

 


 

Open source Code

Github: https://github.com/airicyu/ahp-agent-telebot

 

Related posts

ahp.js – nodejs module for Analytic Hierarchy Process (AHP)

Brief intro about Analytic Hierarchy Process(AHP)

Java及Node.js對dependency module的不同管理方式

自己有玩過Java又玩過Node.js,兩者對於library dependency是頗不同的做法,這篇文是想講講兩者的分別。

Java

Java,多數是用maven or gradle來做library dependency management。
而我作為一個application developer,常常遇到一個問題:
我需要用到的libraries分別用到不同version的Spring或Jackson的不同version。
maven做法是會幫你resolve成同一個version。
但有時version conflict會出問題。

在Java裡面,不同library大多都是直接把class load到同一個class loader來用,所以不能存在multiple version的class。
很多時一些針對某些library來做的動作,都是直接hack/inject logic到那些class。

換句話說,Java的做法就像是有一個global空間,然後不同的library都放在裡面。
這樣把library都放在global空間好處就是,如果我是身為framework developer,這會較方便我去做middleware library,因為我可以直接掌控不同library。
而壞處就是,global空間如果library都各自有dependency,就很難統一manage,所以當library upgrade時就會較多問題/較痛苦。

Node.js

另一方面,Node.js的dependency management是另一種做法。
node.js裡,每個module之下都可以有自己的dependency及version。
如果你用上module A與module B而它們分別depends on module C的不同version,
那麼module A會在其下depends on它需要的module C的某version,
而module B會在其下depends on它需要的module C的另一個version。
兩個module分別用到自己需要的version,而不會conflict。

Node.js的做法,其實都是一個Global空間。
只是它容許不同module的不同version同時存在,而每個module都只會用到自己需要的version。
這樣的design的好處是,較易適應library的upgrade,upgrade的impact只會impact到adopt新version的module/code,而不是所有用某個module的module/code。

而這亦是為什麼node.js的開發能很快的其中一個原因。
因為module順手沾來就能用,較少機會會有module version conflict的問題。

不過Node.js這樣的design的short side是,假如我是framework developer,我就較難去建構middleware library。
我不是說你不能做middleware(express.js的那種),我是指你很難去針對其他library來作出一套全面掌控的framework library。
當然你不是真的不能,就像express.js那樣。
但express是較為多人adopt的web framework,而它本身也沒有很aggressive地去inject logic到其他library之上。

所以寫Node.js的話,如果你是app developer,你固然能把你到手的library都hack掉來for your usage。
但如果你是作為framework developer,你的心態就可能要調整一下,不要用寫java framework的心態及思維去做這件事。

Nodejs v7.6.0 release would support async/await

Node.js v7.6.0 is just released

Node.js v7.6.0 release change log: node/CHANGELOG_V7.md at master · nodejs/node · GitHub

One of the shining change is that this release contains V8 engine 5.5.
V8 engine is the javascript engine which node.js is underlining using. With V8 engine 5.5, it would support async/await features. ( V8 JavaScript Engine: V8 Release 5.5 )

Async programming – Promise/async & await

In Javascript/node.js, there are multiple ways to dual with async programming.
With ES2016, people can use Promise syntax.
And with ES2017, people can use async/await syntax.

Promise style async programming:

Equivalent async/await style async programming:

Why async/await is better than Promise?

There are multiple advantages:

  • The async/awwait style is much cleaner with less coding block/scopes. Promise would wrap the codes in difference function scopes.
  • We can use try catch to catch errors for sync/async codes.
  • Less lines. The general coding style of most people usually need several lines to write a wrapping function.

 


 

Remarks:

Node.js actually support async/await since v7, but it is locked in harmony flag until v7.6.0.

ahp.js – nodejs module for Analytic Hierarchy Process (AHP)

AHP node.js module

Recently I wrote a node.js library for AHP.

If you do not know what is AHP, you may see a brief AHP intro post I wrote. Basically it is a methodology to help decision making scenario which we have to evaluate several choices against multiple criteria.

Example problem:

Github: https://github.com/airicyu/ahp
NPM: https://www.npmjs.com/package/ahp

Sample code:

 

Console output:

Interpretation:

The overall rank score(higher is better) of the choices are:
VendorA: 0.3652
VendorB: 0.2852
VendorC: 0.3495
Hence, “VendorA” is preferred in overall ranking.

給想學Programming的新手建議

過去都試過有好幾次有唔係IT既朋友問我學programming有冇咩advise俾到佢地。

其實, 都真係好睇佢地各自purpose係想做乜。
寫mobile app寫網頁寫backend application其實係唔同範疇黎, advise都唔同。
亦有朋友purpose係想寫特定行業既野, 例finance既application, 我唔熟都俾唔到咩advise。

不過, generally, 我通常都會advise, 如果係新手入門, 最好先學下掌握下少少基本concept。
而打好concept底, 我通常都建議係由python入手。

python唔係新野, 有一定歷史, 有一定community。但python亦都易上手。
唔好以為係舊野, 其實好多data analytic library都係python base, data analytic其實係黎緊既trend, 學完都有potential用得返(唔似pascal學完出黎冇人用)。

當然, java我估可能係最多job(好耐冇搵工, 印象中係咁), 由java入手都ok, 但學python會易上手d。

冇特別preference唔建議由frontend stack(javascript)入手, 因為太多野要同時學, 難上手。

mobile app, 我都會建議睇清楚諗清楚。
黎緊係咪仲興mobile app, 定係轉緊其他trend, 要諗諗依d問題。(open question, 各自可以諗諗)

file-query.js – nodejs module using jQuery to manipulate your folders/files

Recently, I wrote a opensource node.js module “file-query” and put on github. (It is my first opensource github project.)

The basic concept of this module is mapping folder directory structure into virtual DOM structure. And then the module allow you to use jQuery syntax to select and even manipulate the virtual DOM structure in order to manipulate folders/files.

Github: https://github.com/airicyu/file-query
NPM: https://www.npmjs.com/package/file-query

 

Example:

The above code first load the “file-query” module, and then scan folder structure’D:/root/d1′ in order to create virtual DOM mapping.

And then in the later code, we use jQuery selector and manipulation functions just like what we do usually with jQuery. We find directories under path “d:/root/d1/d2”. And then find directory “d3”. And then find all directories under it which has name start with “abc”. And then find all child files. Finally we rename all those files.

More examples can be found in the Github webpage.

 

推介Javascript development IDE – VSCode

[opensource IDE][javascript]
試用過一個microsoft出既opensource IDE, 叫visual studio code (同visual studio係完全兩樣獨立既野黎)。

vscode係比較新, 2015先出。
定位大概係類似atom果種。

我試用過, 裝下基本extension, 其實已經好強大。
內置command terminal, git, debugger整合。
用黎做node.js development一流, 用落慣左會發覺好用過notepad++好多。

相比atom, 食少d resources, 順暢好多。
用落好少要load time, 好responsive。

堅覺得vscode幾有potential。