Skip to content

Instantly share code, notes, and snippets.

View delimitry's full-sized avatar
:octocat:

Dmitry Alimov delimitry

:octocat:
View GitHub Profile
@delimitry
delimitry / get_python_versions_magics.py
Last active January 7, 2022 21:38
A script to get the current list of CPython version's magic numbers from CPython repository
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
A script to get the current list of CPython version's magic numbers from CPython repository.
It is parses "/Lib/importlib/_bootstrap_external.py" source file to get this list.
And this is a helper for my script: https://gist.github.com/delimitry/bad5496b52161449f6de,
which allows to get the version of Python by which the file was compiled
"""
@delimitry
delimitry / m3u8_decryptor.py
Created December 8, 2016 10:00
Python script for download and decrypt TS chunks from m3u8 file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import re
import requests
import sys
from Crypto.Cipher import AES
@delimitry
delimitry / spritesheet_cutter.py
Last active November 2, 2015 07:29
Spritesheet image cutter
#!/usr/bin/env python
#-*- coding: utf-8 -*-
#-----------------------------------------------------------------------
# Author: delimitry
#-----------------------------------------------------------------------
import os
import sys
from PIL import Image
from argparse import ArgumentParser
@delimitry
delimitry / uint_7bit.py
Last active November 7, 2022 16:09
Python version of unsigned integer 7-bit encoder and decoder
#!/usr/bin/evn python
# -*- coding: utf8 -*-
def encode_to_7bit(value):
"""
Encode unsigned int to 7-bit str data
"""
data = []
number = abs(value)
while number >= 0x80:
@delimitry
delimitry / compiled_file_python_version.py
Last active February 12, 2024 12:28
Get the version of Python by which the file was compiled
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
A script to get the version of Python by which the file was compiled
"""
from __future__ import print_function
import binascii
import os
@delimitry
delimitry / python_hashes.py
Last active September 24, 2020 11:47
Python hash algorithms
#!/usr/bin/evn python
# -*- coding: utf-8 -*-
import sys
import math
import struct
if sys.version_info > (3, 0):
basestring_type = str
else:
@delimitry
delimitry / scrolling_text.py
Last active January 13, 2023 23:36
Scrolling ASCII text in console using Python
# -*- coding: utf-8 -*-
"""
A tool for scrolling input text as ASCII art text banner in console
"""
import os
import time
from PIL import Image, ImageDraw, ImageFont
@delimitry
delimitry / Draw grid
Created April 5, 2014 09:06
Draw grid solution
#!/usr/bin/python
#-*- coding: utf8 -*-
import sys
def draw_grid(cols, rows, cell_size=4):
for y in xrange(rows):
# draw horizontal line
sys.stdout.write(('+' + ' - ' * cell_size) * cols + '+\n')
# draw vertical lines