Skip to content

Instantly share code, notes, and snippets.

View mdunham's full-sized avatar
:bowtie:
#OverReacted

Matthew Dunham mdunham

:bowtie:
#OverReacted
View GitHub Profile
@mdunham
mdunham / status-check.js
Created March 10, 2018 15:54
Quick 200/404/500 http status checker for WHM
var urlList = [], xmlhttp = [null, null];
[].map.call(document.querySelectorAll('#listaccts tr'), function(e){
var
domain = e.querySelector(':scope a[title^="Browse to the"]'),
username = e.querySelector(':scope > td:nth-child(5)'),
account = [];
if (username) account.push(username.innerText);
if (domain) account.push(domain.getAttribute('href'));
@mdunham
mdunham / cakephp-date-to-input-converter.js
Created March 18, 2018 11:33
Convert cakephp 3 date time select inputs into html5 date and time inputs
/**
Takes this output from CakePHP:
<div class="row">
<div class="col-md-2">
<select name="scheduled_start[year]" class="form-control"><option ...></select>
</div>
<div class="col-md-2">
<select name="scheduled_start[month]" class="form-control"><option ...></select>
@mdunham
mdunham / FPM-Pool-Tool.js
Created March 26, 2018 10:29
This will allow you to easily change all of the PHP FPM Pool settings for all the domains you have running it on the WHM MultiPHP Manager.
/**
* To use just login to your WHM and go to MultiPHP Manager.
* This is where all FPM pool options are defined. Just copy the code below
* and paste it into your browsers dev tools console.
*
* To change the FPM Pool confs after you've pasted the code into your console and pressed enter to run it.
* You can then tell it to change the confs here is the code to execute the process:
*
* Documentation: window.setFpmPools('[MAX CLIENTS]', '[IDEL TIMEOUT]', '[MAX REQUESTS]');
* Real Example: window.setFpmPools( '5' , '15' , '100' );
@mdunham
mdunham / fa-select.js
Created August 14, 2018 18:14
Creates a dropdown that allows you to select a font awesome icon. Just put an input on the page with an id of icon and load this gist.
/**
* FontAwesome Selection Input
*
* This will extend a select input into a font awesome icon selector.
*
* @author Matthew Dunham <[email protected]>
* @copyright Hot Coffey Design 2018 - http://hotcoffeydesign.com/
*/
(function($){
@mdunham
mdunham / mapper.js
Created September 24, 2018 21:46
Messing up geo mapper
function calcCrow(lat1, lon1, lat2, lon2) {
var R = 6371; // km
var dLat = toRad(lat2 - lat1);
var dLon = toRad(lon2 - lon1);
var lat1 = toRad(lat1);
var lat2 = toRad(lat2);
var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(lat1) * Math.cos(lat2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));