What's your favorite Powershell command or script for system administration?

Question: What's your top Powershell command? Let's make a list and vote up the best ones!
Comment: @Jon: did you mean "cmdlet"?
Comment: Should be tagged as subjective
Answer: Get-Member is the king of PowerShell cmdlets.
Get-Member allows you to interactively explore objects' members and types' (with the -static switch) static members.
Answer: I like having a script for finding AD users:
$strFilter = "(&(objectCategory=User)(sAMAccountName=[USERNAME]))";
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher;
$objSearcher.SearchRoot = "LDAP://dc=[AD_Location]";
$objSearcher.Filter = $strFilter;
$objSearcher.SearchScope = "Subtree";
$objSearcher.FindALL()

Comment: This can be done in one line with the Quest AD cmdlets - they're free and super useful! http://www.quest.com/activeroles-server/arms.aspx
Comment: @Doug Chase
Yes, it's free, but some organizations won't let you use unapproved software, with really bad lead times for getting stuff approved, but scripts you write yourself are instantly available.
Comment: In case anyone sees this now and thinks this is a good script, if you have the RSAT tools installed, you can do this with a one-liner in Powershell 2.0: `Get-ADUser -filter 'Name -like "*"'` (replace "filter" with whatever)
Comment: Also see http://blogs.msdn.com/adpowershell/default.aspx!
Answer: I have to go with get-help.  This cmdlet is the key to finding the functionality of other cmdlets.  A close second would be get-member.
Answer: At the moment I'm a big fan of Get-WMIObject.
Answer: "Test-Path" finding this useful for checking if data is already there or if a default needs to be added.
Answer: For me -WhatIf is the most useful.
Comment: he just specified "command" not cmdlet
Comment: -1: -Whatif is not a cmdlet but a cmdlet option.
Answer: CD (Change-Location) - I can basically navigate around registry as if it is a file system.
basically you can do so for all powershell providers (returned by Get-PSProviders)
cd HKLM:\

Answer: No question about it - Get-Member. I can't imagine any PowerShell session without using it. Discoverability is one of the strongest features of Windows PowerShell.
Answer: This is more of a technique than a particular cmdlet or function, but my favorite PS thing is object construction:
$foo=""|select bar, baz, gronk|ft

gives you
bar   baz   gronk
----- ----- ------

which is handy for turning unstructured data into a set of objects for further processing.
Answer: One of my favorites:

Get-Content "c:\logfile.log" -wait

The powershell-version of 'tail -f 'logfile'
Comment: This doesn't seem to work for me. I ran this command against a CSV file that another powershell command was writing data to and it did not display the updates to the file as it was being changed but only showed me the lines of the file as it existed when I ran the command and then just hung waiting for CTRL+Break.
Answer: I see Get-Member listed which I have to agree is the best but a near and equally neccessary second for me is:
Format-List
The way I more commonly use this is after a pipe to show me all the values of the properties of an object:
$SomeObject | fl *
GM will tell you what the object is and list out the names and types of its properties but more often than not this does not help you really understand the way those properties are used without looking up the documentation which can be tedious.
$SomeObject | Format-List * will output all of the values of the properties available on the object so that you can see what their current values are and start looking for properties that you want to select or use to filter objects on.
I will often find that an object has multiple properties that based on the documentation look like they have the data I want but in reality only one of the properties has data or the data in one of them is not at all what you would expect based on the documentation alone.
Answer: I did just a small method that i added to my Profile. See http://blog.keystroke.ch/2007/08/30/diskusage-in-powershell/.
diskusage myserver
is my prefered command.
Answer: In addition to Get-Member, I  would have to say Add-Member and New-Object which give you the ability to use the Extensible Type System.
Being able to add members to any object at any time allows you to get the exact information you need with the ability to sort it, group it, slice it, dice it, export it, or whatever you want to do with it.


What is the difference between state machine and workflow?

Question: I want to learn what is the difference between "State machine" and "workflow", and how is it any different from "State machine workflow"?
Comment: Basically, in the context of .NET, the terms mean whatever Microsoft says they mean.
Comment: The meaning of "workflow" is highly dependent on context.  And "state machine workflow" is somewhat nonsensical.
Comment: (But I see that this is a term invented by Microsoft, so the nonsense is to be expected, I guess.)
Answer: Workflow and state machines are defined nicely on wikipedia.
I'm guessing you're getting the term State Machine Workflow from this page. .NET seems to support different ways of modeling workflows (which are just some defined steps in a complex human task). A state machine (which is a map of states with transitions between them) would allow loops as opposed to a sequential workflow, which precedes down different branches until done.
Answer:
Product Manager draw Workflow Definition Graph and then give it to the Developer/Programmer .  After reading the Requirements Document writen by Product Managers, Developer/Programmer design entity ,entity state , then set  state of several enities In one WorkFlow Node
A WorkFlow has a parallel gateway, inclusive gateway and exclusive gateway, but State Machine only has an exclusive gateway .so WorkFlow can at several workflow Nodes at the same time ,but State Machine can only at one Node
The term WorkFlow is highly related with representing how people do their work and how they handle information.
A newcomer can easily understand a program by the WorkFlow Definition Graph, and the  WorkFlow  Definition Graph is bound into the code by WorkFlow engines (e.g. acitivti or jbpm6). It is synchronous with code. Requirements Documents are not synchronous with the code.
Answer: As Jere mention, State machines can be cyclic graphs and workflows are usually acyclic. Most of the time the WorkFlow term is used to denote some kind of human interaction where probably some information is being modified (for example: a document). The term workflow is highly related with representing how people do their work and how they handle information. A state machine is a more technical concept where different states of an entity or a group of entities needs to be represented. You should also need to ask about Business Process probably :)
Cheers
Answer:
The major difference between a workflow engine and a state machine
lies in focus. In a workflow engine, a transition to the next step
occurs when a previous action is completed, whilst a state machine
needs an external event that will cause branching to the next
activity. In other words, the state machine is event-driven and the
workflow engine is not.

I've been searching for a major difference between them until I found this real difference from here, which is true. Please refer to this article that I've quoted this difference from.


A Fixed Field of $\mathbb{Q}(\sqrt{2},\sqrt{3},\sqrt{5})$

