Skip to content

Instantly share code, notes, and snippets.

@42LM
42LM / .envrc.example
Last active September 2, 2025 12:53
Get OAuth token and refresh bearer token for gemini cli http streamable mcp server
export CLIENT_ID=""
export CLIENT_SECRET=""
export OAUTH_TOKEN_ENDPOINT=""
export MCP_SERVER_ENDPOINT=""
@42LM
42LM / collaborate.md
Created August 28, 2025 00:53
Work on someone else's branch

#How to work on someone else's branch

Let's assume you need to collaborate with Batman on his forked repository.

  • Add fork as a remote
git remote add batman git@github.com:batman/iambatman.git
  • Fetch remote
@42LM
42LM / Cargo.toml
Last active August 24, 2025 19:31
Shuttle backend example with template `No framework` [Rust]
[package]
name = "test"
version = "0.1.0"
edition = "2021"
publish = false
[dependencies]
shuttle-runtime = "0.53.0"
tokio = "1"
@42LM
42LM / sign_commits.md
Created August 24, 2025 19:19
Signing git commits with SSH key

To enable signing commits using an ssh key:

  • git config --global user.signingkey "your ssh public key"
  • git config --global gpg.format ssh
  • (OPTIONAL: Use 1PW for sharing the ssh key) git config --global gpg.sshprogram /Applications/1Password.app/Contents/MacOS/op-ssh-sign
  • git config --global commit.gpgsign true

To have git log show signature checks:

  • git config --global log.showSignature true
  • git config --global gpg.ssh.allowedSignersFile $HOME/.gitallowed_signers
  • create $HOME/.gitallowed_signers and put in a line such as this (with a name and the public key): name ssh-ed25519 WEPOFJEWOI123/asdQW
@42LM
42LM / spinner.go
Last active August 24, 2025 19:08
Simple spinner example in [Go]
package main
import (
"fmt"
"strings"
"sync"
"time"
)
// var frames = []string{"⠁", "⠁", "⠉", "⠙", "⠚", "⠒", "⠂", "⠂", "⠒", "⠲", "⠴", "⠤", "⠄", "⠄", "⠤", "⠠", "⠠", "⠤", "⠦", "⠖", "⠒", "⠐", "⠐", "⠒", "⠓", "⠋ ", "⠉", "⠈", "⠈"}
@42LM
42LM / mailv2.go
Last active August 24, 2025 19:08
Test email templates via google gmail with new dialer [Go]
package main
import (
"bytes"
"fmt"
"html/template"
"os"
"gopkg.in/mail.v2"
)
@42LM
42LM / sign_git_commits.md
Created June 7, 2025 07:21
Sign git commits with ssh key
  • 1Password makes it easy to manage ssh keys, providing an ssh agent of course. I like this integration, although it's not needed (ssh-add)
  • git allows to sign commits using gpg, but also using ssh keys (which makes it even easier IMO)
  • To enable signing via ssh, add these config entries:
  • git config --global user signingkey "‹your ssh public key›"
  • git config --global gpg. format ssh
  • git config --global gpg.ssh.program /Applications/1Password.app/Contents/MacOS/op-ssh-sign
  • git config --global commit.gpgsign true
  • To have git log show signature checks:
  • git config --global log. showSignature true
  • git config --global gpg.ssh.allowedSignersFile $HOME/.gitallowed_signers
@42LM
42LM / README.md
Last active May 10, 2025 15:09
Use google gemini in rust 🦀

Create example project:

cargo new googlegemini && cd googlegemini

Copy the code of the main.rs file and add dependencies in cargo.toml file:

[dependencies]
reqwest = { version = "0.12", features = ["json"] }
tokio = { version = "1", features = ["full"] }
@42LM
42LM / ch21_02_multithreaded_server.rs
Last active August 24, 2025 19:09
Multithreaded Server with error handling, derived from the rust book: https://doc.rust-lang.org/book/ch21-02-multithreaded.html [Rust]
// Multithreaded Server with error handling
// https://doc.rust-lang.org/book/ch21-02-multithreaded.html
use std::{
fmt,
io::{BufReader, prelude::*},
net::{TcpListener, TcpStream},
sync::{Arc, Mutex, mpsc},
thread,
};
@42LM
42LM / zig-type-pointer-cheatsheet.zig
Last active August 24, 2025 19:10
Zig ⚡️ - Examples for Type/pointer cheatsheet (https://zig.news/toxi/typepointer-cheatsheet-3ne2) [Zig]
// https://zig.news/toxi/typepointer-cheatsheet-3ne2
//
// Examples on how to create/init every type that is part of the type/pointers cheatsheet.
const std = @import("std");
const print = std.debug.print;
/// Cheatsheet stores a list of all types and pointers.
const Cheatsheet = struct {
/// single u8 value
a: u8,