Disable buttons in background during Facebook popup (Corona)

Question: I am using inbuilt Facebook api in Corona to get a Facebook popup. However the pop up does not cover the full screen so buttons in background are visible and clickable. There is a home button. When I click on home button in the back ground the Facebook popup does not close and app returns to home screen in background. I would like either to return to homescreen with pop closed or to make home button not clickable if popup is open.
If I disable the button in the background when Facebook popup appears there is no way to know the user closed the popup and so I can enable the button.
Is there a way to make Facebook popup full screen or to know that the popup was closed. ? Thanks
Answer: When the dialog is closed you SHOULD get an event of type "dialog" sent to your facebook listener that you supplied to facebook.login().  With this in  mind, you could disable all controls on the screen, show the dialog, and then whenever you get a dialog event restore control functionality.  The trick is to then maintain some relationship between your original listener and the code that pops the dialog.


How to make a nice button using Jquery mobile?

Question: I want to make a button using jquery mobile to redirect the user to an other page with a slide animation for example and with rel="external" in order to load external js file .

but there is no transition ! If i use

there is the flip transition but the external file isn't loaded !
What should i use ?
Thanks
Answer: data-rel="external" means you are not using ajax, so there wont be any transition because it will take you to a new page. What you can do is to load the external url with custom jquery ajax function for your button, use the flip-animation and load the external js on ajax-success.


Micropython install RPi.GPIO issue for Pico W

Question: I'm trying to install the RPi.GPIO package on my Raspberry Pi Pico W, but when I run
import mip
mip.install('RPi.GPIO')

I get the message back

Installing RPi.GPIO (latest) from https://micropython.org/pi/v2 to /lib
Package not found: https://micropython.org/pi/v2/package/6/RPi.GPIO/latest.json
Package may be partially installed

When I run
import RPi.GPIO as GPIO

It gives an error, confirming that the package wasn't installed.
The links go to a 404 page so I'm not sure what to do to correct it.
What should I do to successfully download the package?
Answer: As far as I am aware RPi.GPIO is only available in Python for the Raspberry Pi, not for the Raspberry Pico.
https://pypi.org/project/RPi.GPIO/


How does one get Firefox media playing on Ubuntu 20.04?

Question: I have a brand new Ubuntu 20.04 running on my new computer.  YouTube videos play without a glitch, but no other audio/video can play.  H/W accelerator is off.  When I try to install ffmpeg, I end up with a terminal that shows the following.  One cannot access the OK to get past this point.
Answer: Apparently you tried to install ffmpeg via command-line, in this case you'd have to use Tabulator-Key (the one two below Esc) to highlight the "OK"-Button and press Enter.
Besides ffmpeg I usally also install ubuntu-restricted-extras.
Answer: MY BAD!  What a dummy.  I forgot you can get to the OK by hitting TAB.  I'm sooo sorry.  Insufficient morning caffeine.


convert text field to lookup field in salesforce

Question: I need to convert a text field to Lookup field on Object 'A'
As we cannot convert directly so there is one approach is to create a one object 'B'and create a lookup field on object A.My Question is if i am having lots of data in Text field(A)-Do I need to create a record in New Object(B) to display same value in lookup? or there is any other way we can achieve this ?
Please suggest.
Answer: What best you can do is in your use case is create a new lookup field.
And now write a batch class and manually search for record using text field and populate your lookup with Id (This is a one time process) and delete the text field and continue using the lookup field.
Comment: I'd imagine that using the Data Loader would work as well.
Comment: @DerekF but in dataloader they manually need to map records.
Comment: Are you sure about that? Going through the process in my mind, it's just extracting the current records via Data Loader, and then using Data Loader to perform an update, mapping the old text field column to the new lookup field.
Comment: @DerekF I think Dataloader.Io can do what you suggest but other not able to do this. dataloader is a limit in free trial.
Comment: Perhaps we are talking about different tools. I have used the Salesforce-provided Data Loader (Setup -> Administration Setup -> Data Management -> Data Loader, also called Apex Data Loader) for similar tasks, multiple times in the past, over tens of thousands of records. To the best of my knowledge, this tool is provided for no additional charge, though it looks like it's only available for Developer, Enterprise, and Unlimited edition orgs (leaving out Professional and CRM Starter edition orgs).
Comment: @DerekF I have also used this tools. But I don't think this type of mapping is possible with this tool.
Comment: @DerekF  Could you please explain the process in short ,how to do it using data loader.Thanks in advance
Answer: There is no need to create an entirely new object. You will need to create a new Lookup field on your object A. For purposes of illustration, I'll be referring to your existing text field as text_field__c, and the new lookup field as new_lookup__c
Assuming that your text_field__c contains a valid Salesforce Id (15 or 18 characters), you can easily take care of copying the data from text_field__c into new_lookup__c using the Salesforce Data Loader.
As a quick note, at time of writing, the Salesforce Data Loader can only be used in Developer Edition, Lightning Enterprise, and Lightning Unltimited orgs. If you're on a Lightning Professional or SalesforceIQ CRM Starter org, you'll need to find another solution.
I won't go over the basics (logging in, selecting an object, etc...), as that is covered by Salesforce's own page for their Data Loader
I have tested the following procedure myself in one of my Summmer '16 sandboxes. My org already has an object that stores an Id in a text field (been using it as a workaround for 3 years to make a pseudo-lookup to OpportunityLineItem). The general steps to take are:

First, perform an export

Select your object A from the list of objects (Click Show all Salesforce Objects if your object is missing from the list)
Select the destination and name for the csv file that will be generated, click next
Select the Id, text_field__c, and new_lookup__c fields, then click 'Finish'

Then, perform an update

Select your object A again
Browse for the csv file that was recently created, click next
The Data Loader will do some 'initialization'. It should succeed fairly quickly. Click Ok.
On step 3: Mapping, click 'Create or Edit a Map'
Since you only queried for 3 fields, you should only see 3 fields on the lower portion of the Mapping Dialog window. Click Auto-Match Fields to Columns. This should fill in field API names into the Name column of the lower portion of the Mapping Dialog window
In the lower portion of the Mapping Dialog Window, click and drag the text_field__c from the Name column so that it is on the same row as new_lookup__c. This should cause the old mapping for the row with text_field__c in the File Column Header column to disappear. This is what we want.
Click Ok to close the Mapping Dialog window (no need to save the mapping), then click next.
Choose a directory to store the success/error log files
Click finish, and then click yes on the warning dialog that pops up

That should be all you need to do.
Of course, the Id that you're trying to copy into the lookup field must be for the same object that the lookup field is associated with (you can't put an Id for an Opportunity into a lookup field that looks up to an Account).
The triggers, workflow, and validation rules on your object A will still run when performing operations through Data Loader. If you can't update a record in Salesforce through the web ui, then Data Loader won't be able to update it either.
Data Loader runs in batches (default batch size is 200, but this is configurable via settings). Once Data Loader hits an error in a batch, my experience is that the rest of the records in that batch will be marked with the same error. It's slower to complete, but decreasing the batch size can maximize the number of records that update successfully.
Also note that this does not delete the value from text_field__c. It's certainly possible to do this via Data Loader, it just requires a little more setup. You'd need to edit the csv file that was exported in the first major step to include a new column header (and fill all the rows with NULL, I think), change the Data Loader settings to insert null values, and then map your column with the NULLs to text_field__c instead of leaving it blank.
Answer: this is not possible to convert text field into lookup. Have you tried this? You need to create a new field of lookup type.
Comment: Yes i tried by creating new lookup and populating few data in that lookup.But what in this case if that text field contain different data for almost all records.
Comment: When you try to edit the type of field, there is no option of lookup field. Please refer the screenshot attached in answer
Comment: we need to create a same data in Lookup and needs to populate that data same as old Text Field and then we can remove that field.If any other solution please suggest
Comment: That is what  I am saying.In salesforce there is no option to convert text to lookup  ,But my requirement is to convert it into lookup.I am asking other approach .Thanks in advance
Comment: It is not possible and reason is in your question :). Platform got confused with existing data and not able to convert all text-field data to lookup. Salesforce not provide any functionality and you cannot do this.
Comment: What I feel,the workaround would be we need to create a new lookup field and need to create a records in lookup object and using lookup need to assign that record in Object A.and then we can delete the old text field.What do you think Anurag.
Comment: It sounds good to me. You can do it and may provide a one-time approach in which update text-field with lookup values. Once all text-field values available in lookup and replace the text-field from lookup in code (class, VF etc), then you remove the text-field.


How to display custom object field from related object on report on parent object?

Question: I have two objects A and B related through lookup. Object A has a lookup relationship field to object B. I need to display a custom field from object B in a report which is based on object A. Is it a good idea to create a formula field in object A and use that field in report. Is there any better alternative available ?
Will it be slower (or not a good practice) to do it using a formula field and not creating a custom report type ?
Is there a way to find out if a report is build using default / standard report type ?
Comment: can you elaborate a little what is actual requirement. You can display related records on reports based on Object A. Need to create custom report type and apply the filter criteria
Answer: Salesforce provides relationship fields (like lookup or master detail) based on which we can setup relationship among objects.
We can easily filter set of records based on query or filter condition.

Is it a good idea to create a formula field in object A and use that field in report. Is there any better alternative available ? Will it be slower (or not a good practice) to do it using a formula field and not creating a custom report type ?

It depends on the purpose of your requirement. More over, using formula field in query condition slower the retrieval process because formula field is not indexed.
We can traverse up to 5 related objects based on the relationship.
Formula field is good if you try to display parent's information on the child object or try to achieve some calculation or you want put information combining different field values.
Now, if you try to display child's information at Parent then formula field will not work.
So, if we achieve results from our relationship fields then it is not advisable to create duplicate formula fields just to show the related record information.

Is there a way to find out if a report is build using default / standard report type ?

Yes, out-of-box, Salesforce provides following report type when we try to create a report.

Now, according to your requirement, if you have custom objects, then Salesforce cannot provide standard report type for your relationship. That's why you need to create custom report type and define how you could create reports based on that.
For more information, refer Set Up a Custom Report Type
Comment: will it be faster to use a custom report type built using two objects than using a custom formula field on the object and then using this custom field in report ?
Comment: Yes, it is better to use custom report type than using formula field as you will get lot of flexibility in reporting
Answer: Just adding this here for others. I found another (and maybe more suiting) answer here: https://success.salesforce.com/answers?id=90630000000ZjPZAA0

