Skip to content

Instantly share code, notes, and snippets.

View rodnaxel's full-sized avatar

Aleksandr Smirnov rodnaxel

  • Finland
View GitHub Profile
@rodnaxel
rodnaxel / chroot-to-pi.sh
Created July 16, 2019 07:05 — forked from htruong/chroot-to-pi.sh
Chroot to pi sd card
#!/bin/bash
# This script allows you to chroot ("work on")
# the raspbian sd card as if it's the raspberry pi
# on your Ubuntu desktop/laptop
# just much faster and more convenient
# credits: https://gist.github.com/jkullick/9b02c2061fbdf4a6c4e8a78f1312a689
# make sure you have issued
@rodnaxel
rodnaxel / fabric_method.md
Created September 14, 2018 08:09
Фабричный метод

Если вы создаете новые объекты внутри init, то целесообразнее передавать их уже готовыми в качестве аргументов, а для создания объекта использовать фабричный метод. Это отделит бизнес-логику от технической реализации создания объектов.

В этом примере init для создания подключения к базе данных принимает в виде аргументов host и port:

class Query:
    def __init__(self, host, port):
        self._connection = Connection(host, port)
#! /usr/bin/python3.6
# Name: imagehex
# Description: This programm to used convert image to hex sequence
# Author: Aleksandr Smirnov ([email protected])
import sys, os
from fileinput import filename
from PIL import Image
@rodnaxel
rodnaxel / imgconv.py
Last active June 7, 2018 23:50
image converter
#! /usr/bin/python3.6
# Name: imagehex
# Description: This programm to used convert image to hex sequence
# Author: Aleksandr Smirnov ([email protected])
import sys, os
from fileinput import filename
from PIL import Image

Source

Get name of current function and caller with Python

With the python module inspect, one can inspect (not kidding) the run-time python stack. Among other things, this makes it possible to get the name of the current function or callers. Handy for logging or debugging purposes. A simple script to illustrate:

import inspect
# functions
@rodnaxel
rodnaxel / setup.py
Created June 2, 2018 13:03
example my setup.py by Cx_freeze
# python setup.py build
from cx_Freeze import setup, Executable
import sys
import os
import shutil
import zipfile
__appname__ = "userial-qt5"
@rodnaxel
rodnaxel / .gitignore
Last active June 14, 2018 13:10
Example my test ignore
# Whitelist
!appsettings.json
!appsettings.ini
# Blacklist
# ...folders Pycharm, Visual Studio, Sublime
/.idea
/.ropeproject
/.vscode
@rodnaxel
rodnaxel / tmux.conf
Last active June 1, 2018 06:26
Tmux config file foe version >2.1
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@rodnaxel
rodnaxel / install_kivy.sh
Last active August 18, 2020 20:38
Install Kivy on Ubuntu 18.04 (python 3.6)
apt-get install python3-pip
apt-get install cython3 python3-dev
apt-get install libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev
python3.6 -m pip3 install git+https://github.com/kivy/kivy.git@master
apt-get install python3-kivy-examples
@rodnaxel
rodnaxel / paramiko_demo.py
Created December 22, 2017 17:07
Example Paramiko
import argparse
import paramiko
host = '192.168.1.66'
user = 'pi'
passw = 'raspberry'
port = 22
def create_argparse():
p = argparse.ArgumentParser(description='Remote control Raspberry Pi')