Skip to content

Instantly share code, notes, and snippets.

View ktnyt's full-sized avatar
🐱

ktnyt ktnyt

🐱
View GitHub Profile
@ktnyt
ktnyt / chainer_ca.py
Last active August 10, 2020 17:41
Refactored code for a Convolutional Autoencoder implemented with Chainer.
import argparse
import numpy as np
from chainer import Variable, FunctionSet, optimizers, cuda
import chainer.functions as F
import cv2
import random
import cPickle as pickle
import sys
class ConvolutionalAutoencoder(FunctionSet):
@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 / naive-rae.py
Last active February 22, 2019 23:04
Naive implementation of a recursive autoencoder
import numpy as np
import theano
import theano.tensor as T
class RAE(object):
def __init__(self, input, rng, d, W=None, b=None, U=None, c=None):
dv = d
dh = d * 2
self.dv = dv
@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 {