If it's a lookup field to relate just a single object, there's no need to create a bloated relationship, or formula fields. (You still need to create a custom report for object A though.)
You can add fields from object B to your object A report type by editing the report type's layout. On the right hand side you will find a box that says "Add fields related via lookup". There, you can browse every lookup field for every object that is involved in that report type and add the relation's fields.


Where does everipedia store all of its data? What parts are centralized?

Question: Everipedia stores large amounts of data like wikipedia. Where is it stored? And what parts are centralized?
Answer: Everipedia's data is stored using IPFS which is a distributed free IP based file system. Anyone can participate in IPFS and help strengthen the network in general.
Read more about the Everipedia's team explanation about it in this interview or on their official whitepaper.


Two answers from the same user on the same question

Question: I don't know what happened here, but it seems that the question has two answers from the same user. Is that supposed to be possible? Why?
Comment: Multiple answers is what should be done if you have more than one solution.
Comment: @LanceRoberts Yes, but that edit button is also there for a reason, especially in cases like this, where the linked answerer is merely expanding on the same answer, and not constructing a new one.
Answer: Yes, you can post as many answers to a question as you want. The system warns you each time to make sure that you didn't mean to edit an existing answer instead, but you can click through this warning.
Comment: Sometimes, you have two radically different but correct solutions. It makes sense to post them separately so that they can be independently judged by the community.
Comment: I also sometimes post a 2nd answer if I find a better answer and my first answer has comments on it.
Comment: But WHY??? I mean why it is allowed?
Comment: Okay! Clear now, I nearly suspect the man was hacking the SO! Haha! Since, I haven't try that.
Answer: Just had two moments in this April 2020 where found two users with more than one answer to one particular question. Once i've done that in Game Development Stack Exchange (two answers with two different takes) and one of the moderators merged both answers and deleted one of them, so I assumed this was the right procedure overall.
Therefore, my take once saw the multiple answers from the same user was to flag them with moderator attention with a message similar to...
This user has more than one answer to this question which could be merged.
This morning was doing Late Answers Reviews and while flagging one noticed a message saying some of my latest flags weren't accepted. They were the two cases where the users had.
In of of the times, the moderator says

As long as they are using different approaches, it should be fine.

In the other, the moderator says

a moderator reviewed your flag, but found no evidence to support it

So, to answer your question, this might be something moderators deal differently depending on the community. While in Game Development Stack Exchange that isn't accepted and the moderator acted upon it directly, in Stack Exchange it's clearly accepted.
Comment: Despite all experimentation performed we've been unable to get moderators to operate as a single hive mind. The current mostly compatible situation is the best we can hope for short of continuous visits to the re-education camp


Is Satan a seraph or a cherub?

Question: Satan was once an angel, but was expelled from heaven because of his pride.
What type of angel is he now? A seraph, a cherub, or something else?
Answer: This answer will be based on the Catholic traditions in regards to Satan and the nine choirs of angels.
Although it is now generally accept that there are nine choirs of angel and each choir is of angel is different and ranked accordingly.

During the Middle Ages, many schemes were proposed, some drawing on and expanding on Pseudo-Dionysius, others suggesting completely different classifications. According to medieval Christian theologians, the angels are organized into several orders, or "Angelic Choirs
Pseudo-Dionysius (On the Celestial Hierarchy) and Thomas Aquinas (Summa Theologica) drew on passages from the New Testament, specifically Ephesians 1:21 and Colossians 1:16, to develop a schema of three Hierarchies, Spheres or Triads of angels, with each Hierarchy containing three Orders or Choirs. Although both authors drew on the New Testament, the Biblical canon is relatively silent on the subject, and these hierarchies are considered less definitive than biblical material.
Choirs in medieval theology
St. Thomas Aquinas in Summa Theologica (1225–1274):

Seraphim, Cherubim, and Thrones;
Dominations, Virtues, and Powers;
Principalities, Archangels, and Angels. - Christian angelology (Wikipedia)

St Thomas Aquinas' list is by far the most widely accepted list of angelic choirs and places the Seraphic order of angel as being at the highest level of angels followed by the Cherubim, and so on. According to St Thomas:

The angels that rebelled and became demons did not lose their nature or their connatural gifts. They cast away, by their sin, the grace in which they were created. They did not cast away the beatific vision, for they never had it. Now, if we think of angelic orders as orders of angels in glory, then, of course, there are no orders of bad angels. But if we consider angelic orders as order of angelic nature simply, there are orders among the demons.
Certainly, there is a precedence among bad angels; there is a subjection of some to others.
Demons of superior nature do not enlighten inferior demons; enlightenment here could only mean the manifestation of truth with reference to God, and the fallen angels have perversely and permanently turned away from God. But demons can speak to one another, that is, they can make known their thoughts to one another, that is, they can make known their thoughts to one another, for this ability belongs to the angelic nature which the demons retain.
The nearer creatures are to God the greater is their rule over other creatures. Therefore, the good angels rule and control the demons. - ORDERS AMONG THE FALLEN ANGELS

This  stated it only makes sense that Satan was a Seraphim, for surely some of the Seraphim fell in great revolt against God. Although one can not say with certainty it is generally believed Satan was a Seraphim.

SIN OF THE FALLEN ANGELS

Lucifer who became Satan, leader of the fallen angels, wished to be as God. This prideful desire was not a wish to be equal to God, for Satan knew by his natural knowledge that equality of creature with creator is utterly impossible. Besides, no creature actually desires to destroy itself, even to become something greater. On this point man sometimes deceives himself by a trick of imagination; he imagines himself to be another and greater being, and yet it is himself that is somehow this other being. But an angel has no sense-faculty of imagination to abuse in this fashion. The angelic intellect, with its clear knowledge, makes such self-deception impossible. Lucifer knew that to be equal with God, he would have to be God, and he knew perfectly that this could not be. What he wanted was to be as God; he wished to be like God in a way not suited to his nature, such as to create things by his own power, or to achieve final beatitude without God's help, or to have command over others in a way proper to God alone.
Lucifer, chief of the sinning angels, was probably the highest of all the angels. But there are some who think that Lucifer was highest only among the rebel angels. -  ANGELS: FROM THE TEACHINGS OF SAINT THOMAS AQUINAS
Comment: I think *seraphim* is plural, *seraph* being the singular.
Comment: It certainly makes sense that he would have come from the highest rank of Angels per his status as leader of the fallen angels.
Comment: PS- could you clarify on the references.  Feel like it needs to be explicit that the 3rd highlighted section is Aquinas.
Comment: According to Milton, that unfallen being who in falling became Satan (his former name forgotten) was in command of a full third of the heavenly host. That suggests highest rank, though it is conceivable that military officers were systematically drawn from sub-seraphic orders--as in the Mahabharata they are Kshatriya, even though Brahmanas nominally outrank them.
Comment: Also in Milton, though Abdiel proved by example that being in the Northern Division of the heavenly host  (under the command of him who would become Satan) did not have to mean that an angel fell--free will and all--still, all the Northern Division *did* in fact fall *except* Abdiel, and no others did. I would need the total n of the heavenly host to run a chi-square test to determine the probability of the null hypothesis that Milton seems here to be assuming, but it is clearly minuscule.
Answer: If we were to leave to expand or literature beyond Christianity for the sake of understanding angels we could look at the Qur 'an.   Here we have beings called the Djinn,  they were another cast of beings who had powers beyond that of man but also had free will like man.   If Lucifer was indeed an angel he would not be able to rebel against the will of God.  But if he were perhaps a Djinn he could do so. shaytan-jinn where jinn that where also called demons... these beings are known for their wickedness, trickery, and doing favors for humans for something else in return.Christians do not call these beings djinn and instead refer to them purely as demons, Muslims believe demons are a specific type of djinn.  However it could also be the case that Lucifer may have been a hybrid of both angel and djinn. Meaning any rank would not matter to him because he was something else entirely, and perhaps being a hybrid made him more powerful than the elite angels anyway.    The Djinn are said to have inhabited our world before man arrived, and that they, for the most part became corrupt and abused their powers, god sent angels to destroy the wicked djinn and replaced their dominion with mankind.  Now this could have also been what added fuel to them rebellion as well.   But anyways since angels cannot rebel yet Lucifer was an angel...would mean he could have been a hybrid of some sort.
Answer: The Bible say:-
[] Added

NWT Ezekiel 28:16, 17 "So I [God] will cast you [Satan] out as profane from the mountain of God and destroy you, O covering cherub, away from the stones of fire. 17 Your heart became haughty because of your beauty. You corrupted your wisdom because of your own glorious splendor.. . .
Answer: Satan is described as being serpent looking - therefore he must be a seraph. At least part seraph.
Comment: An interesting perspective. Do you think you could point us to sources that describe Satan as serpentine? Also, can you elaborate on why that makes him a seraph?
Answer: It´s pretty clear according to Ezekiel 28 that he is called a cherub. YET, very interestingly, when the Lord instructed Moses in Numbers to make the serpent and mount it on a pole, the actual word used in Hebrew is "seraph", which is the singular form of the plural "seraphim".
The Hebrew word "seraphim" is used in Isaiah 6 when the prophet sees God´s throne room and describes the amazing creatures there and calls them seraphim. The English translators simply transcribed the Hebrew word into English and redenred it "seraphim" in these verses in Isaiah.
Yet in others contexts where the Hebrew word "seraph" is used, it refers to snakes, the actual slithering reptile. And the translations in English do translate it as "snakes" or "fiery serpents" in those contexts.
Why the change? I read one commentary that stated that the translators did not want to use "fiery serpents" for the holy creatures in Isaiah because of the negative connotaion the word "serpent" has and using it to describe the holy creatrues would be problematic. So not knowing what to do, the translators just transcribed it into "seraphim." Now when Numbers speaks about the snakes that bit the Israelites it uses another word for snake, "na-chash". But when the Lord spoke about making one and lifting it up on a pole, He used "SERAPH"!!!!!
So it would read like this:  "Then the LORD said to Moses, "Make a SERAPH (fiery serpent) and mount it on a pole. When anyone who is bitten looks at it, he will live." Num. 21:8. So, we could also translate it this way when the Lord refers to that verse in John 3:14, "Just as Moses lifted up the SERAPH (snake) in the wilderness, so the Son of Man must be lifted up."
Obviously the picture of the venomous snakes is a picture of Satan and sin, and the pole of the Son of Man being lifted up on the cross and made sin on our behalf. Yet He refers to Satan as a SERAPH!!!!!!!!!!!
Maybe Satan was like a combo of both cherub and seraph. This might even be related to having a dual function of priest and king. In Revelation 4, the living creatures are similar to the cherubim described in Ezekiel, but have 6 wings like the seraphim in Isaiah. So even there, they seem to be a combo cherub-seraph.
Whehter cherub or seraph or both, looks like he might have not been an archangel, but this kind of other creature, even higher than archangels. Even Michael the archangel would not pronounce a reviling judgement against Satan, but referred to the Lord to rebuke him.

