Skip to content

Instantly share code, notes, and snippets.

View nickrouty's full-sized avatar

Nick Routsong nickrouty

  • Routy Development LLC
  • Arizona
View GitHub Profile
@nickrouty
nickrouty / rd-class-text-extraction.php
Created May 9, 2018 04:14
Class for extraction the text from doc, docx, xlsx, pptx and wrapper for 3rd party pdf to text library.
<?php
/**
* Class RD_Text_Extraction
*
* Example usage:
*
* $response = RD_Text_Extraction::convert_to_text($path_to_valid_file);
*
* For PDF text extraction, this class requires the Smalot\PdfParser\Parser class.
@nickrouty
nickrouty / example-ion-input-getInputElement.js
Created August 3, 2021 16:42
How to retrieve the native element underlying an IonInput component in React
const passwordInput = useRef<HTMLIonInputElement>(null);
passwordInput.current?.getInputElement().then( (element) => {
if ( element.value ) {
setPassword(element.value);
}
});
@nickrouty
nickrouty / import_non_existing_media_library_entries.php
Created September 17, 2015 18:23
Import Files into WordPress that aren’t in the Media Library
/*
* This function scans through all files in the wp-content/uploads
* folders and imports them into the media library. This should be
* included in your theme's functions.php file. Simply visit your
* website, including the URL param:
* http://www.example.org/?import_non_existing_media_library_entries=1
*
* Plan on it timing out a few times. Just keep refreshing. It won't
* duplicate files being imported.
*/
@nickrouty
nickrouty / functions.php
Created December 12, 2017 04:07
Filter/Customize the Order number for Chase Paymentech WooCommerce XML API Gateway by Routy Development to append the last 4 numbers of the WooCommerce Order ID.
function rd_set_custom_order_id_for_chase_paymentech( $order_id, $order ) {
return uniqid() . '-' . substr($order->get_id(), -4);
}
add_filter( 'chase_paymentech_gateway_transaction_order_id', 'rd_set_custom_order_id_for_chase_paymentech', 10, 2 );
class ExampleSingleton {
private $properties = array();
private static $instance;
private __construct(){}
public getInstance()
{
if (empty(self::$instance)) {
@nickrouty
nickrouty / palindrom-test.php
Created March 8, 2017 18:34
Palindrome or not?
<?php
$string = "madam";
$array = str_split($string);
$reverse_array = array_reverse( $array, true );
$new_string = implode('', $reverse_array);
echo "<pre>";
var_dump($array, $reverse_array);
echo ( $string === $new_string) ? "Yes, {$string} is a palindrome." : "No, {$string} is not a palindrome.";
@nickrouty
nickrouty / gist:5580174
Created May 14, 2013 22:26
Starting up with Marionette
$(function(){
window.AFA = {};
AFA.Models = {};
AFA.Collections = {};
AFA.Views = {};
AFA.Models.User = Backbone.Model.extend({
initialize: function(){
var devices = new AFA.Collections.Devices(this.get('devices'));
@nickrouty
nickrouty / Send HTML Email in PHP
Created May 6, 2013 16:35
Send HTML Email in PHP
$to = 'mail@example.com';
$from = 'you@example.com';
$reply_to = 'you@example.com';
$subject = 'Website Change Reqest';
$headers = "From: " . strip_tags($from) . "\r\n";
$headers .= "Reply-To: ". strip_tags($reply_to) . "\r\n";
$headers .= "CC: " . strip_tags($from) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
@nickrouty
nickrouty / config.xml
Created September 29, 2015 17:03
Example config.xml and index.html meta tag definition for Cordova app to handle Content Security Policy. Learn more: https://github.com/apache/cordova-plugin-whitelist#content-security-policy
<allow-navigation href="*" />
<allow-intent href="*" />
<access origin="*" />
@nickrouty
nickrouty / install-plugin-whitelist.txt
Created September 29, 2015 16:54
Force installation of Cordova Plugin Whitelist in order to work with Cordova iOS Platform 3.9.1
cordova plugin add cordova-plugin-whitelist@1.0.0