This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import uuid | |
from contextlib import contextmanager | |
from collections import Counter | |
import psycopg2 | |
DB_NAME = 'bench' | |
DB_USER = 'postgres' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from types import MethodType | |
class Гражданин(): | |
"""Читайте, завидуйте: я — гражданин Советского Союза!""" | |
Глеб_Жеглов = Гражданин() | |
Костя_Сапрыкин = Гражданин() | |
# Теперь у нас есть метод против Кости Сапрыкина. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Этот гист расположен по адресу https://gist.github.com/idlesign/c1255817bb0234d9971a | |
Он вставлен в текст при помощи следующей директивы: | |
.. gist:: idlesign/c1255817bb0234d9971a | |
''' | |
print('Привет тебе!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
''' | |
Тестируем влияние импорта на проверки идентичности классов. | |
* Создать директорию `imptest`. | |
* Переместиться в директорию `imptest` | |
* В директории `imptest` создать пустой файл `__init__.py`. | |
* В директории `imptest` создать файл `test.py`, поместить в него этот код. | |
* В директории `imptest` создать файл `class_a.py`. | |
* Поместить в `class_a.py` следующий код: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# The purpose of the script is to reinstall the operating system (debrick) on | |
# a harddrive that has been extracted from the housing of a WD MyBook Live. | |
# | |
# From: | |
# http://mybookworld.wikidot.com/forum/t-368098/debricking-script-that-can-keep-data | |
# | |
#help screen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from base64 import * | |
with open('/home/idle/binary.data', 'rb') as f: | |
data = f.read() | |
for method in [b64encode, b32encode, b16encode, a85encode, b85encode]: | |
percent = ((len(method(data)) * 100) / len(data)) - 100 | |
print('%s: +%s%%' % (method.__name__, round(percent, 2))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo dd if=/dev/zero of=/swapfile bs=1024 count=524288 | |
sudo chmod 600 /swapfile | |
sudo mkswap /swapfile | |
sudo swapon /swapfile | |
sudo swapoff /swapfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -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 |
OlderNewer