Is Satan a seraph or a cherub?


Set a level of a factor to be the last

Question: I know that the function relevel sets an specified level to be the first. I would like to know if there is a built-in function that sets an specified level to be the last. If not, what is an efficient way to write such a function?
Answer: The package forcats has a function that does this neatly.
f <- gl(2, 1, labels = c("b", "a"))

forcats::fct_relevel(f, "b", after = Inf)

#> [1] b a
#> Levels: a b

Comment: This is the way... to do it. after = 0 to place the level first.
Answer: There is not a built-in function. You could do it like this:
lastlevel = function(f, last) {
    if (!is.factor(f)) stop("f must be a factor")
    orig_levels = levels(f)
    if (! last %in% orig_levels) stop("last must be a level of f")
    new_levels = c(setdiff(orig_levels, last), last)
    factor(f, levels = new_levels)
}

x = factor(c("a", "b", "c"))
> lastlevel(x, "a")
[1] a b c
Levels: b c a
> lastlevel(x, "b")
[1] a b c
Levels: a c b
> lastlevel(x, "c")
[1] a b c
Levels: a b c
> lastlevel(x, "d")
Error in lastlevel(x, "d") : last must be a level of f

I feel a little silly because I just wrote that out, when I could have made a tiny modification to stats:::relevel.factor. A solution adapted from relevel would look like this:
lastlevel = function (f, last, ...) {
    if (!is.factor(f)) stop("f must be a factor")
    lev <- levels(f)
    if (length(last) != 1L)
        stop("'last' must be of length one")
    if (is.character(last))
        last <- match(last, lev)
    if (is.na(last))
        stop("'last' must be an existing level")
    nlev <- length(lev)
    if (last < 1 || last > nlev)
        stop(gettextf("last = %d must be in 1L:%d", last, nlev),
            domain = NA)
    factor(f, levels = lev[c(last, seq_along(lev)[-last])])
}

It checks a few more inputs and also accepts a numeric (e.g., last = 2 would move the second level to the last).
Comment: beat me by 30 seconds!
Comment: It's not letting me post an edit because the change is too small but the second code block doesn't actually work unless `x` is defined globally, which seems like a mistake. I think the fix is to replace `x` with `f`, the parameter value for the factor.

Set a level of a factor to be the last


Spontaneous parametric down conversion matrix representation

