Skip to content

Instantly share code, notes, and snippets.

View mxwell's full-sized avatar

Murat Khairulin mxwell

  • Almaty, Kazakhstan
View GitHub Profile
@mxwell
mxwell / dst_format_ctl.py
Last active November 7, 2022 18:32
AutoCAD SheetSet *.dst files have some simple coding. This helps to manipulate them.
#! /usr/bin/env python3
"""
AutoCAD SheetSet file with *.dst extension is just an XML stream encoded with substitution cipher.
XML data is firstly encoded with UTF-8. This means characters might have different length (from one to four bytes).
It looks like substitution needs to be done on a per-character level rather than per-byte level.
== Restore conversion dictionary ==
Given two files "Crack.xml" and "Crack.dst", we can restore conversion dictionary (limited to charset used in these files) as follows:
@mxwell
mxwell / init_remote_linux.sh
Last active November 27, 2018 23:40
Script for initial configuration of a clean Linux (read 'Ubuntu') host
#! /bin/bash
set -xe
export NEW_USER=murat
export GITHUB_LOGIN=mxwell
export HOST_NAME=REMOTE
export NEW_HOME=/home/$NEW_USER
sudo useradd -s "/bin/bash" $NEW_USER
@mxwell
mxwell / youtube_dl_mp3.py
Created November 6, 2016 17:46
Wrapped configuration of youtube_dl, that worked on OS based on Ubuntu 14.04
#! /usr/bin/env python3
import argparse
import youtube_dl
class MyLogger(object):
def debug(self, msg):
pass
@mxwell
mxwell / harbour-app.spec
Last active September 6, 2015 18:21
Set permission for files in RPM
# It's useful, if you got warnings like this in SailfishOS SDK validation tool:
# WARNING [/usr/share/icons/hicolor/86x86/apps/harbour-<app>.png] File must not be executable (current permissions: 755)
...
%files
%defattr(755,root,root,-)
%{_bindir}
%defattr(644,root,root,-)
%{_datadir}/applications/%{name}.desktop
%{_datadir}/%{name}
%{_datadir}/icons/hicolor/86x86/apps/%{name}.png
@mxwell
mxwell / convert_from_bt656.py
Created February 18, 2015 16:07
Script to extract a picture from a BT.656 frame
#! /usr/bin/python
###############################################################################
# Script converts a single frame, compliant with ITU-R BT.656-5,
# into a picture of given format (like PNG, JPEG, BMP, etc)
#
# Tested with Python 2.7.5, Pillow 2.7
###############################################################################
from PIL import Image
@mxwell
mxwell / convert_to_bt656.py
Last active September 13, 2022 08:02
Script to convert a picture into ITU-R BT.656 frame.
#! /usr/bin/python
###############################################################################
# Script converts an arbitrary picture into a single frame,
# compliant with ITU-R BT.656-5, see:
#
# http://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.656-5-200712-I!!PDF-E.pdf
#
# Tested on Ubuntu 12.04, Python 2.7.3
###############################################################################
@mxwell
mxwell / init_tmux_round.sh
Created November 16, 2014 20:47
Create tmux session for contest
#! /bin/sh
# create session for round
if [ -z "$1" ]; then
echo "Round name is missing"
exit 1
fi
mkdir $1
@mxwell
mxwell / m4a_to_mp3.rb
Created August 2, 2014 02:29
Convert M4A into MP3 (Linux)
#! /usr/bin/ruby
# @ubuntu: depends on ffmpeg, libavcodec-extra-53
output_dir = "output"
if File.exists? output_dir
id = 1
while File.exists?(output_dir + id.to_s) && id < 10
id += 1
@mxwell
mxwell / decipher.py
Last active August 29, 2015 13:57
Byte-wise deciphering on base of known alphabet.
ab_name = "ab.txt"
cipher_name = "cipher.txt"
output_name = "output.txt"
import sys
if (len(sys.argv) < 2):
print("Error: too few arguments")
exit(0)
@mxwell
mxwell / dtds
Created September 25, 2013 14:56
DTD is a part of EDID. Samples for some modes.
## non-std: 720x288p@50Hz
- clock: 13.5MHz
- horizontal: 720-4-136-4 or 720-724-860-864
- vertical: 288-4-16-4 or 288-292-308-312
- DTD: `46 05 D0 90 20 20 18 10 04 88 40 01 00 00 00 00 00 18`
## std: 720x576p@50Hz
- clock: 27MHz
- horizontal: 720-732-796-864