Skip to content

Instantly share code, notes, and snippets.

@iqbmo04
iqbmo04 / Get-MsdnKeys.ps1
Created May 18, 2019 05:01 — forked from Jaykul/Get-MsdnKeys.ps1
PowerShell + Selenium Demo: Getting Started, and reusing cookies with Invoke-Request
# It might work in 4, but I'm not testing there. Lower you'll have to tweak code
#requires -Version 5.0
param(
# Your Live ID for MSDN login
[Parameter(Mandatory)]
[PSCredential]
[System.Management.Automation.CredentialAttribute()]
$Credential,
# Pick a browser to use. Defaults to Firefox (which doesn't seem to require an external Driver file)
@iqbmo04
iqbmo04 / OutputCaptureTest.java
Created June 14, 2019 13:07 — forked from ClassCubeGists/OutputCaptureTest.java
Capturing stdOut and stdErr as part of a JUnit test. See https://classcube.com/junit-compare-output/ for explanations.
import java.util.*;
import java.io.*;
import static org.junit.Assert.*;
import org.junit.Test;
@SuppressWarnings( "unchecked" )
public class OutputCaptureTest {
private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
private final ByteArrayOutputStream errContent = new ByteArrayOutputStream();
@iqbmo04
iqbmo04 / encoding-helpers.ps1
Created June 25, 2019 20:44 — forked from jpoehls/encoding-helpers.ps1
Convert-FileEncoding and Get-FileEncoding
<#
.SYNOPSIS
Converts files to the given encoding.
Matches the include pattern recursively under the given path.
.EXAMPLE
Convert-FileEncoding -Include *.js -Path scripts -Encoding UTF8
#>
function Convert-FileEncoding([string]$Include, [string]$Path, [string]$Encoding='UTF8') {
$count = 0
@iqbmo04
iqbmo04 / ValidateXmlFile.ps1
Created July 3, 2019 12:34 — forked from DominicCronin/ValidateXmlFile.ps1
ValidateXmlFile: a powershell script for validating XML
function ValidateXmlFile {
param ([string]$xmlFile = $(read-host "Please specify the path to the Xml file"))
$xmlFile = resolve-path $xmlFile
"==============================================================="
"Validating $xmlFile using the schemas locations specified in it"
"==============================================================="
# The validating reader silently fails to catch any problems if the schema locations aren't set up properly
# So attempt to get to the right place....
pushd (Split-Path $xmlFile)
@iqbmo04
iqbmo04 / waitForKeyElements.js
Created August 6, 2019 09:23 — forked from BrockA/waitForKeyElements.js
A utility function, for Greasemonkey scripts, that detects and handles AJAXed content.
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
that detects and handles AJAXed content.
Usage example:
waitForKeyElements (
"div.comments"
, commentCallbackFunction
);
@iqbmo04
iqbmo04 / GetDuration.ps1
Created January 13, 2020 22:52 — forked from C2N14/GetDuration.ps1
[YouTube API V3] New simple Powershell script to get the duration of a YouTube video
#Powershell 4+
#Fix of ShinNoNoir's script that broke with the new API
#https://gist.github.com/ShinNoNoir/d59ca5da3cd5c554a832
function Get-VideoSeconds ([string]$VideoID){
$gdata_uri = "https://www.googleapis.com/youtube/v3/videos?id=$VideoId&key=<APIKEY>&part=contentDetails" #Replace <APIKEY>
$metadata = irm $gdata_uri
$duration = $metadata.items.contentDetails.duration;
$ts = [Xml.XmlConvert]::ToTimeSpan("$duration")
@iqbmo04
iqbmo04 / Wait.java
Created April 1, 2020 12:32 — forked from priyanshus/Wait.java
Wait until angular finishes $http calls in Selenium webdriver
/**
* Sometime it happens while automating the angular app, view gets loaded entirely but performing any action
* on that view fails the test. This could happen because angular $http calls are still pending in backend.
* We can have explicit wait in this way to ensure that angular has made all the $http calls.
* Wait until angular finishes the $http calls while loading the view
*/
public void waitForAngular() {
final String javaScriptToLoadAngular =
"var injector = window.angular.element('body').injector();" +
"var $http = injector.get('$http');" +
@iqbmo04
iqbmo04 / CrxWriter.java
Created April 29, 2020 08:43 — forked from manzke/CrxWriter.java
Creating Chrome Extensions (.crx) without Chrome and with Java - crxmake for Java
package de.devsurf.chrome.extensions;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.Signature;
@iqbmo04
iqbmo04 / mousemove.ps1
Created June 17, 2020 10:54 — forked from MatthewSteeples/mousemove.ps1
Powershell Script to keep the mouse moving
Add-Type -AssemblyName System.Windows.Forms
while ($true)
{
$Pos = [System.Windows.Forms.Cursor]::Position
$x = ($pos.X % 500) + 1
$y = ($pos.Y % 500) + 1
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point($x, $y)
Start-Sleep -Seconds 10
}
@iqbmo04
iqbmo04 / gist:9fbebc314a980f8b40a755ef11911963
Created June 19, 2020 11:34 — forked from SteveGilham/gist:98a39f621cfed70bfa0a
Another PowerShell egg-timer (using events)
<#
.SYNOPSIS
This script provides simple egg-timer like functionality.
.DESCRIPTION
This script counts down a time interval then speaks some text
.NOTES
File Name : Run-Timer.ps1
Requires : PowerShell Version 2.0