Skip to content

Instantly share code, notes, and snippets.

View yuchdev's full-sized avatar
💭
Open for new opportunities

Yurii Cherkasov yuchdev

💭
Open for new opportunities
  • Open for new opportunities
  • Nibiru
View GitHub Profile
@yuchdev
yuchdev / exclusive_product.cpp
Created July 18, 2023 05:43
Exclusive product, little test assignment on C++
#include <iostream>
#include <numeric>
#include <vector>
/// @brief: Calculates array of same size, where each element is the product
/// of all elements excluding corresponding by index
/// Algorithm: O(n) time, O(n) space
/// @param: array of int
/// @return: array of same size
/// @example: {1,2,3,4} => {24, 12, 8, 6}, {1, 2, 3, 4, 5} => {120, 60, 40, 30, 24}
@yuchdev
yuchdev / disable-serv.cmd
Created August 7, 2022 18:19
Disable unnecessary Windows services
rem 1.
sc config "Name of Service" start= disabled
sc stop "Name of Service"
rem 2.
wmic service where name='SQLWriter' call ChangeStartmode Disabled
rem https://www.minitool.com/news/windows-10-services-to-disable.html
rem https://helpdeskgeek.com/windows-10/windows-10-unnecessary-services-you-can-disable-safely/
rem https://www.groovypost.com/howto/12-windows-10-services-that-are-safe-to-disable/
@yuchdev
yuchdev / create_venv.sh
Created July 10, 2022 05:15
Create venv
#!/bin/bash
# Install
pip3 install --user virtualenv
virtualenv –version
# Activate
virtualenv venv
source venv/bin/activate
@yuchdev
yuchdev / bash-snippets.sh
Created June 23, 2022 10:06
Bash Code Snippets
#!/bin/sh
# Backup Partititon
dd if=/dev/sda of=/mnt/backup/sda.img conv=noerror
fdisk -l /dev/sda > /mnt/backup/sda.info
dd if=/dev/sdb of=/mnt/backup/sdb.img conv=noerror
fdisk -l /dev/sdb > /mnt/backup/sdb.info
# execute "git pull" in every dir
for dir in ~/projects/git/*
@yuchdev
yuchdev / random_protonvpn.py
Last active March 18, 2022 08:03
Choose random ProtonVPN server
import os
import sys
import time
import random
import argparse
# Key is country code, value is the number of servers to use
SERVER_LIST = {
"AR": [*range(1, 8)],
"AU": [*range(13, 44)],
@yuchdev
yuchdev / shell_command.py
Created June 10, 2021 17:36
Command os.system with ability to enter and leave directory using 'with' statement
class Shell:
def __init__(self, cd_path):
self.cd_path = cd_path
self.exit_path = os.getcwd()
def __enter__(self):
os.chdir(self.cd_path)
def __exit__(self):
@yuchdev
yuchdev / easy_benshmark.sh
Created March 31, 2020 16:14
Easy way to create benchmark for basically any application
time python3 jira_backup.py
# Output
# real 0m1.542s
# user 0m0.299s
# sys 0m0.136s
@yuchdev
yuchdev / dd_progress.sh
Last active September 23, 2021 12:17
Linux: dd with progress
#!/bin/bash
# Method 1
dd if=/dev/urandom of=/dev/null status=progress
# Method 2
# You just need to enter a controlT character from the keyboard while the dd command is executing.
# By pressing the controlT character, you are sending the same SIGINFO signal to the dd command
# that the command pkill -INFO -x dd sends.
@yuchdev
yuchdev / password_ssh.sh
Last active January 7, 2020 10:52
Password autorization via SSH utility
sudo apt-get install sshpass
# $1: 1st command-line param, password
# $2: 2nd command-line param, username
# $3: 3rd command-line param, rsync source path
# $4: 4th command-line param, rsync destination path
/usr/bin/rsync -ratlz --rsh="/usr/bin/sshpass -p $1 ssh -o StrictHostKeyChecking=no -l $2" $3 $4
# Alternatively, you can avoid the password prompt on rsync command
@yuchdev
yuchdev / disable_logging.sh
Created January 7, 2020 09:01
Linux: disable all logs
#!/bin/bash
/etc/init.d/syslogd stop
/etc/init.d/rsyslogd stop
sudo systemctl disable rsyslog
sudo systemctl disable syslog