Skip to content

Instantly share code, notes, and snippets.

@t-mat
t-mat / AlpineWSL.run.bat
Created May 4, 2024 17:16
[Windows] Download and run Alpine Linux on WSL
@echo off
setlocal EnableDelayedExpansion
set /a errorno=1
for /F "delims=#" %%E in ('"prompt #$E# & for %%E in (1) do rem"') do set "_ESC=%%E"
cd /d "%~dp0"
set /a _E =0
set /a _E+=1 && if not exist "Alpine.zip" ( curl -JOL https://github.com/yuk7/AlpineWSL/releases/download/3.18.4-0/Alpine.zip )
set /a _E+=1 && if not exist "Alpine.zip" goto :ERROR
set /a _E+=1 && if not exist "Alpine.exe" ( tar -xkf .\Alpine.zip )
@t-mat
t-mat / winget-error-0x8a15005e.md
Created April 28, 2024 13:46
[Windows] `winget` keep reporting mysterious error 0x8a15005e

Problem: winget CLI command keep reporting a mysterious error code 0x8a15005e

Solution: Update winget.exe via aka.ms/getwinget

pwsh.exe
cd $env:USERPROFILE\Desktop
curl.exe -JOL https://aka.ms/getwinget
Add-AppxPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.txt.msixbundle
@t-mat
t-mat / SelectAFileInFileExplorer.cs
Created April 8, 2024 08:53
[Unity][Windows] Select a file in the file explorer
using System;
using System.IO;
using System.Runtime.InteropServices;
using UnityEditor;
using UnityEngine;
internal static class Test {
[MenuItem("Help/Test/SHOpenFolderAndSelectItems")]
private static void MenuItem_MyMenu_SHOpenFolderAndSelectItems() {
string path = "C:/Windows/system.ini";
@t-mat
t-mat / ReportAllTextureImporterSettingsAsCSV.cs
Last active April 6, 2024 07:17
[Unity] Report all TextureImporter settings as CSV
//
// This Unity Editor script reports all TextureImporter settings as CSV file.
//
// Usage:
// - Invoke "UnityEditor > Help > TextureImporterReporter > Report all TextureImporter settings as CSV"
// - Script creates report CSV file and reports its file name.
//
// License
// -------
// SPDX-FileCopyrightText: Copyright (c) Takayuki Matsuoka
@t-mat
t-mat / 00cpuid.md
Last active March 28, 2024 12:39
CPUIDを使ってCPUの情報を取得する
  • Pentium 以降の世代の CPU なら問題なく実行できる
  • VC++ (2005 以降?) なら <intrin.h>#include して、__cpuid() および __cpuidex() を使用する
  • gcc なら <cpuid.h>#include して、__get_cpuid(), __cpuid_count() を使用する
  • RDRAND を使ってみたかったのだけど、うちのは対応していなかった!
@t-mat
t-mat / EditorTest.cs
Created August 2, 2016 16:48
[UnityEditorExtension] [Windows] AllocConsole for batch-mode
#if UNITY_EDITOR
// unity.exe -projectPath <PATH/TO/YOUR/PROJECT> -batchmode -executeMethod EditorTest.TestFunc -quit
using UnityEditor;
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
public class EditorTest
{
@t-mat
t-mat / dx11-screen-capture.cpp
Created August 28, 2020 09:36
[WIN32] DX11 DXGI Screen capture sample
// WIN32/C++17: DX11 DXGI Screen capture sample
//
// References:
// - https://github.com/microsoftarchive/msdn-code-gallery-microsoft/tree/master/Official%20Windows%20Platform%20Sample/DXGI%20desktop%20duplication%20sample
// - https://github.com/microsoft/DirectXTex/blob/master/ScreenGrab/ScreenGrab11.cpp
// - https://docs.microsoft.com/en-us/windows/win32/direct3ddxgi/desktop-dup-api
//
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <atlbase.h>
@t-mat
t-mat / jpeg-xl-msvc-2019-x64-build.bat
Last active March 9, 2024 03:08
Build JPEG XL with VC++2019
@rem Build JpegXL for Windows x64 Desktop, VC++2019
@setlocal enabledelayedexpansion
@echo off
pushd .
set /a errorno=1
set "TAG=v0.10.2"
git --version || echo "git" not found && goto :ERROR
@t-mat
t-mat / mrr2.hlsl
Last active March 7, 2024 15:10
Martin Roberts' R2 sequence for dithering in HLSL
// Martin Roberts' R2 sequence in HLSL
// http://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/
namespace MRR2 {
float triangularWave(float x) {
return abs(0.5f - x) * -2.0f + 1.0f;
}
static const float a1 = (0.6180339887498948);
static const float2 a2 = float2(0.7548776662466927, 0.5698402909980532);
static const float3 a3 = float3(0.8191725133961644, 0.671043606703789, 0.5497004779019701);
@t-mat
t-mat / SimpleIniFile.hpp
Created March 6, 2024 21:34
Simple in-memory .ini file parser in C++20
// Simple in-memory .ini file parser in C++20
//
// - Header only library
// - No exception, heap allocation and callback
// - Depends only <stddef.h>
// - Opt-in compatibility with <string_view> (SIMPLE_INI_FILE_HPP_VIEW_TYPE)
//
// Usage
// -----
//