Skip to content

Instantly share code, notes, and snippets.

@smeghead
smeghead / VariableHardUsage.md
Last active April 4, 2025 14:24
Variable Hard Usage: A Metric for Local Variable Utilization in PHP

Variable Hard Usage: A Metric for Local Variable Utilization in PHP

Introduction

Code readability and maintainability are crucial aspects of software engineering. While numerous techniques exist to improve software structure—such as architectural design, modularization, and testability—this document focuses on a micro-level metric that directly impacts code comprehension: Variable Hard Usage (VHU).

Variable Hard Usage is a quantitative measure of how intensely a local variable is utilized within a function or method. By analyzing a variable’s scope (the number of lines it spans), access frequency (how often it is referenced), and update frequency (how often its value is modified), this metric aims to identify overused variables that may degrade code readability and maintainability. High VHU values indicate that a variable is being excessively manipulated, making the code harder to read, understand, and modify.

Importance of Measuring Variable Hard Usage

@smeghead
smeghead / php-variable-hard-usage-check-mode.md
Created March 25, 2025 11:51
CIでローカル変数酷使度をチェック可能にする

修正方針: CheckCommand の追加

ご提供いただいた情報に基づき、CheckCommand を新たに追加する方針を具体化します。

修正が必要な主な箇所

  1. CheckCommand クラスの作成
  • CommandInterface を実装する新しい CheckCommand クラスを作成
  • --threshold=<値> オプションを処理する機能を実装
@smeghead
smeghead / qubit.md
Created December 30, 2024 13:54
キュービット(量子ビット)と関数型言語の型理論の類似点

質問: キュービットの性質は、進んだ関数型言語の型理論に似ているように感じましたが、的外れでしょうか?

ChatGPTの回答: 非常に鋭い観察です!キュービットの性質を型理論と関連付けて考えるのは、興味深く、ある意味で的を射ています。特に、進んだ関数型言語の型理論における概念(例えば代数的データ型やモナド)とキュービットの性質を比較すると、いくつかの共通点が見えてきます。一方で、本質的な違いもあるので、以下で整理してみます。


1. キュービットの性質と型理論の類似点

(1) スーパーポジションと型の柔軟性

@smeghead
smeghead / lubuntu-setup.md
Last active January 4, 2025 12:36
Lubuntu の初期設定

Lubuntuのセットアップ

2024-11-09 Lubuntuのセットアップをするので、作業内容を記録します。

CapsLock

XKBOPTIONS="ctrl:nocaps" の行を追加する。

$ cat /etc/default/keyboard 
@smeghead
smeghead / phel-tdd.md
Last active September 12, 2024 11:02
phel-lang で小さいプログラムを作る方法 (TDD)

phel-lang で小さいプログラムを作る方法 (TDD)

phel-lang を使って小さいプログラムを作るのをTDD(テスト駆動開発)で進める場合に、どのように作成しているかを順番に書いてみます。

作るものを決める

一次元セル・オートマトンでフラクタル図形を描画することができるというのがおもしろいと思い、phel-langで実装してみることにしました。

1次元セル・オートマトン | Wikipedia

@smeghead
smeghead / ShowTest.php
Last active September 1, 2024 16:02
ShowTest DataFactory
<?php
namespace Tests\Feature\View\Function;
use App\Models\PhelFunction;
use App\Models\PhelNamespace;
use App\Models\UsageExample;
use App\Models\User;
use Tests\TestCase;
<?php
declare(strict_types=1);
namespace Nagoya;
interface Expression {
public function toString(): string;
}
class Number implements Expression {
@smeghead
smeghead / HyperLinkText.php
Created August 22, 2023 04:55
テキスト内のURLをタグ化しながら、全体をエスケープするクラス
<?php declare(strict_types=1);
namespace Domain;
/**
* URLを含むテキストをエスケープする。
* URLはリンクとして出力します。
* 改行は<br>を出力します。
*/
final class HyperLinkText {
private string $text;
@smeghead
smeghead / PERSONAL.XLSB
Last active December 6, 2022 02:42
行の高さを設定するマクロ
Sub 高さ()
'
' 高さ Macro
' 行の高さを、カレントセルの高さに設定する。
'
' Keyboard Shortcut: Ctrl+Shift+H
'
Dim rowNo
rowNo = ActiveCell.Row
Dim height
@smeghead
smeghead / custom.css
Created November 22, 2022 02:48
Github Shortcode プラグインのレイアウト崩れを調整する WordPress Customizing Additional CSS
article.post_body .github-box .github-box-download,
article.post_body .github-box .github-box-title .github-stats,
article.post_body .github-box .github-box-title .forks
{
height: auto;
}