Skip to content

Instantly share code, notes, and snippets.



View GitHub Profile
View m5stickc-timer.ino
/* NB: HAT speaker needs to be connected */
#include <M5StickC.h>
#include "esp32-hal-timer.h"
volatile int interruptCounter;
int totalInterruptCounter;
hw_timer_t * timer = NULL; //Created Hardware Timer
masterdezign /
Created May 14, 2020
BCI 101: MNE workshop by David Haslacher
import os
import numpy as np
import mne
from mne.preprocessing import compute_current_source_density
# %matplotlib qt
# First, we need to load the data
sample_data_folder = mne.datasets.sample.data_path()
sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample',
View Raspi WiFi.txt
Edit wpa_supplicant.conf and save it to the root of boot partition.
Replace the country code, ssid, and psk.
Full list of country codes:
On first boot, this file will be moved to /etc/wpa_supplicant/wpa_supplicant.conf where it may be edited later.
masterdezign /
Last active Jul 27, 2020
Hasktorch with Nix
# First of all make sure Nix is up and running
# Clone Hasktorch
git clone
cd hasktorch
nix-env -iA cachix -f
cachix use hasktorch
masterdezign /
Created Mar 20, 2020
A video from images
# Concatenate images
ffmpeg -framerate 5 -pattern_type glob -i "*.jpg" output.mp4
# Compress
ffmpeg -i output.mp4 -vcodec libx265 -acodec aac -crf 23 output_compressed.mp4
masterdezign /
Created Jan 21, 2019
Cellular automata in Python
#!/usr/bin/env python3
Cellular automata in Python
import sys
Z = '.'
O = '#'
View Iris.hs
-- 0. Download and y.dat from
-- 1. Install stack (command line interface is marked by $):
-- $ wget -qO- | sh
-- (alternatively, curl -sSL | sh)
-- 2. Install open-blas from (needed for hmatrix package)
-- 3. Run
-- $ stack --resolver lts-10.6 --install-ghc runghc --package hmatrix- Iris.hs
import Numeric.LinearAlgebra as LA
masterdezign / Grad.hs
Last active Dec 10, 2018
A brief gradient descent illustration in Haskell
View Grad.hs
descent1D gradF iterN gamma x0 = take iterN (iterate _descend x0)
_descend gamma' x = x - gamma' * gradF x
-- Suppose, we have a function F(x) = (x - 3)^2.
-- Therefore, Grad F(x) = 2 * (x - 3).
gradF_test x = 2 * (x - 3)
main = print (descent1D gradF_test 10 gamma 0.0)
where gamma = 0.5
View Grad.hs
-- Run a one dimensional gradient descent written in Clash [1],
-- a high level language that compiles to Verilog and VHDL.
-- Gradient descent can be described by a formula:
-- a_n+1 = a_n - gamma * Grad F(a_n),
-- where the constant `gamma` is what is referred to in deep learning as
-- the learning rate.
-- [1]
masterdezign / brainf.hs
Last active Aug 30, 2017
Brainf**k interpreter in Haskell.
View brainf.hs
Brainf**k interpreter
> Increment data pointer so that it points to next location in memory.
< Decrement data pointer so that it points to previous location in memory.
+ Increment the byte pointed by data pointer by 1. If it is already at its maximum value, 255, then new value will be 0.
- Decrement the byte pointed by data pointer by 1. If it is at its minimum value, 0, then new value will be 255.
. Output the character represented by the byte at the data pointer.
, Read one byte and store it at the memory location pointed by data pointer.