Skip to content

Instantly share code, notes, and snippets.

@uyriq
uyriq / convertChat.ps1
Created June 27, 2024 14:00
Usage example: Convert-ChatSessionToJson -Filename "chat.json" this will produce chat.json.md file
function Convert-ChatSessionToJson {
param (
[string]$Filename = "chat.json"
)
$data = Get-Content -Path $Filename | ConvertFrom-Json
$outputFilename = "$Filename.md"
$empty = $true
$data.requests | ForEach-Object {
@uyriq
uyriq / GetVpnConnectionInfo.ps1
Last active June 20, 2024 17:40
The `Get-VPNConnectionInfo ` function checks if the current internet connection is made through one of the known VPN providers. It fetches the current IP information from ipapi.co and compares the organization name (org field) against a predefined list of VPN providers.
function Get-VPNConnectionInfo {
$connectedVPN = $false
try {
# Read the list of known VPN providers from a JSON file
if (Test-Path -Path "./knownVPNproviders.json") {
$knownVPNProviders = Get-Content -Path "./knownVPNproviders.json" | ConvertFrom-Json
}
else {
Write-Warning "Warning: The file 'knownVPNproviders.json' was not found."
$knownVPNProviders = @()
@uyriq
uyriq / convertIDv3tags.ps1
Last active July 10, 2024 14:53
fix1252/1251 to UTF8 encoding for idv3tags
# .description: "This script reads the ID3 tags of MP3 files in a directory, corrects the encoding from WINDOWS-1251 (incorrectly displayed as WINDOWS-1252) to UTF-8, and saves the corrected tags back to the files."
# .prerequisites: "To run this script, you must first obtain TagLibSharp.dll. This can be done by downloading it from https://nuget.org/packages/TagLibSharp/2.3.0 or by compiling the sources available at https://github.com/mono/taglib-sharp."
# .how_to_use: "Execute this script in the directory containing the MP3 files you wish to correct. Ensure TagLibSharp.dll is accessible to the script, adjusting the library loading path as necessary."
# You can optionally pass args as -AllArtists, -AllAlbum, -AllPicture, -AllComment to set the appropriate meta properties for a group of files
param(
# assign $null by default
[string]$AllArtist = $null,
[string]$AllAlbum = $null,
[string]$AllPicture = $null,
[string]$AllComment = $null
@uyriq
uyriq / .bashrc.part.sh
Created February 22, 2024 11:38
part of ,bashrc for tea command tunning. How to add --repo "reponame" automaticaly postfix based on current repo
# work but badly way
gitea() {
reponame="basename -s .git $(git config --get remote.origin.url)"
giteaargs="$@"
tea $giteaargs --repo $reponame
}
PROG2=gitea
_cli_bash_autocomplete() {
@uyriq
uyriq / anticors.js
Created October 5, 2023 07:00
Axios req
export default function Page() {
const [token, setToken] = useState('');
// function that do post request to get token from backend localhost:8000/api/v1/users/token using axios and post method body email and password
function handToken() {
try {
const data = {
email: 'prostome2@prosto.me',
password: '222',
@uyriq
uyriq / switch2firefox-deb.sh
Created July 10, 2023 18:03
from snap to deb ppa firefox switch
# Step 1: Remove the Firefox Snap by running the following command in a new Terminal window:
sudo snap remove firefox
# Step 2: Add the (Ubuntu) Mozilla team PPA to your list of software sources by running the following command in the same Terminal window:
sudo add-apt-repository ppa:mozillateam/ppa
# Step 3: Next, alter the Firefox package priority to ensure the PPA/deb/apt version of Firefox is preferred. This can be done using a slither of code from FosTips (copy and paste it whole, not line by line):
echo '
@uyriq
uyriq / get-history.ps1
Last active June 14, 2023 15:04
powershell get-history acts as bash history alike 🎉
function get-history {
if ($args.Count -gt 0) {
Write-Output "$args"
$search="$($args[0])"
Get-Content (Get-PSReadlineOption).HistorySavePath | ? { $_ -Like "*$($search)*" }
}
Write-Output 'get-history acts like history'
Write-Output "$args"
}
@uyriq
uyriq / some_bash.sh
Created April 1, 2023 18:02
microsoft edge beta
## Setup
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo install -o root -g root -m 644 microsoft.gpg /usr/share/keyrings/
sudo sh -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge-beta.list'
sudo rm microsoft.gpg
## Install
sudo apt update
sudo apt install microsoft-edge-beta
@uyriq
uyriq / NO_PUBKEY.readme.md
Last active March 27, 2023 06:40
how to fix NO_PUBKEY in ubuntu

1. ищем NO_PUBKEY

Эта команда добавляет ключ безопасности для репозитория Skype в вашу систему.

gpg --no-default-keyring --keyring skype-stable.gpg --keyserver keyserver.ubuntu.com --recv-keys 1F3045A5DF7587C3

2. экспорт в нужный для APT формат

Эта команда экспортирует ключи в нужный формат для APT.

gpg --no-default-keyring --keyring $HOME/.gnupg/skype-stable.gpg --export > ./skypeforlinux-keyring.gpg

3. копируем в удобное место

@uyriq
uyriq / cod.ps1
Last active April 28, 2023 23:11
copy this gist to $PROFILE powershell startup script, to have a shortcut for preferred code editor
function Test-IsAdmin {
try {
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object Security.Principal.WindowsPrincipal -ArgumentList $identity
return $principal.IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator )
}
catch {
throw "Failed to determine if the current user has elevated privileges. The error was: '{0}'." -f $_
}
return false