2020-11-2 grid cell下拉框不自动加载, Jacoco, Excel, Spring MVC vs Boot, if as && in JS, IDEA ECMA 6, linux

    科技2023-12-14  86

    1. redux-saga-routines

    TRIGGER -> REQUEST -> SUCCESS / FAILURE -> FULFILL

    2. ReactJS - Does render get called any time “setState” is called?

    3. ag-grid custom renderer遇到的问题

    问题是…grid cell里custom renderer的下拉框,没法在grid加载时自动加载并选中…

    onFirstDataRendered -> onRowDataChanged就可以了

    因为custom cellRender改变了一个cell的值,也就是改变了row data,进而re-render,导致之前setSelected(true)的row又被deselect了

    这里乱得很…我得再想想

    if only use onFirstDataRendered, can not find instance sometimes because onFirstDataRendered is called so early. If only use onRowDataChanged, maybe fine…

    Since we use onRowDataChanged, which will be tricky than onRowSelected, because we will change the

    Problems found:

    a) Since the rowData can be updated(deselected because some random re-render I still don’t know where, and also the prefCode in-place update from the toggleComponent), b) also the data can be too much that some rows cannot be displayed on UI page, getCellRendererInstances may not find any instances. c) Thus we want to ensure the setSelected(which then trigger the on RowSelected) is triggered after the rowData is fully loaded.Before, I didn’t use useRef for gridApi, sometimes gridApi can be null… Anyway, the key point is if the code bypass the toggleComponent because of cannot find the instance, then the re-render will happens unexpectedly. I use pre-set, onRowDataChanged, (useRef, with onRowDataChanged, this is not necessary) to prevent this deselection happens.Again, the key point is, use onRowDataChanged ensure to be triggered after random re-render/deselection, try to find getCellRendererInstances(when can’t find, we already pre-set the prefCode. pre-set here is not to help getCellRendererInstances to find instance, is just help to in case too much data getCellRendererInstances can’t find instance then the prefCode is null. Meanwhile, pre-set may helps update the data and trigger the onRowDataChanged function again…I found without pre-set, the prefCode sometimes cannot be selected…OMG crazy… ) Anyway, pre-set ensure prefCode is set no matter instance can be found or not… 主要原因就是instance不是每次都能被找到…因为网页加载比代码慢之类的,就这个getCellRendererInstances比较tricky。但是pre-set,就不管找不找得到都行,因为set过了。但是他恰好帮助了多trigger一次onRowDataChanged,反而找到了instance又发现一个新的点,每次打开grid,useSelector都会给一个rowData:[] -> rowData without prefCode -> trigger onRowDataChanged, update rowData with prefCode -> trigger rowData again. 然后我又懂了,如果只用firstDataRendered,里面我改了rowData,导致界面更新componentDidMount啥的都被call一下,但是setSelected却不会被trigger第二次…rowDataChanged成with prefCode本应该被call的。

    Some Solutions: pre-set the value(prefCode) of that cell dropdown list 4. I remember when we change the rowData, it may cause the re-render. So if we pre-set it, it will not update the rowData with prefCode, maybe reduce the re-render. But then I observe random re-render still happens, and refresh the rowData and deselect the row which I setSelected(true) before. 5. Doesn’t matter if the getCellRendererInstances can find the instance or not, because we already pre-set the prefCode, (and componentDidMount will helps to the same thing as toggleComponent function I guess emm… but toggleComponent itself doesn’t have too much code…) 6. Though we don’t need the instance must to get called, but meanwhile it solved the problem that can’t find instance after the ‘params’ passed into getCellRendererInstances changes. The logic is quite complex: a) If the prefCode is already displayed on UI before we call getCellRendererInstances, then we can find instance. b) If the prefCode is not displayed, I found this means, the rowData haven’t been fully loaded on UI, and the rowData changed with prefCode hasn’t take effect on UI, which somehow means, the onRowDataChanged will be called in the future. Since the onRowDataChanged will be triggered again, it will trigger setSelected(true) and onRowSelected again, in which it will find the instance again and give us the instance found. 7. If there are too much data and some rows can’t be displayed on browser, then getCellRendererInstances can’t find instance, and will not call toggleComponent to set the prefCode. So we must pre-set it to give it a value. I actually think calling toggleComponent is not necessary, because componentDidMount helps to do the same thing. But I just found setSelected will trigger the onRowSelected… Anyway, call it works fine.

    I use onFirstDataRendered and onRowDataChanged to trigger this: 8. onFirstDataRendered: add this will ensure every time we open the grid, this will be called, easy for testing, and avoid some bad shouldn’t happen use-cases (e.g. it will never be triggered by onRowDataChanged…) 9. onRowDataChanged: want to trigger it after the rowData change: deselection and prefCode update.

    why onRowDataChanged be called even when rowData didn’t change?

    Seems onRowDataChanged get called when “onFirstDataRendered”…我大概知道为什么了:[] -> rowData without prefCode -> trigger onRowDataChanged, update rowData with prefCode -> trigger rowData again. 但是console log出来的prefCode并没有变化,两个是一样的,但的确console log了三个: [], rowData, rowData. 我用了这个方法copy了console的log,然后放到IntelliJ Json file并且reformat,真的不一样… 有时候copy的时候注意copy的是不是原来那个,可以先console里打一下那个变量名再输入copy指令… I do observe some scenarios that they are different, there are some situation if the row is auto-deselected because some wired re-render, the onRowDataChanged will never be triggered.

    Custom cell render dropdown list, a function-toggleComponent in it change the rowData in-place, though this isn’t trigger the onRowDataChanged after I tested later, but this cause the row that setSelected(true) being deselected…

    shoule be wrong I guess it’s because it change the row data, then cause some wired re-render, then refresh the grid. Because when I comment that line of code of updating the rowNode, the row will not be deselected. I found even the toggleComponent is not been called, if it can’t find the instance to call toggleComponent, it will be deselected… If can’t find instance to trigger toggleComponent, I don’t know who refresh the data into the very beginning formate, but the componentDidMount indeed be triggered after we can’t find the instance… I don’t know which trigger the re-render and deselect the rowData occasionally, really wired. So I have to add onRowDataChanged to re-trigger that.

    Seems change grid cell dropdown selection will not trigger onRowDataChanged.

    This part I was misunderstanding before. Then I console.log the changes, found the cell dropdown list change will not trigger onRowDataChanged

    But seems in-place change dropdown cell of rowData will influence the getCellRenderInstance.

    Sometimes it just can’t find the custom cell render instance, I think it should because we in-place update the data, but the UI hasn’t be updated yet. So the params passed into it is not match with the browser.

    So my logic is, pre-set the prefCode dropdown list cell, which changes the rowData:

    If the UI rendered with prefCode, then it can find the instanceIf the UI haven’t rendered with prefCode, then it will not find the instance, but, since it haven’t rendered with this prefCode, which means (should be like this), the onRowDataChanged haven’t been triggered because the rowData haven’t been displayed totally, then after onRowDataChanged being triggered, it update the UI, also in which will find the instance again, thus find the instance.

    node.setSelected(true) will trigger onRowSelected.

    When change state and causing re-render, which will be cleared? will the state be cleared?

    As 3, re-render will not reset state, then why my gridApi turns to be null sometimes?

    seems node.setSelected(true) will call onRowSelected

    最后实在受不了了,用了useRef The returned object will persist for the full lifetime of the component.

    gridApi有时候是null的问题解决了,但是还是存在getCellRenderInstance返回null的问题…总之感觉是UI界面rendered的参数和传进去找cellRender的参数不一致,可能是UI界面上的参数没有加载完…

    有时候改rowData

    4. Renamed directory, now SVN not allowing me to commit

    差不多就是被删除的文件夹也要commit 中间搞了几个迷操作 然后又建了一个同名文件夹又删了啥的再commit才行

    5. Gradle - clarification on “check.dependsOn dependencyCheckAggregate”

    Note that java plugin has to be applied before setting the dependsOn relation, e.g. like this:

    apply plugin: 'java' check.dependsOn dependencyCheckUpdate

    6. How to add minimum coverage rules for multi module project as a cumulative number

    这里我也是用了executionData…

    6.1 Get coverage on compiled projects with jacoco using Gradle in Android projects

    6.2 JaCoCo with Maven - missing execution data file

    7. Unprotect an Excel file programmatically

    read protected excel into pandas:

    xlApp = win32com.client.Dispatch("Excel.Application") print(xlApp.Version) workbook = xlApp.Workbooks.Open(filename, False, True, None, Password='12345') sheet1 = workbook.Sheets[1] lastRow = sheet.UsedRange.Rows.Count lastCol = sheet.UsedRange.Columns.Count df = pd.DataFrame(list(sheet.Range(sheet.Cells(2, 1), sheet.Cells(lastRow, lastCol)).Value), columns = ['name', 'age', 'job'])

    7.1 How to open a password protected excel file using python?

    7.2 Load password protected Excel files into Pandas DataFrame

    7.3 win32com Excel.Application can’t open documents anymore

    7.4 XLRD/Python: Reading Excel file into dict with for-loops

    8. Difference between Spring MVC and Spring Boot [closed]

    Spring MVC is a complete HTTP oriented MVC framework managed by the Spring Framework and based in Servlets. It would be equivalent to JSF in the JavaEE stack. The most popular elements in it are classes annotated with @Controller, where you implement methods you can access using different HTTP requests. It has an equivalent @RestController to implement REST-based APIs. Spring boot is a utility for setting up applications quickly, offering an out of the box configuration in order to build Spring-powered applications. As you may know, Spring integrates a wide range of different modules under its umbrella, as spring-core, spring-data, spring-web (which includes Spring MVC, by the way) and so on. With this tool you can tell Spring how many of them to use and you’ll get a fast setup for them (you are allowed to change it by yourself later on).

    So, Spring MVC is a framework to be used in web applications and Spring Boot is a Spring based production-ready project initializer. You might find useful visiting the Spring MVC tag wiki as well as the Spring Boot tag wiki in SO.

    9. Pandas Replace NaN with blank/empty string

    10. Shell Script: Execute a python program from within a shell script

    11. JavaScript single line ‘if’ statement - best syntax, this alternative?

    lemons && document.write("foo gave me a bar");

    12. How do I enable support for ECMA 6?

    Please make sure to set ‘JavaScript language version’ ( Preferences > Languages & frameworks > Javascript) to either ‘ECMAScript 6’ or ‘JSX Harmony’

    13. What’s is the difference between “>” and “>>” in shell command?

    “>” is used to overwrite (“clobber”) a file and “>>” is used to append to a file.

    14. Intelli IDEA opens git bash in a separate window than the IDE!!

    15. stdout is not a tty. Using bash for node + tape + tap-spec

    not working:

    node myscript.js < some-input.txt > some-output.txt

    working:

    node.exe myscript.js < some-input.txt > some-output.txt

    16. How in node to split string by newline (’\n’)?

    Try splitting on a regex like /\r?\n/ to be usable by both Windows and UNIX systems.

    “a\nb\r\nc”.split(/\r?\n/) [ ‘a’, ‘b’, ‘c’ ]

    17. DIR=“ ( c d ” ( cd ” (cd( dirname “${BASH_SOURCE[0]}” )“ && pwd )” How does that work?

    Processed: 0.021, SQL: 8