Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@legovaer
legovaer / dsexec.sh
Created September 19, 2023 21:48
Bash script to run docker exec in a docker swarm environment
#!/bin/bash
set -e
SERVICE_NAME=$1; shift
DOCKER_CMD=docker
TASK_ID=$(${DOCKER_CMD} service ps --filter 'desired-state=running' $SERVICE_NAME -q)
NODE_ID=$(${DOCKER_CMD} inspect --format '{{ .NodeID }}' $TASK_ID)
CONTAINER_ID=$(${DOCKER_CMD} inspect --format '{{ .Status.ContainerStatus.ContainerID }}' $TASK_ID)
TASK_NAME=swarm_exec_${RANDOM}
@legovaer
legovaer / group-sonos-on-motion.yaml
Last active December 19, 2023 08:38
Home Assistant Blueprint that joins and leaves Sonos speakers on motion
blueprint:
name: Group Sonos on Motion
description: >
# Group Sonos on Motion
**Version: 1.0**
Group a Sonos device to a main device when presence (e.g. motion) is detected and the main device is playing music.
Can be extended with custom conditions, for example, only group the Sonos when you're not asleep.
@legovaer
legovaer / gist:90e502f3ea63d4708d8115b8929fd63a
Created March 7, 2023 23:09
LINUX COVER YOUR TRACKS COMMANDS
```bash
echo "" /var/log/auth.log - Clear auth.log file
echo '''' -/.bash history - Clear current user bash history
rrn -/.bash histor/ -rf - Delete .bash_history file
history -c - Clear current session history
export HISTFILESIZE=O - Set history max lines to 0
export HISTSIZE=O - Set history max commands to 0
unset HISTFILE - Disable history logging (need to logout to take effect)
kill -9 $$ - Kills current session
@legovaer
legovaer / scan-vpcs.py
Created August 26, 2022 08:14
Python script that collects data about your AWS VPCs. This can be used to determine if you have VPCs that are no longer used.
import boto3
import sys
import csv
import ipaddress
def describe_regions(session):
try:
aws_regions = []
ec2_client = session.client('ec2')
response_regions = ec2_client.describe_regions()['Regions']
@legovaer
legovaer / phpunit.xml
Created April 24, 2017 13:43
PHPUnit configuration to use for docker4drupal
<?xml version="1.0" encoding="UTF-8"?>
<!-- TODO set checkForUnintentionallyCoveredCode="true" once https://www.drupal.org/node/2626832 is resolved. -->
<!-- PHPUnit expects functional tests to be run with either a privileged user
or your current system user. See core/tests/README.md and
https://www.drupal.org/node/2116263 for details.
-->
<phpunit bootstrap="tests/bootstrap.php" colors="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
Date: 2015-05-20 - Wednesday - 9:36am PST - This readme was ported from a [google docs collaborative draft](https://docs.google.com/document/d/1SwH_y4kZyMa_8FlucGOaEdGzFBGp2wB3pAgoLsWEs8s/edit#).
# DrupalCI Testbot
---
#### Contents
`Ctrl-f` for these topic headings or use a markdown renderer to use them as anchor links.
- [Project Synopsis](#synopsis)
- [What are we doing here?](#what)
diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh
index df61328..72df950 100755
--- a/core/scripts/run-tests.sh
+++ b/core/scripts/run-tests.sh
@@ -19,6 +19,10 @@
$autoloader = require_once __DIR__ . '/../../autoload.php';
+$path = getenv('HOME') . '/.composer/vendor/legovaer/phpcov-runner/lib';
+set_include_path(get_include_path() . PATH_SEPARATOR . $path);
diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh
index df61328..72df950 100755
--- a/core/scripts/run-tests.sh
+++ b/core/scripts/run-tests.sh
@@ -19,6 +19,10 @@
$autoloader = require_once __DIR__ . '/../../autoload.php';
+$path = getenv('HOME') . '/.composer/vendor/legovaer/phpcov-runner/lib';
+set_include_path(get_include_path() . PATH_SEPARATOR . $path);
diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh
index 30b3aab..02bd2a9 100755
--- a/scripts/run-tests.sh
+++ b/scripts/run-tests.sh
@@ -12,6 +12,10 @@ define('SIMPLETEST_SCRIPT_EXIT_SUCCESS', 0);
define('SIMPLETEST_SCRIPT_EXIT_FAILURE', 1);
define('SIMPLETEST_SCRIPT_EXIT_EXCEPTION', 2);
+$path = getenv('HOME') . '/.composer/vendor/legovaer/phpcov-runner/lib';
+set_include_path(get_include_path() . PATH_SEPARATOR . $path);
diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh
index df61328..2b18c3e 100755
--- a/core/scripts/run-tests.sh
+++ b/core/scripts/run-tests.sh
@@ -17,6 +17,10 @@
use Drupal\simpletest\TestDiscovery;
use Symfony\Component\HttpFoundation\Request;
+$path = __DIR__ . "/../vendor/phpunit/phpcov/src/lib";
+set_include_path(get_include_path() . PATH_SEPARATOR . $path);