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 / 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 / Twilight Terminal Theme.mdown
Created August 1, 2012 16:41
Twilight Theme Terminal Colors

Twilight Theme Terminal Colors

Based on the timeless TextMate theme.

Basic Colors

Foreground:     #FEFFD3

Background: #141414

@jaywilliams
jaywilliams / convert.php
Last active April 13, 2023 04:23
# Convert a QuickBooks QBXML Report to HTML/CSV File # I created this little script to help me read through the raw XML responses from QuickBooks. I originally built it to export to a CSV file, but found that a simple HTML table was better suited for my usage. However, I've included the CSV code below for anyone who may need that functionality. …
<?php
/**
* Convert a QuickBooks QBXML Report to HTML/CSV File
*
* I created this little script to help me read through the raw XML responses
* from QuickBooks. I originally built it to export to a CSV file, but found
* that a simple HTML table was better suited for my usage. However, I've
* included the CSV code below for anyone who may need that functionality.
*
@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 / sub_category_products.xml
Created December 19, 2013 19:27
A vQmod for OpenCart 1.5.6 to display products in sub-categories.
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<id>Display products in sub-categories while browsing a parent category</id>
<version>1.0.0</version>
<vqmver>2.4.0</vqmver>
<author>Jay Williams - jay@myd3.com</author>
<file name="catalog/controller/product/category.php">
<operation>
<search position="after"><![CDATA['filter_category_id' => $category_id,]]></search>
<add><![CDATA[ 'filter_sub_category' => true,]]></add>
@jaywilliams
jaywilliams / deploy.rb
Last active July 11, 2022 00:32 — forked from el-rotny/deploy.rb
set :repo_url, 'git@github.com:Design-Collective/some-repo.git'
set :application, 'the-app-name.com'
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
@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
@jaywilliams
jaywilliams / install-mosh.sh
Last active January 3, 2024 17:16 — forked from palexander/gist:2975305
Compiling and running mosh on Dreamhost (Updated - 2024)
#!/usr/bin/env bash
set -e
# Dreamhost Mosh Install Script
# Jay Williams (https://gist.github.com/jaywilliams/c9ffab789b3f622abc932dd4cfaaeef5)
# Based on the gracious work of:
# Paul R Alexander (https://gist.github.com/palexander/2975305)
# Sami Samhuri https://gist.github.com/samsonjs/4076746

See Also: https://wiki.archlinux.org/index.php/Xorg#Setting_DPI_manually

Setting DPI manually Note: While you can set any dpi you like and applications using Qt and GTK will scale accordingly, it's recommended to set it to 96, 120 (25% higher), 144 (50% higher), 168 (75% higher), 192 (100% higher) etc., to reduce scaling artifacts to GUI that use bitmaps. Reducing it below 96 dpi may not reduce size of graphical elements of GUI as typically the lowest dpi the icons are made for is 96.

# The bang exclamation is used for comments in the Xresources file
nano $HOME/.Xresources
------------------------------------------------

!Xft.dpi: 96