Skip to content

Instantly share code, notes, and snippets.

Avatar
Hang'n onto those moorings!

Elijah Mooring Vehmloewff

Hang'n onto those moorings!
View GitHub Profile
View encryptor.ts
export function makeEncryptor(key: string) {
const textToChars = (text: string) => text.split('').map(c => c.charCodeAt(0))
const byteHex = (n: number) => ('0' + Number(n).toString(16)).substr(-2)
const applyKeyToChar = (code: number) => textToChars(key).reduce((a, b) => a ^ b, code)
function decrypt(encoded: string) {
return (encoded.match(/.{1,2}/g) || [])
.map(hex => parseInt(hex, 16))
.map(applyKeyToChar)
.map(charCode => String.fromCharCode(charCode))
View useful-utils.md

Some helper functions that can come in handy day to day.

View mod.ts
import { createStreaming } from "https://dprint.dev/formatter/v2.ts";
const globalConfig = {
indentWidth: 2,
lineWidth: 80,
};
console.log("before createStreaming")
const tsFormatter = await createStreaming(
@Vehmloewff
Vehmloewff / .prettierrc
Last active Sep 1, 2020
My go-to prettier configuration
View .prettierrc
{
"arrowParens": "avoid",
"bracketSpacing": true,
"endOfLine": "lf",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"printWidth": 140,
"proseWrap": "preserve",
"requirePragma": false,
"semi": false,