Skip to content

Instantly share code, notes, and snippets.

Guy Elsmore-Paddock GuyPaddock

View GitHub Profile
@GuyPaddock
GuyPaddock / kubectl_timeout_evade_trick.sh
Created Jun 17, 2020
Keeping a long-running command going without interruption through kubectl exec through timeouts
View kubectl_timeout_evade_trick.sh
# This trick keeps the kubectl session active by printing the current time every 10 seconds
#
# Run commands like this
(while true; do sleep 10; date; done) & <YOUR LONG RUNNING COMMAND GOES HERE>
# For example:
(while true; do sleep 10; date; done) & sha512sum my_super_large_file.dat | tee checksum.sha512
# When done, to get control back, run this command:
fg
@GuyPaddock
GuyPaddock / password.txt
Created May 16, 2020
Technicolor CGA4234 VGW Default Password
View password.txt
The default username and password for a Technicolor CGA4234 VGW from AtlanticBBInc is "user" with no password.
@GuyPaddock
GuyPaddock / 01-test-failing.php
Last active May 1, 2020
Why does this script lose CSV rows when three concurrent processes are run? Test.csv has an additional column added in Excel. It's TRUE when two rows are sequential.
View 01-test-failing.php
<?php
// Run this command in three separate consoles, concurrently.
// - Run the first with php -f ./test.php 1
// - Run the second with php -f ./test.php 2
// - Run the second with php -f ./test.php 3
$prefix = $argv[1];
for ($value = 0; $value < 1000; ++$value) {
$sleep_amount = rand(50000, 250000);
@GuyPaddock
GuyPaddock / sample.js
Last active Feb 29, 2020
Converting an Array or jQuery Object to NodeList (from https://stackoverflow.com/a/13363526/4342230)
View sample.js
var tagAttribute = 'data-tag-for-query';
$(elements).each(function() {
$(this).attr(tagAttribute, 'true');
});
var nodes = document.querySelectorAll('[' + tagAttribute + '="true"]');
Array.prototype.forEach.call(nodes, function(node) {
$(node).removeAttr(tagAttribute);
@GuyPaddock
GuyPaddock / more_advanced_js.html
Last active Jan 18, 2020
Simple HTML + JS Examples
View more_advanced_js.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My Slightly More Advanced Page</title>
</head>
<body>
<h1>A Slightly More Advanced Simple Page</h1>
<p id="my_paragraph"></p>
@GuyPaddock
GuyPaddock / results.txt
Created Dec 30, 2019
How array_merge() compares to the + operator when working with different array types
View results.txt
On PHP 7.2.24-0ubuntu0.18.04.1 (cli) (built: Oct 28 2019 12:07:07) ( NTS ):
Result of combining:
Array
(
[0] => 1
[1] => 2
[2] => 3
)
...with:
@GuyPaddock
GuyPaddock / results.txt
Last active Dec 18, 2019
How array_reduce() and array_map() Behave with Associative Arrays in PHP
View results.txt
On PHP 7.2.24-0ubuntu0.18.04.1 (cli) (built: Oct 28 2019 12:07:07) ( NTS ):
Array
(
[a] => ABC: 1
[b] => ABC: 2
)
,1,2
@GuyPaddock
GuyPaddock / results.txt
Last active Dec 18, 2019
How Static Variables Work with Inheritance in PHP
View results.txt
On PHP 7.2.24-0ubuntu0.18.04.1 (cli) (built: Oct 28 2019 12:07:07) ( NTS ):
ClassA = 1576680836
ClassA = 1576680836
ClassA = 1576680838
ClassA = 1576680838
ClassA = 1576680840
ClassA = 1576680840
ClassX = 1576680842
@GuyPaddock
GuyPaddock / resurrect.php
Last active Sep 18, 2019
Resurrecting an Unsaved Drupal 8 Node from the Database using Devel
View resurrect.php
<?php
// NOTE: Node previews expire after 7 days. Be sure to use this method to extract the desired data before then.
// IMPORTANT: Set this to the user ID of the person who was creating/lost the node.
$user_id = 1;
// IMPORTANT: Set this to the UUID that appeared in the node preview URL.
// This value is from a URL that looked like this:
// https://my-site/node/preview/ed4eaac0-3c32-427e-860f-6ce8fc79c3b2/full
$preview_id = 'ed4eaac0-3c32-427e-860f-6ce8fc79c3b2';
@GuyPaddock
GuyPaddock / array_contains.sh
Created Jul 2, 2019
Check if a value is in an array in Bash
View array_contains.sh
##
# Determine if a given element exists in an array.
#
# Based on:
# https://stackoverflow.com/a/11525897/4342230
#
# @param string $1
# The value to look for (the "needle").
# @param string... $2...
# The array of values to search (the "haystack").
You can’t perform that action at this time.