Skip to content

Instantly share code, notes, and snippets.

View MRobertEvers's full-sized avatar

Matthew Evers MRobertEvers

View GitHub Profile
@MRobertEvers
MRobertEvers / NodejsAwaitCallstack.md
Last active March 26, 2025 13:43
nodejs await callstack
async function thrower() {
  throw new Error('error')
}

async function A() {
  return thrower()
}

async function B() {
@MRobertEvers
MRobertEvers / mrobertevers.pub
Created March 7, 2025 18:01
MatthewPublicKey
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDro2WC5iqnDLmQhFChzObbylQ4gGbOMQLMlUMchgTNKeM1hiBlQ7Xg5NNTQuHpFNWTbhYeuhW+idWVPHThZRf28sDcXQFDQYjSu0kFBeFH2sQU7S1Aj9ioYdQF2z3wY/2yCM18W4JbS/WX94LrqBIMjo0Bm/JCwZTM8KJFAlQ68Re4XHhQ6XVu+2kqeqVveyl+lFi30KoVv2ArjdC0V/BJMQVKCZ/CNLxeaND2Mxgo3cjpFhY700Xq1vIEBEJ+dR6gXCDttbRE/q7But3+84Dcm4fa+wbOGQSWxZRTY8DFRBEYclftCNtlvLqDVo42xy5xFbuOshaVZI5lpY7Gh0XVbc/I22ALs/08Ic1Tz6ZUj5W4H6lyusPCmkL0AXBg9i+SK1Goqg+38Ztdp1Y2PYsxZudwM70jllGNMASedVy5qzYljxj1AkNEGkb+CSzhMeu4l/uifMx54bjKNbOc71pZtnF39ds+VW1Je60sRsAzz210zcy0mSdGdXUP5ON6ylc= mrobertevers
@MRobertEvers
MRobertEvers / reduce.js
Last active March 6, 2025 17:08
Reduce N2 Behavior
function _map1(arr) {
return arr.reduce((acc, item) => {
acc[item] = item
return acc
}, {})
}
function _map2(arr) {
return arr.reduce((acc, item) => ({ ...acc, [item]: item }), {})
}
@MRobertEvers
MRobertEvers / iframes_modals.md
Created March 24, 2022 17:11
IFrames In Modals

Careful when putting IFrames in modals. If the modal is otherwise invisible and has pointer-events: none, the iframe will still capture events. The Iframe is capturing pointer events even though a parent div has "pointer-events: none"...

Chromium says that this works as intended 12:00 https://bugs.chromium.org/p/chromium/issues/detail?id=451929 12:01 "Iframes" aren't the target of tap/touch events, so 'pointer-events: none' doesn't apply to them. Then I guess Mozilla disagrees or this is a bug in Firefox? TIL

@MRobertEvers
MRobertEvers / my_react_vscode_snippets.md
Last active August 20, 2022 15:00
React VSCode Snippets

New Component

  "New Component": {
    "prefix": "rfc",
    "body": [
      "interface ${name:${TM_FILENAME_BASE}}Props {}",
      "",
      "export const ${name:${TM_FILENAME_BASE}} = (props: ${name:${TM_FILENAME_BASE}}Props) => { return <div></div> }"
    ]
@MRobertEvers
MRobertEvers / objectivecpp_helloworld.cpp
Last active November 26, 2021 15:18
Compile Objective-Cpp Code (Mac)
```
# -lstdc++ links against the cpp std lib
# -framework Foundation includes the Objective c(pp) foundation
# -fobjc-arc Enables ARC
clang -lstdc++ -framework Foundation -fobjc-arc main.mm -o hello
./hello
```
```objective-c
@MRobertEvers
MRobertEvers / cvpixelbuffer_from_rtcvideoframe.md
Created November 18, 2021 23:42
Create CVPixelBuffer from RTCVideoFrame

Create CVPixelBuffer from RTCVideoFrame

Imports

// Google's WebRTC SDK
#import <WebRTC/WebRTC.h>

@import CoreImage;
@import CoreVideo;
@MRobertEvers
MRobertEvers / feed-pattern.md
Last active April 7, 2021 20:14
Feed Pattern Programming Thoughts

Dependency Free Feed Patterns

I've been thinking about a way to write code that is both dependency free and blocking free for several use cases. (A serial protocol for example)

I've seen solutions where the dependencies are injected into the library code, and the library calls the dependency that way, but if the library is expecting polling, or blocking behavior, that isn't good. E.g. If a uart driver needs a delay(ms) function, that's bad; I don't want the uart driver to block.

Instead, I imagine the library code to return instructions back to the app code, describing what the app should do. (redux-saga for react does something like this, where they return 'effects' - I like that)

So instead of the library code blocking with the delay function - return an 'effect' (stealing redux-saga terms) describing how long to wait. TASK_WAIT_10MS or something like that. It doesn't have to be the returned value, but the idea is that the library code communicates what it needs from the user.

@MRobertEvers
MRobertEvers / program_config.md
Last active February 25, 2021 15:42
Program Config

Program Config as Code

I thought it was weird that some software/libs/frameworks take executable code as config, but I recently read a blog talking about DSLs and config files with conditionals and statements.

It talked about how certain programs provide a DSL in their yaml configs (obviously in-house for each program). These DSLs are not portable because every system rolls their own.

Article here, https://blog.earthly.dev/intercal-yaml-and-other-horrible-programming-languages/

For example, Webpack can take config as an executable javascript file. I always thought that was weird (not bad), but I think I much prefer it to a DSL embedded in yaml or JSON.

@MRobertEvers
MRobertEvers / SoCArch.md
Created February 10, 2021 20:57
Understanding SoC Bus Arch and Clocks

Clocks

I was trying to understand the clocking mechanism in the stm32l0 (among other stms). I was trying to figure out how I would know to enable, e.g. __HAL_RCC_GPIOA_CLK_ENABLE when modifying certain registers.

I found the answer in memory map section, which specifies which peripheral each memory mapped region belongs. Turns out GPIOH is its own peripheral, (I assume, although not explicitly stated, that 'GPIOH' is the peripheral that handles the multiplexing of physical pins.)

Copied from section 2.2.2 of Stm32l0x reference manual.

Memory map and register boundary addresses
See the datasheet corresponding to your device for a comprehensive diagram of the