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 / 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():
@acro5piano
acro5piano / migrate.py
Created July 20, 2022 16:12
single file migration script without any libraries in Python
"""This is the demo to describe how to migrate SQLite3 database in just single file migration script.
Should be useful for minimal Python environments to run these scripts robust.
"""
import sqlite3
conn = sqlite3.connect("myapp.db")
# Migraiton class. It is okay to use tuple, but it is readable to declare such class.
@acro5piano
acro5piano / main.rs
Last active July 13, 2022 05:43
actix-web + async-graphql using routing macro and context
mod db;
mod entities;
mod graphql;
use crate::db::create_db_pool;
use crate::graphql::schema::{create_schema, AppSchema};
use actix_cors::Cors;
use actix_web::{get, middleware::Logger, post, web::Data, App, HttpServer, Responder};
use async_graphql_actix_web::{GraphQLRequest, GraphQLResponse};
use dotenv::dotenv;
@acro5piano
acro5piano / main.js
Created June 15, 2022 05:26
get random Hiragana
function main() {
const res =
'あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをんー'
.split('')
.sort(() => Math.random() - 0.5)
console.log(...res)
setTimeout(main, 50)
}
main()
@acro5piano
acro5piano / README.md
Created February 10, 2022 03:46
simple scraping in terminal

Now, you can scrape website with simple pipe.

$ curl -Ss 'https://moncargo.io' | scrape.rb meta

<meta name="viewport" content="width=device-width">
<meta charset="utf-8">
<meta name="twitter:title" content="MonCargo - Track your cargo online">