Skip to content

Instantly share code, notes, and snippets.

View MRobertEvers's full-sized avatar

Matthew Evers MRobertEvers

View GitHub Profile
@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
@MRobertEvers
MRobertEvers / engineering.md
Created January 23, 2019 13:23
Engineering

Tolerances And Uncertainty

Tolerances are usually given as absolutes. I.e. No uncertainty. This is specified in by the American Society of Mechanical Engineers (ASME), although, it could probably be specified case to case. See this thread on the discussion https://www.eng-tips.com/viewthread.cfm?qid=176582. That thread references ASME Y14.5M-1994, section 2.5, Interpretation of Limits.

A newer version of that document is http://www-eng.lbl.gov/~shuman/NEXT/ANGEL2/ASME-Y14-5M-2004-Dimension-Ing-and-Tolerancing.pdf.

@MRobertEvers
MRobertEvers / oglNotes.md
Created December 9, 2018 02:26
OpenGL Notes

OpenGL

OpenGL is a graphics pipeline and specification that defines how to perform graphical operations.

Windowing

OpenGL doesn't handle windowing because windowing is platform specific. A third party library is needed for cross platform windowing.

@MRobertEvers
MRobertEvers / SphinxDocNotes.md
Last active November 21, 2018 14:04
SphinxDocs

Sphinx Notes

Docs in another dir

In order to include modules from another directory, import the directory w.r.t. the 'doc' directory. E.g. if you put the docs folder in the top level directory of the project, the sphinx interpreter runs in the docs directory. Thus, to import the top level directory, import ... If you want to import a folder within the top level directory import ../<folder>.

import os
import sys
sys.path.insert(0, os.path.abspath('..'))