Skip to content

Instantly share code, notes, and snippets.

View ktnyt's full-sized avatar
💫

ktnyt ktnyt

💫
View GitHub Profile
@ktnyt
ktnyt / array.cpp
Created September 26, 2016 07:53
high functionality array prototype
#include <iostream>
#include <functional>
#include <array>
#include <vector>
template<std::size_t... S>
struct accumulator;
template<std::size_t R, std::size_t... S>
struct accumulator<R, S...> {
class Foo {
call() {
console.log('This:', this)
}
}
const foo = new Foo()
const bar = foo.call
foo.call()
bar()
Benchmark Time CPU Iterations
------------------------------------------------------------
ConstPipeNull/4 3895 ns 3880 ns 177135
ConstPipeNull/8 3972 ns 3943 ns 195948
ConstPipeNull/64 4141 ns 4098 ns 193347
ConstPipeNull/512 3922 ns 3887 ns 170929
ConstPipeNull/4k 4041 ns 4016 ns 188315
ConstPipeNull/32k 3983 ns 3964 ns 182430
ConstPipeNull/256k 3916 ns 3893 ns 191099
ConstPipeNull/1024k 4199 ns 4171 ns 181569
@ktnyt
ktnyt / vector.hpp
Last active June 24, 2016 14:53
NumPy ndarray like container in C++.
#include <iostream>
#include <array>
#include <list>
#include <algorithm>
#include <exception>
#include <memory>
#include <numeric>
#include <cassert>
#include <cstdint>
@ktnyt
ktnyt / cppgenerator.py
Created March 17, 2016 04:43
Personal CPP include/source generation script.
#!/usr/bin/env python
from os.path import isfile
from datetime import date
import argparse
parser = argparse.ArgumentParser(description='HPP/CPP generator')
parser.add_argument('module', type=str, help='Module')
parser.add_argument('--author', default='', help='Author')
parser.add_argument('--basename', default='', help='Basename')
parser.add_argument('--define', default=False, help='Define', action='store_true')
@ktnyt
ktnyt / kanazawa.md
Last active March 15, 2016 02:10 — forked from tonets/kanazawa.md
BH15.15向け金沢案内

#BH15.15向け金沢案内 @tonetsの主観です.行ったこと無い店も含まれています.

#飲み屋 ##金沢駅周辺

  • table nana
  • ランタン
  • オルガン
  • ゆめり
  • くろ屋
@ktnyt
ktnyt / HFComponent.py
Last active March 9, 2016 08:24
Hippocampal Formation Mock
import brica1
from CA1Component import CA1Component
from CA3Component import CA3Component
from DGComponent import DGComponent
from ECComponent import ECComponent
class HFComponent(brica1.ComponentSet):
def __init__(self, params):
super(HFComponent, self).__init__()
@ktnyt
ktnyt / WindowCamera.js
Last active May 7, 2016 19:47
A three.js camera for capturing a view through a static window.
THREE.WindowCamera = function(width, height, far) {
THREE.Camera.call(this);
this.type = 'WindowCamera';
this.width = width;
this.height = height;
this.far = far !== undefined ? far : 2000;
this.updateProjectionMatrix();
};
@ktnyt
ktnyt / shor.py
Created December 25, 2015 04:53
Simulation of Shor's Algorithm
import numpy as np
import matplotlib.pyplot as plt
def Hadamard(n):
def Hn(H=np.array([[1, 1], [1, -1]], dtype=np.complex64), n=n):
if n > 1:
return Hn(H=np.kron(np.array([[1, 1], [1, -1]], dtype=np.complex64), H), n=n-1)
return H
return Hn(n=n)
@ktnyt
ktnyt / treasure_hunt_generator.sh
Last active October 14, 2015 05:23
Self explanatory
#!/bin/sh
if [ -d treasure_hunt ]
then
rm -r treasure_hunt
fi
mkdir treasure_hunt
echo 'Aye aye mate! Welcome to the treasure hunt!' >> treasure_hunt/README