Skip to content

Instantly share code, notes, and snippets.

@noqisofon
noqisofon / hr2message.cpp
Created January 5, 2024 08:47
( ノ╹◡◡╹)ノ HRESULT の値から対応するメッセージを取得したいよなーー、俺もな~~~~~
#include <iostream>
#include <stdexcept>
#include <windows.h>
std::string hresult_to_string( HRESULT hr ) {
constexpr size_t MESSAGE_BUFFER_SIZE = 1024;
CHAR message[MESSAGE_BUFFER_SIZE] = {};
DWORD got = FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
nullptr,
@noqisofon
noqisofon / guess_cxx_version.cpp
Created January 5, 2024 03:36
( ノ╹◡◡╹)ノ C++ のバージョンを判別したいよなー、俺もな~
#include <iostream>
#ifdef _MSVC_LANG
# if _MSVC_LANG >= 201402L
# define HOGE_LANGUAGE_ENABLE_CXX14
# endif //* _MSVC_LANG <= 201402L */
# if _MSVC_LANG >= 201703L
# define HOGE_LANGUAGE_ENABLE_CXX17
# endif //* _MSVC_LANG <= 201703L */
@noqisofon
noqisofon / openpgp.md
Created December 19, 2023 13:46
`keyoxide.org` の証明 gist
@noqisofon
noqisofon / can-you-feel-nil.org
Last active September 9, 2023 00:04
( ノ╹◡◡╹)ノ Nil を判定したいよなー、俺もなー

Nil かどうかを判定したさがある

以下のようなコードは「あー、にるい」が出力されそうですが、実際に実行してみると出力されません。

my $puyo = Nil;
say 'あー、にるい' if $puyo ~~ Nil;

なぜこうなるのかをこれから解説します。

@noqisofon
noqisofon / buy_cat000.rb
Created July 19, 2023 13:54
( ノ╹◡◡╹)ノ 無限にねこを購入するコードだと思う
def not_enough_cats?
true
end
def buy_cat()
purchases = rand(6) + 1
puts "ねこを #{purchases} 匹購入しました。"
end
while true
@noqisofon
noqisofon / about_data_table000.md
Created July 6, 2023 14:19
( ノ╹◡◡╹)ノ DataTable~~~

DataColumnを今の書き方で書くならこんな感じ:

void make_table() {
    // DataTable インスタンスを作成します。
    var table = new DataTable("商品");

    // 列定義をタプルの配列で作成します。
    var columnDefinitions = new (string name, Type dataType, bool allowNull)[] {
        (name: "id"   , dataType: typeof(long)   , allowNull: false),
sequenceDiagram
  にゃんぷっぷー ->> 飼い主 : 愛嬌を振りまく
  飼い主 ->> にゃんぷっぷー : 餌を与える
'./championships.create.sql'.IO.spurt( q:to/END/ );
CREATE TABLE "championships" (
"championship_id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"champion_kind_id" INTEGER NULL,
"name" TEXT NULL
);
END
'./championship_kinds.create.sql'.IO.spurt( q:to/END/ );
CREATE TABLE "championship_kinds" (
@noqisofon
noqisofon / gen-record-data.raku
Created May 13, 2023 02:16
( ノ╹◡◡╹)ノ てきとーな称号を 50 個くらい生成してくれるサイトのデータをカテゴリ分けして INSERT 文にしてくれると思われるすくりぷよ
my @championships = './championship000.tsv'.IO.lines;
my %classificated = classify {
when /['女皇帝' || '皇帝'] $/ { '皇帝' }
when /'内親王' $/ { '内親王' }
when /'親王' $/ { '親王' }
when /'法王' $/ { '法王' }
when /'上級王' $/ { '上級王' }
when /['王' || '女王' ] $/ { '王' }
when /['王子' || '王女' ] $/ { '王息' }
@noqisofon
noqisofon / change_the_in.org
Created April 11, 2023 08:05
( ノ╹◡◡╹)ノ 「いっぱい」の「い」を「お」に変えてみるテスト

「いっぱい」の「い」を「お」に変えてみよう。

my $phrase = 'いっぱい';

Raku 言語においては .subst メソッドを使うと文字列の置換を行うことができる。 早速やってみよう。

みんな大好き「おっぱい」になるのは最初の「い」を「お」に変えたときだ。