Skip to content

Instantly share code, notes, and snippets.

@dagrha
dagrha / 2-mark_all_ebooks_as_favorite.lua
Created February 3, 2024 21:10
KOReader User Patch to add all ebooks found on device to the Favorites collection
-- KOReader user patch to add all ebooks found on device to the Favorites collection
function find_files(directory, file_extensions)
local result = {}
-- Helper function to recursively search for files
local function search_files(dir)
for file in io.popen('ls -1 "' .. dir .. '"'):lines() do
local path = dir .. '/' .. file
local file_extension = file:match("^.+(%..+)$")
@dagrha
dagrha / simple_linear_regression.py
Created November 8, 2020 22:53
Put in a dictionary r2, equation, and series to plot from simple linear regression for easy use with matplotlib
# © 2020 dagrha. GPLv3.0
def linear_regression(df, x_col, y_col):
from sklearn.linear_model import LinearRegression
from sklearn.metrics import r2_score
x = df[(df[x_col].notnull()) &(df[y_col].notnull())][x_col].values.reshape(-1, 1)
y = df[(df[x_col].notnull()) &(df[y_col].notnull())][y_col].values.reshape(-1, 1)