Skip to content

Instantly share code, notes, and snippets.

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

Shotaro Takahashi mamemomonga

🏠
Working from home
View GitHub Profile
@mamemomonga
mamemomonga / tinyavr0-WDT.md
Created July 4, 2021 12:14
tinyAVR0(xmega)でWatchdog Timerを使う

tinyAVR0(xmega)でWatchdog Timerを使う

ATtiny1606 + megaTinyCore

Watch Dog Timer(WDT)とはタイマーの一種で、カウンタがいっぱいになるとハードウェアリセットがかかる。プログラムから定期的にWDTをリセットすることで、プログラムのフリーズで強制再起動させることが可能である。

1秒間のWDT(PERIOD)を有効にする

_PROTECTED_WRITE(WDT.CTRLA,WDT_PERIOD_1KCLK_gc);

WDT_PERIOD_1KCLK_gc の他に以下のものが選べる

@mamemomonga
mamemomonga / ESXiClone.md
Last active July 1, 2021 02:56
ESXiで仮想マシンをクローンする例

ESXiで仮想マシンをクローンする例

  • vmware ESXi 7.0
  • データストアはdatastore1
  • debian10からdebian10-1 にコピーする
  • ディスクは1つ、EFIによるインストール
  • thinプロビジョニングに変更

ESXiのSSHコンソールにログインして作業を行う

@mamemomonga
mamemomonga / osirimeu.pl
Last active October 15, 2021 00:48
お尻めうスクリプト
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Getopt::Std;
use feature 'say';
binmode STDIN,":utf8";
binmode STDOUT,":utf8";
my %opt;
@mamemomonga
mamemomonga / alias.md
Last active February 15, 2021 02:08
便利なAlias

便利なAlias

  • macOS Catalina
  • ~/.bashrc, ~/.zshrc に設定する

lsの色と設定

export LSCOLORS=exfxcxdxbxegedabagacad
alias ls="ls -vG"
alias ll="ls -alG"
@mamemomonga
mamemomonga / cpu-percent.pl
Created January 15, 2021 12:07
LinuxのCPU(全コア)の使用率を表示する。
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';
use Time::HiRes 'usleep';
sub get_cpu_stat {
my $stat='';
open(my $fh,'<','/proc/stat') || die $!;
local $/; $stat=<$fh>;
@mamemomonga
mamemomonga / wasabidns.md
Last active December 29, 2020 13:11
名前解決できないWasabiを解決できる専用DNSサーバをDockerとdnsmasqでつくるメモ

名前解決できないWasabiを解決できる専用DNSサーバをDockerとdnsmasqでつくるメモ

ひとまず名前解決できたという感じ

設定とか

$ cat > resolv.dnsmasq.conf << 'EOS'
nameserver 8.8.8.8
nameserver 8.8.4.4
EOS
@mamemomonga
mamemomonga / _README.md
Last active December 4, 2020 02:22
ssh_configのホスト名を検索するツール

ssh_configのホスト名を検索するツール

最近のssh clientでは ~/.ssh/config に Include conf.d/* とすることで、~/.ssh/conf.d 以下にユーザのconfigファイルを分離することができるようになった。 しかし、自分で設定したホストを憶えきれないので、検索するためのシンプルなシェルスクリプトを作成した。

ssh-hosts-find を引数なしで実行すると、一覧が表示される。引数をつけると、それをキーにしてgrepする

@mamemomonga
mamemomonga / BigSurIso.md
Last active October 15, 2021 00:53
Big SurのISOイメージを作成する

Big SurのISOイメージを作成する

bigsur.isoはVMware Fusionで利用でき、またEtcherなどでUSBメモリに書き込むと、クリーンインストール用のメディアとして利用できる。ちなみに一般的なMacBookでの起動時ディスク選択はoptionキーを押しながら電源ON

$ hdiutil create -o ./bigsur -size 20g -layout SPUD -fs HFS+J -type SPARSE
$ hdiutil attach ./bigsur.sparseimage -noverify -mountpoint /Volumes/installBigSur
$ sudo '/Applications/Install macOS Big Sur.app/Contents/Resources/createinstallmedia' --volume /Volumes/installBigSur
$ hdiutil detach '/Volumes/Install macOS Big Sur'

アンマウントできんかったらmacOS再起動

@mamemomonga
mamemomonga / _README.md
Last active November 2, 2020 09:12
Raspberry Pi3向け Debian10 aarch64 ビルドツール
@mamemomonga
mamemomonga / terraform-env.md
Last active August 18, 2020 14:30
terraform の出力をbash変数として利用する方法

terraform の出力をbash変数として利用する方法

jq, perlを使用する

main.tf の作成

$ cat > main.tf << 'EOS'
output env {
  value = {

VALUE1 = "the value1"