How to configure Share Buttons by AddToAny with Drupal 8

As a quick “note to self,” to get the Share Buttons module by AddToAny working in Drupal 8, I followed these steps:

- install the AddToAny module
- configure permissions so i could work with it
    - admin/people/permissions
- configure AddToAny as desired
    - admin/config/services/addtoany
- create a block, add it to a region (such as Content)
    - i actually created a block, then modified
      my theme to show AddToAny between the Contents and
      the Comments

The key to getting AddToAny was knowing to go to admin/structure/block and then selecting “Place Block” to create an AddToAny block. Not knowing that I had to do that slowed me down for quite a while.

Drupal 8: How to put a View or Block between the Content and Comments

I’m not going to discuss this code much, but in short, the source code below is for a Drupal 8 preprocess_node function that I use to set variables for (a) a custom view and (b) a custom block. I set the variables in this function, and then display them in my node.html.twig file like this:

{{ similar_by_terms }}

and this:

How to display the contents of a gzip/gz file alvin July 11, 2009 - 10:19am

Problem: You have a plain text file that has been compressed with the gzip command, and you'd like to display the file contents with the Unix/Linux cat or more commands.

Solution: Instead of using the cat or more commands, use their equivalents for working with gz files, the zcat and zmore commands.

How to process every line in a text file with Ruby

There are quite a few ways to open a text file with Ruby and then process its contents, but this example probably shows the most concise way to do it:

# ruby sample code.
# process every line in a text file with ruby (version 1).
File.readlines(file).each do |line|
  puts line

As you can see, this example code is very concise, and inside the processing loop you can do whatever you need to do with the line variable.

How to open a file and read its contents using Ruby

Ruby file FAQ: How do I open and read from a file in Ruby?

How many ways are there to open a file with Ruby and process the file contents? I don't know for sure, but here are two different ways to do it.

Ruby file processing, version 1

First, I'll use Ruby and the method to open a file and process its contents, like this:

Java URL example - Download the contents of a URL

Java URL download FAQ: How can I download the contents of a URL using Java?

Note: It's 2013 now and this code is a little old, but hopefully it will still get you pointed in the right direction.

In some Java applications you'll want to download the contents of a URL across a network. For example, I've written two applications that do this regularly.

LaTeX: How to set the Table of Contents (TOC) depth

LaTeX question: For a technical document I'm creating with LaTeX, there are a lot of sections that have a repeated/consistent format. This is exactly what I want, but for a 160 page document, I ended up with a 15-page table of contents (TOC). Is there are way to control the "depth" of the table of contents?

After a little research ... yes, I can. Here's some sample code that I put in the LaTeX preamble, just before the \tablofcontents tag:

Java URL example - A Java class to download and parse URL contents

Java URL download FAQ: Can you share some source code for a Java URL example, specifically a Java class to download and parse the contents of a URL?

This example is a little weak, but it's a program that downloads and parses the contents of a given URL. The purpose has nothing to do with URLs ... it has a lot more to do with the parsing that I am trying to achieve. The parsing code is actually going to be used in an anti-spam program that I am working on.