Question: Given a BBO (Beta barium borate) crystal, with a pump beam of 405nm passing through it, what is the mathematical representation for the transformation spontaneous parametric down conversion (type I) performs on the photons? Would the representation be dependent on the dimensions of the BBO crystal? I'm looking for a representation in the framework of linear algebra.
Comment: You might want to consult Sec.7.2 of the textbook by Gerry and Knight as a starting point.  Briefly: the answer you want depends on how one treats the pump field.
Comment: Could you perhaps clarify what you mean by "matrix" here? The SPDC process is usually represented as a nonlinear interaction term. It contains the second order susceptibility tensor, which is a tensor of rank 3 that represents the nonlinear properties of the crystal.
Comment: @flippiefanus, I'm thinking about this in the context of quantum computing, where all gates can be represented as matrices.
Comment: SPDC is usually not regarded (or used) as a gate in quantum computing. Do you have any references for that?
Answer: Downconversion is a process whereby one photon is "split into two".  In terms of creation and destruction operator, it is represented by a term like
$$
ab^\dagger c^\dagger \tag{1}
$$
which removes the original photon $a$ and creates photons $b^\dagger$ and $c^\dagger$.   These act on the photon vaccuum state. Obviously (1) is not hermitian so the actual interaction Hamiltonian is
$$
H_{int}=\chi \left(ab^\dagger c^\dagger + a^\dagger b c\right)
$$
where $\chi$ is the Kerr coefficient of the medium.  The frequencies of photons $b^\dagger$ and $c^\dagger$ are related to $a$ by conservation of energy and conservation of linear momentum basically $\vec k_a=\vec k_b+\vec k_c$.
In the parametric approximation, the incident photon is from a strong pump field, usually modelled as a coherent state.  Since coherent states satisfy $a\vert \alpha\rangle = \alpha \vert \alpha\rangle$, one replaces $a$ and $a^\dagger$ by $\alpha$ and $\alpha^*$ to obtain
$$
H_{int}\to H_{parametric}=\chi\left(\alpha b^\dagger c^\dagger + \alpha^* b c\right) \tag{2}
$$
If the outgoing photons are degenerate (have same frequency), then $c^\dagger=b^\dagger$ etc.
Sticking to this case for simplicity, the difference between (1) and (2) is that (2) closes on the (non-compact, real) Lie algebra sp(2,$\mathbb{R}$), with generators
$$
\hat K_+=\frac{1}{2}b^\dagger b^\dagger\, ,\qquad
\hat K_-=\frac{1}{2} b\,b\, ,\qquad
\hat K_0=\frac{1}{2}(b^\dagger b+ b b^\dagger)
$$
whereas (1) does NOT close on any finite dimensional Lie algebra.
The unitary irreducible representations of sp(2,$\mathbb{R}$) are actually infinite dimensional, so it is not possible to write the "full" matrix representation for $H_{parametric}$: in the unitary evolution $e^{-i t H_{parametric}}$ one typically the series, usually after the first power in $\chi$ since the coefficients are typically small, and works in a truncated subspace of the infinite-dimensional representation.
Since the $b^\dagger$ and $b$ are just field creation operators, we have
$$
b^\dagger b^\dagger \vert 0\rangle = \sqrt{2}\vert 2\rangle
$$
etc. and
$$
e^{-i t H_{parametric}}\vert\alpha\rangle\vert 0\rangle = \vert\alpha\rangle\vert 0\rangle -i t \chi\alpha \sqrt{2}\vert\alpha\rangle\vert 2\rangle+\ldots \tag{3}
$$
(I'm being loose with the notation...)  Here, $t$ is really the interaction time so for a thicker media the probability of downconversion increases:  $t \approx \Delta x/c$, with $\Delta x$ the thickness.  In this case truncating (3) to a single term may be overly drastic.
In general, $su(1,1)$ matrix elements for arbitrary representations (typically used in many-body systems and not limited to those having $\vert 0\rangle$ as "ground state") can be found in this open access paper by Ui.  There is also quite a bit of more recent work in the context of quantum optics by C.C. Gerry (including a textbook with Sir Peter Knight).
Finally, I don't remember downconversion being used directly for gates (as pointed out by @NorbertSchuch) and a quick search was not successful.  If you have a specific paper in mind where this would be exposed I would like to know about it.


"…Each point in space makes a contribution of E=ħω/2, resulting in a calculation of infinite zero-point energy in any finite volume.."?

Question: Is there then infinite energy (in reality) in vacuum/virtual particles/zero point energy?(https://en.m.wikipedia.org/wiki/Zero-point_energy)
Comment: Related if not a duplicate:  [Can the vacuum energy be made finite with quantized space](http://physics.stackexchange.com/q/149955/9887)
Answer: If we take the simplest case of a free scalar field and quantise it then we find the field has an infinite number of modes. These modes look like an infinite plane wave in position space, or if we Fourier transform into momentum space then they look like a harmonic oscillator at a point in the momentum space.
Incidentally I suspect the quote is getting a bit mixed up between position and momentum space, because the statement Each point in space makes a contribution of $E=\tfrac{1}{2}\hbar\omega$ only makes sense in momentum space.
Anyhow, each mode can contain no particles, one particle, two particles, and so on, and there are an infinite number of these modes. The energy of any particular mode increases with the number of particles in, which is as you would expect.
However, because these modes behave like simple harmonic oscillators that means even if a mode has no particles in it the energy of the mode is not zero. Instead it has a zero point energy $\tfrac{1}{2}\hbar\omega$, where $\omega$ is the frequency associated with the mode. And if we have an infinite number of modes, each with a non-zero energy, that means the total energy will be infinite. This is the source of the claim that the vacuum energy is infinite.
There are several ways round this. For example it's generally true in physics that we can only measure difference in energy so what we would actually observe is the energy of a quantum field relative to its zero point energy. That is, we subtract off the (infinite) zero point energy to make the vacuum energy zero. Then as we add particles to our field the energy increases from zero. This seems a bit cavalier, but what we're really saying is the zero point energy is an artefact of our mathematical model and not something real.
I think this is what the statement you quote is referring to, though we should note there is a second more pernicious source of infinite energy. The free field I've described so far is a simplified mathematical object that we use because it's easy to work with, but all real fields are interacting. In this case we need to consider the interactions when calculating the vacuum energy, and when we do this we also get an infinite energy, even after we've subtracted off the (infinite) zero point energy. This second infinity is fixed by renormalisation.
The energy of the vacuum is obviously not infinite because if it was it would cause an infinite spacetime curvature and the universe would not exist. I said in a previous paragraph that in physics we can only measure differences in energy, but the exception to this is general relativity. The spacetime curvature is related to the total energy density, and an infinite energy density would cause an infinite spacetime curvature. Even if the vacuum energy were very high but not infinite it would still create vastly more curvature than we observe.
Since the universe exists we have to conclude that the infinite zero point energy either doesn't gravitate for some unknown reason, or it's an artefact of our mathematical model and doesn't really exist. Likewise the infinite (or possibly just very large) interacting vacuum energy. I don't think we understand quantum field theory well enough to say for certain how this is resolved.
Comment: "I suspect the quote is getting a bit mixed up between position and momentum space"
I agree, though getting rid of UV divergences by introducing a cut-off is equivalent to a lattice discretization of space right ? After discretization (with a length parameter $a$), the amount of points in a finite volume is finite.  In momentum space, this amounts to an upper bound $p < 1/a$, and the divergence is suppressed. The total energy should be $\propto V$ regardless. Would you agree with that ?
Comment: So if i understood you well if"all real fields are interacting. In this case we need to consider the interactions when calculating the vacuum energy, and when we do this we also get an infinite energy, even after we've subtracted off the (infinite) zero point energy. This second infinity is fixed by renormalisation." then there's infinite energy in reality?
Comment: @Noduagg: I've extended my answer to address your comment.
Answer: An experimentalist's answer:
The vacuum by definition in particle physics means "nothing", therefore working with energy and momentum operators on "nothing" one gets nothing, zero. The quote misunderstands the current standard model of particle physics, and this is the only tool there exists for measuring and predicting the behavior of particles which are the constituents of all matter.

Is there then infinite energy (in reality) in vacuum/virtual particles/zero point energy?

It is particles that carry momentum and energy in the quantum mechanical model of particle physics, and are the source of any fields, classical and quantum mechanical. In Quantum Field Theory, the mathematical statement is used that each particle in the standard model table each particle exists as a field over all spacetime, an electron field, a neutrino field,.... This is a mathematical construct, to illustrate the mathematics of QFT, which uses creation and annihilation operators on these field to represent the real particles and their interactions, so as to calculate cross-sections and lifetimes etc that can be validated experimentally.
Operating with the energy and momentum operators on the vacuum representation of the fields gives zero energy and zero momentum, there is nothing there, unless a real particle exists in the region.
Let us address the difference between real and virtual. These are the characterizations of the lines used in the schematics of Feynman diagrams,

Feynman diagrams make easy the calculations of QFT expressions so as to be compared with experiments. Real are the particles entering and leaving with external lines. They carry energy and momentum and are on mass shell , i.e. $E^2-p^2~ =~m^2$ ($c~=~1$ in this system). The mass of the particle. All internal lines are called virtual and are off mass shell, the mass is variable under the implied integration, they are place holders for the quantum number conservation of the named particle but no physical attributes can be identified with the virtual internal  lines.
To have virtual particles one must have real particles entering or leaving an interaction region to supply the energy and momentum.
Vacuum loops, as in your question, do not exist because the integrals implied by the loop diagram would have zero both as upper and lower limit. The confusion arose because a single real particle traversing the vacuum does see vacuum loops , but the energy momentum balance within the integrals is supplied by the particle traversing the vacuum with creation and annihilation operators defining its path. The loops are real in the calculations as the Lamb shift calculations show, but the particles schematically depicted are not.
The confusion arises because people take the point of view of a traversing electron (for example), which does "see" virtual particle loops, for the electron the vacuum is populated, and they forget that the electron is supplying the energy momentum balance. These loops do add up to infinities that have to be corrected with renormalization tools in order to get predictions for experimental measurements.
So in conclusion, vacuum energy depends on the model used. I was taught nuclear physics using QFT tools ( back in 1961), and there, the vacuum energy was the real lowest energy of the nucleus under consideration. But applying QFT to elementary particles is a different story than a harmonic oscillator model. The elementary particle fields posited in QFT  have zero energy and momentum  by themselves, only a specific real particle propagating on these fields and exchanging energy and momentum within the Heisenberg's uncertainty interval can generate virtual loops.


Why do NOC/Command Centers always have CNN or the Weather Channel on display?

Question: I've been inside of a few NOCs in my time, and almost without exception, there are a couple of big screens playing these channels. Why?
Answer: Bang for buck. You need to get as many colour graphs and cool looking statistical lines onto the screen at the same time as possible. Preferably with sliding news reels and weather information for added real time data awe. This is mostly to convince management types that important things are being done. I know this sounds sarcastic, but it sadly isn't as much as it should be.
Comment: Hahaha.. I think this may be the real answer :)
Answer: Well, it does get boring in there sometimes, and I bet if the CIO saw us watching COPS instead of working it wouldn't go so well... :)
Comment: ... and the weather channel is somehow less boring? I assume the sound is off...
Comment: Actually @mark, some of the shows they have like Storm Stories etc aren't half bad :)
Comment: your weather channel must be different to ours then. The ones I've seen just have 24/7 weather maps with sleep-inducing background music and the occasional live weather report.
Comment: Hmm... I guess so. In the US we actually have a station called "The Weather Channel" and while a majority of the program is the weather they do have other stuff: http://en.wikipedia.org/wiki/List_of_programs_broadcast_by_The_Weather_Channel
Answer: Weather can affect many things, as can major geopolitical events, that could affect the operations of a network.  At least, that's the "business reason".  The actual reason is exactly what BenGC said - that it's boring as all hell to watch a bunch of monitors that 99% of the time are normal.
Answer: I'm working at a support center of a French ISP, and we do need those informations for various reasons:

Weather:

Rain: old copper cables (local loop) are sensible to water.
Thunderstorms: Low-end routers and modems have weak power supplies.
snow slows down our Field engineers :(
Some RF links are also affected by bad weather. (fortunately no laser/optical links)

Other events that I can remember of:

2010 Haiti earthquake: several customers impacted
2010 Chile earthquake: customers & backbone (routers, links) impacted
2004 Indian Ocean earthquake & tsunami: several submarine communications cables down

But we do have also some customers in countries like Irak or Afganistan, were geopolitical situation can increase difficulty to repair. Green zone for example, is a restricted area where our Field engineers have to go...


Is the Steane code the only $ [\![7,1,3]\!] $ CSS code?

Question: Is the Steane code the only $ [\![7,1,3]\!] $ CSS code?
This paper claims there are 10 non-equivalent $ [\![7,1,3]\!] $ stabilizer codes. How many of these are CSS codes? Is it just the Steane code?
Answer: The CSS construction takes a classical linear $[n,k_1]$ code $C_1$ and a classical linear $[n,k_2]$ code $C_2\subset C_1$ such that $C_1$ and $C_2^\perp$ both have code distance at least $d$, and yields a quantum stabilizer code $[\![n, k_1-k_2, d]\!]$. Thus, the question can be answered by counting suitable pairs of classical codes. By the classical Hamming bound $k_1,k_2\leqslant 4$, so there are only three cases to consider.
Case one: $[7,2]+[7,1]$
A classical $[7,1]$ code consists of two code words $a$ and $b$. By a simple counting argument, we can find two distinct $i,j\in\{0,1,\dots,6\}$ such that $a_i=a_j$ and $b_i=b_j$. But then the $7$-bit string $e_{i,j}$ with $1$ on positions $i$ and $j$ and zeroes everywhere else belongs to $C_2^\perp$. However, its Hamming weight is $2$, so $C_2^\perp$ cannot have distance $3$. Therefore, there are no suitable classical codes with $k_1=2$ and $k_2=1$.
Case two: $[7,3]+[7,2]$
The above argument applies in this case, too, albeit we now have to use the fact that the code is linear. In more detail, a classical linear $[7,2]$ code $C_2$ is a subspace of $\mathbb{Z}_2^7$ spanned by two linearly independent $7$-bit strings $a$ and $b$. Once again, we can find two distinct positions $i,j\in\{0,1,\dots,6\}$ such that $a_i=a_j$ and $b_i=b_j$. But then $e_{i,j}\in C_2^\perp$, so $C_2^\perp$ has distance at most $2$ and once again we find no suitable classical codes with $k_1=3$ and $k_2=2$.
Case three: $[7,4]+[7,3]$
Let $G\in\mathbb{Z}_2^{4\times 7}$ be the generator matrix of a $[7,4]$ code $C_1$. By adding and rearranging rows we can transform the matrix into the standard form
$$
G=[I_4|P]\tag1
$$
where $I_4$ is the $4\times 4$ identity matrix and $P\in\mathbb{Z}_2^{4\times 3}$. But $C_1$ has distance at least $3$, so every row of $P$ must have Hamming weight at least two. For the same reason, the rows of $P$ must be distinct. But there are only four possible $3$-bit strings that satisfy these requirements: $111$, $110$, $101$, and $011$. Therefore, up to permutations of rows and columns, the generator matrix is
$$
G=\begin{bmatrix}
1 & 0 & 0 & 0 & 1 & 1 & 1\\
0 & 1 & 0 & 0 & 1 & 1 & 0\\
0 & 0 & 1 & 0 & 1 & 0 & 1\\
0 & 0 & 0 & 1 & 0 & 1 & 1\\
\end{bmatrix}.\tag2
$$
This fixes the $C_1$ code. Our task is then reduced to the task of enumerating all $3$-dimensional subspaces of $C_1$ whose dual is a linear code of distance at least three. However, $C_1$ is a set of mere sixteen elements, so there are fewer than ${15 \choose 3}=455$ eligible subspaces. The exhaustive search is left as a simple coding exercise for the reader.
Comment: I see, this is very nice and not only do these sorts of arguments prove that the Steane code is the only $ [\![7,1,3]\!] $ CSS code but they also show that no $ [\![6,1,3]\!] $ CSS code exists (or generally no $ [\![n,1,3]\!] $ CSS code exists for $ n \leq 6 $).


Require powershell command to retrieve a specific list and that particular list properties

Question: I need to loop through all site collection in a web app and I have to extract the list name called "Project Center" and list down all the list properties. Help required.
Answer: This should do it
<code>$spWebApp = Get-SPWebApplication "http://myapplication.sharepoint.com/"

function getListProperties ($spweb)
{
    foreach ($spList in $spweb.Lists | Where {$_.Title -eq "Project Center"})
    {
        Write-Host "List found in: $($spweb.Url)"
        $spList.PSObject.Properties | Select-Object Name,Value
    }

    foreach ( $subweb in $spweb.Webs)
    {
        getListProperties $subweb
    }

    $spweb.Dispose()
}

foreach ($spSite in $spWebApp.Sites)
{
    Write-Host "Looking in $($spSite.Url)..."
    $rootWeb = $spSite.RootWeb
    getListProperties $rootWeb
}
</code>
Don't forget to replace the spweb application URL with your SharePoint URL.
Comment: Am getting the following errrors: You cannot call a method on a null-valued expression.;;The term 'Get-SPWebApplication' is not recognized as the name of a cmdlet, function, script file, or operable program. ;;;'getListProperties' is not recognized as the name of a cmdlet. Am unable to solve these errors.(I have replaced the webapp url).
Comment: Make sure you are running this in the sharepoint management shell so that the sharepoint snapin is already loaded.
Comment: Hi, the above code worked for me for retrieving list prperties using powershell. I need one more help for display the list properties by exporting it to .csv(export in excel). suggestions are welcome. thanks


Running Emacs through the value of the bash variable

Question: How would I add a value to a new variable in bash, so that when I echo the variable Emacs would run?
Comment: can you clarify what exactly you want/expect, what have you tried and what didn't work for you?
Comment: For example I would like to create a variable EDITOR and than add a value to it, so that with command echo $EDITOR, Emacs would open and I could write something in it
Answer: You can't make bash to invoke commands during echo as far as I know. If I understand well your question you are searching for alias keyword.
alias editor='emacs'
editor  # will invoke emacs

You can store the alias in your .bashrc or just edit on-the-fly as you wish.
Answer: Is this what you were looking for?
editor=emacs
$editor          # This will invoke emacs.


Why is my Time Capsule backup getting stuck on "preparing backup" or "cleaning old backups?"

Question: Had my iMac 2009 21.5" hard drive replaced a few days ago, from a 500GB to a 1TB. This was done by an authorized Apple repair dealer. I have been trying to run backups through Time Capsule but it seems to be getting hung up at one stage or another. Why is my Time Capsule backup getting stuck on "preparing backup" or "cleaning old backups?" The new hard drive has caused a huge positive difference in performance, which is suffering as the Time Capsule and backups get "hung."
Answer: Run tmutil status for a much clearer idea of what's actually happening. Keep running the command and the NumberOfChangedItems should be changing if the backup is taking place. Until then, the command will inform you what's being processed.
Comment: here is what I am seeing for NumberOfChangedItems = 1850001.The iMac has been on all day and it is still "preparing for backup" or "cleaning up."
Comment: Head for [pondini.org](http://www.pondini.org/TM/Time_Capsule.html) for troubleshooting. Your iMac may need to start a fresh backup on your Time Capsule. You can rename your existing backup file on the Time Capsule (e.g. iMac2009.sparsebundle) to another name (e.g. iMac2009.sparsebundle.old) and start again from scratch. This will break any history of backups, but your old backups and history will remain in the old sparsebundle file. You can still browse your old backups using the "browse other backup disks" function in Time Machine. The pondini website contains all the guidance you need.
Comment: There is no "NumberOfChangedItems", it's stuck on "Preparing for Backup" for hours. CPU for `backupd` at 53%


Can we self-host a network like tor with tor source code?

Question: Can we use tor source code for running a network like tor ?
Answer: Yes, tor is licensed under a 3-clause BSD license. That means that you can do what you want with it including selling it as long as you follow the terms of the license. Here is a guide to setting up your own tor network.
Answer: yes, and there're a lot of scripts in launching it in Docker'ed environment. No problems here: even the Directories are using the very same code base, just custom torrc configs


Which is correct? "Did you know?" or "Do you know?"

Question: In asking a question, which is preferred, "Did you know?" or "Do you know?"
Comment: They mean different things. *did you know* means "did you know at one point or another (but may or may not know anymore or don't remember)". *do you know* means "do you **currently** know". It's more likely that you'll want to ask *do you know*.
Comment: This question needs more context in order for it to remain open. Compare: "Did you know the time?" with "Do you know the time?"; and "Did you know that Jane's expecting a baby?" with "Do you know that Jane's expecting a baby?"
Answer: Knowing can be roughly sub-divided as knowing how to and knowing that. If the question is about knowing how to, then the normal 'rules' apply when deciding on the appropriate tense.

Do you know how to make sushi? (present tense)
When you started school did you know how to tie your shoelaces? (past
  tense)

When knowing means knowing that, then the past tense is used for knowledge that existed in the past:

Did you know that she was married when you asked her to dance?

You can use the present tense for present knowledge:

Do you know that the meeting has been cancelled?

However, it is also very common to use the past tense idiomatically to refer to present knowledge. So there is no problem asking:

Did you know that the meeting has been cancelled?

The past tense is often used when the questioner expects that the listener does not in fact know. For example, see these three questions from the first page of Google results for "Did you know that ...":

Did you know that he's Bob Dylan's son?
Did you know that the iPhone 2G is a collector's item?
Did You Know That Earth Is Getting Lighter Every Day?
Answer: "Did" is a past tense verb. Therefore, saying "did you know" asks if you have previously known something. "Do" is the present tense, so saying "do you know" would ask if you currently know.
Comment: I was wondering if you ever noticed that simple past is also used for additional politeness. "Did you know" in particular is *extremely* common when asking about the current situation.
Answer: I too am annoyed by people who use

did you know

when

do you know

would more accurately reflect an inquiry.
Therefore, I urge compatriots of the English language to use do you know whenever possible.
By asking me

Did you know

you are not asking me if I know now, but you are believing that I now know but that my knowledge of a subject prior to a certain time is questionable.
By walking up to me or abruptly asking without prior discussion on the subject

did you know

tickles me as illogical use of language. Because (pls don't fault me for beginning a sentence this way), you would have failed to specify a timeline before which you believe my knowledge on the subject is questionable.
IMO, the reasonable way to use did you know is with the following similar situation,

You: Yesterday, we discussed that the white-tailed deer is actually a collective subspecies of deer.
  Me: OK.
  You: Did you know that the white-tailed deer is actually a collective subspecies of deer?
Comment: *pls* I find much more objectionable.


Total derivatives explanation

Question: If you have a function with multiple variables, lets say $f(x,y)$, then the total derivative for small changes would be $$\Delta f = f_x\Delta x + f_y \Delta y$$ And because of that we can assume that change is linear. But if I imagine a point in space and then move a small amout from that point in x direction and then a small ammount in y direction, wouldn't the correct $\Delta f$ be: $$\Delta f = \sqrt{(f_x \Delta x)^2+(f_y \Delta y)^2}$$
Answer: $f$ itself is a function $\mathbb{R}^2 \rightarrow \mathbb{R}$, not $X \rightarrow \mathbb{R}^2$. So linear addition of the differentials is the logical procedure. In other words, $f_x\Delta x$ and $f_y\Delta y$ are not changes in orthogonal directions, but moves along the same direction.
Answer: It is important to realise that the result of $f$ is a number, not a point in the plane. Each point $(x,y)$ in the plane has associated with it a number called $f(x,y)$. When we talk about $\Delta f$ we are talking about how this number changes. That is, moving from one point to another will change the value of this number and we want to know how much it changes.
If you move from $(x,y)$ to $(x+\Delta x, y + \Delta y)$ you can do it in two steps: from $(x,y)$ to $(x+\Delta x, y)$ and then from $(x+\Delta x,y)$ to $(x+\Delta x,y+\Delta y)$. The change in $f$ associated with the first step is $f_x \Delta x$. This is because $f_x$ represents how much $f$ changes relative to $x$ when $y$ remains constant. Similarly the change in $f$ associated with the second step is $f_y \Delta y$. So the total change in $f$ is $f_x \Delta x + f_y \Delta y$.
If you think about moving directly from $(x,y)$ to $(x+\Delta x, y + \Delta y)$ then the distance you have moved is $\sqrt{(\Delta x)^2 + (\Delta y)^2}$, so you would expect that $\Delta f$ would be equal to $\text{(something)}\times \sqrt{(\Delta x)^2 + (\Delta y)^2}$. This "something" would be the directional derivative in that specific direction, which is not nearly so simple!
The reason we do the two-step version is that we imagine the function to be approximately linear very close to the point $(x,y)$ so it's ok to do it one step at a time.
Answer: Your first displayed equation is (almost) the increment of $z$: $$\Delta z = f_x\,\Delta x + f_y\,\Delta y + \varepsilon_1\,\Delta x + \varepsilon_2 \,\Delta y$$ where $\varepsilon_1\to 0$ as $\Delta x\to 0$ and $\varepsilon_2\to 0$ as $\Delta y \to 0$.  The total differential of $z$ is $$dz = f_x\,dx + f_y\,dy$$ which approximates the actual change in $z$ by adding the changes in $f$ that occured by changing $x$ and $y$ and scaling these changes by $f_x$ and $f_y$, respectively.  Again, this is an approximation to $\Delta z$, the actual change in $z$ by changing $x$ and $y$.
As a counterexample to your claim, consider $f(x,y) = x^3+y^3$ at $(0,0)$.  Note that $f(0,0) = 0$ and $f(0.1,0.1) = 0.002$ so that $\Delta f = 0.002$.  Now compute $\sqrt{[f_x(0,0)(0.1)]^2 + [f_y(0,0)(0.1)]^2}$.
Answer: Another look at this:
The vector $\nabla f = (f_x,f_y)$ (the gradient) is a vector that, when dotted with a direction, tells you the rate of change of the function in that direction. In other words,
$$f_\vec{e}=(\nabla f)\cdot\vec{e}$$
So, if you move perpendicular to the gradient, the change is zero, and if you move along the gradient, you get the maximum possible change. The above can be written with a differential move along some direction:
$$df=(f_x,f_y)\cdot(dx,dy)$$
As others pointed out, you move in two dimensions, but the function is a scalar and has a scalar change. However, if you want to extract the maximum derivative (the magnitude of the gradient), you set
$$\vec{e}=\frac{\nabla f}{|\nabla f|}$$
and of course you get
$$(\nabla f)\cdot\frac{\nabla f}{|\nabla f |}=$$
$$\frac{(\nabla f)\cdot(\nabla f)}{\sqrt{(\nabla f)\cdot(\nabla f)}}=\sqrt{f_x^2+f_y^2}$$
The gradient is a vector and its magnitude follows the pythagorean theorem. The total differential is a scalar product of this vector with the displacement.

Total derivatives explanation


Are there any merchants in Legend of Grimrock 2?

Question: Are there any merchants in Legend of Grimrock 2? I want to know if I should hoard items or just drop the ones that I don't need. I assume it's the same as the first but I want to make sure.
Comment: I haven't found any yet and don't expect to find them, however for items I want to keep for some possible future I just put them all in my Hub. As far as I can tell, dropped items never disappear and the Hub is a central location for travelling around quickly
Answer: No, there are no merchants in Legend of Grimrock 2. There is no money either. If you find a better item, you can drop the old one or give it to someone else in your team.
If you drop something, you should note it on the map, because some puzzles need special objects like rocks and such. So you may need it later in the game.
Answer: What i did was have my packhorse character (the minotaur in my game) hang on to spare items in chests or sacks, and then collect them together near a central save crystal.  If you do leave them, then leave a big pile/sack/chest of them together and mark it on the map.  DO NOT leave things lying around randomly, or you run the risk of needing some item and not knowing where it is.
Later in the game i got a bit OCD and organised all the loot i'd gathered throughout the game into 10 different chests - a chest for light weapons, a chest for heavy weapons, etc.


how to get public key of nami wallet

Question: wondering whats the simplest way to get the pkh for nami-wallet? Is it possible through the webapp?
Answer: I would be interested in getting the holdings of that pkh as a list after getting the pkh, but I think this is a user input type of deal.
I don't think you can get the pkh for a random wallet on nami without other information such as the wallet address (I mean how is it gonna know which address your requesting the pkh for?).
Also if your using smart contracts, I think whatever the solution is would work any address on the chain regardless of which wallet they are using.
Comment: maybe not the pkh or public key of any specific address, but an account-level public key should be an option
Comment: Hi @zhekson can you please clarify what you mean by account level pk and how this differs from the pk of an address?
Comment: Scroll down to the "HD Sequential wallets (à la BIP-44)" [here](https://input-output-hk.github.io/cardano-wallet/concepts/address-derivation)
Comment: Thanks Ill take a look at it
Answer: The easiest way I can think of (so far) is:

Grab your bech32 address from the Nami wallet interface (e.g. addr_***)
Inspect that address with the cardano-address tool with this command:

echo <YOUR_ADDRESS_HERE addr_...> | cardano-address address inspect

You should be able to find the hex hash in the output under the property spending_key_hash

ALTERNATIVELY, there's another easy way where you dont need to download cardano-address. By using the cardano-address demo here Cardano Address Inspector.

Unfortunately they have disabled the hex output option, not sure why
But I realized that they do print the cardano-address output into the console... So if you open the browser inspect tool and hit Inspect again, you should be able to find the hex hash with the key spending_key_hash

how to get public key of nami wallet


"desire that" + subjunctive?

Question: If I want Leonard to eat a banana, is this a desire that Leonard eat a banana or a desire that Leonard eats a banana? How about a desire that my best friend like me / my best friend likes me? Would using the subjunctive in the second case suggest that this is a counterfactual desire?
Comment: Don't say *I desire that Leonard eats / [should] eat a banana* anyway. It's not very natural English. Just say *I **want** Leonard **to eat** a banana*. But if you *must* use the subjunctive form (which I recommend you to avoid wherever possible), it's probably usually best to explicitly precede it by ***should***. The choice of subjunctive (with or without ***should***) instead of a finite verb form like ***eats*** has absolutely no connection to "degree of improbability" or counterfactuality
Comment: ...so obviously it's *I **want** my best friend **to like** me*. If you go around saying things like *I desire that my best friend likes / [should] like me,* you'll be lucky to have any native Anglophone friends at all! It's just too *weird!*
Comment: Thanks! So, while unnatural, the second form would be the correct one?
Comment: If you have to pass an exam, use the subjunctive *(**eat**).* And *if possible* include ***should*** before it, but if you're faced with one of those tiresome "multiple choice" questions where you can only choose between ***eat*** and ***eats*** (from some ignorant test-setter who thinks **I desire that Leonard XXX a banana** is a sensible utterance with only those choices), you *must* choose subjunctive ***eat***. But myself, I'd rather look for a better test-setter!
Answer: The subjunctive in English is optional. Hence

I desire that he eat a banana

and

I desire that he eats a banana

are both correct.  And both are non-idiomatic.
It is much more idiomatic to say "I want my friend to eat a banana" or "I want my friend to like me."
You might use the subjunctive in highly formal situations.  These are exceptionally rare and most learners will never be in a situation in which the subjunctive is the best choice.

His Majesty the King desires that he be taken from this place.

"desire that" + subjunctive?


windows mobile releasing resources when application is closed (.net 3.5 cf)

Question: I have a basic .net 3.5 cf application with 4+ forms.  I am using a window handler class that I created to make sure that certain forms only have one instance open at a time where as other (Product Details for example) can be opened as many times as the user wants.  My problem lies in the fact that when the user closes all the forms (By clicking the "x" on the form rather than the "exit" button in the menu) that the application does not release the database connection.  In addition to this if the user closes all the forms and then opens the app up again their previous search results are shown rather than a new form.   How can I make sure to release all resources when the user closes all the forms??
Answer: The (X) button is a minimize button, not a Close button.  You need to eitehr change the MinimizeButton on the Forms to false - which changes the (X) to an (ok) - or add logic to handle cases where all Forms get minimized.
Comment: this.MinimizeBox = false;
and all my problems are gone
Answer: Be aware that on Windows Mobile that clicking the 'X' is more like minimizing a window than closing it.  It definitely won't exit the application, and may actually literally perform a minimize rather than a close on the form (I can't remember for sure)
So when they're "opening up the app again", it's likely it's just re-showing the same form.


Are there any film cameras that rewind mid-film and the unwind it to the same position?

Question: There are cameras that can tag the film and save capturing data associated with the tag (like a predecessor to EXIF). Are there any film cameras that took this a step further and tagged film (some method like perforation of the film) and used this to enable mid-film rewind and a later unwinding to the same position? This technology lets you use multiple films with different sensitivity without hassle.
Answer: That was one of the features of APS (Advanced Photography System), but it wasn't implemented in all APS cameras. Not to mention that film for APS is devilishly difficult to find, and not exactly available in a wide range of types and sensitivities these days. There was a magnetic recording medium provided in the film system for this purpose (along with format notations — APS-C vs APS-H vs pano, for instance — and date/time recording, etc.) APS also provides smaller negs/transparencies in all of its formats than 35mm, so it's probably not a great choice for "serious" photography.
You can, however, manage something similar with drive-incorporating 35mm cameras having an auto-rewind function. There is almost always a "leader out" rewind option on any but the cheapest consumer-oriented cameras (that may mean finding a manual and setting some DIP switches in the battery bay), and the auto-load first frame position is consistent. At 8 sprockets per exposure, the interframe advance is also consistent. That means it would just be a matter of labelling the film canister for the last-used frame number and shooting (with the lens cap on, of course) your way through the frames that have already been used. At worst you'd have to sacrifice a single frame for safety's sake.
Comment: *APS also provides smaller negs/transparencies in all of its formats than 35mm, so it's probably not a great choice for "serious" photography.* Is that a "serious" statement?
Comment: @BBking - yes, it is. You don't get different rules of physics and chemistry for differently-sized frame sizes; the constraining factor for resolution is grain size where film is concerned, and for any given emulsion, the grain size remains the same. With digital, you can trade off dynamic range against sensel size to make very acceptable pictures with nearly the same level of detail (within limits) with smaller sensors; with film, the "sensel" size is always the same, so you give up resolution when you go smaller. It's like shooting a full-frame camera in crop mode.
Answer: Since you don't directly specify film format, you can find what you need with medium format cameras that use interchangeable backs. these backs hold the film light tight, and have a removable blade that is used precisely to seal the back and allow the photographer to swap roll (either mid-roll or not makes no difference, as far as I know).
I didn't find any free image for posting here, but you can find them on google (q=film+back).
Typical cameras that use these backs are the Hasselblad 500 series.
Comment: The "removable blade" is called a "dark side". Most of the 6x6 and 6x7 "box" SLRs used interchangeable backs; the Pentax 67 (the "Texas Nikon") and most rangefinders didn't, and 645s tended to use inserts rather than backs (you *could* get extra backs for most of them, but they made Hassy backs look cheap, and that's not easy). Bronicas are good 6x6s with very decent lenses (Tamron) and tend to be significantly cheaper than other brands in the same condition.


Crossbow draw strength

Question: My crossbow has a 50LB draw. It has no mechanism to decrease the amount of strength you use to cock it (you literally just grab the string and pull it back). So my question is: "If the draw is 50LB (and it has no mechanism or system to aid you in cocking it) does it require 50LBs of strength to pull it back? You see I am considering installing a new draw on it that will be stronger and I need to know if I will be able to cock it.
Comment: My daughter aged around 12, IIRC, could cock my 100lb crossbow - she may have been younger. Obviously she wasn't legally permitted to do so anywhere remotely public! It isn't one with a stirrup, either. She isn't weak by any standard but it pretty much top effort. Hopefully this offers a rough guide.
Answer: Yes - 50lbs draw means you need to be able to pull 50lbs, unless you have a pulley/gear reduction.
So if you increase to a higher draw, you'll need to be able to pull it.
Answer: If you have to pull it back manually without a mechanism then you will need the strength to pull it back. Also consider when putting a new draw on it, that the body can hold the increased vibration and tension without shattering. I would suggest going for a new crossbow if you want increased poundage, or get a professional to change it for you.
As a side note, it depends on what you want to do with it. If you are gallery 50lbs is enough. If outside target then I wouldn't say any more than 100lb. If you have hunting in mind I would suggest 150lb for small game, or 175lb for larger. Unless you plan to take down a bear you won't need to go any higher.

Crossbow draw strength


How will the U.S. retrogression affect CSPA

Question: I'm a U.S citizen, and in 2010, I applied for an F4 green card for my sister who is Iranian. It got approved in 2015. We were hoping that once my sister gets her interview, her daughter, my niece, could also come along. With the 2020 retrogression, much of our progress has been halted, including my niece's CSPA age going up. She is currently 24 years old. Will the trend allow for my sister to get her green card and apply for her daughter before the CSPA age expires, or will we have to look for a different approach to bringing her to the u.s? Even if not, an estimate as to when my sister's welcome letter will be sent out is appreciated. It is my dream to move my family here with me, and any help is kindly appreciated.
Comment: Are they going to do Consular Processing from abroad or Adjustment of Status within the US?
Comment: @user102008 I believe it's consular processing from abroad.
Answer: If the petition was pending for about 5 years, then the daughter will age out at around age 26 (i.e. age 21 + the exact length of time from the I-130 filing until it was approved). If a visa number doesn't become available before that point, she ages out, and can no longer immigrate as a derivative beneficiary.
The latest visa bulletin shows that F4 Final Action Date is in Mar 2007 (assuming they weren't born in India, Mexico, or the Philippines). So there is still about 3 years worth of petitions before it gets to yours. Given this, it is highly unlikely that a visa number will become available before the daughter ages out in about 2 years.
If she ages out, either of her parents can petition her after they immigrate. An unmarried over-21 child of a permanent resident is in the F2B category, which right now has visa numbers available for petitions filed almost 7 years ago. She would need to not marry during this time, as there is no category for married children of permanent residents.
Comment: I see. When would you estimate my sister to get her visa issued?
Comment: @ComyarD: It's hard to predict how the date on the visa bulletin will move. But probably at least 3 more years.


VU meter design

Question: I'm trying to create a VU meter in Illustrator. I've tried various methods but cannot achieve the result I like. (I tried blend tool method, and also warp Arch method as seen in my example attached.) I got a response from another Illustrator user, but I must admit it's a bit confusing. I'm stuck on the 1st step, which has to do with the transform pallet

Place the original on a Template Layer at the largest possible size that can be easily scaled to the final size, and start on a new Layer above it, and work at a zoom level that allows precise fitting;

1) With the Line Segment Tool Click Drag between the ends of the visible part of the indicator, then in the Transform palette select the top right Reference Point and multiply the W or H value by a sufficient number (maybe 1.5) and press Ctrl/Cmd+Enter to extend past its centre of rotation;

With the Ellipse Tool create an ellipse that fits the upper scale nicely and has its centre on the line from 1);

Object>Path>Offset Path with a negative Offset that gives a fit on the lower scale; you may use Undo for just 3) or for both 2) and 3), depending on the accuracy of the original, to get the best overall fit (if any, I would weight the upper higher in this); copy all the marks and lock the originals;

