Skip to content

Instantly share code, notes, and snippets.

View Attumm's full-sized avatar

Attumm

  • Amsterdam
View GitHub Profile
@Attumm
Attumm / readme.md
Created March 19, 2025 12:25
Improve linux for performance

CPU Cache Optimization

  • Set process affinity to prevent cache thrashing: taskset -c 0-3 jq ...
  • Align buffers to cache lines with compiler flags: -O3 -march=native -falign-functions=64
  • Compile jq from source with profile-guided optimization:
    ./configure --enable-lto
    make CFLAGS="-O3 -march=native -flto -fprofile-generate"
    # Run benchmarks
    

make clean && make CFLAGS="-O3 -march=native -flto -fprofile-use"

redis cluster

As projects scale, so does your infra. Redis dict is the right choice since the fundamental blocks of redis dict are get and set, which perfectly positions it to leverage the horizontal scalability of Redis Cluster. By distributing dictionary entries as independent key-value pairs across cluster nodes, RedisDict ensures optimal resource utilization and avoids performance bottlenecks as your data grows, making it the ideal dictionary solution for robust, large-scale applications built on Redis Cluster.

Redis Cluster achieves horizontal scalability through hash-based sharding, dividing the keyspace into slots and distributing these slots across multiple Redis nodes. When a RedisDict, built on GET and SET, is deployed within a cluster, each dictionary entry effectively becomes an independent Redis key. This is crucial because Redis Cluster's scaling mechanism operates at the key level. As RedisDict uses GET and SET to manage these individual keys, the cluster automaticall

@Attumm
Attumm / App.java
Last active February 19, 2025 21:13
Integer caching
public class App {
public static void main(String[] args) {
System.out.println("Demonstrating Integer Caching in Java");
System.out.println("-------------------------------------\n");
// Test lower bound (-128)
Integer lowerBound1 = -128;
Integer lowerBound2 = -128;
System.out.println("Lower Bound (-128): " + (lowerBound1 == lowerBound2));
// Test just below lower bound (-129)
@Attumm
Attumm / README.md
Last active February 18, 2025 18:58
Analyse Redis

Redis Performance Analysis and Monitoring Guide

Overview

This guide outlines steps to analyze Redis performance issues, particularly focusing on latency problems and ensuring data safety before restart procedures.

Analyzing Redis State

1. Memory Analysis

redis-cli INFO memory
@Attumm
Attumm / README.md
Created February 11, 2025 09:03
Sonar Qube Setup Docker

Local SonarQube Setup

Simple guide to run SonarQube locally and analyze your code.

Step 1: Set up SonarQube

Create a docker-compose.yml:

version: "3.8"
@Attumm
Attumm / main.py
Last active December 16, 2024 10:44
Redis-dict as cache for flask
from flask import Flask, jsonify
from redis_dict import RedisDict
from functools import wraps
import time
app = Flask(__name__)
# Initialize Redis dictionary for caching with default expiry of 5 minutes
cache = RedisDict(host='localhost', port=6379, db=0, namespace='mycache')
@Attumm
Attumm / Dockerfile
Created December 9, 2024 21:29
A weekend.
FROM --platform=linux/amd64 debian:bullseye-slim AS tts-builder
RUN apt-get update && \
apt-get install -y software-properties-common libttspico-utils libttspico0 libpopt0 && \
echo "deb http://deb.debian.org/debian bullseye contrib non-free" >> /etc/apt/sources.list && \
apt-get update && \
apt-get install -y libttspico-utils libttspico0 && \
mkdir -p /copy-root/usr/bin \
/copy-root/lib/x86_64-linux-gnu \
/copy-root/lib64 \
@Attumm
Attumm / keybase.md
Last active December 3, 2024 07:13
keybase.md

Keybase proof

I hereby claim:

  • I am attumm on github.
  • I am mbijman (https://keybase.io/mbijman) on keybase.
  • I have a public key ASBsrvanamXVuh5n_peawm1nhUZSlDFg_siNO2EP0zpXbwo

To claim this, I am signing this object:

export PATH="/usr/local/bin/python3:$PATH"
alias python=python3
def collector(until=float('inf')):
def decorator(func):
def wrapper(*args, **kwargs):
print(until)
print(kwargs.pop("until", None))
#until = kwargs.pop("until", None) or until
val = kwargs.pop("until", until)
for i in range(10):
if i >= val: