Skip to content

Instantly share code, notes, and snippets.

View simonhaenisch's full-sized avatar
💪
Staying fefeka.

Simon Hänisch simonhaenisch

💪
Staying fefeka.
View GitHub Profile
@simonhaenisch
simonhaenisch / rpi-airprint.md
Last active July 16, 2023 19:03
Raspberry Pi, Arch Linux, CUPS, Avahi, AirPrint, USB Printer (Samsung SCX)
@simonhaenisch
simonhaenisch / intercept-node-fetch-requests.md
Last active May 27, 2024 23:22
How to intercept node-fetch (Next.js) requests so that headers can be inspected (with Proxyman).
  1. Install Proxyman (https://proxyman.io/).
  2. Install https-proxy-agent from NPM (https://www.npmjs.com/package/https-proxy-agent).
  3. Add an agent to your fetch call so that requests get sent through Proxyman.
import ProxyAgent from 'https-proxy-agent';

export const request = async (url: string, options: RequestOptions) => fetch(url, {
  ...options,
 agent: ProxyAgent('http://localhost:9090'), // 9090 is the default port of Proxyman (see prefs)
@simonhaenisch
simonhaenisch / config.js
Created January 14, 2020 06:23
Custom marked renderer for including other markdown files in md-to-pdf.
const { readFileSync } = require('fs');
const { Renderer } = require('marked');
const getMarked = require('md-to-pdf/lib/get-marked-with-highlighter');
const renderer = new Renderer();
const originalLinkRenderer = renderer.link.bind(renderer);
renderer.link = (href, title, text) => {
if (text !== 'include') {
@simonhaenisch
simonhaenisch / create-wildcard-cert.md
Last active August 28, 2018 05:29
Cloudcannon: Create Wildcard Certificate with Certbot
  1. Run Certbot:
sudo certbot certonly --manual --server https://acme-v02.api.letsencrypt.org/directory
  1. Enter Domains, e. g. domain.tld,*.domain.tld.
  2. Add _acme-challenge DNS record.
  3. Upload .well-known/acme-challenge file to website:
@simonhaenisch
simonhaenisch / fetch-typekit-fonts.js
Last active May 21, 2018 02:53
Load typekit fonts using the fetch API and abort the request if it takes to long. Example: https://equippers.de
if (window.fetch) {
(async d => {
const controller = new AbortController();
const signal = controller.signal;
setTimeout(() => controller.abort(), 750);
const res = await fetch('https://use.typekit.net/xxxxxxx.css', { signal });
const css = await res.text();
const style = d.createElement('style');
style.textContent = css;
d.querySelector('head > *:last-child').after(style);
@simonhaenisch
simonhaenisch / addTransition.styl
Created March 17, 2018 09:26
Add transition mixin/function for Stylus
addTransition(props, duration = 300ms)
// examples:
// - addTransition(color)
// - addTransition(color, 1s)
// - addTransition('color, background-color')
// - addTransition('color, background-color', 500ms)
$parts = ()
for prop in split(', ', props)
push($parts, prop)
@simonhaenisch
simonhaenisch / install.sh
Last active February 15, 2018 00:49
sync slideshows from Google team drive using rclone on ARM #raspberrypi
# see https://gist.github.com/simonhaenisch/0ca8534bf50f189b4f93d1cc1f20c58f
su # run as root
pacman -Sy # update repos
pacman -S git go # install git and go compiler
go get -u -v github.com/ncw/rclone # installs into ~/go/bin/rclone
mkdir /var/gdrive/slides
@simonhaenisch
simonhaenisch / npm-update-to-latest.sh
Created July 27, 2017 05:58
update all outdated npm packages to latest version
#!/bin/bash
# get output
output=`npm outdated --long`
# get name and type (regular or dev dependency) of all packages
counter=0
for token in $output
do
if [ $((counter > 6)) == 1 ] # skip first 7 tokens
@simonhaenisch
simonhaenisch / sqs_modals.html
Last active June 21, 2017 10:22
Custom modals as header injection for default Squarespace templates
<script>
// --
// Enter Data Here
var data = {
header: "Title",
paragraph: "Lorem ipsum..."
}
@simonhaenisch
simonhaenisch / video-player.html
Last active August 12, 2024 07:59
Play local video files in the browser (HTML5 video player) with playlist, speed control and keyboard shortcuts for pause (spacebar) and 5 second jump (left/right arrow). Created to watch Wes Bos tutorials offline. Playback speed defaults to 2x.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Local HTML5 Video Player</title>
</head>
<body>
<style>
* { box-sizing: border-box; }