View m5stickc-timer.ino
/* NB: HAT speaker needs to be connected */ | |
#include <M5StickC.h> | |
#include "esp32-hal-timer.h" | |
volatile int interruptCounter; | |
int totalInterruptCounter; | |
// https://techtutorialsx.com/2017/10/07/esp32-arduino-timer-interrupts/ | |
hw_timer_t * timer = NULL; //Created Hardware Timer |
View basics.py
#%% | |
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: https://www.thinkpenguin.com/gnu-linux/country-code-list | |
On first boot, this file will be moved to /etc/wpa_supplicant/wpa_supplicant.conf where it may be edited later. |
View hasktorch.sh
# First of all make sure Nix is up and running https://nixos.org/nix | |
# Clone Hasktorch | |
git clone https://github.com/hasktorch/hasktorch.git | |
cd hasktorch | |
NIX_PATH="nixpkgs=https://github.com/NixOS/nixpkgs/archive/release-19.09.tar.gz" | |
nix-env -iA cachix -f https://cachix.org/api/v1/install | |
cachix use hasktorch |
View timelapse.sh
# 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 |
View cellular.py
#!/usr/bin/env python3 | |
""" | |
Cellular automata in Python | |
""" | |
import sys | |
Z = '.' | |
O = '#' |
View Iris.hs
-- 0. Download x.data and y.dat from https://www.kaggle.com/masterdezign/iris-with-onehotencoded-targets | |
-- 1. Install stack (command line interface is marked by $): | |
-- $ wget -qO- https://get.haskellstack.org/ | sh | |
-- (alternatively, curl -sSL https://get.haskellstack.org/ | sh) | |
-- 2. Install open-blas from https://www.openblas.net/ (needed for hmatrix package) | |
-- 3. Run | |
-- $ stack --resolver lts-10.6 --install-ghc runghc --package hmatrix-0.18.2.0 Iris.hs | |
import Numeric.LinearAlgebra as LA |
View Grad.hs
descent1D gradF iterN gamma x0 = take iterN (iterate _descend x0) | |
where | |
_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] https://clash-lang.org/ |
View brainf.hs
{- | |
Brainf**k interpreter | |
Instructions: | |
> 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. |
NewerOlder