Skip to content

Instantly share code, notes, and snippets.

View supermarsx's full-sized avatar
👾

supermarsx

👾
  • Portugal
  • 02:44 (UTC +01:00)
View GitHub Profile
@supermarsx
supermarsx / Get-WebminPortAlt1.sh
Created July 19, 2020 21:35
Linux Webmin, Get webmin configured port, alternative 1
netstat -teplnu | grep perl
@supermarsx
supermarsx / Restart-ExchangeServicesForce.ps1
Created July 21, 2020 01:22
Exchange 2013 Shell, Force exchange services to restart
$services = Get-Service | ? { $_.name -like "MSExchange*" -and $_.Status -eq "Running"}
foreach ($service in $services)
{
Restart-Service $service.name -Force
}
@supermarsx
supermarsx / Get-ComponentStateRequesterSpecific.ps1
Created July 21, 2020 01:28
Exchange 2013 Shell, Get list of specific component state requesters
$SERVERNAME = "SERVERNAME"
$COMPONENT = "ServerWideOffline"
(Get-ServerComponentState -Identity $SERVERNAME -Component $COMPONENT).LocalStates
@supermarsx
supermarsx / Get-ComponentStateRequesterAll.ps1
Created July 21, 2020 01:30
Exchange 2013 Shell, Get list of all component state requesters
$SERVERNAME = "SERVERNAME"
(Get-ServerComponentState -Identity $SERVERNAME).LocalStates
@supermarsx
supermarsx / trimChar.js
Created September 10, 2020 12:26
Trims a given char from a string bounds
/*
trimChar
Trims a specific char from bounds of variable
parameters
string (string) - String to be trimmed
charToRemove (char) - Char to be removed from string
*/
function trimChar(string, charToRemove) {
while (string.charAt(0) == charToRemove) string = string.substring(1);
while (string.charAt(string.length - 1) == charToRemove) string = string.substring(0, string.length - 1);
@supermarsx
supermarsx / padInteger.js
Created September 10, 2020 12:29
Pads an integer with leading zeros
/*
padInteger
Pads an integer with leading zeros
parameters
n (integer) - Integer to be padded
width (integer) - Padding width
z (string) - Character to pad integer with, default is '0'
*/
function padInteger(n, width, z) {
z = z || '0';
@supermarsx
supermarsx / waitForJqueryInjection.js
Created September 10, 2020 12:59
Waits for jQuery injection with puppeteer
/*
waitForJqueryInjection
Waits for jQuery injection with puppeteer
parameters
page (object) - Puppeteer page object
*/
async function waitForJqueryInjection(page) {
// Waiting for jQuery injection
console.log('Waiting for jQuery injection > (page)');
const watchDog = page.waitForFunction('window.jQuery !== undefined');
@supermarsx
supermarsx / delayScript.js
Last active September 10, 2020 16:21
Delays script execution for a given amount of milliseconds
/*
delayScript
Delays script execution
parameters
time (integer) - Time to delay scripts execution
*/
async function delayScript(time) {
return new Promise(function(resolve) {
setTimeout(resolve, time);
});
@supermarsx
supermarsx / pageSimpleScriptInjection.js
Created September 10, 2020 16:27
Simple page script injection with puppeteer
/*
pageSimpleScriptInjection
Simple page script injection with puppeteer
parameters
page (object) - Puppeteer page object
*/
async function pageSimpleScriptInjection(page, scriptName) {
scriptName = scriptName || "injectedScript.js";
// Adding injectedScript.js
console.log(`Adding ${scriptName} > (page)`);
@supermarsx
supermarsx / getNamedIframe.js
Last active September 11, 2020 11:55
Returns a named iframe handle with puppeteer
/*
getNamedIframe
Returns a named iframe handle with puppeteer
parameters
page (object) - Puppeteer page object
iframeName (string) - iframe name
*/
async function getNamedIframe(page, iframeName) {
iframeName = iframeName || 'main';
// Identify frame