Skip to content

Instantly share code, notes, and snippets.

@g3rhard
g3rhard / ip.bat
Last active June 15, 2017 09:15
Send IP address with Telegram in Windows OS
@echo off
set ip_address_string="IPv4"
rem Uncomment the following line when using Windows 7 or Windows 8 / 8.1 (with removing "rem")!
rem set ip_address_string="IPv4 Address"
for /f "usebackq tokens=2 delims=:" %%f in (`ipconfig ^| findstr /c:%ip_address_string%`) do (
echo Your IP Address is: %%f
powershell send_telegram.ps1 -chat_id CHAT_ID -text 'Greetings for %computername% with ip %%f'
goto :eof
)
@g3rhard
g3rhard / sendmessage_telegram.ps1
Last active June 17, 2020 14:46
Send message with Telegram and Powershell
#Usage: sendmessage_telegram.ps1 -chat_id CHAT_ID -text 'TEXT' -markdown
param(
[string]$chat_id = $(Throw "'-chat_id' argument is mandatory"),
[string]$text = $(Throw "'-text' argument is mandatory"),
[switch]$markdown,
[switch]$nopreview
)
$token = "TOKEN"
if($nopreview) { $preview_mode = "True" }
@g3rhard
g3rhard / deploy_zoneminder.sh
Last active April 2, 2018 16:24
Install ZoneMinder with h264 archive storage
#!/bin/bash
# http://zoneminder.readthedocs.io/en/latest/installationguide/ubuntu.html#easy-way-ubuntu-16-04
#Задаем пароль для пользователя root для MySQL
COOKIES_PASSWORD="PASSWORD"
#Задаем часовой пояс для PHP
TIMEZONE="Asia/Irkutsk"
# Настраививаем автоматический ввод пароля для админа mysql.
@g3rhard
g3rhard / deploy_opeenmeetings.sh
Last active June 15, 2017 10:03
Deploy OpenMeetings for Ubuntu 16.04
#!/bin/sh
#
# Ubuntu 16.04 deploy OpenMeetings
# wget -qO - https://gist.github.com/ | bash -s
#
apt update
apt -y install software-properties-common python-software-properties
add-apt-repository -y ppa:jonathonf/ffmpeg-3
@g3rhard
g3rhard / telegram_send.rsc
Created June 19, 2017 05:14
Send messages with Telegram API and Mikrotik fetch tool with cyrillic symbols
:local ttoken "TOKEN";
:local tchatid "CHAT_ID";
:local ttext "\D0\A2\D0\B5\D1\81\D1\82\D0\BE\D0\B2\D0\BE\D0\B5\20\D1\81\D0\BE\D0\BE\D0\B1\D1\89\D0\B5\D0\BD\D0\B8\D0\B5";
:global turl "https://api.telegram.org/bot$ttoken/sendMessage?chat_id=$tchatid&text=$ttext";
#To encode cyrillic symbols, use this or similiar tools: https://www.urldecoder.org/
#And replace "%" to "\"
#Example:
#"Тестовое сообщение" -> "%D0%A2%D0%B5%D1%81%D1%82%D0%BE%D0%B2%D0%BE%D0%B5%20%D1%81%D0%BE%D0%BE%D0%B1%D1%89%D0%B5%D0%BD%D0%B8%D0%B5" -> "\D0\A2\D0\B5\D1\81\D1\82\D0\BE\D0\B2\D0\BE\D0\B5\20\D1\81\D0\BE\D0\BE\D0\B1\D1\89\D0\B5\D0\BD\D0\B8\D0\B5"
/tool fetch url="$turl" mode=https;
@g3rhard
g3rhard / vpn_reconnect.bat
Created June 21, 2017 09:36
Bat script for reconnect VPN connection in Windows
@echo off
:loop
echo testing IP address
ping 123.456.78.90 >nul || (
echo ping failure - disconnecting
rasdial name_of_your_vpn_connect /disconnect
timeout /t 10 /nobreak
echo reconnecting
rasdial name_of_your_vpn_connect
timeout /t 10 /nobreak
#!/bin/bash
# Deploy on Ubuntu 16.04 WordPress CMS
# https://www.digitalocean.com/community/tutorials/wordpress-lamp-ubuntu-16-04-ru
# https://kaiten.support/how-to-automate-wordpress-and-wp-config-php-creation/
#Задаем пароль для пользователя root для MySQL
SQL_PASSWORD="SQL_PASS"
DB_NAME="WP_DB_NAME"
DB_USER="WP_DB_USER"
DB_PASSWORD="WP_DB_PASS"
@g3rhard
g3rhard / winver.ps1
Created July 11, 2017 09:03
Powershell скрипт, который узнает версию Windows
$name=(Get-WmiObject Win32_OperatingSystem).caption
$bit=(Get-WmiObject Win32_OperatingSystem).OSArchitecture
$ver=(Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion").ReleaseId
Write-Host $name, $bit, $ver
@g3rhard
g3rhard / get_software_installed.ps1
Created July 11, 2017 09:57
Узнаем список установленного ПО через Powershell
# https://blogs.technet.microsoft.com/heyscriptingguy/2011/11/13/use-powershell-to-quickly-find-installed-software/
$computername=(get-childitem -path env:computername).value
$UninstallKey="SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
#$UninstallKey="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
$reg=[microsoft.win32.registrykey]::OpenRemoteBaseKey('LocalMachine',$computername)
$regkey=$reg.OpenSubKey($UninstallKey)
$subkeys=$regkey.GetSubKeyNames()
$array = @()
foreach($key in $subkeys){
@g3rhard
g3rhard / ConvertTo-Encoding.ps1
Created July 12, 2017 04:56
Конвертация вывода программы в Powershell
#Script by xaegr (https://xaegr.wordpress.com/2007/01/24/decoder/)
#usage:
# Get-Content notes.txt | ConvertTo-Encoding "windows-1251" "koi8-r" | Set-Content decoded.txt
# command | ConvertTo-Encoding cp866 windows-1251
function ConvertTo-Encoding ([string]$From, [string]$To){
Begin{
$encFrom = [System.Text.Encoding]::GetEncoding($from)
$encTo = [System.Text.Encoding]::GetEncoding($to)
}