Select the upper scale ellipse and Object>Path>Offset Path with a positive Offset to fit the upper ends of the upper marks, then Object>Path>Offset Path with a negative Offset to fit the lower ends of the lower marks

For the upper scale, with the Line Segment Tool ClickDrag from the upper end of each mark (at the upper ellipse) to the centre (of rotation/the ellipses), then extend beyond the upper ellipse as in 1) if needed (see below);

Repeat 4) only for the lower scale;

Increase the Stroke Weight of all parts to match the originals;

8 ) Cut all parts as desired, either
8a) Cut the upper/lower marks at the intersections with 2)/1) and the upper/lower end ellipse and hide/delete the unneeded parts, and also cut the scales, and extend the upper mark at 0 to reach the bottom of the upper scale; or
8b) Select all the parts and Object>Path>Outline Stroke and use the Pathfinder operations to cut;

Set the colour of all parts; cut the upper scale so it switches from black to red just to the right of the upper mark at 0;

Add the numbers, letters, and signs.

Thank you.
Comment: Alternative idea draw the meter straight asif not wrapped. Make it a brush then apply the brush on a arc. Its less errorprone than usung warp arc
Comment: @joojaa good idea, it's just a bit more work to adjust the lines after the brush is applied, since you can't do it on top of the original image like in Andrew's answer.
Answer: I think the Warp Arc Effect still works, you just need to refine the settings to get a closer match. Selecting the objects and adding a Warp Arc of 32% Bend and -3% Vertical Distortion worked for my object. If you add a small negative vertical distortion, it helps sell the effect. Then you can move the lines around to line them up.

