Vegetarian (Vegan) Chili

I don’t envision this turning into a food blog, but I’ve been eating vegetarian/pescatarian for about 5 1/2 years now, and I’ve gotten to the point where I rarely cook with recipes, instead relying on my experience and familiarity with the ingredients I’m using to make things “from memory.”

The thing is… I’ve gotten better as a cook, but I’m not that good. Some of the things I make can be hit-or-miss, since the quantities of ingredients and details of the cooking process are slightly different each time.

So, when I really nail something — which does happen from time to time — I think maybe it would be a good idea for me to write up a recipe, before I forget everything.

Last night I made a vegetarian chili, and was quite pleased with the results. Thus, here is the “recipe” (written up after the fact), mostly so I can remember this later.

Vegetarian Chili

Makes about 6 servings. (Unless you’re me, in which case it’s more like 4.)

Ingredients

For chili:

1/4 cup canola oil
1 small onion, finely chopped
1 red or yellow bell pepper (or 1/2 of each), finely chopped
2 cloves garlic, minced
2 tbsp chili powder
1 1/2 tsp cumin powder
1/2 tsp cayenne pepper
1/2 tsp oregano
1 28-oz can (or 2 14-oz cans) diced tomatoes (with liquid)
2 cups vegetable broth
1 tbsp maple or agave syrup
1 can chili beans, drained and rinsed
1 can black beans, drained and rinsed
salt and pepper to taste

For garnish:

minced cilantro
minced scallions
diced fresh cherry tomatoes
guacamole

Preparation

  1. In a large pot, heat oil over medium-high heat. When oil is hot, add spices (chili powder, cumin, cayenne and oregano) and stir for about 20 seconds, then add onion, peppers and garlic. Cook, stirring occasionally, until onions are translucent, about 5 minutes.
  2. Add diced tomatoes and their liquid and stir. Raise heat to high and bring to a boil. Pour in vegetable broth and syrup and return to boil.
  3. Stir in all of the beans and bring to a simmer. Reduce heat to low.
  4. Cook uncovered for at least 30 minutes, stirring occasionally. Pour in additional broth if chili is getting too thick. Season to taste with salt and pepper.
  5. Pour into bowls and garnish as desired.

Additional Notes and Suggestions

  • Quantities for spices are approximate. (And, honestly, I didn’t measure any of them besides the chili powder.) Adjust to suit your taste.
  • “Chili beans” is kind of a nebulous term. I used a can of Westbrae Natural Organic Chili Beans, which is a mixture of pinto, kidney and black beans. You can use any kind of beans, really, although I think white beans are too delicate in flavor for this. But when I think of chili I think of kidney beans or black beans. And honestly, kidney beans in large quantities don’t “agree with me”, so I went with straight black beans for the second can. I know a lot of people make chili with just black beans, but for some reason I find that a little boring.
  • Sometimes canned tomatoes have herbs like basil added. Be sure you’re getting plain tomatoes.
  • Corn is a nice addition, but we didn’t have any in the freezer last night. Add 1 cup of frozen corn at the same time as the beans.
  • This recipe is vegan, but if you eat dairy, you can garnish with sour cream or shredded sharp cheddar cheese instead of (or in addition to!) the guacamole.
  • For breakfast the next day, heat up a bowl of the leftover chili and top with a poached egg.

Fixing a redirect loop on WordPress sites with WooCommerce when converting the site to all-SSL

Best practice these days is to run sites on all-SSL, not just the parts of the site that “need” it. But not long ago, it was common to apply SSL only when it was absolutely necessary, because SSL encryption meant a performance hit. Not anymore.

You may find, if you’re trying to convert an existing WordPress / WooCommerce site to all-SSL, that reconfiguring your URLs, by using a tool such as interconnect/it’s super-slick, powerful (and dangerous) Search Replace DB tool, that once you’ve made the changes, your home page kicks into a redirect loop, indefinitely cycling between http:// and https:// versions of your URL.

WooCommerce may be to blame!

Specifically, a setting in WooCommerce called “Force HTTP when leaving the checkout”. Head on over to WooCommerce > Settings > Checkout and… um… check it out.

Simply uncheck that box, and, while you’re at it, uncheck “Force secure checkout” since it’s unnecessary on an all-SSL site, save your changes, and your home page should come back to live!

Internet Explorer and the centered background SVG problem

We are rapidly approaching, I believe, a time when we no longer need to worry about things that don’t work in Internet Explorer.

But we’re not there yet.

I’ve started using SVG images on the web a lot, especially for logos, which I tend to put into a flexible-width container at the top left corner of pages. Which is great, except IE has this annoying habit of resizing the canvas for SVGs to fill the container they’re in. The whole logo appears on the page, and scaled properly… but it’s horizontally centered in the container, rather than flush against the left edge.

