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.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)?
@acro5piano
acro5piano / readme.md
Last active April 4, 2024 02:24
Arch linux full system upgrade without bluez

Newer bluez is buggy. It makes CPU usage 100% randomly.

5.72 is working fine. Let's keep using it.

sudo pacman -U /var/cache/pacman/pkg/bluez*5.72-2-x86_64.pkg.tar.zst

I need to ignore upgrading bluez until a stable version is released. To do so,

@acro5piano
acro5piano / cloudfront-function.js
Created August 26, 2023 05:28
cloudfront function for static sites
function handler(event) {
var request = event.request
var uri = request.uri
// Check whether the URI is missing a file name.
if (uri.endsWith('/')) {
return {
statusCode: 301,
statusDescription: 'Moved Permanently',
headers: {
@acro5piano
acro5piano / gist:1b1551b547bd7f00a528557f23d22af4
Created August 14, 2023 14:27
マネーフォワードクラウド会計の仕訳画面で、高さ制限なくして快適に入力できるようになる CSS
.caClientJournalBookSpreadsheetAppRoot {
max-height: unset !important;
}
@acro5piano
acro5piano / Makefile
Created August 3, 2023 06:32
Makefile cd to child directories and execute commands
build/plugins: ./packages/plugins/*
fnm use v16
for dir in $^ ; do \
bash -c "cd $${dir} && yarn && yarn build" ; \
done
@acro5piano
acro5piano / keychron_linux.md
Created April 24, 2023 22:48 — forked from andrebrait/keychron_linux.md
Keychron keyboards on Linux + Bluetooth fixes

Here is the best setup (I think so :D) for K-series Keychron keyboards on Linux.

Most of these commands have been tested on Ubuntu 20.04 and should also work on most Debian-based distributions. If a command happens not to work for you, take a look in the comment section.

Make Fn + F-keys work

Keychron Keyboards on Linux use the hid_apple driver (even in Windows/Android mode), both in Bluetooth and Wired modes. By default, this driver uses the F-keys as multimedia shortcuts and you have to press Fn + the key to get the usual F1 through F12 keys.

@acro5piano
acro5piano / README.md
Last active December 21, 2022 17:53
Download & Optimize Hugo images hosted on other websites (e.g. GitHub, imgur, or AWS S3)
  • Confirmed works on Cloudflare pages.
    • Depends on Ruby and wget and imagemagick
  • This script uses JPG with quality 85 and interlace -plane (progressive JPEG)
  • Further improvement like WebP may be required
@acro5piano
acro5piano / errorExchange.ts
Created November 26, 2022 16:37
URQL automatic error handling toaster
import { Exchange } from 'urql';
import { pipe, tap } from 'wonka';
import { toast } from 'react-hot-toast';
export const errorExchange: Exchange =
({ forward }) =>
(ops$) =>
pipe(
forward(ops$),
tap(({ error }) => {
@acro5piano
acro5piano / idea.ts
Created November 15, 2022 06:11
new graphql framework idea
const { type, t, getExecutableSchema } = '../framework'
interface('Node', {
id: t('ID!'),
})
type('User', implements('Node'), {
height: t('Int!'),
posts: t('[Post!]!').allowWhere().allowOrder(),
})
@acro5piano
acro5piano / auto-xsel.py
Created October 10, 2022 08:53
[linux] Run command on usb device plugged
#!/usr/bin/env python3
# You need to run pip install pyudev before run this script
import subprocess
import pyudev
def main():