Skip to content

Instantly share code, notes, and snippets.

View jaywilliams's full-sized avatar
🌱
Waiting for Spring to begin...

Jay Williams jaywilliams

🌱
Waiting for Spring to begin...
View GitHub Profile
@jaywilliams
jaywilliams / convert_ascii.php
Created May 28, 2009 19:25
This simple function will remove any non-ASCII character. Feel free to fork and extend!
<?php
/**
* Remove any non-ASCII characters and convert known non-ASCII characters
* to their ASCII equivalents, if possible.
*
* @param string $string
* @return string $string
* @author Jay Williams <myd3.com>
* @license MIT License
* @link http://gist.github.com/119517
@jaywilliams
jaywilliams / gist:125557
Created June 8, 2009 01:06
Parse a string, and convert it into a series of sequential numbers.
<?php
/**
* Parse a string, and convert it into a series of sequential numbers.
* It works similar to Acrobat's print specified pages input box.
*
* Examples:
*
* input: "1, 2, 3, 4, 5, 6" --> output: 1, 2, 3, 4, 5, 6
* input: "1-6" --> output: 1, 2, 3, 4, 5, 6
<?php
/**
* @package shippingMethod
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: perweightunit.php 3308 2006-03-29 08:21:33Z ajeh $
*/
/**
* "Per Weight Unit" shipping module, allowing you to offer per-unit-rate shipping options
diff a/includes/modules/shipping/perweightunit.php b/includes/modules/shipping/perweightunit.php
94c94
< global $order, $shipping_weight;
---
> global $order, $shipping_weight, $shipping_num_boxes;
101,102c101,102
< 'cost' => (MODULE_SHIPPING_PERWEIGHTUNIT_COST * $total_weight_units)
< + MODULE_SHIPPING_PERWEIGHTUNIT_HANDLING)));
---
> 'cost' => ((MODULE_SHIPPING_PERWEIGHTUNIT_COST * $total_weight_units)
-- Get Wordpress posts that are within a specific date range
-- Useful for an events calednar.
SELECT wp_posts.ID, wp_posts.post_title, wp_posts.post_name, start.meta_value AS start_date, end.meta_value AS end_date
FROM wp_postmeta AS `end`
JOIN wp_postmeta AS `start` ON ( end.post_id = start.post_id )
JOIN wp_posts ON ( end.post_id = wp_posts.ID )
WHERE (
end.meta_key = "End Date"
AND end.meta_value >= DATE_FORMAT( NOW() , "%Y/%m/%d")
)
@jaywilliams
jaywilliams / array_to_object.php
Created December 16, 2009 04:57
Convert a multi-dimensional array into a stdClass object. Pass by reference.
<?php
/**
* Convert a multi-dimensional array into a stdClass object.
*
* Example:
* $values = array('hello'=>'world');
*
* // Convert the array to an object
* array_to_object($values);
*
@jaywilliams
jaywilliams / csv_to_array.php
Created April 30, 2010 23:18
Convert a comma separated file into an associated array.
<?php
/**
* Convert a comma separated file into an associated array.
* The first row should contain the array keys.
*
* Example:
*
* @param string $filename Path to the CSV file
* @param string $delimiter The separator used in the file
* @return array
@jaywilliams
jaywilliams / gist:979039
Last active May 18, 2023 16:13
Installing PHP 7.4.33 as CGI on *new* Pair Networks architecture
# Installing PHP 7.4.33 as CGI/FastCGI on a Pair Networks VPS
# By Jay Williams <http://myd3.com/>
# Based off of the Pair Users wiki page "Installing PHP5 as cgi" <http://www.pairusers.com/?How%20to%20install%20PHP5>
# Note: Replace "USERNAME" with your actual server username
# Make src directory in home
mkdir ~/src
# Download, configure, and compile OpenSSL
@jaywilliams
jaywilliams / example.html
Created July 25, 2011 20:07
IE Placeholder: A no-dependancy quick and dirty method of adding basic placeholder functionality to Internet Explorer 5.5+
<html>
<head>
<title>IE Placeholder Text</title>
</head>
<body>
<input type="text" name="myInputField" value="" placeholder="HTML5 Placeholder Text" id="myInputField">
<?php
/*****************************************
* Created this test for job interviews. *
*****************************************/
/**
* Directions
*
* Read the direction in the Q and respond below A.