Effective AI for one player-one ghost pacman

Question: I am thinking of a modified version of pacman. In this version, it will be a two-player game. Each player will have one pacman and one ghost. So there are 2 pacmans and 2 ghosts in the board at a time. No additional ghost is there. A player will control both his pacman and ghost separately- there is no predefined or random move of ghosts. Ghost of a player will try to catch the opponent's pacman. Pacman of a player will try to avoid the ghost of the opponent. Collision of ghost and pacman of the same player won't affect anything. So the pacman and the ghost of the same player need to cooperate with each other. "Moving Target Search" seems promising for the ghost, but what about the pacman? Will minimax (with alpha beta pruning) work in this multi-agent cooperative environment? I am saying this cooperative because my ghost will try to catch the opponent's pacman and my pacman will use this opportunity to eat more food. I have separate functions for the pacman move and the ghost move to simplify the gameplay. So returning a single tuple (including the moves of both pacman and ghost) from a function is not possible here.
Answer: This is an adversarial game problem where you need to find the optimal behavior from each position. There are several approaches to attack such problem.
You can do Minimax with alpha beta pruning to find the best move.
It will provide you an optimal move after exploring the entire tree up to some level (not too deep if the branching factor is too high, here your branching factor is $4*players$) using a handcrafted heuristic by you. So the quality of the results heavily depends on the quality of the heuristic. If you improve the pruning you can achieve better results, as you can explore more.
Another approach is Montecarlo Tree Search. This algorithms performs really good in several games, and doesn't depend on any previously knowledge of the game. Roughly speaking, it seeks the best option by expanding the tree from the state you are in and calculates the quality of a state by performing a random simulation of the game.
There is a novel approach, Reinforcement learning, that you can use to find the answer. The idea behind it is approximate the optimal policy that gives you the maximal reward. Here you can understand by policy the action you will make at any position an the rewards are the points you get after each action. You can read more about it here.
Comment: Thanks for the answer. I have already learnt minimax with alpha-beta pruning. So here the order will be like max (my pacman) -> max (my ghost) -> min (opponent pacman) -> min (opponent ghost) ? I have separate functions for the pacman and the ghost to simplify the gameplay.
Comment: That is exactly how it will work. Max for your players and Min for opponent players.


Is EnsureChildControls() in OnLoad a bit of a code smell?

Question: I'm fluffing around with validators for some custom CompositeControls at the moment, and in order to get the server-side validation working I need to do the following:
protected override void OnLoad(EventArgs e)
{
    EnsureChildControls();
    base.OnLoad(e);
}

I've not fully grasped the ASP.NET page lifecycle yet, and am wondering if this is a bit of an ASP smell in general, or is it OK?
(The reason I need to call EnsureChildControls() is because my validators are dynamically added in CreateChildControls(), but it seems the server-side validation is performed before CreateChildControls() is naturally called, and hence before I've actually created any validators.  So I'm calling EnsureChildControls() to force them to exist.)
Comment: Asp.net is a code smell:) use MVC
Comment: Ha, I wish :-)  This all has to fit inside SharePoint 2007, which doesn't play so nice with ASP MVC.
Answer: Say your routine that adds validators is CrateValidators()
I would suggest you move this to Page_Init and LoadViewState basically
bool _doCreateValidators=false;
void OnPageInit(sender,args){
    if(_doCreateValidators){
        CreateValidators();
    }
}

protected override void LoadViewState(StateBag savedState){
       CreateValidators();
       _doCreateValidators = false;
       base.LoadViewState(savedState);
}


Closed-form for recursive "geometric-like" recursion

Question: I asked this question of MSE, but to no avail; alas, here I am.
Let $k>0$, $C\geq 1$, $\alpha \in (0,1]$, and let $(x_n)_{n\geq 1}$, be a sequence of real numbers given by the recursion
$$
x_{n+1} = k |C|^{\alpha} + |x_{n}|^{\alpha} \qquad x_0=0.
$$
Is there a simple "non-recursive" expression for $x_{n}$, for $n>0$?  At the very worst, is there a tight-upper bound for $x_n$ only depending on $C,k,$ and $\alpha$?  I was trying to obtain an upper-bound by the geometric sums $\sum_{i=1}^n{k C}^{\alpha}$ but I'm no longer convinced this is correct.
Comment: What is the significance of $f$? You don't seem to use it again.
Comment: Please include a link to the question on m.se, and include a link there to the question here.
Comment: @GerryMyerson I look down the MSE question. When I migrted it here
Answer: It seems extremely unlikely that a simple "non-recursive" expression for $x_n$ is possible. However, let us obtain an exact upper bound on the $x_n$'s.
Let $a:=\alpha\in(0,1]$ and $b:=k|C|^a\in(0,\infty)$. It is clear that $x_n\ge0$ for all $n$. So,
$$x_0=0,\quad x_1=b,\tag{1}$$
and
$$x_{n+1}=g(x_n)\tag{2}$$
for $n\ge1$, where $g(u):=b+u^a$. To avoid trivialities, assume that $a\ne1$, so that $a\in(0,1)$. Then $h(u):=g(u)-u$ is concave in real $u\ge0$, with $h(0)=b>0$ and $h(\infty-)=-\infty$. So, there is a unique root $u_b\in(0,\infty)$ of the equation $h(u)=0$ and, moreover, $h\ge0$ on the interval $[0,u_b]$, that is,
$$g(u)\ge u\quad \forall u\in[0,u_b],\tag{2.5}$$
whereas
$$b+u_b^a=g(u_b)=u_b.\tag{2.75}$$
In particular, it follows that
$$u_b\ge b.\tag{3}$$
Let us show, by induction on $n\ge0$, that
$$x_n\le u_b\tag{4}$$
for all $n\ge0$. Indeed, by (1) and (3), (4) holds for $n=0,1$. Supposing now that (4) holds for some $n\ge1$, we have
$$x_{n+1}=g(x_n)\le g(u_b)=u_b,$$
in view of (2) and because the function $g$ is increasing. So, (4) holds for all $n\ge0$.
Now (2), (2.5), and (4) imply
$$x_{n+1}=g(x_n)\ge x_n.$$
So, $(x_n)$ is a nondecreasing sequence in $[0,u_b]$. Therefore and in view of (2) and (2.75),
$$x_n\uparrow u_b$$
as $n\uparrow\infty$.
Thus, in view of (4), $u_b$ is the best upper bound on the $x_n$'s.

If $a$ is rational, then the unique root $u_b$ of the equation $u_b=g(u_b)$ will be algebraic in $b$. E.g., if $a=1/2$, then $u_b=(1+2 b+\sqrt{1+4 b})/2$.


You may leave the room,how can we report it

Question: How could we report:

"You may leave the room", the Teacher said

Can we report it as

Teacher gave me the permission to leave the room
OR
Teacher said to me that I might/could/may leave the room.

May, might or could is all are possible.
Answer: Both your suggestions are basically correct. There are some minor errors with the use of "the".

The teacher gave me permission to leave the room.
  The teacher said I may leave the room.
  The teacher said, "You may leave the room."

These mean the same thing because saying "You may leave the room" is how one gives permission. Other words are possible.  "Can leave the room" is less formal than "may" but is more common in spoken English.
Permission is an abstract noun. We use "the" with abstract nouns rarely. It can be used to contrast a particular specific instance of the abstract instance.  "The permission I received from my teacher was dependent on my return within 5 min". That is not the case here, where you are speaking of an indeterminate instance of permission.
Compare

I received an apple from my teacher (countable)
  I received permission from my teacher (abstract and non-count)
Comment: Thank you.could you help me to know,why 'the' is not possible there?
Answer: You can report it in this way:
Teacher told me/said to me to leave the room
or opposite:  Teacher told me/said to me not to leave the room
"Teacher gave me the permission to leave the room" is true
Comment: "said me" is always wrong


How to install SQL Server 2008 32 bit to Windows 2003 Server 64 bit?

Question: How to install SQL Server 2008 32 bit to Windows 2003 Server 64 bit?
Answer: Run setup.exe
You can run 32 but programs on 64 bit OS normally. I'm typing this in 32 bit Opera on Windows 7 x64.
It's only where you need drivers (mostly) that you need x64 code to match
From the SQL Server MSDN Requirements, look at OS requirements for "SQL Server 2008 R2 Standard (32-bit)"
Answer: Install all your prerequirements and then run the setup file in the x86 folder. If you run the setup in the root folder it will choose the architecture for you.


Querying business unit from Enterprise Account

Question: I have a requirements for reports on business units from the enterprise level.
I am trying to generate reports on data from each business unit from the enterprise level. Is there a way to write SQL queries at the Enterprise account level to retrieve information from business units?
 I have searched the documentation and found nothing on this. Is this possible or is there a work around?
Comment: Can you please give more concrete details and what it is that you are looking for?
Comment: I have added a bit more text to it.
Answer: You can't query a Data Extension that resides in a child BU from the Enterprise BU. FYI, child BU DE's are stored within the C-level schema, but there's no way of querying this schema.
The only solution would be to make the DE shared, then append the prefix ENT. before the data extension name to query it from your Enterprise BU.
Answer: Within the Parent Business Unit you can run a query to access most data view information relating to business units, but not subscriber data that only lives within that business unit.
What you can query:

Opens
Clicks
Bounces
Unsubscribes
Shared Data Extensions

What you can't query:

Lists in child business units
Data Extensions in child business units
Job data for sends not made in Parent
Subscriber status on the business-unit specific All Subscribers list

