This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Bookmarklet to copy IP to clipboard with Multiple sources, Error handling and alerts | |
javascript:(function(){const ipServices=['https://api.ipify.org','https://icanhazip.com'];function fetchAndCopyIP(index=0){if(index>=ipServices.length){alert('Failed to retrieve IP from all sources.');return} | |
const url=ipServices[index];fetch(url).then(response=>{if(!response.ok){throw new Error(`Service ${url} failed with status: ${response.status}`)} | |
return response.text()}).then(ip=>{const trimmedIP=ip.trim();navigator.clipboard.writeText(trimmedIP).then(()=>{alert('IPv4 copied to clipboard: '+trimmedIP)}).catch(()=>{alert('Failed to copy IPv4 to clipboard. The IP is: '+trimmedIP)})}).catch(error=>{console.error(`Error fetching from ${url}:`,error);fetchAndCopyIP(index+1)})} | |
fetchAndCopyIP()})() | |
// Bookmarklet without alerts, silently copy IP to clipboard | |
javascript:(function(){const ipServices=['https://api.ipify.org','https://icanhazip.com'];function fetchAndCopyIP(index=0){if(index>=ipServices.length){console.error( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script to retrigger scripts if crashed | |
function trigger-script{ | |
#$proc = Start-Process notepad.exe -Passthru | |
$proc = Start-Process Powershell.exe -argument "C:\Scripts\Script_Name.ps1 ScriptArugments" -Passthru | |
return $proc | |
} | |
function check-process{ | |
[CmdletBinding()] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This method waits until page load is complete | |
* @author Naveenchandar | |
* | |
*/ | |
public static void waitForJavascript(WebDriver driver) { | |
JavascriptExecutor js = (JavascriptExecutor) driver; | |
int maxlimit = 10 * 1000; | |
boolean load = false; | |
try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.Robot; | |
import java.awt.event.KeyEvent; | |
/** Press Esc Key using Robot class **/ | |
public void pressEsc(WebDriver driver) { | |
try { | |
Robot robot = new Robot(); | |
robot.keyPress(KeyEvent.VK_ESCAPE); | |
robot.keyRelease(KeyEvent.VK_ESCAPE); | |
System.out.println("ESC Key pressed."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sleep(ms){ | |
return new Promise(resolve=>setTimeout(resolve,ms)) | |
}; | |
async function join(){ | |
var i = 0; | |
for(i = 0; i < 100; i++){ | |
document.getElementsByClassName('option active add login-required')[0].click(); | |
await sleep(500); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getElementsByXPath(xpath, parent) { | |
let results=[]; | |
let query = document.evaluate(xpath, parent||document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); | |
for(let i = 0,length = query.snapshotLength;i < length;++i){ | |
results.push(query.snapshotItem(i)); | |
} | |
return results | |
}; | |
items = getElementsByXPath("//*"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JavascriptExecutor js = (JavascriptExecutor) driver; | |
// Method 1 | |
String scrollElementIntoMiddle = "var viewPortWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);" + "var viewPortHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);" + "var elementTop = arguments[0].getBoundingClientRect().top;" + "var elementLeft = arguments[0].getBoundingClientRect().left;" + "jQuery('div').scrollTop(elementTop-(viewPortHeight/2));" + "jQuery('div').scrollLeft(elementLeft-(viewPortWidth/2));"; | |
js.executeScript(scrollElementIntoMiddle, element); | |
// Method 2 | |
String scrollElementWithVanillaJS = "arguments[0].scrollIntoView({behavior:\"smooth\", block:\"center\", inline:\"center\"});"; | |
js.executeScript(scrollElementWithVanillaJS, element); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set objShell = CreateObject("WScript.Shell") | |
X = objShell.Popup("Delay Windows Locking?", 10, "WinUnlock", vbYesNo) | |
Select Case X | |
Case vbYes | |
Do | |
objShell.SendKeys ("{F15}") | |
'MsgBox("Pressed F15 Key") | |
WScript.Sleep 5000 | |
Loop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.TimeUnit; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import org.apache.poi.xssf.usermodel.XSSFSheet; | |
import org.apache.poi.xssf.usermodel.XSSFWorkbook; | |
public class ExcelRead { | |
public static void disableWarning() { | |
System.err.close(); | |
System.setErr(System.out); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -- coding: utf-8 -- | |
from win32api import * | |
from win32gui import * | |
import win32con | |
import os | |
import time | |
class WindowsBalloonTip: |