Skip to content

Instantly share code, notes, and snippets.

@basp1
basp1 / main.cpp
Created September 20, 2024 11:29
Simple unit-testing
#include <zero_test.h>
#include <vector>
namespace example::test {
ZERO_DEFINE_TEST_SUITE(test_example);
ZERO_DEFINE_TEST(test_example, name1) {
std::vector<int> v;
v.reserve(10);
@basp1
basp1 / dtw.ijs
Last active September 17, 2020 08:11
DTW timeseries clustering algorithm in J
load '~Projects/u.ijs'
load '~Projects/pq.ijs'
distance=: |@-
dtw=: dyad define
n=. #x
d=. x distance/"1 y
@basp1
basp1 / pq.ijs
Last active September 17, 2020 08:11
Priority queue in J
NB. priority queue
coclass 'PQ'
load '~Projects/u.ijs'
create=: verb define
vals=: $ 0
size=: 0
)
@basp1
basp1 / array.c
Created September 2, 2019 08:10
array
#include "array.h"
#include <assert.h>
#include <memory.h>
#include <stdlib.h>
#include <string.h>
#define HEADER(P) ((array_header_t*)((char*)P - sizeof(array_header_t)))
void* array_new(int length, int value_size)
(package-initialize)
(custom-set-variables
'(blink-cursor-mode nil)
'(ring-bell-function (quote ignore))
'(scroll-bar-mode nil)
'(tool-bar-mode nil)
'(visible-bell t))
(custom-set-faces
@basp1
basp1 / binary_search.ijs
Last active July 3, 2019 07:06
binary search in J
mid =: ([: <. [: -: #) : [:
take_mid =: ({~ mid) : [:
compare_mid =: [: : (> take_mid)
take_left =: ({.~ mid) : [:
take_right =: (}.~ mid) : [:
@basp1
basp1 / .vimrc
Last active March 27, 2019 06:10
vimrc
" Plugins:
" https://github.com/scrooloose/nerdtree
" https://github.com/mbbill/undotree
" https://github.com/rafi/awesome-vim-colorschemes
" https://github.com/ntpeters/vim-better-whitespace
" https://github.com/xolox/vim-misc
" https://github.com/xolox/vim-session
" https://github.com/Shougo/vimproc.vim
" https://github.com/Shougo/vimshell.vim
@basp1
basp1 / time.h
Created May 30, 2018 07:18
std::chrono::time_point to std::string
#include <chrono>
#include <ctime>
#include <string>
static std::string toString(std::chrono::time_point<std::chrono::system_clock> time) {
static char buf[100];
std::time_t timeC = std::chrono::system_clock::to_time_t(time);
std::tm timeTm = *std::localtime(&timeC);
std::strftime(buf, 100, "%c", &timeTm);
@basp1
basp1 / HoltWinters.cs
Last active November 21, 2017 11:49
Holt-Winters
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mathematics
{
public class HoltWinters
{
@basp1
basp1 / A_Miner.cs
Last active June 6, 2018 06:10
Яндекс.Блиц. Финал. А. Сапер
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yandex.Blitz
{
class A_Miner
{