Skip to content

Instantly share code, notes, and snippets.

@mgsloan
mgsloan / after-patches.diff
Last active June 30, 2025 04:03
Zed schemars 1.0 schema changes
diff --git a/crates/settings/src/keymap_file.rs b/crates/settings/src/keymap_file.rs
index febe46c3be..faa418562c 100644
--- a/crates/settings/src/keymap_file.rs
+++ b/crates/settings/src/keymap_file.rs
@@ -423,7 +423,9 @@ impl KeymapFile {
pub fn generate_json_schema_for_registered_actions(cx: &mut App) -> Value {
let mut generator = schemars::generate::SchemaSettings::draft07().into_generator();
- let action_schemas = cx.action_schemas(&mut generator);
+ let mut action_schemas = cx.action_schemas(&mut generator);
#!/bin/bash
# In retrospect I'd have preferred a python script, but hey this works.
#
# https://claude.ai/chat/baf4d2fd-ddbe-4852-9361-91c0a091f40c
#
# https://claude.site/artifacts/9b588d36-cf7e-4bf9-aed1-187adc0b8ef7
#
# > How can I automatically delete my local git branches if the
# > associated github PR has been merged (the remote branch is on the
#!/usr/bin/env python3
# https://claude.site/artifacts/39d84a1a-23fa-498d-a31b-7ada990a85db
# https://claude.ai/chat/097db2b0-18a9-4845-9586-f2f4bb10ac8b
#
# > Please write a python script that git fetches only main without
# > switching to it. Then rebase the current branch atop main. All
# > the commits after the merge-base w.r.t main should get rebased.
#
# > Oh, on further thought explicitly querying the merge-base is
@mgsloan
mgsloan / dogfood.sh
Created January 17, 2025 05:47
Dogfood branch
#!/bin/bash
# Claude 3.5 sonnet
# Please write a bash script that checks that the repository is clean
# (modulo untracked files), then checks out a branch called dogfood
# and reset hards it to origin/main. Then read a file called dogfood
# which has a list of branch names separated by whitespace. Then
# merge in each branch, one at a time. Exit on failure, with nonzero
# exit status
@mgsloan
mgsloan / git-auto-branch.py
Last active January 17, 2025 07:43
Open editor with llm proposed branch name + branch name from first line. Creates branch based on origin/main and cherry-picks commit onto it. Generated by Claude 3.5 sonnet
#!/usr/bin/env python3
import subprocess
import sys
import tempfile
import os
import re
def run_git_command(command, error_message="Git command failed"):
"""
@mgsloan
mgsloan / gist.rs
Last active December 27, 2024 23:40
Find tree sitter node enclosing range, could be used in zed-industries/refactor
// Look up a TreeSitter node based on a range from SCIP.
pub fn find_node<'a>(
start_node: tree_sitter::Node<'a>,
range: &Range<tree_sitter::Point>,
) -> Result<tree_sitter::Node<'a>> {
let mut cursor = start_node.walk();
// Descend to the first leaf that touches the start of the range, and if the range is
// non-empty, extends beyond the start.
while cursor.goto_first_child_for_point(range.start).is_some() {
04785022ed95f0901f865f17542134a3fe9c70cf034cb3eda5e170417372e2abd9e972c6462cfe9b68fa340db25ccaf6d50cc024da358d883e0e15e8cea5a2ec
@mgsloan
mgsloan / simpleMapResult.hs
Last active July 28, 2021 03:00
Simplified function composition with variadic 2nd function (simplified but only works well for monomorphic arguments)
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
-- https://gist.github.com/mgsloan/7100f55c6ec12be8776a1a1c347cf963
-- for a more complex version with better type inference.
--
-- It was initially surprising to me that this one doesn't need the
-- "closed type family" trick to direct which instance is used. On
-- further thought,
@mgsloan
mgsloan / wrap.hs
Last active July 26, 2021 22:29
Function composition where 2nd function is variadic
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
import Data.Proxy (Proxy(..))
@mgsloan
mgsloan / roam-navigator-theme.css
Created June 29, 2020 19:48
CSS for overriding Roam Navigator visual hint styles (https://github.com/mgsloan/roam-navigator). Can be used in extensions like Roam Toolkit (Custom CSS feature) or Stylish
.roam_navigator_hint {
color: purple !important;
font-size: 20px !important;
}
.roam_navigator_hint_typed {
color: orange !important;
}
.roam-sidebar-container .roam_navigator_hint, #right-sidebar .roam_navigator_hint {