Skip to content

Instantly share code, notes, and snippets.

View f4rx's full-sized avatar

Aleksey Stepanenko f4rx

View GitHub Profile
@f4rx
f4rx / Мемориз.md
Last active December 19, 2017 14:07
Мемориз

Vladimir D [7:45 PM]
Ай блин) Навык гугленья это первый навык админа, нагуглите себе задание для ДЗ сами)


Повторение создает привычки, а привычки обеспечивают мастерство в любом деле.


@f4rx
f4rx / set -euo pipefail
Created December 16, 2017 16:59
set -euo pipefail
http://farmaz0n.blogspot.ru/2010/12/pipefail.html
#!/bin/bash
set -euo pipefail
Опция -e останавливает скрипт если процесс вернул не 0 (и пишет в stderr на какой строке ошибка).
Опция -u останавливает скрипт, если используется неопределённая переменная.
Опция -o pipefail фейлит выполнение пайпа, если один из подкомпонентов выполняется с ошибкой.
@f4rx
f4rx / sshfs.sh
Created January 29, 2018 09:42
SSHFS macos
https://github.com/osxfuse/osxfuse/wiki/SSHFS
# mount
sshfs user@host:/dir /tmp/ssh -ocache=no -onolocalcaches -ovolname=ssh
# отмонтировать
umount /tmp/ssh
@f4rx
f4rx / cuda
Created February 16, 2018 18:02
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.1.85-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1604_9.1.85-1_amd64.deb
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda
@f4rx
f4rx / reddit_post.log
Created March 3, 2018 19:42
DevOps Otus HW 25
Traceback (most recent call last):
File \"/usr/local/lib/python3.6/site-packages/urllib3/connection.py\", line 141, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File \"/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py\", line 60, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File \"/usr/local/lib/python3.6/socket.py\", line 743, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name does not resolve
During handling of the above exception, another exception occurred:
@f4rx
f4rx / xo.py
Created March 14, 2018 20:32
XO
#!/bin/env python3
class Players:
def __init__(self):
self.players = {0: "X", 1: "O"}
self.player = 0
def get_player(self):
cd /tmp/
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.13/linux-headers-4.13.0-041300_4.13.0-041300.201709031731_all.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.13/linux-headers-4.13.0-041300-generic_4.13.0-041300.201709031731_amd64.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.13/linux-image-4.13.0-041300-generic_4.13.0-041300.201709031731_amd64.deb
sudo dpkg -i *.deb
apt update
apt -y install curl python-pip python-dev python3-dev git libxml2-dev libxslt1-dev python-openssl python3-openssl python-pyasn1 libffi-dev libssl-dev build-essential
pip install -UI pip
pip install -UI pbr setuptools pytz
pip install -UI git+https://github.com/openstack/python-openstackclient
import sys
import json
import os
import yaml
def get_message(notification):
if 'notification_type' not in notification or notification['notification_type'] != 'error':
raise SystemExit()
return notification['message']
@f4rx
f4rx / get_log_file_for_convert.py
Created May 31, 2018 12:09
Otus Python HW_01 log analyzator
def get_all_files_and_dirs_in_dir_and_sort(dir):
files = glob.glob(dir)
files.sort()
return files
def get_log_file_for_convert(log_dir, report_dir):
if not os.path.isdir(log_dir):
logging.info("Log dir '%s' not found" % log_dir)
return