Redirect – Why is Multisite bypassing WordPress for WP content, WP Admin, WP Includes and .PHP files?

If you set up WordPress to use multisite, you'll be instructed to change yours .htaccess File to use one of the following, described in the Admin and WordPress documentation:

subfolders

...
RewriteRule ^((_0-9a-zA-Z-)+/)?(wp-(content|admin|includes).*) $2 (L)
RewriteRule ^((_0-9a-zA-Z-)+/)?(.*.php)$ $2 (L)
...

subdomain

...
RewriteRule ^(wp-(content|admin|includes).*) $1 (L)
RewriteRule ^(.*.php)$ $1 (L)
...

I understand what these rules do. Instead of processing the requests via WordPress, .htaccess Sends the user directly to the directory or file, whether it exists or not.

What I can not figure out is why. Why is this required for multi-site installations, but not for single-site installations?

I'm asking because we're trying to use the redirect plugin to create redirects for some files wp-content/uploads and some files ending in .php, Unfortunately, these requests will not trigger WordPress, so redirects will never be triggered. We do not want to change that .htaccess Rules without first understanding their purpose. And that was a challenge.

Video – How do I deduplicate iMovie files to "Original Media"?

This page suggests replacing the video files with links to the original, which saves space. It has that kernel in Ruby, and I've encoded that kernel in Python, which is also below. The iMovie library has grown from 300GB to 5GB because I skipped two projects I was still working on.

Like the ruby ​​version:

  • It goes through an iMovie 10 library and replaces the files in Original Media for which it can find a correspondence with links
  • You must import into the library, quit iMovie, and then run the script.

In contrast to the ruby ​​version:

  • It uses symlinks to the original media instead of hard links (I've confirmed that it works just as well)
  • You can define the file types to be replaced (movie, audio, picture).
  • You can customize the global variable PROJECTS_TO_SKIP to avoid replacing media
    on some projects you may be working on.
  • You can skip projects that you are still working on
  • It is assumed that your iMovie library and the original folder have the same event name since I had several in my case DSC001.MOV and I use the event name to distinguish it
  • If the event names are different, e.g. If you create two events titled "Movie," iMovie is renamed
    In the second step of "Movie 1" you can adjust the global variable
    SHOW_NAME_CORRESPONDENCE to map the name of the iMovie event to the name of
    the folder with the original content.
import doctest
import glob
import os
import pathlib
import shutil
import sys

FILE_SUFFIXES_LOWERCASE = (".mp4", ".mts", ".mov", ".jpg", ".jpeg", ".png")

PROJECTS_TO_SKIP = ()  # e.g., ("project 1", "project 2")

SHOW_NAME_CORRESPONDENCE = {}  # e.g. {"movie": "movie 1"}

def skip(f):
    """Returns a boolean for whether to skip a file depending on suffix.
    >>> skip("abc.mp4")
    False
    >>> skip("ABC.JPEG")
    False
    >>> skip("abc.plist")
    True
    >>> skip("00114.MTS")
    False
    """
    suffix = pathlib.Path(f).suffix.lower()
    return suffix not in FILE_SUFFIXES_LOWERCASE

def get_show_and_name(f):
    """
    >>> show, name = get_show_and_name("/Volumes/video/iMovie Library.imovielibrary/my great show/Original Media/00117.mts")
    >>> "my great show" == show
    True
    >>> "00117.mts" == name
    True
    >>> show, name = get_show_and_name("/Volumes/video/path/to/originals/my great show/00117.mts")
    >>> "my great show" == show
    True
    >>> "00117.mts" == name
    True
    """
    path = pathlib.Path(f)
    name = path.name.lower()

    dirname = str(path.parents(0))

    imovie = "iMovie Library.imovielibrary" in dirname
    parent_dir = str(path.parents(2 if imovie else 1))
    show = dirname.replace(parent_dir, "")

    if imovie:
        assert show.endswith("/Original Media"), f
        show = show.replace("/Original Media", "")

    assert show.startswith("/")
    show = show(1:).lower()

    if show in SHOW_NAME_CORRESPONDENCE:
        show = SHOW_NAME_CORRESPONDENCE(show)

    return show, name

def build_originals_dict(originals):
    """Go through the original directory to build a dictionary of filenames to paths."""
    originals_dic = dict()

    for f in glob.glob(os.path.join(originals, "**", "*.*"), recursive=True):
        if skip(f):
            continue

        show, name = get_show_and_name(f)

        originals_dic((show, name)) = f

    return originals_dic

def replace_files_with_symlinks(library, originals):
    """Go through the iMovie library and find the replacements."""
    originals_dic = build_originals_dict(originals)

    # List files recursively
    for f in glob.glob(os.path.join(library, "**", "*.*"), recursive=True):
        if skip(f) or os.path.islink(f):
            continue

        show, name = get_show_and_name(f)

        if (show, name) in originals_dic:
            target = originals_dic((show, name))

            print("Replacing %s with %s" % (f, target))
            os.unlink(f)
            os.symlink(target, f)
        else:
            print("No original found for %s" % f)

def main():
    args = sys.argv
    assert 3 == len(args), "You need to pass 3 arguments"
    library = args(1)
    originals = args(2)

    replace_files_with_symlinks(library = library, originals = originals)

if "__main__" == __name__:
    r = doctest.testmod()
    assert 0 == r.failed, "Problem: doc-tests do not pass!"

    main()        

Compatibility – Is it better to save edited photos as PSD or TIFF files?

TIFF is more generally supported. Many programs do not work with PSD because the format is very complicated. TIFF, on the other hand, is like a "standard" picture format along with JPEG and PNG.

Both TIFF and PSD can retain layer information. Both can handle 16- and 32-bit images. PSD, however, can contain much more. Since this is Photoshop's native format, it can contain a lot of metadata for photo editing, such as: For example, layer styles, layer folders, snapshots, custom channels, and even editing histories (though the file may become very large due to gradients).

Personally, I only store TIFF because it's unlikely that I have a hundred levels and a complex layer structure, for example. But when I design, I probably want to have as much metadata as I want and tons of layer styles, which leaves me no choice but PSD.

EDIT: According to @Conor Boyd and @ysap etc., TIFF can actually contain as much information as PSD. So, go with TIFF. Note, however, that TIFF is a general-purpose image format Not means that each image viewer can read all information stored in a TIFF image. For example, a "baseline" TIFF reader can only render the first level in the image. This behavior is allowed by the TIFF standard.

I need to load a .data, .item and other files with invalid extensions into a data frame in Python

Thanks for writing an answer to Stack Overflow!

  • Please be sure too answer the question, Provide details and share your research!

But avoid

  • Ask for help, clarify or respond to other answers.
  • Make statements based on opinions; Cover them with references or personal experience.

For more information, see our tips for writing great answers.

mojave – Runs, but does not apply `~ / .bash_profile` when writing files

I have a strange but no longer reproducible problem with iTerm2 and Bash.

My default iTerm2 profile used /usr/local/bin/bash (Bash 5 with Brew installed) with no arguments. I tried to determine when and if this profile would be a source ~/.bash_profileSo I added some echos. Every time I do wrote In the file my open terminal printed the standard output
from running ~/.bash_profile,

The actual environment in the iTerm2 session was not changed (eg new variable definitions added to .bash_profile were not visible).

This behavior disappeared when I added this -l Argument (without which Bash should not actually use .bash_profile), and did not return When I removed the argument.

I could not reproduce the behavior in Terminal or with the system standard Bash.

Has anyone seen this behavior? Why is this happening?