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

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

@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 / .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
<?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: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 / 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;
-- 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)