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: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 / 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;
@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 / gist:4692466
Created February 1, 2013 16:40
Your problem with Vim is that you don't grok vi.

###Your problem with Vim is that you don't grok vi.

Source: http://stackoverflow.com/a/1220118/540977

You mention cutting with yy and complain that you almost never want to cut whole lines. In fact programmers, editing source code, very often want to work on whole lines, ranges of lines and blocks of code. However, yy is only one of many way to yank text into the anonymous copy buffer (or "register" as it's called in vi).

The "Zen" of vi is that you're speaking a language. The initial y is a verb. The statement yy is a synonym for y_. The y is doubled up to make it easier to type, since it is such a common operation.

This can also be expressed as dd P (delete the current line and paste a copy back into place; leaving a copy in the anonymous register as a side effect). The y and d "verbs" take any movement as their "subject." Thus yW is "yank from here (the cursor) to the end of the current/next (big) word" and y'a is "yank from here to the line containing

@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.
@jaywilliams
jaywilliams / .htaccess
Last active June 7, 2018 16:09
Magento 2 SSL Redirect Loop Fix (Apache + Varnish + Nginx)
# Add this to your the Magento .htaccess file located in your docroot
############################################
## Nginx proxy HTTPS Fix for Magento
## Source: https://www.sonassi.com/blog/magento-kb/magento-https-redirect-loop-2
SetEnvIf X-Forwarded-Proto https HTTPS=on