Skip to content

Instantly share code, notes, and snippets.

View Samk13's full-sized avatar
πŸ€
Busy coding...

Sam Arbid Samk13

πŸ€
Busy coding...
View GitHub Profile
@Samk13
Samk13 / utils.py
Last active February 12, 2024 00:50
# https://github.com/inveniosoftware/invenio-communities/pull/1086/files#diff-6c07ffce9d2dd97c912da89fd4869787bdb49626a3fa278d466117cc8e489941
# Simplifying the function
def filter_dict_keys(src, keys):
"""Filter a dictionary based on a list of key paths."""
# Split the keys into top-level and nested keys
top_level_keys = [key for key in keys if "." not in key]
nested_keys = [key for key in keys if "." in key]
@Samk13
Samk13 / Keycloak-docker-compose.yaml
Created February 3, 2024 14:50
Keycloak docker-compose setup
# https://www.youtube.com/watch?v=6ye4lP9EA2Y
version: '3'
services:
postgresql:
image: postgres:16
environment:
- POSTGRES_USER=keycloak
- POSTGRES_DB=keycloak
- POSTGRES_PASSWORD=SUPERsecret
volumes:
@Samk13
Samk13 / docker-compose.md
Last active December 1, 2023 23:54
docker compose commands

full video

Quick way to see if you did something wrong:

# list your docker compose
docker compose config

# list all images used
docker compose config --images 
@Samk13
Samk13 / PowerShell.ps
Last active November 24, 2023 23:39
PowerShell commands
# Get motherboard model
Get-WmiObject win32_baseboard | Select-Object -Property Product
# Get the maximun capacity of the MB RAM in GB
Get-WmiObject -Class Win32_PhysicalMemoryArray | Select-Object -Property @{Name="MaxCapacityGB";Expression={$_.MaxCapacity / 1MB}}
# Get the current RAM installed
Get-WmiObject -Class Win32_PhysicalMemory | Measure-Object -Property Capacity -Sum | Select-Object @{Name="TotalGB"; Expression={ $_.Sum / 1GB }}
# Get list of connected storage devices
from langchain.chat_models import ChatOpenAI
from langchain.prompts import ChatPromptTemplate
from langchain.schema.output_parser import StrOutputParser
import requests
from bs4 import BeautifulSoup
from langchain.schema.runnable import RunnablePassthrough, RunnableLambda
from langchain.utilities import DuckDuckGoSearchAPIWrapper
import json
RESULTS_PER_QUESTION = 3
@Samk13
Samk13 / certs.md
Last active September 14, 2023 21:09
Generating SSL Certificates

Generating SSL Certificates for OpenSearch in InvenioRDM

Overview

This document outlines the steps to generate SSL certificates required for OpenSearch in an InvenioRDM project.

Required Certificates

Three certificates are generally required:

@Samk13
Samk13 / Git.md
Last active September 5, 2023 20:28

Git related shit ...

Mark a specific point in the codebase as a release version

git commit --allow-empty -m "release: v1.00.0"
git tag v1.00.0
git push origin v1.00.0
@Samk13
Samk13 / apply_patch.md
Last active August 28, 2023 10:02
How to apply a patch for a python package

Working:

Download the patch:

curl 

Didn't work as expected

Instructions to apply a specific PR to a package (invenio-rdm-records as example)

@Samk13
Samk13 / Windows folder Permissions Cleanup.md
Last active August 2, 2023 22:27
Windows folder Permissions Cleanup

Context:

After a Windows reset, certain folders may retain permissions from non-existing accounts, leading to "Permission denied" errors. This Gist provides commands to take ownership, grant full permissions, and remove a specific folder on drive to resolve the issue.

# Take ownership and grant full permissions
takeown /F D:\Foldername p /R /A
icacls D:\Foldername /grant "YourUserName":(F) /T

# Remove the folder and its contents

Invenio setup on Ubuntu

Install pyenv

sudo apt-get update; sudo apt-get install --no-install-recommends make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev checkinstall libncursesw5-dev libgdbm-dev libc6-dev
curl https://pyenv.run | bash # https://github.com/pyenv/pyenv#automatic-installer