Skip to content

Instantly share code, notes, and snippets.

@t-mat
t-mat / build-volume-control-cli.bat
Last active December 28, 2023 16:33
[Windows]Clone and build volume-control-cli
@echo off
:
: Clone and build volume-control-cli for Windows x64 Desktop, VC++2022
:
setlocal enabledelayedexpansion
set "OLDCD=%CD%"
set /a errorno=1
for /F "delims=#" %%E in ('"prompt #$E# & for %%E in (1) do rem"') do set "esc=%%E"
:
@t-mat
t-mat / build-libwebp.bat
Created December 26, 2023 12:19
Download and build libwebp 1.3.2 for Windows x64 Desktop, VC++2022
@echo off
setlocal enabledelayedexpansion
set "OLDCD=%CD%"
set "libwebp-tgz=libwebp-1.3.2.tar.gz"
set "libwebp-tgz-dir=libwebp-1.3.2"
set "libwebp-url=https://storage.googleapis.com/downloads.webmproject.org/releases/webp/%libwebp-tgz%"
set /a errorno=1
for /F "delims=#" %%E in ('"prompt #$E# & for %%E in (1) do rem"') do set "esc=%%E"
@t-mat
t-mat / cl-exe.cmd
Created December 21, 2023 04:38
[Windows]Invoke cl.exe from plain command prompt via batch file
@echo off
setlocal enabledelayedexpansion
: Set exit code (EXIT_FAILURE)
set /a errorno=1
:
: Find vswhere
: https://github.com/Microsoft/vswhere
:
@t-mat
t-mat / change_case_simd.c
Last active December 19, 2023 02:35 — forked from easyaspi314/change_case_simd.c
SIMD functions to apply toupper/tolower to each character in a string
// Created by easyaspi314. Released into the public domain.
// test:$ gcc -msse -DTEST change_case_simd.c && ./a.out
// > cl /EHsc /DTEST change_case_simd.c && .\change_case_simd.exe
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef DEMONSTRATE_BASIC_ALGORITHM
#include <stdint.h>
@t-mat
t-mat / rng_goldengamma.hpp
Created December 16, 2023 09:33
[C++]Generalized Golden Gamma for PRNG
// rng_goldengamma.hpp
//
// License
// -------
// SPDX-FileCopyrightText: Copyright (c) Takayuki Matsuoka
// SPDX-License-Identifier: CC0-1.0
//
#ifndef RNG_GOLDENGAMMA_HPP
#define RNG_GOLDENGAMMA_HPP 1
namespace Rng {
@t-mat
t-mat / DebugLog.cs
Last active December 7, 2023 05:31
[Untiy]Debug Log function
public static class DebugLog {
// Example: 1999-01-23T142536
private static readonly string s_dateTimeNowString = DateTime.Now.ToString(
"yyyy-MM-ddTHHmmss", System.Globalization.CultureInfo.InvariantCulture);
// Example: %USERPROFILE%\AppData\LocalLow\<MY_COMPANY>\<MY_APP>\debug_1999-01-23T142536.txt
private static readonly string s_logPath =
$"{Application.persistentDataPath}/debug_{s_dateTimeNowString}.txt";
// Append s to s_logPath
@t-mat
t-mat / unity_sample_sh_and_friends.md
Created July 14, 2023 19:38
[Unity][HLSL] SampleSH() (without LPPV) and related functions

tag:2022.2.0a9.1292, URP 14.0.2

// input
// normalWS : normal in World Space.  length(normal) must be 1
//
// output
// half3: RGB color.
@t-mat
t-mat / AdvancedRasterization.cpp
Created May 6, 2023 08:43
[C++] Advanced Rasterization by Nicolas "Nick" Capens from Devmaster Forum
// Advanced Rasterization by Nicolas "Nick" Capens - Devmaster Forum
// https://web.archive.org/web/20141221050705/http://forum.devmaster.net/t/advanced-rasterization/6145
//
// Result : https://godbolt.org/z/rzvzzf3cc
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdint>
@t-mat
t-mat / Visual C++ のプロジェクトに必ず追加したいオプション.md
Last active October 15, 2023 15:06
[VC++]Visual C++ のプロジェクトに必ず追加したいオプション

Visual C++ のプロジェクトに必ず追加したいオプション

コンパイラオプション

Visual Studio のメニュー > プロジェクト > プロパティ > Configuration Properties > C/C++ > Command Line 内の Additional Options に下記を加える

/utf-8
@t-mat
t-mat / ZeroSievertBorderlessWindow.cs
Created May 3, 2023 23:44
[Zero-Sievert] Borderless Window
using System;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Text;
public static class Program {
public static void Main() {
const string targetTitleName = "ZERO Sievert";
const string targetClassName = "YYGameMakerYY";