Skip to content

Instantly share code, notes, and snippets.

View kusa-mochi's full-sized avatar
🏠
Working from home

Kusa Mochi kusa-mochi

🏠
Working from home
View GitHub Profile
@kusa-mochi
kusa-mochi / main.go
Created October 4, 2023 12:32
calc conway-chain.
package main
import (
"fmt"
"math/big"
)
// コンウェイのチェーン表記で a -> b -> c を計算する。
func chain(a big.Int, b big.Int, c big.Int) big.Int {
if b.Cmp(big.NewInt(1)) == 0 { // b == 1
@startuml
actor 息子 as son
actor パパ as papa
actor ママ as mama
actor おじいちゃん as grandpa
activate son
son -> papa ++ : アイス食べたい!
papa --> son -- : 今日は甘い物たくさん食べたからまた明日ね
@kusa-mochi
kusa-mochi / server_to_server_connect.puml
Last active October 28, 2023 23:16
server-to-server transition test using connect potocol.
@startuml
actor You as you
box ServerA
participant "main-A Go routine" as main_a
participant "server A Go routine" as server_a
participant "RPC handler A Go routine" as handler_a
end box
box ServerB
participant "main-B Go routine" as main_b
#include "stdio.h"
#include "pthread.h"
void *TestRoutine(void *p) {
int testVar = 123;
printf("TestRoutine - testVar:%d\n", testVar);
int *ip = (int *)p;
ip = &testVar;
}
@kusa-mochi
kusa-mochi / main.go
Last active June 25, 2023 08:07
Go言語では、スコープを抜けた変数であっても参照があれば、自動的にヒープ領域に移動され値を参照し続けられるようにしてくれる。
package main
import "fmt"
func TestRoutine(ch chan *int) {
var testVar int = 123
defer func() { ch <- &testVar }()
fmt.Printf("TestRoutine - testVar:%v\n", testVar)
}
@kusa-mochi
kusa-mochi / clone-with-saving-download-space.ps1
Created February 10, 2022 09:32
GitHubにあるリポジトリから、特定のフォルダ以下のファイルを、ダウンロード容量を節約しつつ取得するPowerShellスクリプトのサンプル。
# GitHubにあるリポジトリから、特定のフォルダ以下のファイルを、ダウンロード容量を節約しつつ取得するPowerShellスクリプトのサンプル。
$userName = "kusa-mochi"
$repoName = "image-tracer"
$targetFolderPath = "ImageTracer/ViewModels/"
$repoUrl = "https://github.com/${userName}/${repoName}.git"
set-location ../
remove-item $repoName -Recurse -Force
@startuml 米炊き
actor 太郎
box キッチン
participant 米びつ
participant 水道
participant 炊飯器
end box
太郎 -> 米びつ : お米を計量する
@startuml 米炊き
actor 太郎
box キッチン
participant 米びつ
participant 水道
participant 炊飯器
end box
太郎 -> 米びつ : お米を計量する
@kusa-mochi
kusa-mochi / example.c
Created April 29, 2021 04:14
ソースコードの簡単な説明
#include <stdio.h>
// エントリポイント
int main() {
printf("てすてす");
return 0;
}
#include <Servo.h>
#define loopInterval 33 // loop関数のループ間隔[msec]
#define echoPin 2 // 超音波センサーからの入力ピン
#define trigPin 4 // 超音波センサーへのトリガ出力ピン
#define servoPin1 3 // 1つ目のサーボモーターを制御するピン
#define servoPin2 5 // 2つ目のサーボモーターを制御するピン
#define sonicSpeed 340 // 音速[m/sec]
#define sensorFilterLength 30 // 超音波センサー入力の平滑化フィルタの長さ
#define switchOnDistance 1.0 // サーボモータの角度をONに切り替える基準とする距離[cm]
#define switchOffDistance 6.0 // サーボモータの角度をOFFに切り替える基準とする距離[cm]