Skip to content

Instantly share code, notes, and snippets.

@hidez8891
hidez8891 / cpp_type_demangle.hpp
Last active November 16, 2021 11:33
C++の型を文字表現化 (support C++20 later)
#include <sstream>
#include <type_traits>
#include <typeinfo>
#if __has_include(<cxxabi.h>)
#include <cxxabi.h>
inline std::string _impl_type_demangle_raw(const char* mangled)
{
int status;
char* buf = abi::__cxa_demangle(mangled, 0, 0, &status);
@hidez8891
hidez8891 / cpp_template_literal.cpp
Created May 11, 2021 13:29
templateパラメータによる文字リテラルの変換
#include <iostream>
#include <string>
#include <tuple>
#include <boost/preprocessor/cat.hpp>
#define literal_cast(T, CHARS) \
std::get<const T*>( \
std::tuple< \
const char*, \
@hidez8891
hidez8891 / cpp_concepts_interface.cpp
Last active February 7, 2021 04:11
継承とインターフェイスによる、template引数の制限 (C++20)
#include <iostream>
#include <fstream>
#include <type_traits>
#include <cassert>
// 継承関係で制限
template <class T, class U>
concept Derived = std::is_base_of<U, T>::value;
template <typename IStream, typename OStream>
@hidez8891
hidez8891 / cpp_filter_map.cpp
Created February 6, 2021 12:57
C++でのfilter/map操作 (C++98~C++20, range-v3)
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
// after C++20
#if __cplusplus >= 202002L
#include <ranges>
#endif
@hidez8891
hidez8891 / progress.py
Last active December 8, 2018 11:54
Progressbar & loss image & sample image extension for chainer
from fastprogress import master_bar, progress_bar
from chainer import reporter
from math import ceil
import six
import PIL
from io import BytesIO
from IPython import display
@hidez8891
hidez8891 / config_via_proxy.md
Created October 10, 2018 12:54
Proxyでつらい人のためのメモ書き

Proxyでつらい人のためのメモ書き

様々な理由で、Proxyを通してコマンドを使わなきゃいけない人のためのメモ。

環境変数

WindowsでもLinuxでも同じ。
これで、だいたいのコマンドは行ける。

# cmd.exe
@hidez8891
hidez8891 / error_and_die.go
Created May 30, 2018 11:25
avoid golang error boilerplate (but, this is evil code)
package main
import (
"fmt"
)
func main() {
err := test1()
fmt.Println("test1:", err) // "test1: error message"
@hidez8891
hidez8891 / itc2extractor.go
Last active November 12, 2017 10:42
itc2 (iTunes Artworks Cache Format) extractor
package main
import (
"fmt"
"image"
"image/color"
"image/jpeg"
"io"
"os"
@hidez8891
hidez8891 / Dockerfile
Created October 21, 2017 12:34
Docker for golang with neovim
FROM golang
RUN apt-get update && apt-get install -y \
neovim \
python3 \
python3-pip \
&& rm -rf /var/lib/apt/lists/* \
&& pip3 install --upgrade neovim \
&& mkdir -p /root/.config/nvim \
&& go get -u github.com/nsf/gocode \
@hidez8891
hidez8891 / autoup.go
Created September 20, 2016 14:39
auto version string updater for Golang
package main
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
"io/ioutil"
"os"
"strconv"