Skip to content

Instantly share code, notes, and snippets.

@istupakov
istupakov / online_stft.cpp
Last active December 17, 2023 03:20
Online STFT on C++ (fftw)
#include <vector>
#include <span>
#include <complex>
#include <cmath>
#include <numbers>
#include <fftw3.h>
using std::complex;
using std::span;
@istupakov
istupakov / online_stft.py
Created December 16, 2023 08:45
Online STFT on Python (numpy)
import numpy as np
class OnlineSTFT:
def __init__(self, n_chan, n_fft=4096):
self.hop = n_fft // 2
self.win_a = 0.54 - 0.46 * np.cos(np.linspace(0, 2 * np.pi, n_fft, endpoint=False)) # Hamming window
self.win_s = self.win_a / (self.win_a**2 + np.roll(self.win_a, self.hop)**2)
self.input = np.zeros((n_fft, n_chan))
self.output = np.zeros((n_fft, n_chan))
self.n_freq = n_fft // 2 + 1
@istupakov
istupakov / WordToQTI.cs
Last active July 14, 2021 10:17
Word to QTI Converter
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
@istupakov
istupakov / markdown.component.ts
Created June 7, 2017 16:38
Angular 4 Markdown Component with Router Navigation.
import { Component, Input, ViewChild, AfterViewInit, ElementRef } from '@angular/core';
import { Router } from '@angular/router';
import { markdown } from 'markdown';
@Component({
selector: 'markdown',
template: `<div [innerHtml]="html" #root></div>`
})
export class MarkdownComponent implements AfterViewInit {
@ViewChild('root') root: ElementRef;
@istupakov
istupakov / AutomaticDifferentiation.cs
Last active February 2, 2017 21:09
Automatic differentiation (second order) on C# with Roslyn for parsing.
using System;
using System.Linq.Expressions;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp.Scripting;
using Microsoft.CodeAnalysis.Scripting;
namespace AutomaticDifferentiation
{
public struct DualNumber
@istupakov
istupakov / neerc2016-L.cpp
Created December 9, 2016 19:24
ACM ICPC NEERC 2016: Problem L. List of Primes
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;
pair<int, int> get_next_prime(int k)
{
for (int i = 2; i < k; i++)
@istupakov
istupakov / neerc2016-F.cpp
Created December 9, 2016 19:21
ACM ICPC NEERC 2016: Problem F. Foreign Postcards
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
std::string a;
getline(std::cin, a);
@istupakov
istupakov / ShuntingYardParser.cs
Created September 29, 2016 18:39
C# realization of Shunting-yard algorithm
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace ShuntingYardParser
{
enum TokenType { Number, Variable, Function, Parenthesis, Operator, Comma, WhiteSpace };
@istupakov
istupakov / NativeDll.prop
Created June 14, 2016 19:17
MsBuild config for nuget packages with native dlls
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Content Include="$(MSBuildThisFileDirectory)\..\lib\native\*.dll">
<Link>%(Filename).dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
@istupakov
istupakov / ConsoleApp.cs
Created February 13, 2016 23:55
Bug in .NET Core. Method not found: Expression.Update
using System;
using System.Linq.Expressions;
namespace ConsoleApp
{
class Visitor : ExpressionVisitor
{
protected override Expression VisitParameter(ParameterExpression node)
{
return Expression.Constant(1.0);