today i learned
collection of things i learn "today", revised & expand sometime not today.
force refresh hook with a single line react
-
const [refreshKey, refresh] = useReducer(()=> Date.now(), 0)
-
sometime you just want to force refresh things
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.
-
desoldering header pin
Record<string, unknown> is not assignable to Interface typescript
-
should put a playground in here
get client bounding rect by using inverse matrix cssgraphic
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
rotoscoping means tracing over real life animation for more realistic result artanimation
viewport meta tag html
-
https://developer.mozilla.org/en-US/docs/Web/HTML/Viewport_meta_tag#minimum-scale
-
instead provide a scrollbar to scroll around, this tell browser to shrunk down to fit into mobile space
-
no-scale usually get frowned upon. and safari actually ignore that to always allow user to zoom.
wifi in public doesn’t work most likely because it run out of ip addresses
networking
fractional indexing for real time sequences multiplayer
it is not possible to query by db/id
in logseq logseq
-
use
block/uuid
instead
dynamic import astro component
astro
-
const {default: Component} = await import(`../d/${name}.astro`) --- <Component/>
back/forward cache browserweb
resetting suspense
with keys reactssr
-
https://react.dev/reference/react/Suspense#resetting-suspense-boundaries-on-navigation
-
using
<Suspend>
causing trouble for old router ofnext.js
-
specifying
key
outside ofsuspense boundaries
help reseting it and things magically work again -
react suck
narrowing with includes
and is
typescript
-
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
-
free as in free beer
is different than free as in free speech
popover
is native to the web now uihtml
disable modal clicking outside using onPointerDownOutSide={e=>e.preventDefault()}
radix-uireact
there’s a processing fee at least 1.1%
for online transaction like steam, spotify, aliexpress finance
-
1%
of the amount +10%
VAT of that1%
MAYA rule design
-
abbreviate for “Most Advance. Yet Accessible”
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
andastro
components into singleindex.ts
file
deploying by webhook using cloudflare and apple shortcut cloudflare
reverse lookup attribute in pull
dataloglogseq
-
useful to perform nested query to find children of parent in the search
use process.cwd()
to get current directory node.js
how to rotate a vector
scaling canvas
properly
-
use
ctx.translate(0.5, 0.5)
to avoid0.5px
line at border
show scrollbar options macos
-
before
-
after
scroll anchoring with css css
prevent content from expanding grid items css
use (not template)
to exclude template from queries logseq
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
-
-
how svg path works svg
how bezier curves work mathcsssvg
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.
everything is pretty if it have enough pixel typographydpi
-
font hinting is not needed when your screen have over 300dpi or ppi
-
that’s why kindle e-ink only need 300ppi
-
-
https://www.sven.de/dpi/ calculating dpi
monitor events with chrome dev tools devtools
border radius can do something like this css
json stringify and parse jsonjavascript
-
empty string
is not a valid JSON, henceJSON.parse("")
will throw error
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
, theclient
or thebrowser
don’t know about this -
redirect happen in both
server
andclient
-
issue some
http/status code
like301
,302
,307
, etc,… -
reflected on the url bar in the
browser
-
only need /api
folder to serve api
function in node
next.js
form attribute formhtmlweb
-
form
attribute to anid
in<form>
tag -
useful for design parentless form
colocation in react react
-
Place code as close to where it’s relevant as possible
inspect block data in logseq logseq
-
:view (fn [result] (for [r result] [:pre (pprint r)]))
yup validation for simple object, simple form object-validationyup
-
export const validate = async ( data: PromoCreateCode, ): Promise<boolean | Error> => { try { await schema.validate(data, { abortEarly: false, }); return true; } catch (errors) { return { errors: errors.inner.reduce( (allErrors: Error, currentError: ValidationError) => ({ ...allErrors, [currentError.path as string]: { type: currentError.type ?? 'validation', message: currentError.message, }, }), {}, ), }; } };
-
this small snippet will aggregate error into its object path and emit message and type for the schema.
-
readmore:
-
yup context and condition validation
#yup
safely remove a key, set it to undefined
javascriptjson
-
JSON.stringify
will not serialized undefined field
timedate-local
html
-
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local
-
work with system locale
-
AM/PM according to system clock
-