Skip to content

Instantly share code, notes, and snippets.

View CostaFot's full-sized avatar
🍦

Costa Fotiadis CostaFot

🍦
View GitHub Profile
const params = new URLSearchParams(window.location.search);
if (params.get("q")) {
const trySend = setInterval(() => {
const button = document.querySelector('button[aria-label="Send message"]');
if (button && !button.disabled) {
button.click();
clearInterval(trySend);
}
}, 200);
setTimeout(() => clearInterval(trySend), 5000);
chrome.contextMenus.onClicked.addListener((info) => {
if (info.menuItemId !== "askClaude") return;
const text = `I selected "${info.selectionText}" on my browser\n\nI would normally Google this. Tell me what I need to know.`;
chrome.tabs.create({ url: `https://claude.ai/new?q=${encodeURIComponent(text)}` });
});
{
"manifest_version": 3,
"name": "Ask Claude",
"version": "1.0",
"description": "Right-click selected text to ask Claude",
"permissions": ["contextMenus"],
"background": {
"service_worker": "background.js"
},
"content_scripts": [
@app.route("/claps", methods=["GET"])
def get_claps():
data, _ = get_claps_file()
key = normalise_url(request.args.get("url"))
return jsonify({"claps": data.get(key, 0)})
@app.route("/claps", methods=["POST"])
def add_clap():
data, sha = get_claps_file()
key = normalise_url(request.args.get("url"))
@CostaFot
CostaFot / RetainDecorator.kt
Created March 4, 2026 12:09
RetainDecorator.kt
class RetainDecorator<T : Any>(
retainedValuesStoreRegistry: RetainedValuesStoreRegistry,
) : NavEntryDecorator<T>(
decorate = { entry ->
logDebug { "Retaining ${entry.contentKey}" }
retainedValuesStoreRegistry.LocalRetainedValuesStoreProvider(entry.contentKey) {
entry.Content()
}
},
@Composable
fun GameScreen(
gameViewModel: GameViewModel = viewModel()
) {
// ...
}
@Composable
fun FirstScreen() {
val customRetainedViewModel = retain {
CustomRetainedViewModel()
}
val state by customRetainedViewModel.state.collectAsStateWithLifecycle()
// ....
}
@Composable
fun FirstScreen() {
val customRetainedViewModel = rememberRetainedViewModel<CustomRetainedViewModel>()
val state by customRetainedViewModel.state.collectAsStateWithLifecycle()
// .... rest of the owl
}
@Composable
inline fun <reified T : RetainedViewModel> rememberRetainedViewModel(noinline factory: (Context) -> T): T {
val context = LocalContext.current
return retain { factory(context) }
}
// ..compose layer
val customRetainedViewModel = rememberRetainedViewModel { context ->
EntryPoints.get(context, CustomRetainedViewModelEntryPoint::class.java).customRetainedViewModel()
}
@EntryPoint
@InstallIn(ActivityComponent::class)
interface CustomRetainedViewModelEntryPoint : RetainedViewModelEntryPoint<CustomRetainedViewModel>
@RetainedEntryPoint(CustomRetainedViewModelEntryPoint::class)
class CustomRetainedViewModel @Inject constructor(
// ...
) : RetainedViewModel() {
// ...
}