On almost all Data Views (https://help.marketingcloud.com/en/documentation/exacttarget/interactions/activities/query_activity/data_view_open/) you will see a column labeled "OYBAccountID". This stands for 'On-Your-Behalf' accounts, which can be considered legacy speak for child business units. So you could filter or label specific business units using that field, or just pull in data for all business units.


kB vs MB - will pictures be good quality

Question: I recently had my sons newborn shoot done and the photographer has sent me all his images in kB, is this right as I have always received MB files from previous ones. Will the quality be ok when I go to print a large size picture?
Comment: What was the 'fee structure' (EG: 1/2 hour + 10 prints for $300), how many photos were taken? -- **Maybe** she shoots 100 photos and sends them all in tiny JPGs so you can choose the 10 you want to actually pay for, then you get 10 prints of a specified size and a promotional USB Keyfob with high resolution (MB) versions for you to print yourself (or elsewhere) if you wish. Low resolution (KB) images that are watermarked are either not the finished product or there's a problem with what is expected that people would accept.
Comment: Check the wording of the contract/invoice/licence agreements. I routinely send images in kB rather than MB (by providing in lower res), just because it's a lot easier to email a smaller data file without either client rejecting it. My invoice/licence agreement also stipulates if they want higher res versions then they can have them free of charge.
Comment: The problem won't be they're in kB.  A filesize is NOT representitive of quality. What you need to do is check the properties for the resolution (pixel dimension height vs width) and potentially the DPI. It's very likely she gave you lower res copies you'd be unable to print in order to upsell you prints. It's common business practice.
Comment: Hi everyone thanks for commenting so far, we paid $350 for the session and we signed a contract to say that we would have access to all digital files - ( own them ) we did the same with another photographer, who sent the images in MB. When I went to a canvas store to print they said these weren't mean to be enlarged and quality would be low. When I asked the photographer she said that she always sends files in KB and it shouldn't be an issue, I asked for the unedited ones - she said she deleted them and doesn't have them now so all I have is the Kb pictures.
Comment: @MarkRansom all depends on the data held in the image... I just exported a JPEG 3600x2400 (so 12"x8") but as it was shot on white seamless the file size was 360k.. the images above all feature similar colour tones...
Comment: Please tell me the images intended for printing do not have the huge, ugly logo... I would bury myself in the ground in shame if I sold images that look like ads.
Comment: Is this normal for a photographer to send like this? And my question is are the Kb files she sent worse quality or ok if I tried to print a large 18x18 canvas - ps she sent them me in a gallery, and the ones to download don't have her logo on. But still in KB
Comment: If the images you added to this post are the full size you received, they were not meant for prints, or at least prints larger than 4x6.
Comment: @Laura - "When I asked the photographer she said that she always sends files in KB and it shouldn't be an issue ...". One would expect to be able to enlarge to the capability of the camera, resolution and compression level are key. If they are low res highly compressed JPGs for $350 how happy should she expect you to be? You can buy a camera for 2x that. You really want a couple of frameable prints for that $, especially if was 15 min.
Answer: KB and MB are units to measure the amount of digital information.  Without getting into technical details, what is important for you to know is that a megabyte (MB) has about 1,000 times more digital information than a kilobyte (KB).
If a photographer provided a 1KB image to you, you have reason to be worried. If they provided a 900KB file - that is not very concerning. Keep in mind that the units can be used to describe the same amounts, such as 0.9MB ≈ 900KB.
In general, if the images look fine on your screen I would assume your photographer knows what they are doing and shared with you images to fit the use case for which you purchased them. If you purchased images to print, the photographer should provide images suitable for printing. If you only purchased rights to digital images without the intent to print, that is a different case.
Comment: @LauraHeden 2084x1528 is 3 megapixels. No professional photographer would be caught dead using a 3 megapixel camera today, it's obvious that the image has been resized. With that said, the texture of the canvas will obscure fine detail anyway, so the print might look OK; I'm afraid the only way to know for sure is to try it.
Comment: @LauraHeden I don't think you understand. MB vs KB is like pounds vs. ounces, they are just different units of the same thing.  Don't worry about that, just be concerned with the resolution, that's what determines your printability. Also, don't expect any professional or even serious amateur to give you the unedited images.  That being said, it is surprising that they deleted the originals, that's not typically done either.
Comment: The _resolution_ of the pictures matters more than the file size.  When you open these in a editor or viewer, you should see an image size like 2592x1520 or similar.  This is the size _in pixels_.  So what is that size?  Also, I have no idea why they would delete your originals so quickly.
Comment: Hi everyone again! Thank you for all your comments I have just gone in to check one of the images and it's as follows - width 2084x height 1528 pixels, resolution 300 - is this going to be ok if I tried to order a 16x18 canvas quality wise? Thank you all so much!
Comment: Hi thanks for this response, we paid for images to print - they range in size from about 200kb - 700kb. I asked for the unedited images just so we have them in MB to print and also offered extra money just so she could send them but she has said she has deleted the original pictures. I had a bad feeling when. She took 2 months to send - after his session so we have used someone else for his milestone pics since. I am just upset that I won't be able to print off good quality pics of my son or get them on a canvas- do you think printing at 16x18 will still mean the quality remains?
Comment: @Robin It's not *just* the resolution in pixel dimensions, though. The images may have significant artifacts from too-high jpeg compression.
Comment: @LauraHeden 2084x1528 is much too low for an 16x18 print. More like 7x5.
Comment: @mattdm - Fair enough, but I was just addressing the OP's misunderstanding and focus on the file size units. That is another factor that we don't really know about without some full res examples. We do know that with the resolution she has received is way too small for the size print she wants. If it was also saved at a low quality, then it's even worse again.
Answer: As some other answers have already pointed out the measure unit means nothing in itself, although it's obvious in this context that you meant something entirely different. While it's true that you can measure the size of a file both in KB and in MB, in this context you clearly mean "the pictures are less than one megabyte"
That said, as everyone wrote, the size of the picture itself is not a straight index of quality: most image formats perform some kind of compression, which means they use a plethora of mathematical algorithms to store a bigger quantity of information in a smaller file; this can happens by trading off the quality of the picture, and on the other hand it heavily depends on the information stored in the picture itself, so sometime you can happen to have a small file with an high quality image or a big file with a poor quality image.

Finally, all cleared, let's come to the core of the question: will you get decent enough prints from this picture?
Well, quality is way subjective, and on top of it it depends not only from the size of the print but from the distance you plan to look at them. So here it comes some starting point, to at least have a rough measurement; just remember nobody can measure your expectations :-)
The magic word in printing is "DPI", which stands for "dot per inches"; this is a measure of how many "points" we fit in a inches when printing.
Let's take a 2084x1528 pixels image and print it at 300 DPI. Math it's easy:

2084 / 300 = 6.94 inches
1528 / 300 = 5.09 inches

So at 300 DPI, for example, you can print your pictures at a size of 7x5 inches. Stay with me, we are nearly finished.
I used 300 DPI 'cause is a way common number when it comes to high quality printing, but that's not a magic number. What's the next step? Well, pick your quality!
As I wrote most of it comes from your own expectations, but you can always start with some "scientific evidence". Taken from one of the many website reporting this table, here is a list of common DPI numbers you can use a starting point for your decisions:

Finally, two additional advices:

You can always print one single picture and see the result. On a different note, the photographer said she trashed the originals, so you have no other choices. On a different different note she may be hiding to you that she still has the files, and if you order prints from her you'll get a better result. On a different different different note, this is a terrible photographer: a professional puts its logo in a way which doesn't draw away the eyes from the subject of the picture, here she did the total opposite. And she trashed the original, which is a bad thing for her to do
As a last resort, you can actually try to ask someone to enlarge the picture while applying a good sharpening algorithm, so that when printed it could ("could") give a better result. Again, "could".
Comment: +1 to all of this, but it's also with adding that high jpeg compression is another way to squeeze file size down without reducing pixel resolution, and the resulting compression artifacts will also affect how a print looks.
Comment: I'm glad you spotted the actual resolution posted as a comment to another answer. It's possible that the photographer was simply ignorant of this information; if her customers all received 8x10" prints they might not have noticed anything was wrong, 191 dpi is still pretty good.
Comment: In this context it should be ppi (pixels per inch). Dpi (dots per inch) for a printer are sub-pixel level drops of ink that, when combined with other drops (dots) of other colors of ink, combine to render a single pixel.
Answer: Your intuition is right. Modern cameras produce higher resolution than pictures you posted. Also the photos have the photographer logo, so the image is a result of post-processing in a graphic editor. For example the child skin on forehead looks edited (fashion magazine like smooth).
Best is to ask the photographer also to send you the original camera files. They might not look as fancy, but they are like negatives, preserving all information from the photo.
If you like the visual edited result, then maybe ask the photographer to send the image saved in PNG-24 format (it contains more information than Jpeg). Or if the photographer agrees, the original graphic editor files (e.g. PSD or TIFF).
Comment: Something is definitely wrong when someone feels the need to airbrush a baby's skin.


What is the definition of a binary relation?

Question: According to http://en.wikipedia.org/wiki/Binary_relation it is first defined as "a collection of ordered pairs of elements of A" and then as "an ordered triple (X, Y, G) where X and Y are arbitrary sets (or classes), and G is a subset of the Cartesian product X × Y. The sets X and Y are called the domain (or the set of departure) and codomain (or the set of destination), respectively, of the relation, and G is called its graph." What is the correct definition of it? Also according to http://en.wikipedia.org/wiki/Function_%28mathematics%29 a function is a relation between a set of inputs and a set of permissible outputs with the property that each input is related to exactly one output. How a function can be a relation between sets? Shouldn't it be a relation on sets? Because defined like this, one can think of a function as an object that relates an input x to output f(x) while what it really is is an ordered triple (X, Y, G). Is there anything significant behind these definitions or it's just abuse of definitions and words?
Comment: I would recommend you split this question into one about equivalence relations and one about functions.
Answer: You have many questions, I'll try to adress them all.
A binary relation, as you read is just some set $R$ which is a subset of the cartesian product of two sets $A$ and $B$, that is $R \subseteq
 A\times B$.
An example may ilustrate this:
Let $A=\{\dots,-4,-2,0,2,4,\dots \}$ (the set of even numbers), $B=\{1,3,5\}$.
Then a relation $R_1$ could be $R_1=\{(-4,1),(-4,3)(0,5)\}$
We usually denote a pair $(a,b)$ of a relation with the notation $aRb$ meaning a is related with b.
A function is a relation between two elements of two given sets condition that for each element in the domain there's one and only one image(*).
(*)That is: if $R$ is a function, $x_1\in Dom(f)$ and $y_1,y_2\in Im(f)$,
$$
x_1Ry_1 \wedge x_1Ry_2 \iff y_1=y_2
$$
Comment: I don't understand. How can a function be a relation between two elements of two given sets when a relation is a set?
Comment: Do you understand the concept of a cartesian product?

To give you an example, lets say we define a function $f: \Bbb{N} \rightarrow \Bbb{Z}: f(x)=-x^2$. We can denote this function as a set of ordered pairs of the form $(x,f(x))$, in this case: $(x,-x^2)$. The set being some set $R=\{(1,-1),(2,-4),(3,-9),...\}$ describes completely this function.
Comment: It seems I am not so good with words. Lets try this way: We define the word relation to denote a subset of the cartesian product $A \times B$. Now you say that a function is a relation *between two elements* of two given sets, in other words, "a set between two elements of two given sets" and i think this has no meaning. If a function is a relation (subset of $A \times B$), then you can say that an element (a,b) is in the set, where a is an element of A and b of B, and that 'a' relates to 'b'. Am I right?
Comment: Yes, the only thing missing (and the most important to the concept of a function) is that for every $a \in A$ there exists a unique $b \in B$ such that $f(a)=b$, that is why a relation like x=y^2 is not a function.

I'm sorry if I made my answer unclear, I'll try to rephrase it.


Slack: How to open replies with the keyboard (without mouse)?

Question: How can I open the "7 replies" with the keyboard (without a mouse)?

I am using the slack web-app.
Answer: You can use up and down arrow keys to move through messages. When you reach the message with thread replies (in your case, 7 replies), press the right arrow key to open thread messages panel.


Can't find mesh in object mode

Question: I've imported a mesh, and it's in the scene collection, but nowhere to be found. I looked around, nothing.
Answer: The first thing to check is that the object is visible. The eye icon beside the object name in the collection should be white/open. I'm assuming you checked this, but just in case.
Another possibility is that the object is large enough that it's outside the distance that Blender will display in the viewport. The viewport in Blender by default will only display 1000 meters deep (referenced from wherever you're currently viewing). Select your object in the collection, then open the properties panel with N and look at the dimensions. If they're a lot larger than that 1000 meter limit, Blender just isn't showing the object even though it's there. If that's the case, scale the object down until it's visible.
Blender 2.8 and later also has the ability to filter the viewport display by type. At the top right of the viewport there's a cursor/eye icon. Click that and make sure meshes are set to visible.
EDIT: Another thing that I have seen is some sort of disconnect between the object and it's corresponding mesh data. If you click the little arrow beside the object name in the outliner, does the mesh data appear? It should have the same name as the object, just with a green triangle icon in front of it. If not, it's an issue with the import or the file itself.
You can also try edit mode. If you enter it on the object and select everything with A does it say you have anything selected?
One final option is to add another object, such as a cube, and delete all its vertices in edit mode. Then in object mode, go to the Object Data tab of the Properties Editor and select the mesh data of your imported object.
Answer: I've had that happen before with some meshes when I've imported them, usually because the origin point wasn't right and the mesh was scaled too big. Press "t" on your keyboard to bring up the left side toolbar. Click the black drop down menu under the edit tab, make sure your mesh is selected in the scene collection. Click "Origin to Geometry" then press "Shift" + "S"  and select "selection to cursor". This will center your mesh to the 3D cursor. You may have to scale your mesh down which you can do my pressing "s" and then left clicking to set the scale.
Comment: If I'm not mistaken, you're not using the same version of Blender. The question mentions Collections, which only exist in 2.8 and newer, but the toolbar has changed in 2.8 as well and no longer has the options you mention.
Comment: Yeah, I've been using 2.79, my bad.

Can't find mesh in object mode


Adding Google Analytics and Indexing

Question: I have a particular website that I want to add Google Analytics to, however I don't want it to get indexed because of that.  Will adding Google Analytics make Google start indexing my site?
Comment: If you don't want your site indexed you must explicitly block it from doing so. Google will index your site otherwise and you cannot hide it from them.  So block it immediately if you do not want it indexed.
Answer: There is no reason for Google to index your website just because of the GA code (it might index it through other methods though, i.e. - links to your site). Moreover, Google obeys robots.txt and the META ROBOTS protocol, so to prevent your website from being indexed by Google, you may upload a robots.txt file with the following instruction
user-agent: googlebot
Disallow: /

If you want to disallow all SEs, then replace Googlebot with *. However, do note that despite adding the robots.txt file, your website will still show up in Google if your URL is searched with but it won't display any content from your website on the search results.
If you want to completely avoid getting into the google index, add the following META ROBOTS tag in the  of all your pages
<meta name="googlebot" content="noindex">

If you don't want to be indexed by any search engines, replace googlebot with robots in the above meta tag
Answer: Google will begin to index your site the moment it finds it, GA installed or not. I suppose adding GA to your site may help them find it faster, but if you do not want your site indexed you need to take explicit steps to stop that from happening with proper no-indexing and a robots.txt file.
It is actually even a little more involved than that, so here is a link to a page where Matt Cutts, from Google, goes into more detail.
https://www.mattcutts.com/blog/google-noindex-behavior/
Answer: There are two ways to keep your website deindex.

Use noindex tag in your html code. This will tell crawler not to crawl your website for search engine indexing.
Add disallow tag in the robots.txt file for not crawling your entire website.

Adding Google Analytics and Indexing


Wouldn't micro black holes in the atmosphere have noticeable effects?

Question: If there are extra dimensions of space,the force of gravity would (in microscopic distances) increase way more than a factor of 4 times when the distance between masses is halved,which is the case in our three spatial dimensions. This makes the energy required to create a mini black hole fall in the TeV range ,possibly allowing particle accelerators/colliders such as the LHC and high-energy particles in the atmosphere to create one. Let's say,then,if in the case that there are mini black holes being produced naturally in the atmosphere,wouldn't the Hawking Radiation evaporated cause some detectable effects?
Answer: Take a look at Giddings, High-energy black hole production, https://arxiv.org/abs/0709.1107 , specifically the sections titled "Signatures" and "Cosmic ray production," and also Giddings' reference 33. Basically the answer seems to be that yes, it would be observable, and in fact the nonobservation of such events may by now be sufficient to rule out large extra dimensions. My understanding is that large extra dimensions are also pretty much ruled out at this point by LHC data. Others may be able to supply more recent references.
Comment: here is a recent review talk of predictions,including for the LHC.  http://www.physics.ntua.gr/corfu2016/Talks/ignatios_antoniadis@polytechnique_edu_01.pdf I suppose that with the new conferences in 2017 we shall see the analysis of the recent higher energy data


Is there any relation between BSON storage for mongoDB and MySQL storage?

Question: I am working on an application where I need to make analysis that what will be the storage size of BSON structure if same data is stored which is stored in MySQL. Basically I am comparing MongoDB and MySQL storage. Is there any relation between them? or some formula which gives size of BSON storage?
Answer: In each database, there is no one answer to what size something is when it is stored.  In MongoDB there are several factors to take into account, for example:

What types are being stored (BSON having more types than JSON, and with each getting different allocations)
Should you include the (16 byte) record header?
Is the collection you are storing the data in using powerOf2Sizes?
Are you using the default storage engine? (pluggable engines were just announced at MongoDB World 2014 and Toku has provided a fork with very different storage characteristics for some time)
Do you need to include index size in the storage calculation?
Does running a compact/repair alter the storage characteristics?

That note about storage engines is a good one.  I am not a MySQL expert, but I know there are multiple options there (MyISAM, ARCHIVE, MERGE and others) that will again have very different storage characteristics just within MySQL itself.
There's no easy answer on this one I'm afraid - you are going to have to tightly control the data being stored, look for equivalent/fair types across the two databases to store.  Then you will need to familiarize yourself with the intricacies of each in terms of how to measure storage and how different actions might impact that storage.


What is the easiest way to "listen" to the network?

Question: If I want to automatically check up on payments and ensure they are not double spends and check the confirmation count, what is the easiest way to do so?
Answer: https://blockchain.info/ , 'nuff said.
They feature live events of transactions appearing in the network, as well as blocks.
Other than that, there is this - http://bitcoinmonitor.com/ . It shows such events graphically, along with currency trades.


How can I use Edge Creasing with OpenSubdiv?

Question: I see that OpenSubdiv has been integrated but could not find any material about using it for utilizing its edge creasing capability to create harder edges in subd-modeling instead of using support loops. Of course I fiddled around but could get no result, just strange shading as if it's not working properly.
It seems to makes subd and hard edges so much easier as shown here for example in 3ds Max (video by Arrimus 3D)
https://www.youtube.com/watch?v=QFckVSyvVy4
Answer: OpenSubdiv has not been completely implemented into Blender. It is currently only used for viewport playback speed for animators.
Official Document about it's implementation
Limitations
There are number of limitations which are not resolvable with the current OpenSubdiv release and current OpenGL profile of Blender itself:

Smooth normals aren't currently correct. This goes into limitations of GLSL level we can currently use in Blender and what OpenSubdiv can provide us. It's being worked on though with high priority.
No OSX support, Historically Blender is using rather old OpenGL API and OpenSubdiv is using OpenGL 4. This makes it impossible to make Blender working with OpenSubdiv on OSX due to policy from Apple which forces everyone to drop older OpenGL code if newer API is used in application.
No UV maps support in viewport. This limitation is caused by OpenSubdiv which currently doesn't have nice support of UV mapping evaluation on GPU and has no way to calculate UVs on CPU as well.
No generated coordinates support. Generated coordinates in blender requires calculation of undeformed mesh on CPU which makes it rather really complicated to use OpenSubdiv in such configuration because all it's data is on GPU.
Tools which requires having mesh on CPU (for example snap tools) will fail for OpenSubdiv mesh. This also includes areas like geometry primitive counter in the Info header.
Currently shading is limited to a single material only. This is easy to resolve from Blender side and will happen sooner than later.
Loose edges and vertices are not supported.
Auto split is not working yet
Loop normals are not supported yet as well


BX cable connection to vapor tight luminaire

Question: I have some vaportight luminaires that I plan to install in a garage. The garage has bare stud walls, so all wiring is run in 3/8" BX armored cable. The luminaires came with a cable gland connection and approximately 1 ft of SOOW wire stubbed out. I can open the fixture and remove the wiring, but the BX cable is much too large to fit through the gland. My understanding of the electrical Code (Salt Lake City) is that all exposed wiring in garages has to be protected from damage. I don't believe SOOW wiring is rated for permanent installation. How should I connect the BX cable to this light?
Comment: Can you post photos of the installation instructions for the luminaires? Is there enough room to gland the free end of the SOOW whip into a "side" j-box for the splice to the armored cable?
Answer: The normal thing is to either add a plug to that cord or tie it in at a junction box. MFG instructions override code in this case. Current code in a garage if an receptacle it must have GFCI protection no exceptions.
Comment: No exceptions even for freezer or fridge? I thought a non-GFI circuit was acceptable for those...
Comment: If a local exception allows it but the 2017 code doesn't allow it. For example in Oregon table 1 E of the revised statues states if the device is not easily moved the GFCI device can be omitted.


Using an old domain with new content reflects SEO?

Question: I have searched for my question on google but i didn't found an answer, i have a deals website (e-commerce) but actually it's not working, it's only online. I'm expecting to remove the content of the website and use its domain for another website e-commerce but with different niche, with new content. It's a good idea? this will not reflect SEO for the new website?
Answer: The main issue that you will encounter is that existing backlinks can become non-revelant which in time can become detrimental to your rankings.
Nowadays it is better to seek out a old domain that has on-topic links or one that has few links to none.
Relevancy is everything! in this day and age .
Comment: I have few backlinks
Comment: If they are relevant or nofollow then you should be okay.
Comment: no they are follow
Answer: If the site you will be putting on there is something similar, where the backlink environment will be beneficial and also fits to the new website, I don't see a problem. Otherwise, as you mentioned with a different niche, it might be not as good of an idea. In this case it might be best if you maybe look for an aged domain to buy that already has a link environment that fits to your new niche & website.


