Skip to content

Instantly share code, notes, and snippets.

View aladagemre's full-sized avatar

Emre Aladağ aladagemre

View GitHub Profile
@aladagemre
aladagemre / redis_export.py
Created October 30, 2024 11:15
Export Redis Data from Heroku
import json
import redis
client = redis.StrictRedis(
host='hostname',
port=6379,
db=0,
password='password',
ssl=True,
ssl_cert_reqs=None
)
# Export data from source postgresql database.
pg_dump --format=custom --no-owner --verbose --file=backup.dump "$SOURCE_URL"
# Restore the data to the target postgresql database.
pg_restore --clean --if-exists --no-owner --verbose --dbname="$TARGET_URL" backup.dump
@aladagemre
aladagemre / consumer.py
Last active April 21, 2025 14:22
NATS Jetstream pull consumer and publisher sample
"""Consumer Sample for NATS
It creates a "durable pull consumer" named "TEST_DURABLE".
The consumer only listens to the "TEST.pushed" subject.
It prints the json messages pushed to the "TEST.pushed" subject."""
import asyncio
import json
from nats.aio.client import Client as NATS
async def main():
nc = NATS()