Skip to content

Instantly share code, notes, and snippets.

After over a decade, I think it's time for a new avatar!

Jay Williams jaywilliams

After over a decade, I think it's time for a new avatar!
View GitHub Profile
jaywilliams / gist:125557
Created Jun 8, 2009
Parse a string, and convert it into a series of sequential numbers.
View gist:125557
* 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
View gist:193690
* @package shippingMethod
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license 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
View gist:193693
diff a/includes/modules/shipping/perweightunit.php b/includes/modules/shipping/perweightunit.php
< global $order, $shipping_weight;
> global $order, $shipping_weight, $shipping_num_boxes;
< 'cost' => (MODULE_SHIPPING_PERWEIGHTUNIT_COST * $total_weight_units)
> 'cost' => ((MODULE_SHIPPING_PERWEIGHTUNIT_COST * $total_weight_units)
View gist:228383
-- 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 )
end.meta_key = "End Date"
AND end.meta_value >= DATE_FORMAT( NOW() , "%Y/%m/%d")
jaywilliams / xpath_escape.php
Created Jun 6, 2012 — forked from chrif/xpath_escape.php
Function to escape single and double quotes in XPath queries using PHP
View xpath_escape.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 / gist:3035044
Created Jul 2, 2012
Auto-Install Sublime Text 2 Twig Bundle
View gist:3035044
curl | 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 / gist:4692466
Created Feb 1, 2013
Your problem with Vim is that you don't grok vi.
View gist:4692466

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


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 / example.html
Created Jul 25, 2011
IE Placeholder: A no-dependancy quick and dirty method of adding basic placeholder functionality to Internet Explorer 5.5+
View example.html
<title>IE Placeholder Text</title>
<input type="text" name="myInputField" value="" placeholder="HTML5 Placeholder Text" id="myInputField">
View deploy.rb
set :repo_url, ''
set :application, ''
set :theme_name, 'sage'
# Branch options
# Prompts for the branch name (defaults to current branch)
#ask :branch, -> { `git rev-parse --abbrev-ref HEAD`.chomp }
# Hardcodes branch to always be master
# This could be overridden in a stage config file
View test_php_skill.php
* Created this test for job interviews. *
* Directions
* Read the direction in the Q and respond below A.
You can’t perform that action at this time.