C++(MFC) 簡易ザラ場判定関数

#include <chrono>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <string>
#include <Windows.h>

// 日本時間で営業時間内(9:00-15:30、土日を除く)かどうかを判定する関数
BOOL IsJapanMarketHours()
{
    // 現在のUTC時間を取得
    auto now = std::chrono::system_clock::now();
    auto now_time_t = std::chrono::system_clock::to_time_t(now);
    
    // UTCの時間を構造体に変換
    std::tm utc_tm;
    gmtime_s(&utc_tm, &now_time_t);
    
    // 日本時間に変換(UTC+9時間)
    std::tm jst_tm = utc_tm;
    jst_tm.tm_hour += 9;
    
    // 日付の繰り上げ処理
    std::mktime(&jst_tm);
    
    // 曜日を取得(0=日曜日, 1=月曜日, ..., 6=土曜日)
    int dayOfWeek = jst_tm.tm_wday;
    
    // 土曜日(6)または日曜日(0)の場合はFALSEを返す
    if (dayOfWeek == 0 || dayOfWeek == 6)
    {
        return FALSE;
    }
    
    // 時間と分を取得
    int hour = jst_tm.tm_hour;
    int minute = jst_tm.tm_min;
    
    // 現在の時刻を分単位に変換(9:00は540分、15:30は930分)
    int currentMinutes = hour * 60 + minute;
    
    // 9:00から15:30の間かどうかをチェック
    if (currentMinutes >= 540 && currentMinutes <= 930)
    {
        return TRUE;
    }
    
    return FALSE;
}

// 日本時間を文字列で取得する補助関数
std::wstring GetJapanTimeString()
{
    // 現在のUTC時間を取得
    auto now = std::chrono::system_clock::now();
    auto now_time_t = std::chrono::system_clock::to_time_t(now);
    
    // UTCの時間を構造体に変換
    std::tm utc_tm;
    gmtime_s(&utc_tm, &now_time_t);
    
    // 日本時間に変換(UTC+9時間)
    std::tm jst_tm = utc_tm;
    jst_tm.tm_hour += 9;
    
    // 日付の繰り上げ処理
    std::mktime(&jst_tm);
    
    // 日本時間を文字列に変換
    std::wstringstream wss;
    wss << std::put_time(&jst_tm, L"%Y-%m-%d %H:%M:%S JST");
    
    return wss.str();
}

// 使用例
void Example()
{
    std::wstring japanTime = GetJapanTimeString();
    std::wstring message;
    
    if (IsJapanMarketHours())
    {
        message = L"現在は取引時間内です\n日本時間: " + japanTime;
    }
    else
    {
        message = L"現在は取引時間外です\n日本時間: " + japanTime;
    }
    
    MessageBox(NULL, message.c_str(), L"日本市場状態", MB_OK | MB_ICONINFORMATION);
}

phpにアクセスしたら HTTP ERROR 500  になった。原因がわかるようにphp側に仕込むコード

<?php
// エラー表示を有効化
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

// エラーログの場所を指定(アクセス権があるディレクトリを指定)
ini_set('error_log', './error.log');

// デバッグ情報をログに記録
error_log('Debug: order.php accessed at ' . date('Y-m-d H:i:s'));

// 実行時間の延長(必要な場合)
set_time_limit(60);

// メモリ制限の拡大(必要な場合)
ini_set('memory_limit', '256M');

try {
    // ここに既存のコードを配置
    
    // サーバー情報、POSTデータなどのデバッグ
    error_log('SERVER: ' . print_r($_SERVER, true));
    error_log('POST: ' . print_r($_POST, true));
    error_log('GET: ' . print_r($_GET, true));
    
    // ここから既存のコードを続ける...
} catch (Exception $e) {
    // 例外をログに記録
    error_log('Exception: ' . $e->getMessage());
    error_log('Trace: ' . $e->getTraceAsString());
    
    // エラーメッセージを表示(開発環境のみ)
    echo '<h1>エラーが発生しました</h1>';
    echo '<p>詳細: ' . $e->getMessage() . '</p>';
    echo '<p>エラーの詳細はログに記録されました。</p>';
    exit;
}
?>

Claude Desktopからjavascriptで更新されるようなサイトからも情報取れるMCP追加 ( Puppeteer MCPの導入方法)

Node.jsとnpmのインストール

Puppeteer MCP Serverを動作させるには、Node.jsとnpmが必要です。以下のコマンドでインストール済みか確認してください:

node -v
npm -v

npxを使用して直接実行:

npx -y @modelcontextprotocol/server-puppeteer

設定ファイルを開く

Claude Desktopの設定ファイルは以下の場所にあります:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Claude\claude_desktop_config.json

追記する

windowsの場合

  "mcpServers": {
    "puppeteer": {
      "command": "node",
      "args": [
        "C:\\Users\\<user名>\\AppData\\Roaming\\npm\\node_modules\\@modelcontextprotocol\\server-puppeteer\\dist\\index.js"
      ]
    },...

Macの場合

"mcpServers": {
  "puppeteer": {
    "command": "npx",
    "args": ["-y", "@modelcontextprotocol/server-puppeteer"]
  }
}

Claude Desktop再起動

タスクトレイからちゃんと落とすこと

windows環境でClaude Codeを使う方法

インストール方法はこちらみて

qiita.com

powersehllからの起動方法

wslからUbuntu起動

wsl -d Ubuntu

claude code起動

claude

バッチファイルでそのフォルダを起点に起動させる方法

batファイル(パスは環境にあわせること)

wsl -d Ubuntu bash -c "/home/<user>/.nvm/versions/node/v22.14.0/bin/node /home/<user>/.nvm/versions/node/v22.14.0/lib/node_modules/@anthropic-ai/claude-code/cli.js"

これをプロジェクトのルートなど、実行したい場所において、そこから起動させればOK

C# 通常ビルドと単一ファイル配置するときでは アプリケーションのベースディレクトリを取得する方法が違う

private async void Form1_Load(object sender, EventArgs e)
{
    // アプリケーションのベースディレクトリを取得する改良された方法
    string directoryPath;
    
    // Assembly.Location が空の場合は AppContext.BaseDirectory を使用
    string assemblyPath = Assembly.GetExecutingAssembly().Location;
    if (string.IsNullOrEmpty(assemblyPath))
    {
        // 単一ファイル配置の場合はこちらが実行される
        directoryPath = AppContext.BaseDirectory;
    }
    else
    {
        // 通常配置の場合はこちらが実行される
        directoryPath = Path.GetDirectoryName(assemblyPath);
    }
 
....
} 
 

PHP4系でもいけるSlack送信関数

// Slack送信関数
function sendSlackMessage($webhook_url, $message) {
    try {
        $data = array(
            'payload' => json_encode(array(
                'text' => $message
            ))
        );
        
        $ch = curl_init($webhook_url);
        
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        
        $result = curl_exec($ch);
        
        if ($result === false) {
            throw new Exception("Slack通知の送信に失敗しました: " . curl_error($ch));
        }
        
        curl_close($ch);
        return true;
    } catch (Exception $e) {
        error_log("Slack通知エラー: " . $e->getMessage());
        return false;
    }
}