Skip to content

Instantly share code, notes, and snippets.

View mh-firouzjah's full-sized avatar
🐗
Valar Codilis: all men must code

Mahdi Firouzjah mh-firouzjah

🐗
Valar Codilis: all men must code
View GitHub Profile
@mh-firouzjah
mh-firouzjah / subtitle_encoder.md
Last active May 30, 2021 06:55
convert subtitle(.srt) files encoding form `windows 1256(arbic)` to `utf-8`.

Subtitle Decoder/Encoder

Subtitles are often not displayed properly on players due to incorrect encoding/decoding.

this python script is able to recive a path to subtitle/*.str files and change encoding form arabic/windows-1256 to utf-8.

'''
convert all subtile (*.srt) files inside given directory
from encoding `windows 1256` to `utf-8`
'''
@mh-firouzjah
mh-firouzjah / Django-login-required-middleware.md
Last active September 23, 2024 09:20
Django Login Required Middleware

Django Login Required Middleware

if you need users to be loged in first, before visiting your website, so it's easier to use a middleware to check if they're loged in or not. inorder to have such a middleware, use the following code:

# middleware.py
import re

from django.conf import settings
from django.contrib.auth.middleware import AuthenticationMiddleware
@mh-firouzjah
mh-firouzjah / merge-video-and-sound.py
Created February 16, 2021 10:12
python-ffmpeg merging video and sound files
# I had mistakenly downloaded some video fiels without sound so then after I had to download the sound files related but
# how could I merge them to finally have a single file? following code would this!
# !attention this file has to be inside the directory where the video and sound exists -
# and the result would be in a sub-directory named `output`
import os
from os import listdir
from os.path import isfile, join