Skip to content

Instantly share code, notes, and snippets.

View ayghri's full-sized avatar

Ayoub Ghriss ayghri

View GitHub Profile
@ayghri
ayghri / build_nvim.sh
Last active March 12, 2025 03:24
Build Neovim (0.10.x) on Debian 12 (Bookworm)
# build neovim debian package with bundled dependencies
# I needed this for Raspberry Pi OS since bookworm default neovim is at 0.7.x currently
sudo apt install gperf luajit luarocks libuv1-dev libluajit-5.1-dev libunibilium-dev libmsgpack-dev libtermkey-dev libvterm-dev libutf8proc-dev ninja-build gettext cmake unzip curl build-essential
git clone https://github.com/neovim/neovim
# working from root dir
cd neovim
cmake -S cmake.deps -B .deps -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build .deps
cmake -B build -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build
<domain type="kvm">
<name>Win11Nvidia</name>
<uuid>06989f60-f8e7-4b9a-912e-63c45f47f772</uuid>
<title>Win11Nvidia</title>
<description>Windows 11</description>
<memory unit="KiB">16777216</memory>
<currentMemory unit="KiB">16777216</currentMemory>
<vcpu placement="static">10</vcpu>
<cputune>
<vcpupin vcpu="0" cpuset="0"/>
@ayghri
ayghri / excluded_sampling.py
Last active March 8, 2025 23:09
A numpy-numba function optimized for sampling unique indices per row exluding provided indices
# Ayoub Ghriss, 2024
import numpy as np
from numba import njit, prange, int64, int32
@njit(int64[:, :](int64, int64, int64[:, :]), parallel=True, cache=True, nogil=True)
def sample_excluded_parallel(n: int, k: int, to_exclude: np.ndarray) -> np.ndarray:
"""
Generate random integers in parallel excluding specified values.
Parameters:
@ayghri
ayghri / path.lua
Last active August 7, 2023 12:55
Path reduction algorithms for IDE
local M = {}
-- Map intergers 1... to A....
local function int_to_char(i) return string.char(i + 64) end
local function group_by_first(b_to_s)
local starts = {}
for b, s in pairs(b_to_s) do
if #s == 0 then
error("empty string in hash_by_first" .. vim.inspect(b_to_s))
end
@ayghri
ayghri / ltex.lua
Last active July 20, 2023 15:52 — forked from lbiaggi/ltex.lua
lspconfig - Implement addToDictionary for ltex
local S = {}
-- define the files for each language
-- new words will be added to the last file in the language table
S.dictionaries = {
["en-US"] = { vim.fn.stdpath("config") .. "/spell/en.txt" },
}
-- function to avoid interacting with the table directly
function S.getDictFiles(lang)
@ayghri
ayghri / install_nbgrader.sh
Created January 31, 2023 18:44
Install nbgrader in Python venv
python3 -m venv my_test_env
source my_test_env/bin/activate
pip install jupyter
pip install nbgrader
jupyter nbextension install --sys-prefix --py nbgrader --overwrite
jupyter nbextension enable --sys-prefix --py nbgrader
jupyter serverextension enable --sys-prefix --py nbgrader
@ayghri
ayghri / PKGBUILD
Last active April 30, 2019 18:12
AUR - Openfst for python3.7 on Arch Linux
# Maintainer: Ayoub Ghriss <[email protected]>
# Save file in folder as PKGBUILD and run "makepkg -si" in the same folder
# Works for Python3.7 on Arch, for other versions, change the Vim replacement line to corresponding folders
pkgname=openfst
pkgver=1.7.2
pkgrel=1
pkgdesc='Library for constructing, combining, optimizing, and searching weighted finite-state transducers (FSTs)'
arch=(i686 x86_64)
url='http://www.openfst.org'
@ayghri
ayghri / update_cmake.sh
Created June 22, 2018 03:09
Update CMake Ubuntu 16.04
sudo apt purge cmake -y
wget https://cmake.org/files/v3.11/cmake-3.11.3-Linux-x86_64.tar.gz -O cmake.tar.gz
tar -xvf cmake.tar.gz -C ./
cd cmake-3.11.3-Linux-x86_64
sudo cp -r bin /usr/
sudo cp -r share /usr/
sudo cp -r doc /usr/share/
sudo cp -r man /usr/share/
cd ..
rm -rf cmake
@ayghri
ayghri / openfst_py3.sh
Last active April 30, 2019 18:13
openfst with python3 extension for Ubuntu 16.04
# Ubuntu packages
VERSION=1.6.7
sudo apt update
sudo apt install -y vim build-essential python3 python3-dev vim
# Compile OpenFST with Python extension for Python 3 and Install
wget http://www.openfst.org/twiki/pub/FST/FstDownload/openfst-$VERSION.tar.gz
tar xzvf openfst-$VERSION.tar.gz
cd openfst-$VERSION/