Skip to content

Instantly share code, notes, and snippets.

View aghriss's full-sized avatar

Ayoub Ghriss aghriss

View GitHub Profile
@aghriss
aghriss / excluded_sampling.py
Created March 22, 2024 15:50
A numpy-numba function optimized for sampling unique indices per row exluding provided indices
# Ayoub Ghriss, 2024
@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:
n (int): Number of samples.
@aghriss
aghriss / 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
@aghriss
aghriss / 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)
@aghriss
aghriss / 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
@aghriss
aghriss / PKGBUILD
Last active April 30, 2019 18:12
AUR - Openfst for python3.7 on Arch Linux
# Maintainer: Ayoub Ghriss <aghriss@yandex.com>
# 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'
@aghriss
aghriss / 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
@aghriss
aghriss / 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/