Question: I was working on a review problem from Dummit and Foote and came across the following issue. It is clear that the Galois group of the splitting field for the polynomial $(x^2-2)(x^2-3)(x^2-5)$ has order $8$ and one of the automorphisms is
$$
a+b\sqrt{2}+c\sqrt{3}+d\sqrt{5} \mapsto a-b\sqrt{2}-c\sqrt{3}+d\sqrt{5}
$$
which I would think has associated fixed field $\mathbb{Q}(\sqrt{5})$. However, after completing the problem I found in the solutions that this automorphism has fixed field $\mathbb{Q}(\sqrt{6},\sqrt{5})$. Why is the $\sqrt{6}$ there? I would think that by setting
$$
a+b\sqrt{2}+c\sqrt{3}+d\sqrt{5} =a-b\sqrt{2}-c\sqrt{3}+d\sqrt{5}
$$
we find
$$
b\sqrt{2}+c\sqrt{3}=-b\sqrt{2}-c\sqrt{3}
$$
so that $b\sqrt{2}+c\sqrt{3}=0$ so that $(b/c)^2=3/2$, impossible as $b,c \in \mathbb{Q}$. How how is it that this automorphism is fixing $\mathbb{Q}(\sqrt{6})$?
Comment: The automorphism fixes the square root of 6, what's the problem? Recall not all elements of your field are linear combination of those four numbers, $1$ and the three roots, there are also combinations of products. You can tell, because the dimension is 8, not 4.
Comment: @AdamHughes I didn't observe that until catching rogerl's answer. I thought it was sufficient to check the image of the generating elements alone. Is it always the case that one need check all the possible products of images of the generating set?
Comment: Fixed fields are fixed sub vector spaces, so you need to check on a linear combination of basis elements. In particular, you are looking for fixed subspaces for the linear transformations that are the automorphisms in question.
Comment: @AdamHughes Thank you, that makes it very clear. I had been too focused on the action on the generating set and not enough on the action on the basis.
Answer: Under this automorphism, $\sqrt{2}\mapsto -\sqrt{2}$ and $\sqrt{3}\mapsto -\sqrt{3}$, so that $\sqrt{6}\mapsto\sqrt{6}$.
Comment: Thanks! That clears up the question so easily! It is always the case that one need consider not only the image of the generating elements but all their possible products as well?
Comment: Yes, of course, because you are talking about field homomorphisms.
Comment: @KyleL Does that make sense now?
Comment: I believe so. Just to be sure, if it were enough for the fixed field to be a vector subspace we would only need to check what I did, check the image of the basis elements. However, since a fixed subfield also has products (it's a field so it has multiplication and addition) we need to check products of the basis elements under the automorphisms as well. Correct?
Comment: That's essentially correct. As you point out, $\mathbb{Q}(\sqrt{2},\sqrt{3},\sqrt{5})$ is both a $\mathbb{Q}$-vector space and a field extension; the two are very different algebraic structures.
Comment: Thank you very much for taking the time to clear this up so clearly and efficiently!


What is the difference between a functional check and an operational check?

Question: Can anyone explain what is the difference between a functional check and an operational check in aviation?
Basically I faced a problem to prepare the task card for functional and operational check of a FDR (Flight Data Recorder).
Comment: I've only ever done aircraft maintenance in the UK military.  I have no idea if this will help or hinder.  Functional testing was conducted before flight after maintenance.  It answered the question "does the component basic functionality work?" This might include BITE (automated tests, "**B**uilt **I**n **T**est **E**quipment) and testing with dedicated test equipment.  A given component might also need an operational check which was an item added to the next flight plan to confirm the component in airborne use or operated with all other related systems together.
Comment: In other words, a functional test only verified the component.  An operational test confirmed it's working within the overall system.  An example would be a GPS receiver.  Functional test - does it lock on, acquire and display a good location fix.  Operational test - does it successfully and accurately feed the FMS for flight progress calculations?
Answer: From the ATA spec 100 which is the standard for aircraft maintenance documentation, they provide the following definitions:

(c) Following are definitions of three categories of test that shall
  apply:
1 Operational Test
a.  That procedure required to ascertain only that a system or unit is
  operable. These tests should require no special equipment or
  facilities other than that installed on the aircraft and should be
  comparable to the tests performed by the flight crews. It is not
  intended that the operational test of the unit shall meet the
  specifications and tolerances ordinarily established for overhaul, or
  major maintenance periods.
2 Functional Test
a.  That procedure required to ascertain that a system or unit is
  functioning in all aspects in accordance with minimum acceptable
  system or unit design specifications. These tests may require
  supplemental ground support equipment and should be more specific and
  detailed than an operational test. It should contain all necessary
  information to perform proficiency tests to maintain system or unit
  reliability at an acceptable level, without reference to additional
  documents.
3 System Test
a.  That procedure containing all adjustment specifications and
  tolerances required to maintain system and/or unit performance at
  maximum efficiency and design specifications. It shall be
  self-contained and may duplicate other tests. It is normally used at
  major maintenance periods.

I would expect that these definitions are pretty universal in aviation.


GDB: Passing EXC_BAD_ACCESS signal to program

Question: Note: This question stems from another question I asked about iPhone launching: Launch installed app on tethered iPhone
I have a situation where I need to catch all signals, particularly EXC_BAD_ACCESS for use in a crash handler. When the GDB is attached to the process it handles the signal and breaks rather than letting the program take care of it.
GDB has the command handle all noprint pass nostop which is supposed to pass all signals on to the program and not break. This works for all signals that I've tried except  EXC_BAD_ACCESS, even though its listed in its signal list.
Now the i386 Darwin 6.3.5 version of GDB also has the command dont-handle-bad-access 1. If I switch this on and trigger the signal, GDB successfully passes on the signal which turns into a SIGBUS in the program.
Now for the crux of my problem. I'm debugging remotely on a connected iPhone. The GDB version which is used is the ARMV7 6.3.5 version, which unfortunately does not have the dont-handle-bad-access command. If I leave the handle all noprint pass nostop command on and trigger a crash the debugger hangs, and if I leave it default the debugger catches the signal and my signal handler is never entered.
Is there a way to properly get this version of GDB to pass along the EXC_BAD_ACCESS signal, or is there a way to trigger an action on any kind of crash or break (in which case I can signal a SIGBUS or at least quit the program).
Comment: I don't know any Apple stuff, but I'm pretty good with gdb and nobody else is answering so I'll take a shot if you help me out by posting a copy of everything that gdb prints when this happens.
Answer: Here is a workaround, use setting handle all print pass nostop and monitor the error stream, if you see the line like Program received signal ..., kill the process gdb-arm-apple-darwin


What does "force your heart" mean?

Question: English is not my native language and I don't fully understand what does the expression "force your heart" mean.
I have seen it in the Rudyard Kipling's poem If:

If you can force your heart and nerve and sinew
Comment: It means that If you can continue putting your efforts untiringly with **will** even if your heart and nerves worn out, and just *hold on* with what you are doing, you can achieve greatness. This is what I understood when I read the poem.
Answer: I think it's worth pointing out that Kipling is (probably) not literally talking about your heart organ, but rather "heart" used as an expression for determination.  "heart" is commonly used in this way, for example saying that a sports team "doesn't have the heart to win the championship".  Obviously they have hearts in their chests, but the speaker is saying they will give up at some point when it gets too difficult.
There are a lot of examples of this (organs meaning something else) in English:
"heart" can mean "determination"
"nerve" can mean "the ability to stay focussed and courageous in the face of opposition"
"guts" can mean "bravery"
"stomach" can mean "the ability to do or view something without being too disgusted to carry on"
"gall" can mean "the ability to ignore the fact that what you are doing might offend people", or more simply, "impertinence"
etc.
Answer: "If you can force your heart and nerve and sinew
    To serve your turn long after they are gone,
And so hold on when there is nothing in you
    Except the Will which says to them: 'Hold on!' "
He's saying that if you can overcome your human frailties by force of will, endure things when you should be past the point of human endurance....
It was very much part of Kipling's view of "Britishness" that a man should be stoic and resilient.  The whole "Stiff Upper Lip" culture is ingrained quite deeply into us Brits and was certainly how I was raised.
Answer: To force yourself to do something is to make yourself do something you either do not want to do or do not think you are able to do.
In other words, there are times in life when in our hearts we want to give up and stop trying. Kipling is saying that at those times we need to force our hearts, nerves, and sinew to do what we do not want to do or what we feel we are incapable of doing.
A marathon runner, for example, may feel like quitting after 18 miles. We say he or she has "hit the wall." That wall is the feeling they cannot go on. Kipling would say,

"With an act of the will you can force your heart to do what seems to be impossible, even if your heart says you cannot do it."
Answer: This is one of my favourite poems, but you need to read the whole poem (see below) to really get the meaning. The poem is about how one should cope with life's trials and tribulations. In this particular line 'nerve and sinew' refers to body and soul. When you feel you are defeated by the harshness of a situation, you are tired and lack the willpower then dig deep, hold on and you will find the strength and determination to carry on.
If you can keep your head when all about you
    Are losing theirs and blaming it on you,
If you can trust yourself when all men doubt you,
    But make allowance for their doubting too;
If you can wait and not be tired by waiting,
    Or being lied about, don't deal in lies,
Or being hated, don't give way to hating,
    And yet don't look too good, nor talk too wise:
If you can dream—and not make dreams your master;
    If you can think—and not make thoughts your aim;
If you can meet with Triumph and Disaster
    And treat those two impostors just the same;
If you can bear to hear the truth you've spoken
    Twisted by knaves to make a trap for fools,
Or watch the things you gave your life to, broken,
    And stoop and build 'em up with worn-out tools:
If you can make one heap of all your winnings
    And risk it on one turn of pitch-and-toss,
And lose, and start again at your beginnings
    And never breathe a word about your loss;
If you can force your heart and nerve and sinew
    To serve your turn long after they are gone,
And so hold on when there is nothing in you
    Except the Will which says to them: 'Hold on!'
If you can talk with crowds and keep your virtue,
    Or walk with Kings—nor lose the common touch,
If neither foes nor loving friends can hurt you,
    If all men count with you, but none too much;
If you can fill the unforgiving minute
    With sixty seconds' worth of distance run,
Yours is the Earth and everything that's in it,
    And—which is more—you'll be a Man, my son!

What does "force your heart" mean?


Pressure - temperature relationship in constant volume with high temperature and density

Question: For the coating, it is necessary to pour 40 ml of liquid in a closed container with a volume of 80 ml and place it in an oven at a temperature of 200-300 °C .My question is whether, given the high temperature and low volume and high gas density, the pressure to temperature ratio at a constant volume is the same as the ideal gas ratio .If not, what is the relationship between them at high temperatures?
thank you very much
Comment: What liquid is it?
Comment: I'm not decided yet. is it important?
Comment: It depends on the critical pressure and temperature of the liquid.
Comment: It is a solution that is acid soluble. I have not yet decided on a Solvable
Answer: The ideal gas law is $PV=nRT$, and the ratio of pressure to temperature is seen to be
$\frac{P}{T}=\frac{nR}{V}$
For an ideal gas only (i.e., no liquid) in a constant volume container, the right hand side of the above equation is seen to be composed entirely of constants, so the ratio of $\frac{P}{T}$ is in fact constant under conditions of varying temperature and pressure.  However, your container initially has 40 ml of water in an 80 ml container.  As the temperature of the water increases, the vapor pressure of the water increases, so some liquid water evaporates and enters the vapor space of the container, increasing the pressure in the container according to the Antoine equation (see https://en.wikipedia.org/wiki/Antoine_equation).  Thus, the number of moles in the vapor space, variable $n$, varies with temperature, so the right hand side of the "P/T" equation is not constant, and hence, the ratio of "P/T" is not constant in this case as temperature increases.
To find the relationship of pressure to temperature, you need to obtain Antoine constants in the temperature range that you are operating.  At a given temperature, you can calculate the vapor pressure of water to obtain the pressure in your container is only water vapor is present.  If air is also present, it will follow the ideal gas law and add to the pressure that you calculated from the Antoine equation alone.


Group and Enterprise Edition Relationship - Salesforce to Salesforce

Question: is it possible to connect regular objects and custom objects from Enterprise edition of Salesforce Sales Cloud to Group edition of Salesforce Sales Cloud through Salesforce to Salesforce functionality?
Answer: Salesforce to Salesforce requires API access. Normally, it doesn't have API access on it's own. However, it's possible for Group Edition to obtain API access through ISV Apps from the App Exchange. However, Group Edition does not have Sharing. That would seem to rule out the possibility of implementing Salesforce to Salesforce in Group Edition. I don't have a Group Edition Org available to me to see if it's there, but off-hand, I don't see a way of setting it up via apex if it's not already part of the built-in features.
Answer: According to the following feature comparison chart (http://www2.sfdcstatic.com/assets/pdf/datasheets/DS_SalesCloud_EdCompare.pdf) the Salesforce to Salesforce feature is available in Group Edition so it might be worth setting up a test to see if you can do what you are trying to accomplish.
Comment: Yes, I tested that, but it didn't work. Thanks!
Answer: I tried and tested setting up a connection between Group and Enterprise and it throws : INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: [] error while inserting PartnerNetworkCOnnection Record. However, you can share a record manually.   But sharing through apex is not possible, I guess.


Can you make a lucky brilliant move?

Question: Is it possible to make a brilliancy (a brilliant move) with luck? Or is it so rare that it can only be spotted by the best chess players?
Comment: What is a brilliant move?
Comment: What are you trying to ask here? Is *what* so rare? Of course, it's possible to play a move which is good, without understanding the reason why the move is good. And "bad" players can also sometimes find and understand "good" moves.
Comment: chess.com's automated analysis has done so much damage
Answer:
Is it possible to make a brilliancy (a brilliant move) with luck?

Absolutely.
For adventurous players I think it is not that uncommon. They often make risky moves which they haven't calculated all the way through. Sometimes they work and sometimes they don't. Tal played a lot of brilliant moves which later were found to be unsound but his opponent's couldn't find the refutation over the board. Tal was lucky.
What happens at a lower level is you see what looks like a brilliant move and play it without calculating all the way through to the end. Several moves in your opponent makes a move you hadn't anticipated or seen which seems to refute your sacrifice. You break out into a sweat. You hunker down and start thinking hard trying to find a way out. After 10 or 15 minutes you find the right move and play it. A few moves later your opponent resigns.
Your original move was a brilliancy which you didn't have the ability or patience to calculate all the way through. If you had calculated a little bit further you would have found your opponent's apparent refutation and given up. You were lucky you didn't calculate that far and then you were lucky again when there was a good reply that kept your attack going after your opponent found the tricky move.
Comment: So true. Here is a very recent example by myself: r1r2nk1/pb2qp2/1p2p1pp/2p1N2B/3P4/P3Q3/1PP2PPP/3RR1K1 w - - 0 18 1.Dxh6!! Dh4! Upsie. Hadn't even seen it. In the main line, I don't get my piece back and still am better by computer evaluation, as the black king loses all protection (2. Ng4!). (I played differently, the game ended in complete mayhem and a draw.)
Answer: Yes. The proof is trivial.  For any chess position where a legal "brilliant"1 move exists, then by definition there are at least n >= 1 legal moves. Then even if a player randomly selects a move legal in such a position, there exists the possibility of playing a "brilliant" move.
In cases where a player is not playing random moves, the possibility still exists, though it may be with a low probability.
YouTube videos from chess Twitch streams abound with content where a lower rated player plays an incredibly strong move without knowing why it is so strong, or where a lower rated player plays a move not realizing they checkmate their opponent. Similarly, though maybe less often, strong players may play a move believing it is strong not realizing it leads to disaster.
1. The question is unclear on the definition for a "brilliant" move but the answer holds for any definition that is also a legal move.

Can you make a lucky brilliant move?


Memory (RAM) of computers after shut down

Question: After computer shuts down, is it possible to retrieve data in RAM? I heard that police was able to do that... so I felt that was somehow weird..
Comment: As Steven says. The result varies very very greatly with technology. Long ago I have seen low power CMOS RAM memory gradually remmeber with increasing accuracy a program which was always loaded into it. ie the storage got better with time and the image was slowly being burned into RAM (not erom or whatever).
Comment: "the storage got better with time", does that include fixing bugs? Would be great ;-)
Answer: It's not like a powerdown deliberately erases data, so it's mainly leakage currents through which a bit's value is lost over time. That can be minutes, but you can't rely on that; it may also be seconds, and depending on your data, a couple of changed bits can render all of it worthless, for instance if they're looking for encryption keys.
The police will have a hard time with it. It will have to remove the memory, because powering the PC on again will overwrite much of it, place the memory in another computer which will not do so, and do all of this as quickly as possible. I don't think they do this.
It should be noted that low temperatures will decrease leakage current from the memory cell's capacitor, so to a certain extent you can "freeze" memory.
Answer: As stevenvh pointed out, the data disappears mainly by current leakage. This process can be slowed down by cooling (e.g. compressed air). The main paper is called Lest We Remember:
Cold Boot Attacks on Encryption Keys. Besides that specialized hardware like CaptureGUARD can be used by anyone.
Answer: Conceptually, an unpowered memory cell will hold its bits as an analog level of charge.  If one could read out the precise level of charge on every transistor within a memory chip without powering it on, one could probably pretty well reconstruct its contents even after it had been powered down for a long time (perhaps even days).
In practice, however, there is generally no feasible way of reading the precise charge level of any transistor in a memory array (much less every transistor) without powering it on.  Powering on a static memory array will instantly cause every bit to switch state to a solid "one" or a solid "zero".  If the charge levels are insufficient to be detected by the circuitry within the chip, any information present in the charge levels will be lost.
Dynamic RAM is a little different.  If a memory is not commanded to perform refresh cycles, merely applying power will not disrupt the charge levels of its storage cells.  On the other hand, the only way a DRAM can try to read a memory cell (a small capacitor) is to connect it to a memory bus (which behaves as a much larger capacitor) which is charged to VDD/2, and observe whether that causes the bus voltage to go up or down.  The memory cell will end up with a voltage essentially equal to VDD/2 after this process is performed.  If one had a means of measuring the charge on a memory cell without having to connect it to something with such huge capacitance, it might be possible to ascertain the state of non-refreshed memory bits much longer.  On the other hand, memory chips generally don't provide any such facility (since their goal is to be cheap).


How do you set the min-height of an iframe from c# code-behind?

Question: <code>    HtmlGenericControl iframectrl = new HtmlGenericControl("iframe");
    iframectrl.Attributes.Add("src","blah blah blah");
    iframectrl.Attributes.Add("width","100%");
    iframectrl.Attributes.Add("min-height", "100%");
</code>
I am creating an iframe dynamically (as seen above) and putting it on a tab panel which is also created dynamically.  I can set the height of the tab container and the tab panel from my PageLoad function, but I cannot get the height of the iframe to set correctly no matter what I do.  I am trying to avoid using Javascript to set the height.  I have tried adding an attribute for this, but it doesn't work.  If I create the iframe control in my aspx page, I can set min-height and it works fine.  Should I create my iframe in a PreLoad or PreRender function or is there something better?
Answer: Try adding as a CSS style.
<code>iframectrl.Attributes.Add("style", "min-height:100%,width:100%;");
</code>


Typescript access dynamic property with [' '] syntax

Question: export class Foo{
 someproperty: string;
}

I am trying to understand why, when trying to access dynamic object property I can do the following as I saw on one of the answers here:
let fooObj: foo = someObj['someproperty'];

but by doing this, I get an error.
let fooObj: foo = someObj.someproperty;

I am trying to understand, why the first method works for accessing/assigning to dynamic objects.
Error:
"someproperty does not exist on type"
Question asked before here, answer by Angelo R is the one I am interested in.
question
Comment: Add to your question  the code which defines the type of `someObj` and how you assign a value to it.
Comment: What exactly does "doesn't work" mean? Do you get an error? If so, what exactly does it say?
Comment: "someproperty does not exist on type", but on the type it does exist
Comment: it depends on the foo type definition.
Comment: should work, check your spelling
Comment: Guys, in foo definition this property exists.
Answer: This is just a convention in TypeScript, available for convenience. If you want to access some arbitrary property that is not defined in the type signature of the object, you can use the ["foo"] notation, and the type checker will not try to enforce that the instance you're accessing has such a property in its type signature.
Comment: More about this in the TypeScript specification: [4.13 Property Access](https://github.com/Microsoft/TypeScript/blob/1db4f96fd14fc3de5ae3704e925afd6474cfb8f5/doc/spec.md#4.13)
Answer: The way I foud to pass propery of object is using const myproperty = 'name' as const;
type MyObject = {
        name: string,
        age: number;
    }

    let obj:MyObject = {name: 'Ryu', age:30};
    const myproperty = 'name' as const;

    console.log(obj[myproperty])

For example, if you want to pass parameters on the function called sum() to sum all property 'visited', another time you want to sum all deals in this same function, using property 'deals', you can put all properties on an array and passing a index of this array, sum(0) or sum(1).
type Sale = {
    id: number;
    visited: number;
    deals: number;
    amount: number;
 }

let data:Array<Sale> =[{id: 1, visited: 83, deals: 66, amount: 5501},
{id: 2, visited: 113, deals: 78, amount: 8290},
{id: 3, visited: 36, deals: 12, amount: 6096}]

const args = ['visited',  'deals', 'amount'] as const;

 const sum = (property:number) => {

        let total:number = 0;
        data.forEach((element) => {

            total += element[args[property]];
        });

        return total;
    }

console.log(sum(0))  //Visited
console.log(sum(1))  //deals
console.log(sum(2))  //amount

Or you can use enum for more general use.
 enum CategoryOfSum{
        VISITED = 'visited',
        DEDALS = 'deals',
        AMOUNT = 'amount'
    }

    const sum = (type:CategoryOfSum) => {

        let total:number = 0;
        data.forEach((element) => {

            total += element[type];
        });

        return total;
    }

sum(CategoryOfSum.VISITED)
sum(CategoryOfSum.DEDALS)
sum(CategoryOfSum.AMOUNT)


CNN pooling and convolution

Question: In the past, I've worked with the MNIST dataset and I am currently working with Java. I do not use any external libraries like numpy (for python) or something like that. I started from scratch and build a feed forward network. I mastered the backpropagation algorithm and managed to get a result of 94%.
Obviously, I wanted to get something higher than 94% so I started building and using a CNN. My problem now is that there exist a couple of different explanations of each layer and I am not completely sure which one is the "best" or most efficient way (if there is one).
Well. The feed forward in every Layer worked fine. My convolution is working fine but here I come to my first question:
1) Normally a ReLU would be added after my conv. layer. I've seen a couple of different functions that can be used here. I am familiar with the sigmoid function that I use in my FC-Layer. Most people like to use the max(x,0) function here but I don't understand how to backpropagate this. So which function shall I use ? Wouldn't it be more efficient to handle ReLU as just a function that I add into my Conv-Layer instead of handling it as it's own Layer ?
2) When I calculate the error signals through my pooling layer I would set the error signal of the neuron with the highest activation value to the error signal I just calculated previously. My problem now is that I've read that most people set the error signal to 1 and everything else to 0. Why would you do this ?? I've added a picture for illustration. (My Paint-Skills are not the best :))
Pooling Layer painted in Paint with error signals
3) Coming back to the Convolution Layer and calculating the signal errors. I thought I could use the same formula like in my fully connected layer:
<code>//i = layer we are currently working in
for (j = 0; j < outputs[i].length; j++) {
    Sum = 0;
    for (k = 0; k < outputs[i + 1].length; k++) {
        Sum = Sum + weights[i + 1][k][j] * error_signals[i + 1][k];
    }
    error_signals[i][j] = derivatives[i][j] * Sum;
}
</code>
This works fine for my FC-Layer. but does this also work for my conv. layer ? And when I update my weights and biases. How can I do this ? I was thinking of updating each weight by the same formula as in the FC-Layer. That would also mean that I use the sigmoid function in my ReLU. The sharing weights stuff would just result in updating one weight more often each time I run my backpropagation.
Because I am just a "simple" student and not someone who has studied anything (not yet) I do not yet understand the math that is used here. I managed to handle the backpropagation in feed forward nets but still I do not completely understand why it works. I would be very happy if someone could tell me if my ideas work and if they do not work, tell me a better way (in a simple way please) :).
I am thankful for any help :)
Answer: I can't answer your entire question but;

The back propagation of ReLu is based on the differentiation of ReLu which is: 0 at x <=0 and 1 at x>0.
Depending on what type of pooling you use (max, mean) you propagate the error back to the appropriate neuron (ie. If you use max pooling you propagate all of the error back to the neuron that had the maximum value).

CNN pooling and convolution


I just made my altcoin, should I list my source code at Github?

Question: It seems to me that every new coin introduced, they list source code in Github.
Is that customary in the industry?
Comment: Could you please point me to a guide on how did you create it? I have gone through the one on bitcointalk but its very outdated
Answer: Most users are not going to trust a closed-source altcoin, so you should make its code available to the public. This board also doesn't support closed-source cryptocurrencies.
GitHub provides free hosting for open-source projects and has become a standard in the open source community so (primary opinion-based statement follows) it's probably a good idea to put your code there.


What are these green pigs with red mustaches?

Question: What are the green pigs with red mustaches?  Are they different in any way from standard pigs?  What are they based on?
Comment: Send us a picture of it
Answer: They seem to be "General / Admiral" pigs.  I get the impression they're somehow Prussian.
They take slightly more effort to kill (more force, or more minor hits) than the regular pigs.  In turn the king pig takes the most effort to kill (partially due to the protective effect of the crown).
Answer: Yes, the Forman/Mustache Pig takes more hits to kill than Corporal/Helmet Pig, but less than King Pig. You can kill him in one hit with Bomb's explosion, Chuck when he is speeding, Matilda's Egg Bomb, Terrence, Hal while boomeranging, and Bubbles's puff-up ability. It is harder to kill him with Red or The Blues or Stella. He is King Pig's second in command.


