Skip to content

Instantly share code, notes, and snippets.

@jailop
jailop / basicrag.py
Created September 30, 2025 11:34
A basic RAG system to explore PDF documents, supported by Ollama
# Basic RAG
#
# This script implements a basic Retrieval-Augmented Generation tool to
# query about the content of PDF documents. It is based on modules
# provided by LangChain and is supported by an Ollama server that should
# available to process the queries.
#
# To use this script:
#
# 1. Create a folder './docs' from the point the script will run
@jailop
jailop / example.py
Last active August 25, 2025 23:41
Least Squares Example
from typing import Optional
import numpy as np
from scipy import stats
import pandas as pd
class LeastSquares:
alpha: float
coefficients: np.ndarray
residuals: np.ndarray
@jailop
jailop / priorcircqueue.zig
Last active March 23, 2025 01:53
Priority Circular Queue
/// A Priority Circular Queue Implementation
///
/// (c) 2025, Jaime Lopez <https://github.com/jailop>
const std = @import("std");
pub const QueueError = error {
Full,
Empty,
};
@jailop
jailop / cronbachalpha.py
Last active March 16, 2025 13:20
Cronbach's Alpha Calculation
import numpy as np
# Rows are respondents
# Columns are survey items
data = np.array([
[4.0, 4.0, 4.0, 5.0],
[3.0, 4.0, 3.0, 4.0],
[5.0, 4.0, 5.0, 5.0],
[2.0, 3.0, 2.0, 3.0],
[4.0, 4.0, 4.0, 4.0],
@jailop
jailop / cronbachalpha.rs
Created March 15, 2025 22:30
Cronbach's Alpha Calculation
/**
* In a survey questionnaire, a set of items can be included
* referred to the same construct or concept. Therefore,
* it is expected that responses for those items are similar
* or highly correlated. To measure that, the Cronbach’s
* Alpha is frequently used. It estimates the reliability
* or the internal consistency for a set of survey items.
*/
/**
@jailop
jailop / flac2mp3dir.sh
Created October 24, 2024 16:14
Convert flac to mp3 for all files contained in the same directory
#!/bin/sh
for i in *flac; do
ffmpeg -i "$i" -ab 320k -map_metadata 0 -id3v2_version 3 "${i%.*}.mp3"
done
@jailop
jailop / sieve-eratosthenes.zig
Last active December 27, 2023 20:52
Sieve of Eratosthenes Prime Number Generator - Implementation in Zig
/// Sieve of Eratosthenes Algorithm
/// Finding prime numbers less or equal than n
/// Implementation in Zig
/// Reference:
/// https://brilliant.org/wiki/sieve-of-eratosthenes/
/// (2023) Jaime Lopez
const std = @import("std");
/// Function implementing
/// Sieve of Eratosthenes Algorithm
#!/bin/sh
#
# This script converts pictures stored in CR2 format
# to jpg using the utility 'convert'.
#
# To use this script, make a copy of it in the
# corresponding folder and next, from de command line run:
#
# $ sh convert.sh
#
@jailop
jailop / gini.cpp
Last active July 11, 2020 11:25
Gini Index is used to measure discrimanatory power of qualitative features in a dataset, as part of classification algorithms
/*
* Gini Index implementation
*
* Gini Index is used to measure discrimanatory power of qualitative features in
* a dataset, as part of classification algorithms
*
* (2019) Jaime Lopez <jailop AT protonmail DOT com>
*/
#include <iostream>
@jailop
jailop / stress.c
Last active November 27, 2018 02:48
/* stress.c
*
* El propósito de este programa es causarle 'stress' al procesador.
* Es decir, obligarlo a trabajar en niveles próximos al 100%.
* Además, si el procesador es de varios núcleos, también se puede forzar
* a que los ocupe todos (o solo algunos de ellos).
*
* This program's aim is to cause streess to CPU,
* i.e. making it to work nearly 100% of load.
* If CPU is multicore, this program can force all of them to work.