Skip to content

Commit

Permalink
lots of changes for blog
Browse files Browse the repository at this point in the history
  • Loading branch information
jamischarles committed Oct 20, 2024
1 parent 0f6a2b4 commit f303a0c
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 119 deletions.
6 changes: 4 additions & 2 deletions animation/motion-canvas.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# Motion canvas hard to find items


## How to spin an item infinitely

```js
yield loop(
() => spinnerIconRef().rotation(0).rotation(360, 2, linear),
);
```

## How to count down a number
`<Txt>` <- use a text ref

`<Txt>` \<- use a text ref

```js
countDownRef().text("2s", 1).to("1s", 1),
```
19 changes: 6 additions & 13 deletions bundlers/bundling.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,32 @@
# Bundling best practices...
# Bundling best practices...

https://www.misha.wtf/blog/rollup-library-starter
https://nodejs.org/api/packages.html#dual-package-hazard


History reading:
https://www.simplethread.com/javascript-modules-and-code-bundling-explained/

## Typescript lib

## Typescript lib
Winner: esbuild


Reading:
https://eisenbergeffect.medium.com/an-esbuild-setup-for-typescript-3b24852479fe <-- WONDERFUL
https://eisenbergeffect.medium.com/an-esbuild-setup-for-typescript-3b24852479fe \<-- WONDERFUL
https://janessagarrow.com/blog/typescript-and-esbuild/



https://tsdx.io/ -2


Rollup is great but pretty low level.

For a higher abstraction, try esbuild, vite, or tsdx.

For a higher abstraction, try esbuild, vite, or tsdx.

## TS Bundling options for a package

tsdx -1 (seems abandoned. Some things not working anymore w)
tsup -1 but maybe tsup + tsc (will help fix the output extension issue I ran into...)
tsup -1 but maybe tsup + tsc (will help fix the output extension issue I ran into...)
vite
custom rollup
esbuild or esbuild + tsc
https://jakeginnivan.medium.com/options-for-publishing-typescript-libraries-9c37bec28fe



https://www.reddit.com/r/typescript/comments/pss7kx/compiling_ts_libraries_which_bundler_compiler/
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# Should I use <script> or <head> tags in Next.js 13+ app router?
# Should I use `<script>` or `<head>` tags in Next.js 13+ app router?

tl;dr Don't add your own `<head>` and `<script>` tags in Next.js app router RSCs. Use `<Script>` instead.

No.

In basic terms, Next.js does a lot of magic with the `<head>` tag and `<script>` tags. You're far better off using the metadata api instead of adding your own `<head>` in `layout.tsx`.


Use `<Script>` nextjs component and use the `strategy` attribute to control when & where the script is loaded (can do inline too). It won't give as much finegrained control over where exactly the script goes but it gets pretty close.

When I used `<script>` tags they seemed to run fine, but I'd see hydration errors like `Extra attributes from the server: nonce`.
When I used `<script>` tags they seemed to run fine, but I'd see hydration errors like `Extra attributes from the server: nonce`.

## Open questions:
* ?: Can you control the load order of specific scripts more finely when using <Script> tags in next.js?

- \?: Can you control the load order of specific scripts more finely when using `<Script>` tags in next.js?

## More reading

https://github.com/vercel/next.js/discussions/50772#discussioncomment-7993642
9 changes: 5 additions & 4 deletions fe-framework-nextjs/suspense-loading-spinners.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# React / Next.js loading best practices with suspense...

> <Suspense> lets you display a fallback until its children have finished loading.
https://react.dev/reference/react/Suspense
> `<Suspense>` lets you display a fallback until its children have finished loading.
> https://react.dev/reference/react/Suspense
```jsx
<Suspense fallback={<Loading />}>
<SomeComponent />
</Suspense>
```


## Open questions

Q: Is suspense a provider?
Q: Can we hook into susense lifecycle hooks (or create our own) to capture timing data quickly and easily for suspense start, end etc...?

## More reading

https://react.dev/reference/react/Suspense
https://demystifying-rsc.vercel.app/server-components/streaming/ <-- really good on RSC vs RCC suspense...
https://demystifying-rsc.vercel.app/server-components/streaming/ \<-- really good on RSC vs RCC suspense...
16 changes: 10 additions & 6 deletions javascript/execution-context-scope.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
# What is execution context and how can we pass it in?

## What is execution scope

It's the environment the code executes in, including local scope, local
variables, closures etc, global vars etc...

## Use case:

You have a JS sandbox where you want to run some code. I want to be able to
define what the execution context for the code i want to run is...

