Skip to content

Instantly share code, notes, and snippets.

View ktnyt's full-sized avatar
💫

Mirei Itaya ktnyt

💫
View GitHub Profile
This file has been truncated, but you can view the full file.
The Project Gutenberg EBook of Moby Dick; or The Whale, by Herman
Melville
This eBook is for the use of anyone anywhere at no cost and with almost
no restrictions whatsoever. You may copy it, give it away or re-use
it under the terms of the Project Gutenberg License included with this
eBook or online at www.gutenberg.org
Title: Moby Dick; or The Whale
@ktnyt
ktnyt / tp.zsh
Last active December 26, 2022 02:42
Directory teleportation.
#!/bin/zsh
function tp() {
help() {
echo "usage: tp [-h | --help] [<alias>] [<directory>]"
}
TP_CONFIG_PATH="${XDG_CONFIG_HOME:-$HOME/.config}/tp"
TP_CONFIG_FILE="${TP_CONFIG_PATH}/config.tsv"
if [ ! -d $TP_CONFIG_PATH ]
@ktnyt
ktnyt / thread_pool.hpp
Created July 9, 2019 08:22
C++14 Minimal Thread Pool
#ifndef __KTNYT_THREAD_POOL_HPP__
#define __KTNYT_THREAD_POOL_HPP__
#include <thread>
#include <functional>
#include <mutex>
#include <condition_variable>
#include <queue>
#include <vector>
@ktnyt
ktnyt / sorted_map.hpp
Created July 9, 2019 08:18
C++14 Sorted Map
#ifndef __KTNYT_SORTED_MAP_HPP__
#define __KTNYT_SORTED_MAP_HPP__
#include <utility>
#include <vector>
namespace ktnyt {
namespace detail {
template <class C, bool> struct sorted_map_brace_impl;
define-command -params 1 -shell-script-candidates %{
if [ -d .git ]; then
alias list='git ls-files --exclude-standard -co'
{ list | xargs -n1 dirname | sort | uniq | perl -ple '$_.="/"'; list | sort; } | fzy -e "$1"
else
find . -type f -or -type d | fzy -e "$1"
fi
} fzy-edit %{
edit %arg{1}
}
@ktnyt
ktnyt / c-utils.kak
Last active January 22, 2019 09:52
define-command -hidden -override c-family-insert-include-guards %{
evaluate-commands %sh{
case "${kak_opt_c_include_guard_style}" in
ifdef)
echo 'execute-keys ggi__<c-r>%__<ret><esc>gg/include/<ret>dggxs(/|\.)<ret>c_<esc><space>x~ggxyppI#ifndef<space><esc>jI#define<space><esc>jI#endif<space><space>//<space><esc>O<ret><ret><esc>'
;;
pragma)
echo 'execute-keys ggi#pragma<space>once<esc>'
;;
*);;
@ktnyt
ktnyt / kakrc
Last active January 17, 2019 09:00
My kakoune config.
# Generic Settings
hook global InsertChar k %{ try %{
exec -draft hH <a-k>jk<ret> d
exec <esc>
}}
hook global WinDisplay .* info-buffers
hook global WinCreate ^[^*]+$ %{ add-highlighter window/ number-lines -separator ' ' }
# Mappings
#include QMK_KEYBOARD_H
// #include "flip_keymap.h"
extern keymap_config_t keymap_config;
#define BASE 0
#define META 1
#define RGB 2
// Fillers to make layering more clear
@ktnyt
ktnyt / shared_vector.hpp
Last active August 8, 2018 05:52
A simple wrapper for a reference counted vector container.
#ifndef __LAPLUS_SHARED_VECTOR_HPP__
#define __LAPLUS_SHARED_VECTOR_HPP__
#include <memory>
#include <vector>
namespace laplus {
template <class T, class Allocator = std::allocator<T>>
class shared_vector {
@ktnyt
ktnyt / assoc_vec.hpp
Last active June 21, 2018 16:56
std::vector based association vector for C++11.
#ifndef __KTNYT_ASSOCVEC_HPP__
#define __KTNYT_ASSOCVEC_HPP__
#include <functional>
#include <memory>
#include <utility>
#include <vector>
namespace ktnyt {