Which is correct Jess' or Jess's

Question: Please help us solve our debate.
One person says to write "Jess' Bridal Shower", the other says to write "Jess's Bridal Shower".
What is the correct way, or are the both correct?
Comment: Welcome to EL&U. The short answer is found in *[Which singular names ending in "s" form possessives with only a bare apostrophe?](https://english.stackexchange.com/questions/79081/which-singular-names-ending-in-s-form-possessives-with-only-a-bare-apostrophe)*: use *ss's* if you pronounce the extra *'s*, as in *Buzz's jetpack*, use the bare *ss'* if you don't, as in *Hercules' sword*.
Answer: This is a question of style, and different style manuals will give different recommendations. For example, both the Chicago Manual of Style and Garner's Modern American Usage would recommend Jess's Bridal Shower. On the other hand, the Associated Press Stylebook would recommend Jess' Bridal Shower.
So, arguably, if this is really a point of contention, then what you and your friends should do is this: first, agree on the style manual to use in all text connected to the event. Then, when there are points of disagreement among your friends as far as writing, you will all agree in advance to follow the recommendation of the agreed-upon style manual. In other words, the manual will be your 'arbitration official' in cases of disagreement.
I understand that you may not have access to any of these manuals. However, you can always post a question here on ELU, of the form According to [the name of your chosen style manual], how should one write...
For more details on the general rules about forming possessives given by all these manuals, see this answer.
Comment: I believe the AP Style Guide is meant specifically for writing in newspapers
Comment: @user9825893y50932 Even if that were true (see below), the AP's recommendation would still be useful as far as making the point that the answer to OP's question is indeed a matter of style, since different style manuals give different recommendations about it.
Comment: @user9825893y50932 As far as AP Style: 'many newspapers, magazines and **public relations offices** across the United States use AP style' [(source)](https://owl.english.purdue.edu/owl/resource/735/02/). And the *Chicago Manual of Style* is mostly used in the academia.  Is it really clear that one is more appropriate for **bridal showers** than another? The point is that all these are influential style manuals, and any of them will do as 'courts of final appeal' in the OP's case.

Which is correct Jess' or Jess's


Can you create and use a micro USB to micro USB cable using micro USB charging cables?

Question: Can you splice a micro USB charging cable and turn it into a micro USB to micro USB cable so you can transfer data? I no longer have a computer only a tablet
Comment: There are definitely micro USB to micro USB cables out there [like this one](https://www.amazon.com/CableCreation-Compatible-Kindle-Android-Tablet/dp/B01M5GZ3N0/). But you specifically mention USB charging cables and honestly those would not work for data. The reason being is the vast majority of USB charging cables only use two of the four wires that consist of a full USB connection: Only the power and ground wires. The data wires are simply not there in USB charging cables. So you can't generally just do what you are asking unless you are 100% sure both "donor" cables have all four wires.
Answer: Probably not.
USB charging cables typically do not have the data pins connected.
In fact there might only be two conductors (just for power) in the cable instead of the required four conductors for USB just to save on cost.  (I have actually taken a USB charger apart.)
Whether you will be able to "transfer data" to/from your tablet depends on what you want to connect to your tablet and maintain the USB host-to-device hierarchy.
As is, you're asking an XY question.
Answer: No, you can't.
There's literally one specific scenario where this can work

You have a USB OTG adapter - which is not exactly the same as a USB micro adaptor. These are less than 2-3 dollars online, maybe a fiver if you get a fancy one.
One device is able to act as a host, and the other as the target.

That said, any attempts to splice your own from two cables without knowing these things will just result in 2 broken cables.
For extra fun - the quality of cables ranges broadly - from the cost engineered cables sawdust has mentioned. You're better off getting the USB OTG adaptor, and testing with a known good data capable cable over splicing a pair of perfectly good cables (or 2 terrible ones, or any mix of those).


Where is a good place to farm metal shards?

Question: I'd like to purchase a Shadow weapon from a merchant and while I have the couple of rare components needed, I am short a lot of metal shards.  While I could go out and hunt random beasts for their metal shards, I was wondering if there's a particularly good place to do so.
Answer: There are some tips for farming shards from here and a reddit thread
Here is one:

Buy the Shadow Sharpshot Bow
Craft Harvester Arrows
Return to the first hunting ground you run into (with the Watchers and Grazers).
Choose the trial that requires you to shoot a certain number of Blaze Canisters off the backs of Grazers.
Take the rope down, then stealth kill the entire herd with your spear.
Once they're dead, go to each body and shoot off all 4 Blaze Canisters with the Harvester Arrow.
Loot all bodies and pick up the canisters off the ground.
Speak to the Trial Giver and restart the Trial.
Rinse and repeat the kill/harvest cycle.
Answer: A great way that I always did is to farm thunderjaws ( it's actually pretty easy ) all you need is tearblast arrows and some good aim. How? You aim for the disc launchers on his back. Tearblast them down. Pick them up. Shoot him using them. He's gonna be down in a matter of seconds. Each one you loot is gonna have 157 metal shards, and the hole action doesn't take but 3-5 minutes, do that for a while and you will quickly be able to buy the best equipment from merchants. Wish you luck ;)


Node.js appears to be missing the multipart module

Question: I am trying to parse form data, including upload files with a node.js http server. All of the tutorial type articles I have found use a require("multipart"); to include the multipart module, but when I try the same I get:
Error: Cannot find module 'multipart'

I also can't find it in the current api docs (though it is in the google cached version). So, has this module been removed from the standard installation or is there something else that does the job?
Answer: Multipart.js is now standalone module.
Answer: There is a better multipart parser now.  You can find it at: http://github.com/felixge/node-formidable
Answer: Run a cmd window, there go to the folder that contains the files where you are trying to use the multipart module. Then, run the following command:
npm install multipart

That's all.


Geocoding addresses from Excel in QGIS 3

Question: I have a set of addresses in Belgium in Excel and I would want to geocode/transform them in coordinates in order to be able ta visualize them in QGIS 3.4. Does someone know how I could do?
Comment: How many records, do you have  to process?
Answer: There is a QGIS plugin called MMQGIS that has a function to geocode a CSV file using either OpenStreetMap/Nominatim or Google (if you have a Google API key).
Answer: For QGIS versions QGIS 3.20 and higher
Starting from QGIS 3.20 it is possible to geocode addresses to coordinates by means of the native tool "Batch Nominatim geocoder", can be found under Vector General in the Processing Toolbox (Ctrl+Shift+T).
Step 1. Prepare your input CSV file which includes an address field i.e. is a concatenation of fields e.g. street, house number, postal code, city, state, country. (Some attributes are optional)
Let's assume there is a CSV file called 'test.csv', see image below.

Step 2. Drag&Drop the CSV file into QGIS. Make sure the right encoding was chosen i.e. UTF-8

Step 3. Apply the "Batch Nominatim geocoder" and press Run

Step 4. Get the final output


How can i use Google Cloud SQL to support multi-tenancy for my application

Question: How can i use Google Cloud SQL to support multi-tenancy for my application? I know that data-store supports namespace API bu what about Google Cloud SQL.
Answer: According to https://developers.google.com/appengine/docs/python/multitenancy/ datastore, memcache & taskqueue are the only things that supports namespace which is used by the multitenancy feature. Meaning stuff like blobstore and cloud sql you have to manually namespace or implement yourself.


Connect an mp3 player to an Arduino?

Question: I have been looking for a good way to play sounds using an Arduino.  I started to consider just buying a cheap mp3 player and replacing the player's buttons with optical switches, which connect to an Arduino.  I wanted to know if anyone has done this before and if there was a good mp3 player for this (one that may have some sort of control port / ir sensor.)
Comment: It's probably going to be very challenging to select the desired track, and it will have start up delay.  You can play lower fidelity digital audio directly from an Arduino or related chips, or comparable with add-ons - though there is a challenge in storing the clips uncompressed unless you opt for an sdcard.  What sorts of things do you want to play?
Answer: Yes, people have done this before, and they have documented it on their own blogs and similar sites.  Maybe you should have asked Google first before you came here?  You'd most likely have ended up on instructables, where someone has documented exactly what you want to do and how to do it. and saved yourself this entire step.

Connect an mp3 player to an Arduino?


would a discussion concerning my emacs fingers growing a bit stiffer be appropriate?

Question: I've been an emacs user for many years. The last couple of weeks I've noticed my fingers loosing their "fluidity" and feeling a bit stiffer (resulting in a lower keys per minute count and more mistakes). I would like to ask whether this is alarming and what I should consider as possible remedies (e.g. keyboard, room temperature, diet, finger exercises, rest, etc.).
Comment: Meta works differently; you don't gain or lose reputation here. Downvotes simply mean people do not agree with what you're saying.
Comment: Maybe I've misunderstood the use of 'meta'. Isn't this the place to ask which questions are appropriate? Or should there be a meta-meta as well? why the downvote?
Comment: Downvotes on Meta have a different meaning than downvotes on the main site. Downvotes on meta mean "I disagree with this question" or "I think this is a *bad question*". But: you don't lose reputation points for downvotes on meta, and you don't risk having your account banned from meta, as long as your posts aren't deliberate trolling or anything of the sort. In short, don't take meta downvotes personally. They are very, very unlikely to have any negative effect on your account status.
Comment: Votes on meta usually indicate disagreement with the point raised in your question. In this case it is probably an indication that someone does not believe that your question is on-topic for our site.
Comment: This sounds like a medical question. I would ask a doctor, not a bunch of IT guys.
Answer: Of course this is off-topic. Your fingers are not a part of a computer, nor are they software. You could ask this on Quora or maybe chat, but I don't think any existing SE site would field such a question based on their topicality rules.
Honestly, when I first read this question, I thought that maybe it was a joke. If it is a joke, ha-ha, you got me. But if you were being serious, then I just want to make it clear that asking how to make your fingers nimbler is definitely not topical for Super User.
Edit: Actually, it might be topical on Fitness.SE, though I would recommend posting a meta Q there before asking, because I'm really not sure. I've never asked a question on Fitness.SE before, and I haven't even joined their site. But based on a quick scan of their FAQ, it looks like this question could at least be within the general topic realm of what their site is about.
You would really have to remove the whole bit about emacs, though, and make the question generically about how one would go about making their fingers more dexterous for rapid keyboarding.
See Here -- it looks like this question may have already been asked (or something very close to it) on Fitness.SE, and it wasn't closed. In fact, it has +1 upvotes. There may not be a lot of interest in this particular topic there, but at least the type of question is accepted by their community.
Answer: I disagree that a question like that would generally be off-topic for Super User.
We even have rsi for "Questions relating to Repetitive Strain Injury", which is very much on-topic for our site as it can be categorized under interaction with computer hardware.
However, if you have a medical issue, you should talk to a physician, not computer geeks.
Comment: Haha....Dr. Geek to the rescue!!!!


Can't Ping other local ips on l2tp vpn connection, getting: ping: sendmsg: No such device

Question: I have setup an l2tp client using xl2tp to connect to an l2tp vpn server. The server connection requires that the connection be setup WITHOUT ipsec. So I have set up a basic xl2tp connection. The connections seems to work and I get an ip address from the vpn server, that is visible when I run ifconfig. However I cannot ping any ip's on the network I have connected to, there is a specific ip on that network I need to connect to: 10.10.251.32, however when I attempt to I get this error: "ping: sendmsg: No such device". I try the ping with command: ping -I ppp0 10.10.251.32. I have tried connecting to the vpn from other machines, the ip address that I get assigned are for example: 10.10.2.163, or 10.10.2.120, or 10.10.2.114 all in the 10.10.2.xxx subnet,

This is my xl2tpd.conf:
[global]
access control = no
auth file = /etc/ppp/chap-secrets
debug avp = no
debug network = no
debug packet = no
debug state = no
debug tunnel = no
[lac vpn-connection]
lns = xx.xx.32.43
redial = yes
redial timeout = 5
require chap = yes
require authentication = yes
ppp debug = no
pppoptfile = /etc/ppp/options.l2tpd
require pap = no
autodial = yes
name = thename

here is my: options.l2tpd
ipcp-accept-local
ipcp-accept-remote
refuse-eap
require-mschap-v2
noccp
noauth
idle 1800
mtu 1410
mru 1410
defaultroute
usepeerdns
debug
lock
connect-delay 5000
name xxxxxx
password xxxxx

I know that the connection gets made because I get a ppp0 interface and an ip address:
ppp0      Link encap:Point-to-Point Protocol
          inet addr:10.10.2.115  P-t-P:xx.xx.32.43  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1410  Metric:1
          RX packets:5 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:98 (98.0 B)  TX bytes:110 (110.0 B)

The ip address of the server that I need to hit is: 10.10.251.32, when I try to ping it using a ping command specific to that interface:
ping -I ppp0 10.10.251.32

I end up getting this error: ping: sendmsg: No such device

Thinking maybe it was some kind of subnet issue I connected to the vpn using multiple client clients simultaneously and got ip's such as 10.10.2.120, 10.10.2.114 and to ping each of the clients from the other to the same issue: ping: sendmsg: No such device. With all the clients I get connected and ifconfig returns the right  ip address.

The person administering the other networks swears that those ip addresses are up and running. I'm not sure how to proceed.. forgive a total linux newbie..

Here is the output of ip ro show:
default via xx.31.32.1 dev eth0
xx.xx.32.43 dev ppp0  proto kernel  scope link  src 10.10.2.125
xx.31.32.0/20 dev eth0  proto kernel  scope link  src xx.31.36.249

Comment: Check your routing table. With the tunnel up, run `ip ro show` and add the output to your question.
Answer: In summary it was routing issue, I needed to add a script in the   /etc/ppp/ip-up.d folder, this script, called routes.sh would be run when the vpn/ppp interface came up.
/etc/ppp/ip-up.d/route
#!/bin/bash
route add -net 10.10.251.32 netmask 255.255.255.255 dev ppp0
route add -net 10.10.247.1 netmask 255.255.255.255 dev ppp0
exit

Then I also needed to enable ipforwarding in sysctl.conf, the command: net.ipv4.ip_forward = 1
That was it..  set the routes when in the interface comes up, and enable forwarding.


File format for a portfolio for a job application

Question: I am a college student and aspiring graphic designer. Currently I'm trying to apply for some simple low-level graphic design positions at my college and local businesses. Of course, along with a resumé, I need to provide a portfolio of my graphic design work.
My question is how do I format this? I'm not talking about how the portfolio looks aesthetically, but how I am supposed to provide it? Do I literally just include a large image file containing an organized mass of what I've created? A pdf file of the same? Perhaps a link to a website showcasing my work? I suppose this varies from company to company, but is there a standardized (or at least most common) way that portfolios are shared? Perhaps this is a silly question to ask but I don't feel like I understand enough to ask a better worded question.
Comment: A single PDF or Web link... PDF is often preferred. *Most* position announcements tell you what to submit.
Comment: @Scott Thank you for the quick response. None of the position announcements I have looked at so far have had any specifics.
Comment: You should be good with a PDF file.
Answer: Definetaly not jpeg's. When I'm applying, I'm attaching my CV and Portfolio seperately in PDF format.
I used to include my CV at the end of my portfolio PDF but that also meant for people to download my whole portfolio and then extract the last page if they wanted to have it printed it out. So it's good for everyone to have your cv separate.
I know it's annoying but it's always a good practice to keep a .doc copy of your cv just in case HR's can't launch pdf's for some reason (it happens, a lot). If you have a website, definitely include a link within both cv pdf and your mail body.
Pls, never ever send a huge mass lol. It's pretty easy for designers to zoom but it's the exact opposite for non designers. You can create a multi paged PDF. Try to place one work at a one page. Double pages are fine too if you feel like to show a zoomed in detail or something. Also a few words to describe the work won't hurt.
But the most important is, Size of your PDF. Try to keep it under 9-12 megs.
Answer: The short answer is:
Provide a web link or a PDF file.

The long one is a question... What do you do?
A very important topic as a graphic designer is to provide the right solution for the right project, and this includes the delivery.
If you are a web designer, prepare a personalized web page. Prepare a well-structured website, with clear sections, and relevant information. "I do not have a credit card" is not a reason for not having it, you can have a free hosted webpage.
But perhaps you are more like an illustrator. Do you have any social media for this?
Behance, Instagram, DeviantArt?
If you like editorial design, the PDF itself will be part of the portfolio. Do you know how to make a decent-sized PDF with good quality and small file size?
I once received a 200Mb PDF... I do not even remember the design... the delivery was nonsense. One thing is the CV, another is the portfolio.
You can even send a nice formatted email, in a newsletter form.
Are you a motion graphics designer? Do I really need to say that a youtube channel or Vimeo is the best option?

Part of what a designer has to do is making decisions... Make some of your own. What an employer wants is to be impressed.
Answer: Just submit your website link. Make sure you have a linkedin account too with that web link. Never send PDFs. Make sure your web link is on your resume at the top. Good luck!
Answer: I wouldn't send a PDF unless that's what's been requested and the user knows that it'll likely be a large file. And even if email attachments are asked for, I always send one simple text email to let them know that the big file will be coming as a separate email shortly and to please let me know if they don't receive it within a few minutes. THEN I'll send the email with the attachment.
Some folks may vastly prefer a PDF because they can pass it around internally, feed it into their HR process, etc. But it seems that an HTML portfolio would be equally/more useful, as it'd always be up to date. Whoever they pass the link along to would get the benefit of your most recent work/updates.


what is the best and esiest way to find Square root?

Question: Hi to all I'm new this forum . I want to know easiest way to find squre root of large number with in a seconds without using calculator.
Suppose I have 2601 and 4096 values. How to find the these value's of the root's with in seconds
Comment: Say, if you are a programme, it is unthinkable that you would not know that $4096=2^{12}$, so $\sqrt{4096}=2^6=64$. With $2601$ I would start with the known value $\sqrt{2500}=50$. Because the derivative of $\sqrt{x}$ is $1/2\sqrt x$, the derivative at the point $x=2500$ is $1/100$. Therefore $\sqrt{2600}\approx 51$ (and I know that $\sqrt{2601}=51$ exactly - just trying to describe a mental arithmetic method here). Anyway, anchoring such an approximation to "known values" gives reasonably accurate approximations.
Answer: Wikipedia has a list of methods of computing square roots.  Perhaps the most relevant here is the base 10 digit-by-digit calculation (assuming you have access to a pen and paper) or the rough estimation.
Comment: I'm asking shortcut way @Joel Reyes Noche
Answer: There is no universal, simple formula.
If you know that the number has an exact (integral) square root, there are lots of mental tricks that apply to different situations.
For 2601, I first noted that 2+6+0+1 = 9, which means it is divisible by 9, so its square root must be divisible by 3.
2601 is a bit bigger than 2500, and I know its square root is 50. The first number larger than 50 divisible by 3 is 51. As 51*51 = 2601, 51 is the correct answer. If it had not been, I would have tried 54 then 57 (the next multiples of 3).
For 4096, unfortunately I know it is 2^12 (I'm a computer scientist) so the square root is 2^6 = 64. Had I not known that, I would have known the last digit was either a 4 or a 6 (because the square ends in 6), it is bigger than 60 (because 60^2 = 3600) and less than 70 (because 70^2 = 4900). This leaves only two possibilities, 64 and 66. There is a simple formula for calculating the square of a number ending in 5 in your head (I will spare you this one) from which you can determine the answer is less than 65 which means it must be 64.
There are lots of simple rules (like these) which you can use to calculate exact square roots in your head. The problem is that there are lots and lots of such rules and techniques, and different numbers require different rules. I am afraid there is not one (or even a couple of) simple rules that work for all numbers.
Comment: U know `4096` = ` 2^12` but I don't  that value, at that we can do? . I'm preparing for competitive exams
Answer: So, you want to solve $x=\sqrt a$, $a$ being a large number. This means that you look for the solution of $$f(x)=x^2-a=0$$ and suppose that you have a rought estimate of the root (let us call it $x_0$). So, perform one iteration of Newton method; this will give you  as a better estimates $$x_1=\frac{a+x_0^2}{2 x_0}$$ Let us try with $a=2601$; we know that $x_0=50$ is reasonable; so the previous formula gives $x_1=51.01$.
Do the same  with $a=4096$; we know that $x_0=60$ is reasonable; so the previous formula gives $x_1=64.13$. Suppose that, instead of $x_0=60$, we use either $x_0=50$ or $x_0=70$; the above formula would respectively give either $x_1=65.96$ or  $x_1=64.26$.
Answer: There's a little known trick to calculate squares up to $75^2$, provided you know the squares up to $25^2$, exploiting
$$a^2=|a-50|^2+100(a-25).$$
Here's how it works.  To compute $37^2$, determine the distance from $37$ to $50$, that's $13$, and square it to get 169.  Now add as much hundreds as $37$ is above $25$, namely $1200$, to get $37^2=169+1200=1369$.
For $51^2$ we get $1+2600=2601$. As $\sqrt{4096}$ might be $64$ or $66$ we compute $64^2=14^2+3900=4096$ and are done.
Another example: what's $\sqrt{2209}$?  Candidates are $43^2=7^2+1800=1849$ and $47^2=3^2+2200=2209$.  Bingo. These calculation are done in some seconds.


What are the consequences of having non-constant variance in the error terms in linear regression?

Question: One of the assumptions of linear regression is that there should be a constant variance in the error terms and that the confidence intervals and hypothesis tests associated with the model rely on this assumption. What exactly happens when the error terms do not have a constant variance?
Answer: The consequences of heteroscedasticity are:

The ordinary least squares (OLS) estimator $\hat{\mathbf{b}} = \left(X'X \right)X'\mathbf{y}$ is still consistent but it is no longer efficient.
The estimate $\hat{\mathrm{Var}}\left(\mathbf{b} \right) = \left( X'X\right)^{-1} \hat{\sigma}^2$ where $\hat{\sigma}^2 = \frac{1}{n-k} \mathbf{e'}{\mathbf{e}}$ is not a consistent estimator anymore for the covariance matrix of your estimator $\hat{\mathbf{b}}$. It may be both biased and inconsistent. And in practice, it can substantially underestimate the variance.

Point (1) may not be a major issue; people often use the ordinary OLS estimator anyway. But point (2) must be addressed. What to do?
You need heteroscedasticity-consistent standard errors. The standard approach is to lean on large-sample assumptions, asymptotic results and estimate the variance of $\mathbf{b}$ using:
$$\hat{\mathrm{Var}}\left(\mathbf{b}\right)=\frac{1}{n}\left( \frac{X'X}{n} \right)^{-1} S \left( \frac{X'X}{n} \right)^{-1}$$
where $S$ is estimated as $S = \frac{1}{n-k}\sum_i \left(\mathbf{x}_i e_i\right) \left(\mathbf{x}_i e_i \right)'$.
This gives heteroskedasticity-consistent standard errors. They're also known as Huber-White standard errors, robust standard errors, "sandwich" estimator, etc... Any basic standard statistics package has an option for robust standard errors. Use it!
Some additional comments (update)
If the heteroskedasticity is large enough, the regular OLS estimate can have big practical problems. While still a consistent estimator, you may have small sample problems where your whole estimate is driven by a few, high variance observations. (This is what @seanv507 is alluding to in comments). The OLS estimator is inefficient in that it's giving more weight to high variance observations than optimal. The estimate may be extremely noisy.
A problem with trying to fix the inefficiency is that you probably don't know the covariance matrix for the error terms either, hence using something like GLS can make things even worse if your estimate of the error term covariance matrix is garbage.
Also, the Huber-White standard errors I give above may have big problems in small samples. There is a long literature on this topic. Eg. see Imbens and Kolesar (2016), "Robust Standard Errors in Small Samples: Some Practical Advice."
Direction for further study:
If this is self-study, the next practical thing to consider are clustered standard errors. These correct for arbitrary correlation within clusters.
Comment: @seanv507 heteroskedasticity doesn't bias the OLS estimate. What I think you're referring to is inefficiency. By weighting high-variance observations and low-variance observations equally, the OLS estimator has higher variance than is theoretically achievable with something like [inverse variance weighting](https://en.wikipedia.org/wiki/Inverse-variance_weighting). Whether you want to use your estimates of $\sigma^2_i$ in the estimation phase (i.e. for estimating $\mathbf{b}$) depends on how much you believe you know $\sigma^2_i$.
Comment: Matthew - I think more practical problems would clarify point (1). eg wouldn't the estimator be 'biased' towards those regions with higher variance? - which would be a bigger problem if those regions were far from the mean causing high leverage.
Comment: Matthew, I know its not introducing bias (I apologise [to you and OP] for using the term in quotes :) I couldn't think of the appropriate term ).  But I am trying to draw out the practical implications (and suggesting the OP wants to understand those) - when/why point (1) is  not a major issue. Wouldn't you agree that the effect is that then $ \mathbb b$ depends more on the high variance region than you might intuitively expect/want .(intuitive straight line fit would be that each region has equal weighting whereas infact OLS will concentrate more on high variance regions).
Comment: @seanv507 feel free to add your own answer!
Comment: In place of using heteroskedasticity-robust standard errors (which Ed Leamer in his 2010 paper ["Tantalus on the road to Asymptopia"](http://www.jstor.org/stable/25703497?seq=1#page_scan_tab_contents) calls *White-washing*), one could also try to correct the point estimates (together with the variance estimate) for heteroskedasticity by WLS. This might be worth mentioning in your answer.
Answer: Well the short answer is basically your model is wrong i.e.

In order for the ordinary least squares to be the Best Linear Unbiased Estimator the constant variance of the error terms is assumed.
The Gauss-Markov assumptions - if fulfilled - guarantee you that the least squares estimator for the coefficents $\beta$ is unbiased and has a min variance amongst all unbiased linear estimators.

So in case of heteroscedasticity problems with estimating the variance-covariance matrix happen, which lead to wrong standard errors of the coefficients, which in turn leads to wrong t-statistics and p-values. Briefly put, if your error terms do not have constant variance then ordinary least squares is not the most efficient way for estimation.
Have a look at this related question.
Answer: "Heteroscedasticity" makes it difficult to estimate the true standard deviation of the forecast errors. This can lead to confidence intervals that are too wide or too narrow (in particular they will be too narrow for out-of-sample predictions, if the variance of the errors is increasing over time).
Also, the regression model may focus too heavily on a subset of data.
Good reference: Testing assumptions of linear regression


Arithmetic of integer (based on mathematical induction)

Question: If $m,n,p,q$ are non-negative integers, prove that
$\sum_{m=0}^{q}(n-m)\frac{(p+m)!}{m!}=\frac{(p+q+1)!}{q!}\left (\frac{n}{p+1}-\frac{q}{p+2}\right )$
I tried for this but wasn't able to come up with an effective approach. So, please help me...
Answer: Use induction on $q$:
For $q = 0$ the equality holds.
Assume that the equality holds for $q = t-1$ (with $t \geq 1$), we need to show that the equality holds for $q = t$.
We have: $ LHS = \sum_{m = 0}^t (n-m) \frac{(p+m)!}{m!}= \sum_{m = 0}^{t-1} (n-m) \frac{(p+m)!}{m!} + (n-t)\frac{(p+t)!}{t!}$. By induction hypothesis this becomes: $\frac{(p+t)!}{(t-1)!}(\frac{n}{p+1} - \frac{t-1}{p+2}) + (n-t)\frac{(p+t)!}{t!}$. After some calculation (making all fractions have the same denominator), we get: $\frac{(p+t)!}{t!(p+1)(p+2)}(npt +2nt - t^2p -t^2 +pt - t +np^2+3np+2n-tp^2-3tp)$.
We also have $RHS = \frac{(p+t+1)!}{t!}(\frac{n}{p+1}-\frac{t}{p+2}) = \frac{(p+t)!}{t!(p+1)(p+2)}(\frac{n}{p+1}-\frac{t}{p+2})(p+1)(p+2)(p+t+1)$ and it's easy to show that this is equal to $LHS$.


How do I find a certain brush?

Question: In Adobe Photoshop I always use the default brush, but then I clicked something by accident and now it has changed with no easy way to change back. Can someone help me?
Answer: If what you're asking is how to get back to the default set of brushes, click on the arrow next to the brush thumbnail in the control panel, click on the gear icon, and select "Reset Brushes..."

How do I find a certain brush?


Is the uniqueness of file checked when an NFT is minted?

Question: First of all sorry if this is a very stupid question, because I have no idea about Ethereum or NFTs. My question is simple: after I minted, for example, an piece of art that I created, what prevents other people from minting another NFT with the same piece of art? It is checked during the minting process the uniqueness of the piece, to ensure that it has not been converted to an NFT already? Thank you
Answer: I'm sorry to tell you but there is typically no checks at all about what art or content you upload with your NFT. Any NFT you upload can be re-uploaded by anyone else.
The only way to know if your NFT is the original is by the fact that your NFT was published first.


What is philosophical discourse?

Question: Is philosophical discourse about the pursuit of wisdom? What principles are involved?
Comment: If the answer is a yes or no, then the question certainly was not very philosophical. Also, are you asking about this site or philosophy as such?
Comment: Sometimes. But good phil increases our understanding.
Comment: Overly brief answers can be imprecise or unclear, and there could be important caveats or clarifications. And every field tends to have it's own terminology, which can make it hard for outsiders to understand. Then again, some people seem to use big words and intricate logic for what could be expressed much more simply (and it's not uncommon for this to obscure the fact that their ideas just *aren't very good*).
Comment: It's understandable to want to reword a question after it has been closed, but when any such changes are as substantial as they are here, they render previous answers and comments close to redundant. It is probably better to create a fresh question, so that new viewers aren't confused by the incongruity.
Comment: Does this answer your question? [Which field is more rigorous, mathematics or philosophy?](https://philosophy.stackexchange.com/questions/100740/which-field-is-more-rigorous-mathematics-or-philosophy)
Comment: I have now asked a substantially reworded question. I cannot delete the question above because of existing answers and comments.
Answer: Demarcation, investigating definitions and exploring the nature of boundaries between disciplines, are core concerns of philosophy. That can seem superficially like pedantry, but the aim is different. In philosophy we do not aim simply to hold texts or arguments to established standards, like say a grammar guide. But instead to work out what are good standards to have, towards establishing clear thinking and argument. See discussion here: Why is it so hard to give a good definition of philosophy?
And philosophy as the field of cultivating wisdom, which is to say good decision making, versus analysis as the role of science: Wisdom and John Vervaeke's awakening from the meaning crises?
Comment: Even our standards have standards.
Comment: I am a scientist. We do more than analyse.
Comment: @Meanach: Did you read the link? Take climate change, science informs with analysis, the decision making remains outside. By all means give your account, eg answering 'Can one speak unambiguously of "the" scientific method?' https://philosophy.stackexchange.com/questions/31942/can-one-speak-unambiguously-of-the-scientific-method/73819
Comment: Interesting, thank you. The scientific method has utility. Scientists are generally satisfied with this. There are major problems like attachment to useless paradigms. Having been a research scientist for decades, I am aware that scientists analyse and interpret. We also make the scientific agenda. Having also been a politician for a decade, I am aware that most politicians are scientifically illiterate. In my view, philosophy is the pursuit of wisdom. Wisdom requires parsimony, thus my revised question.
Answer: Yes.
Much philosophical writing is bloated, overblown, ridiculously obscure and of no practical value, but you will not find any of those words in a dictionary definition of pedantry.
Pedantry is undue concern for petty details. Details need not be petty, and a concern for them need not be undue. Countless tiny details are assessed in brain surgery, for example, which you would not describe as an exercise in pedantry.
Personal footnote. The gratuitously impenetrable ramblings of some philosophers drives me effing nuts, and I have no idea why so much of it isn't just binned as nonsense, but please don't tell anyone or my name will be even more mud than it currently is.
Comment: While a PhD student philosophy, it drives me nuts as well. My enjoyment of philosophy is in spite of the terrible writing styles, not because of it.
Comment: @hokon and Meanach, that's lovely feedback, thanks. Perhaps we should start a campaign to rid the world of pretentious writing! All the best.
Comment: Thanks for your honesty. I have binned a lot of nonsense in my time.

What is philosophical discourse?


Do SunTour freewheels have uneven cog spacing?

Question: I have a Suntour freewheel (6 spd, "Perfect" model) that has unequal spacer widths. The spacer between the top and bottom 3 speeds is wider than the other 4 spacers. I purchased the bike used ('80-'81 Colnago Super), and I know the wheels (hubs and rims) are not original, but the freewheel (the body anyways) is of the correct time period. I noticed that the cogs do not have beveled teeth; I thought all SunTour FWs of that era had bevelled teeth to help transitioning from higher to lower gears. Teeth on cogs (excepting the smallest) have little or no wear (front 52T ring is unworn,44T ring shows wear); I assume previous owner rode the small ring in both the front and rear, rarely shifting. Bike is in excellent condition for 40 years old.
Answer: Freewheels normally had uneven spacing between gears back back then. Until indexed shifting became popular starting in the mid-80s, there was no need for spacing to be consistent. The outer sprockets were threaded on, and the inner ones were splined, so they weren't even attached in the same way. (Aside: I recall a bike shop had threaded together a "9-speed" freewheel and stuck it in their display case as a joke—It was much too wide to mount on a bike. Simpler times.)
I don't remember sprockets having fancy tooth profiles back then: that's an an even newer development to improve shifting.
Comment: I have investigated early Suntour FWs ('70s-'80s), and found them to have beveled teeth, but no uneven spacing between cogs; both from personal and online examples. The uneven spacing is causing shifting problems when shifting to or through the cogs on each side of that wider spacer. I believe the FW assy was incorrectly reassembled using the wrong spacer or that wide spacer is in the wrong position.


mount samba when a user logs in

Question: Right now I give my users these instructions.  It mounts our company samba share using fstab.
sudo mkdir /mnt/simsamba
echo "//atlas/data$ /mnt/simsamba cifs credentials=/root/.credentials,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0" >> sudo tee -a /etc/fstab
sudo echo "username=$USER" > /root/.credentials
echo "password=" >> /root/.credentials
chmod 600 /root/.credentials
nano /root/.credentials
#  Complete both lines by entering your active-directory username/password and saving it here (no space after the =)

There are two major problems with this:

User-specific credentials are used machine-wide.  That means if another user ssh's into this machine they'll access the samba mount using the host's credentials.
User credentials are stored in clear-text.

Another way to do it is to simply have the user run this whenever they log in:
sudo mount -t cifs -o user=$USER //atlas/data$ ~/shared_drive

But I'd like to automate this.  I could put that line in ~/.bashrc, but then they would need to enter their password whenever they launch a new terminal.  Also, if they didn't launch a terminal before opening their file-browser, this wouldn't mount.  I could put it in ~/.profile but I'm not sure how the password interaction would work.  They are actually logged into this machine with the same account as they'll use to access samba, so optimally I'd like to avoid the need for the user to re-enter the password.
Answer: Try to play with pam_mount it is able to use users password from login process, or krb5 tickets:

mount samba when a user logs in


Dynamically processing multiple batch files and generating corresponding output files with Spring Batch

Question: I've recently started learning Spring Batch in order to make use of some of its more advanced features like asynchronous batch processing, job stopping, and scheduling to replace some existing batch processing functionality, and implement new batch processing functionality.  Right now, I'm trying to figure out how to dynamically process multiple batch files and generate a "receipt" file for each input file, and I'm confused by some of the design decisions of the Spring Batch architects.  It seems like in order to process a simple flat CSV file and generate the output, I'm going to have to manually hack the beans in my ApplicationContext and manually set their "resource" properties at runtime in order to achieve what I want with the FlatFileItemReader and FlatFileItemWriter.  This is neither safe nor good practice for something that is allegedly a multi-threaded, high-performance batch processing framework.  Am I just missing something ?
Comment: I've answered the question of the property hacking : the beans related to a Job can be made unique to a JobInstance by using scope="step" on the beans, which is an addition to the Spring Framework contributed by Spring Batch, but I'm still looking for an easy way to map 'n' input batches to 'n' output batches.
Comment: Alex are you still looking for an answer to your question of how to make a generic job to handle multiple source files and output your receipt file?
Answer: Seems like you might use the MultiResourceItemReader to specify multiple resources and set the FlatFileItemReader as  MultiResourceItemReaders delegate.
Comment: I had actually looked at doing that, but there's no (convenient) way to multiplex output files from input files.
Answer: As it turns out, I was misunderstanding some of the documentation.  Spring Batch introduces a new bean scope, "step" and uses that to create new beans for each step in a batch flow based on the bean with the name given in the configuration for the readers and writers.  It then dynamically configures these using Spring's EL.  As for getting the multiple batches going, I just wound up doing the configuration for a single batch definition, then pushing the multiple batch handling into code.
Comment: can you please help me with this http://stackoverflow.com/questions/7878122/dataloader-using-spring-batch-partitioning


Why can't one put type signatures in instance declarations in Haskell?

Question: I like to put type signatures for all top-level definitions in my code. However, type signatures in instance declarations don't seem to be allowed, and if I put one I get a "Misplaced type signature" error from GHC. Why is this so? Why can't GHC check if the type signature is the same as what it was expecting, and reject (or warn) if it isn't?
Comment: On [the ticket I opened](http://hackage.haskell.org/trac/ghc/ticket/5676) SPJ commented: "I've wanted [type signatures in instance declarations] myself, so I've done it in a spare moment." He currently set the milestone to GHC 7.6, though there is a slight chance it will make it into GHC 7.4. Thanks for asking this question! And thanks, Daniel Fischer, for suggesting that we make a ticket.
Answer: You can add type signatures for instances using [the new]  -XInstanceSigs, which is especially useful for bringing type variables in scope. You can find more information in the official docs.
Answer: Most of the other answers here are pretty old... there's now a language extension:
stick the following at the top of your file:
{-# Language InstanceSigs #-}

Answer: You can create the functions separately, outside the instance body, if you really want the type declarations.
class Class a where
    f1 :: a -> a

instance Class Foo where
    f1 = foo_f1

--monomorphic version of f1 for Foo:
foo_f1 :: Foo -> Foo
foo_f1 = ...

Answer: Since the signature is part of the class definition, a type signature in an instance declaration would be a duplicate signature. I don't think there's a problem with allowing duplicate signatures in principle, but there's no advantage in allowing them generally, and it's simpler to disallow them. So the language definition says there can be at most one type signature per entity. The feature of allowing signatures also in instance declarations hasn't been asked for much, so there's no extension allowing it. If you really want that, you can raise a feature request on the GHC trac. If it gets enough interest, it may be implemented (but I don't expect the demand to be high).
Comment: Programmers can make mistakes too. :-) For example, a programmer might mistakenly think that to make something some `T` a `Functor` one has to define `fmap :: T (a -> b) -> T a -> T b` (getting confused with `Applicative`) and write this type signature, along with some complicated implementation of `fmap`. Surely a "This type signature is wrong, it should be such-and-such!" error will be easier to understand than whatever "could not match bar with foo, expected baz, actual quux" error that will be generated.
Comment: I meant checking against what the programmer believes the signature to be (apart from checking against the signature in the class). This does not give any additional safety, true. But it can give more understandable error messages: "you think the type signature is X, but actually it is Y" instead of some other type error. Also, it allows a programmer to adopt a uniform style of writing type declarations, instead of having to make a special case of commenting it out inside instance declarations.
Comment: I agree that this is not a major issue, since there is no safety being violated, it's more an issue of clearer communication between the user and the compiler and being able to adopt a uniform coding style.

As for the extra top-level function, that seems a bit inelegant : it introduces a needless name in the top-level namespace (which need not be exported in case it's a module, I agree), it separates the implementation from the instance declaration, it needs extra work and attention, ...
Comment: We've been talking a little about this on #haskell IRC. I made a ticket: http://hackage.haskell.org/trac/ghc/ticket/5676
Comment: @DanBurton Too slow, Prateek filed a request hours ago :)
Comment: The advantage will be that GHC will check the signature - the programmer can assert his/her belief of the type signature and have it checked, and caught in case it is wrong.
Comment: @Prateek The compiler checks it against the signature in the class anyway. Since any signature except the one from the class definition (with the pertinent type variables substituted for the instance types) must be rejected, it can give no additional information or safety. It would only be a bit of additional documentation for readers of the code (that isn't a bad thing, but you can achieve it now with signatures in comments - I do that if I think the types aren't obvious and well-known).
Comment: @Prateek I don't understand, surely the programmer believes that the most general type of the implementation is at least as general as what the class specifies? Can you give an example of an error message that would be better if a direct signature would be used than with the inherited? I can't think of such a case off the top of my head. However, if the implementation is not short, it's good practice to do what missingno suggested, define a top level function and bind the class member to that in the instance declaration, why not do that also for short implementations?
Comment: I agree that uniformity in writing type signatures is nice, and for that it would be handy to allow signatures in instance declarations. But I find it not to be a pressing problem.
Comment: @DanielFischer yep, looks like SPJ just tagged them as dupes of each other. Is there a way to merge tickets?
Comment: @Prateek, I know this is old, but I figured I should mention that there are quite a few cases where one ends up wanting the extra top-level function anyway. In particular, that approach seems to work better if you're going to introduce GHC rewrite rules that match on the function in question.
Answer: In any case, the type is redundant and one normally wants to avoid redundancies.
In Frege, it is nevertheless allowed to write type signatures for instance members. They are checked and then thrown away. It's of course easier to forbid them right away.
Answer: Allowing type signatures in instance declarations is enabled by default since GHC 9.2.1.
This follows from GHC 9.2.1 supporting GHC2021, which enables some extensions by default, among these the InstanceSigs extension.
Here's an example from the documentation:
instance Eq a => Eq (T a) where
   (==) :: forall b. b -> b -> Bool
   (==) x y = True

Note that type signatures in instances are redundant in most cases. The documentation mentions these possible motivations for adding them:

using the type checker to confirm that the inferred type matches what the programmer expects (this is the motivation the user posting the original question gives)

as a way to document the code

bringing scoped type variables into scope

On the history of allowing type signatures in instance declarations in Haskell
This feature has its origins in this StackOverflow question.
The user posting the question created an issue ticket the same he asked the question in 2011. The day after, Dan Burton also created a ticket, and the first ticket was closed as a duplicate. Another day later Simon Peyton Jones chimed in and mentioned him having wanted this possibility himself. He sketched out the implementation the same day and made the commit seven days later. The extension was added to GHC 7.6. It was enabled by default in GHC 9.2.1, which was released in October 2021.
Note: PureScript added the extension in 2017.


Dynamic MVC Razor Model from Database

Question: I have a database table with questions for a competition. These are created for specific competitions from an edit page that our staff can use, so each competition may have different questions.
The Questions table has details like the field name, the type (ie checkbox) and the validation type (ie Required and Compare etc).
Is there any way when trying to build the competition view for the customer to dynamically render the questions to the view (as each competition will have different questions)?
I was thinking a dynamic model or something? I am not really sure. Any ideas are welcome.

I am a little confused about how to fit my objects into this model structure. So do I create the editor template for the question of the Answer?
Basically when an admin user set's up a competition they have an entry in the competition table with the basic comp into then they can create a number of Questions which go into the CompetitionQuestion table which is linked back to the Comp table, each comp has any number of questions - this table holds details like the field name, the type (ie checkbox) and the validation type (ie Required and Compare etc) as mentioned above.
But when the competition view is rendered for a person to enter it it pulls info from the Comp Model (which is fine) then I need to loop through the CompetitionQuestion's (don't know how to create model for this) and render out each question for the specific comp - these are then saved when the person enters in the Entry (basic user and comp details) and EntryAnswer (answer to each question) tables.
So do I link the EditorTemplate up to the CompetitionQuestion object or the EntryAnswer object?
Ah so confused right now :(
Answer: What you are looking for is Editor templates.
It's template that you can create to match your custom objects.
Here is a good tutorial on how to proceed.
http://coding-in.net/asp-net-mvc-3-how-to-use-editortemplates/
Comment: Is there a razor version of this?
Comment: You had me worried there... The link I provided is actually all Razor.

Dynamic MVC Razor Model from Database


Which user should i give permission to in IIS?

Question: I'm running a windows 2012 server with IIS 8 installed,
I have a php script which complains about not having write permission on a specific folder.
If I grant permissions to this IUSR user, It works just fine,
But I don't know if this is the right way to do it or if it is secure?
I read about the IUSR & there was tons a description about this user being for anonymous authentication, I just didn't understand if there was any risks giving full permission to it.
So I stopped the work & thought it would be wise to get some advice from experts first.
Which user should I grant permissions?
Thanks!
Answer: All object access in Windows NT-based operating systems is performed under the context of a user account. When anonymous users access your website IIS accesses files and scripts under the IUSR_machinename user account. This user account has very limited rights and serves to compartmentalize the anonymous access.
The authentication functionality in IIS allows remote users to authenticate such that IIS will "impersonate" their Windows user account and access files and scripts under their user account's context rather than the anonymous user account's context.
If your remote users don't have Windows user accounts then they're just anonymous users and have no ability to authenticate to IIS. In that case (which is the typical one) you're just going to need to grant the anonymous user account rights to do whatever is necessary to make your application work. That's just the way it is w/ some applications-- you don't have the ability for the users to authenticate so you have to make due w/ anonymous access and granting permissions to the anonymous user account.
Is that "risky"? That depends on your application. If anonymous users have the ability to upload arbitrary files to a directory and execute them, for example, then you're effectively opening up public shell access on your server computer. The architecture of the application is going to determine this.
Applications that allow anonymous users to upload arbitrary types, quantities, and sizes of files to a remote server computer seem very risky to me on the surface. It's a complete showstopper if the directory where the uploads are stored is accessible via the webserver for downloads because, effectively, you just made your server into a public file-sharing site. It's also a complete showstopper if the user can cause any content they upload (including EXE files and/or script files) to be executed by either Windows or the PHP interpreter.
The more "removed" the writing is from user control (i.e. if the script is just keeping files there to track state, rather than allowing users to upload arbitrary content) the less "risky" it seems. I'd be looking for the script to do a good job sanitizing user input and limiting the quantity of data that a user can cause the script to write (to prevent DoS attack).
What you're really looking for, ultimately, is a an application security architecture review, and maybe a pentest. If this is a commonly-used script that is supported and publicly available then, hopefully, simple security bugs should have already been shaken-out. If this is something more boutique or custom then I'd be wary of trusting the security architecture of the application w/o having it review.
Comment: Thanks for you complete answer,
What about wordpress?The thing that I didn't understand is that If I grant modify & write permissions to IUSR on wp-contents & wp-admin folders, is it possible for a visitor to edit wordpress PHP files from his own computer? ( Assuming that I don't allow file uploads).
Comment: In a nutshell-- no. The remote user wouldn't be able to modify the existing files in those folders if you grant the IUSR_machiename write access to those folders in the NTFS Access Control Lists. Do be careful about granting "Write" permission in the IIS settings, however-- that will allow users to upload files and, if the NTFS ACLs permit them to write into a folder and "Write" permission is allowed in IIS then uploads _are_ possible.


Daintree National Park as a backpacker

Question: I will have 2.5 days to visit Daintree National Park from Cairns (and get back there). What are the possible itineraries to do it as a backpacker (and keep the costs down)? I have seen many tours organized from Cairns, but they are rather expensive and I don't usually enjoy this kind of experience anyway - its nice to be able to decide for yourself! Is it worth hiring a car (for 1 or 2 people, not sure yet), or public transport is sufficient?
Answer: About five years ago I hired a car from Cairns and drove to the Daintree as you suggest.  It is easy and scenic drive.  A ferry crossing is included.  This way you can find your own accommodation and easily get around if you want to hike, day-trip to the reef and generally explore.
I have not investigated public transport; there might be a bus service.  You would likely need to catch taxis once there if you do arrive by bus.
Comment: There's no bus service to speak of.  Renting a car is the only real option if you're not joining a tour.

Daintree National Park as a backpacker


How to add numbers represented as prime factorization vectors?

Question: Suppose we represent all positive integers as vectors of the powers of their prime factorization. Ex.
$$72 = (2^3)(3^2)(5^0)(7^0)...=\{3,2,0,0,...\}$$
and applying Legendre's Theorem for example:
$$n! =\{\sum_{k=1} ceil(\frac{n}{p_1^k}),\sum_{k=1} ceil(\frac{n}{p_2^k}),...\}$$
Some operations, such as multiplication, are trivial to define:
$$\{a_1,a_2,...\}*\{b_1,b_2,...\}=\{a_1+b_1,a_2+b_2,...\}$$
An addition definition, if it can be given as a single statement, seems difficult to define. I'm curious to see what if one exists and what results from such a statement.
$$\{a_1,a_2,...\}+\{b_1,b_2,...\}=\{?\}$$
$$3+5=8 \Leftrightarrow \{0,1,0,...\}+\{0,0,1,0,...\}=\{3,0,...\}$$
Perhaps first removing all common factors:
$$\{a_1,a_2,...\}+\{b_1,b_2,...\}=\{min(a_1,b_1),min(a_2,b_2),...\}*\{?\}$$
Is there a way to define addition that doesn't require converting the vector representation back to its integer form in some way?
Answer: You are trying to bite the core of number theory. Twin primes, Goldbach's, Mersenne's, Fermat's, etc, depend on what you are asking.
To show the difficulty:
$$2+7=9$$
$$3+11=14$$
$$5+13=18$$
Answer: I don't think an efficient way exists. Otherwise this would trivialize figuring out whether a number is a fermat prime or not.
one thing is clear though:
If you let $(a_1,a_2,\dots ) + (b_1,b_2,\dots )= (c_1,c_2,\dots )$
then you have $c_n=\min(a_n,b_n)$ whenever $a_n\neq b_n$.
Comment: I see that, in addition to the distributive property the asker mentioned, you've also used the principle that a number which is a factor of one summand but not the other cannot be a factor of the sum (as is provable by considering the sum modulo that factor). That's why the min only applies whenever a_n ≠b_n. It's also true that, if a_n = b_n, then c_n ≥ a_n = b_n, by the distributive property the asker mentioned.
Comment: These facts reduce the computational burden of refactoring the sum inside the parentheses after the distributive property, conversion to addable notation, and addition. It's also possible to use either the prime factorization of the largest summand (which one is larger can be determined by comparing the dot product of each prime exponent vector with a vector of the logs of primes in some constant base, converting it into it's logarithm base that base) or the length of their sum in positional notation to get an upper bound on the square root of the sum if rooting it directly is too much.