Skip to content

Instantly share code, notes, and snippets.

View DineshSolanki's full-sized avatar
:octocat:
Looking for java roles

Dinesh Solanki DineshSolanki

:octocat:
Looking for java roles
View GitHub Profile
public static void showProgressWithETA(int current, int total, long startTime) {
long elapsedTimeMillis = System.currentTimeMillis() - startTime;
int percent = current * 100 / total;
int progress = percent / 2;
System.out.print("\r[");
for (int i = 0; i < progress; i++) {
System.out.print("\u001b[32m=\u001b[0m");
}
for (int i = progress; i < 50; i++) {
System.out.print(" ");
@DineshSolanki
DineshSolanki / remove_ansi.ps1
Created March 22, 2023 14:11
remove ansi escape codes from log files
# Get input path from user
$path = Read-Host "Enter file or folder path"
# Check if input path is a file or folder
if (Test-Path $path -PathType Leaf) {
# If path is a file, process it and save output to 'Cleaned' subdirectory
$outputPath = Join-Path (Split-Path $path) "Cleaned"
New-Item -ItemType Directory -Path $outputPath -Force
(Get-Content $path -Raw) -replace "\x1B\[[0-9;]*[mK]" | Set-Content (Join-Path $outputPath (Split-Path $path -Leaf))
} elseif (Test-Path $path -PathType Container) {
@DineshSolanki
DineshSolanki / remove_ansi.sh
Last active March 22, 2023 13:57
remove ansi escape code from log files
sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" input_file > output_file
(Get-Content input_file) -replace "\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "" | Set-Content output_file
@DineshSolanki
DineshSolanki / treat_http_as_secured.txt
Created March 24, 2022 05:15
Testing features that need HTTPS
To test features on any domain that needs HTTPS (Secured) connection -
enable these settings -
for chrome -go to chrome://flags/#unsafely-treat-insecure-origin-as-secure ->then enter domain and enable it
for firefox - go to about:config ->then enable -> media.getusermedia.insecure.enabled
@DineshSolanki
DineshSolanki / UpdateMultipleSVN.bat
Created March 16, 2022 10:06
Update multiple svn folders with batch file
REM originally found here - https://medium.com/tinywave/svn-automatic-update-using-batch-file-9eaf78f226b9
set CHECKOUTFOLDER=D:\folder1*D:\folder2
set SVNPATH=C:\Program Files\TortoiseSVN\bin
"%SVNPATH%\TortoiseProc.exe" /command:update /path:"%CHECKOUTFOLDER%" /closeonend:2
@DineshSolanki
DineshSolanki / GetCountryMobileNumberMask.cs
Created September 13, 2021 09:44
Get country mobile number mask using libphone
//https://www.nuget.org/packages/libphonenumber-csharp
public static string GetMobileMask(string regionCode) // "IN"
{
try
{
var exampleNumber = PhoneNumberUtil.GetExampleNumberForType(regionCode, PhoneNumberType.MOBILE);
var formattedNumber = PhoneNumberUtil.FormatNumberForMobileDialing(exampleNumber, regionCode, true)[1..];
var mask = Regex.Replace(formattedNumber, @"\d", "0"); //change 0 to whatever you want, my controls treats 0 as any digit
return mask; //"00000 0000"
}
@DineshSolanki
DineshSolanki / ZipExeInDirSeparately.ps1
Created August 4, 2021 16:09
This powershell scrip archives all exe present in directory to individual zip.
dir *.exe | ForEach-Object { & "$($env:ProgramFiles)\7-Zip\7z.exe" a -tzip "$($_.BaseName).zip" $_.Name }
#!/bin/bash
if [ $# -eq 0 ]; then
echo "No jira id provided"
exit 1
fi
nohup xdg-open http://jira.yourdomain.com/browse/${1}
#usage - openJira.sh jiraid
@DineshSolanki
DineshSolanki / backmerge.sh
Created May 23, 2021 11:26
Backmerge current branch with master/developer or any branch
#!/bin/bash
branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
IFS='/' read -r id bname <<< "$branch"
IFS='_' read -r id bname <<< "$bname"
git update-index -q --refresh
if ! git diff-index --quiet HEAD --; then
echo "Working directory not clean, please commit your changes first"
exit
fi
echo "-------------------------------------------------------------------------"
@DineshSolanki
DineshSolanki / gitcommit.sh
Created May 23, 2021 11:23
Extract and commit with jira ID in commit message if jira id exist in branch name
#!/bin/bash
if [ $# -eq 0 ]; then
echo "No commit message provided"
exit 1
fi
branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
IFS='/' read -r id bname<<< "$branch"
if test -z $bname
then
IFS='_' read -r id bname<<< "$branch"