Skip to content

Instantly share code, notes, and snippets.

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

ka kaosf

🏠
Working from home
View GitHub Profile
@kaosf
kaosf / sakura-cloud-shell-experiment.sh
Created May 26, 2023 04:54
Install Rust, Build AikatsuDOWN, and Run it; Experiment on Sakura Cloud Shell (ref. https://www.sakura.ad.jp/services/cloudshell/)
tmux
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source .cargo/env
sudo apt install tig
git clone https://github.com/kaosf/AikatsuDOWN
cd AikatsuDOWN
git checkout no-deps
@kaosf
kaosf / lines.tsx
Created May 13, 2023 15:37
React component for multiple lines string, with converting URL to "a" tag.
import * as React from "react";
const Lines: React.FC<{ body: string }> = (props) => (
<>
{props.body.split("\n").map((line) => {
const result = line.match(/(.*)(https?:\/\/[^\s]*)(.*)/);
if (result === null) {
return (
<>
{line}
<br />
@media (prefers-color-scheme: dark) {
body {
background-color: #303742;
color: #b7b7b7;
}
a {
color: #7775f9;
}
a:visited {
color: #a7a6fb;
@kaosf
kaosf / test.rb.diff
Last active March 25, 2023 06:35
Active Record Encryption, test environment, without config/master.key, on CI
require "active_support/core_ext/integer/time"
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
@kaosf
kaosf / docker-compose.yml
Created February 10, 2023 17:10
Nginx on https-portal for NIP-05
version: '3.7'
services:
https-portal:
image: steveltn/https-portal:1
restart: always
environment:
CUSTOM_NGINX_KAOSFIELD_NET_CONFIG_BLOCK: |
location = /.well-known/nostr.json { add_header Access-Control-Allow-Origin * always; root /nostr; }
volumes:
- /some/where:/nostr:ro
@kaosf
kaosf / Dockerile
Last active February 3, 2023 15:01
Docker on Jenkins on Docker
FROM jenkins/jenkins:lts-jdk11
USER root
RUN VERSION=20.10.22 && \
curl -fsSLO https://download.docker.com/linux/static/stable/x86_64/docker-${VERSION}.tgz && \
tar xf docker-${VERSION}.tgz && \
mv docker/docker /usr/local/bin && \
rm -r docker docker-${VERSION}.tgz
USER jenkins
# ref. https://stackoverflow.com/a/43594065/1006253
@kaosf
kaosf / 1 what-to-do-to-run-xmodmap-cmd-on-bt-kbd-reconnecting.sh
Last active November 24, 2022 17:14
How to run "xmodmap" command when a Bluetooth keyboard is reconnected.
# Check your Bluetooth keyboard MAC Address by
sudo bluetoothctl devices
# Prepare .xmodmap file.
# It crashes "xmodmap $HOME/.xmodmap" command when there is no Caps_Lock keysym.
# Prepare a script file of "reconnect.sh", and change the MAC address placeholder and some commands in it.
# Run this command.
sudo btmon | bash reconnect.sh
@kaosf
kaosf / interesting-prime-number.md
Last active November 3, 2022 09:12
Interesting prime number

ref. https://twitter.com/abakcus/status/1587885836158308353

Check:

openssl prime 99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999989999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999

Output:

@kaosf
kaosf / Dockerfile
Last active September 9, 2022 18:26
Active Record in Docker
FROM ruby
COPY ["Gemfile", "Gemfile.lock", "app.rb", "/"]
RUN bundle
CMD ["ruby", "/app.rb"]
@kaosf
kaosf / file-directory-permissions-resetter.sh
Last active July 31, 2022 13:34
File/Directory permissions resetter
# All file permissions are changed:
# 7xx -> 750
# 6xx -> 640
# All directory permissions are changed:
# 7xx -> 750
# `ls -l` output's 4th byte is owner's execute permission "x" or "-"
chmod -R o-rwx .