Skip to content

Instantly share code, notes, and snippets.

View Red-Eyed's full-sized avatar

Vadym Stupakov Red-Eyed

View GitHub Profile
@Red-Eyed
Red-Eyed / set_ssh_perm.sh
Created February 11, 2024 09:32
set right ssh permissions
#!/bin/bash
SSH_DIR="${HOME}/.ssh"
chmod 700 "${SSH_DIR}"
find "${SSH_DIR}" -type f \( -name 'id_rsa' -o -name 'id_dsa' -o -name 'id_ecdsa' -o -name 'id_ed25519' \) -exec chmod 600 {} \;
find "${SSH_DIR}" -type f \( -name '*.pub' -o -name 'known_hosts' -o -name 'authorized_keys' \) -exec chmod 644 {} \;
@Red-Eyed
Red-Eyed / logging_config.py
Last active December 5, 2023 06:56
Convenient way to set python logging
from pathlib import Path
import logging
import sys
def set_logger(error_file: Path, info_file: Path):
error_file = Path(error_file).expanduser().resolve()
error_file.parent.mkdir(exist_ok=True, parents=True)
info_file = Path(info_file).expanduser().resolve()
info_file.parent.mkdir(exist_ok=True, parents=True)
@Red-Eyed
Red-Eyed / lru_cache.cpp
Last active November 2, 2023 06:58
C++ lru cache like in python
#include <iostream>
#include <functional>
#include <unordered_map>
#include <tuple>
// Define a hash function for std::tuple so that it can be used as a key in std::unordered_map
namespace std {
template <typename... T>
struct hash<std::tuple<T...>> {
size_t operator()(const std::tuple<T...>& t) const {
@Red-Eyed
Red-Eyed / flask_webapp_segmentation.py
Created July 18, 2023 11:06 — forked from deepak-karkala/flask_webapp_segmentation.py
FLASK Webapp for Image Segmentation Model
# FLASK Webapp for Image Segmentation Model
import os, sys, io
sys.path.append(".")
import webapp
from flask import Flask
import flask
import numpy as np
import pandas as pd
@Red-Eyed
Red-Eyed / How_to_webdav.md
Last active July 16, 2023 08:26
python webdav server

Server: Install webdav server

python -m pip install wsgidav cheroot lxml

Server: Run web dav server

python -m wsgidav.server.server_cli -p60012 --root=/ --auth=anonymous -Hlocalhost

Client: Configure ssh config

#!/usr/bin/env python3
from argparse import ArgumentParser
from functools import partial
from shutil import copy
from subprocess import Popen, PIPE
from shlex import split
import os
import re
import atexit
@Red-Eyed
Red-Eyed / .gitconfig
Created April 4, 2022 14:47
git and ssh accounts
[includeIf "gitdir:~/Projects/work/"]
path = .gitconfig_job
[includeIf "gitdir:~/Projects/personal/"]
path = .gitconfig_personal
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
@Red-Eyed
Red-Eyed / !Android debloat.md
Last active December 18, 2022 14:27
Android debloat

Usefull commands

Get current ativity: dumpsys activity activities | grep mResumedActivity

Uninstall app example: pm uninstall -k --user 0 com.aura.oobe.samsung.gl

Restore removed app example: pm install-existing com.aura.oobe.samsung.gl

@Red-Eyed
Red-Eyed / logcat.py
Last active December 18, 2022 14:26
logcat
#!/usr/bin/env python3
from pathlib import Path
import os
import sys
from subprocess import Popen, PIPE, getoutput
from shlex import split
from contextlib import redirect_stdout
import argparse
@Red-Eyed
Red-Eyed / 1. kill_vlc_on_resume.service
Last active December 18, 2022 14:25
kill vlc after suspend
[Unit]
Description=Kills VLC on resume in order to fix logging spam
[Service]
Type=oneshot
ExecStart=-/usr/bin/killall vlc
TimeoutSec=0
StandardOutput=syslog
After=suspend.target