Skip to content

Instantly share code, notes, and snippets.

Avatar

Brian Mathews sparkalow

View GitHub Profile
@sparkalow
sparkalow / how-to-set-up-stress-free-ssl-on-os-x.md
Created Oct 12, 2017 — forked from jed/how-to-set-up-stress-free-ssl-on-os-x.md
How to set up stress-free SSL on an OS X development machine
View how-to-set-up-stress-free-ssl-on-os-x.md

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

View wordpress-dump-posts-query-sql.php
function dump_request( $input ) {
var_dump($input);
return $input;
}
add_filter( 'posts_request', 'dump_request' );
@sparkalow
sparkalow / list-files-in-folders.gs
Created Sep 21, 2016
Google Apps Script to recursively list files in a folder
View list-files-in-folders.gs
/*
Recusrsively add a list of files from a named foler to a sheet
*/
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var searchMenuEntries = [{
name: "Create List from Folder",
functionName: "start"
}];
@sparkalow
sparkalow / find-wide-dom-elements.js
Created Apr 27, 2016
Useful JS snippet for finding DOM elements wider than current viewport. Only tested in Chrome.
View find-wide-dom-elements.js
var els = document.querySelectorAll('*');
var l = els.length;
var maxWidth = window.innerWidth;
console.log('Elements wider than ' + maxWidth);
for(var i = 0 ; i < l; i ++){
var e = els[i];
var width =e.offsetWidth;
rect = e.getBoundingClientRect();
if(rect.width > maxWidth){
@sparkalow
sparkalow / jq-ga-events.js
Last active Sep 27, 2019
jQuery Google Analytics Events
View jq-ga-events.js
$('[data-ga-event]').on('click',function (event ) {
var $el = $(this);
var category = $el.data('ga-event'),
action =$el.data('ga-action'),
label = $el.data('ga-label');
ga('send', 'event', category, action, label);
});
@sparkalow
sparkalow / Unban ip with Fail2Ban
Last active Sep 4, 2015
Unban ip with Fail2Ban
View Unban ip with Fail2Ban
##get list of jails
fail2ban-client status
# fail2ban-client set [jail-name] unbanip [ip]
fail2ban-client set ssh-iptables unbanip 104.130.138.247