## Options && Approaches:
## Options && Approaches:

1. I could use an iframe and inject the things I want defined into the global
scope of the iframe

2. Use `with` keyword (exactly what it is for haha). It extends the scope chain,
though usage is not recommended.
`with (myobj) var res = eval(c);`
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/with
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/with

3. Inject eval into function top:
Pass in a `scope` key-val obj, and iterate over those...
`eval(`var ${k} = vegetableColors['${k}']`);`
Pass in a `scope` key-val obj, and iterate over those...

4. Inject temp var assignments / destructuring into function top
```js
eval(`var ${k} = vegetableColors['${k}']`);
```

4. Inject temp var assignments / destructuring into function top

Really interesting options here
https://stackoverflow.com/questions/31907970/how-do-i-destructure-all-properties-into-the-current-scope-closure-in-es2015


https://stackoverflow.com/questions/43754035/javascript-convert-object-properties-to-variables-inside-function-scope?noredirect=1&lq=1
32 changes: 20 additions & 12 deletions javascript/incremental-code-eval-execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ We have a code block. We'd like to have swift-playground like result where we
see the result of each expression in the right rail...

## Approaches I've tried

### Eval each line separately

Doesn't work because each line sets up a new in-browser VM with isolated
execution context (lose the scope from prior lines).

### Eval incrementally
Eval to line 1, eval to line 2, eval to line 3 etc...

Eval to line 1, eval to line 2, eval to line 3 etc...

Doesn't work because the last expression is what's returned...

