Skip to content

Instantly share code, notes, and snippets.

View natterstefan's full-sized avatar
🟨
getting things done 💪🏻

Stefan Natter natterstefan

🟨
getting things done 💪🏻
View GitHub Profile
@natterstefan
natterstefan / README.md
Last active May 7, 2024 17:47
NODE | macOS fix node-gyp

Research | macOS fix node-gyp

visitors

Node

Update asdf

asdf plugin-update --all
@natterstefan
natterstefan / HTMLToReact.tsx
Last active April 8, 2024 13:54
html-react-parser | TypeScript solution
/**
* Works in Next.js 10.x
*/
import React from 'react'
import parse, {
domToReact,
attributesToProps,
Element,
HTMLReactParserOptions,
} from 'html-react-parser'
@natterstefan
natterstefan / README.md
Last active February 23, 2024 19:40
JEST | Debug with Google Chrome and/or VS Code

How to debug Jest tests with Chrome

Taken from Jest's troubleshooting page:

  • Place a debugger; statement in any of your tests, and then, in your project's directory
  • yarn test-debug
  • open Chrome and go to chrome://inspect
  • click on "Open Dedicated DevTools for Node"
  • click on the address displayed in the terminal (usually something like
@natterstefan
natterstefan / password_autofill_expo_how_to.md
Created March 18, 2020 20:10 — forked from amcvitty/password_autofill_expo_how_to.md
Configure Password Autofill on a React Native Expo app

Password Autofill on a React Native Expo app

Developing an app to accompany our website, worried that we would lose people in the transition if they couldn't remember their password, we were looking to make our app do Password AutoFill, a feature in iOS.

A talk from WWDC introducing the feature: https://developer.apple.com/videos/play/wwdc2017/206/

It works well, but there were a few bumps in the road making it work for React Native on Expo, so here are some notes to help out.

Apple's docs are here: https://developer.apple.com/documentation/security/password_autofill and they say something like this:

@natterstefan
natterstefan / README.md
Last active December 12, 2023 09:49
Jest | Mock jsdom errors
@natterstefan
natterstefan / README.md
Created February 18, 2020 14:47
Jest | Mock useState

Jest - mock useState

When using import React, { useState } from 'react' in your components, this is how you can mock useState with jest.

@natterstefan
natterstefan / README.md
Last active October 17, 2023 18:26
VSCode | Debug tests in Create-React-App (all or single file)

VSCode | Debug tests in Create-React-App (all or single file)

Add launch.json into the .vscode folder.

image

Now, enter the Debug view. Either add debugger into one of the tests or add breakpoints, before you execute one of the scripts.

image

@natterstefan
natterstefan / moveMouse.js
Created April 27, 2023 19:40
JS Utils | Move Mouse Randomly Forever
// function to generate a random number within a range
function getRandomNumber(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// function to generate a random mouse coordinate within the viewport
function getRandomCoordinate() {
const x = getRandomNumber(0, window.innerWidth);
const y = getRandomNumber(0, window.innerHeight);
return { x, y };
@natterstefan
natterstefan / README.md
Created January 18, 2023 10:08
Next.js | Catchall including index

Next.js | Catch-All route including index

@natterstefan
natterstefan / setup.sh
Last active January 9, 2023 04:25
Raspberry Pi | Setup gdrive to sync local folder to Google Drive
#!/bin/bash
# gdrive client: https://github.com/gdrive-org/gdrive
# inspired by https://github.com/gdrive-org/gdrive/issues/205#issuecomment-423759052
# Create directory ~/backups (must be empty at the beginning)
rm -rf ~/backups && mkdir ~/backups
# upload it the first time into a parent directory
# 1234 => id of the parent directory on google drive
# eg. https://drive.google.com/drive/u/0/folders/1234