Skip to content

Instantly share code, notes, and snippets.

View jmbr's full-sized avatar

Juan M. Bello-Rivas jmbr

View GitHub Profile
@jmbr
jmbr / python-interpreter.lisp
Created February 14, 2023 16:56
Python interpreter embedded in SBCL
(defpackage :python-interpreter
(:use :common-lisp :cffi)
(:export #:run-python))
(in-package :python-interpreter)
(define-foreign-library libpython (:unix "libpython3.10.so"))
(use-foreign-library libpython)
@jmbr
jmbr / embedding.py
Created November 3, 2022 22:16
Code for experiments on Bayesian optimization in dimensionally-reduced models
from abc import ABC, abstractmethod
from typing import Optional
import numpy as np
from diffusion_maps import diffusion_maps
from mapping import Mapping
class Embedding(ABC):
@jmbr
jmbr / evince.patch
Created September 19, 2022 18:52
Change default scrolling mode of Evince when changing pages.
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 1ffbf16..079cfd0 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -8616,7 +8616,7 @@ ev_view_change_page (EvView *view,
gint x, y;
view->current_page = new_page;
- view->pending_scroll = SCROLL_TO_PAGE_POSITION;
+ view->pending_scroll = SCROLL_TO_KEEP_POSITION;
@jmbr
jmbr / reparameterization.py
Last active May 14, 2022 04:40
Reparameterize a curve by its arc-length.
"""Numerically reparameterize a curve by its arc-length.
"""
from typing import Optional
import numpy as np
import scipy
import scipy.interpolate
@jmbr
jmbr / check-bibtex.sh
Created March 9, 2022 15:53
Find BibTeX entries that are not referenced from the TeX document files.
#!/bin/sh
if [ $# -ge 1 ]; then
bibtex_file=$1
else
bibtex_file="bibliography.bib"
fi
awk -F "[{,]" '/^@/ { print $2 }' $bibtex_file \
| while read reference; do
@jmbr
jmbr / mfpt.py
Created February 7, 2022 19:32
Example of how to compute mean first passage times by brute force in parallel.
from joblib import Parallel, delayed
import numpy as np
n = 10000 # Number of experiments
dt: float = 1e-5 # Time step length
def integrate_until_exit(random_seed):
np.random.seed(random_seed)
@jmbr
jmbr / plot-contact-map.awk
Created January 26, 2022 03:45
Plot contact map between aminoacids (alpha carbons) of a protein using AWK and gnuplot
#!/usr/bin/awk -f
BEGIN {
num_atoms = 0;
if (ARGC < 3) {
print "Usage: plot-contact-map.awk PDBFILE THRESHOLD" > "/dev/stderr";
error_exit = 1;
exit 1;
}
@jmbr
jmbr / plot-protein.awk
Created January 26, 2022 03:36
Protein (PDB) viewer written in AWK
#!/usr/bin/awk -f
BEGIN {
gnuplot = "gnuplot -p";
print "set terminal wxt noraise" | gnuplot;
print "set view equal xyz" | gnuplot;
print "set linetype 1 linecolor palette z linewidth 5" | gnuplot;
print "unset tics" | gnuplot;
print "unset border" | gnuplot;
@jmbr
jmbr / sample_small_rotations.py
Created October 30, 2021 01:08
Quick and dirty sampling of small rotation matrices
"""Quick and dirty sampling of small rotation matrices."""
import numpy as np
from scipy.linalg import expm
from scipy.spatial.transform import Rotation
n: int = 3 # Dimensions
epsilon: float = 1e-2 # Amplitude of the rotation
@jmbr
jmbr / holder.stl
Created August 23, 2021 05:51
Holder for needle-tip plastic bottles
//$fn = 90;
diameter = 30.5;
spacing = 2;
width = 4 * spacing + 3 * diameter;
depth = 2 * spacing + diameter;
height = 20 + spacing;
difference() {
scale([0.94, 0.85, 1])