unity3d – why path in AssetDatabase.ImportAsset method in unity must be relative path?

I want to import a new assets, and the method doesn’t work, because the path it use must be relative path about the project, which means it can’t import a file that is not in the project, or it’s difficult to do it. So what’s the use of this method? AssetDatabase.ImportAsset

Now I use copy file and refresh assetdatebase to import external asset. I just want to know what’s its use. Thanks

plugins – Image path in childs theme

I hope you can help me. How do I have to change the file path to get an specific image from my upload folder in my plugin/shortcode?
I have added the following lines to my childs theme – functions.php but it doesn’t work.

add_shortcode( 'webcamtime', 'webcamtime_timestamp' );
function webcamtime_init (){
    function webcamtime_timestamp() {
        $file = '/wp-content/uploads/webcam/webcamimage.jpg';
        $filename = basename($file);
        if (file_exists($filename)) {
            return "Last modified: " . date ("F d Y H:i:s.", filemtime($filename));
add_action('init', 'webcamtime_init');

Thank you in advance!!

php – MyListing + WCFM – Change path on click (redirect?)

Im attemptng to tweak MyListing and WCFM so they can play nicely together but im having some trouble.

The main issue is that when a user has registered and created a listing it creates the url domain.com/listing/shopname which takes you to the MyListing Shop. So a user searching the listings will click on one and be taken to domain.com/listing/shopname instead of the WCFM store at domain.com/store/shopname. I have tried various redirects but not having any success.

Essentially I need every time someone visits the URL domain.com/listing/shopname it swaps /listing/ for /store/ so the user ends up at domain.com/store/shopname? This will mean they arrive at the WCFM store instead of the MyListing store.

Any help would be appreciated.

merkleblock – How Does the SPV merkle path form of multiple transactions in Merkle block looks like?

While I’m studying about the Bitcoin, I’ve wondered how many merkle paths should be contained in merkle block.

From the point of view of Merkle path, it is generated as the form of containing hashes of counterpart stepping up from bottom to top.

For example, if I have 4 transactions(let me use tx1, tx2, tx3, and tx4) in a block, then the hashes of them(h1, h2, h3, and h4) will be located at the bottom as the leaves. The parents of them will be (h12 and h34), after all, the merkle roots will be (h1234). So, if a SPV node want to verify that the tx2 is in the block, the full node can offer h1, h34 as a merkle path (as well as block header), so that they can prove as the step of hashing will lead them to the merkle roots which is contained in block header.

However, If I requests to verify multiple transactions in a block (e.g. using Bloom filter), then what would be contained into the merkle block (which contains merkle path and block header)?

Does they have ultiple merkle paths for each transactions which are interested in, so that the transactions can be verified respectively? or adapted merkle path to be included which encompass all transactions related? (e.g. if we want to verify tx1, tx3 then generating h2, h3; though this exmample seems not to be guaranteed to show the order of transactions)

unity – Creating/following a path

So I’m working on my first project in unity. The final result must look something like a medicine (sphere) travelling down a human body (plane with image of circulatory/digestive system). I know this might seem like a little off to do it in Unity, but I’ve tried a lot, with very little result. The issue now is that I’ve created a sphere that can be controlled by my arrows and a plane to roll on. Next thing wanted to do was create path, so I don’t have to do the rolling myself. I watched a very useful tutorial on YouTube, and downloaded the B├ęzier Path Creator asset.

I’ve copied the script as showed in the tutorial, but somehow it doesn’t work. Whenever I hit play in the game mode, it gives the following error “all compiler errors have to be fixed before you can enter play mode”. I presume something is wrong in my code or maybe my library, but I have no idea what.

My code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PathCreation;
using System.Threading;
using System.Security.Cryptography;

public class Follower : Monobehaviour
    public PathCreator pathCreator;
    public float speed = 5;
    float distanceTravelled;

    void Update() {
        distanceTravelled += spreed * Time.deltaTime;
        transform.position = pathCreator.path.GetPointAtDistance(distanveTravelled);



Code in the tutorial:

source: https://www.youtube.com/watch?v=saAQNRSYU9k

The only thing I might think went wrong is that in the tutorial some words get a certain color (for example ‘UnityEngine’ turns blue) and in my code don’t change color. So maybe these commands are not recognized?

Does anybody know a possible way to fixed this? Help will be very much appreciated, so many thanks in advance!

dnd 5e – Do the conjured “intangible spirits” that randomly move 30 feet in the Path of the Wild Soul (UA) move though walls?


From the text you linked, it says

You conjure 1d4 intangible spirits that look like flumphs in unoccupied spaces within 30 feet of you. Each spirit immediately flies 30 feet in a random direction. At the end of your turn, all spirits explode and each creature within 5 feet of one or more of them must succeed on a Dexterity saving throw or take 2d8 force damage.

As far as I know, Intangible is not a in-game term, therefore, we should interpret it in plain English.

Intangible, from Google, says:

unable to be touched or grasped; not having physical presence.

Since it “can not be touched” and does not possess any physical form, there is no reason for them to be stopped by a wall or any other object. The fact that they are spirits also supports this interpretation. Again, simply “spirits” is not an in-game term, so, we should go with usual reading: spirits are incorporeal and can move through walls.

PS: I am reading your question as “can the spirits”, rather than “do the spirits”, which I believe is what you meant. Ultimately, what the spirits do, in fact, depends on the DM, but they certainly can move through walls.

magento2 – magento 2 : resize image before upload on destination path

I want to upload images for custom module, so before upload image on media folder I want that resize image.
How can I set resize image before upload on media folder ?

Here is my code:

public function __construct(
        MagentoFrameworkAppActionContext $context,
        MagentoFrameworkTranslateInlineStateInterface $inlineTranslation,
        MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig,
        PsrLogLoggerInterface $loggerInterface,
        MagentoStoreModelStoreManagerInterface $storeManager,
        Filesystem $filesystem,
        FileFactory $fileFactory,
        MagentoMediaStorageModelFileUploaderFactory $uploaderFactory,
        MagentoFrameworkImageAdapterFactory $adapterFactory,
        MagentoFrameworkImageAdapterFactory $imageFactory,

        array $data = ()
        $this->_inlineTranslation = $inlineTranslation;
        $this->_scopeConfig = $scopeConfig;
        $this->_logLoggerInterface = $loggerInterface;
        $this->messageManager = $context->getMessageManager();
        $this->filesystem = $filesystem;
        $this->mediaDirectory = $filesystem->getDirectoryWrite(MagentoFrameworkAppFilesystemDirectoryList::MEDIA);
        $this->fileFactory = $fileFactory;
        $this->uploaderFactory = $uploaderFactory;
        $this->adapterFactory = $adapterFactory;
       $this->imageFactory = $imageFactory;

    public function execute()
         try {$files = $this->getRequest()->getFiles('image');
    //echo "<pre>";print_r($files);die();
            foreach($files as $key => $value){
            $imageAdapter = $this->adapterFactory->create();
             $mediaDirectory = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA);
            $imagepathfolder= 'test/';
            $destinationPath = $mediaDirectory->getAbsolutePath($imagepathfolder);
}echo "<pre>";print_r($result);die();
        } catch (Exception $e) {
        echo $e->getMessage();die();
        /* $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
        return $resultJson; */

taxonomy terms – How can I change which view wins over two using the same path?

I have two views in Drupal 8.

  1. The standard Taxonomy term (content) view, path: /taxonomy/term/%
  2. My custom view for just one term at path: /term-alias

When I go to my custom term, I see the view for all terms (#1), when I want to force it to #2. How can I do that?

c++ – LeetCode 1293: Shortest Path in a Grid with Obstacles Elimination

I’m posting my code for a LeetCode problem copied here. If you have time and would like to review, please do so.


  • Given a m * n grid, where each cell is either 0 (empty) or 1 (obstacle). In one step, you can move up, down, left or right from and to an empty cell.

  • Return the minimum number of steps to walk from the upper left corner (0, 0) to the lower right corner (m-1, n-1) given that you can eliminate at most k obstacles. If it is not possible to find such walk return -1.

Example 1:

grid = 
k = 1
Output: 6
The shortest path without eliminating any obstacle is 10. 
The shortest path with one obstacle elimination at position (3,2) is 6. Such path is (0,0) -> (0,1) -> (0,2) -> (1,2) -> (2,2) -> (3,2) -> (4,2).

Example 2:

grid = 
k = 1
Output: -1
We need to eliminate at least two obstacles to find such a walk.


  • grid.length == m
  • grid(0).length == n
  • 1 <= m, n <= 40
  • 1 <= k <= m*n
  • grid(i)(j) == 0 or 1
  • grid(0)(0) == grid(m-1)(n-1) == 0

Accepted Code

#include <array>
#include <string>
#include <vector>
#include <unordered_set>
#include <utility>
#include <algorithm>

class Solution {
    inline int shortestPath(const std::vector<std::vector<int>>& grid, const int k) {
        if (grid.empty()) {
            return 0;

        int path_distance = INT_MAX;
        get_manhattan_distance(0, -1, -1, 0, 0, k, grid, path_distance);
        return path_distance == INT_MAX ? -1 : path_distance;

    // Four neighbor cells
    static inline std::array<std::pair<int, int>, 4> directions = {{{0, 1}, {1, 0}, {0, -1}, { -1, 0}}};
    std::unordered_set<std::string> memo;

    // row - col - k string
    static inline std::string get_key(const int row, const int col, const int k) {
        return std::to_string(row) + "#" + std::to_string(col) + "#" + std::to_string(k);

    // Calculate Manhattan distance 
    inline void get_manhattan_distance(const int path, const int prev_row, const int prev_col, const int row, const int col, int k, const std::vector<std::vector<int>>& grid, int& base_distance) {
        if (k >= get_row_length(grid) + get_col_length(grid) - 3 - row - col) {
            base_distance = min(base_distance, path + get_row_length(grid) + get_col_length(grid) - 2 - row - col);

        if (row == get_row_length(grid) - 1 && col == get_col_length(grid) - 1) {
            base_distance = min(base_distance, path);

        if (!memo.insert(get_key(row, col, k)).second) {

        int curr_dist = get_distance(row, col, grid);

        for (const auto& direction : directions) {
            if (!(row + direction.first == prev_row && col + direction.second == prev_col) && is_valid(row + direction.first, col + direction.second, grid)) {
                int dist = get_distance(row + direction.first, col + direction.second, grid);

                if (grid(row + direction.first)(col + direction.second) == 0) {
                    get_manhattan_distance(path + 1, row, col, row + direction.first, col + direction.second, k, grid, base_distance);

                } else if (dist < curr_dist && k > 0) {
                    get_manhattan_distance(path + 1, row, col, row + direction.first, col + direction.second, k - 1, grid, base_distance);

    // Get Current distance
    static inline const int get_distance(const int row, const int col, const std::vector<std::vector<int>>& grid) {
        return std::abs(row - get_row_length(grid) - 1) + std::abs(col - get_col_length(grid) - 1);

    // Check for grid boundaries
    static inline const bool is_valid(const int row, const int col, const std::vector<std::vector<int>>& grid) {
        return row > -1 && row < get_row_length(grid) && col > -1 && col < get_col_length(grid);

    // Get grid row size
    static inline const int get_row_length(const std::vector<std::vector<int>>& grid) {
        return grid.size();

    // Get grid column size
    static inline const int get_col_length(const std::vector<std::vector<int>>& grid) {
        return grid(0).size();


LeetCode has a template for answering question. There is usually a class named Solution with one or more public functions which we are not allowed to rename.

c# – Algorithm to find path between nodes

First time working with any type of graph traversal. The algorithm determines whether a path exists between two nodes using breadth first searching (BFS). The BFS method has a tuple return type indicating whether a match has been found along with length between the two nodes. I implemented it this way since it’s part of a private member and wont be seen externally. When the result is seen as part of the HasPath method I modeled it after the Try-Pattern similar to TryParse(...).

The local function EnqueueNonVisitedChildrenNodes is declared as such since it would make no sense to call it anywhere else. It too uses a tuple to simplify its invocation.

Am I properly using the tuple type? Is there anything that could be improved with code structure?

using System.Collections.Generic;
using System.Diagnostics;
(DebuggerDisplay("Name = {Name}, ChildCount = {Children.Count}"))
public class Node
    public string Name { get; }
    public List<Node> Children { get; } = new List<Node>();
    public bool Visited { get; set; }

    public Node(string Name)
        this.Name = Name;

    public Node(string name, IEnumerable<Node> children)
        Name = name;

        foreach (var node in children)

    public void AddChild(Node node)

The implemented algorithm.

public class PathAlgorithm
    Node Start { get; }
    Node End { get; }

    public PathAlgorithm(Node start, Node end)
        Start = start ?? throw new ArgumentNullException(nameof(start));
        End = end ?? throw new ArgumentNullException(nameof(end));

    public bool HasPath(out int length)
        bool hasPath;
        (hasPath, length) = BreadthFirstSearch(Start);

        return hasPath;
    public (bool, int) BreadthFirstSearch(Node root)
        if (root == null)
            return (false, 0);

        Queue<(Node, int)> searchQueue = new Queue<(Node, int)>();
        root.Visited = true;
        searchQueue.Enqueue((root, 0));
        while (searchQueue.Any())
            (Node node, int length) = searchQueue.Dequeue();
            if (node == End)
                return (true, length);

            EnqueueNonVisitedChildrenNodes(searchQueue, (node, length));

        return (false, 0);

        void EnqueueNonVisitedChildrenNodes(Queue<(Node, int)> queue, (Node node, int length) foo)
            foreach (var n in foo.node.Children)
                if (!n.Visited)
                    n.Visited = true;
                    searchQueue.Enqueue((n, foo.length + 1));