Skip to content

Instantly share code, notes, and snippets.

@achmel
achmel / download_apk.py
Created October 13, 2021 14:01 — forked from dawand/download_apk.py
Download APK files from Google Play Store with Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
File name: download_apk.py
Author: Dawand Sulaiman
Download APK files from Google Play Store with Python
This script scraps https://apkpure.com to get the apk download link
Make sure you have BeautifulSoup and urllib libraries
"""
@achmel
achmel / chrome_websocket_messages.py
Last active March 16, 2024 03:24
Tiny parser to get websocket messages from Google Chrome Developer Tools > Network > Export HAR...
# !/usr/bin/env python3
# encoding: utf-8
import json
file_name = 'websocket.har'
f = open(file_name)
j = json.load(f)
entries = j['log']['entries']
for e in entries:
if e['_resourceType'] == 'websocket' and '_webSocketMessages' in e.keys():
@achmel
achmel / fetchExcelCustomField.ps1
Last active November 26, 2020 11:56
Powershell script that fetches a custom property field from Microsoft Excel document.
$tmpPath = "C:\tmp\"
# $searchPath = "H:\Desktop"
$searchPath = (Get-Location).Path
$files = Get-ChildItem $searchPath -Recurse -Include *.xlsx
foreach ($f in $files){
$filename = $f.FullName
$guid = [guid]::NewGuid().Guid
$tempname = $tmpPath + $guid + ".zip"
$destinationUnarchivedPath = $tmpPath + $guid
$docProps = $destinationUnarchivedPath + "\docProps\custom.xml"
@achmel
achmel / asterisk_watchdog.py
Created January 14, 2019 20:37
A simple POC forwarder of 7-bit SMS from Asterisk logs to any 3-rd party delivering API. Takes less resources being compared to a usual `tail -f`. Requires python 3.7 due to `smspdudecoder` dependency (TODO: provide a simple inline GSM 7-bit decoding).
#!/usr/bin/env python3.7
# encoding: utf-8
import time
import os
from io import StringIO
from smspdu.fields import SMSDeliver
import requests
asterisk_log = '/var/log/asterisk/messages'

Закон Гутенберга-Рихтера: временные и энергетические ряды

События случайные и кореллированные

Всякая последовательность событий может характеризоваться двумя метриками - амплитудой (т.е., интенсивностью события) и временным интервал между двумя ближайшими событиями.

Как правило, наиболее распространен случай, когда «маленьких событий много, а больших событий мало». Построим линейный график зависимости интенсивности от временных интервалов между событиями.

(Fig 1)

Значимая информация в таком графике тяжела для человеческого восприятия, и поэтому для наглядности преобразуем шкалы из линейных в логарифмические.

@achmel
achmel / vk_markovify.py
Created December 2, 2017 08:13
VK markov-chains-based posts generator
#!/usr/bin/env python3
# encoding: utf-8
import vk
import markovify
service_token = '{PUT YOUR TOKEN HERE}'
vk_id = '{PUT VK ID HERE}'
session = vk.Session(access_token=service_token)
vk_api = vk.API(session)
posts_json = vk_api.wall.get(domain=vk_id, count=100)
text = ''