Skip to content

Instantly share code, notes, and snippets.

View idlesign's full-sized avatar
🐍

Igor Starikov idlesign

🐍
View GitHub Profile
@idlesign
idlesign / pypi_stats.py
Created February 16, 2018 04:29
This will produce an SQL to query Google BigQuery for a certain author packages downloads monthly statistics.
"""This will produce an SQL to query Google BigQuery
for a certain author packages downloads monthly statistics.
"""
try:
import xmlrpclib
except ImportError:
import xmlrpc.client as xmlrpclib
@idlesign
idlesign / smbclient.py
Last active March 7, 2018 10:20 — forked from jean-helsinki/gist:85b3ea97b7445abdd9a7
smbclient Python Wrapper using pexpect
# -*- coding: utf-8 -*-
"""
https://gist.github.com/idlesign/6000f730a7fa2421b34a5287d6011a8b
Based on
https://gist.github.com/jean-helsinki/85b3ea97b7445abdd9a7
"""
from __future__ import unicode_literals
@idlesign
idlesign / youtube_find_relevant.py
Last active May 26, 2019 09:22
Finds YouTube videos you're interested in. PyCon US talks finder example.
import re
import requests
import html
API_KEY = ''
'''Google API (YouTube Data API v3) key from https://console.developers.google.com/apis/.'''
# Put titles you're interested into RELEVANT string:
# one title per line. These are regular expressions.
# NOTE: escape (), [], etc.
@idlesign
idlesign / py_strformat.sh
Created December 28, 2018 06:37
Python 3.7 string formatting variants speed measure
#!/bin/bash
measure () {
local RES=$(python3.7 -m timeit -n 2000000 -s 'x=256' "$1" | cut -d ":" -f 2)
echo "$1 -> $RES"
}
measure 'str(x)'
measure 'f"{x}"'
@idlesign
idlesign / months.py
Created February 25, 2020 11:17
Get months count since date
from datetime import datetime
from dateutil import relativedelta
def get_months(since):
delta = relativedelta.relativedelta(datetime.now(), since)
months = delta.months + (delta.years * 12)
return months
@idlesign
idlesign / m86bin2hex.py
Created April 10, 2021 05:37
bin в hex для прошивок к m86
# Python-скрипт преобразует прошивки с https://chiptuner.ru/content/ser_m86/
# из двоичного представления (bin) в шестнадцатеричное (hex), которое используются
# в Infineon Memtool.
#
# Требуется установленный пакет intelhex:
# pip install intelhex
#
# Запуск:
# python m86bin2hex.py < I765BL57v3.bin > I765BL57v3.hex
#
from os import getuid
from time import sleep
_uid = getuid()
p_out = open(f'/tmp/audacity_script_pipe.to.{_uid}', 'w')
p_in = open(f'/tmp/audacity_script_pipe.from.{_uid}', 'r')
def write(cmd: str):
@idlesign
idlesign / audacity_prepare.sh
Created June 1, 2023 13:04
Create launcher for Audacity appImage
#! /usr/bin/env bash
read -p "This will create Audacity launcher for an appImage found nearby. Press Enter to begin."
echo Creating audacity/ directory ...
mkdir -p audacity/
echo Searching for Audacity appImage nearby ...
find ./ -maxdepth 1 -type f -name "audacity*.AppImage" -print0 | xargs -0 -I{} mv "{}" "audacity/audacity.AppImage"