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 / 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));
@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 <matt@hotcoffeydesign.com>
* @copyright Hot Coffey Design 2018 - http://hotcoffeydesign.com/
*/
(function($){
@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 / 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 / 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 / Google-Hmmm.js
Last active July 19, 2019 22:55
Who wants to know what Google is up to? X-D
/* _GlobalPrefix_ */
this.gbar_ = this.gbar_ || {};
(function(_) {
var window = this;
/* _Module_:syf */
try {
var Gk = function(a) {
if (a instanceof _.ue)
return a;
if ("function" == typeof a.oc)
@mdunham
mdunham / Delete-All-LinkedIn-Messages.js
Created January 4, 2018 04:07
I got tired of manually deleting messages on LinkedIn so I created this little gem. It adds a delete all messages button for your LinkedIn inbox. Just like my delete all Facebook messages script. :-) Enjoy!
/**
* Delete all LinkedIn Messages Bookmark
* Create a new bookmark in your bookmark bar named: Clean LinkedIn Inbox
* Set the url of the bookmark to everything the code below on line 7
*/
javascript:(function(b,c){var d=0,f=function(){var k=b('a[href^="/messaging/thread/"]',!0);k[d]?(k[d].click(),setTimeout(g,c)):(console.log('All Done :)'),location.reload())},g=function(){var k=h,l=b('a[title="Show conversation details"]');l?l.click():(d++,k=f),setTimeout(()=>k(),c)},h=function(){var k=b('[data-control-name="clear_conversation"]');k&&k.click(),setTimeout(j,c)},j=function(){var k=b('[data-control-name="clear_conversation_confirm"]');k&&k.click(),setTimeout(f,c)};f()})(function(b,c){return c?document.querySelectorAll(b):document.querySelector(b)},1000);
// Now you can navigate to your linkedin.com inbox and then
// click your new bookmark to begin cleaning your inbox.
@mdunham
mdunham / angular.io-service-worker.js
Last active November 28, 2017 04:44
This is a very interesting piece of obfuscation that I found as Angular.IO's service worker.
!function() {
"use strict";
function t(t) {}
function e(t, e, n, r) {
void 0 === r && (r = !0);
var i = 3
, o = function(e) {
if (0 === i--)
return Promise.reject("Hit redirect limit when attempting to fetch " + e + ".");
var n = t.adapter.newRequest(e);
@mdunham
mdunham / bash-cheatsheet.sh
Created November 11, 2017 22:20 — forked from hnq90/bash-cheatsheet.sh
Bash CheatSheet for UNIX Systems
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
@mdunham
mdunham / update-dns-serials.sh
Created October 6, 2017 20:40
Mass update all DNS zones and set new serial using find and replace
# Backup
cp -rpf /var/named /var/named.backup
# Find and Replace
replace "find_something" "replace_with" -- /var/named/*.db
# Generate New Serial
grep "serial, todays" /var/named/*.db | sed "s/://g" | cut -d/ -f4 | awk {'system("replace "$2" "strftime("%Y%m%d")"00 -- /var/named/"$1)'}