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 April 2, 2019 11:41
Lint-Staged - lint only staged files with eslint and stylelint

Lint-Staged - lint only staged files with eslint and stylelint

Based on the solution created by luuuis, I added two npm scripts lint-css-staged and lint-js-staged. They both lint (with ESLint and stylelint) only staged files.

You could also use pre-commit.sh from luuuis, if you do not want to put this into your package.json.

Prettier provides an example as well.

@natterstefan
natterstefan / test.js
Created April 6, 2019 08:07
JEST & ENZYME | test component with React.createRef()
import React from 'react'
import { mount } from 'enzyme'
describe('Foo', () => {
it('enzyme should mount object refs', () => {
// inspired by:
// - https://stackoverflow.com/a/55292957/1238150
// - https://github.com/styled-components/styled-components/blob/e6f1b85726512cde163dd5fcdd7fb0f2439d4a09/packages/styled-components/src/test/basic.test.js
// - https://github.com/styled-components/styled-components/blob/e6f1b85726512cde163dd5fcdd7fb0f2439d4a09/packages/styled-components/src/hoc/withTheme.js
@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
@natterstefan
natterstefan / backup.sh
Created May 1, 2019 05:41
Raspberry Pi | Backup and Sync Pi-hole and UniFi data from a Raspberry Pi to Google Drive
#!/bin/bash
# create backup folders (if they do not exist yet)
mkdir -p ~/backups
mkdir -p ~/backups/unifi
mkdir -p ~/backups/pihole
# backup pi-hole
(cd ~/backups/pihole && pihole -a teleporter)
@natterstefan
natterstefan / gdrive-setup.sh
Last active July 8, 2020 17:58
Raspberry Pi | Setup gdrive
#!/bin/bash
# im ersten Schritt laden wir gdrive herunter (den Download-Link
# Link habe ich von hier: https://github.com/gdrive-org/gdrive#downloads)
$ wget https://drive.google.com/uc?id=1f5Q-yAwUYZYt_frYjodFHbU0v7ppQkem&export=download
# wir ändern den Namen der Datei
$ mv uc\?id\=1f5Q-yAwUYZYt_frYjodFHbU0v7ppQkem gdrive
# nun machen wir die Datei ausführbar
@natterstefan
natterstefan / index.html
Last active December 25, 2019 17:47
VS Code Test
<h1>Hello World</h1>
@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 / README.md
Last active November 30, 2022 14:57
Typescript | Infere Types from PropTypes

Infer Types from PropTypes

Result

image

image

Limitations

@natterstefan
natterstefan / keyboard.json
Created February 11, 2020 11:51
VS Code | Increase and decrease Workbench Command
[
{
"key": "shift+cmd+j",
"command": "workbench.action.increaseViewSize",
},
{
"key": "shift+cmd+k",
"command": "workbench.action.decreaseViewSize",
},
]
@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.