Skip to content

Instantly share code, notes, and snippets.

View ahbanavi's full-sized avatar
🎯
Focusing

Amir ahbanavi

🎯
Focusing
View GitHub Profile
@ahbanavi
ahbanavi / v2ray_ip_replace.sh
Last active January 16, 2024 15:29
This Bash script replaces hostnames with IP addresses in V2Ray and VLESS server configurations (from subscription url) by resolving each domain to its IP.
#!/bin/bash
# read url from args
url=$1
# If no URL is provided, exit with usage
if [[ -z "$url" ]]; then
echo "Usage: $0 <url>"
exit 1
fi
@ahbanavi
ahbanavi / switch_interface_ssh.sh
Last active December 22, 2023 13:02
swich / watch wan interfaces on router to swich between them based on cron or usage
#!/bin/bash
interface=$1
# Check if the interface is valid and set the other interface
if [[ $interface == "wan" ]]; then
other_interface="wanb"
elif [[ $interface == "wanb" ]]; then
other_interface="wan"
else
@ahbanavi
ahbanavi / hevc.bat
Created December 12, 2023 22:17
ffmpeg stuff :) just drag and drop videos to the `.bat` file
@echo off
for %%A in (%*) do (
ffmpeg -i "%%A" -vcodec hevc_nvenc "%%~nA.x265%%~xA"
)
pause
@ahbanavi
ahbanavi / config.json
Last active February 10, 2023 13:46
imdb userscript
[
{
"id": "cinemagia",
"title": "Cinemagia",
"icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAADH0lEQVQ4T4VTXWgUVxT+7tydzKi72Z/UkNTEGDSlMbCaqCCmIKHaEgumUZC+FWvb0IcI1hehERSi4IuIDxoRBEUF0Sr0RasoWlHTEBEURdKUNmljMMlkk83s7szeO/d6ZgUpWPTMnLlw7/Cdc77vu+yrn059P/TPZE8+X1jAABgGQ7j+Nxht+DICkys6UwBtxKLR/PKlVb1s895zUxmPVRS9PIQMIEupoLQuAYWAOWHjk7ohRJjEbyONmG/60LwMSVtPsx0nb81oFolLKaCUQhAoSMppz0LeEyj6PjzBcal9F66NrMexx1uQsFxC5rAMZNn2s3ccbURSgRDQ9ASaI1mWR2vsV0yoZXjqppG276C7oQfHn+/E0eEdSPBJcM4wj+sM+/ZKv6MMnlIEIFUIweApC7uW/IJWcz9cfyFVKsA0XDzMbcSFmW689GLIBjaUKGbYN5cHnIAAwhGSlolsUaCM2utetxrjT/fgM/MQmAEQJaUVlK6swTX/O1yd/SLDtv884GhupvI0a3phObYuX0Q/MlTHY7j9/BnaptYgRiOFAELbGPTacLPQgT/1KhBVGbbt/O8OCEBRBwGR2LbkA3StXYY8FUsMfQ28OAPBQgkl/vKb0PXyIiRJGSMleEAjfHrklsMMM5XNFbCiNonOlTX4uKYSCecq+OMfcGK8A/f99ThY2YO6yCi+HLtCHNngERI5kBnW2ffAsW0r1bIoiubaBJqq4+j/ewbDw/fQ8tEK9N714QuJD/koeuM/4sDsfozIelgRDSH8DGvve81BY4WFbc3ViFkcZwfH8GRCYHHCgksGcz0JVy3AYuMP+IpjXFaVZJRCZNjnfYNOQ1U8taE+So5TeDTmYs6XtM7BIMtyIpTekkeKuo
@ahbanavi
ahbanavi / docker-compose.yml
Created October 11, 2022 11:52
docker compose psql
version: "3.3"
services:
db:
container_name: db_container
image: postgres:14-alpine3.16
restart: unless-stopped
volumes:
- db_vol:/var/lib/postgresql/data
environment:
@ahbanavi
ahbanavi / docker-image.yml
Created October 1, 2022 08:40
gh action docker ci/cd
name: Create and publish a Docker image
on:
release:
types: [published]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
@ahbanavi
ahbanavi / contracts...SimpleSplitter.sol
Created April 21, 2022 07:55
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.13+commit.abaa5c0e.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
contract SimpleSplitter {
event Received(address, uint256);
error PaymentFailed();
error WrongShares();
error WrongAddress();
·---------------------------------------------------------------|---------------------------|-------------|-----------------------------·
| Solc version: 0.8.11 · Optimizer enabled: true · Runs: 800 · Block limit: 30000000 gas │
································································|···························|·············|······························
| Methods │
··········································|·····················|·············|·············|·············|···············|··············
| Contract · Method · Min · Max · Avg · # calls · usd (avg) │
··········································|·····················|·············|·············|·············|···············|··············
| ERC721ABurnableMock · approve
@ahbanavi
ahbanavi / contracts...SimpleSplitter.sol
Created April 14, 2022 12:44
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.13+commit.abaa5c0e.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
contract SimpleSplitter {
event Received(address, uint256);
error PaymentFailed();
error WrongShares();
address private immutable _addr1;
@ahbanavi
ahbanavi / contract.sol
Last active May 19, 2022 19:49
ECDSA Sign off-chain and Validate on-chain
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
using ECDSA for bytes32;
// verify signature
if (
keccak256(abi.encodePacked(msg.sender, address(this))).toEthSignedMessageHash().recover(signature) !=
owner()
) revert InvalidSignature();