Skip to content

Instantly share code, notes, and snippets.

View rvasilevsk's full-sized avatar

Roman rvasilevsk

  • Minsk, Belarus
View GitHub Profile
@rvasilevsk
rvasilevsk / stdout_write_bin.py
Last active January 31, 2021 06:55
[stdout_write_bin.py] #python #stdout #binary
import sys, array, os
def main_256():
arr = array.array("B", range(256))
arr.tofile(sys.stdout.buffer)
sys.stdout.flush()
def main_256_2():
@rvasilevsk
rvasilevsk / export_parent_dir.sh
Created January 29, 2021 16:48
[var=parent dir] #bash
export NAVI_HOME="$(cd "$(dirname "$0")/.." && pwd)"
@rvasilevsk
rvasilevsk / fs_walk_example.py
Created September 14, 2020 10:56
[fs_walk_example.py] #fs #python
from bin_cfg import pdf_dirs
def path_seq_print():
yield from pdf_dirs
# for path in pdf_dirs:
# try:
# assert_readable_dir(path)
# s = "%s: %s" % ("ok", path)
# print(path)
@rvasilevsk
rvasilevsk / bat_creator.py
Last active September 12, 2020 10:15
[bat_creator.py] #bat #dotfiles #python
# в винде10 не работало
# echo something | clip
# хз почему
# поэтому сделал clip_from_stdin.py
cmd_lines = '''
wh = where %*
gist git status
@rvasilevsk
rvasilevsk / validate.py
Created August 25, 2020 19:34
[validate.py] #python #validate
#######################################################################################################################
re_is_url = re.compile(
r'^(?:http|ftp)s?://' # http:// or https://
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' # domain...
r'localhost|' # localhost...
r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
r'(?::\d+)?' # optional port
r'(?:/?|[/?]\S+)$', re.IGNORECASE)
@rvasilevsk
rvasilevsk / json_rows.py
Created August 25, 2020 13:49
[json_rows.py] #python #json #json_rows #cache
#!/usr/bin/env python
import datetime
import json
#######################################################################################################################
def replace_suffix(s, suffix, replace):
"""
replace suffix if exists
@rvasilevsk
rvasilevsk / win.install.shell.cmd
Last active September 10, 2020 14:49
[win.install.shell.cmd] #scoop #install.win #shell.win #dotfiles #list.soft
scoop install conemu clink
REM загрузить zip и распаковать:
REM [Clink](https://mridgers.github.io/clink/)
REM %ConEmuBaseDir%\clink
REM todo рассмотреть zsh.exe
@rvasilevsk
rvasilevsk / polina_equ2.py
Created August 25, 2020 09:36
[polina_equ2.py] #polina
def hr():
print('--------------------------------')
def equ2(a, b, c):
d = b * b - 4 * a * c
print('D =', d)
aa = a * 2
d_sqrt = d ** 0.5
@rvasilevsk
rvasilevsk / requirements.txt
Created August 25, 2020 09:30
[requirements.txt - polina] #polina #pip.requirements
pygame
#pycairo
p5
@rvasilevsk
rvasilevsk / pygame_draw.py
Created August 25, 2020 09:29
[pygame_draw.py] #python #2d #pygame
import pygame as pg
FPS = 30
WW = 800
WH = 600
BLUE = (0, 0, 255)
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)