Skip to content

Instantly share code, notes, and snippets.

Avatar
🎅

Claus Wahlers claus

🎅
View GitHub Profile
@claus
claus / example.js
Created Sep 22, 2020
Proxy wrapper for tweenjs that automatically starts/stops requestAnimationFrame so you don't have to
View example.js
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 Aug 1, 2020
Storyblok Rich Text Renderer for React
View sbRichTextReactRenderer.js
/*
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
View gist:7f80a5704a95b5d69925b5caaaada6a0
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 Jun 15, 2020
Migrando de uma instância Mastodon para outra
View migrar-mastodon.md

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
Restore scroll position after navigating via browser back/forward buttons in Next.js
View _app.js
import useScrollRestoration from "utils/hooks/useScrollRestoration";
const App = ({ Component, pageProps, router }) => {
useScrollRestoration(router);
return <Component {...pageProps} />;
};
export default App;
@claus
claus / flashforward.asm
Created Oct 16, 2019
6502 assembler intro for Flash Forward awards ceremony 2006 in Austin, Tx (FC64 emulator)
View flashforward.asm
; FC64 Flashforward Trailer
; =========================
; Basic: "1 SYS(2064)"
.a 0801
.b 0d,08,01,00,9e,28,32,30,36,34,29,00,00,00,00
@claus
claus / NextWorkboxPlugin.js
Last active Oct 15, 2019
Simple Webpack plugin to create Workbox based service workers for Next.js 9.1+ projects.
View NextWorkboxPlugin.js
const fs = require('fs');
const path = require('path');
const crypto = require('crypto');
const readdir = require('recursive-readdir');
const SW_NAME = 'sw.js';
const fileBlacklist = [
'sw.js',
'build-manifest.json',
@claus
claus / screencapture.sh
Created Sep 11, 2018
MacOS: capture screenshot and add it to IPFS
View screencapture.sh
# Exit on errors
set -e
set -o pipefail
# Filename of captured image
FILE="$(date +%Y-%m-%d-%H-%M-%S).png"
# User/host
HOST="user@xx.xxx.xxx.xxx"
# Capture screen (interactively) and save image to the desktop
screencapture -i ~/Desktop/$FILE
# Upload the captured image to the server
@claus
claus / functions.php
Created Aug 17, 2018
Wordpress: Also search tags in addition to post title and content
View functions.php
function tax_search_join( $join, $query ) {
global $wpdb;
if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) {
$join .= "
INNER JOIN
{$wpdb->term_relationships} ON {$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id
INNER JOIN
{$wpdb->term_taxonomy} ON {$wpdb->term_taxonomy}.term_taxonomy_id = {$wpdb->term_relationships}.term_taxonomy_id
INNER JOIN
{$wpdb->terms} ON {$wpdb->terms}.term_id = {$wpdb->term_taxonomy}.term_id
@claus
claus / data-prefetching-in-next-js.md
Last active Aug 25, 2020
Data Prefetching in Next.js
View data-prefetching-in-next-js.md

Data Prefetching in Next.js

You can’t perform that action at this time.