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 / 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

@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
#!/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 / opencv-opencl-android.md
Created September 13, 2022 12:16 — forked from iago-suarez/opencv-opencl-android.md
Setting Up OpenCL for OpenCV on Android, the full story

Setting Up OpenCL for OpenCV on Android, the full story

The tutorial Use OpenCL in Android camera preview based CV application show us how we can use the Transparent API to dramatically increase the performance of some expensive operations.

The first step in order to be able to execute the tutorial example is to re-compile opencv with the correct flags:

# Export your NDK, it will be looked for OpenCV to compile your project. In my case
export ANDROID_NDK=~/graffter/libs/android-ndk-r10d/

# Download the necessary code
@Red-Eyed
Red-Eyed / logging_config.py
Last active September 11, 2024 15:40
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 / 0-install-deluge-python.sh
Last active May 22, 2022 15:06
Install deluge-web (used for raspberry pi)
# To use geoip
sudo apt install geoip-database libgeoip-dev
py_ver=`python -c "from sys import version_info as vi; print(f'{vi[0]}.{vi[1]}')"`
sudo apt install python${py_ver}-venv
pip install pipx
pipx install deluge
pipx inject deluge libtorrent GeoIP
@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