Skip to content

Instantly share code, notes, and snippets.

@bbhenry
bbhenry / script-template.sh
Created July 21, 2022 05:36 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
# Nginx proxy for Elasticsearch + Kibana
# If you use this, you'll want to point config.js at http://FQDN:80/ instead of
# http://FQDN:9200
server {
listen *:80 ;
server_name kibana.myhost.org;
access_log /var/log/nginx/kibana.myhost.org.access.log;
- name: Get instance ec2 facts
action: ec2_facts
register: ec2_facts
- name: Get resource tags from ec2 facts
sudo: false
local_action: ec2_tag resource={{ec2_facts.ansible_facts.ansible_ec2_instance_id}} region=us-east-1 state=list
register: result
- name: Create CPU utilization metric alarm
@bbhenry
bbhenry / grid-extra-node
Last active August 29, 2015 14:23
Selenium Grid Extra Node Boxstarter Script
Disable-UAC
if (Test-PendingReboot) { Invoke-Reboot }
Update-ExecutionPolicy Unrestricted
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar
Enable-RemoteDesktop
Disable-InternetExplorerESC
$seleniumGridPath = "c:\SeleniumGrid"
$seleniumGridExtraDownloadUrl = "https://github.com/groupon/Selenium-Grid-Extras/releases/download/1.10.0/SeleniumGridExtras-1.10.0-SNAPSHOT-jar-with-dependencies.jar"
input {
file {
path => [ "/var/log/messages", "/var/log/kern.log" ]
type => "linux-syslog"
}
file {
path => "/var/log/apache2/access.log"
type => "apache-access"
}
@bbhenry
bbhenry / benchmark.sh
Last active August 29, 2015 13:57 — forked from ochronus/commands.sh
# install sysbench
$ apt-get install sysbench
# CPU benchmark, 1 thread
$ sysbench --test=cpu --cpu-max-prime=20000 run
# CPU benchmark, 64 threads
$ sysbench --test=cpu --cpu-max-prime=20000 --num-threads=64 run
# Disk benchmark, random read. See .fio files in this gist
@bbhenry
bbhenry / bash_template
Last active January 2, 2016 21:29
bash script template
#!/bin/bash
PROGNAME=`basename $0`
CRIT=15
WARN=30
usage() {
echo "$PROGNAME -H <FQDN> [-c <15>] [-w <30>]"
echo "-H Mandatory, please put the fully qualified domain name for the SSL Certificate you want to monitor"
echo "-c Default 15, the number of days left before it alerts for Critical state"
@bbhenry
bbhenry / gist:6198584
Created August 10, 2013 01:21
Perl_test_exit_code
system();
if ($? == -1) {
print "failed to execute: $!\n";
} elsif ($? & 127) {
printf "child died - signal %d, %s coredump\n",
($? & 127), ($? & 128) ? 'with' : 'without';
} else {
printf "child exited with value %d\n", $? >> 8;
}
#!/usr/bin/perl
use strict;
use warnings;
use Selenium::Remote::Driver;
use Test::More;
my $driver = Selenium::Remote::Driver->new;
my $driver2 = Selenium::Remote::Driver->new(remote_server_addr=>'10.4.20.1');
@bbhenry
bbhenry / Perl_Selenium_example.pl
Created July 30, 2013 20:42
Perl_Selenium_example
#!/usr/bin/perl
use Selenium::Remote::Driver;
use Test::More tests=>4;
my $driver = Selenium::Remote::Driver->new;
$driver->get("http://www.google.com");
$driver->find_element('q','name')->send_keys("Hello WebDriver!");
ok($driver->get_title =~ /Google/,"title matches google");
is($driver->get_title,'Google',"Title is google");