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 / 0_reuse_code.js
Created July 28, 2016 13:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@natterstefan
natterstefan / .eslintrc.json
Last active September 20, 2021 19:43
.eslintrc Example
{
"extends": "airbnb",
"parser": "babel-eslint",
"env": {
"browser": false,
"node": true,
"es6": true,
"mocha": false
},
"parserOptions": {

Keybase proof

I hereby claim:

  • I am natterstefan on github.
  • I am natterstefan (https://keybase.io/natterstefan) on keybase.
  • I have a public key ASDj9cIeoiAekkMwiS1ZlqPPfts4yWHQ89OQNX8b_TOaHAo

To claim this, I am signing this object:

@natterstefan
natterstefan / plate-snitch.js
Created September 1, 2017 06:19 — forked from taitems/plate-snitch.js
(Extract) Check the status of a vehicle registration and scrape results.
// Open form and submit enquire for `rego`
function getInfo(rego) {
horseman
.userAgent('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0')
.open(url)
.type('#registration-number-ctrl input[type=text]', rego)
.click('.btn-holder input')
.waitForSelector('.ctrl-holder.ctrl-readonly')
.html()
.then(function(body) {
@natterstefan
natterstefan / jest-react-intl-setup.js
Created June 4, 2018 19:37
Jest Helper for react-intl
/**
* Components using the react-intl module require access to the intl context.
* This is not available when mounting single components in Enzyme.
* These helper functions aim to address that and wrap a valid,
* English-locale intl context around them.
*
* Docs
* - https://github.com/yahoo/react-intl/wiki/Testing-with-React-Intl#enzyme
* - https://github.com/yahoo/react-intl/wiki/Testing-with-React-Intl#snapshot-testing
*
@natterstefan
natterstefan / scrollbar.css
Created July 4, 2018 20:04
CSS: vertical scrollbar
/* width */
::-webkit-scrollbar {
width: 5px;
border: 1px solid #d5d5d5
}
/* Track */
::-webkit-scrollbar-track {
background: #f1f1f1;
}
@natterstefan
natterstefan / list.js
Created July 31, 2018 17:19
React - Example Component connected to react-router server w/ prefetching data
/* eslint-disable no-underscore-dangle */
import React from 'react'
import PropTypes from 'prop-types'
import get from 'lodash.get'
import BemHelper from 'react-bem-helper'
import { apiClient } from '../../../common/api/client'
// Styling
const classes = new BemHelper('list')
@natterstefan
natterstefan / promise-all.js
Created August 7, 2018 16:59
Avoiding promise.all to fail
// inspired by (Credits):
// - A: https://davidwalsh.name/promises-results
// - B: https://nmaggioni.xyz/2016/10/13/Avoiding-Promise-all-fail-fast-behavior/
// Solution A
await Promise.all(loadDataRequests.map(p => p.catch(() => undefined)))
// Solution B
await Promise.all(
loadDataRequests.map(p =>
@natterstefan
natterstefan / README.md
Last active September 17, 2021 12:44
How to track content statistics for Facebook Instant Articles with Google Analytics

Track Facebook Instant Articles with Google Analytics

The *.html example assumes you have integrated the tracking code as an iframe in the instant articles feed.

<figure class="op-tracker">
    <iframe src="https://www.example.com/fia-google-analytics-tracking.html"></iframe>
</figure>
@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