Skip to content

Instantly share code, notes, and snippets.

View acro5piano's full-sized avatar
🏠
Working from home

Kay Gosho acro5piano

🏠
Working from home
View GitHub Profile
@acro5piano
acro5piano / main.py
Created March 3, 2026 07:34
Linux voice input with OpenAI API
import os
import subprocess
import sys
from pathlib import Path
import numpy as np
import sounddevice as sd
import typer
from openai import OpenAI
from scipy.io.wavfile import write
@acro5piano
acro5piano / Cargo.toml
Created February 11, 2026 07:49
cdp test using chromiumoxide - by attaching existing headed chrome instance (not launching a new one)
[package]
name = "cdp_test"
version = "0.1.0"
edition = "2024"
[dependencies]
anyhow = "1.0.101"
chromiumoxide = { version = "0.8", features = ["tokio-runtime"], default-features = false }
env_logger = "0.11.8"
futures = "0.3"
@acro5piano
acro5piano / i18n-extract.ts
Created May 25, 2025 04:26
simple i18n based on yaml
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs'
import { dirname, join } from 'path'
import { glob } from 'glob'
import yaml from 'js-yaml'
interface TranslationEntry {
key: string
files: string[]
}
@acro5piano
acro5piano / prql.ts
Created November 15, 2024 10:04
Bringing PRQL into TypeScript
prql
.query()
.from('invoices')
.derive({
transaction_fee: 0.8,
income: 'total - transaction_fee',
})
.filter('income', '>', 5)
.filter('invoice_date', '>=', '@2010-01-16')
.group('customer_id', {
import { DateTime } from 'luxon'
const a = DateTime.now().setZone('Asia/Tokyo')
const b = DateTime.fromISO('2024-11-07').setZone('Asia/Tokyo').endOf('day')
const c = DateTime.now()
console.log({ a, b, c })
console.log(a < b)
console.log(b < c)
@acro5piano
acro5piano / generateAllMutations.mjs
Created September 7, 2024 17:42
Generate all GraphQL mutations from GraphQL schema IDL
import fs from 'fs'
const header = `
#
# This file is auto generated. Do not edit by hand.
#
`.trimStart()
const schema = fs.readFileSync('path/to/schema.graphql', 'utf8')
const allMutations = generateAllMutations(schema).join('\n')
@acro5piano
acro5piano / rust-to_string-vs-clone.md
Last active July 10, 2024 10:36
Rust to_string vs clone performance comparison
// main.rs

use std::time::Instant;

fn main() {
    let instant = Instant::now();
    let text = "".to_string();
    for _ in 1..100000000 {
        let _ = text.to_string();
@acro5piano
acro5piano / main.sh
Last active December 23, 2025 06:41
Run android emulator on Arch Linux
# Pre installtion notice:
# - The iso image can be downloaed from: https://www.android-x86.org/download.html
# - Linux Zen is recommended. See: https://riq0h.jp/2020/12/07/210053/
# - Also see: https://wiki.archlinux.org/title/QEMU
sudo pacman -S qemu-full
sudo pacman -S qemu-desktop
qemu-img create -f raw android 16G
@acro5piano
acro5piano / readme.md
Created June 28, 2024 09:32
gqtx-like library idea
type ScalarField = 'ID' | 'String'

type ResolvableField<Out extends ObjectType<any>> = {
  type: Out
  resolve: () => Out extends ObjectType<infer Src> ? Src : never
}

export class ObjectType<Src> {
  constructor(public name: string) {}
@acro5piano
acro5piano / main.rs
Created April 11, 2024 10:03
rust server sent event (EventSource) client with infinite reconnect loop
use anyhow::Result;
use eventsource_client::{Client, ReconnectOptions, SSE};
use futures::TryStreamExt;
use std::time::Duration;
const URL: &str = "http://localhost:8000/sse";
#[tokio::main]
async fn main() -> Result<()> {
let client = eventsource_client::ClientBuilder::for_url(URL)?