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 / requirements.txt
Last active April 17, 2018 20:11
Python script to extract content types from a Drupal 7 sitemap.xml.
tqdm==4.19.5
requests==2.18.4
beautifulsoup4==4.6.0
PyYAML==3.12
@kyletaylored
kyletaylored / dom-loaded-test.html
Last active September 17, 2018 21:10 — forked from passcod/dom-loaded-test.html
onload, readyState, and DOMContentLoaded
<!DOCTYPE html>
<html>
<head>
<script>
window.onload = function () {
console.log(''+(+new Date)+': Onload fired');
};
document.onreadystatechange = function () {
console.log(''+(+new Date)+': Ready state changed');
@kyletaylored
kyletaylored / lift-example.js
Last active October 2, 2018 21:10 — forked from monan/www.crozerkeystone.org.user.js
Acquia Lift API example
// ==UserScript==
// @name www.crozerkeystone.org
// @namespace https://www.crozerkeystone.org/
// @version 0.1
// @description Implements Acquia Lift
// @author Mike Monan
// @match *://www.crozerkeystone.org/*
// @grant none
// @xrequire https://code.jquery.com/jquery-latest.js
// @copyright 2017 acquia.com
@kyletaylored
kyletaylored / app.js
Last active October 4, 2018 21:17
Venom extractor
const cheerio = require('cheerio')
const fetch = require('node-fetch')
// Main function to run.
async function main(url) {
// Fetch URL, log content
await fetch(url)
.then(resp => {
resp.text().then(body => {
@kyletaylored
kyletaylored / drupalvm-setup.sh
Last active October 18, 2018 14:32
A shell script to help set up a standard DrupalVM project
#!/bin/bash
# Get project directory and git url
echo "Project code (used for project directory name):"
read project_code
echo "Project repo git url (can be blank):"
read project_git_url
# Clone DrupalVM
git clone git@github.com:geerlingguy/drupal-vm.git $project_code
@kyletaylored
kyletaylored / swap.sh
Last active December 10, 2018 16:53
Docksal swap file command to increase swap size for Composer issues (beta)
#!/usr/bin/env bash
set -e # Abort if anything fails
echo "Checking current swap space..."
fin exec free -h
# Increase swap memory
echo "Creating 512M swap file..."
fin exec sudo dd if=/dev/zero of=/swapfile bs=1M count=512
@kyletaylored
kyletaylored / get_loc.js
Last active February 8, 2019 18:07
Get public ip location data using jQuery or Vanilla JS
// jQuery
(function($) {
$(document).ready(() => {
$.get("https://ipinfo.io/json").done((loc) => {
console.log(loc);
});
})
})(jQuery);
// Fetch (VanillaJS)
@kyletaylored
kyletaylored / loader.js
Last active February 14, 2019 00:53
Load scripts with JS
// Load JS function
var loadJS = function(url, callback){
var scriptTag = document.createElement('script');
scriptTag.src = url;
scriptTag.onload = callback;
scriptTag.onreadystatechange = callback;
document.body.appendChild(scriptTag);
};
// Load CSS function
@kyletaylored
kyletaylored / parser.php
Created April 19, 2019 14:25
Sitemap XML De-duplicator
<?php
$xml=simplexml_load_file("sitemap.xml") or die("Error: Cannot create object");
$storage = [];
$xmltxt = fopen("xml.txt", "w");
$count = $skipped = 0;
// Normalize and remove duplicates.
foreach ($xml as $sxe) {
$count++;
$loc = strtolower($sxe->loc);
@kyletaylored
kyletaylored / go.sh
Created April 22, 2019 22:44
Combine access.log files and run GoAccess report at the same time.
input="goaccess.log"
output="goaccess.html"
touch $input
for var in "$@"
do
cat $var >> $input
done
goaccess $input -o $output --log-format=COMBINED