If you spend more time, I'm sure you could get almost an exact match.
Answer: The arc where the dB marker lines and number reside is not at all circular. The needle of the meter rotates around a fixed axis but its rotation center is totally different. This is typical in audio devices, round meter scale is rare.
The meaning of the scale in VU (=volume unit) meters has some standards but in consumer devices good looks laid out by artists override technical requirements. So, in consumer devices one should compare the readings only to the readings in the same device.
Having an artistically refined custom "volume unit" scale is not a fraud as long as no claim of obeying a certain standard nor scale division as decibels isn't presented.
The next image hopefully gives some idea of non-round VU-meter designs:

The green ellipse is matched (by eye) to the arc of the numbers and marker lines. The markers point to the axis of the needle. The cyan lines are drawn to find approximately the axis of the needle.
The needle is the radius of the magenta circle, but the revolution range is typically only 90 degrees in consumer devices.
How to calculate the exact needle positions is actually off-topic here but the formula is simple for meters which get their signal from perfectly designed analog circuits which rectify the signal linearly without the original diode rectifier non-linearity. If we say the needle position for totally silent signal i.e. far left is zero degrees and for maximum (=+3dB) signal it's +90 degrees we have the following formula:
the needle position angle = 63,64 degrees * 10^(D/20)
D is the number of decibels.
That 60,64 degrees in the formula is actually 90 degrees divided by sqrt(2) as persons who know decibels surely see.
The ideal needle positions for 90 degrees max. deflection are in the next Excel table. The calculation accuracy is 0,1 degrees or better:

