Skip to content

Instantly share code, notes, and snippets.

@andreasbotsikas
andreasbotsikas / Program.cs
Created December 15, 2016 01:33
Sync folders by copying only new files, ignoring moved files on target path
class Program
{
static void Main(string[] args)
{
var fromPaths = ConfigurationManager.AppSettings["FromPath"].Split(';');
var toPaths = ConfigurationManager.AppSettings["ToPath"].Split(';');
if (fromPaths.Length != toPaths.Length)
{
throw new ApplicationException(string.Format("From paths must be equal to to paths. Got {0} from and {1} to", fromPaths.Length, toPaths.Length));
@andreasbotsikas
andreasbotsikas / ProcessImages.bat
Created December 15, 2016 01:39
Optimize images using node.js and smushit
@REM Note that it doesn't like spaces in the names
npm install --global gulp-cli
npm install gulp-smushit
gulp
@andreasbotsikas
andreasbotsikas / Backup-AzureAPIM.ps1
Last active May 10, 2019 14:01
Azure API Management backup automation
<#
.SYNOPSIS
This Azure Automation runbook automates Azure API Management backup to Blob storage and deletes old backups from blob storage.
.DESCRIPTION
You should use this Runbook if you want manage Azure API Management backups in Blob storage.
This is a PowerShell runbook, as opposed to a PowerShell Workflow runbook.
It requires AzureRM.ApiManagement module to be installed.
The script uses the AzureRunAsConnection connection to login and perform the backup.
# To log in as root user first we have to enable it, to do so type the following command whilst logged in as the default pi user:
sudo passwd root
# Disable autologin
raspi-config
reboot
# And then logout back in as the user 'root' using the password you just created. Now we can rename the the default pi user name. The following method renames the user 'pi' to 'newname', replace this with whatever you want. Type the command:
usermod -l newname pi
# Now the user name has been changed the user's home directory name should also be changed to reflect the new login name:
usermod -m -d /home/newname newname
# Now logout and login back in as newname. You can change the default password from raspberry to something more secure by typing following command and entering a new password when prompted:
@andreasbotsikas
andreasbotsikas / GeneratePfxAndSnkFile.ps1
Created January 21, 2020 19:17
Generate pfx and snk file to sign an SQL CLR assembly
$solutionName="SampleDll"
$pfxPassword="password"
$pvkFilePath="$PSScriptRoot\$($solutionName)Key.pvk"
$cerFilePath="$PSScriptRoot\$($solutionName)Key.cer"
$pfxFilePath="$PSScriptRoot\$($solutionName)Key.pfx"
$snkFilePath="$PSScriptRoot\$($solutionName)Key.snk"
if (![System.IO.File]::Exists($pfxFilePath)){
@andreasbotsikas
andreasbotsikas / ConfigureExplorerView.ps1
Last active February 21, 2020 12:38
Powershell scripts to run on a new vm
$UserKey = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
# Show hidden items
Set-ItemProperty -Path $UserKey -Name "Hidden" -Value 1
Set-ItemProperty -Path $UserKey -Name "ShowSuperHidden" -Value 2
# Show file extensions
Set-ItemProperty -Path $UserKey -Name "HideFileExt" -Value 0
# Launch to PC view
Set-ItemProperty -Path $UserKey -Name "LaunchTo" -Value 1
Stop-Process -Name Explorer
@andreasbotsikas
andreasbotsikas / Vob2Mp4.bat
Last active August 2, 2024 13:56
Convert DVD to mp4 using ffmpeg
REM Download ffmpeg from https://www.ffmpeg.org/download.html.
REM Place ffmpeg.exe in the folder with the vob files
REM Merge all vob files into one
REM VTS_01_0.VOB is usually the menu which you may not want
if exist VTS_01_7.VOB (
copy /b VTS_01_1.VOB+VTS_01_2.VOB+VTS_01_3.VOB+VTS_01_4.VOB+VTS_01_5.VOB+VTS_01_6.VOB+VTS_01_7.VOB ConCat.vob
) else if exist VTS_01_6.VOB (
copy /b VTS_01_1.VOB+VTS_01_2.VOB+VTS_01_3.VOB+VTS_01_4.VOB+VTS_01_5.VOB+VTS_01_6.VOB ConCat.vob
) else if exist VTS_01_5.VOB (
@andreasbotsikas
andreasbotsikas / Configure_proxy.bat
Created September 20, 2020 15:57
Set proxy for cmd.exe
Rem Based on https://stackoverflow.com/questions/26992886/set-proxy-through-windows-command-line-including-login-parameters
set HTTP_PROXY=http://proxy_userid:proxy_password@proxy_ip:proxy_port
set FTP_PROXY=%HTTP_PROXY%
set HTTPS_PROXY=%HTTP_PROXY%
@andreasbotsikas
andreasbotsikas / Remove-Unknown-Locale.ps1
Created December 24, 2020 12:22
Remove qaa-Latn unknown locale
# First add it to the list (it is not there initially)
$LanguageList = Get-WinUserLanguageList
$LanguageList.Add("qaa-latn")
Set-WinUserLanguageList $LanguageList -Force
# Refresh the list (may not be needed)
$LanguageList = Get-WinUserLanguageList
# Get reference to the locale we want to remove
$Language = $LanguageList | where LanguageTag -eq "qaa-Latn"
$LanguageList.Remove($Language)
Set-WinUserLanguageList $LanguageList -Force
@andreasbotsikas
andreasbotsikas / encode.bat
Created December 30, 2020 15:36
Encode mts video to mp4
@REM Note that we scale down the video to 720p. Expect 200Mb to be converted into 70Mb. 1M in mpeg is too broken so we selected 5M
ffmpeg.exe -i original_video.mts -filter:v scale=720:-1 -vcodec mpeg4 -b:v 5M -acodec libmp3lame -b:a 128k output_video.mp4