Skip to content

Instantly share code, notes, and snippets.

View KEINOS's full-sized avatar

KEINOS KEINOS

View GitHub Profile
@KEINOS
KEINOS / md5.gs
Last active March 20, 2024 04:05
GAS(Google Apps Script) user function to get MD5 hash or 4digit shortened hash for Multibyte(UTF-8, 2bytes character) environment.
/**
* ------------------------------------------
* MD5 function for GAS(GoogleAppsScript)
*
* You can get a MD5 hash value and even a 4digit short Hash value of a string.
* ------------------------------------------
* Usage1:
* `=MD5("YourStringToHash")`
* or
* `=MD5( A1 )`
@KEINOS
KEINOS / README.md
Last active March 15, 2024 00:16
docker-compose.yml files for home lab
@KEINOS
KEINOS / README.md
Last active March 13, 2024 17:05
[NanoPi NEO2] Cronjob example to reboot Armbian machine by detecting the CPU temperature.

Auto Rebooting NanoPi NEO2 NAS Before Crash

This gist explains how to reboot the NanoPi NEO2 NAS before the CPU temperature rises too high and the device crashes.

Cron Job Setting Example

$ sudo crontab -l
# Check CPU temperature every 30 min (reboot if over 70°C)
*/30 * * * * /root/cron_jobs/onheat_reboot.sh > /root/cron_jobs/onheat_reboot.log 2>&1
@KEINOS
KEINOS / README.md
Last active March 2, 2024 18:05
[Golang]: Simple example of Diffie–Hellman key exchange

ディフィー・ヘルマン鍵共有の概念 with Go

package main

import "fmt"

// Public constant
const (
	g = 2 // 基数
@KEINOS
KEINOS / index.md
Last active February 8, 2024 18:11
List of key words to dig in.

Hot Keywords To Be Checked

キーワード 概要 Wiki 備考
[ABRoot][abroot] OS をイミュータブル OS 化するツール -- ルート・パーティションをカレントとアップデート用で 2 つ用意し [A/B テスト][abtest]方式でパーティションを切り替えるツール。カレントのルート・パーティションは書き込み禁止にし、各種変更は、もう片方のアップデート用に行うことで、アップデートの失敗でもフォールバックできるようにする。Go 言語で実装された単体バイナリで動作する。Vanilla OS などのイミュータブル OS で使われる。[OSTree][ostree] と似たコンセプトだが、OSTree は git などのように変更をコミットする方式であるのに対し、ABRoot はパーティションを切り替える。
[Albius][albius] Linux 系 OS インストール時のバックエンド -- [Vanilla OS][vanillaos] の、OS インストーラーのバックエンドとして Go 言語で書かれたアプリ。現在は汎用化されており、OS のインストールだけでなく、[SquashFS][squashfs] や [OCI][oci](コンテナイメージ)のインストールなどにも対応している。従来のシェルスクリプトによる実行でなく、JSON 形式でインストール・プロセスを記述できるのが特徴。主に CUI ベースのインストーラーとして使われるが、GNOME 用 GUI フロントエンドには、Python ベースの [Vanilla Installer][vanilla-installer] がある。
[Ansible][ansible] SSH 接続による操作の自動化ツール(ターミナル操作の自動化みたいなもの) [Wikipedia][ansible_wiki] VM、LXC、Docker 含む OS のセットアップ、定型処理など SSH 接続経由でできることであれば何でも自動化できる。利点は、接続先には何もインストールしなくてもいいこと。似たような環境構築系に [Terraform][terraform] がある。両者の違いは Ansibl
@KEINOS
KEINOS / README.md
Last active January 18, 2024 23:33
References for OKdo Nano C100 Developer Kit (a NVIDIA Jetson Nano Developer Kit B01 - The Jetson Nano Computing Module Compatible Board)
@KEINOS
KEINOS / how_to_mock_os.Stdin.md
Last active December 15, 2023 05:04
【Golang】How to mock `os.Stdin` during the test in Go. 標準入力をモックする方法

「"golang" test "os.Stdin" "keinos"」でググってもヒットしなかったので、自分のググラビリティとして。

[Golang] How to mock/mimic os.Stdin during the test in Go

In the dependency injection point of view, it is a good practice to var OsStdin = os.Stdin and use OsStdin instead of os.Stdin. Then monkey patch (temporary replace) the variable during the test.

But if the external package doesn't support that OsStdin alias feature, and uses os.Stdin, we need to mock the os.Stdin some how.

Here's my snippet of the helper function to mock the os.Stdin.

@KEINOS
KEINOS / README.md
Last active December 13, 2023 00:25
[golang] "io.reader" read by characters

How to read by characters using io.Reader in Go

The below golang code will print the input rune by rune.

package main

import (
	"bufio"
	"fmt"
@KEINOS
KEINOS / README.md
Last active November 16, 2023 04:36

Running Ollama on Intel Mac (MBP Early 2015)

This is a memorandom of running Ollama on Intel MacBook Pro.

$ neofetch --stdout
keinos@KEINOS-no-MacBookPro.local 
-----------------------------
OS: macOS 12.7.1 21G920 x86_64 
Host: MacBookPro12,1 
@KEINOS
KEINOS / Proxmox.md
Last active October 9, 2023 02:50
[Memo] Hardware spec information to install Linux on iMac Late2009 and old PC.