Skip to content

Instantly share code, notes, and snippets.

View geerlingguy's full-sized avatar
:shipit:
Tea, Earl Grey, hot.

Jeff Geerling geerlingguy

:shipit:
Tea, Earl Grey, hot.
View GitHub Profile
@geerlingguy
geerlingguy / k8s-cluster-resources.sh
Created February 27, 2019 23:54
Monitor overall Kubernetes cluster utilization and capacity.
#!/bin/bash
#
# Monitor overall Kubernetes cluster utilization and capacity.
#
# Original source:
# https://github.com/kubernetes/kubernetes/issues/17512#issuecomment-367212930
#
# Tested with:
# - AWS EKS v1.11.5
#
@geerlingguy
geerlingguy / ansible-role-test.sh
Last active January 18, 2024 17:37
Ansible Role Test Shim Script
#!/bin/bash
#
# Ansible role test shim.
#
# Usage: [OPTIONS] ./tests/test.sh
# - distro: a supported Docker distro version (default = "centos7")
# - playbook: a playbook in the tests directory (default = "test.yml")
# - role_dir: the directory where the role exists (default = $PWD)
# - cleanup: whether to remove the Docker container (default = true)
# - container_id: the --name to set for the container (default = timestamp)
#!/bin/bash
#
# Add a commit and push to origin for each 'geerlingguy.*'' Ansible role.
message="Remove sudo requirement from Travis build."
# Loop through all directories starting with "geerlingguy".
for dir in ./geerlingguy*/
do
# cd into role directory.
@avafloww
avafloww / PhpJava.java
Last active October 16, 2022 18:50
This snippet of code is syntactically valid in both PHP and Java, and produces the same output in both.
/*<?php
//*/public class PhpJava { public static void main(String[] args) { System.out.printf("/*%s",
//\u000A\u002F\u002A
class PhpJava {
static function main() {
echo(//\u000A\u002A\u002F
"Hello World!");
}}
//\u000A\u002F\u002A
PhpJava::main();
@geerlingguy
geerlingguy / dashcam-time-lapse.sh
Last active August 10, 2023 06:06
Create a time lapse video from a set of real-time dash cam clips.
#!/bin/bash
#
# Batch Time-Lapse creation script.
#
# This script can be used to speed up, trim, and finally concatenate tens or
# even hundreds of video clips, e.g. from a dash cam. You can do other things,
# too, but the main things this script does include:
#
# 1. Copy across and speed up video clips from an input dir to an output dir.
# 2. Trim off the first x frames of each of the copied/sped up clips.
# In YAML, this...
something:
- { name: test.example }
# ...is the same as this:
something:
- name: test.example
# And this:
something:
@geerlingguy
geerlingguy / acsf_environment_detection.php
Created April 28, 2016 15:18
Acquia Cloud Site Factory Environment Detection
<?php
/**
* Acquia Cloud Site Factory Environment detection examples.
*/
// This may require the ACSF module to be installed.
// @see https://www.drupal.org/project/acsf
$site settings = [
'site' => '',
'env' => '',
@geerlingguy
geerlingguy / extension-bookmarklet.js
Created January 10, 2016 03:08
JS bookmarklet - add an extra extension to the end of a domain
function locationreplace(a, b) {
currentLocation = window.location.href;
newLocation = currentLocation.toString().replace(a, b);
document.location.href = newLocation;
}
locationreplace('.org', '.org.etc.etc');
@geerlingguy
geerlingguy / post-slack-messages-on-interval.js
Created November 13, 2015 19:42
Post Slack messages on an interval - paste this into console on a Slack chat page
setInterval(function() {
jQuery('#message-input').val('ruby--');
jQuery('#message-form').submit();
jQuery('#message-input').val('game of shadows++');
jQuery('#message-form').submit();
}, 30 * 1000);
#!/usr/bin/env ruby
# Get passed in arguments
projectName = ARGV[0]
drupalVersion = ARGV[1]
vmRepo = 'https://github.com/geerlingguy/drupal-vm.git'
baseDirectory = '/#{Dir.home}/Sites/'
vmDirectory = baseDirectory + projectName + '_vm/'