Skip to content

Instantly share code, notes, and snippets.

View pbelskiy's full-sized avatar

Petr Belskiy pbelskiy

View GitHub Profile
@pbelskiy
pbelskiy / leetcode.js
Last active April 14, 2024 09:07
How to find user name on Leetcode contest table
javascript
(function () {
const username = 'pbelskiy';
function find() {
if (document.body.innerHTML.search(username) !== -1) {
alert('found!');
return;
}
@pbelskiy
pbelskiy / python.md
Last active September 15, 2022 14:46
Python package distributing

Python package distribution overview

python


Have you ever heard about such words when you working with Python? easy_install, pip, distutils, setuptools, sdist, bdist, egg, wheel, twine, pypi let's structuring knowledge about it.

@pbelskiy
pbelskiy / example.service
Created August 4, 2021 12:09
systemd restart on failed and notify
[Unit]
After=postgresql.service
[Service]
Type=simple
ExecStartPre=/bin/bash -c '(journalctl -n 5 --user-unit=%n | grep "Failed with result") && \
(journalctl -n 50 --user-unit=%n | mailx -s "[systemd] %n failed" user@domain.ua) || \
true'
ExecStart=/usr/bin/python3 /home/user/daemon.py
Environment=PYTHONUNBUFFERED=1
@pbelskiy
pbelskiy / time_profiler.py
Created September 17, 2018 12:20
Python function profiling time
#!/usr/bin/env python3
import time
class TimeProfiler:
functions = list()
start_time = instance = None
def __init__(self):
@pbelskiy
pbelskiy / usb-linux.md
Created January 24, 2018 07:57
How to associate logical to physical USB topology on Linux

How to associate logical to physical USB topology on Linux

As you know every time USB device is rebooted is devnum is changed, but physical USB port is the same as was.

Sometimes it's needed to convert static USB path from lsub -t to current device num on sysfs (/dev/bus/usb/XXX/YYY). It's useful for working with devices often are rebooted.

Some little solution that I've found, this script just convert static USB path from lsusb -t utility to current device on sysfs.

For example, you connected your device to your PC. And its physical topology, for example, is: 218, where 2 is USB bus, and 18 is nested port hierarchy, it's hierarchy will change only if you change physical USB port on your PC.

@pbelskiy
pbelskiy / gist:919ec917de007636749b4d50032d3fef
Created November 17, 2017 18:01
speedup get_build() of jenkinsapi python module
diff --git a/jenkinsapi/job.py b/jenkinsapi/job.py
index 280cf93..20c6932 100644
--- a/jenkinsapi/job.py
+++ b/jenkinsapi/job.py
@@ -90,7 +90,7 @@ class Job(JenkinsBase, MutableJenkinsThing):
def poll(self, tree=None):
data = super(Job, self).poll(tree=tree)
- if not tree:
+ if not tree and self.jenkins.lazy is False: