Skip to content

Instantly share code, notes, and snippets.

@mxmlnkn
mxmlnkn / magicByteProbability.py
Created November 29, 2020 13:55
Calculate probability to find a string in a random sequence using transition matrices
#!/usr/bin/env python3
import numpy as np
def transition_matrix_for_string_matching( string_to_find, letter_probabilities ):
"""
string_to_find: An iterable, whose elements are interpreted as letters. E.g., "01001110" or [0,1,0,0,1,1,1,0].
letter_probabilities: If it is a number, then it will be assumed that all letters are equiprobable and the given
number is that probability. If it is a dictionary, then all elements in string_to_find are
@mxmlnkn
mxmlnkn / pmemdump.sh
Last active December 20, 2021 09:18
Dump memory of running process
#!/bin/bash
function pmemdump()
{
# Adapted from:
# https://serverfault.com/questions/173999/dump-a-linux-processs-memory-to-file
# Example output for /proc/xxx/maps:
# d7d90000-d7ed0000 rwxp 00000000 00:00 0
# d8ab0000-d8bf0000 rwxp 00000000 00:00 0
# f4111000-f43b9000 rw-s 00000000 00:05 429195289 /SYSV00000000 (deleted)
@mxmlnkn
mxmlnkn / delentropy.py
Last active December 15, 2023 10:02
Image Delentropy
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Trying to reproduce: https://arxiv.org/abs/1609.01117
from urllib.request import urlopen
from scipy import misc,ndimage,signal
import numpy as np
import matplotlib.pyplot as plt
import urllib.request, json