Skip to content

Instantly share code, notes, and snippets.

View DrewDouglass's full-sized avatar
🤠

Drew Douglass DrewDouglass

🤠
View GitHub Profile
@DrewDouglass
DrewDouglass / dnd.sh
Created September 13, 2019 12:13
Toggle Do Not Disturb Mac OS Command Line
#!/bin/bash
# https://apple.stackexchange.com/a/303400
set -eou pipefail
# From https://heyfocus.com/enabling-do-not-disturb-mode and
# https://apple.stackexchange.com/questions/145487
if [[ $(defaults -currentHost read ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturb) -eq 0 ]]; then
@DrewDouglass
DrewDouglass / s3.sh
Created July 11, 2019 13:29
Download all files from s3 bucket to local machine
# Can also use --dryrun instead of --recursive to see what would have happened.
aws s3 cp s3://yourbucket/theoneyouwant/ ~/Desktop/bucket-backup --recursive
@DrewDouglass
DrewDouglass / s3_client.py
Created May 6, 2019 11:32 — forked from tamouse/s3_client.py
Example: An S3 proxy client written in Python
"""
The server application uses AWS S3 in various places.
This utility provides a common place for interacting
with S3 and handles the authentication in a unified manner.
"""
import os.path
import logging
@DrewDouglass
DrewDouglass / search_custom_columns.php
Created March 25, 2019 17:21
WordPress Admin area search custom columns
<?php
function cf_search_join( $join ) {
global $wpdb;
if ( is_search() ) {
$join .=' LEFT JOIN '.$wpdb->postmeta. ' ON '. $wpdb->posts . '.ID = ' . $wpdb->postmeta . '.post_id ';
}
return $join;
}
@DrewDouglass
DrewDouglass / getParams.js
Created December 5, 2018 17:14
jQuery get URL Param
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = window.location.search.substring(1),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
@DrewDouglass
DrewDouglass / findFonts.sh
Last active November 10, 2018 01:36
Find fonts used in PDF file on Mac OS
strings ~/Desktop/filename.pdf | grep FontName
@DrewDouglass
DrewDouglass / workaround-js.html
Last active January 30, 2019 21:49
Load scripts in webskins that do not load them
<!-- Assumes jQuery is loaded which is almost always the case -->
<img src="/your/image.jpg" alt="Logo" onload="$.getScript('https://yoursite.com/main.js');">
@DrewDouglass
DrewDouglass / scroll.js
Created November 8, 2018 19:47
Scroll to top - jQuery
$("a[href='#top']").click(function() {
$("html, body").animate({ scrollTop: 0 }, "slow"); //Can replace with milliseconds
return false;
});
@DrewDouglass
DrewDouglass / .htaccess
Created September 28, 2018 20:15
a2 redirect from ahosted subdomain
RewriteCond %{HTTP_HOST} !https://domainnamehere.org$ [NC]
RewriteRule ^(.*)$ https:// domainnamehere.org/$1 [R=301,L]
@DrewDouglass
DrewDouglass / target-ie-11.css
Created September 12, 2018 21:13
Target IE10 and 11 with media query
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
// IE10+ CSS here
}