Understanding offsetWidth, clientWidth, scrollWidth Note All these property will round the value to an integer. If you need a fractional value, use element.getBoundingClientRect(). Get Scrollbar width Reference: https://www.30secondsofcode.org/js/s/get-scrollbar-width/
Get window scroll bar width const getScrollbarWidth = () => window.innerWidth - document.documentElement.clientWidth; getScrollbarWidth(); Get a element scroll bar width const getScrollbarWidth = (el) => { const leftBorder = parseInt( getComputedStyle(el).getPropertyValue('border-left-width'), 10 ); const rightBorder = parseInt( getComputedStyle(el).getPropertyValue('border-right-width'), 10 ); return el.offsetWidth - el.
generic types optional To make a generic type optional, you have to assign the void as the default value.
const fetchData = <T = void>(url: string): T => { const res: T = fetch(url); return res; }; https://garbagevalue.com/blog/optional-generic-typescript#quick-solutions-make-generic-type-optional
string[ ] & [ string, …string[ ] ] The main difference is that type [string, ...string[]] at least have one element. [] will alert error. string[] could be empty. [] is ok.
Reference official https://ffmpeg.org
blog https://fireship.io/lessons/ffmpeg-useful-techniques/
node js https://www.npmjs.com/package/fluent-ffmpeg
example concatenate ffmpeg -f concat -i vids.txt -c copy out.mp4
vids.txt:
file 'name1.mov' file 'name2.mov' file 'name3.mov' Type convention ffmpeg -i in.mp4 out.mov
ffmpeg -i in.mp4 out.gif
Scale It very common to reduce size of output file. Change scale usually the common and efficient way to do so.
ffmpeg -i in.mov -vf scale=960:-1 out.gif
Reference from ffmpeg wiki
React –>Look this post<–
WEB basic Please Stop Using Local Storage https://www.rdegges.com/2018/please-stop-using-local-storage/
JWT authentication: When and how to use it https://blog.logrocket.com/jwt-authentication-best-practices/#:~:text=A%20JWT%20needs%20to%20be,storage%20(or%20session%20storage).
Graphql Dispatch This: Using Apollo Client 3 as a State Management Solution https://www.apollographql.com/blog/dispatch-this-using-apollo-client-3-as-a-state-management-solution/
Apollo Client update cache when delete an item from list https://github.com/apollographql/apollo-client/issues/6451#issuecomment-775242381
Several things for Graphql Security https://ithelp.ithome.com.tw/articles/10208008
should I put useQuery inside a useEffect and should I store returned data in state? https://github.com/trojanowski/react-apollo-hooks/issues/158
How to Use GraphQL DataLoader https://rahmanfadhil.
Modal box Demo
Cursor & hover effect Demo
Pure Css hamburger button This is a hamburger button using pure css to style it.
Demo
Loading Demo
Sidebar Demo
Profile Demo
webpack is a static module bundler for modern JavaScript applications.
Document: https://webpack.js.org/concepts/
Installation npm i -D webpack webpack-cli webpack core concept Entry An entry point indicates which module webpack should use to begin building out its internal dependency graph. webpack will figure out which other modules and libraries that entry point depends on (directly and indirectly).
Output The output property tells webpack where to emit the bundles it creates and how to name these files.