Skip to content

Instantly share code, notes, and snippets.

@Tc-001
Tc-001 / escape-the-box.md
Last active May 8, 2025 02:52
How to "escape" nixos FHS sandbox for vscode

So, I needed to use the 1password CLI from vscode-fhs, but it didn't work because the sandbox user wasn't the same as the native one.

tc001 ~/foo> op whoami                                                                     
[ERROR] connecting to desktop app: read: connection reset, make sure 1Password CLI is installed correctly, then open the 1Password app, select 1Password > Settings > Developer and make sure the 'Integrate with 1Password CLI' setting is turned on. If you're still having trouble connecting, restart the app.

Thankfully this was pretty easy to solve once I figured it out, but it wasn't really doccumented anywhere.

@Tc-001
Tc-001 / app.tsx
Created December 22, 2022 18:31
Add doctype in honojs's JSX layout
function DoctypeComponent() {
let s = new String("<!DOCTYPE html>") as any
s.isEscaped = true
return s
}
export const Layout = (props: { children?: string }) => (
<Fragment>
<DoctypeComponent />
<html lang="en">
@Tc-001
Tc-001 / index.ts
Created August 9, 2022 09:50
Quick and dirty html+css+js collapse/minify
const min = (html:string) => html
.replace(/(\n|\s)*(<[^>]*>)(\n|\s)*/g, "$2") //Collapse whitespace around tags
.replace(/(?<=<style[^>]*>[^<]+)(\{|;|:|\r)(\s)+(?=[^<]+<\/style>)/g, "$1") //Collapse css
.replace(/(?<=<script[^>]*>[^<]+)\s*([\{\}\,\;])\s*(?=[^<]+<\/script>)/g, "$1") //Collapse scripts
.replace(/[^\S\r\n]+/g," ") //Remove spaces
.replace(/\n+/g,"\n") //Remove newlines
/*
Will not remove all that can be removed
Focus was more on making sure nothing can break if you use mostly valid syntax