Skip to content

Instantly share code, notes, and snippets.

View tidusia's full-sized avatar

Thibaud Duthoit tidusia

View GitHub Profile

I had some head-scratching moments setting up Claude to work with the GitHub CLI and 1Password on my MacBook. I had the gh wrapped in a 1Password plugin in /Users/bep/.config/op/plugins.sh:

 alias gh="op plugin run -- gh"

This made gh work great when doing manual terminal work with fingerprint authentication and all. But UI popups doesn't work in Claude, Claude needs a GH_TOKEN.

So, following some sketchy guides online, I created a new vault in 1Password named Claude, and added my GitHub token to that vault:

@adactio
adactio / saveTextarea.js
Last active December 2, 2023 06:52
Put the contents of a textarea into localStorage if the user leaves the page before submitting the form.
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
// http://creativecommons.org/publicdomain/zero/1.0/
(function (win, doc) {
// Cut the mustard.
if (!win.localStorage) return;
// You should probably use a more specific selector than this.
var textarea = doc.querySelector('textarea');
// The key for the key/value pair in localStorage is the current URL.
var key = win.location.href;
@bvaughn
bvaughn / react-lifecycle-cheatsheet.md
Last active July 12, 2026 14:01
React lifecycle cheatsheet

React lifecycle cheatsheet

Method Side effects1 State updates2 Example uses
Mounting
componentWillMount Constructor equivalent for createClass
render Create and return element(s)
componentDidMount DOM manipulations, network requests, etc.
Updating
componentWillReceiveProps Update state based on changed props
@kevinweber
kevinweber / encodeSvg.js
Created October 31, 2016 05:36
Helper: Convert React component (SVG element) to base64 encoded URL. Useful for adding a background image.
import ReactDOMServer from 'react-dom/server';
export function encodeSvg(reactElement) {
return 'data:image/svg+xml,' + escape(ReactDOMServer.renderToStaticMarkup((reactElement)));
}
import React from "react";
import { render } from "react-dom";
const ParentComponent = React.createClass({
getDefaultProps: function() {
console.log("ParentComponent - getDefaultProps");
},
getInitialState: function() {
console.log("ParentComponent - getInitialState");
return { text: "" };