Skip to content

Instantly share code, notes, and snippets.

View stephenfeather's full-sized avatar

Stephen Feather stephenfeather

View GitHub Profile
@stephenfeather
stephenfeather / wordpress_sequence.php
Last active April 30, 2023 11:45
Wordpress function and action to list all hooks/action in sequence of excecution
# Courtesy of Prosti (https://wordpress.stackexchange.com/users/88606/prosti)
# Context (https://wordpress.stackexchange.com/a/250293/215668)
function _20161224_printer( $r ){
$line = microtime(true)*10000 . ' ' . $r . "\n";
$fp = fopen( ABSPATH . 'hooks.txt', 'a+');
fwrite($fp, $line);
fclose($fp);
@stephenfeather
stephenfeather / verify_attachment_url.sh
Created February 27, 2023 17:27
Bash script to deleted wordpress attachments that have a bad URL (WIP)
#!/usr/bin/bash
BASE_URL="https://myourdomain.com/files/"
# We need to be able to trap breakouts
trap exit_script INT
function exit_script() {
end=`date +%s.%N`
runtime=$( echo "$end - $start" | bc -l )
@stephenfeather
stephenfeather / wp-useful-sql-queries.txt
Last active December 23, 2022 16:02
Useful Raw SQL Queries for Wordpress
/*
This is a query to return a post.ID, post.post_title, and the SKU of
products that do not have an attached image. The vendor, as associated through
wp-all-import into an ACF field, can be adjusted as needed.
*/
USE featherarms;
SET @vendor = 'CSSI' COLLATE utf8mb4_unicode_ci;
SELECT fa_posts.ID, fa_posts.post_title, fa_postmeta1.meta_value as SKU
FROM fa_posts
LEFT OUTER JOIN fa_postmeta pm ON (fa_posts.ID=pm.post_id AND pm.meta_key = '_thumbnail_id')
@stephenfeather
stephenfeather / analytics.js
Created June 2, 2012 18:09
commonJS version of Roger Chapman's Google Analytics Library for Appcelerator's Titanium Mobile SDK
/*
The MIT License
Copyright (c) 2010 Roger Chapman
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@stephenfeather
stephenfeather / parse.js
Last active March 1, 2022 12:06
Quick library for using the Parse REST API within Appcelerator's Titanium. Building it out as I need different pieces of the API.
// Copyright Stephen Feather and other contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
@stephenfeather
stephenfeather / cleanup.zsh
Created April 21, 2019 00:49
Clean Up wasted space on osx
#!/usr/local/bin/zsh
echo "Updating Homebrew"
brew update
brew upgrade
brew cask upgrade
brew cleanup -s
brew doctor
brew missing
echo "Updating App Store Items"
mas outdated
@stephenfeather
stephenfeather / LatLon.js
Last active November 14, 2018 18:00
GeoTools we use in Appcelerator Titanium (sourced from Chris Veness) http://www.movable-type.co.uk/scripts/latlong.html
/*jslint vars: true, sloppy: true, nomen: true, maxerr: 1000 */
function LatLon(lat, lon, rad) {
if (typeof(rad) == 'undefined') rad = 6371; // earth's mean radius in km
// only accept numbers or valid numeric strings
this._lat = typeof(lat)=='number' ? lat : typeof(lat)=='string' && lat.trim()!='' ? +lat : NaN;
this._lon = typeof(lon)=='number' ? lon : typeof(lon)=='string' && lon.trim()!='' ? +lon : NaN;
this._radius = typeof(rad)=='number' ? rad : typeof(rad)=='string' && trim(lon)!='' ? +rad : NaN;
}
04d13ee4564f01142758f002d6b3069e7bfccf6d6ed92b8352e4782c9ceedddac7a38ed4109da157c27888d4318552a3738a07ef9910ebc9e8c1bbdfc56aea4e4a
@stephenfeather
stephenfeather / waze.js
Last active August 24, 2017 19:15
Appcelerator Titanium module for Waze
// Copyright Stephen Feather and other contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//