Skip to content

Instantly share code, notes, and snippets.

View claus's full-sized avatar
🎅

Claus Wahlers claus

🎅
View GitHub Profile
@claus
claus / custom.css
Last active February 19, 2023 22:18
Mastodon: Add red border to images without description
/* Fix image gallery styles */
/* Add red border-bottom to media without description */
/* Left image */
.media-gallery__item[style^="inset: auto 2px auto auto"] {
margin-right: 2px;
}
/* Top left image */
.media-gallery__item[style^="inset: auto 2px 2px auto"] {
@claus
claus / ProtonMailUnreadMessageCount.js
Last active June 6, 2022 07:17 — forked from TChilderhose/ProtonMailUnreadMessageCount.js
ProtonMail Unread Message Count in Favicon
// ==UserScript==
// @name ProtonMail Unread Message Count in Favicon
// @description Shows the number of unread ProtonMail messages in the FavIcon
// @version 1.2
// @author Tyler Childerhose, Claus Wahlers
// @homepageURL https://gist.github.com/claus/e92b3b4a3ac6c0ddb4cdb71ad6797fcf
// @match https://mail.proton.me/*
// @grant none
// ==/UserScript==
@claus
claus / html-to-contentful.js
Last active April 4, 2022 16:40
Convert HTML to Contentful Rich Text Document object structure
import { parse as parseHtml } from 'node-html-parser';
import { MARKS, BLOCKS, INLINES } from '@contentful/rich-text-types';
const tagMap = new Map([
['p', { type: 'block', nodeType: BLOCKS.PARAGRAPH }],
['h1', { type: 'block', nodeType: BLOCKS.HEADING_1 }],
['h2', { type: 'block', nodeType: BLOCKS.HEADING_2 }],
['h3', { type: 'block', nodeType: BLOCKS.HEADING_3 }],
['h4', { type: 'block', nodeType: BLOCKS.HEADING_4 }],
['h5', { type: 'block', nodeType: BLOCKS.HEADING_5 }],
@claus
claus / base64fixer.js
Created August 25, 2021 19:12
Fixes base64 casing in case it got lost
const b64alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
const b64 = 'd2ugzwnobyb3zsbly2hvihdligvjag8gd2ugzwnobyb3zsbly2hvihdligvjag8gcndligvjag8gd2ugsgvsbg8/igvjag8gd2ugzwnobyb3zsbly2hvihdligvjag8gd2ugzwnobyakd2ugzwnobyb3zsbly2hvifdlignhbibtyxlizsbzzw5kigegbwvzc2fnzsb3zsakd2ugzwnobyb3zsbly2hvihdligvjag8gd2ugzwnobyb3zsbly2hvihdligvjag8gcndligvjag8gd2ugzwnobyb3zsb3agvyzsbhcmugd2u/igvjag8gd2ugzwnobyakd2ugzwnobyb3zsbzb21lag93igvjag8gd2ugzwnobyb3zsbly2hvihdligvjag8gcndligvjag8gd2ugzwnobyb3zsbly2hvihdligvjag8gd2ugzwnobyb3zsbly2hviap3zsbly2hviekgc2vligegbglnahqgynv0igl0j3mgzg9lc250igxvb2sgcmlnahqgiap3zsbly2hvihdligvjag8gd2ugzwnobyb3zsbly2hvihdligvjag8gd2ugzwnobyakd2ugzwnobyb3zsbly2hvienhbib5b3ugagvhcibtzt8gd2ugzwnobyb3zsbly2hvia=='.toUpperCase();
const b64arr = b64.split('');
function getBestMatch(quad) {
const scores = [];
let cancelled = false;
for (let i = 0; i < 16; i++) {
const bin = i.toString(2).padStart(4, '0');
const res = new Array(3).fill(0);
/*
Make sure you have Node.JS and Outguess.app installed.
Copy this file as 'outguess.js' into an empty folder.
In that folder, run:
npm init
npm i guess-file-type tmp png-js
Change OUTGUESS_APP, WORK_DIR, SOURCE and VERBOSE below as you need them.
@claus
claus / example.js
Last active January 24, 2021 08:30
Proxy wrapper for tweenjs that automatically starts/stops requestAnimationFrame so you don't have to
import { tween } from './tween';
tween({ x: 0 })
.to({ x: 1 }, 200)
.onStart(() => { console.log('onStart') })
.onStop(() => { console.log('onStop') })
.onComplete(() => { console.log('onComplete') })
.onUpdate(tweenObj => { console.log('onUpdate', tweenObj.x) })
.start(1000)
@claus
claus / sbRichTextReactRenderer.js
Last active August 1, 2020 06:43
Storyblok Rich Text Renderer for React
/*
Usage:
storyblokRichTextRenderer(document, {
blokResolvers: {
// Resolve a blok to a custom React component
['test_blok']: props => <TestBlok {...props} />
},
nodeResolvers: {
// Resolve a node to a custom React component
1D=@%:$D="$=E5H9HAI=E// 32 G.UBOBJ7I1M3I.H8EE5A3D3B / ,D F3J3;D?DIAP=YBW8S2P0P""D &1V9^;_A[AZ;S1V'=RCYEYMTMSDKCP=R&@ENSPSVNVMIB@E&JBWLYL_H^FP>JB":MO.0:V.19;3;0;19,1,0;0;5
2F.I=1TO7:V=?D:D=D+1:F.J=32TOV:X=?D*8+128:Y=D?1*12-288:D=D+2:PL.5+(J<33),X,Y:N.:PL.&85,X-8*(I>1),Y+4:N.:F.I=0TO32:MOV.640,512:PL.145,416+I*2,0:N.:GC.0,0:F.I=0TO900:PL.69,RND(1279),RND(1023):N.
@claus
claus / migrar-mastodon.md
Created June 15, 2020 23:50
Migrando de uma instância Mastodon para outra

Migrando de uma instância para outra

Este é o passo-a-passo de como migrar sua conta no mastodon de uma instância para outra. Você pode migrar tudo (seguidores, seguidos, silenciados e bloqueados) exceto seus toots e mídia, você pode exportá-los mas não pode importá-los na nova instância.

Primeiro de tudo, para migrar de uma instância para outra, você deve fazer uma nova conta na instância para a qual você quer mudar, então siga os passos abaixo:

  1. Na nova instância vá em Preferências > Conta > Configurações da conta

    migrate-1

@claus
claus / _app.js
Created May 14, 2020 05:35
Restore scroll position after navigating via browser back/forward buttons in Next.js
import useScrollRestoration from "utils/hooks/useScrollRestoration";
const App = ({ Component, pageProps, router }) => {
useScrollRestoration(router);
return <Component {...pageProps} />;
};
export default App;