today i learned

collection of things i learn "today", revised & expand sometime not today.
2024/07/17
force refresh hook with a single line react
  • const [refreshKey, refresh] = useReducer(()=> Date.now(), 0)
    
  • sometime you just want to force refresh things

2024/07/02
merge pdf with preview on macos pdfmacos
  • Open PDF in Preview. This is the default viewer for iOS. If yours does not automatically open with this app, right-click on the PDF file, then select Open With > Preview.

  • Enable Thumbnails sidebar. If no sidebar appears on the left side of your document, then select View > Thumbnails or press Option + Command + 2 to enable it.

  • Indicate where to insert a secondary PDF file. Within the Thumbnails sidebar, select the page where you want to insert another PDF document.

  • Insert file to merge. On the toolbar, select Edit > Insert > Page from file. From the dialog box, select your file. The secondary PDF will now merge with the first.

  • Save the merged document. Select File, then Export as PDF. In the dialog box, rename the new document and press Save.

  • from: https://www.adobe.com/acrobat/hub/merge-pdf-files-on-a-mac.html

    • fishy tactic to make user create account, fuck u adobe, fuck u.

2024/06/18
desoldering header pin
2024/06/10
Record<string, unknown> is not assignable to Interface typescript
  • should put a playground in here

get client bounding rect by using inverse matrix cssgraphic
2024/03/11
you should always xcode-select --install everytime you update macos macosnetworking
  • otherwise it will break most of the app i usually use

  • git disappear usually a good indication some thing went wrong

2024/01/15
rotoscoping means tracing over real life animation for more realistic result artanimation
2023/12/25
viewport meta tag html
wifi in public doesn’t work most likely because it run out of ip addresses networking
2023/12/14
it is not possible to query by db/id in logseq logseq
2023/12/11
dynamic import astro component astro
  • const {default: Component} = await import(`../d/${name}.astro`)
    ---
    <Component/>
    
2023/11/28
back/forward cache browserweb
2023/11/23
resetting suspense with keys reactssr
2023/11/22
narrowing with includes and is typescript
  • image.png

  • TODO should try and document this

    • step by step to create pseudo translation utils

    • support autocompletion with typescript

    • satisfies, is, T extends Interface, etc..

    • expands and something

  • image.png

2023/11/20
2023/11/19
popover is native to the web now uihtml
2023/11/16
disable modal clicking outside using onPointerDownOutSide={e=>e.preventDefault()} radix-uireact
2023/11/15
there’s a processing fee at least 1.1% for online transaction like steam, spotify, aliexpress finance
  • 1% of the amount + 10% VAT of that 1%

2023/11/11
MAYA rule design
  • abbreviate for “Most Advance. Yet Accessible”

  • image.png

2023/11/09
vite eval the whole file when import, so import things using vite before init vite is not recommend viteastro
  • such as bundle both astro:integration and astro components into single index.ts file

2023/11/07
deploying by webhook using cloudflare and apple shortcut cloudflare
  • image.png

2023/11/04
reverse lookup attribute in pull dataloglogseq
2023/04/10
use process.cwd() to get current directory node.js
2023/04/08
how to rotate a vector
2023/04/06
scaling canvas properly
2023/04/03
show scrollbar options macos
  • before

    • image.png

  • after

    • image.png

2023/04/02
2023/03/30
use (not template) to exclude template from queries logseq
2022/09/13
tab vs space
  • use tab always

    • can always use tabstop, tabsize to change the content

    • ways easier to read

    • example

      • a codebase with 2 space as 1 tab can not convert to 4 space or 8 space

      • but with tab, things can change easily, plus accessibility

2022/06/30
2022/06/29
2022/06/03
punctuation of parenthesis typography
  • When writing in English (not a programming language or math), the rule is: put a space before the opening parenthesis, and either a space or a punctuation mark after the closing parenthesis.

2022/05/09
everything is pretty if it have enough pixel typographydpi
monitor events with chrome dev tools devtools
2022/05/03
border radius can do something like this css
2022/05/01
json stringify and parse jsonjavascript
2022/04/23
getStaticProps getStaticPaths can not be re-export like NextPage as it would break nextjs’s treeshaking next.js
rewrite vs redirect
  • rewrite only happen on server, the client or the browser don’t know about this

  • redirect happen in both server and client

    • issue some http/status code like 301, 302, 307, etc,…

    • reflected on the url bar in the browser

2022/04/09
only need /api folder to serve api function in node next.js
2022/04/06
form attribute formhtmlweb
2022/03/30
colocation in react react
2022/03/03
inspect block data in logseq logseq
  • :view (fn [result] (for [r result] [:pre (pprint r)]))
    
2022/02/23
yup validation for simple object, simple form object-validationyup
2022/02/22
safely remove a key, set it to undefined javascriptjson
timedate-local html