Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
Tea, Earl Grey, hot.

Jeff Geerling geerlingguy

:shipit:
Tea, Earl Grey, hot.
View GitHub Profile
@geerlingguy
geerlingguy / pi-general-benchmark.sh
Last active Sep 12, 2020
Raspberry Pi Benchmark Suite - Phoronix
View pi-general-benchmark.sh
#!/bin/bash
#
# Benchmark script for Raspberry Pi OS.
#
# WARNING: This script is meant to be run as the root user.
# This script should never be run on a system/partition you
# care about. You should only run this on a system that you
# intend to use only for benchmarking and can reinstall or
# re-flash easily.
#
@geerlingguy
geerlingguy / pi-cpu-stress.sh
Last active Sep 12, 2020
Raspberry Pi CPU temperature and throttling test script
View pi-cpu-stress.sh
#!/bin/bash
# Raspberry Pi stress CPU temperature measurement script.
#
# Download this script (e.g. with wget) and give it execute permissions (chmod +x).
# Then run it with ./pi-cpu-stress.sh
# Variables.
test_run=1
test_results_file="/home/pi/cpu_temp_$test_run.log"
stress_length="10m"
@geerlingguy
geerlingguy / k8s-cluster-resources.sh
Created Feb 27, 2019
Monitor overall Kubernetes cluster utilization and capacity.
View k8s-cluster-resources.sh
#!/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 Aug 2, 2020
Ansible Role Test Shim Script
View ansible-role-test.sh
#!/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)
View commit-to-all.sh
#!/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.
@forairan
forairan / PhpJava.java
Last active Mar 14, 2020
This snippet of code is syntactically valid in both PHP and Java, and produces the same output in both.
View PhpJava.java
/*<?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 Aug 6, 2020
Create a time lapse video from a set of real-time dash cam clips.
View dashcam-time-lapse.sh
#!/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.
View yaml-object-example.yml
# 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 Apr 28, 2016
Acquia Cloud Site Factory Environment Detection
View acsf_environment_detection.php
<?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 Jan 10, 2016
JS bookmarklet - add an extra extension to the end of a domain
View extension-bookmarklet.js
function locationreplace(a, b) {
currentLocation = window.location.href;
newLocation = currentLocation.toString().replace(a, b);
document.location.href = newLocation;
}
locationreplace('.org', '.org.etc.etc');
You can’t perform that action at this time.