Wei Gao
NUS Friday Hacks
Aug 25, 2023
I'm not a GPT or LLM expert, I won't answer questions like whether I think ChatGPT will take your job or if it should be banned for your homework.
<svg id="track" xmlns="http://www.w3.org/2000/svg" width="1460" height="1708" viewbox="0 0 1460 1708" fill="none">
<path id="curve" d="M1061.5 179C919.5 69.4998 395.536 -86.0222 105 69.4998C-64.9999 160.5 -6.50002 483.65 172.5 600C271.72 664.493 500.5 743.5 1048 743.5C1172.42 743.5 1246.5 737.667 1326.5 743.5C1443.5 752.031 1525.5 1088.5 1372 1137C714.198 1344.84 860 1658 526 1658C233.737 1658 152.833 1682.33 103 1704" stroke="#ED5500" stroke-width="7" />
</svg>
path.getTotalLength()
path.getPointAtLength()
https://svgwg.org/svg2-draft/types.html#__svg__SVGGeometryElement__getPointAtLength
(x, y)
path.getPointAtLength(fraction * totalLength)
const totalLength = path.getTotalLength()
https://glitch.com/edit/#!/mapotofu-plane?path=script.js
...really quickly
you're doing more of code reviewing v.s. actual coding
but you're also taken away the opportunity to figure out the puzzle by yourself
follow @szzzzkkkk on IG 🤣
when posting multiple media, IG requires that all of them in a same aspect ratio
...such that their carousel doesn't have to resize
"how do you add borders to photos?"
...all in browser locally (no network requests)
...all in browser locally (no network requests)
https://glitch.com/edit/#!/classic-crystal-idea
https://www.w3schools.com/jsref/canvas_drawimage.asp
https://www.w3schools.com/jsref/tryit.asp?filename=tryhtml5_canvas_drawimage2
ctx.drawImage()
carousel (canvas)
gallery (svg)
color picker
apply button
uploader
atom: raw files
atom: color of choice
async selector:
rasterized images
write: upload file
read: rasterization & thumbnail gallery
write: color picker
read: rasterization & thumbnail gallery
select: raw files & color
await rasterization
ChatGPT: Instagram uses 1080x1080
web developer: me got Chrome DevTools inspector
disclaimer: it did say "based on my knowledge as of Sept 2021..."
ChatGPT: iPhone 14 Pro does not exist
(but it actually knows it's supposed to exist)
It'd be 8~11 times faster if we are to use Instagram's resolution directly
Me (rookie canvas developer): Should I optimize by drawing smaller resolution or compressing the images?
ChatGPT: You should do both!
How are the two optimizations different - drawing lower resolution v.s. file compression
Downsampling:
Adjusting Quality with canvas.toDataURL
:
How does canvas decide which pixel to draw when drawing higher resolution images to lower resolution?
"Downsampling" - reducing the resolution of the image to fit the target dimensions. There are various downsampling algorithms:
- Nearest-neighbor sampling
- Bilinear sampling
- Bicubic sampling
- Lanczos resampling
- ...
Browsers choose which downsampling algorithms to use
reminder slide for code tour
transform: translateX(dx)
finishSliding()
https://squareanimage.com
https://www.tunetheweb.com/blog/what-does-the-image-decoding-attribute-actually-do/
Task | Score |
---|---|
coding generic problem | 🦄🦄🦄🦄 |
coding subject to specific requirements | - - |
product research | 🦄🦄🦄 |
performance analysis | 🦄🦄🦄 |
interpreting code | 🦄🦄🦄🦄🦄🦄 |
explaining technology | 🦄🦄🦄🦄🦄 |
writing talk script | 😬 |
you can get up and running with ChatGPT pretty quickly
you will be doing more code review as opposed to actual coding
you should focus more on defining the right problems to solve
Recoil is a state management library for React that offers a way to manage global state across components. The main pieces are atoms (where you store states) and selectors (how you get accessed to values or deduced values).
Recoil selectors are like any other state selector you imagine but has most of your problems solved:
- have access to any atom
- asynchronous processes can hide behind Recoil selectors and they they cache the results by default