7月 13, 2021

First Vue components project

 

vue.Left: template component

.Right: Separated script component



Mapping Component on App.vue, the root component

 

Javascript object array map problem

 for an array of objects, to extract fields and map into a simpler array, 

object : SomeObject = {a: 1, b:2, c:3}

array: SomeObject[] = ...


do:

newArray = array.map(x => ({x.a, x.b}))


instead of

newArray = array.map(x => {x.a, x.b})

 

Otherwise it doesn't work.

 

Reference:

 

"What you need to do is force the parser to treat the object literal as an expression so that it's not treated as a block statement. The trick is to add parentheses around the entire body: "


https://mariusschulz.com/blog/returning-object-literals-from-arrow-functions-in-javascript

7月 11, 2021

Kotlin with gradle

 Some issue faced with after creating new project the first time in Idea for Gradle-Kotlin project.


1. Make sure project root name consistent to package: src/main/kotlin/[packagename]/...

2. main() exist outside class

3. MainClass = [package].MainKt

The suffix Kt is required, or there will be a  'main() not exist in main class' error.

6月 29, 2021

Windows install software without root

 ```

Windows Registry Editor Version 5.00
#https://superuser.com/questions/171917/force-a-program-to-run-without-administrator-privileges-or-uac
[HKEY_CLASSES_ROOT\*\shell\forcerunasinvoker]
@="Run without privilege elevation"

[HKEY_CLASSES_ROOT\*\shell\forcerunasinvoker\command]
@="cmd /min /C \"set __COMPAT_LAYER=RUNASINVOKER && start \"\" \"%1\"\""

 

``` 


This should be be used to install drivers or other software that actually need system mode access.

6月 27, 2021

git clean, something you don't want to use lightly

 尋日搞python pip conda 好煩

pip 沒辦法安裝 scipy on M1 Mac

跟住見到教路如何清理pip cache

唔知頭唔知路,突然走左去跟 'git clean -f'

 

run 一次,當堂醒曬。

 

結語:

搞唔掂,用conda 算。

唔好亂跟。

6月 07, 2021

markdown pandoc generate table number

 # Install:

pip install --user pandoc-fignos pandoc-tablenos

 

# Usage:

## Command line:

pandoc ... --filter pandoc-xnos

 

## On markdown:

Add:

    Table : This is a table {#tbl:id}

 

# Limitation:

- Generated number put captions above table.  This is not the wanted style.

- For unknown reason, pandoc parser cannot recognize \rarr, while markdown-it previewer can.

6月 01, 2021

decryption python implementation

 做decryption exercise 用chr() 唔見有野出。原來result漏加base ascii code.

eg: 0 -> chr(0) is blank

x = 1+ ord('a') -> ch= chr(x) -> print(ch) -> 'b'