The smallest commonly shown number is -20dB in VU-meters. The needle position for it is 6,4 degrees. As you see, in my previous image the -20dB marker is placed at less than 6,4 degrees apart from zero angle and the -3dB marker is far from 45 degrees. It's not possible to decide here is it an attempt to compensate not so perfect (=non-linear rectifier) measuring electronics or is it an artistic decision for better look. At least there's no mention of decibels.
A rudimentary design example:
The next image has green "artistic" ellipses, a magenta circle to show the actual rotation path of the needle and some magenta lines for a few needle position markers.

The green ellipses are made by scaling the smallest to 2 bigger sizes. They have a common center but they are aligned only horizontally with the needle parts.
In the next image the all lines and curves are are selected and Pathfinder panel's Outline is applied:

Pathfinder panel's Outline splits every line and curve at every crossing and removes all colors. The result is a group. After ungrouping the splinters are recolored and the extras are deleted. The numbers are inserted manually.
In the next image the overdrive area and non-distorting area are colored with the Shape Builder + by selecting the stroke colors, the intended device front panel hole is drawn and the needle and it's possible path are shown as magenta:

VU meter design


Should women stay up Shavuos night?

Question: Should females remain awake the night of Shavuos? (sources please)
Answer: See Yeshiva.org here (under heading תיקון ליל שבועות, number 15 [טו]):

לימוד נשים - נשים אינן חייבות בתיקון ליל שבועות, ואם הן באות ולומדות תנ"ך וכד' תבוא עליהן ברכה (שו"ת רב פעלים א, או"ח סוד ישרים, סי' ט).

And here (second paragraph under heading "staying up at night")

Responsa  Rav Pa'alim  (Sod Yesharim 9) points out that for mystical reasons women who wish to stay up on the night of Shavuot should not recite the tikun

Which both quote from Rav Pa'alim that women should not read Tikkun Leil Shavuos, but staying up is a good thing (although optional).
Looking around online, I see some people say women in their community do stay up, and some say they don't.
Answer: As brought on this website:
http://www.atorahminute.com/2014-06-01
The Ben Ish Chai said that women should NOT stay up on the night of Shavuos for Kabbalistic reasons.
Comment: Ben Is Chai is cited in the other answer as just saying they shouldn't say the formal kabbalistic Tikkun. Your site may be misrepresenting this.

Should women stay up Shavuos night?


HC-05 module short circuit

Question: I have bought a HC05 bluetooth module and I think I accidentally short circuited it. Is there any way to change the voltage regulator or methods to reuse it again?
Comment: Accept the answer to close your question.
Answer: I suppose you're referring to the HC05 module, already soldered on a board, with the 6-pin header. The regulator is on that board.
Online you'll find several versions of that board, therefore you should check the schematics, to find which you need to mount. For instance, on some board, a R1114-33 is used.
Changing the regulator is not the hardest task on earth, however, other components are very close to it (capacitors).
Still there are 2 things to consider:

Is it worthy to change the regulator? That module will cost few
bucks.
As you can see from the datasheet, the regulator is short-circuit protected (yes, it does not mean that it will be indestructible). I think, instead, you destroyed one of the two ICs of the bluetooth module soldered on board. And those one, beside of being quite difficult to find and expensive in small quantity, they are very hard do replace.
Comment: Thank you for your comment sir. I have already lost 2 of them due t short circuit issue ,which is really frustrating .So instead of buying I wanted to fix it. Is there any way to know if the Bluetooth ICs are destroyed?
Comment: @curious-boy do they heat up? If yes, they are dead. If not, this does not mean that they aren't... How and where did you short circuit the module? I.e. which pin?
Comment: yes they heat up .I guess i have to buy a new one.
Comment: I think that this has been caused by:
1) accidentally a wire (powered at 5V) contacted one of the various solder joints of your board. (always turn off power when mounting the circuit!) 2) maybe you should consider to put a resistor in series to the TXD and RXD lines (yes, many modules already have them, but in some of them they are just 100 Ohm! too low for a 5V to 3.3V conversion! Put 10k  if you're going up to 115200).

To be sure: you didn't connect that module to a serial port of a PC, right? The serial port outputs up to 12V on the RXD and TXD lines...

HC-05 module short circuit


How to fetch Document Library List in my application?

Question: I want to fetch Document Library List in my application using java-script/Jquery
How can I fetch SharePoint  Document Library record and show in my application.
Comment: Q.1.Do you want each document name in your library or you are fetching one document based on some condition? Q.2. Does your library have folders in it?
Comment: Q.1. I want each doc name.(List record). Q2. No any folder only doc.
Comment: If you need any help regarding my answer, feel free to ask
Answer: These are the two easy ways of doing it

Using REST Services
Using JavaScript Object Model

1. Using REST
Using REST services, you can make a REST call to the document library and simply get all the items in an array.
Here the REST call will be: http://*your site*/_api/web/GetFolderByServerRelativeUrl(LibName )/Files
When the call is completed, the results are stored in FilesData array which you can use in your application.
Eg. var name = FilesData.d.results[i].Name would get you the name and var URL = FilesData.d.results[i].ServerRelativeUrl will get you the URL of the document. So if you want the document to be downloadable from your application simply store it in a variable as  var DownloadLink = name
Note: You can also get other properties like created, modified, created by, modified by, etc.
    var LibName = "Documents";
    $("#btn").click(function(){  //btn is the id of the button, you can call this function on any event
     StoreInArray();
});
    function StoreInArray(){
    var CallLibrary = GetListItems();

    $.when(CallLibrary).then(function (FilesData) {
            for (var i = 0; i < FilesData.d.results.length; i++) {
                var name = FilesData.d.results[i].Name;
                var url = FilesData.d.results[i].ServerRelativeUrl;
            }
       });
    }

    function GetListItems() {
        var siteURL = _spPageContextInfo.webAbsoluteUrl + "/_api/web/GetFolderByServerRelativeUrl('"+LibName+"')/Files";
        return $.ajax({
            url: siteURL,
            async: false,
            method: "GET",
            headers: { "Accept": "application/json;odata=verbose" }
        });
    }

2. Using JavaScript Object Model
See the msdn link How to: Retrieve List Items Using JavaScript
Comment: Thanks for reply Mayank. But I want to access sharepoint site in my other application not sharepoint how can I access this in my other application.?
Comment: What languages are you using in your other application?
Comment: Yes, Try the code in my answer, it should work.
Comment: 1. Using REST   :  I get this error when i run "Uncaught ReferenceError: _spPageContextInfo is not defined"
Comment: try giving full url of sharepoint site instead of it. var siteURL = "http:///_api/web/GetFolderByServerRelativeUrl('"+LibName+"')/Files
Comment: Paste this URL and in your IE address bar, if it doesn't get error then it should work
Comment: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/53980/discussion-between-mayank-srivastava-and-admin).


