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 / 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">
@acro5piano
acro5piano / wl-paste-serve.mjs
Created January 29, 2022 08:14
Share wayland clipboard via Node.js standalone server (no deps)
#!/usr/bin/env node
import { createServer } from 'http'
import { exec } from 'child_process'
import { networkInterfaces } from 'os'
const log = (t) =>
console.log(`[${new Date().toLocaleTimeString()}] ` + JSON.stringify(t))
createServer((req, res) => {
@acro5piano
acro5piano / README.md
Created October 18, 2021 14:27
Restore brightness using Arch Linux + System76 Lemur 10 + light

I've created a systemd unit to restore brightness of my laptop (system76 Lemur Pro 10).

It has been worked for almost a year, but suddenly it stopped working. I've fixed by value (sleep 5).

I took the log and found this line, I would like to stop this, but don't know how to do it.

Oct 18 23:17:35 archlinux kernel: video LNXVIDEO:00: Restoring backlight state
@acro5piano
acro5piano / how-to-use.tsx
Last active June 26, 2021 07:34
Background blur-ed Twilio video track
export const MyComponent() {
const { toggleVideoBlur, isVideoBlur } = useBlurLocalTrack({})
const _toggleVideoBlur = async () => {
twilioRoom.localParticipant.videoTracks.forEach((track) => track.unpublish())
const videoTrack = await toggleVideoBlur()
await wait(1000)
participant.publishTrack(videoTrack)
}
import { useState } from 'react'
export const Draggable: React.FC<{}> = ({ children }) => {
const [position, setPosition] = useState({ x: 0, y: 0 })
return (
<div
className="cursor-move"
draggable
style={{ transform: `translate(${position.x}px, ${position.y}px)` }}
diff --git a/src/components/Room/Room.tsx b/src/components/Room/Room.tsx
index 443c1f120..7cb7c3f5e 100644
--- a/src/components/Room/Room.tsx
+++ b/src/components/Room/Room.tsx
@@ -1,7 +1,15 @@
-import React from 'react';
+import React, { useRef, useEffect } from 'react';
import ParticipantList from '../ParticipantList/ParticipantList';
import { styled } from '@material-ui/core/styles';
import MainParticipant from '../MainParticipant/MainParticipant';
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.2"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/body-pix@2.0"></script>
<style>
.relative {
position: relative;
}
.renderer {
width: 400px;