Skip to content

Instantly share code, notes, and snippets.

View stephenfeather's full-sized avatar

Stephen Feather stephenfeather

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / dangerous.txt
Last active May 13, 2023 00:59
Bash script to remove/replace a prefix from woocommerce products
UPDATE wp_postmeta
SET meta_value = REPLACE(meta_value, 'FA-', '')
WHERE meta_key = '_sku'
AND meta_value LIKE 'FA-%'
ORDER BY post_id DESC
LIMIT 10000;
@stephenfeather
stephenfeather / wp_url_import.sh
Created May 15, 2023 13:45
Bash script to serve an asset url w/ optional params to remote wordpress setup for importation via wp_cli - b7cd9ff84718d3ca7fca26ebb60e765d1a0a8d5642722db795522e99a6759a90
#!/bin/bash
#
# upload_and_run.sh
# Author: Stephen Feather
# Copyright (c) 2023 Stephen Feather
# License: CC BY-SA 4.0
if [ -z "$1" ]; then
echo "Error: URL argument is required."
@stephenfeather
stephenfeather / NimbusPlus.xml
Last active June 2, 2023 14:42
Controller mapping file for Steelseries Nimbus+ and Farming Simulator 2019 (MacOS/OSX) - On some older macs the productID and vendor ID show as 000 so an alternate file is available.
<deviceMapping backends="rawInput;directInput;macosXSdl">
<productKey productId="1422" vendorId="1038" />
<productName vendorId="1038">
<keyword text="nimbus+" />
</productName>
<category>gamepad</category> <!-- gamepad, wheel, joystick, farmWheel, farmSidePanel -->
<buttonMappings>
<buttonMapping physical="0" logical="0" label="A" />
<buttonMapping physical="1" logical="1" label="B" />
<buttonMapping physical="2" logical="2" label="X" />
@stephenfeather
stephenfeather / parseFFL.php
Created June 28, 2023 14:37
A PHP function to parse a Federal Firearms License (FFL) number
/**
* Parses the FFL number and extracts relevant information.
*
* @param string $fflNumber The FFL number to parse.
* @return array An array containing the parsed FFL information or an error object.
* If parsing is successful, the array will have the following keys:
* - ffl_number: The full FFL number.
* - region: The region of the FFL.
* - irs_district: The IRS district of the FFL.
* - fips_code: The FIPS code of the FFL.