Richtextbox control in Provider hosted app

Question: Is there a way to use RichText Control in provider hosted app? I am currently using SharePoint 2013.
Comment: Amit, I have removed the version tag since the question shouldn't be version specific. Free to roll back if you think it should be
Answer: Check CKEDITOR. It comes as a nuget package and you can add it in your project and use it. We have used this in provider hosted app MVC project.


List of recommended patches for specific Sitecore version

Question: Is there an easy way to find a list of recommended patches for a specific Sitecore version/update? I can see that individual patches are recommended for a particular version but I can't find a a list of all recommended patches.
Comment: Are you referring to environment patching.  The patches that Sitecore provides as examples, are there to help it to fit into specific scenarios.  In other words, no size fits all.
Comment: It's a good idea in theory, but I think it would be too complex to maintain such a list - perhaps a wiki would work though so the effort is distributed.
Comment: @DylanYoung I was referring to support patches.
Comment: I don't think that such a list exists. In theory you could go through all 1500+ repositories on https://github.com/SitecoreSupport/ and check the corresponding release pages for the affected Sitecore versions.
Answer: As commenters above have said, there isn't a definitive list of patches for a specific version.
Answer: To find all security patches for a specific Sitecore version, you can refer to the Security Bulletin section on the Knowledge Base website:

Browse to https://support.sitecore.com/kb
Click on the Security Bulletins tab to see the most recent security bulletins and learn steps to make your Sitecore installation more secure.
You'll see filters on the left side to select language, Sitecore product and Sitecore versions.
Selecting the Sitecore version will give you all the patches applicable for this version.
Answer: Even though there is no definitive list of patches for a specific Sitecore version, the best approach to this is to contact Sitecore Support. By providing them your Sitecore version, they can easily pull out the list of recommended patches that you required.
I did a Sitecore upgrade from 7.2 to 8.1 and the 7.2 instance had several Sitecore patches. By contacting Sitecore Support, they told me which patch is still required on the Sitecore 8.1.


PN junction band gap - equal across all devices?

Question: With a given material eg silicon, is the band gap constant across devices? For example, at a constant temperature is the band gap of a diode ("diode drop") exactly the same as that of (say) an NPN transistor? If not, what kind of variation would one expect between devices?
Comment: There is no such a thing as "PN junction band gap". Are you asking about the band gap or the Diode/PN junction drop? See my answer below.
Comment: @Curd Diode drop. Band gap applies to pure material
Answer: For a 100% pure element (no doping) it will be the same.
For a practical diode or transistor, the dopant levels and purity have quite a large effect on both the forward voltage and temperature coefficient.
For pure silicon the tempco is -2.1mV / degree C, but the venerable 2N3904 usually has -2mV / degree C (depends on manufacturer).
If you read the SPICE files for some devices, this can be inferred from ideality factor as seen in the Schockley diode equation.
For a diode, this is N in the model.
For a transistor NF is the forward mode ideality factor and NR is the reverse ideality factor.
A perfect device will have N=1.
Here is the model for the MMBD4148 small signal / switching diode

*SRC=MMBD4148;DI_MMBD4148;Diodes;Si;  75.0V  0.250A  4.00ns   Diodes Inc. Switching Diode
.MODEL DI_MMBD4148 D  ( IS=300n RS=0.422 BV=75.0 IBV=2.50u
  + CJO=1.99p  M=0.333 N=2.77 TT=5.76n )

Here N is 2.77 (the higher this value, the less ideal it is)
Looking at the 2N3904 model

Model Generated by MODPEX     *
  Copyright(c) Symmetry Design Systems
All Rights Reserved        *
UNPUBLISHED LICENSED SOFTWARE   *
Contains Proprietary Information *
Which is The Property of      *
SYMMETRY OR ITS LICENSORS      *
  *Commercial Use or Resale Restricted *
by Symmetry License Agreement    *

Model generated on Aug 7, 01
MODEL FORMAT: PSpice

*$
.MODEL Q2n3904 npn
  +IS=1.26532e-10 BF=206.302 NF=1.5 VAF=1000
  +IKF=0.0272221 ISE=2.30771e-09 NE=3.31052 BR=20.6302
  +NR=2.89609 VAR=9.39809 IKR=0.272221 ISC=2.30771e-09
  +NC=1.9876 RB=5.8376 IRB=50.3624 RBM=0.634251
  +RE=0.0001 RC=2.65711 XTB=0.1 XTI=1
  +EG=1.05 CJE=4.64214e-12 VJE=0.4 MJE=0.256227
  +TF=4.19578e-10 XTF=0.906167 VTF=8.75418 ITF=0.0105823
  +CJC=3.76961e-12 VJC=0.4 MJC=0.238109 XCJC=0.8
  +FC=0.512134 CJS=0 VJS=0.75 MJS=0.5
  +TR=6.82023e-08 PTF=0 KF=0 AF=1

Here the forward ideality factor is 1.5 (much closer to  an ideal diode). This is one of the reasons that temperature sensors often use a diode connected transistor.
So the forward voltage is process dependent (as is reverse leakage).
Comment: I've read the Ideality Factor is controlled by the abruptness of the junction. Is that true?
Comment: From memory (a long time ago) the abruptness and ideality factor are inter-related but I don't recall the abruptness *controlling* it (I could be wrong). :)
Answer: No, it certainly isn't equal for all devices. Semiconductors are not made of pure silicon, but silicon that is carefully mixed ('doped') with other materials. This is done to influence the bandgap voltage, creating areas that are more positive or more negative than other areas on the device. This is how the P and N regions in a PNP transistor, diode etc. are made.
The bandgap is very sensitive to the dopants, and will usually differ slightly even between devices of the same type.
The specifications of the device will usually show what kind of spread can be expected in forward voltage for a given current and temperature.
Answer: You said

...is the band gap of a diode ("diode drop")...

suggesting that both things are the same, which is not the case.
Band gap and diode drop are two completely different things. Common for both is only that both are measured in Volts.
Band gap is a constant specific to a semiconductor material (a material constant). It is the difference between the potential of the lower limit of the conduction band and upper limit of the valence band.
For Si it's about 1.1V (with only small dependency on temperature and doping).
Diode drop is a constant specific to a PN junction, i.e. a specific semiconductor device.
For Si PN junctions it is about 0.6V; For Si Schottky junctions it is only about 0.3V; at room temperature (with substantial dependency on temperature).


Leaking pipes somewhere but don't know where

Question: I had frozen pipes during the recent winter storm in TX. Now the weather warms up and water came back. My Flume device detecting water leakage about 2 gallons per hour for the last 24 hours.  No leaking signs inside the house or attic. Suspect it's the underground pipe but how do I pinpoint where?  Called the insurance company and they have not replied back. Help please
Comment: Have you turned off your main valve (the first one after the water meter)? If that's off and the meter still shows flow, then the leak is in the underground pipe. If no flow with that off, the leak is inside your plumbing and you'll need to start hunting.
Comment: Hint: 48 gallons that you still can't see means it's not upstairs ;)
Comment: turn off mains. wait one hour. open faucet. If nothing comes out, you have a leak. If a little comes out then stops, you're probably fine.
Comment: 2 gallons an hour is not a lot there could be a "pinhole" leak in a pipe in the wall. If you can not hear water flow by listening method look under the home. A few years back my daughters home sprang a leak in a wall it was small but after a week the small spray cut through the drywall she did not have a monitor, did not notice anything until the spray cut through. I was surprised it took so long. I had to cut a chunk of Sheetrock out but it needed to dry out anyway sweated in a new piece of copper and things were fine. After looking at those flume devices you pay for the water from that point
Answer: I use a broom stick or dowel place it on the ground then my ear to the dowel.
Yes a 3 or 4' dowel works better than one you have to kneel down for.
Ipoh are turning the stick into a stethoscope. I listen if I can here water I move on until I can no longer hear the water movement.
I take extra time on sidewalks or driveways as these are places pipe likes to break.
In some cases you can hear the flowing water pickup rocks and hit the concrete.
The break can also be under the house. By using this method I have found broken pipes and even located drain pipes under slabs when I did not know where they went having someone tap on the pipe with a wrench or hammer may help you to find it in some cases if it turns and you loose the sound.
If you find a spot the water noise stops turn the water on in the house if you now hear it the break is usually 1-2' closer to the main, I have had really good luck using a broomstick or even a 1/4" wood dowel I think anything solid would also work to transmit the vibrations.


Hamiltonian vector field - confusion

Question: I am trying to understand the definition of a Hamiltonian vector field. I take as my symplectic manifold the sphere $$p_1^2+p_2^2+p_3^2=1$$ with symplectic form $$\omega=p_1 dp_2 \wedge dp_3+ p_2 dp_3 \wedge dp_1 + p_3 dp_1 \wedge dp_2.$$ I take as the Hamiltonian $H$ something very simple, namely, $$H(p_1,p_2,p_3)=p_1.$$ Then $$dH=dp_1.$$ By definition, the Hamiltonian vector field $X_H$ is the unique vector field such that $\omega(X_H,\cdot)=dH$. I compute $$\omega(X_H, \cdot)=(p_2 X_3-p_3 X_2) dp_1+(p_3 X_1 -p_1 X_3)dp_2+(p_1 X_2-p_2 X_1)dp_3,$$ so that equating coefficients of $dp_i$, I get
$$1=p_2X_3-p_3 X_2$$ $$0=p_3X_1-p_1 X_3$$ $$0=p_1 X_2-p_2 X_1,$$ which is inconsistent. What went wrong?
Answer: You have to solve the equation $dH=\omega(X_H,.)$ on the sphere, not on $R^3$. The form $\omega_H$ has max rank 2 on $R^3$, so in $R^3$ the equation does not has always a solution, you have to write the equation of the tangent of a point of $S^2$ and the equation of a vector field of $S^2$ tangent to each of its point

Hamiltonian vector field - confusion


How to find the locus of common points of two segments that belong to the same line

