Skip to content

Instantly share code, notes, and snippets.

View kazeto's full-sized avatar

kazeto kazeto

  • NEC Central Lab.
  • Japan
View GitHub Profile
@kazeto
kazeto / boolean.h
Last active September 2, 2018 14:40
Boolean to be automatically initialized to false.
class boolean_t
{
public:
inline boolean_t(bool b = false) : m_bool(b) {}
inline boolean_t(const boolean_t&) = default;
inline explicit operator bool() const noexcept { return m_bool; }
inline bool operator!() const noexcept { return !m_bool; }
inline boolean_t& operator=(const boolean_t&) = default;
@kazeto
kazeto / tsv-mode.el
Created August 2, 2018 08:21
Emacs mode for TSV files.
;;; -------- TSV mode --------
(defface my-face-tsv-tab '((t (:background "black" :foreground "black"))) "Face for tabs in TSV.")
(defvar my-face-tsv-tab 'my-face-tsv-tab)
(defface my-face-tsv-2 '((t (:foreground "blue"))) "Face for 2nd column in TSV.")
(defvar my-face-tsv-2 'my-face-tsv-2)
(defface my-face-tsv-3 '((t (:foreground "yellow"))) "Face for 3rd column in TSV.")
(defvar my-face-tsv-3 'my-face-tsv-3)
@kazeto
kazeto / LICENSE
Created April 12, 2018 06:00
This license applies to all of my public gists.
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
@kazeto
kazeto / range.hpp
Last active April 12, 2018 05:45
Simple Python-like range function for the range-based for statement in C++11.
template <class T> class range
{
public:
template <class T> class iterator
{
public:
iterator(T c) : m_count(c) {}
T operator*() const { return m_count; }
void operator++() { ++m_count; }
@kazeto
kazeto / ansi_color.py
Created February 28, 2018 05:35
Python code to color a string with ANSI escape sequence.
from functools import partial
def ansi_color(code, text, is_bold=False):
if is_bold:
code = ('1;' + code)
return '\033[%sm%s\033[0m' % (code, text)
ansi_red = partial(ansi_color, '31')
ansi_green = partial(ansi_color, '32')
ansi_yellow = partial(ansi_color, '33')
@kazeto
kazeto / remove_ansi_escape.py
Last active February 28, 2018 03:57
Python code which removes ANSI escape sequences in a string.
import re
def remove_ansi_escape(s):
return re.sub(r'\033\[[0-9;]+m', '', s)
@kazeto
kazeto / LNK.md
Created April 3, 2017 06:32
リンクエラーに直面した時の対処

General

  • 各プログラムの「ランタイムライブラリ」が一致しているかを確認する
  • 各プログラムの「文字セット」が一致しているかを確認する
  • 必要なlibファイルを「追加の依存ファイル」に記述したかどうかを確認する
  • 必要なlibファイルの場所を「追加のライブラリディレクトリ」に記述したかどうかを確認する

VS2015

  • legacy_stdio_definitions.lib を「追加の依存ファイル」に記述してみる
  • printf などの関数でリンクエラーが出た場合はこれを疑う
@kazeto
kazeto / tuffy.el
Last active November 27, 2016 23:56
A Emacs major mode for Tuffy.
;;; -------- Tuffy mode --------
(define-derived-mode
tuffy-mode text-mode
"Tuffy" "View mode for Tuffy's input file."
(setq tuffy-font-lock-keywords
'(("//.*$" . font-lock-comment-face)
("!" . font-lock-warning-face)
("\\(\"[^\"]*\"\\)\\s-*," 1 font-lock-string-face)
("\\(\"[^\"]*\"\\)\\s-*)" 1 font-lock-string-face)
(" v " . font-lock-constant-face)