Skip to content

Instantly share code, notes, and snippets.

View mamemomonga's full-sized avatar

Shotaro Takahashi mamemomonga

View GitHub Profile
@mamemomonga
mamemomonga / EC2Debian.md
Created June 3, 2020 08:22
Debian AmazonEC2Image
@mamemomonga
mamemomonga / nginx-wasabi.md
Last active July 13, 2024 09:44
Wasabiをnginxでプロクシする

Wasabiをnginxでプロクシする

  • Wasabiの出力をnginxでプロクシして media.example.com から出力する
  • Wasabiのリージョンは us-east-2

mastodonの .env.production 設定例

S3_ENABLED=true
S3_BUCKET=Wasabiのバケット名
@mamemomonga
mamemomonga / F401RE-USART-HelloWorld.md
Last active May 26, 2020 15:29
STM32 Nucleo F401RE の USARTでHello World

STM32 Nucleo F401RE の UARTでHello World

  • STM32 Nucleo F401RE macOSでビルドとアップロードしてLチカ
  • STM32 NucleoのUSART2はST-LinkのUARTと繋がっている。
  • Linuxマシン(Raspberry Piなど)に接続すると、/dev/ttyACM0として認識される
  • STM32CubeMXのF401REボードのデフォルト設定、Makefile用で初期コードを生成して開始する。
  • 要screen、終了はCTRL+A, k → y

コード

@mamemomonga
mamemomonga / stm32.md
Last active May 26, 2020 02:06
STM32 Nucleo F401RE macOSでビルドとアップロードしてLチカ
@mamemomonga
mamemomonga / log-monitor.pl
Created May 14, 2020 15:09
コンテナの/app/log/production.logに特定文字列がでてきたらSlackCatをつかって通知する
#!/usr/bin/env perl
# -----------------
# コンテナの/app/log/production.logに特定文字列がでてきたらSlackCatをつかって通知する
# 実行 nohup ./log-monitor.pl &
# -----------------
use feature 'say';
use strict;
use warnings;
$|=1;
@mamemomonga
mamemomonga / example.sh
Last active May 5, 2020 11:38
汎用シェルスクリプト
#!/bin/bash
set -eu
# 実行ファイルのあるディレクトリ
BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# 実行ファイルの一階層下のディレクトリ
# BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
# 実行可能コマンド
@mamemomonga
mamemomonga / login.sh
Created April 26, 2020 00:43
awscliスニペット集
#!/bin/bash
set -eu
# ECRにログイン
# Version2にはレポジトリパスが必要
ecr_login() {
local awscli_version="$( aws --version | perl -nlE 'say $1 if (m#aws-cli/(\d)\.#)' )"
case "$awscli_version" in
"1" )
aws ecr get-login --no-include-email --region ap-northeast-1 | sh
@mamemomonga
mamemomonga / Dockerfile
Created April 23, 2020 19:55
Dockerfileにnode.js組み込み(debian)
RUN set -xe && \
curl -Lo /tmp/node.tar.xz https://nodejs.org/dist/v12.16.2/node-v12.16.2-linux-x64.tar.xz && \
curl -Lo /tmp/yarn.tar.gz https://yarnpkg.com/latest.tar.gz && \
tar Jx --strip-components 1 -f /tmp/node.tar.xz -C /usr/local && \
tar zx --strip-components 1 -f /tmp/yarn.tar.gz -C /usr/local && \
rm /tmp/node.tar.xz && \
rm /tmp/yarn.tar.gz
@mamemomonga
mamemomonga / FoldingatHome.md
Last active April 2, 2020 01:05
Ubuntu/DebianにFolding@homeをインストールする方法

Ubuntu/DebianにFolding@homeをインストールする方法

あまりCPU負荷のかかってないVPSなどにいれて、ウィルスの解析に役立てましょう。

$ wget https://download.foldingathome.org/releases/public/release/fahclient/debian-stable-64bit/v7.5/fahclient_7.5.1_amd64.deb
$ sudo dpkg -i fahclient_7.5.1_amd64.deb

WebUIへの接続

SSHのポートフォワードを使うと便利です。

@mamemomonga
mamemomonga / dev.sh
Created March 31, 2020 22:28
EC2で接続されているネットワーク情報をインスタンス内で取得
#!/bin/bash
set -eu
get_meta_data() {
curl --retry 3 --silent --fail http://169.254.169.254/latest/meta-data/$1
}
PUB_MAC=$( get_meta_data mac )
for i in $( ls /sys/class/net ); do
if [ "$i" == "lo" ]; then continue; fi