Skip to content

Instantly share code, notes, and snippets.

View hkboujrida's full-sized avatar

Haithem BOUJRIDA hkboujrida

View GitHub Profile
docker run -it \
--name pytorch \
--network=host \
--cap-add=SYS_PTRACE \
--security-opt seccomp=unconfined \
--device=/dev/kfd \
--device=/dev/dri \
--group-add video \
--ipc=host \
--shm-size 8G \
@hkboujrida
hkboujrida / cidr
Last active March 1, 2024 13:08
cidr
output_address_cidr = "${join(".", [split(".", local.base_address)[0], split(".", local.base_address)[1], split(".", local.base_address)[2], split(".", split("/", local.other_address_cidr)[0])[3]])}/${split("/", local.other_address_cidr)[1]}"
# terraformer import azure -R edgeprime-oss -r subnet
# terraform plan -out=tfplan
# terraform show -json tfplan > plan.json
# bash script to automatically import state to terraform
#!/bin/bash
# get all the ressources id and name from the state file
file="imported.tfstate"
# jq '.modules[].resources | .[] | {type: .type, id: .primary.id, name: .primary.attributes.name}' "$file"
# put the ressources id and name, and type with jq into the variable ressources
existing_ressources=$(jq '[.modules[].resources | .[] | { type: .type, name: .primary.attributes.name, id: .primary.id}]' imported.tfstate)
provider "azurerm" {
features {}
}
data "azurerm_container_registry" "acr" {
name = var.registry_name
resource_group_name = var.resource_group_name
}
resource "azurerm_container_registry_task" "daily_purge_prod_images" {
@hkboujrida
hkboujrida / script
Last active December 22, 2023 10:49
pipelines
trigger:
- main
parameters:
- name: chartName
displayName: 'Select Helm Chart'
type: string
default: 'chart1'
values:
- chart1
@hkboujrida
hkboujrida / custom-wsl-ubuntu-install.md
Last active March 31, 2024 17:55
custom wsl ubuntu install

Custom install ubuntu wsl2

Benefits:

  • no need to install ubuntu from the store
  • choose the version you want
  • choose the name you want
  • choose the location you want
  • install multiple versions of ubuntu

Install Ubuntu the classic way

@hkboujrida
hkboujrida / build_kernel_wsl2.sh
Created August 8, 2023 17:33
build wsl2 kernel
#!/bin/bash
WSL_COMMIT_REF=linux-msft-wsl-5.15.90.4
apt update && apt install -y git build-essential flex bison libssl-dev libelf-dev bc dwarves
mkdir src
cd src
git init
git remote add origin https://github.com/microsoft/WSL2-Linux-Kernel.git
git config --local gc.auto 0
git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +${WSL_COMMIT_REF}:refs/remotes/origin/build/linux-msft-wsl-5.15.y
@hkboujrida
hkboujrida / setup.sh
Last active September 20, 2023 10:11
#!/bin/bash
sudo apt update && sudo apt upgrade -y
sudo apt install zsh git curl wget build-essential fzf -y
export NONINTERACTIVE=1
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
(echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> /home/dotexec/.profile
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
brew install gcc
#!/bin/bash
# example : refresh_ftp_users.sh -t ftp
# This script is used to refresh the ftp users
# it reads the users in the "ftpusers group"
# and creates the users in the ftpusers file
# read ftp type variable form the command line with -t or --type
# if no variable is passed then set it to "ftp"
# set USERS variable from the ftpusers group
# if type equals ftps then FTP_USERFILE is /etc/vsftpd-ftps.userlist else /etc/vsftpd-ftp.userlist
# Set vi key bindings mode
set -g mode-keys vi
set -g status-keys vi
# Set new panes to open in current directory
bind c new-window -c "#{pane_current_path}"
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"