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 / .stignore
Last active November 29, 2020 15:23
[syncthing .stignore] #ignore #syncthing
.DS_Store
Thumbs.db
# any
.git
# joplin
.lock
# rust
@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 / str_utils.py
Last active September 11, 2020 16:09
[str_utils.py] python str utils #python #str
import sys
import re
###############################################################################
# from six.py:
# Useful for very coarse version differentiation.
PY2 = sys.version_info[0] == 2
PY3 = sys.version_info[0] == 3
PY34 = sys.version_info[0:2] >= (3, 4)
@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 / 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 / python_doctests.py
Last active August 25, 2020 15:17
[python_doctests.py] #python #doctests
#!/usr/bin/env python
def fn_none():
"""
>>> fn_none() is None
True
"""
return None
@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