Expand All @@ -18,10 +21,11 @@ ie:
This returns 5.
What I'm looking for is 3 returns: `undefined`, 5, `undefined`.
Instead the last line returns 5. :(

```js
eval(`
let x;
x=5;
let x;
x=5;
let y;
`')
```
Expand All @@ -31,33 +35,37 @@ This is because of statement vs expression.
SOLUTION!!!!:
Nested eval.
eval(`
let x;
x=5;
eval('let y'); // expression that returns a value
`')
```js
### Eval and pass in execution context
TODO: Make a til on execution context...
eval(` let x;
x=5;
eval('let y'); // expression that returns a value`')
```

### Eval and pass in execution context

TODO: Make a til on execution context...

Q: Could we pass in / provide the scope by doing module wrapping like node
does?
does?

I believe this is how Webpack and node handle module isolation...

```js

// wrapper
function(){

code we want to run


}(); // execute immediately
```

// we could just use the params and args to define the local scope right...?
interesting...

//and then if we replace window, or run web worker we could pass in the scope
and isolate it?
and isolate it?

Q: Could we define the execution context that way? Interesting......
5 changes: 3 additions & 2 deletions javascript/strict-mode.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#
# What is strict mode in JavaScript?

Triggered via `use strict` at the top of a file / script...

Eval behaves differently

- isolates the eval scope from the surrounding scope (makes it more of a sandbox)
- allows eval to use surrounding scope, but won't allow eval to modify the
surrounding scope.
surrounding scope.

More reading:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode
Expand Down
6 changes: 1 addition & 5 deletions npm/subpath-exports.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# How to export sub paths from a library?


```json
"exports": {
".": {
Expand All @@ -20,10 +19,7 @@
^ This means we can now do the following:
`import {} from "@ppcorp/atomic-events`


`import {} from "@ppcorp/atomic-events/dev-logger` <- subpath

`import {} from "@ppcorp/atomic-events/dev-logger` \<- subpath

https://blog.r0b.io/post/esm-nodejs-typescript-with-subpath-exports/
https://nodejs.org/api/packages.html#subpath-exports

6 changes: 3 additions & 3 deletions rust/debugging-rust-with-lldb.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Debugging rust programs with lldb


`$ sudo rust-lldb target/debug/deps/mainMYGITHASH`

https://bryce.fisher-fleig.org/debugging-rust-programs-with-lldb/

## lldb with node
https://asciinema.org/a/29589 <-- great demo of how to use lldb
https://github.com/nodejs/llnode

https://asciinema.org/a/29589 \<-- great demo of how to use lldb
https://github.com/nodejs/llnode

## How to use lldb with vscode

https://tauri.app/v1/guides/debugging/vs-code/
42 changes: 14 additions & 28 deletions screencasting-streaming/sound-mixing-overview.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@


## TODO:

- Gradually copy over the info here...
- make small zettelcasten type notes in a "sound mixning" folder
https://roamresearch.com/#/app/Mordor/page/dEmCEc4ta

https://roamresearch.com/#/app/Mordor/page/dEmCEc4ta

Most of the stuff here is for Reaper but the principles will apply to any sound
mixing process.

## Reaper is a DAW

## Normalizing in Reaper

(right click on track and `item processing->"normalize"`)

This takes the highest volume of the track, and makes that 0db (dbfs aka 0db full scale)

Then "bring down to -3db" means dragging that top 0db level down to -3db (quieter x2)

## Gate
If you get clipping at the end of the word (like quiet end), increase release
## Gate

If you get clipping at the end of the word (like quiet end), increase release

Look at sound or noise gates... and Hysteresis

Expand All @@ -32,29 +31,17 @@ https://www.youtube.com/playlist?list=PL32A31658187EFFE7
**Compression terms**
https://reaperaccessibility.com/index.php/The_fast_and_easy_way_to_understand_compression_and_reaComp_accessibility



https://forum.cockos.com/showpost.php?p=278807&postcount=247
- **How a compressor works**
- Inside the compressor is a little gremlin that turns down the volume. That's it. Really. HOW and WHEN he turns down the volume is determined by the instructions you give him with the compressor controls.
- `THRESHOLD` sets the gremlin's alarm clock. It is what tells him to wake up and start doing what he does, i.e. turning down the volume. If you set the threshold at -10dB then the gremlin just sleeps his lazy ass off, doing nothing at all until the signal level goes above that threshold. A signal that peaked at anything lower than -10dB will never wake up the gremlin and he'll never do a damn thing. (see why presets could be problematic?) But once the signal goes above the threshold, the gremlin rips off the sheets and springs into explosive action.
- `RATIO` decides HOW MUCH the gremlin turns down the volume, and it acts completely in relation to the threshold. If the ratio is set to 2:1, and the signal goes ABOVE the THRESHOLD, then the gremlin will cut that signal in half. For example, with -10 threshold, a signal that hits -5 (which is 5dB ABOVE -10) will be turned down 2.5dB for an output of -7.5dB. Negative values can be confusing if you're not used to thinking in such terms so re-read and ask questions if you're stuck. This is important, and it does get instantly easier once you "get" it.
- `ATTACK` is like a snooze button for the Gremlin's alarm clock. It lets the gremlin sleep in for a little while. So if the THRESHOLD is set for -10dB, and the ATTACK is set to, say, 50ms, then once the signal goes above -10dB, the gremlin will let the first 50ms pass right by while he rubs his eyes and makes coffee. An attack of zero means the gremlin will respond instantly, like a hard limiter, and will allow nothing above threshold to get through unprocessed. Any slower attack means the gremlin will allow the initial "punch" to "punch through" and will only later start to act on the body of the signal.
- `RELEASE` is like a mandatory overtime clock for the gremlin. It tells him to keep working even after the signal has dropped below threshold. A release of zero means strict Union rules-- once the signal drops below threshold, the whistle blows, and the gremlin drops whatever he's doing and goes back to sleep. But a slower release means the gremlin keeps compressing the signal even after it has dropped below the threshold. This can lead to smoother tails and less "pumping" or "sucking" artifacts that come from unnatural and rapid gain changes.


https://forum.cockos.com/showpost.php?p=278807&postcount=247 - **How a compressor works** - Inside the compressor is a little gremlin that turns down the volume. That's it. Really. HOW and WHEN he turns down the volume is determined by the instructions you give him with the compressor controls. - `THRESHOLD` sets the gremlin's alarm clock. It is what tells him to wake up and start doing what he does, i.e. turning down the volume. If you set the threshold at -10dB then the gremlin just sleeps his lazy ass off, doing nothing at all until the signal level goes above that threshold. A signal that peaked at anything lower than -10dB will never wake up the gremlin and he'll never do a damn thing. (see why presets could be problematic?) But once the signal goes above the threshold, the gremlin rips off the sheets and springs into explosive action. - `RATIO` decides HOW MUCH the gremlin turns down the volume, and it acts completely in relation to the threshold. If the ratio is set to 2:1, and the signal goes ABOVE the THRESHOLD, then the gremlin will cut that signal in half. For example, with -10 threshold, a signal that hits -5 (which is 5dB ABOVE -10) will be turned down 2.5dB for an output of -7.5dB. Negative values can be confusing if you're not used to thinking in such terms so re-read and ask questions if you're stuck. This is important, and it does get instantly easier once you "get" it. - `ATTACK` is like a snooze button for the Gremlin's alarm clock. It lets the gremlin sleep in for a little while. So if the THRESHOLD is set for -10dB, and the ATTACK is set to, say, 50ms, then once the signal goes above -10dB, the gremlin will let the first 50ms pass right by while he rubs his eyes and makes coffee. An attack of zero means the gremlin will respond instantly, like a hard limiter, and will allow nothing above threshold to get through unprocessed. Any slower attack means the gremlin will allow the initial "punch" to "punch through" and will only later start to act on the body of the signal. - `RELEASE` is like a mandatory overtime clock for the gremlin. It tells him to keep working even after the signal has dropped below threshold. A release of zero means strict Union rules-- once the signal drops below threshold, the whistle blows, and the gremlin drops whatever he's doing and goes back to sleep. But a slower release means the gremlin keeps compressing the signal even after it has dropped below the threshold. This can lead to smoother tails and less "pumping" or "sucking" artifacts that come from unnatural and rapid gain changes.

- [[Sound mixing]][[Reaper]]
Compression basics
How To Use Compression - Detailed Tutorial
https://www.youtube.com/watch?v=yi0J9JsRdI4
- Where possible, don't compress solo. Do it in comparison to BG music or other tracks you have. EQ etc you can do solo.

Compression basics
How To Use Compression - Detailed Tutorial
https://www.youtube.com/watch?v=yi0J9JsRdI4 - Where possible, don't compress solo. Do it in comparison to BG music or other tracks you have. EQ etc you can do solo.

## DB values

- [[Sound mixing]]
db values
db values

Src: https://pulsarinstruments.com/en/post/understanding-decibels-decibel-scale-and-noise-measurement-units

Expand All @@ -65,12 +52,11 @@ Src: https://pulsarinstruments.com/en/post/understanding-decibels-decibel-scale-
- digital audio describes the current position of a signal with numbers, and when you get up to 0 the numbers have run out, it's as high as you can go, so the same max number just keeps repeating and the peak of your waveform gets chopped clean off, which creates the sound of distortion
- So you want to avoid hitting it so that your audio doesn't distort, and you need to keep at least 10db of a buffer away from it so that a sudden loud part doesn't ruin your recording.
- TODO
- {{[[TODO]]}} Watch this https://nofilmschool.com/2017/06/watch-where-should-your-levels-be-when-recording-audio
- {{[[TODO]]}} Watch: https://www.youtube.com/watch?v=oce3YfLVpc4
- [[TODO]] Watch this https://nofilmschool.com/2017/06/watch-where-should-your-levels-be-when-recording-audio
- [[TODO]] Watch: https://www.youtube.com/watch?v=oce3YfLVpc4

- **Notes**


When you measure noise levels with a sound level meter, **you measure the intensity of noise called decibel units** (dB).

a **logarithmic scale is used**, using 10 as the base, rather than a linear one. This scale is called the `decibel scale`.
Expand All @@ -80,11 +66,10 @@ A `logarithmic scale` is used when there is a large range of quantities. It is b
**Log scale:**
0db - silence
10db - 10x louder than 0db
20 db - 1000x louder than 0db
20 db - 1000x louder than 0db

![](https://firebasestorage.googleapis.com/v0/b/firescript-577a2.appspot.com/o/imgs%2Fapp%2FMordor%2FOaNLZ8gzNh.png?alt=media&token=ec75c936-9726-4c9c-a386-74f2670e744d)


**Common sound values:**

- Near-total silence - 0 dB
Expand All @@ -102,4 +87,5 @@ A `logarithmic scale` is used when there is a large range of quantities. It is b
- So you want to avoid hitting it so that your audio doesn't distort, and you need to keep at least 10db of a buffer away from it so that a sudden loud part doesn't ruin your recording.
- Also, though, the analog stages that your signal goes through, such as your preamps and the analog parts of your a/d converter are optimized to work at a certain level. This level is the zero of the analogue world, 0db**vu**. At this point analoge gear is designed to have its sweetspot, where the signal is high above the noise of the circuit, but not so high that it starts to distort. However unlike digital, it's alright if your signal goes over 0dbvu a bit because the distortion is usually gradual, and sometimes kind of nice sounding. This 0dbvu usually translates to around -18dbfs, but different converter designs can be calibrated to different levels. So you want to have your analogue levels around this level while your recording so that you get the best sound out of your gear.
- I'm not really sure why the digital scale has to be negative, but that it how it is and there is no option to use another scale.

https://forum.cockos.com/showthread.php?t=113067
Loading

0 comments on commit f303a0c

Please sign in to comment.