Skip to content

Instantly share code, notes, and snippets.

View constructor-s's full-sized avatar

Bill constructor-s

View GitHub Profile
@constructor-s
constructor-s / temp.py
Created August 22, 2017 15:12
Tracker
import endo_transform
import numpy as np
data = np.loadtxt(r'N:\GTx\ToBill\20170822_NUDGE_TEST\Nudge Test - Sheet1.csv', skiprows=2, delimiter=',')
tracker1 = data[:, (1, 2, 3, 5, 6, 7, 8)]
tracker2 = data[:, np.array((1, 2, 3, 5, 6, 7, 8)) + 8]
for i, (t1, t2) in enumerate(zip(tracker1, tracker2)):
@constructor-s
constructor-s / cout_speed_test.cpp
Created January 13, 2018 01:22
cout_speed_test.cpp
#include <iostream>
#include <chrono>
using namespace std;
using namespace std::chrono;
int main()
{
const int N = 100000;
% pts1 = [-97.7589, 107.423, 424;
% 92.029, 110.208, 432;
% 73.7443, 20.5885, 427;
% -75.4565, 17.4702, 424;
% 13.7856, 64.4569, 425];
%
% pts2 = [-37.0552, -124.662, -411.111;
% -28.2589, 87.5111, -421.536;
% -123.679, 63.8717, -417.216;
% -132.088, -101.241, -408.636;
@constructor-s
constructor-s / polyarea.py
Created March 6, 2019 02:34
Calculate area in polygon
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 5 20:17:08 2019
@author: bill
"""
import matplotlib.pyplot as plt
import numpy as np
% M up N down
% stays the same unless
% all previous M trials are 0 -> stop up, go down
% all previous N trials are 1 -> stop down, go up
m = 1
n = 1
d = 5
num = 1e7
phi = @(x) atan(1*x)/pi + 0.5
@constructor-s
constructor-s / static_qt_windows.md
Created July 3, 2020 03:14
How to use static Qt (5.12.8) on Windows 10 (qt5:x64-windows-static)

Compile static Qt

Use vcpkg with the following command:

vcpkg install qt5:x64-windows-static

Configure compiler

@constructor-s
constructor-s / bayesian_regression.ipynb
Created August 27, 2020 00:18
Bayesian Linear Regression
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@constructor-s
constructor-s / pi_video_cam.py
Created July 18, 2020 04:14
Raspberry Pi continous camera recording with built-in picamera and frame timestamp in Python (very low CPU usage)
import picamera
from picamera import PiCamera
import time
import signal
import sys
import threading
from datetime import datetime
CAMERA_WAIT_SEC = 1
CAMERA_ROTATE_SEC = 1800
@constructor-s
constructor-s / float_bits.py
Created October 17, 2020 19:56
See the representation of a floating point in Python
import struct
num = 0.5
bits = [[c>>i & 1 for i in range(7, -1, -1)] for c in struct.pack("!d", num)]
bits_flatten = [i for l in bits for i in l]
bits_sign = bits_flatten[0]
bits_exponent = bits_flatten[1:12]
bits_fraction = bits_flatten[12:64]
@constructor-s
constructor-s / linear_regression_p_value.ipynb
Last active February 17, 2021 03:56
Linear_Regression_P_Value.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.