There appear to be many possible solutions, but for a solution that is 100% fluid/responsive (that is, it will scale with the container), this does the trick.

It does involve manually editing the SVG code, but it’s simple and you only need to do it once as part of the image prep process. In the <svg> tag, look for the viewbox attribute. It will most likely consist of four numbers… 0 0 followed by the width and height of the canvas. After this attribute, simply add width="x" height="y" with the same x and y values from the viewbox attribute.

It works!

Noted for future reference (by me): How to reset the MySQL root password in Ubuntu 18.04

As a bleeding-edge early adopter, here in June 2018 I am already using Ubuntu 18.04 LTS for new sites I’m setting up for clients. (How daring!)

I ran aground this afternoon with a new server setup, because I couldn’t log into phpMyAdmin as root (or, therefore, as anyone, since I hadn’t set up my own user yet).

All of the old familiar ways I had been trying, and the tutorials I had referred to for at least the past two years, were not working. So then I specifically searched for a solution for Ubuntu 18.04 and found this excellent tutorial.

First off, mysql_secure_installation wasn’t working. That was one of the “old familiar ways” I had already tried thrice. THRICE I TELL YOU!

The key, I think, was these two unexpected lines:

$ sudo mkdir -p /var/run/mysqld
$ sudo chown mysql:mysql /var/run/mysqld

Because that folder didn’t exist and/or didn’t have the proper permissions, some other steps were failing silently or giving error messages that failed to point me in the direction of the actual problem.

The other thing to note is that with the version of MySQL included in Ubuntu 18.04, these are the proper MySQL commands to run:

USE mysql;
UPDATE user SET authentication_string=PASSWORD("linuxconfig.org") WHERE User='root';
UPDATE user SET plugin="mysql_native_password" WHERE User='root';

And it is actually important to run both of those UPDATE commands, because in the tutorial the results displayed show that the first one updated a record for them, while the second didn’t. I had already run the first command (but not the second) in one of my failed updates. So when I ran these, the first one didn’t update any records and the second one did.

How to modify WooCommerce to prevent users from selecting UPS shipping for P.O. Box addresses

Anyone who’s dealt with e-commerce in any capacity probably knows that UPS won’t deliver to P.O. boxes. Well, technically they can’t deliver to P.O. boxes. And apparently they’ll forward packages on to the box owner’s physical address, but they charge a big extra fee to do it. So, you want to avoid it.

Unfortunately, WooCommerce and its UPS Shipping add-on do not account for this, and will accept UPS orders to P.O. box addresses. Not good.

The official WooCommerce developer documentation has an article on how to block P.O. box shipping, but it applies to all shippers. Not what we want.

Also, I’m not sure if the documentation is outdated or what, but their code sample didn’t work for me with the latest version (3.4.3) of WooCommerce, because of the wc_add_notice() function.

I’ve modified the original code to add a check for UPS shipping, and also to use the $errors variable. (I also considered removing the global $woocommerce; line since it seems unnecessary, but I didn’t take the time to test whether or not it’s definitely safe to remove, so I left it in.)

add_action('woocommerce_after_checkout_validation', function($data, $errors) {
  global $woocommerce;
  if (isset($data['shipping_method'][0]) && strpos($data['shipping_method'][0], 'ups') === 0) {
    $address1 = (isset($data['shipping_address_1'])) ? $data['shipping_address_1'] : $data['billing_address_1'];
    $address2 = (isset($data['shipping_address_2'])) ? $data['shipping_address_2'] : $data['billing_address_2'];

    $replace = array(” “, “.”, “,”);
    $address1 = strtolower(str_replace($replace, '', $address1));
    $address2 = strtolower(str_replace($replace, '', $address2));

    if (strstr($address1, 'pobox') || strstr($address2, 'pobox')) {
      $errors->add('shipping', __('Sorry, UPS cannot deliver to P.O. boxes. Please enter a street address or choose another shipping method.' . $datadump, 'woocommerce'));
    }
  }
}, 10, 2);

Important notes:

1. This code may not immediately work for you; I believe the 'ups' string in the conditional line may vary depending on your Shipping Classes settings, so you may need to investigate exactly what values are returned in $data['shipping_method']. Since this code is fired off by an AJAX call, it can be difficult to debug. I was able to crudely debug it by commenting out the conditional, then appending print_r($data) to the error string.

2. This is using an anonymous function, so it won’t work in PHP versions below 5.3. But you’re not using a PHP version that old, are you? ;)

3. The original version checked the address line 1 and the postcode field, rather than address lines 1 and 2. I’ve United States-ified my code because that’s what I needed. If you’re part of the other 95% of the world, you may need to add that back in, with appropriate adjustments to the nested conditional. (I’m not really sure if this issue is as UPS-specific outside the US, so my modifications may not be relevant.)