How to determine if a post was last edited in the Visual Editor

Question: Is there any way to determine whether a post was last edited using the Visual or HTML editor? Perhaps by hooking into an action?
Answer: wp_default_editor(); will tell you the default editor - the last editor used. You can hook into the update/save post action and store this for the current post in the options array or somewhere similar. It's used in wp-includes/class-wp-editor.php to define the default editor when loading TinyMCE in the post editor.


How to find number of records inserted/updated in an Upsert operation?

Question: Is there a way to find how many records have been inserted or updated during an upsert operation? If there is a way, can someone please suggest how to get that details?
Comment: Are you looking for a way to calculate the total number of records during a bulk transaction or during a trigger / apex code?
Answer: I believe you would need to use the Database.upsert method to obtain the results as shown here, in this example:
<code>public class DmlSamples {

   /* This method accepts a collection of lead records and
      creates a task for the owner(s) of any leads that were
      created as new, that is, not updated as a result of the upsert
      operation */
   public static List<Database.upsertResult> upsertLeads(List<Lead> leads)  {

      /* Perform the upsert. In this case the unique identifier for the
         insert or update decision is the Salesforce record ID. If the
         record ID is null the row will be inserted, otherwise an update
         will be attempted. */
      List<Database.upsertResult> uResults = Database.upsert(leads,false);

      /* This is the list for new tasks that will be inserted when new
         leads are created. */
      List<Task> tasks = new List<Task>();
      for(Database.upsertResult result:uResults) {
         if (result.isSuccess() && result.isCreated())
              tasks.add(new Task(Subject = 'Follow-up', WhoId = result.getId()));
      }

      /* If there are tasks to be inserted, insert them */
      Database.insert(tasks);

      return uResults;
   }
}
</code>


DNS cache on macOS (Catalina)

Question: Can somebody share with me a way to display the DNS cache on my MacOS, Catalina (10.15.4)?
Comment: May be this answer may help? https://stackoverflow.com/a/54151812/4440387
Answer: It's very likely you don't actually have a DNS cache. If you do, dscacheutil -cachedump seems relevant here, probably sudo dscacheutil -cachedump. That said, I don't see any cache on any system I have, neither server-oriented systems nor end-user laptops.
See man dscacheutil for more.
Denis' answer via the comment will let you see lookups as they happen, but the DNS cache is very short lived if present at all.
Is there an actual problem at hand?

DNS cache on macOS (Catalina)


World Clock Webservice?

Question: What is the most reliable World Clock Webservice that you use?
Answer: Unfortunately, you'll probably never get a really accurate atomic clock webservice due to latency issues with the transport of the messages/packets back and forth from your machine to the server.
Most atomic clocks that are accessible over the internet use a specific protocol called the Network Time Protocol that includes a jitter buffer which specifically accounts for and adjusts based upon the latency of the transport.  This provides a more accurate representation of the atomic clock's time than using a web-service over HTTP.
I think if you must use a webservice, the most accurate one will be the one hosted on a server that is physically and geographically closest to you and also has the least number of network hops to get from your own machine to the server, since this will reduce the latency of the packets.
Answer: Understood about latency.  With that in mind, I go to NIST's site for US times and World Time Server for the rest.  Don't know if either is the "best".
Answer: I think due to latency, there is no such thing as a reliable atomic clock webservice.
Answer: Here's a blog post which comes to the same conclusion.
Purists are quick to point to the accuracy problem. But I bet you could not even get perfectly accurate time even if your application was sitting on the same server as the atomic clock software itself.
I think there is a need for a clock Web Service. I can think of a few scenarios where it doesn't matter being off a few seconds.
Aside accuracy, another challenging area of serving up date and time is taking into account the daylight saving details of most country. That is something even the latest OSes struggle to get right. But that is definitely something that would make a clock Web Service valuable.
Answer: Since there are so few web services out there delivering time, http://www.timeapi.org/utc/now is only reliable web service that I know of (besides http://www.earthtools.org/timezone/0/0, which does not appear to be reliable). Therefore it's the most accurate one I can recommend, especially if you are just using it for determining the difference between local time and UTC time, which can be rounded to the nearest 15 minutes.  And if you want the time in a specific time zone, replace utc with the three-letter abbreviation for the time zone -- i.e., http://www.timeapi.org/est/now for the Eastern Standard Time.
Answer: A NTP webservice would be fine as long as the latency is predictable.  NTP is a wire protocol and very lightweight to remove any moving pieces that may cause additional variation in latency (aka jitter).  A SOAP stack would introduce more variability.

World Clock Webservice?


Adding a Snagit image to the body of an e-mail

Question: My company just moved to Gmail and I am having trouble finding a way to add a Snagit image to the body of my e-mail.
Answer: At the moment, pasting images into the body of an email (not as an attachment) does not work. Gmail team is working on it, and hopefully solve it soon. However, there is a workaround to try. The following is the explanation of Paul McDonalds (Gmail Product Manager) about the issue dated Dec 18th, 2010:

Copy and paste works everywhere, it
  should work in Gmail too, right? We
  agree and we are working on a way to
  enable those of you with modern
  browsers (Google Chrome is our
  favorite) to copy and paste an image
  from the clipboard into the email
  body. The problem is that most browser
  don't allow you to do this without a
  bunch of work-arounds. We aren't quite
  there yet but trust that its something
  we are working on
In the meantime you can use the
  "insert image" lab that adds a new
  button to the rich text compose
  menu.By clicking this button you can
  insert an image directly into the body
  of the email and it will be displayed
  inline when read.


Deploying a Java flexible project by Google Cloud maven plugin to a different region

Question: I have a simple servlet Java project which I intend to deploy to App Engine southeast asia region.
I am using:
mvn gcloud:deploy

But it always deploys it to us-central region, what about if I want to deploy to a different region?
Answer: The region where your servlet is deployed is the one selected during the App Engine creation process. I'm guessing that you selected us-central at that time. That's why you are deploying to that region.
Currently, you can't change the App Engine's region after you set it the first time. So, if you want to deploy to a different version, you'll have to create a new project, create a new App Engine and then select other region.
There are various feature requests in Google Issue Tracker regarding changing App Engine's zone after creation, like this one, and the App Engine developer team is aware of this petitions, so the situation migh change in the future.


Polymorphism confusion

Question: I have read once in a book about exception where "an object of type Exception can be an instance of any
subclassof Exception". I kinda get it, but there's still confusion can anyone clarify me the meaning of this?
Comment: It means precisely what it states. Anything specific about your confusion?
Comment: can anyone provide me another example that is related to that, that's the confusion. it doesn't seem so clear to me, maybe another example of something related to it would do
Answer: Author means to say that base class pointers can point to any object of derived classes.
A derived class will have the public/protected members of the base class. So, the casting is implicit and not harmful.
Example:
We have a class vehicle.
Class car is derived from it, and so is truck.
So, if you create an object of car or truck type, the object can obviously point to its base class vehicle. This crux of it is the is-a relationship. A car is-a vehicle.
Answer: The point the author is getting at is when you have a variable that's declared to be of type Exception, the actual object assigned to that variable is not necessarily an instance of Exception itself - it may also be any of the subclasses of Exception.
Comment: Other than type Exception can you provide a another example? I kinda still don't get it.
Answer: Exception subclasses consist of objects that extend Exception, ie NullPointerException, ClassNotFoundException, OutOfRangeException.  Only subclasses of Exception will ever be an Exception object.
From wikipedia;

In object-oriented programming, a class is a construct that is used as a blueprint to create instances of itself – referred to as class instances, class objects, instance objects or simply objects.

Boxer, Beagle, Collie = Subclasses of Dog
Comment: which means that Boxes, Beagle is an instance of Dog?
Comment: `Boxer myBoxer = new Boxer();`  myBoxer is an Instance of Boxer as well as an instance of a Dog object.
Comment: will this do? Dog Boxer = new Boxer() but the Boxer will only have the methods of Dog am I right? to access the methods of Boxer I'll type cast it right?
Comment: But this thing is not allowed Boxer Dog = new Dog() am right?  I am just clearing out the concepts.
Comment: I made a little snippet at IDEone here: http://ideone.com/Nvm2C It isn't allowed implicitly. But you can always do so explicitly like the casting operators in C++. http://www.cplusplus.com/doc/tutorial/typecasting/
Answer: The point of polymorphism is that objects of a certain class can be treated in the same way as objects of their parent class, although their behavior may be different.
The prime example in Java is the Object class.  All other classes in Java are subclasses of Object, and so can be used wherever Object can.  A List is an ordered collection of Objects--thus (at least prior to Java 1.5) a List could hold 3 Foo objects, 14 Bar objects, and single Bat object.  You don't necessarily know up front what the actual class of the objects in the List are, except that they are Objects.
Another good example in Java is the Number class.  An Integer is an Number, so anywhere you can use a Number, you can use an Integer, or any of the other subclasses of Number (Long, Float, Double, Short, BigDecimal, AtomicInteger, etc).  All of these subclasses of Number are a little different--Floats represent real numbers, whereas Integers represent integers--but all of them are Numbers and so can be described and accessed in terms of them being numbers.

Polymorphism confusion


In java, can i use string split to split by character?

Question: For instance, I have the String variable abbaabbbba. I would like to use String split so each character would be separated, so it would be {a,b,b,a,a,b,b,b,b,a}. All the instructions I can find for string split say i need to have something, like a a space:
String mySplit = str.split("/");
Is there anyway to do this by character?
Answer: You can use the toCharArray method like this:
String myString = "abbaabbbba";
char[] myCharacters = myString.toCharArray();