Skip to content

Instantly share code, notes, and snippets.

View ifttt-after-dark.js
let openTime = new Date( MyqDevices.doorOpened.CreatedAt )
let sunriseAt = new Date( Weather.currentWeather[0].SunriseAt )
let sunsetAt = new Date( Weather.currentWeather[0].SunsetAt )
if ( openTime > sunriseAt && openTime < sunsetAt ) {
Wyzecam.plugTurnOn.skip()
}
@nullvariable
nullvariable / private-files.php
Created Sep 29, 2020
Private Files Example for Pantheon
View private-files.php
<?php
/**
* Plugin Name: Example Private Files
* Author: Doug Cone
* Description: Auth for Pantheon Private files
* Version: 0.1.0
*/
/**
* This doesn't protect direct access, you must move your files to a folder not accessible to the public, but accessible to this script.
@nullvariable
nullvariable / cache-aggressive-license-checks.php
Last active Oct 15, 2020
Make annoying WordPress plugins that constantly perform license checks in the admin behave.
View cache-aggressive-license-checks.php
<?php
/**
* Plugin Name: Cache Aggressive License Checks
* Description: Cache the license checks for plugins that are lame and check on every request.
* Author: Doug Cone
* Author URI: http://dougcone.com
* Version: 0.0.1
*
*/
@nullvariable
nullvariable / README.md
Last active Oct 25, 2019
Simple script to select browser
View README.md

Steps to get this working in Ubuntu 18.04

  • edit whichbrowser.sh as you see fit
    • handy way to see your Chrome profiles: cat ~/.config/google-chrome/Local\ State | jq .profile
  • copy whichbrowser.sh to /usr/local/bin/whichbrowser
  • copy whichbrowser.desktop to /usr/share/applications
  • edit /usr/share/applications/defaults.list to add whichbrowser.desktop to the same handlers as chrome/firefox
  • run sudo update-desktop-database
  • use Ubuntu settings -> Details -> Default Applications, to change default web browser to whichbrowser script
  • ???
  • profit
@nullvariable
nullvariable / example.css
Last active Oct 20, 2019
Create an image cap for Bootstrap 4 that aligns on the left side of a card
View example.css
.card-img-left {
border-bottom-left-radius: calc(.25rem - 1px);
border-top-left-radius: calc(.25rem - 1px);
float: left;
padding-right: 1em;
margin-bottom: -1.25em;
}
@nullvariable
nullvariable / pantheon.yml
Created Sep 20, 2019
Create symlinks with Quicksilver
View pantheon.yml
api_version: 1
workflows:
sync_code:
after:
- type: webphp
description: Create symlinks
script: private/symlinks.php
@nullvariable
nullvariable / functions.php
Created Aug 20, 2019
Remove query strings from WordPress static assets
View functions.php
<?php
function remove_query_strings() {
if(!is_admin()) {
add_filter('script_loader_src', 'strip_query_string', 15);
add_filter('style_loader_src', 'strip_query_string', 15);
}
}
function strip_query_string($src){
$output = preg_split("/(&ver|\?ver)/", $src);
@nullvariable
nullvariable / composer.json
Created May 7, 2019
Use typerocket with root composer.json
View composer.json
{
"require": {
"typerocket/core": "4.0.*"
},
"scripts": {
"typerocket-migrate": [
"php ./wp-content/mu-plugins/typerocket/galaxy migrate up"
]
}
}
@nullvariable
nullvariable / functions.php
Created Mar 12, 2019
don't send user count to wp.org stats.
View functions.php
<?php
add_filter( 'core_version_check_query_args', 'hide_stats', 99 );
function hide_stats( $query ) {
$query['blogs'] = 1;
$query['users'] = 1;
return $query;
}
@nullvariable
nullvariable / wp-cli.php
Last active Feb 27, 2019
use wp-cli as a proxy for typerocket galaxy commands
View wp-cli.php
<?php
if ( defined( 'WP_CLI' ) && WP_CLI ) {
\WP_CLI::add_command( 'galaxy', function () {
$count = count( $_SERVER['argv'] );
for ( $i = 0; $i < $count; $i++ ) {
// strip any preceeding arguments so galaxy isn't confused.
$arg = array_shift( $_SERVER['argv'] );
if ( 'galaxy' == $arg ) {
array_unshift( $_SERVER['argv'], 'galaxy' );
break;