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 / gist:3035044
Created July 2, 2012 19:11
Auto-Install Sublime Text 2 Twig Bundle
curl https://nodeload.github.com/Anomareh/PHP-Twig.tmbundle/tarball/master | tar xvz -C ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/ && mv ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/Anomareh-PHP-Twig.tmbundle* ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/TWIG/
@jaywilliams
jaywilliams / xpath_escape.php
Created June 6, 2012 16:21 — forked from chrif/xpath_escape.php
Function to escape single and double quotes in XPath queries using PHP
<?php
function xpathEscape($query, $default_delim = '"')
{
if (strpos($query, $default_delim) === false)
return $default_delim . $query . $default_delim;
preg_match_all("#(?:('+)|[^']+)#", $query, $matches);
list($parts, $apos) = $matches;
foreach ($parts as $i => &$part) {
$delim = $apos[$i] ? '"' : "'";
$part = $delim . $part . $delim;
<?php
/*****************************************
* Created this test for job interviews. *
*****************************************/
/**
* Directions
*
* Read the direction in the Q and respond below A.
@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">
@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 / 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 / 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);
*
-- 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")
)
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)
<?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