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 / drun.sh
Created December 18, 2024 20:53
Run a typescript function directly
#!/bin/bash
filepath=$1
funcname=$2
[[ $filepath != *.ts ]] && filepath="$filepath.ts"
dataurl='data:text/typescript,import { '$funcname' } from "file://'$(pwd)'/'$filepath'";console.log(await '$funcname'());'
deno run -A "$dataurl"
brew install SergioBenitez/osxct/x86_64-unknown-linux-gnu
DEB_NAME=libssl-dev_1.1.1n-0+deb10u3_amd64.deb
OPENSSL_DIR="$HOME/.cache/temp/libssl_dev"
mkdir -p $OPENSSL_DIR/include
cd $OPENSSL_DIR
curl -O http://ftp.us.debian.org/debian/pool/main/o/openssl/$DEB_NAME
ar p $DEB_NAME data.tar.xz | tar xvf -
mv usr/include/openssl/* usr/include/x86_64-linux-gnu/openssl/
@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/[email protected]/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(