Skip to content

Instantly share code, notes, and snippets.

View Shterneregen's full-sized avatar
:octocat:

Iurii Sergeev Shterneregen

:octocat:
View GitHub Profile
@Shterneregen
Shterneregen / CreateScheduledTask.ps1
Last active April 19, 2024 06:37
Windows task to update Cisco AnyConnect InterfaceMetric to help with internet connectivity porblem with running VPN. After the first launch, the task will automatically start when you turn on the VPN
# - Create CreateScheduledTask.ps1 file with content below.
# - Run as admin command in PowerShell:
# Get-Content .\CreateScheduledTask.ps1 | PowerShell.exe -noprofile -
# - Restart Windows
# - Launch WSL
# - Launch VPN
# - Done! Metric automatically updated
$taskname="Fix VPN for WSL"
$scriptName = "UpdateAnyConnectInterfaceMetric.ps1"
@Shterneregen
Shterneregen / WakeOnLanService.kt
Last active July 7, 2022 22:14
Wake On Lan using Kotlin by sending magic packet
import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Service
import random.telegramhomebot.utils.logger
import java.net.DatagramPacket
import java.net.DatagramSocket
import java.net.InetAddress
/**
* The magic packet is a frame that is most often sent as a broadcast and that contains anywhere within its payload
* 6 bytes of all 255 (FF FF FF FF FF FF in hexadecimal), followed by sixteen repetitions of the target computer's
@Shterneregen
Shterneregen / git-recover-branch.md
Created March 1, 2021 11:18 — forked from jbgo/git-recover-branch.md
How to recover a git branch you accidentally deleted

UPDATE: A better way! (August 2015)

As pointed out by @johntyree in the comments, using git reflog is easier and more reliable. Thanks for the suggestion!

 $ git reflog
1ed7510 HEAD@{1}: checkout: moving from develop to 1ed7510
3970d09 HEAD@{2}: checkout: moving from b-fix-build to develop
1ed7510 HEAD@{3}: commit: got everything working the way I want
70b3696 HEAD@{4}: commit: upgrade rails, do some refactoring
@Shterneregen
Shterneregen / nginx.conf
Created July 10, 2020 23:56
NGINX server block that redirects all requests to https
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 301 https://$host$request_uri;
}
@Shterneregen
Shterneregen / fetch_pull_master.bat
Last active March 26, 2020 23:15
How to pull master branch being on another branch
:: https://stackoverflow.com/questions/18857570/git-pull-without-checkout
git fetch origin master:master
@Shterneregen
Shterneregen / getInterfaceInfo.bat
Created March 26, 2020 22:12
Get information about current connected interface via BAT (CMD)
@echo off
FOR /F "tokens=1,2 delims=: " %%A IN ('netsh wlan show interface') DO (IF "%%A"=="SSID" SET SSID=%%B)
if "%SSID%"=="" (echo no wifi) else (netsh wlan show profile name="%SSID%" key=clear)
pause
@Shterneregen
Shterneregen / alias.cmd
Last active March 26, 2020 21:33
How to create CMD aliases in Windows
# This file should be placed in folder you wrote in AutoRun in alias.reg file (%USERPROFILE%\alias.cmd)
# https://stackoverflow.com/questions/20530996/aliases-in-windows-command-prompt
@echo off
DOSKEY alias=notepad %USERPROFILE%\alias.cmd
DOSKEY go=cd C:\Program Files
DOSKEY some_command_alias=ant clean all
DOSKEY some_alias=some.bat
@Shterneregen
Shterneregen / closePort.bat
Created March 26, 2020 21:21
Open / Close port in Windows via BAT (CMD)
@echo off
set /p port=Close port:
netsh advfirewall firewall delete rule name="Port%port%"
echo %port% port closed
pause
@Shterneregen
Shterneregen / wlanExport.bat
Last active March 26, 2020 21:16
Export-Import WI-FI credentials via CMD (by admin)
@echo off
set folder=%CD%
set exportPath=%folder%\wifi
if not exist "%exportPath%" mkdir "%exportPath%"
netsh wlan export profile key=clear folder=%exportPath%
cls
exit
@Shterneregen
Shterneregen / changing_author_info.sh
Created March 26, 2020 20:46
Changing author info
#!/bin/sh
# https://help.github.com/en/github/using-git/changing-author-info
git filter-branch --env-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]