Skip to content

Instantly share code, notes, and snippets.

View jlmelville's full-sized avatar

James Melville jlmelville

View GitHub Profile

June 28 2023 O frabjous day! After much fruitless occasional faffing around with cmake settings over the course of several months, new CUDA update for WSL Ubuntu means that I am now able to build the nearest neighbors library Faiss with GPU support for my 1080 laptop graphics card. Here is the setup that worked for me.

Why would you want to build your own Faiss? Well, if you are using pip to install faiss-gpu, you can't get anything more recent than version 1.7.2. Also, with recent dependency management changes with newer Pythons (particularly Python 3.11), some packages are going to be playing catch-up with getting up to parity, so it may be useful to build from source. I don't remember how bad it was trying to install faiss-gpu on Python 3.11 with pip, but it must have been fairly un-fun, because I gave up and scuttled back to the relatively welcoming environs of Python 3.10 pretty quickly after briefly dipping my

jlmelville /
Last active December 13, 2023 08:09
Setting up Python linting with VS Code

I set up my linters for use with VS Code, so I only use the linting tools that can be integrated into the Problems tab, but these can be used from the command line. I have attempted to avoid having different tools give duplicate warnings, but this is a work in progress. The VS code settings.json is at

Create a linting-requirements.txt file:

# this also installs pylint and pycodestyle
jlmelville / build.gradle
Created October 27, 2015 17:17
Workaround for gradle application plugin 'the input line is too long' error on Windows
tasks.withType(CreateStartScripts).each { task ->
task.doLast {
String text = task.windowsScript.text
text = text.replaceFirst(/(set CLASSPATH=%APP_HOME%\\lib\\).*/, { "${it[1]}*" })
task.windowsScript.write text
jlmelville / settings.json
Last active October 11, 2023 00:58
VS Code settings for Linux
"[html]": {
"editor.insertSpaces": true,
"editor.tabSize": 2
"[markdown]": {
"editor.rulers": [
"editor.tabSize": 2
jlmelville /
Last active September 28, 2023 14:54
fetching and merging forks
# Basic .gitconfig stuff
    editor = vim
    rebase = false
# Enforce SSH
[url "ssh://"]
  insteadOf =
jlmelville / isomap_data.R
Last active September 12, 2022 23:56
Reading Isomap data into R
### Swiss Roll
# Install the R.matlab package:
# install.packages("R.matlab")
# downloads and reads Swiss Roll data
# returns a list:
# a 3 x 20000 matrix of the column-stored X, Y, Z data
# a 2 x 20000 matrix of what I assume is the unrolled data coordinates
read_isoswiss <- function(url = "") {
jlmelville /
Last active September 5, 2022 17:28
Fixing the legacy gpg keyring warning when installing CUDA on Ubuntu for WSL2

Ubuntu, CUDA, WSL2 and legacy keyrings

In the Ubuntu tutorial on enabling CUDA with WSL2, and specifically in part 3, you are directed to use apt-key to point Ubuntu at the correct toolkit package. On Ubuntu 22.04 this will lead to the following warning whenever you run apt-get update:

 Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
jlmelville / kabsch.R
Last active January 6, 2022 20:32
The Kabsch algorithm in R for aligning one point set over another
#' Kabsch Algorithm
#' Aligns two sets of points via rotations and translations.
#' Given two sets of points, with one specified as the reference set,
#' the other set will be rotated so that the RMSD between the two is minimized.
#' The format of the matrix is that there should be one row for each of
#' n observations, and the number of columns, d, specifies the dimensionality
#' of the points. The point sets must be of equal size and with the same
#' ordering, i.e. point one of the second matrix is mapped to point one of
jlmelville /
Last active December 24, 2021 20:19
20 newsgroups python/R
jlmelville / transitive_dependencies.R
Created November 30, 2021 16:39
transitive dependencies in R
# modified slightly from
distrib.pkgs <- library(lib.loc=R.home("library"))$results[,1]
dependencies <-
function(pkg, dependencies = c("Depends", "Imports", "LinkingTo"),
pl = installed.packages())
if (!(pkg %in% rownames(pl))) stop("unknown pkg ", pkg)
fields <- pl[pkg, dependencies]