Skip to content

Instantly share code, notes, and snippets.

View hansamlin's full-sized avatar
🎯
Focusing

Sam Lin hansamlin

🎯
Focusing
View GitHub Profile
{
"$schema": "https://opencode.ai/config.json",
"agent": {
"plan": {
"permission": {
"read": "allow",
"edit": "deny",
"glob": "allow",
"grep": "allow",
"list": "allow",
@hansamlin
hansamlin / statusline.sh
Last active June 23, 2026 03:05
statusline.sh
#!/bin/bash
# Read JSON input from stdin
input=$(cat)
echo "$input" >> /tmp/statusline_debug.log
# Extract values using jq
MODEL=$(echo "$input" | jq -r '.model.display_name')
# Get git branch if in a git repo
GIT_BRANCH=""
{
"typescript.tsserver.experimental.enableProjectDiagnostics": true,
"editor.tabSize": 2,
"editor.rulers": [80],
"editor.detectIndentation": false,
"editor.insertSpaces": true,
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
/* http://meyerweb.com/eric/tools/css/reset/
v5.0.2 | 20191019
License: none (public domain)
*/
html,
body,
div,
span,
applet,
@hansamlin
hansamlin / dom_performance_reflow_repaint.md
Created July 23, 2024 08:38 — forked from faressoft/dom_performance_reflow_repaint.md
DOM Performance (Reflow & Repaint) (Summary)

DOM Performance

Rendering

  • How the browser renders the document
    • Receives the data (bytes) from the server.
    • Parses and converts into tokens (<, TagName, Attribute, AttributeValue, >).
    • Turns tokens into nodes.
    • Turns nodes into the DOM tree.
  • Builds CSSOM tree from the css rules.
@hansamlin
hansamlin / isJavaScriptProtocol.js
Created December 29, 2023 08:57
check is javascript protocol
export const isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i;
class LinkedListNode {
constructor(value) {
this.next = null;
this.value = value;
}
}
class LinkedList {
constructor() {
this.head = null;
function _get(obj, path, _default) {
if (typeof obj !== "object") {
throw new Error("param 1 must be an object")
}
if (typeof path !== "string" && !Array.isArray(path)) {
throw new Error("param 2 must be an object or a string")
}
let _path = path
function getArrayBuffer(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.addEventListener('load', () => {
resolve(reader.result);
});
reader.addEventListener('error', () => {
reject();
});
import { useEffect } from 'react'
import Script from 'next/script'
import { useRouter } from 'next/router'
import * as gtag from './gtag'
const App = ({ Component, pageProps }) => {
const router = useRouter()
useEffect(() => {
const handleRouteChange = (url) => {
gtag.pageview(url)