Skip to content

Instantly share code, notes, and snippets.

View delimitry's full-sized avatar
:octocat:

Dmitry Alimov delimitry

:octocat:
View GitHub Profile
@niksumeiko
niksumeiko / git.migrate
Last active November 10, 2024 18:26
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@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
@delimitry
delimitry / scrolling_text.py
Last active October 9, 2024 03:58
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 / 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 / compiled_file_python_version.py
Last active May 20, 2024 04:22
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 / 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 / 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 / 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 / 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
"""
@muodov
muodov / empty-hash-assignment.md
Last active February 24, 2022 17:42
Location and links behaviour when setting empty hash
Command (executed in this order) Chrome 72 Firefox 65 Safari 12.0.3 IE11
window.location.hash "" "" "" ""
window.location.href "https://example.com/" "http://example.com/" "http://example.com/" "http://example.com/"
window.location.hash = '#' "#" "#" "#" "#"
window.location.href "https://example.com/" "http://example.com/#" "http://example.com/" "http://example.com/#"
window.location.hash "" "" "" "#"
window.location.hash = '#1' "#1" "#1" "#1" "#1"
window.location.href "https://example.com/#1" "http://example.com/#1" "http://example.com/#1"