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 / 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],
@chrdek
chrdek / DS0103EN-1-1-1-From-Problem-to-Approach-v2.0.ipynb
Created September 12, 2020 08:40
Created on Skills Network Labs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chrdek
chrdek / gpioterm.sh
Last active August 15, 2020 17:24
Terminate process for pins from shell
#!/bin/bash
GPIO_PIN=10
# stop gpio pins, relevant cmd process
ctrl_c() {
echo "0" > "/sys/class/gpio/gpio${GPIO_PIN}/value"
echo $GPIO_PIN > /sys/class/gpio/unexport
exit
}
@chrdek
chrdek / Gen-Human-Read-Pass.ps1
Created August 15, 2020 02:39
Several methods to generate passwords with powershell
<# Methods for generating secure passwords with various types of security #>
# Password length 10, alphanumeric with symbols
$var = @("a","f","G","A","4""\","$","0","1","9","4","2",":F","3","..>","5","m","'","<",".","k","8","7","i",";","K","l","=","+"); $output="";
0..10 | %{ $output+=$var[$(Get-Random -Maximum 10)]; }
# Password length 10, SHA-256 derived OTP
(Get-Random) > "./tempcode.hash"; "$($((Get-FileHash -Path "./tempcode.hash").Hash)[0..10] + '')"-replace " ",([String]::Empty);