Skip to content

Instantly share code, notes, and snippets.

View joonaojapalo's full-sized avatar

Joona Ojapalo joonaojapalo

View GitHub Profile
@joonaojapalo
joonaojapalo / kalmanfilt.py
Created January 27, 2023 09:50
Basic 1D Kalman filter implementation with `x_{t+1} = v_t + x_0` dynamics
"""
Adapted from work by Ian Glover (https://gist.github.com/manicai/922976)
"""
import numpy as np
__all__ = ["kalmanfilt1d"]
def kalmanfilt1d(x, time_step=0.1, n_init_samples=10, mesurement_noise=30, process_variance=0.01):
"""1-D Kalman filter with x1 = vt + x0 dynamics.
@joonaojapalo
joonaojapalo / gamma-interp.js
Created October 30, 2020 07:39
Gamma interpolation function
//N = Math.ceil((x1 - x0) / d + 1))
/**
* @param {Number} k Gamma.
* @param {Number} x Interpolation value [0, 1]
*/
const f = (k, x) => (Math.exp(k * Math.max(0, Math.min(1, x)))-1)/(Math.exp(k)-1)
/**
* @param {Number} k Gamma
import React from "react";
import PropTypes from "prop-types";
const Link = ({ text, url }) => (
<a href={url}>{text}</a>;
);
Link.propTypes = {
text: PropTypes.string.isRequired,
url: PropTypes.instanceOf(URL).isRequired,
@joonaojapalo
joonaojapalo / node-up.sh
Last active December 10, 2019 11:54
node.js script playground
echo '{"presets":[["@babel/preset-env",{"targets":{"node":"current"}}]]}' > .babelrc
echo 'console.info(" ** It works: node_modules/.bin/nodemon --exec babel-node index.js")' > index.js
npm i --save-dev @babel/node @babel/preset-env @babel/core nodemon
code index.js &
node_modules/.bin/nodemon --exec babel-node index.js
@joonaojapalo
joonaojapalo / modal.css
Created May 30, 2019 18:54
Modal style
/**
@example:
<div class="modal">
<h1 class="title">Hox!</h1>
<hr/>
</div>
*/
body {
background: #ddd;