Skip to content

Instantly share code, notes, and snippets.

View dojeda's full-sized avatar
🏠
Working from home

David Ojeda dojeda

🏠
Working from home
View GitHub Profile
#!/usr/bin/env python
def sqrt(x):
begin = 0
end = x
while begin <= end:
mid = begin + (end - begin) // 2
@dojeda
dojeda / trigraphs-c++
Created April 15, 2015 16:16
TIL about trigraphs in C and C++. Wat the fk!
#include <iostream>
#include <vector>
#include <iterator>
using namespace std;
int main(int , char *[]) {
vector<int> v1 = {0,1,2};
#include <iostream>
#include <vector>
#include <Eigen/Dense>
int main(int argc, char *argv[]) {
Eigen::MatrixXd X = Eigen::MatrixXd::Random(3, 3);
// PCA = EVD of the covariance matrix
Eigen::SelfAdjointEigenSolver < Eigen::MatrixXd > solver(X.selfadjointView<Eigen::Lower>());
@dojeda
dojeda / epoching.py
Last active March 22, 2018 16:38
Epoching of 2D array on its last dimension using a view (not a copy)
""" Small proof of concept of an epoching function using NumPy strides
License: BSD-3-Clause
Copyright: David Ojeda <david.ojeda@gmail.com>, 2018
"""
import numpy as np
from numpy.lib import stride_tricks
@dojeda
dojeda / openapi.yaml
Created February 17, 2019 15:29
Example OpenAPI specification for inline model bug reproduction
openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets:
@dojeda
dojeda / riemann_euclid_plot.py
Created June 8, 2020 09:06
Comparison of distance functions on covariance matrices
from functools import partial
import matplotlib.pyplot as plt
import numpy as np
from pyriemann.utils.distance import distance_riemann
@partial(np.vectorize, excluded=['ref'])
def distance_riemann_v(c_xx, c_yy, ref):
""" Vectorized version of distance_riemann projected in 2D