Skip to content

Instantly share code, notes, and snippets.

View mumumu's full-sized avatar

Yoshinari Takaoka mumumu

View GitHub Profile
@mumumu
mumumu / vimium_myconf.txt
Created April 3, 2019 01:51
vimium の自己流設定。モード指定など全て無効に
# Insert your preferred key mappings here.
unmapAll
map j scrollDown
map k scrollUp
map l scrollRight
map h scrollLeft
map gg scrollToTop
map G scrollToBottom
@mumumu
mumumu / why_you_should_avoid_use_uint8_in_cp.md
Last active February 24, 2024 08:34
uint8_t とかをカッコつけて競技プログラミングでは使わないほうがいい、という話

uint8_t とかをカッコつけて競技プログラミングでは使わないほうがいい、という話

  • 競技プログラミングでは、std::cin で値を入力するのが一般的である
  • 問題の制約上、小さな値 (例: 0 < N < 100 とか)は、uint8_t で扱えそう、と思ったりする人がいるかもしれないが、ここに罠がある
    • uint8_t な変数に std::cin すると、ビットパターンは char になる。少なくとも gcc (libstdc++) の環境では。
      • 他の処理系だと異なる動きをするかもしれない
    • なので、数値と比較すると思ったように動作しない

サンプルコード (gcc only)

Q. C++ で using namespace std; をなぜ避けるのか?

A. 以下のような、「名前空間汚染」と呼ばれる害悪を引き起こすからです。
特に複数人で、比較的大きなコードを書く場合は強く効いてきます。

ここでは、 std を名前空間の例として挙げていますが、std に限りません。

1. std 名前空間に定義されている名前と被った、ユーザー定義型などを安易に使えなくなる

わざとらしい例だと、以下のような感じです。

@mumumu
mumumu / couriertls_tls_private_key_memo.md
Last active September 25, 2018 13:24
couriertls の TLS_PRIVATE_KEY 対応方針

couriertls の TLS_PRIVATE_KEY 対応方針

ここでは、下記チケットの対応方針について述べる
svarshavchik/courier#10

前提

couriertls(1) には client モードと server モードがある。

client モードは、 couriertls が TLSクライアントとして動作するときのモードを実装するものである。server モードはその対になるもので、courirertls がサーバとして動作するときのモードを実装するものである。

diff --git a/tcpd/libcouriertls.c b/tcpd/libcouriertls.c
index 199015e..b24ccc3 100644
--- a/tcpd/libcouriertls.c
+++ b/tcpd/libcouriertls.c
@@ -333,6 +333,7 @@ static void load_dh_params(SSL_CTX *ctx, const char *filename,
}
static int read_certfile(SSL_CTX *ctx, const char *filename,
+ const char *private_key_filename,
int *cert_file_flags)
@mumumu
mumumu / php_chm_build_environment_memo.md
Last active October 13, 2020 19:50
メンテナ向け: PHPマニュアル の chm ビルド環境

メンテナ向け: PHPマニュアル の chm ビルド環境

PHPマニュアル の chm は、ビルドに Windows 環境が必要である。
現在は、クラウドの力を借りて週に一度ビルドから配布までを行っているが、誰でも出来るようにするには少し課題がある。

ビルド環境の詳細

  • Windows が前提
    • 2018/06 現在は、Amazon EC2 上の Windows Server 2016 を使用
  • ビルドした成果物は phpmanualchm という公開バケットへ aws s3 sync し、php.net 側はそれを毎週1回DLして公開する

Git 版 Courier IMAP をビルドし、起動する方法のメモ

courier-unicode は、以下の方法でビルドし、インストールしておく

$ git clone https://github.com/svarshavchik/courier-libs
$ cd courier-libs/unicode
$ autoheader
$ aclocal
@mumumu
mumumu / memo_letsencrypt_wildcard.txt
Created May 3, 2018 19:40
手元の環境で letsencrypt の wildcard 証明書を取ってみたメモ
mumumu@mailserver 23:27:14 ~/certbot [master] $ ./certbot-auto
Requesting to rerun ./certbot-auto with root privileges...
Bootstrapping dependencies for RedHat-based OSes... (you can skip this with --no-bootstrap)
yum は /bin/yum です
yum はハッシュされています (/bin/yum)
読み込んだプラグイン:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* epel: mirror.dmmlabs.jp
* extras: ftp.iij.ad.jp
@mumumu
mumumu / sylpheed_vi_keybind.patch
Last active September 22, 2019 10:56
sylpheed vi keybind patch, highly improved version than previous one ( https://gist.github.com/mumumu/e11837ec1e5923981b7f0b0064259388 )
Index: src/mainwindow.c
===================================================================
--- src/mainwindow.c (revision 3616)
+++ src/mainwindow.c (working copy)
@@ -481,7 +481,9 @@
static void next_labeled_cb (MainWindow *mainwin,
guint action,
GtkWidget *widget);
-
+static void latest_cb (MainWindow *mainwin,
@mumumu
mumumu / sylpheed_vi_less_keybind_patch_on_summaryview.patch
Last active May 4, 2018 11:07
sylpheed vi/less keybind patch on summaryview
Index: src/summaryview.c
===================================================================
--- src/summaryview.c (revision 3616)
+++ src/summaryview.c (working copy)
@@ -6122,22 +6122,26 @@
((event->state & (GDK_SHIFT_MASK|GDK_MOD1_MASK)) != 0);
switch (event->keyval) {
- case GDK_space: /* Page down or go to the next */
- case GDK_KP_Space: