Skip to content

Instantly share code, notes, and snippets.

@t2ym
t2ym / compile_time_truncation.h
Created June 15, 2021 02:56
Kotlin-style trimIndent() at compile time for C++ raw literals
/*
* Blog of the original author: https://davidgorski.ca/posts/truncate-string-whitespace-compiletime-cpp/
* Original source gist: https://gist.github.com/dgski/810ede7c4a80917c0adc99c6852fee9a
*
* Modifications by @t2ym (https://github.com/t2ym)
* - Rearranged as a header file
* - Surrounded main() by #ifdef COMPILE_TIME_TRUNCATION_EXAMPLE ... #endif
* - Added an argument "" to static_assert() to comply with C++11
* - Put truncateWhitespace() in the compiletime namespace
* - Made is_whitespace() inline
@t2ym
t2ym / ldap_member_of.cc
Last active June 9, 2021 06:29
Prototype for accessor of memberOf attributes for LDAP users to be used for nicexprs.h middleware
/*
* Copyright (c) 2021, Tetsuya Mori <t2y3141592@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
@t2ym
t2ym / nghttp2-v1.43.0-ssl.patch
Last active June 15, 2021 07:45
Git patch to nghttp2-v1.43.0 to add const SSL *nghttp2::asio_http2::server::request::ssl() to associate client certificates with requests
diff --git a/src/asio_server.cc b/src/asio_server.cc
index 74c92276..5a79061e 100644
--- a/src/asio_server.cc
+++ b/src/asio_server.cc
@@ -154,7 +154,7 @@ void server::start_accept(boost::asio::ssl::context &tls_context,
return;
}
- new_connection->start();
+ new_connection->start(new_connection->socket().native_handle());
@t2ym
t2ym / asio-sv.cc
Last active June 15, 2021 03:14
sample for nicexprs.h - based on nghttp2/examples/asio-sv.cc
/*
* nghttp2 - HTTP/2 C Library
*
* Copyright (c) 2014 Tatsuhiro Tsujikawa
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
@t2ym
t2ym / nicexprs.h
Last active April 30, 2022 04:28
nicexprs.h: a single header file ExpressJs-like middleware API on nghttp2 asio library
/*
* Copyright (c) 2021, Tetsuya Mori <t2y3141592@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
@t2ym
t2ym / minila.json
Created November 11, 2017 08:12
Minila-like key mappings with left Cmd for Karabiner-Elements Complex Modifications Add Rules (~/.config/karabiner/assets/complex_modifications/minila.json)
{
"title": "Minila-like key mappings with left Cmd",
"rules": [
{
"description": "Minila-like key mappings with left Cmd",
"manipulators": [
{
"from": {
"key_code": "s",
"modifiers": {
@t2ym
t2ym / .Xmodmap
Created October 21, 2017 03:01
Minila keymap for X11 with US keyboard (Super_L(Windows_L) as Fn key feature in AltGr keycode)
remove mod4 = Super_L
keycode 133 = Mode_switch
keycode 24 = q Q q Q
keycode 25 = w W w W
keycode 26 = e E Up Up
keycode 27 = r R r R
keycode 28 = t T t T
keycode 29 = y Y y Y
keycode 30 = u U u U
@t2ym
t2ym / LeftWinAsAppsKeyAndRightAltAsLeftWin.reg
Last active November 4, 2016 08:50
FILCO Minila-like key mappings with Left Windows key for AutoHotKey assisted by SharpKeys
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,5d,e0,5b,e0,5b,e0,38,e0,\
00,00,00,00
@t2ym
t2ym / private.xml
Last active September 7, 2017 00:22
FILCO Minila-like key mapping with Left Command key and terminal tab switching with Scrollwheel (Left/Right) for Karabiner
<?xml version="1.0"?>
<root>
<item>
<name>Fn + Minila (with Command_L to Fn)</name>
<identifier>option.minilamode_fn</identifier>
<autogen>__KeyToKey__ KeyCode::S, ModifierFlag::FN, KeyCode::CURSOR_LEFT</autogen>
<autogen>__KeyToKey__ KeyCode::D, ModifierFlag::FN, KeyCode::CURSOR_DOWN</autogen>
<autogen>__KeyToKey__ KeyCode::E, ModifierFlag::FN, KeyCode::CURSOR_UP</autogen>
<autogen>__KeyToKey__ KeyCode::F, ModifierFlag::FN, KeyCode::CURSOR_RIGHT</autogen>
<autogen>__KeyToKey__ KeyCode::M, ModifierFlag::FN, KeyCode::FORWARD_DELETE</autogen>
@t2ym
t2ym / https-local-server.sh
Last active June 22, 2017 11:15
Script to launch local HTTPS server for watching local XLIFF files
#!/bin/sh
if [ "$1" = "" ]; then
echo Please specify the path to the root folder containing the target XLIFF file
echo $0 /Path/To/XLIFF/Folder
exit 1
fi
which openssl
if [ "$?" = "1" ]; then
echo Please install openssl command