Skip to content

Instantly share code, notes, and snippets.

@wm3
wm3 / ComposeLayout1.kt
Last active October 15, 2022 14:54
Jetpack Compose のレイアウトまとめ1: 基本的な仕組み
import android.graphics.Paint
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.*
import androidx.compose.material.ProvideTextStyle
import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
@wm3
wm3 / main.c
Last active January 11, 2021 18:41
FDCAJHxIBCFEH=FBAECIIJEGIH
// https://twitter.com/miharasan/status/1348654370921934849?s=20
#include <stdio.h>
long v[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
long val(char alpha) {
return v[alpha - 'A'];
}
@wm3
wm3 / 11.md
Last active April 1, 2020 09:02
11章 契約による設計:信頼性の高いソフトウェアを構築する 1

11章 契約による設計:信頼性の高いソフトウェアを構築する

テーマ*

  • 信頼性を確保するための手法として
  • 「表明」の概念を説明
  • キーコンセプトは「契約による設計」
  • 例外処理は12章

11.1 基本的な信頼性のメカニズム

struct A { var v: Int }
struct B {
var _a = A(v: 0)
var a: A {
get { print("get \(_a)"); return _a }
set(a) { print("set \(a)"); _a = a }
}
}
var b = B()
@wm3
wm3 / sample.swift
Created November 13, 2016 18:04
クラスメソッドを抽象メソッド化できると嬉しいと思う使い方
//
// Swift で例を挙げてみる。
//
// 例: JSON が与えられたら適宜クラスを選択してデコードする処理
//
// [
// { "type": "user", "id": "12345", "name": "wm3" },
// { "type": "post", "userId": "12345", "content": "今日こそ早く寝るぞ!😤" }
// ]
//
@wm3
wm3 / 24.md
Last active December 16, 2015 04:59
24-25章.md
  • 今までの説明 → テストの可読性、 有用な診断メッセージ
  • 今回 → 関係あるコードが壊れてる時だけ失敗させる

この章の趣旨を一言で表すと…

「何が起こるべきなのかを正確に指定せよ。余計なことを一切指定するな」

情報の表現ではなく中身をテストする

例: 顧客を検索するためのクラスのモック

@wm3
wm3 / 14-15章.md
Last active December 14, 2015 18:09
実践テスト駆動開発第2回

14章 スナイパーがオークションで落札する

  • 落札する機能を追加する
  • この際に、以前のリファクタリングが成果を上げる

まずは失敗するテストから

エンドツーエンドテストの改善

  • テスト項目
@wm3
wm3 / 1章.md
Last active December 14, 2015 03:09
実践テスト駆動開発第1回

1章 テスト駆動開発のポイントとは?

この章の概要

開発における本書の基本的な考え

  • 開発における「予期せぬ変化を予期する」 (anticipate unanticipated changes)
  • 開発に「入れ子になったフィードバックループ」を形成する
  • ソフトウェアの「 内側と外側の品質」
@wm3
wm3 / gist:4465225
Created January 6, 2013 04:34
The Art of Multiprocessor Programming 読書会 第五回 三〜四章まとめ

3 Concurrent Objects – 並行オブジェクト

https://gist.github.com/3304936

並行オブジェクトにおける correctness の解説(3.1 ~ 3.5)

  • Quiescent consistency, Sequential consistency, linearizable
  • (最適化のために、並行オブジェクトは実際に実行されたタイミングとのズレが生じる。それをどこまで許容するかの線引きを行う、という認識)

付属の特性 (3.6、3.7)

@wm3
wm3 / gist:4463523
Last active December 10, 2015 16:48
The Art of Multiprocessor Programming 読書会 第五回 九章

Linked Lists: The Role of Locking

9.1 Introduction

データ構造への各処理をロックでラップした並列化対応

  • coarse-grained synchronization (粗い同期)と呼んでいる
  • スケーラビリティがあまり良くない