梵
保存
正在保存
梵总 发布的帖子
-
group by & count array of objects
const allPubs = rows.reduce((ac, item) => {
const idx = ac.findIndex((x) => x.publicationName === item.publicationName);
console.log("IDX", idx);
if (idx === -1) {
ac.push(item);
} else {
ac[idx].publicationQty += item.publicationQty;
}
return ac;
}, []);const sortedRows = orderBy(allPubs, ["publicationQty"], ["desc"]);
-
RE: write to Excel on the client side
const xslsHeaders = [type, "Total", "Percentage"]; const sheetData = [[type, "", ""], [dateRange, "", ""], xslsHeaders, ...main]; onClick={() => exportFile(`${type} ${dateRange}`, sheets)}
-
Fix Href Interpolation Failed error
https://nextjs.org/docs/messages/href-interpolation-failed
const handlePaginationChange = async (value) => { // await fetchRecords(scope, value - 1); // setActivePage(value); const params = { pathname: "/clubs/[slug]", query: { slug: lsc, page: value }, }; router.push(params, undefined, { shallow: true }); window && window.scroll({ top: 0, behavior: "smooth" }); };
-
start serverless with different port
"its": "sls offline start --stage=localits --noAuth --noTimeout --httpPort=4000 --lambdaPort=4002"
-
use Env variable in public.html for create react app
<script type="text/javascript"> console.log("CODEBUILDNUMBER: ", "%REACT_APP_CODEBUILD_BUILD_ID%"); // code build number if any console.log("%NODE_ENV%"); // development </script>
-
remote access to your WSL
Great tutorial:
https://www.illuminiastudios.com/dev-diaries/ssh-on-windows-subsystem-for-linux/In my case, the WSL should be on the main network, i.e. 192.168.1., not on the subNetwork like mesh wifi network, ex: 192.168.4. (which is a subnetwork of the mesh network 192.168.1.*)