Skip to content

Instantly share code, notes, and snippets.

View chrdek's full-sized avatar
♻️
Fully reCaptcha resistant....

ChrDek chrdek

♻️
Fully reCaptcha resistant....
  • Ham
  • Bacon
View GitHub Profile
@chrdek
chrdek / timer_display.ps1
Created November 13, 2021 11:52
Make a real-time progress bar using powershell. example for 2000 ms
$elapsedTime = [system.diagnostics.stopwatch]::StartNew()
# change value for other timer durations.
1..2000 | %{write-progress -activity "Working..." -status "$([string]::Format("Time Elapsed: {0:d2}:{1:d2}:{2:d2}", $elapsedTime.Elapsed.hours, $elapsedTime.Elapsed.minutes, $elapsedTime.Elapsed.seconds))" -percentcomplete ($_/10);}
$elapsedTime.stop()
@chrdek
chrdek / PS_login_with_Screenshot.ps1
Last active July 31, 2023 19:45
Automated testing for login screen - login to website/take screenshot with watermark
<#
#
# Initial login flow for website image to be generated
# ->Open main website
# -> Open login form
# -> login to website main part, click on a 'specific' button
# -> take screenshot of whole website part, logout and close browser window.
#
# NOTE: screenshot is watermarked with a timestamp (time/date) and an MD5 digest
#
@chrdek
chrdek / Chrome_Downgrade.ps1
Last active March 15, 2021 12:18
Script for uninstall, downgrade chrome to earlier versions, locks future updates.
<#
# chrome_downgrade.ps1
#
# Script used for downgrading current chrome installation to earlier instances (recommended up to v83+).
#
# Used for renaming current system configuration and sets
# appropriate setting for using chrome with older version.
#
# WARNING: This script also will disable any future updates on chrome
# so that the downgraded version is locked to the latest installation.
@chrdek
chrdek / PS_selen_test_run_v1.ps1
Created March 1, 2021 18:20
Automated tests runs for website (using Selenium PS)
Import-Module "$($($env:PSModulePath -split ';')[2])\Selenium\3.0.1\Selenium.psd1" -Force
$Browser = Start-SeChrome -Arguments @("Incognito","start-maximized");
Enter-SeUrl "http://intranet.test.site.net" -Driver $Browser
# Main login form.
$txtuname = Find-SeElement -Driver $Browser -By Name -Selection "username";
Send-SeKeys -Element $txtuname -Keys "usename1pass1";
$txtpassword = Find-SeElement -Driver $Browser -By Name -Selection "password";
Send-SeKeys -Element $txtpassword -Keys "onetimepass1pass2";
@chrdek
chrdek / PS_attachment.ps1
Created February 10, 2021 23:16
Create save a new draft email message with attachment using powershell
<#
Create a new email -with attachment- in outlook and save draft.
#>
$OL = New-Object -ComObject Outlook.Application
Start-Sleep 5
#Create Mailbox Item
$mItem = $OL.CreateItem(0);
#Add Messages etc..
@chrdek
chrdek / zip_files.bat
Last active February 21, 2023 23:57
Various data compression methods for file archiving using 7z, other programs
:: Method 1 (Zip compression using 15 passes with deflate)
"%PROGRAMFILES%\7-Zip\7z.exe" a -mm=Deflate -mfb=258 -mpass=15 -r "%USERPROFILE%\Downloads\samples1.zip" "%USERPROFILE%\Downloads\zipfiles\*"
1294MB -> 1192 MB (7.9% compression)
:: Method 2 (Zip compression using max compression with deflate)
"%PROGRAMFILES%\7-Zip\7z.exe" a "%USERPROFILE%\Downloads\samples1.zip" "%USERPROFILE%\Downloads\zipfiles\*" -tzip -mx9 -mm=Deflate64
1294 MB -> 1189 MB (8.2% compression)
@chrdek
chrdek / Wipe-Data.ps1
Last active January 3, 2021 13:07
Confidential files data wipe using various data shredding methods.
<#
.SYNOPSIS
** USE AT OWN RISK AND WITH CAUTION **
Function used for byte-level information scrambling for most files (For example: zip,documents,plain text or pdf).
.DESCRIPTION
** USE AT OWN RISK AND WITH CAUTION **
This function provides various methods of destroying the contents of a file, rendering it unreadable.
It can either be used on text or other types of data file formats.
Methods of removing data include XOR directly bytes in file, removing data by using source-dest. files
@chrdek
chrdek / Modify_xls.ps1
Last active December 26, 2020 16:24
Add daily tasks in excel - with SIG (with DD/MM/YYYY)
Function Modify-Excel([switch]$addSheet) {
$defaultdir = "$env:USERPROFILE\Documents\Spreadsheet_1.xlsx";
$xls = New-Object -ComObject Excel.Application; $xls.Visible = $false;
$xlShiftDown = -4121;
$fileModify = $xls.Workbooks.Open($defaultdir);
# select latest/current working month ..
$spreadSheet = $fileModify.ActiveSheet; # $fileModify.Worksheets | ?{ $_.Name -ilike "*2020" } | Select -Last 1
@chrdek
chrdek / b64Enc_Dec.js
Created November 5, 2020 09:23
base64 encode, decode
//Extend the String object with toBase64() and fromBase64() functions
//ES6..
String.prototype.toBase64 = function() {
var basechars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
return [...this].map(c=>c.charCodeAt()).map(n=> {
return ((+n).toString(2).length < 8) ? "0".repeat(8-(+n).toString(2).length)+(+n).toString(2)
:(+n).toString(2);
}).join("")
.replace(/(\d)(?=(?:\d{6})+$)/g,"$1 ")
.split(" ")
@chrdek
chrdek / 12hr_to_24hr.js
Created October 12, 2020 17:54
Time Converter function (12Hr-24Hr format) using Javascript
// This oneliner function converts 12-Hour time into its 24-Hour counterpart.
// Examples (hh:mm:ss(PM/AM) to HH:MM:ss(24hour):
// 12:00PM ->12:00, 12:00AM->00:00, 04:00PM -> 16:00
function timeConversion(s) {
return (s.includes("PM")) ?
(s.replace(s.split(':')[0],(s.startsWith("12"))?s.split(':')[0]:(Number(s.split(':')[0])+12)+"")).replace("PM","") :
(s.replace(s.split(':')[0],
(s.startsWith("12"))?(s.split(':')[-1])||"00":s.split(':')[0])
.replace(s.split(':')[0],