Question: i read various related answers. In particular here (How do you detect where two line segments intersect?) it is greatly explained how to find the intersection between two segments and to check for parallelism and  if they belong to the same line. I wrote a fortran program following that great idea. The problem now consists of finding the union segment when the two segments belong to the same line. Here I found a C++ code (Detecting coincident subset of two coincident line segments) but it is not explained and I cant read C++ but only Fortran (here is a useful image depiction the problem, posted in another question but with no useful answer http://judark.myweb.hinet.net/parallel.JPG ). What is the best language-agnostic algorithm to find the  locus of common points (i.e. the union segment, i.e. the two points defining this union) of two segments belonging to the same line? I have managed to do it with planty of "if" computing all the manhattan distances between the points (http://en.wikipedia.org/wiki/Taxicab_geometry) but I was wondering if there is a better way to do it.
Thanks
A.
Answer: If the two segments are on the same line and do overlap, then the union is simply the segment between those two of the four end points which are farthest apart from one another. So simply compute all squared distances (no need to compute square roots) and identify the pair with maximal distance. This approach handles many degenerate cases nicely, including the case where all 4 points coincide and the union of two equal points is simply that point.


Can you find the maximum or minimum of an equation without calculus?

Question: Without using calculus is it possible to find provably and exactly the maximum value
or the minimum value of a quadratic equation
$$ y:=ax^2+bx+c $$
(and also without completing the square)?
I'd love to know the answer.
Comment: Without completing the square, or without calculus?
Comment: Also here is http://meta.math.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference for formatting your functions properly.
Comment: Odd question... No calculus, no completion of the square... I guess asking the teacher should work.
Comment: This is like asking how to win a martial arts tournament while unconscious.
Comment: That said, I would guess the ancient Greeks knew how to do this, and I think completing the square was discovered less than a thousand years ago.
Comment: For the Greeks, the maximum/minimum of a conic section was just that, it would be like us saying "solve for 5".  They didn't think of conic sections as embeddings into Cartesian coordinate systems.
Comment: @MattSamuel The Babylonians were solving quadratic equations c. 1700 BCE via a procedure equivalent to the quadratic formula. The modern innovation is to complete the square in algebraic notation rather than words.
Comment: @mattsamuel what brought me here was trying to help my kid with his algebra homework.  I would just use calculus but that obviously isn't what he is expected to do. It looks like DanielV's answer is a more complete version of what he is being taught.
Answer: The vertex of $y=x^2$ is $(0, 0)$.
The vertex of $y = Ax^2$ is $(0, 0)$.
The vertex of $y = A(x - k)^2$ is just shifted right $k$, so it is $(k, 0)$.
The vertex of $y = A(x - k)^2 + j$ is just shifted up $j$, so it is $(k, j)$.
Multiply that out, you get $y = Ax^2 - 2Akx + Ak^2 + j$.  So you get
$$b = -2ak \tag{1}$$
$$c = ak^2 + j \tag{2}$$
Solve (1) for $k$ and plug it into (2), then solve for $j$,you get:
$$k = \frac{-b}{2a}$$
$$c = a\left(\frac{-b}{2a}\right)^2 + j \implies j = \frac{4ac - b^2}{4a}$$
So the vertex occurs at $(j, k) = \left(\frac{-b}{2a}, \frac{4ac - b^2}{4a}\right)$.
Comment: So it works out the values in the shifts of the maxima or minima at (0,0) , in the specific quadratic, to deduce the actual maxima or minima in any quadratic. I think this is a good answer to the question I asked.
Comment: This is one of the best answer I have come across
Answer: We assume (for the sake of discovery; for this purpose it is good enough
if this is just an inspired guess)
that the curve $y = ax^2 + bx + c$ is symmetric around a vertical axis.
It's obvious this is true when $b = 0$, and if we have plotted
$y = ax^2 + bx + c$ for various other values of $a$, $b$, and $c$,
we may observe enough appearance of symmetry to suppose that it might be true in general.
So it's reasonable to say: supposing it were true, what would that tell
us about the minimum/maximum value of the polynomial?
We find the points on this curve of the form $(x,c)$ as follows:
\begin{align}
y &= c. \\
c &= ax^2 + bx + c. \\
0 &= ax^2 + bx = (ax + b)x.
\end{align}
Hence if $(x,c)$ is on the curve, then either $ax + b = 0$ or $x = 0$.
Setting $x_1 = -\dfrac ba$ and $x_2 = 0$, we can plug in these two values
for $x$ and confirm that indeed the two points
$\left(-\frac ba, c\right)$ and $(0, c)$ are on the curve.
Using the assumption that the curve is symmetric around a vertical axis,
the vertical axis would have to be halfway between
$\left(-\frac ba, c\right)$ and $(0, c)$, that is, it is
the line $x = -\dfrac b{2a}$.
If there is a global maximum or minimum, it is a reasonable guess that
it would be on this line, so let's see what we have at
$x_0 = -\dfrac b{2a}$. Plugging this into the equation and doing the
algebra to find the point $(x_0, y_0)$ on the curve,
\begin{align}
y_0 &= a\left(-\frac b{2a}\right)^2 + b\left(-\frac b{2a}\right) + c \\
&= c - \frac{b^2}{4a}.
\end{align}
So that's our candidate for the maximum or minimum value.
To prove this is correct, consider any value of $x$ other than
$-\dfrac b{2a}$. Any such value can be expressed by its difference
from $-\dfrac b{2a}$, that is, we let
$$ x = -\frac b{2a} + t$$
where $t \neq 0$. Now plug this value into the equation
and do the algebra:
\begin{align}
y &= a\left(-\frac b{2a} + t\right)^2 + b\left(-\frac b{2a} + t\right) + c
\\[.5ex]
&= at^2 + c - \frac{b^2}{4a}. \tag 1
\end{align}
If $a$ is positive, $at^2$ is positive, hence $y > c - \dfrac{b^2}{4a} = y_0$
for every point $(x,y)$ on the curve such that $x \neq x_0$,
and therefore $y_0 = c - \dfrac{b^2}{4a}$ is a minimum.
But if $a$ is negative, $at^2$ is negative, and similar reasoning
says that $y_0 = c - \dfrac{b^2}{4a}$ is a maximum.

Note that the proof made no assumption about the symmetry of the curve.
On the contrary, the equation $y = at^2 + c - \dfrac{b^2}{4a}$
can be used to prove that the curve is symmetric.
If we take this a little further, we can even derive the standard
quadratic formula from it.  The roots of the equation
$y = ax^2 + bx + c$ are the values of $x$ such that $y = 0$.
But as we know from Equation $(1)$, above,
if we make the substitution $x = -\dfrac b{2a} + t$, that means
\begin{align}
0 = y &= ax^2 + bx + c \\ &= at^2 + c - \frac{b^2}{4a}.
\end{align}
A little algebra (isolate the $at^2$ term on one side and divide by $a$)
gives us
$$
t^2 = \frac{b^2}{4a^2} - \frac ca. \tag 2
$$
In general, if $p^2 = q$ then $p = \pm \sqrt q$, so Equation $(2)$
tells us that
\begin{align}
t &= \pm \sqrt{\frac{b^2}{4a^2} - \frac ca} \\
 &= \pm \sqrt{\frac{b^2 - 4ac}{4a^2}}\\
 &= \pm \frac{\sqrt{b^2 - 4ac}}{\lvert 2a \rvert}\\
 &= \pm \frac{\sqrt{b^2 - 4ac}}{2a},
\end{align}
and recalling that we set $x = -\dfrac b{2a} + t$,
\begin{align}
x &= -\frac b{2a} \pm \frac{\sqrt{b^2 - 4ac}}{2a} \\
  &= \frac{- b \pm \sqrt{b^2 - 4ac}}{2a},
\end{align}
which is precisely the usual quadratic formula.

Is the reasoning above actually just an example of "completing the square,"
or is it sufficiently different from the usual method of "completing the square" that it can be considered a different method?
The equation $x = -\dfrac b{2a} + t$ is equivalent to
$t = x  + \dfrac b{2a}$; the method of completing the square involves
expanding $\left(x  + \dfrac b{2a}\right)^2$;
and in fact we do see $t^2$ figuring prominently in the equations above.
Certainly we could be inspired to try completing the square after
noticing how neatly the equation
$ax^2 + bx + c = at^2 + c - \dfrac{b^2}{4a}$
simplified the problem; but we never actually expanded the
binomial $\left(x  + \dfrac b{2a}\right)^2$, and we never subtracted
the original polynomial from it to find the amount we needed to
"complete" the square.
Instead, the quantity $c - \dfrac{b^2}{4a}$ just "appeared" in the
original equation as the result of a direct substitution.
I think that may be about as different from "completing the square"
as a purely algebraic method can get.
Answer: One approach for finding the maximum value of $y$ for $y=ax^2+bx+c$ would be to see how large $y$ can be before the equation has no solution for $x$.
First rearrange the equation into a standard form:
$ax^2+bx+c-y=0$
Now solving for $x$ in terms of $y$ using the quadratic formula gives:
$x= \frac{-b\pm \sqrt{b^2-4a(c-y)}}{2a}$
This will have a solution as long as $b^2-4a(c-y) \geq 0$
You can rearrange this inequality to get the maximum value of $y$ in terms of $a,b,c$. See if you get the same answer as the calculus approach gives. Remember that $a$ must be negative in order for there to be a maximum.
Comment: @Karlie Kloss Technically speaking this solution is also not without completion of squares because you are still using the quadratic formula and how do you get that???
Comment: Yes a variation  of this idea can be used to  find the minimum too
Comment: @KarlieKloss Just because you don't see something spelled out in its full detail doesn't mean it is "not used." The question then is, what is the proof of the quadratic formula that does not use any form of completing the square?
Comment: Yes, t think now that is a better question to ask. So this method answers the question if there is a proof of the quadratic formula that does not use any form of completing the square.
Answer: This is  almost the same as completing the square but .. for giggles.
If $a = 0$ we know $y = xb + c$ will get "extreme" and "extreme" positive and negative values of $x$ so no max or minimum is possible.
So if $ax^2 + bx + c = a(x^2 + x b/a)+c := a(x^2 + b'x) + c$ So finding the max/min is simply a matter of finding the max/min of $x^2 + b'x$ and multiplying by $a$ and adding $c$.
In other words .... wolog $a = 1$ and $c = 0$.
Now we know $x^2 + bx$ has only a min as $x^2$ is positive and as $|x|$ increases the $x^2$ term "overpowers" the $bx$ term.  Or if $x > |b|/2$ then $(x+ h)^2 + b(x + h) = x^2 + bx +h(2x + b) + h^2 > 0$ so the expression has no max value.
So we want to find the minimum of $x^ + b'x = x(x + b)$.  Let $y := x - b'/2$ then $x(x + b')=(y -b'/2)(y + b'/2)= y^2 - (b'^2/4)$.  As $y^2 \ge 0$ the min will occur when $y = 0$ or in other words, $x= b'/2 = b/2a$
So the max/min of $ax^2 + bx + c$ occurs at $x = b/2a$ and the max/min value is $b^2/4 + b^2/2a + c$
Okay, that really was the same thing as completing the square but it didn't feel like it so what the @@@@.


Git Branch in ZSH Prompt?

Question: When working on a git repository with multiple branches, how do I modify my zsh prompt to include my current active branch?
Answer: Use the vcs_info function in the zsh user contributions (included in the zsh package). Quick start:
autoload -Uz vcs_info
precmd () { vcs_info }
setopt prompt_subst
PS1="\$vcs_info_msg_0_$PS1"

It's likely that you'll want to make the output prettier. Since that's matter of personal taste, I refer you to the examples in the documentation.
Answer: Use oh-my-zsh.  It is an auto-updating collection of several dozen plugins and themes that make zsh even better than it is already.  Assuming that you have git installed already, it will automatically activate the git plugin, and then you're ready to go!
Answer: For those wanting something more lightweight, here's my heavily modified Zsh port of the bash prompt Gentoo came with by default when I was on it.
function parse_git_branch() {
    # Speed up opening up a new terminal tab by not
    # checking $HOME... which can't be a repo anyway
    [ "$PWD" = "$HOME" ] && return

    # Fastest way I know to check the current branch name
    ref="$(command git symbolic-ref --short HEAD 2> /dev/null)" || return
    echo " [$ref]"
}

prompt_gentoo_precmd() {
    path_prompt="%B%F{blue}%1~$(parse_git_branch)"

    PS1="$base_prompt$path_prompt $pre_prompt%# $post_prompt"
    PS2="$base_prompt$path_prompt $pre_prompt%_> $post_prompt"
    PS3="$base_prompt$path_prompt $pre_prompt?# $post_prompt"
}

prompt_gentoo_setup () {
    base_prompt="%k%B%(!.%F{red}.%F{green}%n@)%m "
    pre_prompt="%(0?..%F{yellow})%(1j.%%.)"
    post_prompt="%b%f%k"

    precmd_functions+='prompt_gentoo_precmd'
}

Git Branch in ZSH Prompt?


Were medieval city states like Venice and Milan feudal?

Question: I know they had lots of powerful factions and families, but Venice, for instance, was a republic, no? And Rome was a theocracy. If they were feudal, how did their respective governments work in a feudal system. If they weren't, how did they raise armies and such?
Comment: Please consult the Wikipedia pages for these city states (and the links therein). If you can't what you are looking for there, please edit your question to explain exactly what it is you want to know.
Comment: It is perfectly possible to merge the two  - to derive political legitimacy from republican principles, but to base economic exploitation on a feudal system of land rents.
Answer: Medieval Venice operated internally as more of an Oligarchy, as descent from a noble family was required for membership in its legislative body, which was also the body that selected the Doge.
However, nearly all its neighbors were operating under Feudal systems, so when necessary for the purposes of interacting with them, the Doge was roughly reckoned as a Duke. That is in fact where the word "Doge" (Venetian "Doxe") came from. Its Venetian for "Duke" (Latin "Dux").
Of course the line between Oligarchy and Republic is quite fuzzy. Likely the franchise in Venice wasn't significantly more restricted on a per-capita basis than that of 1788 South Carolina (a plantation society where voting required property ownership).
The Medieval Papal State, was a different beast. While the leadership position was appointed (calling it "elected" would be a bit of a stretch during that era), and had some obvious religious administrative responsibilities that most European states didn't have to deal with, the state itself operated much like any other medieval duchy. This includes raising armies and invading neighbors from time to time. The "clergy" involved in this election were typically puppets of whatever ruler owned the land they were sitting on, and the popes they elected were often just that ruler's younger-son relatives.
Comment: Also, I got curious and did a wee bit of research ... in 1800 SC reported about 13% of its population being free white males of voting age. Looking elsewhere, US states at the time had between 50% and 75% franchise for free white men. SC would likely have been on the lower end.
Comment: Venice was for much of its history nominally part of the (East-)Roman Empire. The title dux (=duke, doge) was given by the Roman Emperor in the 8th century (not roughly reckoned). While the relationship to Constantinople is not fully equivalent to a vassal-lord relationship , it had its similarities.
Comment: @R.K. - Yes, initially Leo II meant what he said with "dux", but at the time that just meant "military commander" (and he wasn't happy about it, just acknowledging reality). Later Doges kept the title long after Venice became independent (9th century, if not earlier). The modern term "Duke" evolved to mean a hereditary feudal noble two ranks under a king, and the Doge wasn't really that.
Comment: I note that beginning in about 1050 hte popes fought to become independent rulers, and beginning in about 1150 the people of Roman formed a commune and sought to gain power from the popes, so that power struggles in Rome were often complex.


Size Limit in response. Visualforce pages

Question: We have created an app that includes a Visualforce page with an Angular dev inside. We use Javascript Remoting / RemoteActions to connect the Javascript code to the Salesforce Server. We have faced two main problems: the total number of records retrieved by SOQL queries limit and the maximum MB limit. For the first one, we have solved it using the @ReadOnly annotation that allows as to do unrestricted queries against the database. But for the second one, we don't have a solution yet. The response is bigger than 40MB because we are managing more than 200K records. Somebody know how to solve this problem or maybe a different approach?
Comment: I think a different approach will be keyed on *why* you are accessing 200,000 records on a page view. Are you using aggregate information? Doing some kind of filtering in JavaScript?
Comment: Hi David Reed. The Visualforce page has an Angular app inside really optimize to work with big amounts of data and we store the information in IndexedDB in the browser. The user can interact really fast with a map inside (zooming, scrolling, applying filters...) without waiting every time for data from the server. this is why we want to collect all the data first and store it in the Indexed DB. We have implemented some kind of pagination to get the data with waterfall requests. The problem is that the total response size is really big (15-20 for 250k records).
Answer: Depending on your use case, you should be able to just query all of the ID values (<4.5MB worth of data) in a single query, then in subsequent callbacks, pass in about 10,000 Id values at once and collect all the results into a client-side cache. This will allow you to have a coherent initial query (because you'll have all the ID values), and then lazy load additional data from the server as you need to.
Alternatively, you can do pagination as myself and others have described in various answers on this site, other sites, blogs, and so on. There's a ridiculous amount of information you can find on the subject if you just take a moment to use a search engine. Your use case is not unique, people have done it before, and, despite warnings from others, will continue to do so in the future.
Browsers are amazing pieces of software, but asking it to load 200,000+ records in memory and render it all is just asking for a performance nightmare. You'll get much better performance if you load the data on demand, and unload it when you're done with it. Taking my ID suggestion above, you can have a small cache of ID values, then go up to the server and get just the data you want to show when the time is right.
Comment: Hi sfdcfox. Thank you for your detailed answer. We already have some kind of pagination implemented. We want the all the data first to create a map with all the Accounts geolocated. The performance, in that case, is really good in the browser. This is not the problem. The problem is the aggregate response time. We have already some pagination (request in a waterfall) but we are thinking about creating parallel request to reduce the waiting time.
Comment: But maybe there is a way to overcome MB limit for every response. Our pagination makes a number of requests in a waterfall. The first idea is to change that and create parallel requests, but we wanted to ask first the community to see if there was a much better approach.
Comment: @RobertoSolís You can't overcome the limits, which is why they're called limits. You should be able to make the data requests parallel, but the initial ID grab should be in serial, since it's all one query with a single cursor. Depending on your browser, I'd guess you can probably make 2-4 parallel calls at once. Since you know there's 40mb of data, I would split the data into 8 chunks and get 5mb responses. You'll get better performance that way.


Challanges to integrate sum types into json/protobuffer/toml/yaml?

Question: What challenges might arise when integrating sum types into data exchange or configuration file formats such as json, protobuf, toml or yaml?
Comment: I'm voting to close this question because it asks multiple questions; all those data exchange formats are quite different and would have different approaches.
Comment: What does "integrating sum types into ... json, protobuf, toml or yaml" even mean? Representing elements of sum types in those languages is already trivially easy.
Comment: @Seggan That sounds like 'needs more focus' to me.
Comment: @RydwolfPrograms that's possible :p
Comment: @user16217248 ah yes of course theres a close reason i overlooked
Answer: Depending on how easy it is to differentiate the types, you might be forced to make sum types tagged. For example, a type float | int would be impossible to infer from JSON, as JSON.stringify({a: 1.0}) === '{"a":1}' on most JS implementations.
Comment: @kaya3 oops, I thought they were synonyms, tmyk
Comment: This looks like a union type to me, not a sum type. A sum type is a tagged union.
Answer: Swift has native sum types with enum, and serialization in the standard library with Codable. Codable is usually used for JSON, but it's meant to be format-agnostic. So, let's see how it handles this:
enum SumType: Codable {
  case i(Int)
  case d(Double)
}

It encodes this as a nested object (example):
{ "i": { "_0": 5 } }
// or
{ "d": { "_0": 0.5 } }

The key _0 is just the default as it's an unlabelled value; you're allowed to have things like this:
enum MyError {
  case unrecoverable(message: String)
  case recoverable(message: String, suggestions: [String])
}

In which case the keys of the inner object would be message and suggestions rather than _0 or similar.
This approach is amenable to JSON, YAML, and TOML, which all support nested objects. I'm not familiar with protobuf, but given how common nested structures are in code, I'd be very surprised if that doesn't support them.


what is auth data in AES-GCM

Question: I am trying to understand AES-GCM and I do not understand what I should transmit to Auth Data during encryption. What kind of data is that?
Answer: Auth Data 1 as shown in the diagram is the optional "Additional Authentication Data". It's optional & need not be passed if your use-case doesn't need it.
You can use it for stuff which is not secret (like version number of your protocol, address of recipients or anything else)
The purpose of AAD is to send information along with the ciphertext that is not encrypted, but cannot be changed because the MAC is computed over the AAD and the ciphertext together.
For e.g. packet headers which are not secret but whose integrity you want to ensure can be there in AAD.
Answer: The relationship between Auth Data and Plaintext can be compared with that of a network packet header and payload. Modern ciphers provide provision to "authenticate" additional data that's not encrypted so that more robust protocols can be designed. Of course, if you don't have header, you can pass an empty bit string to it.

what is auth data in AES-GCM


'plecto, plectere, plexi', -tor/-sor form (agent noun)

Question: How would one add the agent noun suffix (normally -tor) to the verb 'plecto' (I weave/twist)?  It's been a few years — about 10 — but if I recall correctly, verbs whose stem ends in 't' uses -sor as the agent suffix.  This would be 'plectsor', which seems very unwieldy; however, plecttor is certainly not correct.  Obviously in English there are verbs whose agent form is irregular, and some which have no such form.  Is this the case with this Latin verb?  If this is the case, what would be the correct way to form the noun in theory?
Thank you in advance.
Answer: You seem to be missing the four part in the verb's dictionary entry: plectō, plectere, plexī, plexus.
The agent noun is derived from the perfect participle stem, which for this verb is plex-.
This stem is obtained by removing -us from the participle listed in most dictionaries.
To this stem you add -or, so the noun you are after is plexor.
(This kind of counts as -sor because x=cs.)
The participle stem tends to be indicated by -t- or -s-.
One important aspect of using the perfect participle stem is that you have one less thing to memorize.
There are exceptions, but they are rare.
Deriving agents from the perfect participle stem is an excellent rule of thumb.
Comment: Thanks!  Good to know this rule of thumb, I will keep it in mind.
Answer: Good question! Let's break it down.
The root of this verb is plect- (notably not plēct- which has a different meaning!). If you look it up in a dictionary you'll see the four parts plectō, plectere, plexī, plexus, which literally mean "I weave, to weave, I wove, woven".
Now, the suffix is usually written as -tor, but a better way to think of it is -or, without the t. You put it on the supine stem, aka the past participle stem, aka the fourth principle part: this is the last form listed in the dictionary, the one that ends in -us. In this case, it's plexus. Take the -us off and add the -or and you're done, getting plex-or.
To go a bit more in depth, most verbs use a suffix -t- to make the fourth principle part, but some instead use -s-, especially third conjugation verbs ending in dental consonants. This verb happens to be one of those! The actual reasons for choosing one or the other are unclear, but seem to go back to Proto-Italic or even Proto-Italo-Celtic. Back then, either one could be used, but the speakers generally picked one and stuck with it by the time of Latin.
So that's where the s comes from, but why don't we see *plectsor? Well, that is indeed what you get when you glue all the pieces together. But the combination ts isn't allowed within Latin words (with the singular exception of etsi which is really two words written together for convenience). So the ts simplifies to s, giving plecsor. Compare the word for "night", in the nominative: noct-s → noc-s → nox.
Finally, cs in Latin is written as x, as in duc-s → dux. This doesn't actually change anything about the pronunciation, it's just a spelling quirk. So our final result is plexor.
Comment: +1 despite my losing the race to answer the question. :) Isn't the choice between t and s the same in the agent noun as in the perfect participle, at least mostly?
Comment: @JoonasIlmavirta Good question! I hadn't thought of it that way, but it sounds like you're correct—let me think for a moment and see if I can come up with any counter-examples.
Comment: @JoonasIlmavirta I'm convinced you're right now! Edited my answer to reflect that. Even if there are some rare exceptions, that's a much more useful way for a learner to think of it.
Comment: Just to be sure, I asked [a follow-up question](https://latin.stackexchange.com/q/8947/79). I'm not aware of any counterexamples, but I don't know how universal it really is.


Bridge distribution mechanism says "none" despite it having been set in torrc?

Question: So I am running a new bridge relay at https://metrics.torproject.org/rs.html#details/D8931228F0FEB5668C7F5680D9B6CDB2AF86690E
Oddity happening, despite it being listed in the torrc confoguration to be distributed by email,the relay information says 'Bridge distibution mechanism: None". But also, the bridge states it is getting traffic in the tor log.
Here is the torrc:
Nickname udeservefreedom
ExtORPort auto
ORPort 00000
BridgeRelay 1
PublishServerDescriptor 1
BridgeDistribution email
ServerTransportPlugin obfs4 exec C:\ProgramData\chocolatey\bin\obfs4proxy.exe
Note that the port was excluded so as not to share that on here. Thank you. But I wonder why it still says no distribution mechanism despite that?
Thanks.
Answer: <code>Nickname udeservefreedom
ExtORPort auto
ORPort 00000
BridgeRelay 1
PublishServerDescriptor 1
BridgeDistribution email
ServerTransportPlugin obfs4 exec C:\ProgramData\chocolatey\bin\obfs4proxy.exe
</code>
Shoudn't be there an additional port for the obfs4?
Something like:
ServerTransportListenAddr obfs4 0.0.0.0:portnumber


5 vs 10 vs 15 speed

Question: I'm looking for a road bike that's primarily for commuting around town and pulling a trailer with two kids. It's been a few years since I rode so I'm a bit of a noob. Please give me reasons why one is better over the other, I'd prefer having easier upkeep as well.
Answer: One minor point:  In the US you hardly ever find 5/10/15 speed bikes, except perhaps at WalMart.  Generally there will be from seven to 10 cogs on the rear.
Re the "right" gearing, it depends on the terrain, but if it's at all hilly where you live and you'll be pulling a trailer, and you're not a gorilla, you need some low gearing to get the trailer up hills, so two or three front rings would be advised.
Maintenance is essentially identical for any derailleur-style bike.  There's a little less maintenance if you have only one front ring, but the difference is negligible.
Mainly you want to buy a decent quality bike from a reputable bike shop, then take it back once or twice in the first few months (at least the first visit should be free) to have it tuned up (since shift and brake cables stretch when the bike is new).  (You may be tempted to buy a fancy internal gear hub bike or some such.  Don't.  They're more expensive to buy and maintain, and generally less reliable.  Re disk brakes, there are some arguments in favor of them, but no compelling reason for you to go with disks unless you like to spend money.)
Otherwise, wipe the chain with a rag and squirt a little chain oil (from the bike shop) on it every few months.  (No need for this when it's new -- wait a few months.)  Every year or two haul it back to the shop for a tuneup (or learn to do it yourself).
Answer: There are two main things to consider:

What will be the largest (heaviest, faster) gear, and what will be your smallest (lightest, slower) gear, one for cruise speed and other for steep hills. It matters to know WHAT these gears will be, as they determine your maximum cruise speed and the maximum steepness you'll climb. Since you plan to ride with your kids in a trailer, you'll definitely NEED low gears;
How many gears you will have in between. As an extreme example, it would not be useful to have ONLY the above mentioned gears, since most the time you will want something in between. The more gears you have, greater the probability to find a comfortable gear for a given speed and/or effort level.

That is to say it matters not only how much gears the bike have, but how low and how high can they get.
As a suggestion, I would try a double compact or a triple chainring in front, with a rear cluster having the greatest cog around 28 teeth (for the hills), or 24 teeth minimum if you live in a flat area.
Hope this helps.
Answer: I'll give some insight from my personal experience...
I was looking for something similar to you.  I bought a 27 speed road bike that I currently use for commuting.  I live in a flat location and I find that I only really use 2 gears, 1 for acceleration and small hills, and another for straightaways.
Keep in the back of your mind the route you will take to and from your start point and destination.  If you are really using this bike for commuting you will probably have a prominent route that you take.  If that is the case, it may be best to minimize the maintenance and possibilities of problems by going for a 5 speed.
Also, for easy upkeep, shy away from embedded gear boxes. Instead go for an external cassette, you'll be happier because you will be able to do the basic maintenance on your own.
Comment: Whether internal hubs are less upkeep or more is entirely dependent on the quality of the hub. Quality hubs require less maintenance than a derailer rig, but they're also more expensive and slightly less efficient. It's also harder to find low gears in an internal hub.
Answer: More gears != more gearing range.  Are you in a hilly town or a flat one?  Traffic-jamming or cruising longer distances between stops?
Close gears (i.e., many gears) are great for touring in flatter country because you'll be more likely to have just the right gear for the grade, the wind, the load, and your condition, and be able to stay in it long enough to matter.
In hillier country or when traffic-jamming, you won't stay in one gear long enough to care how close to just-right it is or isn't; having enough gears to cover the conditions you'll encounter will be more important.
Comment: What you say is true to a degree, but it's hard to get a wide range of gears with a single front sprocket.  In particular, if you want a reasonably low gear for hill climbing and still a good gear ratio for running on the flat you probably need at least two front sprockets, on any conventional derailleur setup.
Answer: It goes down to where are you riding, Flat or hill, 20 meters difference on height is not a hill.
Keep it simple! the less gears you can have in your bike, the easier will be the upkeep, where 5 gears is optimum for flat area, and 21 for hills.
Do not buy a cheap bike, insist on good quality brakes and gear.(not excellent, as it is expensive without reason)
If you are not planing on going off road, use sleek road tires, even on a mountain bike.
No back suspension, as it will take your power away while pulling a trailer.
I used to pull on a trailer, get one that fits properly to the bike.

5 vs 10 vs 15 speed


Opening documents results in security warning

Question: I am a sharepoint beginner but help run our company site, and on it we have a resource library full of several libraries with urls to documents and files. We suddenly came upon an issue where clicking these files results in a security warning before downloading the file. Up to yesterday, clicking the urls of the file would open it as a new page in the browser, which is what I want the site to keep doing. This issue is happening on all of the browsers I've tested it on (chrome and edge).
This issue appears to be only happening on our main resource library site, as other sites with libraries are still opening documents fine in the browser without a warning.
The only recent change made to the library came from adjusting all of the views' column formatting to make it so that the titles would wrap the text and be one click links, rather than needing a double click. The JSON code for this change is as follows:
<code>{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "customRowAction": {
    "action": "defaultClick"
  },
  "style": {
    "white-space": "wrap",
    "cursor": "pointer"
  },
  "txtContent": "@currentField"
}
</code>
I'm not sure if the issue is related to an MS Office update or if it is from making some adjustment to the sharepoint site, but any help on this issue would be greatly appreciated.
Answer: Please following steps:
1.Start >> Run >> gpedit.msc >> Enter
2.On the Local Group Policy Editor, click on Computer Configuration >> Administrative Templates >> Windows Components >> Internet Explorer >> Enable "Turn Off the security settings check feature" option

3.On the Local Group Policy Editor, click on User Configuration >> Administrative Templates >> Windows Components >> Internet Explorer >> Enable "Turn Off the security settings check feature" option

4.Restart the computer


Trust desktop icons without clicking them manually in Ubuntu 18.04 Gnome 3

Question: After moving a .desktop file into the "Desktop" location ~/Desktop, it show the icon on the Desktop. For the first run you have to trust the application. Is there any way to trust it directly without clicking? chmod +x *.Desktop is already done to make the file executable
Comment: Sorry my solution only works on KDE, but I found this older solution which may still work in bionic, though it would still be more work than simply using the trust dialog for less than the number of new .desktop entries you find inconvenient https://askubuntu.com/questions/969231/17-10-desktop-files-are-no-longer-trusted/995690#995690
Answer: Desktop files can be trusted via command line:
gio set Your_desktop_file.desktop "metadata::trusted" yes

and the trust state can be obtained by:
gio info Your_desktop_file.desktop | grep "metadata::trusted"

NOTE:

You have to run this command with the same user as the owner of the desktop files
It only works if you run the command in the gnome shell (not via SSH)
To do this automatically at logon, you have to make a logon script what will execute an script, as this only run when Gnome is started. For example you can create an .desktop file in ~/.config/autostart/ what execute some shell script including the gio commands
Make sure nautilus-desktop is really started. You can create an while loop with a sleep 1 till nautilus-desktop run
Icon's will not refresh automatically. You can achieve this with pressing F5 on the desktop or restart nautilus in your autostart script. killall nautilus && nautilus-desktop & (the last & sign is to make sure the rest of your code will run. Otherwise it will stop the script there till you close nautilus-desktop process again)
Comment: It's not working for me. I checked the home metadata archive and `.desktop` owner, but I'm still receiving `gio: Setting attribute metadata::trusted not supported` error message
Comment: I have been looking for something like this for awhile so thanks to you both!  However, I ran into a couple issues.  First, the metadata file (~/.local/share/gvfs-metadata/home) was owned by root instead of my user for some reason.  I used chown to fix that.  However, now I get an error "gio: Unable to set metadata key".  Still looking for a solution for this.
Comment: This happen when you run this script in another user. It have to run with the same owner and also really in gnome interface (or autostart). It is usefull when you run this for `.desktop` files located in `~/Desktop`.
Comment: Awesome, glad it worked for you :)
Comment: I also had this problem. Running `sudo chown $USER:$USER ~/.local/share/gvfs-metadata/home*` solved it.
Comment: For LXQT, the command needs to be `gio set Your_desktop_file.desktop "metadata::trusted" true`. Maybe you can add that to your answer?
Answer: Inspired by the great answer of @Sander, i am quite happy with this approach in Ubuntu 18.04. I use this in an automated VM creation setup, where first the desktop icons are placed, and then these scripts are prepared. They are only executed at the first start.
I create a desktop file ~/.config/autostart/desktop-truster.desktop with the following content:
[Desktop Entry]
Name=Desktop-Truster
Comment=Autostarter to trust all desktop files
Exec=~/.config/autostart/desktop-truster.sh
Type=Application

Next to it, a script ~/.config/autostart/desktop-truster.sh, which is invoked by the autostart desktop file:
#!/bin/bash
# Wait for nautilus-desktop
while ! pgrep -f 'nautilus-desktop' > /dev/null; do
  sleep 1
done
# Trust all desktop files
for i in ~/Desktop/*.desktop; do
  [ -f "${i}" ] || break
  gio set "${i}" "metadata::trusted" yes
done
# Restart nautilus, so that the changes take effect (otherwise we would have to press F5)
killall nautilus-desktop && nautilus-desktop &
# Remove X from this script, so that it won't be executed next time
chmod -x ${0}

Comment: On ubuntu 19.10 `gio set "${i}" "metadata::trusted" yes` didn't work. Instead, I used the following: `gio set "${i}" "metadata::trusted" true` and now it's all good.
Comment: Exactly like this, good job @Janos Only thing when you remove the X from itself it will not run this anymore in case you put new icons in
Answer: You have to make the .desktop files executable (trust), which you can do by going to ~/Desktop in a terminal and issue the following command
chmod u+x foo*

Obviously use a wildcard suitable for your needs, then refresh your desktop. That would be more effort than the trust mechanism for a single entry, but save time if you imported say more than n entries (where n is your number of max inconvenience).
There are ways of monitoring the directory and automatically doing this with external tools but I would advise you to seriously consider the security implication of doing such a thing.
But there is no way of doing this within your DE that I am aware of.
NOTE: This works on KDE but apparently does not work on Gnome.
Comment: It's not that I can not execute them. If I don't make it "trusted" with the chmod you are suggesting, I am not able at all to open the .desktop file. After I have done the `chmod +x` I still need to click on every single entry on the Desktop and click on the button "trust". I have edited my question and added an image.
Comment: @Sander Oh, that's different to what I get, which is why I suggested that solution. I get a dialog showing me the command that will be run, asking if I want to run the application on first execution. After clicking continue, I never get the dialog again. But if I pre set the execution permission on the .desktop file, then I do not get the dialog on first or subsequent executions, it is simply _trusted_. Seems gnome and kde have different ideas about trust, I thought it was a Ubuntu mechanism and as such would be the same across DEs.
Comment: Ah, you are using kde. Guess that this must be a difference then, yes. After you make it executable with `chmod +x *.desktop` it ask this question. When you click once on "Trust and Launch" it will work forever. It's just the first time. Looking forward for the special trick! Thank you anyway :-)
Comment: @Sander found an old post that has a cli trick in it which I put in a comment under your question, maybe that will do it for you, wish you luck in your quest :)
Answer: I've adapted Janos answer to work for my setup (/etc/skel is created through pam_mkdir on an Ubuntu 22.04), by placing the following in /etc/profile.d/desktop-truster.sh (all users need to be able to read that file):
#!/bin/bash
# Trust all desktop files
for i in ~/Desktop/*.desktop; do
  [ -f "${i}" ] || break
  gio set "${i}" "metadata::trusted" true
done

# Restart nautilus, so that the changes take effect (otherwise we would have to press F5)
nautilus -q

The changes made:

replaced yes with true
removed the waiting as that did not work
uses nautilus -q to restart nautilus


How do I dual-boot Kali Linux With ISO (no CD/USB/DVD)

Question: I am trying to install Kali Linux 1.0.7 to my Windows 8.1 32-bit PC. I have the ISO, but I have no CD's, USB Sticks, or DVD in my home so I was wondering how can I install Kali Linux without CD/USB/DVD? I've tried UNetBootIn but that didn't work. So what do I do?
Comment: How did unetbootin  not work ?
Comment: Network install? https://superuser.com/questions/42263/how-to-install-windows-7-from-the-network
Answer: I guess you're trying to boot your PC from an ISO located on your hard drive.
I've never done this before and I don't know if it will work, but EasyBCD can add an ISO image to the boot menu. You can then boot from it and install Linux. After that boot back into Windows and use EasyBCD to delete the ISO boot entry.
See https://neosmart.net/wiki/easybcd/portable-entries/iso-images/
Comment: I've tried EasyBCD and whenever I start the OS, it takes me to a terminal called Grub4Dos and I don't know how to use it.
Answer: If you only want to install it without modifying your grub, I would place the ISO somewhere in the drive. Boot my machine, when grub menu appears I would go to command line grub, and from there start the ISO. It is easier to boot from a UUID so that you don't have to identify the chain position of the drive/partition you want to boot from. To idendify your drive UUID you can check your fstab which will probably be set that way, or just execute blkid which will give you de ids of your devices.
search --fs-uuid YOUR_DRIVE_UUID --set=root
set iso=Path_and_name_to_the_iso

You should load the modules you need if your drive have an ext2 partition insmod ext2 and so on...
set opt="findiso=$iso boot=live noconfig=sudo username=root hostname=kali"
linux (loop)/live/vmlinuz $opt
initrd (loop)/live/initrd.img

Finally just enter the command boot and your ISO will be loaded and you will be able to install Kali.
Becarefull when your installation is finished, since it will ask to modify your grub, you may want to modify it manually in your ubuntu installation or let the kali install set it in that partition (I'm talking about grub.cfg)
Edit: UUID is better if you use it in your grub.cfg, if you are going to type it (which is the case I'm talking about) it is better to identify the drive and set it root with (hd0,msdos1) as Ruslan Gerasimov stated in his post.
Answer: Unetbootin can make your external drive bootable with certain ISOs without formatting the drive - it keeps all the data and adds the MBR to it, along with some unpacked folders and files from the ISO. But be careful, it has an option to format the drive, tick that checkbox before pressing next.
If you want to install Ubuntu in a normal way, to separate the partition, then you'll need to write your ISO to CD/DVD/USB and then boot from it (you'll have to tell the BIOS about it). If you have had any linux distribution previously installed, you could add a boot menu entry to the GRUB and tell it to run certain ISO image from a specific drive.
Do you want to install Ubuntu to the same Windows partition? Because with WUBI you can install Ubuntu to a Windows partition alongside with your current Windows, just by running all stuff from Windows. See the link I put on WUBI.
If you had had Linux already then to install ISO without having CD/DVD ot USB, you could run it as LIVE from you hard drive. The steps for this are as follows:

Place your ISO file to /live:

sudo mkdit /live
sudo cp somelinux.iso /live

Add new menu entry to the grub.cfg

sudo gedit /etc/grub.d/40_custom
menuentry 'ISO Ubuntu 14.04 2014 Live' --class os --class gnu-linux --class gnu --class os --group group_main {
                set isofile="/live/ubuntu-14.04-desktop-amd64.iso"

         insmod ext2
         insmod loopback
         insmod iso9660
                loopback loop (hd0,msdos5)$isofile

                linux (loop)/casper/vmlinuz.efi  file=(loop)/cdrom/preseed/ubuntu.seed noprompt boot=casper persistent iso-scan/filename=/$isofile quiet splash --
                initrd (loop)/casper/initrd.lz

}

TO DO:

change in the menu entry above the code name for your partition, holding /live/somelinux.iso, in my case it's hd0,msdos5 because it is on /dev/sda5/
change the file name from somelinux.iso to yours, in my case I have: ubuntu-14.04-desktop-amd64.iso

update GRUB

sudo update-grub

reboot
Comment: I don't want to install Ubuntu. I want to install Kali Linux, and it's Debian 7 based. Plus, I want to install it to another partition without CD/USB/DVD. And I want to install it with Windows 8.1 Pro, and I don't have Linux already.
Comment: But ill try WUBI.
Comment: WUBI only works with Ubuntu, not different Linux OSes.
Comment: There are Kali tools which can be installed on Ubuntu
Comment: From my point of view having Kali (or Ubuntu + Kali Tools) installed on Windows partitions avoids a number of features from a variety of security principles of Unix and particularity Kali called to defend. But you know better what you do.
Comment: Whenever I install Kali Linux with Unetbootin, it takes me to a terminal that says Grub4DOS and I don't know how to use that.
Answer: please open your iso with the help of winmount into new drive then you click kali linux setup after it will open the menu takes your permission for starting the kali linux installation. You can give permission to them
Answer: The easiest, least-fuss way is to go buy a USB stick.  They're dirt-cheap. Even here in Australia you can get a 16GB USB stick for $5 ($1AUD ~= $0.70 USD).
Answer: You can extract an ISO to one of your HDD partition (be sure to format as FAT32), for example /dev/sda7, then use easyuefi to set a uefi boot item for this partition.
When you boot from this partition, select graphic installation, it will ask you to install from a CD, then you can go to command-line mode by alt + ctrl + F2. then type mount /dev/sda7 /cdrom to mount this partition as a CD.
After that alt + ctrl + F5 to go to the graphic mode and continue.
If there is still some errors,use key alt + ctrl + F4 to open the log output, and check the error.
For example the error is "/dists/kali-rolling not found", then you can make a dir names "/dists/kali-rolling",and copy -r dists/kali-last-snapshot/* /dists/kali-rolling/.
Switch to graphic mode and continue.  It seems everything will work!