Skip to content

Instantly share code, notes, and snippets.

View anaisbetts's full-sized avatar

Ani Betts anaisbetts

View GitHub Profile
anaisbetts / Actions.kt
Created April 11, 2024 17:41
Actions in Compose
import android.util.Log
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.currentCoroutineContext
anaisbetts /
Last active March 11, 2024 21:32
Check dmesg with AI
set -eu
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
export OPENAI_API_KEY='sk-your-openai-key'
journalctl --since "24 hours ago" --no-pager -k | npx typechat-cli@latest -s "$SCRIPT_DIR/dmesg-scan.ts"
anaisbetts /
Last active September 22, 2023 17:25
Make a sane HTTP API for Vestaboard
import os
import vestaboard
import json
import threading
from dotenv import load_dotenv
from flask import Flask, request
anaisbetts / Buzzer.cs
Created January 1, 2022 17:28
Doorbell Automation
namespace HomeDotAnaisDotDev;
using System;
using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using HomeAssistantGenerated;
using NetDaemon.Common;
using NetDaemon.HassModel.Common;
export abstract class Result<T> {
abstract isOk(): boolean;
abstract isErr(): boolean;
abstract ok(): T | undefined;
abstract err(): Error | undefined;
static Ok<T>(val: T): Result<T> {
return new OkValue(val);
public async Task KillProcessNicely(uint pid, int delayInMs = 3*1000)
// Ugh, this is gross -
var tids = NativeMethods.GetAllTopLevelWindowsInZOrder()
.Select(hwnd => {
uint wndpid = 0;
var tid = NativeMethods.GetWindowThreadProcessId(hwnd, out wndpid);
if (wndpid != pid) {
return (uint)0;
> JustTheGame.dll!JustTheGame.LicensePromptViewModel..ctor.AnonymousMethod__18_5(Akavache.LoginInfo _) Line 67 C#
System.Reactive.dll!System.Reactive.Linq.ObservableImpl.Do<Akavache.LoginInfo>.Actions._.OnNext(Akavache.LoginInfo value) Line 158 C#
System.Reactive.dll!System.Reactive.Linq.ObservableImpl.Select<System.__Canon, System.__Canon>.Selector._.OnNext(System.__Canon value) Line 48 C#
System.Reactive.dll!System.Reactive.SafeObserver<JustTheGame.GameStoreHeuristicInfo>.WrappingSafeObserver.OnNext(JustTheGame.GameStoreHeuristicInfo value) Line 31 C#
System.Reactive.dll!System.Reactive.Linq.ObservableImpl.Select<ReactiveUI.ReactiveCommand<System.Reactive.Unit, System.__Canon>.ExecutionInfo, System.__Canon>.Selector._.OnNext(ReactiveUI.ReactiveCommand<System.Reactive.Unit, System.__Canon>.ExecutionInfo value) Line 48 C#
System.Reactive.dll!System.Reactive.Sink<ReactiveUI.ReactiveCommand<System.Reactive.Unit, JustTheGame.GameStoreHeuristicInfo>.ExecutionInfo>.ForwardOnNext(ReactiveUI.ReactiveComman
anaisbetts / index.ts
Created August 31, 2019 00:03
Create a PostgreSQL + Hasura database in Docker with Pulumi
import * as pulumi from '@pulumi/pulumi';
import * as docker from '@pulumi/docker';
import * as pg from '@pulumi/postgresql';
const cfg = new pulumi.Config();
const network = new docker.Network('net');
const pgImg = new docker.RemoteImage('postgresql-image', {
name: 'postgres:11',
keepLocally: true
anaisbetts / index.ts
Created August 30, 2019 05:27
PostgreSQL + Pulumi
import * as pulumi from "@pulumi/pulumi";
import * as docker from "@pulumi/docker";
import * as pg from '@pulumi/postgresql';
const cfg = new pulumi.Config();
const network = new docker.Network("net");
const pgImg = new docker.RemoteImage("postgresql-image", {
name: "postgres:11",
keepLocally: true