Skip to content

Instantly share code, notes, and snippets.

View nddipiazza's full-sized avatar

Nicholas DiPiazza nddipiazza

View GitHub Profile
@nddipiazza
nddipiazza / build.gradle
Created September 1, 2017 17:52
Gradle file for the headlessfirefox selenium example
group 'com.mozilla'
version '1.0'
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
@nddipiazza
nddipiazza / RemoteToGeckoServerHeadlessFirefoxSeleniumExample.java
Last active September 12, 2017 14:58
GeckoDriverService + Selenium RemoteDriver + Firefox Marionette - Not timing out
package com.mozilla.example;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.GeckoDriverService;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.service.DriverService;
import org.openqa.selenium.support.ui.WebDriverWait;
@nddipiazza
nddipiazza / javascript_timeout.html
Last active September 12, 2017 14:57
page that will hard loop in the <script> section.
<!DOCTYPE html>
<html>
<body>
<div id="container">Will never display</div>
<script>
while (true) {}
</script>
</body>
</html>
@nddipiazza
nddipiazza / test-sharepoint-user-query.ps1
Created October 23, 2017 14:04
This is a powershell script that can query sharepoint to get the Account and Name values for a user given the domain\username format of the user.
$sharepointSite = "http://102.15.12.153"
$loginUserName = "some-username"
$domain = "THEDOMAIN" # must be upper case
$userNameToQueryFor = "USERNAME-TO-QUERY-FOR" # must be upper case
$passwordSecure = Read-Host "What is $loginUserName's password?" -AsSecureString
$credential = New-Object –TypeName "System.Management.Automation.PSCredential" –ArgumentList $loginUserName, $passwordSecure
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $loginUserName,$passwordSecure)))
$response = Invoke-RestMethod -Method Get -Uri "$sharepointSite/_vti_bin/listdata.svc/UserInformationList?`$filter=substringof(%27$domain%5C$userNameToQueryFor%27%2Ctoupper(Account))%20eq%20true%20and%20ContentType%20eq%20%27Person%27" -Headers @{Authorization = "Basic $base64AuthInfo" } -Credential $credential -ContentType "text/xml"
$ns = @{d="http://schemas.microsoft.com/ado/2007/08/dataservices"}
@nddipiazza
nddipiazza / test-sharepoint-group-query.ps1
Last active October 23, 2017 18:30
This is a powershell script that can query sharepoint to get the Account and Name values for a group given the domain\username format of the user.
$sharepointSite = "http://102.15.12.153"
$loginUserName = "some-username"
$domain = "THEDOMAIN" # must be upper case
$groupNameToQueryFor = "GROUPNAME-TO-QUERY-FOR" # must be upper case
$passwordSecure = Read-Host "What is $loginUserName's password?" -AsSecureString
$credential = New-Object –TypeName "System.Management.Automation.PSCredential" –ArgumentList $loginUserName, $passwordSecure
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $loginUserName,$passwordSecure)))
$response = Invoke-RestMethod -Method Get -Uri "$sharepointSite/_vti_bin/listdata.svc/UserInformationList?`$filter=substringof(%27$domain%5C$groupNameToQueryFor%27%2Ctoupper(Name))%20eq%20true%20and%20ContentType%20eq%20%27DomainGroup%27" -Headers @{Authorization = "Basic $base64AuthInfo" } -Credential $credential -ContentType "text/xml"
$ns = @{d="http://schemas.microsoft.com/ado/2007/08/dataservices"}
@nddipiazza
nddipiazza / TestTimeout.java
Last active November 8, 2017 05:04
easier to see example of this
package test;
import org.junit.Assert;
import org.junit.Test;
import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@nddipiazza
nddipiazza / SpPrefetchIndexBuilder.cs
Created November 9, 2017 18:29
Simple sharepoint c# example
using System;
using System.Net;
using System.Security;
using Microsoft.SharePoint.Client;
namespace SpPrefetchIndexBuilder
{
class SpPrefetchIndexBuilder
{
public static string defaultSite = "http://localhost";
@nddipiazza
nddipiazza / grpc-ssl-setup.sh
Last active July 18, 2022 00:18
Simple bash script that sets up test certs for grpc
CN_NAME=localhost
# Certificate Authority
echo Generate CA key:
openssl genrsa -passout pass:1111 -des3 -out ca.key 4096
echo Generate CA certificate:
openssl req -passin pass:1111 -new -x509 -days 365 -key ca.key -out ca.crt -subj "/CN=${CN_NAME}"
# Server side key
echo Generate server key:
#!/bin/bash
echo -n Enter Sharepoint Username:
read sharepointUsername
echo -n Enter Sharepoint Password:
read -s sharepointPassword
echo ""
echo "Enter ADFS STS Trust endpoint (e.g. https://server.com/adfs/services/trust/2005/usernamemixed)"
read stsUrl
echo ""
uuid=$(uuidgen)
#!/bin/bash
echo -n "Enter sharepoint url (i.e. https://mytenant.sharepoint.com):"
read sharepointUrl
echo "Enter fedAuthToken (from logs): i.e. EgApAgMAAAAEgAAAAwAB ... wAAAAAAAA=="
read token
echo ""
curl -v -L -X POST \
"${sharepointUrl}/_forms/default.aspx?wa=wsignin1.0" \
-H 'Content-Type: application/soap+xml' \
-H 'Content-Length: 740' \