Skip to content

Instantly share code, notes, and snippets.

@SaitoAtsushi
SaitoAtsushi / sample.cpp
Created December 23, 2023 03:49
型に連番を割り当てる
#include <cstddef>
#include <iostream>
#include <type_traits>
// 型に結び付いた連番を生成するクラステンプレート
template <class... T>
class identify_number_traits {
private:
template <class U>
struct foo {
@SaitoAtsushi
SaitoAtsushi / string_append.cpp
Created September 6, 2022 02:36
文字列の連結
#include <algorithm>
#include <iostream>
#include <string>
#include <string_view>
#include <type_traits>
#include <utility>
template <class T, class = void>
class is_string : public std::false_type {};
@SaitoAtsushi
SaitoAtsushi / column_split.hpp
Last active September 19, 2021 08:23
整数を各桁に分解するイテレータ。 過剰な抽象化をやってみた余興。 右の記事を見てやってみただけ → https://qiita.com/dsy_i07/items/5de9417ff235d5aa6a42
#include <cassert>
#include <iterator>
#include <type_traits>
template <class T, int base, typename std::enable_if<std::is_unsigned<T>::value, void*>::type = nullptr>
class column_splitted_iterator {
private:
T data;
bool endflag;
@SaitoAtsushi
SaitoAtsushi / geo3x3.sls
Created February 25, 2021 06:13
Geo3x3 in Scheme (R6RS)
#!r6rs
(library (geo3x3)
(export encode decode)
(import (rnrs))
(define (encode lat lng level)
(assert (real? lat))
(assert (real? lng))
(assert (integer? level))
(assert (> level 0))
# Qiita で見た題材を Rust らしく整理
# 元ネタ → https://qiita.com/fltwtn/items/7ca55afd3f648ca63281
[package]
name = "geodetic"
version = "0.1.0"
authors = ["SAITO Atsushi <[email protected]>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@SaitoAtsushi
SaitoAtsushi / ssltest.log
Created June 7, 2019 08:14
Gauche-0.9.8_rc1 (以前からだけど) の rfc.tls モジュールのテストで失敗するログ
All AES tests passed
All MD5 tests passed
All SHA1 tests passed
All SHA256 tests passed
All SHA384 tests passed
All SHA512 tests passed
All HMAC tests passed
All BIGINT tests passed
All RSA tests passed
invalid digest: 2a 86 48 ce 38 04 03
@SaitoAtsushi
SaitoAtsushi / hoge.sls
Created May 22, 2019 09:06
Chez Scheme なら出来るライブラリ隠蔽のトリック
(library (huga)
(export foo)
(import (rnrs))
(define foo 'bar)
)
(library (hoge)
(export foo)
(import (huga))
)
@SaitoAtsushi
SaitoAtsushi / pixiv-dl.scm
Last active October 25, 2019 02:24
PIXIV からダウンロードするやつ
(define user-name "user-name") ;; PIXIV のユーザー名
(define user-password "password") ;; PIXIV のパスワード
(use rfc.http)
(use rfc.822)
(use rfc.cookie)
(use rfc.json)
(use rfc.uri)
(use rfc.md5)
@SaitoAtsushi
SaitoAtsushi / defer.cpp
Created April 2, 2019 06:27
Go の defer っぽいものを C++ でやってみる遊び
#include <functional>
class defer_t {
private:
std::function<void(void)> f;
public:
defer_t(std::function<void(void)> f);
~defer_t(void);
};
@SaitoAtsushi
SaitoAtsushi / average.sls
Created October 30, 2018 15:38
効率的に平均を計算するマクロ
#!r6rs
(library (average)
(export average)
(import (rnrs))
(define (%average . args)
(/ (apply + args)
(length args)))
(define-syntax average