Skip to content

Instantly share code, notes, and snippets.

View aladagemre's full-sized avatar

Emre Aladağ aladagemre

View GitHub Profile
@aladagemre
aladagemre / plog
Last active September 9, 2025 12:35
PLOG: JSON to Human Readable Format converter
#!/usr/bin/env python3
"""
* Save it as `/usr/local/bin/plog`
* `sudo chmod +x /usr/local/bin/plog`
and then in a new terminal:
`docker-compose logs -f <service> | plog`
you'll see your logs in humanized format.
"""
@aladagemre
aladagemre / bash
Created September 8, 2025 22:04
paket-kontrol.sh
#!/bin/bash
# Compromised NPM Packages Checker
# Bu script compromised npm paketlerini projelerinizde arar ve rapor oluşturur
# Compromised paketler listesi
COMPROMISED_PACKAGES=(
"ansi-styles"
"debug"
"backslash"
@aladagemre
aladagemre / pip2toml.py
Last active June 26, 2025 15:20
Converter: pip requirements to pyprojec.toml dependencies
"""
If you have a project with requirements/base.txt, requirements/local.txt, requirements/production.txt,
and you want to use uv for managing dependencies, this script will read all those deps from txt files
and adds to pyproject.toml so that you can install them with
uv sync --extra local
uv sync --extra production
"""
@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()
# 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 / 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
)
@aladagemre
aladagemre / n11cat.py
Created December 30, 2020 23:00
N11 kategori listesini çeken bir script
import bs4
import csv
import requests
r = requests.get("https://www.n11.com/site-haritasi")
soup = bs4.BeautifulSoup(r.text, features="html.parser")
with open("kategoriler.csv", "w") as csvfile:
writer = csv.writer(csvfile, delimiter=';', quotechar='"')
mcs = [(a.text, a.get('href')) for a in soup.find_all("a", class_="main-category")]
@aladagemre
aladagemre / polen_crawler.py
Created July 12, 2020 12:38
Madrid Polen Crawler
"""
This is a script for parsing polen levels in Madrid, Spain.
It used to work in 2019 but you may need to make fixes to make it work in the following years.
"""
import re
import locale
import time
import logging
import requests
package controllers
import (
"github.com/revel/revel"
"fmt"
"time"
"gopkg.in/mgo.v2/bson"
"net/url"
"github.com/ChimeraCoder/anaconda"
"strconv"
@aladagemre
aladagemre / pandas_dataframe_intersection.py
Created December 6, 2016 20:55
Check whether a pandas dataframe contains rows with a value that exists in another dataframe.
# We have dataframe A with column name
# We have dataframe B with column name
# I want to see rows in A with name Y such that there exists rows in B with name Y.
# It's like set intersection.
intersected = reduce(lambda x, y: x | (A['name'] == y), [False] + list(B['name']))
intersection = A[intersected]
# other alternatives
intersection = pd.merge(A, B, how='inner', on=['name'])
intersection.dropna(inplace=True)