Skip to content

Instantly share code, notes, and snippets.

View maxboeck's full-sized avatar

Max Böck maxboeck

View GitHub Profile
import fetch from 'node-fetch'
import dotenv from 'dotenv'
import Twitter from 'twitter'
import { decode } from 'html-entities'
dotenv.config()
// URL of notes JSON feed
const NOTES_URL = 'https://mxb.dev/notes.json'
@maxboeck
maxboeck / allsettled.js
Created December 18, 2020 08:59
Promise.allSettled
// Promise.all: if one promise rejects, all fail.
const [dogs, cats, possums] = await Promise.all([
getDogs(),
getCats(),
getPossums()
])
// Promise.allSettled: if one rejects,
// the others will still go through!
const allRequests = await Promise.allSettled([
➜ ~ curl -H "Accept-Encoding: gzip,deflate,br" -I -X GET https://mxb.dev
HTTP/2 200
cache-control: public, max-age=0, must-revalidate
content-type: text/html; charset=UTF-8
date: Thu, 20 Aug 2020 12:00:12 GMT
etag: "631b652bdb73e4d0c9b90d79a626dac9-ssl-df"
referrer-policy: no-referrer-when-downgrade
strict-transport-security: max-age=31536000
x-content-type-options: nosniff
x-frame-options: DENY
@maxboeck
maxboeck / tooltip.css
Created August 24, 2019 10:21
CSS tooltip
/* ToolTip */
[aria-label].has-tooltip {
position: relative;
}
[aria-label].has-tooltip::after {
display: block;
content: attr(aria-label);
width: auto;
@maxboeck
maxboeck / git-append-issue
Created May 15, 2019 09:30
Custom git command to append an issue number to the last commit message.
#!/bin/sh
OLD_MSG=$(git log --format=%B -n1)
git commit --amend -m "$OLD_MSG, #$1"
@maxboeck
maxboeck / donottrack.js
Last active November 6, 2023 10:00
Check "Do Not Track" Client Hint
const allowsTracking = () => {
const dnt =
window.doNotTrack ||
navigator.doNotTrack ||
navigator.msDoNotTrack
if (dnt === 1 || dnt === '1' || dnt === 'yes') {
return false
}
if ('msTrackingProtectionEnabled' in window.external) {
return !window.external.msTrackingProtectionEnabled()
@maxboeck
maxboeck / selection.css
Created April 17, 2019 15:26
Custom Selection Color
/* Custom Selection Color */
::selection {
background: #d81e05;
color: #ffffff;
}
::-moz-selection {
background: #d81e05;
color: #ffffff;
@maxboeck
maxboeck / array_from_mapping.js
Last active April 2, 2019 13:32
Array.from mapping function
const allButtons = document.querySelectorAll('button');
const init = btn => {
btn.classList.add('is-initialized');
btn.addEventListener('click', () => console.log(btn, 'clicked'));
return btn;
}
Array.from(allButtons, init);
@maxboeck
maxboeck / cardlist.html
Last active February 24, 2019 19:13
linked card pattern
<ul>
<li class="card">
<a href="/foo" class="card__link">
<p class="card__title">The Card Title</p>
<img class="card__image" src="/some/image.jpg" alt="">
<small class="card__meta">Some category</small>
<p class="card_summary">Lorem ipsum, dolor sit amet!</p>
</a>
</li>
{
"Create a stateless React component": {
"prefix": "scomp",
"description": "A stateless component",
"body": [
"import React from 'react'",
"import PropTypes from 'prop-types'",
"\nconst $1 = props => {",
"\treturn (",
"\t\t$0",