## How to correct a view query?

I would like to know how to correct a view query, when Drupal goes nuts ?

I’m using a view that should list media by categories (taxonomy term).
This view is called by a node, that held a reference to the same categories (same taxonomy term) that the medias I wish to display.

I need to order thos categories according to the delta field on my node object.

So in my views I did a join from the media taxonomy field to the taxonomy terms.
Then, I have a join on my any node that hold the taxonomy field.
I filter on the nid through contextual filters.

Until then all is good.

However, if I add the sort Critera on the delta value of categorie, the views module add another (unnecessaray) join on the table holding data for my taxonomy field on my node. This confuses my database and then I get a scalar product as results (every media is sent back, for each existing delta line).

Exemple of the query (I get two joins on node__field_categorie) :

``````    SELECT DISTINCT field_categorie_taxonomy_term_field_data__node__field_categorie.delta AS field_categorie_taxonomy_term_field_data__node__field_catego, media_field_data.mid AS mid, taxonomy_term_field_data_media__field_standard_termref_1.tid AS taxonomy_term_field_data_media__field_standard_termref_1_tid, field_categorie_taxonomy_term_field_data.nid AS field_categorie_taxonomy_term_field_data_nid
FROM
{media_field_data} media_field_data
LEFT JOIN {media__field_standard_termref_1} media__field_standard_termref_1 ON media_field_data.mid = media__field_standard_termref_1.entity_id AND media__field_standard_termref_1.deleted = '0'
INNER JOIN {taxonomy_term_field_data} taxonomy_term_field_data_media__field_standard_termref_1 ON media__field_standard_termref_1.field_standard_termref_1_target_id = taxonomy_term_field_data_media__field_standard_termref_1.tid
INNER JOIN {**node__field_categorie**} taxonomy_term_field_data_media__field_standard_termref_1__node__field_categorie ON taxonomy_term_field_data_media__field_standard_termref_1.tid = taxonomy_term_field_data_media__field_standard_termref_1__node__field_categorie.field_categorie_target_id AND taxonomy_term_field_data_media__field_standard_termref_1__node__field_categorie.deleted = '0'
INNER JOIN {node_field_data} field_categorie_taxonomy_term_field_data ON taxonomy_term_field_data_media__field_standard_termref_1__node__field_categorie.entity_id = field_categorie_taxonomy_term_field_data.nid
LEFT JOIN {media__field_domain} media__field_domain ON media_field_data.mid = media__field_domain.entity_id AND media__field_domain.deleted = '0' AND (media__field_domain.langcode = media_field_data.langcode OR media__field_domain.bundle = 'useful_document')
LEFT JOIN {**node__field_categorie**} field_categorie_taxonomy_term_field_data__node__field_categorie ON field_categorie_taxonomy_term_field_data.nid = field_categorie_taxonomy_term_field_data__node__field_categorie.entity_id AND field_categorie_taxonomy_term_field_data__node__field_categorie.deleted = '0'
WHERE ((media_field_data.status = '1') AND (media_field_data.bundle IN ('useful_document'))) AND (media__field_domain.field_domain_target_id LIKE 'intranet_adapei69' ESCAPE '\')
ORDER BY field_categorie_taxonomy_term_field_data__node__field_catego ASC
``````

Exemple of my view, so you can better understand.

How can I correct such a query ?
I’m using Drupal 8.7.12 and can’t upgrade for the moment.
I guess the easier way around this would be to be able to add an order by clause using the column made available by my first join on : node__field_categorie

I looked into query_alter and views_query_alter hooks, but it seems it is no longer possible to add an order by clause there (or I tried the wrong way). Any ideas ?

## How can I use my fourth gen IPod classic to play podcast episodes in correct chronological order?

The default order when I download podcast episodes to my IPod is reverse chronological, such that the most recent episode plays first. I’d like my podcasts to play in correct chronological order, such that the oldest episode plays first. I have tried:

• Pressing play on the podcast folders on the IPod rather than individual episodes
• Going into my Mac’s podcast app to change the settings on individual podcasts to play in sequential order
• Setting individual podcasts to custom play settings, changing episode order to “oldest to newest”
• Creating my own podcast station, setting station’s play setting to “oldest to newest”

After each of the last three steps, I would remove my podcasts, sync, add them again with the new settings, and sync. The IPod still plays the most recent episode first. Many suggestions I see when you google this question involve using playlists, which no longer exist in the current podcasts app for Mac. Ditto the title.

## binary tree – Is this model of converting integers to Gray code correct?

The model shown in the figure converts all numbers that have k digits in the binary system to Gray code without any calculation, but I have no proof that guarantees this claim.

Here is some information on how to use it.

Conversion model of all integers that have k digits in the binary system in Gray code.

Rules

1. You will need k columns of numbers. The numbers to be encoded are arranged in the last column.

2. The conversion is done gradually by transferring groups of numbers to the adjacent columns in the way the arrows show. There are two types of paired arrows, parallel (=) and intersecting (×). Symbolically, the (=) and (×) are considered inverse of each other.

3. Each column with arrows is formed by an exact copy of the previous column and by a copy of the previous column that has inverted pairs of arrows, which is placed below the exact copy.

Observation

If we set “=” = 0 and “×” = 1, then the successive columns containing arrows form the Thue Morse sequence which essentially forms the rules for converting integers to Gray code.

## When importing a wallet from private key or seed phrase, how do you guess the correct address format?

How do I determine the derivation path for the seed when importing it?

I don’t think you can determine the derivation path from the seed phrase, you have to ask the user to choose one from a list or input it if not listed. You can build in a list of derivation paths for popular wallets, the user then has to know the name, and maybe version number, of the wallet that produced the seed they are importing.

or do i just do a wallet address lookup based on the supported derivation paths and keep searching for about 20 address if it has any transactions on the blockchain ?

That would work in many cases. It assumes you have access to a full copy of the blockchain indexed by all addresses with non-zero balance. It needn’t be local but a non-local source might make your seed-importation take a long time.

## Correct way with Macbook Pro trackpad to select from dropdown form?

Having started to use a MacBook Pro with Catalina a lot more than a Mac Mini, I’ve had trouble trying to negotiate the trackpad after using a mouse for so long.

I want to be able to use a dropdown / select, like this example at https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_optgroup but do not know the correct trackpad gesture for selecting it; I’ve done some light Google-ing but am unsure.

Any help is appreciated.

## jpeg – Wrong DNG colors but correct JPG. How can I “transfer” correct colors to the DNG?

I have a Fimi X8 SE drone and it has a RAW DNG (+ JPG) capture mode.

The only downside to this is that the DNG files are somehow “broken” because all colors seems to be wrong. Strong magenta cast in the shadows, looks like green in the highlights, etc.

However, the JPG produced by the drone is perfectly normal.

My question is, is there a way to: either fix or correct the DNG colors, or somehow “transfer” the correct JPG colors onto the DNG file ?

I’ve put the images in the attachement.

Thanks in advance for anyone trying. Cordialy.

Here are the different RAW + JPG files for anyone wanted to try something: https://mega.nz/folder/0t1R3DxT#mk5tJszH-nZtTsqblTCeLA

Here are the different comparisons:

## shortcut keys – Correct way to copy-paste file location from nautilus into a file chooser?

To paste a file or directory into the file-chooser dialogue of any application, I used to be able to select and copy the file from any Nautilus window with Ctrlc, then paste the whole pathname into the file-name field of the chooser with Ctrlv, whatever directory it was currently showing.

Since Ubuntu 19.04 (Nautilus 3.30), when you copy a file in Nautilus the clipboard includes a two-line media-type and action before the path, as follows:

``````x-special/nautilus-clipboard
copy
file:///path/name
``````

So, when you paste into the file-name field of a chooser dialogue, it no longer works – you get just the first line `x-special/nautilus-clipboard` not the pathname.

Is there a correct way to paste these new 3-line Nautilus path-names into the file-name field of a file-chooser?

I’ve discovered a work-round where I can type Ctrll in Nautilus and copy the path of the containing directory, then type Ctrll in the file-chooser and paste the containing directory with Ctrlv. This at least gets the chooser to the right location in the file system, but you still have to select the file you want. So this feels more like a walk-round the houses than a work-round!

From reading the developer’s discussions, inclusion of this metadata in the clipboard seems to be part of some master-plan. For instance, once I had copied one of these 3-line Nautilus path names to my clipboard, I noticed that right clicking on a gnome-terminal shows a new entry `Paste as filenames`, which pastes the filename(s) surrounded by quotes {see Note 1}.

So, is the master-plan that a matching paste action will eventually be written for the file-chooser that recognizes this new 3-line clipboard entry? But in the meantime we’re left with a temporary regression? Or perhaps there is some new way that I’m meant to be pasting these pathnames – hence my question.

{Note 1}: Incidentally, `Paste` is also on the right-click menu of gnome-terminal, which allows you to paste the above three lines into the terminal. Useful eh? I imagine no-one will use that menu more than once! Similarly, Ctrl-Shift-v used to paste the pathname, but now it pastes the above three lines into the terminal.

## unity3d – C#/Unity – Update the text boxes to show the correct number collected per resource

So, I am playing with Unity/C#. I am very new to this, so feel free to point out my many mistakes below. I have a few resources: apples, oranges, lemons etc. I am collecting them fine in a dictionary. Then I wanted to write a method to display the collected resources in various UI text boxes with this public class controlling the display (Window Game Resources). In the inspector, I have this script attached to the inventory game objects. Then, from another class I am calling the method UpdateResourceTextObject. I think my problem is with the FindObjectOfType().UpdateResourceTextObject(); because what I want is for the method to run on all objects containing the script so that the inventory can be updated correctly. For each inventory object I have serialized the correct resourceType using the Enum categorisation. I have completed muddled myself up.

``````public class WindowGameResources : MonoBehaviour
{
(SerializeField) GameResources.ResourceType resourceType;
Text resourceText;

private void Start()
{
resourceText = transform.Find("Text").GetComponent<Text>();
UpdateResourceTextObject();
}

public void UpdateResourceTextObject()
{
resourceText.text =
GameResources.GetResourceAmount(resourceType).ToString();
}
}

public class GameResources : MonoBehaviour
{

public enum ResourceType
{
apple,
orange,
lemon,
}

static Dictionary<ResourceType, int> ResourceAmountDictionary;

private void Awake()
{
Init();
}

public static void Init()
{
ResourceAmountDictionary = new Dictionary<ResourceType, int>();
foreach (ResourceType resourceType in Enum.GetValues(typeof(ResourceType)))
{
ResourceAmountDictionary(resourceType) = 0;
}

}

public static void AddResourceAmount(ResourceType resourceType, int amount)
{
ResourceAmountDictionary(resourceType) += amount;
FindObjectOfType<WindowGameResources>().UpdateResourceTextObject();
}

public static int GetResourceAmount(ResourceType resourceType)
{
return ResourceAmountDictionary(resourceType);
}
}
``````

## unity – Player is not looking at correct direction

My Enemy/Bot is facing the wrong direction as shown in the attached screenshot 1.
Basically what I want is that Enemy/Bot gun should directly face the player, not enemy/Bot himself.

Note: White line in the image is representing Aim direction which is
correct.

Here is my Code:

``````Vector3 targetPosition = kbcrd.playerToEngage.thirdPersonPlayerModel.shootTarget.position;
targetPosition .y = 0;

Vector3 botPosition = pb.thirdPersonPlayerModel.gunDirection.position;
botPosition.y = 0;

Quaternion targetRotation = Quaternion.LookRotation(targetPosition - botPosition);

//pb is Bot which is holding transform and other scripts.
pb.transform.rotation = Quaternion.RotateTowards(pb.transform.rotation, targetRotation, kbcrd.lookingInputSmooth);
``````

What I Get from the above code is this: (Screenshot # 1)

What I want is this: (Screenshot # 2)

Any help is appreciated. I know its simple problem but I struggling now. 🙁

## Is it correct or incorrect to say that an input say \$C\$ causes an average run-time of an algorithm?

I was going through the text Introduction to Algorithm by Cormen et. al. where I came across an excerpt which I felt required a bit of clarification.

Now as far as I have learned that that while the Best Case and Worst Case time complexities of an algorithm arise for a certain physical input to the algorithm (say an input $$A$$ causes the worst case run time for an algorithm or say an input $$B$$ causes the best case run time of an algorithm , asymptotically), but there is no such physical input which causes the average case runtime of an algorithm as the average case run time of an algorithm is by it’s definition the runtime of the algorithm averaged over all possible inputs. It is something I hope which only exists mathematically.

But on the other hand inputs to an algorithm which are neither the best case input nor the worst case input is supposed to be somewhere in between both the extremes and the performance of our algorithm is measured on them by none other than the average case time complexity as the average case time complexity of the algorithm is in between the worst and best case complexities just as our input between the two extremes.

Is it correct or incorrect to say that an input say $$C$$ causes an average run-time of an algorithm?

The excerpt from the text which made me ask such a question is as follows:

In context of the analysis of quicksort,

In the average case, PARTITION produces a mix of “good” and “bad” splits. In a recursion tree for an average-case execution of PARTITION, the good and bad splits are distributed randomly throughout the tree. Suppose, for the sake of intuition, that the good and bad splits alternate levels in the tree, and that the good splits are best-case splits and the bad splits are worst-case splits. Figure(a) shows the splits at two consecutive levels in the recursion tree. At the root of the tree, the cost is $$n$$ for partitioning, and the subarrays produced have sizes $$n- 1$$ and $$0$$: the worst case. At the next level, the subarray of size $$n- 1$$ undergoes best-case partitioning into subarrays of size $$(n-1)/2 – 1$$ and $$(n-1)/2$$ Let’s assume that the boundary-condition cost is $$1$$ for the subarray of size $$0$$.

The combination of the bad split followed by the good split produces three sub- arrays of sizes $$0$$, $$(n-1)/2 – 1$$ and $$(n-1)/2$$ at a combined partitioning cost of $$Theta(n)+Theta(n-1)=Theta(n)$$. Certainly, this situation is no worse than that in Figure(b), namely a single level of partitioning that produces two subarrays of size $$(n-1)/2$$, at a cost of $$Theta(n)$$. Yet this latter situation is balanced!