Skip to content

Instantly share code, notes, and snippets.

View dolphin2410's full-sized avatar
I Feel Amylase

dolphin2410 dolphin2410

I Feel Amylase
View GitHub Profile
from sklearn.linear_model import LinearRegression
import matplotlib.pyplot as plt
import numpy as np
data_time = [9.13E-02, 1.08E-01, 1.25E-01, 1.41E-01, 1.58E-01, 1.75E-01, 1.91E-01, 2.08E-01]
data_y = [1.50E-03, -4.40E-02, -9.14E-02, -1.44E-01, -2.00E-01, -2.63E-01, -3.24E-01, -3.92E-01]
regression = LinearRegression()
regression.fit(np.array(list(map(lambda x: [x**2, x], data_time))).reshape(-1, 2), np.array(data_y).reshape(-1, 1))
from sklearn.linear_model import LinearRegression
import matplotlib.pyplot as plt
import numpy as np
data_time = [1.08E-01, 1.25E-01, 1.41E-01, 1.58E-01, 1.75E-01, 1.91E-01]
data_velocity_y = [-2.78E+00, -3.00E+00, -3.27E+00, -3.56E+00, -3.71E+00, -3.88E+00]
regression = LinearRegression()
regression.fit(np.array(data_time).reshape(-1, 1), np.array(data_velocity_y).reshape(-1, 1))
@dolphin2410
dolphin2410 / wheel_control.ino
Created May 1, 2024 06:15
Wheel control using serial
#define LWheel 0
#define RWheel 1
// 0: not running, 1: only left is running, 2: only right is running, 3: both is running
int runningState = 0;
int priorRunningState = -1;
void setup() {
Serial.begin(9600);
@dolphin2410
dolphin2410 / rust-publish.yml
Created January 27, 2023 06:09
Replace 'mycrate' with your crate's name
on: [push]
name: Build
jobs:
build:
strategy:
matrix:
include:
- os: windows-latest
@dolphin2410
dolphin2410 / bluetooth-keyboard.ino
Created May 18, 2022 13:25
Arduino writes bluetooth input to the keyboard
#include <SoftwareSerial.h>
#include <Keyboard.h>
#define BLUETOOTH_RX 14 // Change this (RX)
#define BLUETOOTH_TX 16 // Change this (TX)
SoftwareSerial BTserial(BLUETOOTH_RX, BLUETOOTH_TX);
void setup() {
Serial.begin(9600);
print("Hello, World")
@dolphin2410
dolphin2410 / progress.py
Created July 14, 2021 13:54
Python CLI progressbar
class ProgressBar():
def __init__(self, size, finishedChar='#', unfinishedChar='-'):
self.size = size
self.finishedChar = finishedChar
self.unfinishedChar = unfinishedChar
def update(self, percent):
ratio_0 = math.floor(percent / (100 / self.size))
ratio_1 = self.size - ratio_0
sys.stdout.write("\r|" + self.finishedChar*ratio_0 + self.unfinishedChar*ratio_1 + "| " + str(math.floor(percent)) + "%")
import urllib.request
import os
urllib.request.urlretrieve("https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar", "./buildtool.jar")
os.system("java -jar buildtool.jar --rev latest --remapped")