Skip to content

Instantly share code, notes, and snippets.

View keiya's full-sized avatar

keiya keiya

View GitHub Profile
let fibSeq = [0, 1];
function setup() {
createCanvas(400, 400);
for (let i = 2; i < 1000; i++) {
fibSeq[i] = fibSeq[i-1] + fibSeq[i-2]; // Generating Fibonacci sequence
}
}
function draw() {
@keiya
keiya / 1__fly.rails.toml
Last active September 26, 2023 02:04
Mastodon for fly.io with SendGrid + Cloudflare R2
app = "don-example-com-rails"
kill_signal = "SIGTERM"
kill_timeout = 60
primary_region = "nrt"
[build]
image = "tootsuite/mastodon:v4.2.0-rc1"
[build.args]
RAILS_ENV = "production"
@keiya
keiya / gem_extensions_checker.rb
Created August 14, 2023 01:40
This Ruby script lists all gems in the current project that contain native extensions. This is useful for diagnosing extension-related issues and assessing project compatibility across different environments.
# typed: false
require 'bundler'
gems = Bundler.load.specs.map(&:name)
extensions = gems.map do |gem|
spec = Gem::Specification.find_by_name(gem)
{ name: gem, extensions: spec.extensions }
end
@keiya
keiya / violentmonkey.js
Created April 8, 2023 08:53
Violentmonkey script that scan magnet links and sends an RPC request to Transmission on click
// ==UserScript==
// @name Magnet link to Transmission
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Automatically send magnet link to Transmission for download
// @match *://*/*
// @grant GM_xmlhttpRequest
// ==/UserScript==
const transmissionUrl = "http://xxxx:9091/transmission/rpc";
@keiya
keiya / mastodon-docker-postgres-auto-backup.sh
Last active January 4, 2023 12:30
PostgreSQL in docker online remote backup script (with encryption) useful for Mastodon
#!/bin/bash
cd /home/ec2-user/mastodon
TMPFILE=$(mktemp)
PASSWORD=xxxxxxx
DAY=$(date +"%a")
docker-compose exec db pg_dump -Z1 -Fc -U postgres postgres | openssl enc -aes-128-ctr -md sha256 -e -pass pass:$PASSWORD > $TMPFILE
@keiya
keiya / README.md
Last active May 3, 2024 09:59
foobar2000 Accessing UPnP DLNA Example (also Python upnpclient example)

Generate M3U Playlist from foobar2000 UPnP/DLNA Server

I have many songs stored in foobar2000 on Windows, and I wanted to listen to them from other Macs or tablets. foobar2000 mac and foobar2000 mobile seemed suitable for this purpose, but it took a long time to list the songs. So I used this script to create a playlist in advance to save me the trouble.

How to use

  • step 0: create playlist in your foobar2000
  • step 1: install UPnP/DLNA Renderer, Server, Control Point in your foobar2000
    • and make some configuration
  • step 2: install pip packages
@keiya
keiya / autoshutdown.py
Created October 5, 2020 10:39
auto shutdown script when inactive
import os
import pprint
from time import sleep
INACTIVE_TIME = 30
pp = pprint.PrettyPrinter(indent=4)
inactive_count = 0
@keiya
keiya / ssh-bench.py
Last active February 26, 2024 21:33
A SSH benchmarking script which can test KexAlgorithms, Cipher, MACs. https://blog.twogate.com/entry/2020/07/30/benchmarking-ssh-connection-what-is-the-fastest-cipher
#!/usr/bin/env python3
# SSH-Bench
# v 0.1 by TwoGate inc. https://twogate.com
# MIT license
# A benchmarking script for ssh.
# Tests in various ssh ciphers, MACs, key exchange algorithms.
# You can change settings in "configuration section" in this file.
# Note that result csv file will be overwrote if already exists.
@keiya
keiya / README.md
Created May 6, 2019 18:50
automatic gravity turn & circularize for Kerbal Space Program (KSP)
@keiya
keiya / add_header.sh
Created April 25, 2019 16:05
add a header for multiple files
#!/bin/bash
content=""
for var in "$@"
do
if [[ -f "$var" ]]; then
echo "$content" | cat - ${var} > /tmp/add_header_out && mv /tmp/add_header_out ${var}
fi
done