Skip to content

Instantly share code, notes, and snippets.

View gursuj's full-sized avatar
💭
99 ideas but haven't worked on one

Sujal Gurung gursuj

💭
99 ideas but haven't worked on one
View GitHub Profile
@gursuj
gursuj / remember-ssh-windows.md
Last active June 20, 2026 14:17
SSH Passphrase Caching on Windows

The goal

Be prompted for your SSH key passphrase on first use, have it remembered for ~10 minutes, then forgotten. Caching for the whole session (the Windows default) was the thing you wanted to avoid for security.

Why it was hard

The built-in Windows OpenSSH ssh-agent simply cannot expire keys. We proved this empirically:

  • ssh-add -t 600 → "agent refused operation"
  • AddKeysToAgent 600 in ssh config → silently refused, key never stored
@gursuj
gursuj / woocomm-product-attribute-icons.md
Created June 14, 2026 23:52
Adding icons to WooCommerce global product attributes

adding icons to woocommerce global attributes (without acf)

wanted to let an admin attach an icon (dashicon or uploaded img) to each global product attribute (e.g. pa_length, pa_paper-type), then show them as icon cards on the single product page.

what didn't work

wasted a lot of time trying to do this w/ acf/scf field groups on the attribute term edit screen. everything failed for the same root cause:

@gursuj
gursuj / details-accordion-animation.md
Created May 27, 2026 05:46
Animating `<details>` Accordions

Animating <details> Accordions

Why CSS-only fails for close

The browser removes the open attribute synchronously when the user clicks a summary. Any CSS rule tied to details[open] stops matching instantly — before a transition can play. So close never animates with CSS alone.

CSS grid-rows (grid-template-rows: 0fr / 1fr) works for opening but transitionend on fr units is also unreliable across browsers, so it's not a safe base for JS-driven animation either.

Use explicit pixel heights animated via JS.

@gursuj
gursuj / adb-logcat-lnav.md
Last active February 11, 2026 07:08
View adb logcat output in a nicer way (using lnav)

Requires adb and lnav

Currentlly has an issue where newer logs aren't shown after a while. Check this chat for fixes

adb logcat -v color --pid=$(adb shell pidof com.your.packagename) | lnav

Requires a slightly more complex one-liner to use wildcards.

@gursuj
gursuj / .ignore-patterns.txt
Created August 31, 2025 10:38
Syncthing ignore patterns for Obsidian
// obsidian ignore patterns for syncthing.
// these will be synced across all devices automatically.
// just make sure to set each device's ignore pattern to #include .ignore-patterns.txt
// source: https://www.youtube.com/watch?v=Lhk1IVCzYiM
// ignore workspace file, which stores editor pane layout, open files
// can cause issues when syncing
.obsidian/workspace.json
// .obsidian/icons // optional
@gursuj
gursuj / Edge blur gradient.css
Created August 20, 2025 07:44
This should be used on elements w/ black backgrounds like in distinctstudios.com.np
selector {
--blur-width: 50px;
position: relative;
/* blur edges */
&:before,
&:after {
content: "";
position: absolute;
z-index: 10;
@gursuj
gursuj / GSAP ScrollTrigger img lazy load bug.md
Last active August 17, 2025 15:25
Fix for when ScrollTrigger is broken due to layout shift caused by lazy loading

On Firefox, lazy loaded images may break GSAP ScrollTrigger positions. LLMs will propbably advise you to call ScrollTrigger.refresh() after every lazyloaded image finishes loading.

A better way is to call refresh when a scrollTrigger (either a ScrollTrigger close to the image, or set a trigger on the image itself) is triggered using the onEnter lifecycle method. This is done to re-calculate start, end positions for all triggers after the image has loaded and caused a layout shift.

const node = document.querySelector('...');
node.isRefreshCalled = false;

gsap.to(node, {
 scrollTrigger: {
@gursuj
gursuj / nextjs-serve-static-html.md
Last active August 17, 2025 14:38
Serving html pages inside NextJS

Needed to serve an html file at siteurl/zohoverify/verifyforzoho.html in order to verify domain for zoho mail.
Problem is: NextJS uses routes without extensions

You can just put html files inside /public and Next will serve them according to the file structure.
Seems that when Next is matching a route, it first checks /public and then dynamic routes (/app dir).
If you want to keep html files in /public/html, take a look at the next rewrite docs