Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>My first three.js app</title>
<style>
body { margin: 0; }
canvas { display: block; }
</style>
</head>
import io
import numpy as np
from numpy.random import randint, standard_normal
dtypes = ('float32', 'float64', 'int64', 'int32', 'int16')
def make_random_array():
s = randint(1, 5, size=randint(1, 5))
d = dtypes[randint(0, len(dtypes))]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import threading
import serial
import queue
import time
# make thread-safe queue for data logging/writing
global_dataMsgQ = queue.Queue()
# make a thread-safe queue to inform different threads when it's time to stop
global_stopQ = queue.Queue()
#include <stdio.h> // for printf
#include <math.h> // for testing only, not used by cordic
#include "cordic-32bit.h" // for actual cordic algo
//Print out sin(x) vs fp CORDIC sin(x)
int main(int argc, char **argv)
{
float p;
// sin_int, cos_in;
@standarddeviant
standarddeviant / two_timing.py
Created January 3, 2020 15:37
Simple script to calculate the error of polling multiple sample rates with Python `time.sleep`
import time
import numpy as np
fs_list = [120.0, 2.0]
dt_list = [1/fs for fs in fs_list]
prevt_list = [time.time(), ] * len(fs_list)
sample_times = [list() for fs in fs_list]
timeout_seconds = 10
sleep_seconds = min(dt_list) * 0.1
@standarddeviant
standarddeviant / golf_dates.ipynb
Created November 25, 2019 15:20
Days Between Trump's Golf Outings
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@standarddeviant
standarddeviant / base.c
Last active November 5, 2019 12:44
Soundpipe ex_biquad only, embedded exercise
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#ifndef NO_LIBSNDFILE
#include <sndfile.h>
#endif
#include "soundpipe.h"
int sp_create(sp_data **spp)
@standarddeviant
standarddeviant / git_version_hooks_for_c.py
Created June 6, 2019 03:33
A python script to generate git hooks to dump git version to a C header
import os
git_version_hook_lines = [
"#!/bin/sh\n",
"git_version_str=$(printf '#define GIT_VERSION_STRING \"%s\"' $(git rev-parse --short=16 HEAD))\n",
"echo $git_version_str\n",
"echo $git_version_str > ./git_version.h\n",
]
hooks_dir = os.path.join(os.getcwd(), '.git', 'hooks')
@standarddeviant
standarddeviant / WarCardSim.ipynb
Created December 30, 2018 03:55
Simulation of War, the card game
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.