This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function cleanUTF8(str){ | |
| return str.replace(/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]|[\x00-\x7F][\x80-\xBF]+|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/g,'') | |
| .replace(/\xE0[\x80-\x9F][\x80-\xBF]|\xED[\xA0-\xBF][\x80-\xBF]/g,''); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # usage: | |
| # ./server.sh [port] [response] | |
| # | |
| RESPONSE="HTTP/1.1 200 OK\r\nConnection: keep-alive\r\n\r\n${2:-"OK"}\r\n" | |
| while { echo -en "$RESPONSE"; } | nc -q 0 -l -p "${1:-8080}"; do | |
| echo "================================================" | |
| echo "you can do stuff on request" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env python | |
| """ | |
| Pandoc filter to convert svg files to pdf as suggested at: | |
| https://github.com/jgm/pandoc/issues/265#issuecomment-27317316 | |
| """ | |
| __author__ = "Jerome Robert" | |
| import mimetypes | |
| import subprocess |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| if [[ "$1" == "" ]]; then | |
| echo 'usage: deploy <origin> <branch>' | |
| exit | |
| fi | |
| if [[ "$2" == "" ]]; then | |
| echo 'usage: deploy <origin> <branch>' | |
| exit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (str, alpha) => { | |
| if(!/^#([A-Fa-f0-9]{3}){1,2}$/.test(str)) | |
| throw new Error('Bad hex') | |
| let c = str.substring(1).split('') | |
| if(c.length === 3) c = [c[0], c[0], c[1], c[1], c[2], c[2]]; | |
| c = '0x'+c.join(''); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cd ~ && chmod 600 ~/.ssh/* && chmod 700 ~/.ssh && chmod 644 ~/.ssh/*.pub |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function easeOutElastic(x) { | |
| const c4 = (2 * Math.PI) / 3; | |
| return x === 0 | |
| ? 0 | |
| : x === 1 | |
| ? 1 | |
| : Math.pow(2, -10 * x) * Math.sin((x * 10 - 0.75) * c4) + 1; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require('fs/promises') | |
| const sharp = require('sharp') | |
| // this will create 2 images | |
| // one with 1200 width and one with 600 width | |
| // it will place them in the current directory | |
| // note that the original image(s) will be expected to be png |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fpsMeter() { | |
| let prevTime = Date.now(), | |
| frames = 0; | |
| requestAnimationFrame(function loop() { | |
| const time = Date.now(); | |
| frames++; | |
| if (time > prevTime + 1000) { | |
| let fps = Math.round( ( frames * 1000 ) / ( time - prevTime ) ); | |
| prevTime = time; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ((w,d) => { | |
| w && d && | |
| w.matchMedia('(prefers-color-scheme:dark)')?.matches && | |
| d.getElementsByTagName('html')[0]?.classList.add('dark') | |
| })(window,document) |