Skip to content

Instantly share code, notes, and snippets.

Avatar
🐍

Igor Starikov idlesign

🐍
View GitHub Profile
@idlesign
idlesign / m86bin2hex.py
Created Apr 10, 2021
bin в hex для прошивок к m86
View m86bin2hex.py
# Python-скрипт преобразует прошивки с https://chiptuner.ru/content/ser_m86/
# из двоичного представления (bin) в шестнадцатеричное (hex), которое используются
# в Infineon Memtool.
#
# Требуется установленный пакет intelhex:
# pip install intelhex
#
# Запуск:
# python m86bin2hex.py < I765BL57v3.bin > I765BL57v3.hex
#
@idlesign
idlesign / months.py
Created Feb 25, 2020
Get months count since date
View months.py
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 / py_strformat.sh
Created Dec 28, 2018
Python 3.7 string formatting variants speed measure
View py_strformat.sh
#!/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 / youtube_find_relevant.py
Last active May 26, 2019
Finds YouTube videos you're interested in. PyCon US talks finder example.
View youtube_find_relevant.py
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 / smbclient.py
Last active Mar 7, 2018 — forked from jean-helsinki/gist:85b3ea97b7445abdd9a7
smbclient Python Wrapper using pexpect
View smbclient.py
# -*- 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 / pypi_stats.py
Created Feb 16, 2018
This will produce an SQL to query Google BigQuery for a certain author packages downloads monthly statistics.
View pypi_stats.py
"""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
View dump restore classic
# -Fc - `format - custom` for parallel restore; not sql commands; compression
> pg_dump -Fc db_name > name.dump
# most of time - index recreation
> pg_restore --dbname=db_name name.dump
# can be parallel; jobs=num of cores +1
> pg_restore --jobs=2
View swap_1024.sh
sudo dd if=/dev/zero of=/swapfile bs=1024 count=524288
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapoff /swapfile
@idlesign
idlesign / instructions.sh
Created Nov 14, 2015
Make HDMI audio be listed in Ubuntu Sound Output Devices
View instructions.sh
; also https://wiki.archlinux.org/index.php/PulseAudio/Examples
; Show available cards and devices
aplay -l
; And ping a device. 0 - card, 3 -device
speaker-test -c 2 -r 48000 -D hw:0,3
@idlesign
idlesign / loop.sh
Created Nov 14, 2015
Load/unload loopback (monitor sound from inputs) pactl
View loop.sh
; load loopback (prints module number into console)
pactl load-module module-loopback latency_msec=1
; unload module by number (see above)
pactl unload-module {n}