Skip to content

Instantly share code, notes, and snippets.

View sparkalow's full-sized avatar

Brian M. sparkalow

  • null
View GitHub Profile
@sparkalow
sparkalow / Unban ip with Fail2Ban
Last active September 4, 2015 16:04
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
@sparkalow
sparkalow / jq-ga-events.js
Last active September 27, 2019 04:17
jQuery Google Analytics Events
$('[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 / find-wide-dom-elements.js
Created April 27, 2016 16:31
Useful JS snippet for finding DOM elements wider than current viewport. Only tested in Chrome.
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 / list-files-in-folders.gs
Created September 21, 2016 17:42
Google Apps Script to recursively list files in a folder
/*
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 / wordpress-dump-posts-query-sql.php
Created October 12, 2016 14:34
Wordpress dump post query sql
function dump_request( $input ) {
var_dump($input);
return $input;
}
add_filter( 'posts_request', 'dump_request' );
@sparkalow
sparkalow / how-to-set-up-stress-free-ssl-on-os-x.md
Created October 12, 2017 18:18 — 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

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

@sparkalow
sparkalow / product.twig
Created December 9, 2021 18:48 — forked from piotrpog/product.twig
commerce product page with sprig
{% extends 'shop/_layouts/main' %}
{% block main %}
{{ sprig('product_content', {productId: product.id}) }}
{{ sprig.script }}
{% endblock %}
@sparkalow
sparkalow / xdebug.sh
Created March 18, 2022 22:11 — forked from carstenwindler/xdebug.sh
Bash script to quickly enable / disable xdebug in a PHP docker container
#!/usr/bin/env bash
# see https://carstenwindler.de/php/enable-xdebug-on-demand-in-your-local-docker-environment/
if [ "$#" -ne 1 ]; then
SCRIPT_PATH=`basename "$0"`
echo "Usage: $SCRIPT_PATH enable|disable"
exit 1;
fi
# Expects service to be called app in docker-compose.yml
@sparkalow
sparkalow / svg-symbal-usage.html
Created March 9, 2023 16:17
Using SVG symbol example
<!--
define symbol using <defs> tag, include viewBox attribute on symbol and visually hide the svg
multiple symobls can be defined with unique id's
-->
<svg xmlns="http://www.w3.org/2000/svg" hidden>
<defs>
<symbol id="logo-symbol" viewBox="0 0 341 127">
<path fill="#FFF" d="m136.3 60.1 8.3-59h19.2v85h-12.6V25.2l-.6-.1-9.2 60.9h-11.5l-9-59.6h-.5V86h-12.1V1h19.3l8.3 59.1h.4m145.1-2.5-5.6-39.7h-.5l-5.5 39.7h11.6Zm-15.7 28.5H253L266.8.8h18.5L299.2 86h-13.6l-2.5-16.4-14.9.1-2.5 16.4m-57.4 0h-36.4v-85h36.4v12h-22.9v22.2h18.1v12.6h-18v25.9h22.8v12.3Zm33.8 0h-13.6V13.3h-14V1.1h41.3v12h-13.7v73ZM319 73.8h21.7V86h-35.3V1H319v72.8ZM39.9 25.7H27c0-2.2.1-4.3 0-6.4-.2-3.8-2.4-5.9-5.9-6.1-3.7-.2-6.2 1.7-6.8 5.5-.8 5.1.7 9.6 4.2 13.4 2.8 3 5.9 5.8 9 8.7 5.3 5 10.7 10.1 11.9 17.5.8 4.9 1 10.1.2 14.9-1.4 8.5-7.5 13.5-16.3 14.2a35 35 0 0 1-9.7-.6c-5-1-8.7-3.9-10.9-8.5A33.4 33.4 0 0 1 .3 61.7h13v6.8c.2 4.5 2.4 6.8 6.5 6.9 4.1.1 6.3-1.9 6.9-6.4.7-5.7-1.1-10.6-5-14.6-3-3.1-6.2-5.8-9.3-8.8-5.3-5-10.3-10.4-