Skip to content

Instantly share code, notes, and snippets.

View Vehmloewff's full-sized avatar
🤦‍♂️
Efficiency begot effectiveness and the daughter devoured the mother

Elijah Mooring Vehmloewff

🤦‍♂️
Efficiency begot effectiveness and the daughter devoured the mother
View GitHub Profile
@Vehmloewff
Vehmloewff / appealing.tsx
Created November 30, 2022 03:30
An appealing idea for a syncjs-like framework
export function HomePage() {
const { setTemplate, update } = createPage()
const title = 'Example'
const heading = 'Simple Counter'
let clicked = 0
function increment() {
clicked++
update('#message')
events {
}
http {
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;
root /usr/share/nginx/html;
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>MyApplication</string>
<key>CFBundleExecutable</key>
<string>MyApplication</string>
<key>CFBundleIconFile</key>
<string>MyApplication.icns</string>
@Vehmloewff
Vehmloewff / errors-disappear.ts
Last active November 24, 2021 01:25
Errors thrown inside http.serve disappear
import { serve } from 'https://deno.land/std@0.113.0/http/mod.ts'
const listener = Deno.listen({ port: 3000 })
await serve(listener, () => {
console.log('before throw')
throw new Error('whoa! this does not print')
console.log('after throw')
return new Response('hello world')
@Vehmloewff
Vehmloewff / 1.ts
Last active July 17, 2021 00:18
Deno dynamic import bug
import './2.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))

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

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 September 1, 2020 19:54
My go-to prettier configuration
{
"arrowParens": "avoid",
"bracketSpacing": true,
"endOfLine": "lf",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"printWidth": 140,
"proseWrap": "preserve",
"requirePragma": false,
"semi": false,