Skip to content

Instantly share code, notes, and snippets.

View kyletaylored's full-sized avatar
🍝
unfurling wet spaghetti

Kyle Taylor kyletaylored

🍝
unfurling wet spaghetti
View GitHub Profile
@kyletaylored
kyletaylored / pantheon-mysql-dashboard-link.js
Last active March 23, 2020 17:34
Add MySQL link in Pantheon dashboard
@kyletaylored
kyletaylored / index.js
Created April 22, 2020 15:41
Alexa Parser
// Node script for extracting Alexa data
const path = require('path');
const fs = require('fs');
const flatten = require('flat');
const jsonexport = require('jsonexport');
// Get all files in the JSON directory
const directoryPath = path.join(__dirname, 'json');
// Passing directoryPath and callback function
@kyletaylored
kyletaylored / rename.py
Created May 11, 2020 16:16
Python renaming script (specific use case)
# Python 3 code to rename multiple
# files in a directory or folder
# importing os module
import os
from shutil import copyfile
# Function to rename multiple files
def main():
@kyletaylored
kyletaylored / ipinfo.py
Last active May 19, 2020 22:39
IPInfo script for GeoIP detection
import requests
from dotenv import load_dotenv
from netaddr import IPAddress
import os
import pickledb
import codecs
import csv
import argparse
from tqdm import tqdm
from pprint import pprint
<?php
print("\n==== WP-CFM Config Import Starting ====\n");
// Activate the wp-cfm plugin
exec('wp plugin activate wp-cfm 2>&1');
// Automagically import config into WP-CFM site upon code deployment
$env = (!empty($_ENV['PANTHEON_ENVIRONMENT']) && !in_array($_ENV['PANTHEON_ENVIRONMENT'], ['test', 'live'])) ? 'dev' : $_ENV['PANTHEON_ENVIRONMENT'];
$path = $_SERVER['DOCUMENT_ROOT'] . '/private/config/' . $env;
$files = array_diff(scandir($path), array('.', '..'));
@kyletaylored
kyletaylored / asynchronous-vs-parallel-bash-processes.markdown
Last active September 29, 2020 18:17
Asynchronous vs Parallel Bash Processes

Asynchronous vs Parallel Bash Processes

Problem

Terminus is a process-driven, Symfony console application that implements cURL requests using PHP in the background to the Terminus API. There are some performance bottlenecks in the current implementation:

  • Core (and contributed plugin) mass functions run commands serially, looping over a list of sites, and waiting for each site process to complete.
  • Terminus API implements request timeouts when too many requests are submitted at once (but does provide automated retries).
  • Terminus doesn't have a good dependency management system when creating new plugins.
@kyletaylored
kyletaylored / .gitignore
Last active November 20, 2020 06:03
Terminus Site Inventory
node_modules
<?php
/**
* This is a script to retrieve DB credentials for database connections
*
*/
/**
* Check IP address function
*/
function checkIPAddress() {
$allowed_ips_array = file(getcwd() . "/private/dbcr/allowed_ips.txt", FILE_IGNORE_NEW_LINES) or die("Unable to open ip list file!");
@kyletaylored
kyletaylored / package.json
Created July 12, 2021 14:56
Traffic simulator in a node script
{
"name": "traffic-simulator",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
@kyletaylored
kyletaylored / fetch.php
Created September 3, 2021 18:47
Simple PHP fetch command
/**
* Simple PHP Fetch command
*
* @param string $method
* @param string $url
* @param string $body
* @param array $headers
* @return void
*/
function fetch(string $method, string $url, string $body, array $headers = []) {