Skip to content

Instantly share code, notes, and snippets.

Charles Crossan crossan007

Block or report user

Report or block crossan007

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:f04fd9caca244482272a2d627daae389
var webdriver = require('selenium-webdriver'),
By = webdriver.By,
until = webdriver.until;
var driver = new webdriver.Builder()
.forBrowser('chrome')
.build();
driver.get('http://www.webdriverjs.com/');
driver.findElement(By.css('.search-field.form-control')).sendKeys("WebdriverJs");
driver.findElement(By.css('button.search-submit i')).click();
driver.wait(until.elementTextIs(driver.findElement(By.css('.vl-main-header>h1')), "Search Results for: WebdriverJs"), 10000);
@crossan007
crossan007 / Prune-FileBeatRegistryFiles.ps1
Created Aug 14, 2019
"Prune" specific entries from a Filebeat 6.x registry JSON file
View Prune-FileBeatRegistryFiles.ps1
$ErrorActionPreference = "Stop"
Function Test-IISLogFile{
Param(
$FilePath
)
return $($FilePath -Like "*.com\Logs\*") -or $($FilePath -Like "*.com\Log\*")
}
Function Clean-FileBeatRegistry {
Param(
$RegistryFile
View Lock PC When webservice returns 1
'On Error Resume Next
do
Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
objHTTP.SetOption 2, objHTTP.GetOption(2) - SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS
objHTTP.Open "POST", "https://webserviceurl/shouldlock", False
objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
objHTTP.send ""
@crossan007
crossan007 / Get-LastLogLines.ps1
Created May 15, 2019
Gets the final lines of a really big log file, and outputs them to a smaller, more manageable log file
View Get-LastLogLines.ps1
Function Get-LastLogLines {
Param(
$FileName,
$Lines = 30
)
# Method borrowed and adapted from: https://stackoverflow.com/questions/36507343/get-last-n-lines-or-bytes-of-a-huge-file-in-windows-like-unixs-tail-avoid-ti
$result = ""
$seq = "`r`n"
$buffer_size = 10mb
$buffer = new-object Byte[] $buffer_size
@crossan007
crossan007 / README.md
Created Mar 5, 2019 — forked from metmajer/README.md
Ansible Logging To Elasticsearch
View README.md

Ansible Logging To Elasticsearch

Turns Ansible log outputs into plain JSON strings and sends them to an Elasticsearch cluster.

Place the script in your playbook's plugins/callbacks/ directory.

View MySQL ChurchCRM Event Recurrence Script
/* Add Recurring event, with a secondary calendar on the Third Tuesday of the Month */
DELIMITER $$
DROP PROCEDURE IF EXISTS create_events$$
CREATE PROCEDURE create_events()
BEGIN
DECLARE event_date DATETIME;
DECLARE event_end DATETIME;
DECLARE ocurrences INT;
DECLARE last_inserted INT;
DECLARE week_of_month DOUBLE;
@crossan007
crossan007 / Convert-TopToBranch.ps1
Last active Jul 23, 2018
Convert All Top-Level Folders in Git Repository to Independent Repositories
View Convert-TopToBranch.ps1
# This basically creates a fork-bomb where each forked process is splitting out one top-level folder
$MaxSimultaneousJobs = $(Get-WmiObjectclass Win32_processor).NumberOfCores * .5
Write-Host "Processing up to $MaxSimultaneousJobs at a time"
Get-ChildItem -Directory | Foreach-Object {
$FolderName = """$($_.Name)"""
$BranchName = $_.Name -Replace(' ','-')
while (@(Get-Job -State Running).Count -ge $MaxSimultaneousJobs) {
@crossan007
crossan007 / Tasks and Defaults.md
Last active Jul 11, 2018
Ansible Download Jenkins Artifact from API by Partial Filename Query
View Tasks and Defaults.md

Defaults

#Jenkins Query Params
JenkinsBaseURL: "https://jenkins.yourco.com"
JenkinsJobName: "<YOUR JOB NAME>"
JenkinsMultibranchPipelineBranchName: "master"
JenkinsBuildQuery: "(builds[?artifacts[?contains(fileName, '{{ArtifactDesiredVersion}}') == `true`]])[0]" # Partial artifact file name - this assumes your file names are unique per build
JenkinsBuild: "{{ (jenkins.content | from_json) | json_query(JenkinsBuildQuery) }}"
View keybase.md

Keybase proof

I hereby claim:

  • I am crossan007 on github.
  • I am crossan007 (https://keybase.io/crossan007) on keybase.
  • I have a public key ASBeYWUz3Uibu1jTf8gsXZzmm9rPqCUGaf2qhLnVh2cougo

To claim this, I am signing this object:

@crossan007
crossan007 / Resize-VBOXDisk.ps1
Created May 31, 2018
VirtualBox Resize Disk on VM
View Resize-VBOXDisk.ps1
$VMName = "MyCoolVM"
$NewDiskSize = 102400
$VBoxManage = 'C:\Program Files\Oracle\VirtualBox\VBoxManage.exe'
# Gather data from VBoxManage
$VBOXDrive = & $VBoxManage showvminfo $VMName | Select-String ".vmdk"
$RegEx = 'SATA \((\d),\s?(\d)\):\s?(.*?)\s\(UUID:(.*?)\)'
$M = [System.Text.RegularExpressions.Regex]::Matches($VBOXDrive,$RegEx)
$VMDK = $M.Groups[3].Value
You can’t perform that action at this time.