Skip to content

Instantly share code, notes, and snippets.

View afrendeiro's full-sized avatar

André F. Rendeiro afrendeiro

View GitHub Profile
@afrendeiro
afrendeiro / kde_2d_weighted.py
Last active April 2, 2026 22:15
2D weighted kernel density estimation (KDE)
import numpy as np
import matplotlib.pyplot as plt
# class from here: http://nbviewer.ipython.org/gist/tillahoffmann/f844bce2ec264c1c8cb5
class gaussian_kde(object):
"""Representation of a kernel-density estimate using Gaussian kernels.
Kernel density estimation is a way to estimate the probability density
function (PDF) of a random variable in a non-parametric way.
@afrendeiro
afrendeiro / flac+cue2mp3.sh
Created September 15, 2013 10:39
Command-line conversion of flac+cue files to mp3 split tracks
#!/bin/sh
# Flacon-style convert to mp3 and split tracks from flac+cue files
# Made by André Rendeiro (afrendeiro@gmail.com)
# Rename
{
find . -name '* *' | while read file; do target=`echo "$file" | sed 's/ /_/g'`; mv "$file" "$target"; done
find . -name '* *' | while read file; do target=`echo "$file" | sed 's/ /_/g'`; mv "$file" "$target"; done
find . -name '* *' | while read file; do target=`echo "$file" | sed 's/ /_/g'`; mv "$file" "$target"; done
@afrendeiro
afrendeiro / spatial_classifier_demo.py
Last active September 9, 2025 18:47
A quick demo of cell type classification from graphs
#!/usr/bin/env uv --script
# /// script
# dependencies = [
# "numpy",
# "squidpy>=1.6.5",
# "scikit-network",
# ]
# python_version = ">=3.12"
# ///
@afrendeiro
afrendeiro / convert_to_pptx.sh
Created June 25, 2025 15:29
Guaranteed flawless odp to pptx convertion
#!/bin/bash
set -e
INPUT="$1"
EXT="${INPUT##*.}"
BASENAME=$(basename "$INPUT" ."$EXT")
INPUT_DIR=$(dirname "$(realpath "$INPUT")")
TMPDIR=$(mktemp -d)
@afrendeiro
afrendeiro / series_matrix2csv.py
Created December 10, 2020 16:49
Get a GEO series matrix file describing an experiment and parse it into project level and sample level data.
#!/usr/bin/env python
"""
Get a GEO series matrix file describing an experiment and
parse it into project level and sample level data.
"""
import os
from typing import Tuple, Union
import tempfile
@afrendeiro
afrendeiro / modeling_compositional_data.py
Last active February 19, 2025 08:23
Testing out ILR transformation and compositional data testing
# /// script
# dependencies = [
# "numpy",
# "pandas",
# "statsmodels",
# "scikit-learn",
# "scikit-bio",
# "matplotlib",
# ]
# ///
@afrendeiro
afrendeiro / ubuntu_fresh_install.sh
Last active November 24, 2024 21:24
Software install from fresh Ubuntu 14.04 LTS image on AWS EC2
# New users
sudo adduser username
# Grant the new user sudo privileges
sudo visudo
# username ALL=(ALL:ALL) ALL
# add this line ^^
# change to that user
su - username
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#! python3.7
import argparse
import os
import numpy as np
import speech_recognition as sr
import whisper
import torch
from datetime import datetime, timedelta