Skip to content

Instantly share code, notes, and snippets.

View joey-g's full-sized avatar

Joey Gryder joey-g

View GitHub Profile
@joey-g
joey-g / git_branch_prune.rb
Last active April 23, 2021 17:22
Git Branch Pruning Utility
def get_all_branches
value = `git branch --list`
value.split("\n")
end
def parse_branch_name(branch_name_line)
branch_name_line.match(/^(\*\s)?(\s{2})?(.*)$/i).captures.last
end
def print_branch_names(branch_names)
@joey-g
joey-g / WaitUntil.cs
Created August 20, 2018 18:00
WaitUntil.cs
private void WaitUntil(Action assertion, int timeoutMillis)
{
var cancelTokenSource = new CancellationTokenSource(timeoutMillis);
var token = cancelTokenSource.Token;
var t = Task.Factory.StartNew(() =>
{
while (true)
{
try
@joey-g
joey-g / nettiers-diff.js
Last active August 7, 2018 16:06
Remove all config/proj/sln/refresh files from PR diffs including Nettiers changes
$$('.file-info').forEach(fileInfo => {
const trimName = fileInfo.textContent.trim().toLowerCase();
const excludeSuffixes = ['.csproj', 'packages.config', 'app.config', 'production.config', 'qa.config', 'dll.refresh', '.sln', 'assemblyinfo.cs'];
const shouldDelete = excludeSuffixes.find(s => trimName.endsWith(s));
if (shouldDelete) { fileInfo.closest('.js-file').remove(); }
});
@joey-g
joey-g / update_add_hash_array.rb
Created May 7, 2018 13:05
Update / Add hash to array
def get_default_features
[
{'name' => 'Feature1', 'enabled' => true},
{'name' => 'Feature2', 'enabled' => true}
]
end
# Param will be in the shape:
# {'name': 'FeatureName', 'enabled': true/false}
def set_feature(original_feature_set, feature_to_set)
@joey-g
joey-g / control_ecs_asg.py
Last active February 28, 2018 17:57
ECS/ASG Startup Script
import boto3
import sys
import time
# Script param validation.
def validate_params():
param_error_found = False
if len(sys.argv) < 3:
param_error_found = True
if sys.argv[1].lower() not in ['qa0', 'qa1', 'qa2', 'qa3', 'qa4', 'qa5', 'qa6', 'qa7', 'qa8', 'qa9', 'qa10']:
@joey-g
joey-g / headless-wd-example.es6
Last active April 26, 2024 23:17
Headless Chrome - WebDriver Example
// https://developers.google.com/web/updates/2017/04/headless-chrome
const fs = require('fs');
const {Builder, By, Capabilities, Key, until} = require('selenium-webdriver');
const chromedriver = require('chromedriver');
const chromeCapabilities = Capabilities.chrome();
chromeCapabilities.set('chromeOptions', {args: ['--headless']});
async function test() {
// Note: On macOS, you'll likely see a new Chrome process flash on your 'Dock'
// when this new driver object is built. As it's launched headlessly, it's
@joey-g
joey-g / svc.rb
Created February 17, 2017 04:41
Modular Sinatra
require 'sinatra/base'
require 'rack'
# http://recipes.sinatrarb.com/p/embed/event-machine
class WebService < Sinatra::Base
def initialize(test_obj)
super()
@test_obj = test_obj
end
@joey-g
joey-g / todo_items.rb
Created March 27, 2015 16:49
Automation Training Week 8
class TodoItem
attr_reader :name
attr_accessor :status
def initialize(arg1)
@name = arg1
@status = false
end
@joey-g
joey-g / google_search_example.rb
Created March 2, 2015 17:39
Automation Training Week 4
require 'selenium-webdriver'
begin
driver = Selenium::WebDriver.for :chrome
driver.get 'http://google.com'
search_input_field = driver.find_element(:id => 'lst-ib') # Returns an instance/object of the WebElement class.
search_input_field.send_keys('Ryan Buff')
ensure
driver.quit
@joey-g
joey-g / webdriver_api_example.rb
Created February 20, 2015 16:46
Automation Training Week 3
# WebDriver API Examples
driver = WebDriver.new('Chrome')
# Example of sending keystrokes to an input field.
input_el = driver.find_element(<some_input_selector_goes_here>) # <-- Returns an instance of the WebElement class.
input_el.send_keys('Hey') # <-- Sends keystrokes to the retrieved input WebElement object.
# Example of clicking a button.
button_el = driver.find_element(<some_button_selector_goes_here>) # <-- Returns an instance of the WebElement class.
button_el.click() # <-- Clicks the retrieved button WebElement object.