Skip to content

Instantly share code, notes, and snippets.

@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
{
@basp1
basp1 / D_Graph.cs
Created September 18, 2017 10:31
Яндекс.Блиц. D
// https://contest.yandex.ru/hiring/contest/5048/problems/D/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace yandex.blitz
{