Skip to content

Instantly share code, notes, and snippets.

import cv2
import numpy as np
from mss import mss
import time
from collections import deque
def capture_screen_area(x, y, width, height):
"""Capture a specific area of the screen using mss and return it as an OpenCV image."""
monitor = {"top": y, "left": x, "width": width, "height": height}
screenshot = sct.grab(monitor)
@Vaiz
Vaiz / wireguard.md
Created April 8, 2023 06:19
How to set InterfaceMetric for wireguard tunnel
@Vaiz
Vaiz / hyper-v.cmd
Last active March 19, 2023 10:40
Install hyper-v on Win11 home
dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txt
for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i"
del hyper-v.txt
dism /online /enable-feature /featurename:Microsoft-Hyper-V -All /LimitAccess /ALL
@Vaiz
Vaiz / expected.hpp
Created July 15, 2022 08:15
use boost::outcome as an alternative to std::expected
// https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0323r11.html
// https://en.cppreference.com/w/cpp/header/expected
// https://www.boost.org/doc/libs/master/libs/outcome/doc/html/index.html
// https://github.com/TartanLlama/expected
#include <boost/outcome.hpp>
template <typename T>
using expected = boost::outcome_v2::result<T, std::exception_ptr>;
#Get all file properties
PS E:\> Get-Item E:\dedupFile.bin | Format-list -Property *
#Get item attributes
PS E:\> [System.IO.File]::GetAttributes("<path>") -as [uint64]
PS E:\> (Get-ItemPropertyValue -Path <path> -Name Attributes) -as [uint64]
#change file date:
@Vaiz
Vaiz / monokai.xml
Created October 7, 2015 14:52
Monokai style for QtCreator
<?xml version="1.0" encoding="UTF-8"?>
<style-scheme version="1.0" name="Monokai 2">
<style name="Text" foreground="#f80951" background="#272822"/>
<style name="Link" foreground="#88cee7" italic="true"/>
<style name="Selection" background="#49483e"/>
<style name="LineNumber" foreground="#8f908a"/>
<style name="SearchResult" foreground="#000000" background="#94caef"/>
<style name="SearchScope" foreground="#000000" background="#e2efff"/>
<style name="Parentheses" foreground="#000000" background="#94caef"/>
<style name="CurrentLine" background="#49483e"/>
@Vaiz
Vaiz / QBuildDateTime.cpp
Last active September 17, 2021 05:06
Build time in QDateTime
QDateTime buildDateTime()
{
QDateTime dateTime;
dateTime.setDate(QLocale("en_US").toDate(QString(__DATE__).simplified(), "MMM d yyyy"));
dateTime.setTime(QTime::fromString(__TIME__, "hh:mm:ss"));
return dateTime;
}