Skip to content

Instantly share code, notes, and snippets.

View Joel-hanson's full-sized avatar
:octocat:
Looking for opportunities

Joel Hanson Joel-hanson

:octocat:
Looking for opportunities
View GitHub Profile
@Joel-hanson
Joel-hanson / Kafka 4 noticable changes
Last active November 4, 2025 17:19
This is the kafka 4 changes from docs
1.5 Upgrading From Previous Versions
Upgrading to 4.1.0
Upgrading Servers to 4.1.0 from any version 3.3.x through 4.0.x
Notable changes in 4.1.0
Apache Kafka 4.1 ships with a preview of Queues for Kafka (KIP-932). This feature introduces a new kind of group called share groups, as an alternative to consumer groups. Consumers in a share group cooperatively consume records from topics, without assigning each partition to just one consumer. Share groups also introduce per-record acknowledgement and counting of delivery attempts. Use share groups in cases where records are processed one at a time, rather than as part of an ordered stream. To enable share groups, use the kafka-features.sh tool to upgrade to share.version=1. For more information, please read the release notes.
Common
The logger class name for LogCleaner has been updated from kafka.log.LogCleaner to org.apache.kafka.storage.internals.log.LogCleaner in the log4j2.yaml configuration file. Added loggers for org.apache.kafka.storage.internals.log.LogCle
@Joel-hanson
Joel-hanson / convert-np-image-to-ascii.py
Created October 2, 2024 16:56
Create an ASCII representation of the image. The following is a function that converts a numpy array (representing an image) into an ASCII art representation.
def image_to_ascii(img, width=100, height=50):
# Convert to numpy array if it's not already
if not isinstance(img, np.ndarray):
img = np.array(img)
# Ensure the image is in the correct format (H, W, C)
if img.ndim == 3 and img.shape[0] == 3:
img = np.transpose(img, (1, 2, 0))
# Normalize the image if it's not in [0, 1] range

title: "Supercharging Your AI: Setting Up RAG with PostgreSQL and pgvector" date: 2024-09-30T21:28:28+05:30 draft: false ShowToc: true TocOpen: false summary: "Learn how to implement a powerful Retrieval-Augmented Generation (RAG) system using PostgreSQL and pgvector. This comprehensive guide covers everything from setting up a custom PostgreSQL Docker image to creating a fully functional RAG query system with vector embeddings and language model inference." tags: ["PostgreSql", "PGVector", "RAG", "Vector Database", "AI", "NLP", "Docker", "GPT", "LLM"] categories: ["Database", "Artificial Intelligence", "Tutorial"] cover:

{
"title": "Supercharging Your AI: Setting Up RAG with PostgreSQL and pgvector",
"content": "## Introduction\n\nImagine having a conversation with an AI that not only understands your questions but also draws upon a vast repository of knowledge to provide accurate, contextually relevant answers. This isn't science fiction—it's the power of Retrieval-Augmented Generation (RAG) systems. In this blog post, we'll dive into the exciting world of RAG and show you how to harness this technology using PostgreSQL and pgvector.\n\n## What is RAG, and Why Should You Care?\n\nRAG is like giving your AI a photographic memory and the ability to instantly recall relevant information. It combines the power of large language models with a knowledge base, allowing the AI to provide more accurate, up-to-date, and contextually relevant responses. Whether you're building a chatbot, a question-answering system, or any AI application that requires access to specific knowledge, RAG is your secret weapon.\n\n## Prerequisites\n\nB
import argparse
import json
import re
import sys
from datetime import datetime
import frontmatter
def convert_markdown_to_medium(input_file, output_file):
@Joel-hanson
Joel-hanson / Git-alias.md
Created June 22, 2024 02:59
Git aliases are a powerful workflow tool that create shortcuts to frequently used Git commands.

title: "Git Aliases to Supercharge Your Workflow" date: 2024-03-21 draft: false ShowToc: true TocOpen: false math: true summary: "Git aliases are a powerful workflow tool that create shortcuts to frequently used Git commands." tags: [ "git", "version-control", "workflow", "development", "productivity", "command-line", "aliases", "git-commands", "git-aliases", "coding",

1. Get details about this Connect worker and the id of the Kafka cluster it is connected to

curl -X GET "http://localhost:8083/" -H "accept: application/json"

2. List the current loggers and their log levels

curl -X GET "http://localhost:8083/admin/loggers" -H "accept: application/json"
@Joel-hanson
Joel-hanson / videospliting.py
Created July 11, 2021 06:41
Video spliting problem
"""
- based no splits 1000 splits
- based on time eg 10s
- based on time interval 2:10 -> 2:50
- 10 people upload 1 gb 2 file daily
- we have design a system to split it into 1000 partitions
Solution:
@Joel-hanson
Joel-hanson / fib.py
Last active April 10, 2021 17:36
Find nth Fibonacci number using recursion.
def fibonacci(n):
if n <= 2:
return 1
return fibonacci(n - 1) + fibonacci(n - 2)
@Joel-hanson
Joel-hanson / urls.py
Created July 31, 2020 10:40
The urls for django rest framework
from django.urls import path, include
from rest_framework import routers
from .views import UploadViewSet
router = routers.DefaultRouter()
router.register(r'upload', UploadViewSet, basename="upload")
# Wire up our API using automatic URL routing.
urlpatterns = [
path('', include(router.urls)),