Skip to content

Instantly share code, notes, and snippets.

View m5knt's full-sized avatar

Yukio KANEDA m5knt

  • Osaka,Japan
View GitHub Profile
@m5knt
m5knt / che.bat
Last active August 20, 2023 22:17
uac & powershell launcher
@(echo "`" >nul & goto :__BATCH__) & rem ") | Out-Null
<#
:: UAC Elevation & Powershell Launcher
:: MIT License (c) Yukio KANEDA
:__BATCH__
@if "%~1" neq "/?" call :__MAIN__ %0 %* <nul & exit /b
@shift /1 & call :__MAIN__ %0 /h <nul & exit /b
:__USAGE__
if not exist %_000%.ps1 (
@m5knt
m5knt / sh.bat
Last active March 28, 2023 01:51
Automatically finds and executes sh.exe
@echo off
call :MAIN %* <nul
exit /b
:MAIN
if not exist "%BAT_SH_BAT%" call :AUTO_DETECTOR
if not exist "%BAT_SH_BAT%" (
echo sh not found
echo please install "Git for Windows" or "MSYS2" or "Visual Studio 2017 later"
echo see https://gitforwindows.org/
@m5knt
m5knt / cmake.bat
Last active March 28, 2023 01:50
Automatically finds and executes cmake
@echo off
call :MAIN %* <nul
exit /b
:MAIN
if not exist "%BAT_CMAKE_BAT%" call :AUTO_DETECTOR
if not exist "%BAT_CMAKE_BAT%" (
echo cmake not found
echo please install "cmake"
echo see https://cmake.org/
@m5knt
m5knt / CppProperty2.cpp
Last active May 14, 2023 22:07
C++ Property, implement with EBO
#include <iostream>
#include <type_traits>
#include <string>
template<class T>
struct PropertyUtil {
// empty base
PropertyUtil(const PropertyUtil&) = delete;
PropertyUtil(PropertyUtil&&) = delete;
PropertyUtil& operator=(const PropertyUtil&) = delete;
@m5knt
m5knt / CppProperty.cpp
Last active May 14, 2023 17:06
C++ Property (getter/setter/accessor) implement with anonymous-union-struct
namespace property_impl {
/// property offset utillity
template <class Outer, bool IsStandardLayout = std::is_standard_layout<Outer>::value>
struct offset;
/// property offset utillity for standard-layout-class
template <class Outer>
struct offset<Outer, true> {
@m5knt
m5knt / ImportModule.vba
Last active December 27, 2022 08:00
Import vba module
' 動作させる為には
' ファイル => オプション => セキュリティーセンター => セキュリティーセンターの設定
' マクロの設定 => "VBAプロジェクトオブジェクトモデルへのアクセスを信頼する" をチェック
Sub Hoge()
ImportModule ("Fuga")
Application.Run "Fuga.Fuga", "aa"
End Sub
Sub ImportModule(modname)
@m5knt
m5knt / MoveOrCopy.cpp
Created March 21, 2017 08:10
C++のコンテナ挙動確認用クラス
struct Foo;
std::ostream& operator<<(std::ostream& out, const Foo& self);
struct Foo : std::string {
typedef std::string Base;
~Foo() {
std::cout << "dtor : " <<
std::addressof(*this) <<
" " << *this << std::endl;
}
@m5knt
m5knt / inc.sh.bat
Last active May 16, 2023 08:02
シェルスクリプトを内包するバッチファイル
: rem="
@echo off
type %~f0 | bash
exit /b %ERRORLEVEL%
";
echo "aaa"
@m5knt
m5knt / EditPlayerSettings.py
Created February 8, 2017 02:35
UnityのPlayerSettingsを編集する方法
#!/usr/bin/env python
import yaml, collections
def represent_odict(dumper, instance):
return dumper.represent_mapping('tag:unity3d.com,2011:129', instance.items())
def construct_odict(loader, node):
return collections.OrderedDict(loader.construct_pairs(node))
@m5knt
m5knt / SendIPMsg.txt
Created February 1, 2017 07:26
IPMsg を送る方法
posix
echo "1:`date +%s`:送信者:送信機器:32:メッセージ" | iconv -f utf-8 -t cp932 | nc -w 1 -u 127.0.0.1 2425
win
set T=%time::=0%
set T=%T:.=0%
echo 1:%T%:送信者:送信機器:32:メッセージ | ncat -w 1 -u 127.0.0.1 2425
ipmsg /msg 127.0.0.1 メッセージ