Skip to content

Instantly share code, notes, and snippets.

View usagi's full-sized avatar
🍣
Sushi

Usagi Ito usagi

🍣
Sushi
View GitHub Profile
@usagi
usagi / file0.txt
Created January 21, 2016 00:50
cmake : externalproject で zlib と libpng を扱う例 ref: http://qiita.com/usagi/items/c5715c50bb56b65d0cd5
cmake_minimum_required( VERSION 3.2 )
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
link_directories(${CMAKE_CURRENT_BINARY_DIR}/lib)
include( ExternalProject )
set( zlib_source_path ${CMAKE_CURRENT_BINARY_DIR}/external/zlib/src/external_zlib/ )
set( zlib_cmake_file_path ${zlib_source_path}/CMakeLists.txt )
@usagi
usagi / file0.cpp
Last active January 19, 2016 05:21
Lua & C++ : Lua に関数が定義されているか確認してから pcall を実行する方法 ref: http://qiita.com/usagi/items/b67371413ef8ebe6bb32
namespace usagi
{
namespace lua
{
/// @brief lua_state に name が関数として定義されているか確認する
/// @param name 確認したい関数のシンボル名
auto is_function( c::lua_State* lua_state, const std::string& name )
{
lua_getglobal( lua_state, name.c_str() );
const auto r = static_cast< bool >( lua_isfunction( lua_state, -1 ) );
@usagi
usagi / file0.sh
Created January 17, 2016 03:18
Git-2.7.0.windows.1 と CMake-3.4.1 で FindGit できない時の応急措置 ref: http://qiita.com/usagi/items/c0d039196810b3158f99
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.4/Modules/ExternalProject.cmake:1743 (message):
error: git version 1.6.5 or later required for 'git submodule update
--recursive': GIT_VERSION_STRING=''
@usagi
usagi / file0.txt
Created January 11, 2016 12:36
C++ & Lua : 任意の引数群と return 群の Lua の関数を C++ から簡単に扱えるヘルパーライブラリーの作り方 ref: http://qiita.com/usagi/items/82b3d4777b6894b7e978
function hoge( a, b )
return a + b, a - b, a / b, a .. b
end
@usagi
usagi / file0.cpp
Created January 11, 2016 09:14
C++14 : 任意のタプルへ任意のファンクターを適用する apply( my_tuple, my_functor ) の作り方 ref: http://qiita.com/usagi/items/4eda4ee6a6ddc9dae41d
auto tuple = std::make_tuple( 1, 2.3f, '4', "567" );
auto functor = []( auto value ){ std::cout << value << "\n"; };
apply( tuple, functor ); // <-- これを作りたい
@usagi
usagi / file0.cpp
Created January 10, 2016 15:59
C++ & Lua : C++ から Lua へ提供するモジュールと C++ データ型と Lua ユーザーデータを簡潔に定義するヘルパーライブラリーの実装例 ref: http://qiita.com/usagi/items/414736673417a92f3206
#include <lua.hpp>
#include <iostream>
#include <vector>
#include <new>
#include <mutex>
#include <stdexcept>
namespace usagi
{
namespace lua
@usagi
usagi / file0.cpp
Last active January 10, 2016 09:54
C++ & Lua : C++ のネイティブデータ型を Lua へ提供し、操作する例 ref: http://qiita.com/usagi/items/1e9f759b1822e4eeab93
struct f32vec4
{
float x, y, z, w;
f32vec4( const float a = 0, const float b = 0, const float c = 0, const float d = 0 )
: x( a ), y( b ), z( c ), w( d )
{ }
};
using native_data_type = std::vector< f32vec4 >;
@usagi
usagi / file0.txt
Last active January 8, 2016 15:35
組み込みスクリプト言語として Lua をソースから CMake で扱う方法 ref: http://qiita.com/usagi/items/116367830d3dfa945023
file( GLOB_RECURSE lua_sources ${lua_path}/src/*.c )
list( REMOVE_ITEM lua_sources
${lua_path}/src/lua.c
${lua_path}/src/luac.c
)
@usagi
usagi / file0.txt
Last active January 8, 2016 05:31
powershell 実行中に PATH 環境変数へカレントディレクトリーを追加する簡単な方法 ref: http://qiita.com/usagi/items/e753ba1f5701c874e097
$env:path = "$(cmd /c cd);" + $env:path
@usagi
usagi / file0.txt
Last active December 8, 2015 13:38
Visual Studio Code: Task 機能のクロスプラットフォーム対応 ref: http://qiita.com/usagi/items/8b23738777f904795b02
{ "command": "sh"
, "args": ["-c"]
, "windows":
{ "command": "cmd"
, "args": ["/c"]
}
, "tasks":
[ { "taskName": "hoge"
, "suppressTaskName": true
, "isBuildCommand": true