If some polynomial is in an ideal $I$, how can I write it as a linear combination of the generators of $I$?

Question: I'm looking for a (easy) procedure of some sort. I also know a little bit of Singular and CoCoA, and was wondering if you can do that in there?
Comment: There is no 'easy' procedure. You can do this with Groebner bases.
Comment: @MooS Okay, but I want a linear combination in terms of the given generators of $I$, not a combination in the polynomials of the Groebner basis.
Comment: When you produce a Gröbner basis of $I$ you can keep track of the progress, and will then know how to write the elements of the resulting Gröbner basis in terms of the original set of generators.
Comment: @JyrkiLahtonen It's sometimes not very easy to compute a basis by hand, so if I'm using a computer to find a Groebner basis, how do I keep track of  everything then?
Comment: As I said: There is no easy procedure.
Comment: You could of course let the computer only do the division algorithms and keep track of the S-polynomials by hand (or by a self-written script).
Answer: Here's how in Macaulay2.
Let's say your ideal is $I=(x^2+2y^2-3,y^2-yx)$.
Then I claim that $y^3-y$ is in the ideal. Then we can write
<code>i59 : f

       2     2
o59 = x  + 2y  - 3

o59 : R

i60 : g

               2
o60 = - x*y + y

o60 : R

i61 : f = x^2+2*y^2-3

       2     2
o61 = x  + 2y  - 3

o61 : R

i62 : g = y^2-x*y

               2
o62 = - x*y + y

o62 : R

i63 : I = ideal(f,g)

              2     2               2
o63 = ideal (x  + 2y  - 3, - x*y + y )

o63 : Ideal of R

i64 : (y^3-y) // gens I

o64 = {2} | 1/3y      |
      {2} | 1/3x+1/3y |

              2       1
o64 : Matrix R  <--- R
</code>
Hence we see that $y^3-y = \frac 13 f +\frac 13(x+y)g$.
Comment: @user1952009 Well, yes, but you don't a priori know the degree of $a,b$ in $af+bg$, so that you don't know a priori how big a system you  must solve.
Comment: in $k[x_1,x_2,\ldots,x_n]$ when $k =\mathbb{Q}, \mathbb{R}$ or $\mathbb{C}$ it reduces to solving a system of linear equations ?
Comment: I didn't notice that problem, can the degree of $a_1,a_2,\ldots$ really be arbitrary big with respect to the degree of $P \in I$ ?


Prove existence and uniqueness of Convex Hull containing compact set

Question: I want to prove the existence and uniqueness of the convex set described below, which is the convex hull.  My thinking is that I'm to generate a set containing all the convex sets containing $A$ and take their intersection.  Then pointing out that the intersection will also be convex.  How could I formalize the set containing all such convex sets containing $A$?
Thanks in advance

If $A\subset\mathbb{R^n}$ is compact, then show that $\exists$ a unique convex subset $B$ of $\mathbb{R^n}$ such that $A\subset B$ and $B$ lies in any compact convex subset of $\mathbb{R^n}$ containing $A$.
Comment: I think the definition in wiki is clear enough to solve your problem. https://en.wikipedia.org/wiki/Convex_hull
Comment: The statement is a little disingenuous; there is a unique convex subset $B$ (called the convex hull) such that $A \subset B$ and $B \subset C$ for **any** convex $C$ containing $A$ (that is, not just compact ones). What is also truu in finite dimensions is that the convex hull of a compact set is also compact. one route to proving this is Carathéodory's theorem.
Answer: To formalize: let $\mathscr C$ be the collection of sets (so it is a subset in the power set of $\mathbb R^n$):
$$\mathscr C:= \{ B\subset \mathbb R^n : B \text{ is convex and } A\subset B\}.$$
Then the set you want is
$$ A^h := \bigcap _{B\in \mathscr C} B.$$
Comment: This makes sense.  So I guess it would be enough to just say prior to describing the collection that since $A$ is compact, it's bounded, which guarantees that such convex sets contain it
Comment: Indeed one can find a convex hull for any subset (indeed, $\mathbb R^n$ is convex and so $\mathscr C$ is always nonempty. The point is that when $A$ is compact, the convex hull is also compact (is that your question? @johnfowles)
Comment: Well, proving that the convex hull is compact is what I want to prove next, but I wanted to make sure that in proving the first part of the question, I was correctly defining the set which contained every convex set containing $A$ before I took the intersection of that set


Why do some artists tune their guitars half a step or whole step down?

Question: Is there a reason some guitarists tune down half or whole steps, other than preference or style?
It bugs me sometimes when I would like to play along with a song only to find that it's played down half or a whole step.
I have purchased software that enables me to adjust the pitch of songs without affecting the tempo, etc, and my guitar tab software can transpose tabs, but knowing why artists do this in the first place would be helpful.
Comment: They do it to bug you; Some artists are like that you know, they forget where they came from and who's buying their music. And, I agree, it would be considerate of them to say when they are going to tune down a half or whole step, though, out of courtesy to them I think we should let them tune two steps or more unannounced. :-)
Comment: I remember reading that stevie ray vaughan used the thickest strings he could find and then tune a semi tone down so that they become a little more manageable.
Comment: Is pitch shifting the audio and transposing the tab less effort than retuning your guitar or having a second one on-hand that's already tuned down?
Comment: @alfonso well... yeah, it's just a button press in Guitar Pro, but that wasn't the point of the question (which I might also add is now over 10 years old). I wasn't _complaining_ about it, just asking for reasoning behind it.
Comment: @Jasarien, oh my mistake. Your question was in my digest email last week. You were using guitar pro a decade ago and this is the first I hear of it. I'm pretty old I guess... wow!
Answer: Lots of reasons; the most prevalent reason is probably so that they can keep the tune within the range of their voice.  Jimi Hendrix was famous for this; tuned a half step down.
Other reasons; to create a different atmosphere in the music; as in the case of Metal where instruments are down-tuned to create the darkest most aggressive sounding riffs possible.
Comment: And Muddy Waters was known for capoing on the second fret and playing and singing songs in F#. Perhaps that suit his voice better.
Comment: This answer assumes the guitarist is using predominantly open chords, but I still doubt that one semitone down will affect the range of any song enough to make it worthwhile.Does a 5 fret bar A chord  sound much different from a 4 fret Ab chord ? (Obviously not in a key situation)
Comment: I agree with Tim, I think this reasoning is off. If the range was an issue, they'd just play in a different key.
Comment: Well, for metal the low E string is used predominantly, and a half or whole step down makes a difference.
Comment: Tuning down also effects the overall sound of the instrument, even when playing fretted notes.
Answer: An additional point is that a guitar tuned a half/whole step down will be easier to play with higher action or larger gauge strings due to the less tension on the strings required to maintain the right pitch. I believe I have an interview with Stevie Ray Vaughn around here somewhere where he cites this, as well as many other reasons, as to why he played a half step down.
Comment: It also makes it easier to rattle the strings against the frets == acoustic distortion.
Answer: Another reason is to make it easier to bend strings. A great example would be Jerry Cantrell from Alice in Chains. He constantly bends up a semi or whole tone and mostly all his songs are in Eb standard or Drop C# tuning.
Comment: I'm not sure that's the main reason. It seems it played a role for Iommi (Black Sabbath), though, to ease the tension on his faux fingertips.
Answer: I have done this in the past with 12-string guitars for the simple reason that it makes the high G string last longer! On a 12, the G string has a double that is an octave higher, making it significantly higher and tenser than any string on a normal 6-string. It's always the first string to snap.
Another reason why records don't always seem to be in the expected key is that varispeed recording was very popular at one time. The Beatles used it a lot; Rain was slowed down, while many other songs were speeded up. Strawberry Fields Forever was made of two halves, one slowed down, the other speeded up.
Some guitarists tune their guitar up a tone, whether to fit the range of a vocalist or to get a brighter sound from the tension in the strings. Johnny Marr would do that. (Of course this is far less of a problem if you're playing along as you can just use a capo.)
Answer: I was under the impression that drop tuning also makes it easier to do some power chords. For example: dropping the tuning on the E string allows single finger power chords.
Comment: The idea being discussed seems to be moving the tuning from **EBGDAE** to **DAFCGD**, while you're taking Drop-D, which moves the tuning to **EBGDAD**. It's a common and useful thing, but not what OP is asking about.
Answer: The short answer is that guitarists use alternate tunings to make it easier to play songs in keys other than E, A and D.
One example of a reason for this would be to accompany a singer who insists that a certain song needs to be sung in a lower key than the one the guitarist learned it in.
Another example would be when the guitarist determines that in a particular song, he needs to play low notes that are lower than the low "E" on the guitar when it is in standard tuning.
Answer: For a variety of reasons:

They like the sound of the looser strings and lower pitches (many dark metal acts)
They like the snappier, jangly sound of tighter, higher pitched strings (e.g. Johnny Marr of The Smiths)
They want to play certain open-string chords, while keeping the song within their vocal range
They want to play certain open-string chords, while being in a key that is convenient for their accompanying musicians (for example, you've learned chords in E; I want to play the melody on a diatonic melodeon in D)
They didn't use any form of reference pitch when tuning
Answer: Advantages:
1) better accomadates a particular vocal range     try singing simple man by LS in standard tuning.
LS tuned their guitars down 1/2 step.....another good example....several Neil Young songs....down by the river...only love can break your heart. Even neil on occasion, when his range shifts for whatever reason, tunes his guitar down a half step...     the song the Joker by Steve Miller is tuned down a full step.
2) makes bar chords and lead a bit easier to play because of less string tension
3) can possibly extend life of strings? maybe? I don't know for sure, but it make sense.
4) Can always capo up to standard tuning, whereas going from standard to lower tunings requites physically retuning your guitar
Disadavantages
1) When asked to sit in with other musicians, re-tuning to standard, if that's what they're using, can be a pain in the ass. Unfortunately, the term "standard" tuning, besides the fact that it is the guitar tuning used most frequently, can play havoc with a musicians ego and/or subconcious. I've heard more than a few musicians, begginners and advanced, speak of "non-standard" tunings as if those who used them were "out of the mainstream" and, as such, were either cheating, or vocally weak. This is easily demonstrated as sheer non-sense when taking a look at the plethora of famous singer/songwriter/guitarists who use, or did use them, routinely.
2) When it's really desirable to capo up to standard, having the capo on the first fret makes playing chords up the neck confusing, because it reconfigures fret markers. Super good players can account for that I suppose, but when I capo up from a half step down, I prefer to capo up to the second fret when possible to avoid these "odd" positionings. If all chords of a song are near the capo (i.e. predominately open as opposed to bar chords), this is not an issue.
3) Does tuning a guitar a half or full step down change how a guitar matures over time? I don't know. It would be interesting to ask the worlds greatest luthiers whether the physics of any particular guitar design pre-supposes that the guitar will be played in standard over most its life.
Answer: Well, aside from the fact that they just like it I will admit that there are some songs which sound strikingly different in tone and mood just from a simple 1/2 step down-tuning.
But ultimately, it is my belief that guitarists tune a 1/2 step down in order to make it easier for a piano/keyboardist to play along. Many times when guitarists are working with others in a band or just doing their own songwriting, in regular tuning playing along with a guitarist using a piano/keyboard, one has to be fairly familiar with the piano's scales and chords to play something that sounds good. Meaning, you'd have to be a rather accomplished pianist in order to "freestyle" along with a guitarist.
If you didn't know, there's a dirty secret about playing the piano- if you limit yourself to playing on (pretty much) only the black keys, anything you play will pretty much sound good, or at least correct. When a guitarist tunes down 1/2 step, it is suddenly tuned such that it has essentially made the black keys the white keys for the piano player.
So, it is my assertion that 1/2 step down is mostly because it makes it incredibly easy to play along with on the piano. Hope this helps.
Answer: It's because to make the pitch of the guitar tune agrees with the vocal's pitch :) If one doesn't tune properly , the pitch would sound different . For example playing a 'C' note , and suddenly a 'C#' pitch will be heard . If the vocal sings a C , guitar must play a 'C' too .
Comment: On the assumption the vocalist has perfect pitch and is a pedant, this could be true.
Answer: Well, I play in dropped A tuning. Why?
The informal reason: The metal band Suicide Silence is the reason I wanted to start playing guitar in the first place and I could not play their songs unless I was in the same tuning as them.
This opened up a WHOLE WORLD for me!
Remember, no matter what tuning you're in, you can always go higher, not lower. Meaning, in dropped A, I can play songs that are in ANY tuning, except for like dropped F which is sooo rare.
Any song I learn, I instantly transcribe to dropped A. I really don't see the need for me to play in any other tuning, to be honest. I play bass guitar, and higher tunings just don't have the "oomph" I need.
Look at it this way: When you down tune a guitar, you are loosening the strings. Which means the strings actually vibrate more when you play and if you pair that with distortion UGH it's amazing. The crunch is unbeatable.
Down tuning was actually founded by jazz and blues musicians. The looser strings are the trick to their play style.
And when you play say, songs that are played in standard but in dropped A, you bring your vibrato and your crunch from the lower tuning with you and create a style that is your own.
I tune my guitar like this: A/E/A/D.
So, I have a lower A and a higher A. This allows me to create melodies with the two strings that I cannot do in other tunings.
Also! The band Motograter (the band Ivan Moody was in before Five Finger Death Punch) has a horizontal bass guitar that they built that only has two strings both tuned in A. So I know when I play that band, I only need to use the 2 strings and it sounds identical! And the melodies are so awesome you would never know they only use 2 strings.


Twig escapes tags when using raw value in template

Question: I am printing fields in a node template, but Twig is escaping my tags and ruining my day.
My .tpl looks like this:

{{ content.field_myfield.0 }}

I want to strip all tags from the original field and then "wrap" the field in a paragraph tag with the title class.  I found out how to get the raw value without tags based on this question.
However, this is the HTML that is actually output:

When you wish upon a star

What am I doing wrong?
Comment: content.field_myfield.0|render|striptags|trim . Can we try something like this.
Answer: You can use the following code below:
{{content.field_myfield.0|render|striptags|trim}}

render:  The striptags filter strips SGML/XML tags and replaces
  adjacent whitespace by one space.  You can also provide tags which
  should not be stripped:

{{ content.field_myfield.0|striptags('

')}}

trim: The trim filter strips whitespace (or other characters) from the beginning and end of a string:
{{ '  I like Twig.  '|trim }}

{# outputs 'I like Twig.' #}

{{ '  I like Twig.'|trim('.') }}

{# outputs '  I like Twig' #}

{{ '  I like Twig.  '|trim(side='left') }}

{# outputs 'I like Twig.  ' #}

{{ '  I like Twig.  '|trim(' ', 'right') }}

{# outputs '  I like Twig.' #}

The example above used from the twig website.


Why do I not get stereo output of my drums through the mixer?

Question: I am trying to mix my electronic drum kit with music from my iPhone so I can play along with tracks on my drum kit.
Here is my drum kit controller with outputs.

And here is my mixer:

I am connecting things as follows:
<code>drums iphone
  |     |
  -------
     |
   mixer
     |
 headphones
</code>
The drums I connect via the 'phones' output (as I presumed this would be stereo) and I use this cable:

I connect my iPhone with a similar cable.
I connect to my headphones with this adaptor:

However, when I listen the sound in the headphones is only in one ear!
I suspect the problem is something to do with these cables I am using, but I wanted to be sure before I purchased any more gear.
Thanks in advance for the help!
Comment: Just get a stereo mixer. This one's a mono mixer.
Answer: The problem is that the mixer is fully monaural (mono) and your headphones are stereo. Your mixer's output is not designed to work with headphones. A TRS cable connecting the drum module to the mixer will not help because the mixer will only see mono.
The quickest, easiest way to play along to music on your iPhone is to plug the iPhone into the drum module's AUX IN jack (using whatever adapter you're currently using to plug it into the mixer) and plug your headphones into the drum module's PHONES jack. Then you'll hear everything in both ears and in stereo. This use case is what the AUX IN jack is for. You don't need the mixer at all.
In comments, you asked if you'd be better off using the MIDI OUT. The answer is no. MIDI is a digital interface that carries performance and configuration data, not audio. (It allows electronic instruments and computers to control one another.)
If you were dead set on using the mixer, you'd need to buy a headphone amplifier that accepts mono input and is capable of sending the mono signal to both ears. And, even then, you'd only hear one side of the iPhone's stereo. On some familiar recordings, you'd definitely hear things missing.
There are a few other points to make that don't apply to what you're trying to accomplish, but may help you understand your gear more fully.

To connect your drum module to a mono system, you would ideally use the L/MONO output, not the PHONES output, which is designed for headphones.
An additional problem with using the PHONES output to feed a mono system is that the individual pieces of your kit will have uneven volume. In the stereo field that you hear from the drum module's PHONES output (when you plug headphones into it), you'll hear hi-hats more strongly on one side and ride on the other. Same with the toms. If you connect this stereo output to a mono input, you'll only hear one side of the stereo field, causing one side of the kit to sound weaker than the other.
To connect your drum module to a stereo system, you would want to use both the R and L/MONO outputs, not the PHONES output.
Comment: Sadly, this is true. Buyer beware! I do feel like I understand my gear a lot better now, however.
Answer: That cable you use to connect the drums to the headphone out is not stereo. You need a TRS cable (Tip Ring Sleeve). It will look like your other cable which has one more line around it on the sleeve.
The first pic shows a TRS (Stereo) 1/4" plug.

The next one shows a TS (mono) 1/4" plug.

Also the headphone Jack on the mixer might not be the best level coming into your mixer. Ideally you want to use both jacks in the output section into two channels. Or into one stereo channel.
Comment: The mixer is mono and will never treat a stereo input as stereo.
Comment: Yes, the whole mixer is fully mono. Manual is here: https://media63.music-group.com/media/sys_master/h06/h4a/8849815404574.pdf
Comment: You iPhone is stereo so yes you will want a stereo cable out of the iPhone into a stereo input on your mixer. Midi will not be able to go into your mixer directly you will need a midi interface to make the sounds.
Comment: So same for the iPhone in? It is using the same type of cable.
Comment: Also: am I better off using the MIDI out on the drums?
Comment: @trw it is mono out? If it only takes mono in then you can go out of the mono output into a channel. Out of iPhone you will need a TRS cable split to two mono cables into two channels so you get both sides


How can i add a line-break on a costume tooltip?

Question: How can i add a line-break on a costume tooltip? Be it a css or jquery one , i am not sure how to do it , it's simple with native tooltips by using
 but that doesn't work with a costume one , and that makes displaying some info hard , for example:

Name:John Smith
Age:15
Hair-Color:Green
.
.
.

So what would be the solution?
Comment: Yes , a line break.In some languages u can use /n for that i thought it would be the same for jQuery but no.
Comment: @aleksXPO This is not related to jQuery, but to displaying the line breaks, which means you will have to use some CSS.
Answer: If you use a simple line break
 or \n , you have to set white-space: pre; to preserve line breaks and white space. Or you may transform each
 to a line break HTML tag
 in the backend or via JS.
See: https://developer.mozilla.org/en-US/docs/CSS/white-space
Comment: Nice info about white-space: pre;
Answer: In javascript there are two ways you can do this:
Using the newline \n character in your string:
var tooltipstring = "John Smith \n Age:15 \n Hair-Color:Green";
Or by adding a new line in the string and escaping it correctly with a backslash \:
var tooltipstring = "John Smith \
Age:15 \
Hair-Color:Green";


Eclipse, Maven and code coverage

Question: Is there any Eclipse plug-in that gives the code coverage directly within the Eclipse JAVA editor, just like eCobertura or EclEmma, but that launches the tests using the Maven goal test (i.e. mvn test)?
I need to specify a Maven profile to get some properties filtered (i.e. mvn -Pdev test), but the two solutions given above don't allow us to work with Maven (AFAIK).
PS: I know I could use the clean site Maven goals (i.e. mvn -Pdev clean site) or the Cobertura Maven Plugin (i.e. mvn -Pdev cobertura:cobertura) to get a code coverage report, but I would like to get the coverage directly within the Eclipse JAVA editor. Convenience-addict.
Answer: Can you set the default maven profiles for your project using Project Properties -> Maven -> Active Maven Profiles?
(Aside: I wouldn't have a special 'test' profile if that means the tests don't run without it. It's too easy to forget to run the tests. 'dev' makes sense, but should probably be active by default. Otherwise new developers will struggle to build the project.)
Comment: That made it work! I already tried to add an `` tag within the pom.xml file, but I hadn't tried using the project properties. Many thanks `;)`

Eclipse, Maven and code coverage


Configure kubectl command to access remote minikube cluster on virtualbox debian VM

Question: i have set up successfully on debian minikube with simple cluster
Debian VM :
umen@debian12:~$ kubectl get pods
NAME                     READY   STATUS    RESTARTS   AGE
hello-77c947d946-jq2s4   1/1     Running   0          45m
hello-77c947d946-wm6n2   1/1     Running   0          45m

umen@debian12:~$ minikube service list -p multinode-demo
|-------------|------------|--------------|---------------------------|
|  NAMESPACE  |    NAME    | TARGET PORT  |            URL            |
|-------------|------------|--------------|---------------------------|
| default     | hello      |           80 | http://192.168.49.2:31000 |
| default     | kubernetes | No node port |                           |
| kube-system | kube-dns   | No node port |                           |
|-------------|------------|--------------|---------------------------|

umen@debian12:~$ curl http://192.168.49.2:31000
Hello from hello-77c947d946-wm6n2 (10.244.1.2)

As you see above all working
now In my windows host i try to connect this cluster
i downloaded the certificates from the debian server
vi ./kube/config_debian
apiVersion: v1
clusters:
- cluster:
    certificate-authority: debian/ca.crt
    extensions:
    - extension:
        last-update: Mon, 23 Oct 2023 08:54:23 IDT
        provider: minikube.sigs.k8s.io
        version: v1.31.2
      name: cluster_info
    server: https://192.168.49.2:8443
  name: minikube
contexts:
- context:
    cluster: minikube
    extensions:
    - extension:
        last-update: Mon, 23 Oct 2023 08:54:23 IDT
        provider: minikube.sigs.k8s.io
        version: v1.31.2
      name: context_info
    namespace: default
    user: minikube
  name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
  user:
    client-certificate: debian/client.crt
    client-key: debian/client.key

when i try to connect im getting :
$ kubectl -v=8 --kubeconfig=config_debian get pods
I1023 10:55:55.058414   16936 loader.go:372] Config loaded from file:  config_debian
I1023 10:55:55.154616   16936 cert_rotation.go:137] Starting client certificate rotation controller
I1023 10:55:55.154616   16936 round_trippers.go:432] GET https://192.168.49.2:8443/api?timeout=32s
I1023 10:55:55.155136   16936 round_trippers.go:438] Request Headers:
I1023 10:55:55.155136   16936 round_trippers.go:442]     Accept: application/json, */*
I1023 10:55:55.155136   16936 round_trippers.go:442]     User-Agent: kubectl.exe/v1.22.0 (windows/amd64) kubernetes/c2b5237
I1023 10:56:16.186405   16936 round_trippers.go:457] Response Status:  in 21031 milliseconds
I1023 10:56:16.186405   16936 round_trippers.go:460] Response Headers:
I1023 10:56:16.186405   16936 cached_discovery.go:121] skipped caching discovery info due to Get "https://192.168.49.2:8443/api?timeout=32s": dial tcp 192.168.49.2:8443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
I1023 10:56:16.188079   16936 round_trippers.go:432] GET https://192.168.49.2:8443/api?timeout=32s
I1023 10:56:16.188079   16936 round_trippers.go:438] Request Headers:
I1023 10:56:16.188079   16936 round_trippers.go:442]     Accept: application/json, */*
I1023 10:56:16.188079   16936 round_trippers.go:442]     User-Agent: kubectl.exe/v1.22.0 (windows/amd64) kubernetes/c2b5237
I1023 10:56:37.192081   16936 round_trippers.go:457] Response Status:  in 21003 milliseconds
I1023 10:56:37.192189   16936 round_trippers.go:460] Response Headers:
I1023 10:56:37.192189   16936 cached_discovery.go:121] skipped caching discovery info due to Get "https://192.168.49.2:8443/api?timeout=32s": dial tcp 192.168.49.2:8443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
I1023 10:56:37.193955   16936 shortcut.go:89] Error loading discovery information: Get "https://192.168.49.2:8443/api?timeout=32s": dial tcp 192.168.49.2:8443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
I1023 10:56:37.194510   16936 round_trippers.go:432] GET https://192.168.49.2:8443/api?timeout=32s
I1023 10:56:37.194510   16936 round_trippers.go:438] Request Headers:
I1023 10:56:37.195088   16936 round_trippers.go:442]     Accept: application/json, */*
I1023 10:56:37.195088   16936 round_trippers.go:442]     User-Agent: kubectl.exe/v1.22.0 (windows/amd64) kubernetes/c2b5237

and in virtual box i set the port forward like this :

The question is why i can't connect to the remote cluster
Comment: It seems the kubectl lost connection to the Cluster and you can set the Cluster context by following this [Troubleshooting kubectl command times out](https://cloud.google.com/kubernetes-engine/docs/troubleshooting#kubectl-times-out). You can try to use the **kubectl proxy** to open local 8xxx for accessing the web interface of Kubernetes for more details refer to [How to Install Minikube on Debian](https://linux.how2shout.com/how-to-install-minikube-on-debian-11-bullseye-linux/).
Comment: Feel free to update the status of the question. Let me know if my answer & comment helps to resolve your issue? I am happy to help you if you have any further queries.
Comment: Have you tried my suggestions and the issue is resolved?
Answer: As per the Github issue #2575, check the causes for connection issues & mitigations as explained below :

Check you might have an issue with having both Docker Toolbox (old version using VirtualBox) and Docker for Windows (using Hyper-V) installed. Removing Docker Toolbox and re-installing Docker for Windows may help to resolve the issue.

Check the server's resources running low : make sure the server has enough resources (such as memory) to handle the no.of requests you are sending.

From certification side try below 2 steps & follow the documentation minikube TLS without verification, which may help to resolve your issue further :

Setup port forward from host 8443 to Minikube vm 8443 in virtualbox

Create a new context minikube-vpn without TLS verify.


Do I need RDS CALs for the users that come with Windows Server 2012 R2 Foundation?

Question: I bought a server hardware with a Windows Server 2012 R2 Foundation license. That license comes with 15 users, which is sufficient for my needs. I'd like to use the server for RemoteApps. I configured everything and it works fine, but RD Licensing Diagnostics says I have no licenses. On the other hand, RD Licensing Manager reports I have an unlimited number of device TS-CALs of Windows 2000 Server type.
Do I need to buy additional device or user CALs if I want to stay below the 15 user limit?
Comment: Have you... *activated* RDS?
Comment: Yes I have. I activated the RD Licensing Server with Microsoft. Everything works, but since I am in this 120 days grace period, I don't know how long.
Comment: You need to purchase RDS CAL's (not to exceed 15). - https://technet.microsoft.com/en-us/library/jj679892(v=ws.11).aspx
Answer: You'll need to purchase RDS CAL's (not to exceed 15).
https://technet.microsoft.com/en-us/library/jj679892%28v=ws.11%29.aspx


Finding UMVUE of Bernoulli random variables

Question: Given i.i.d. Bernoulli$\left(\theta\right)$ r.v.s $X_1, X_2, ...,X_n$, I'm asked to solve for the UMVUE of $\left(1−\theta\right)^2$ for the case $n=4$.
I think that $\sum X_i$ is my sufficient statistic (and I think completely sufficient) from using the Factorization Theorem, but I'm having trouble proceeding from there.
I know that I have to use the Rao-Blackwell theorem, but I'm not exactly sure how that follows. I would appreciate any tips!
Comment: Another way is to expand $(1-\theta)^2$ and use https://math.stackexchange.com/questions/2687375/how-to-find-umvue-of-thetak-with-bernoulli-distribution.
Answer: The idea is that you can start with any estimator of $(1-\theta)^2$, no matter how awful, provided it is unbiased.  The Rao-Blackwell process will almost magically turn it into a uniformly minimum-variance unbiased estimator (UMVUE).
There are many ways to proceed.  One fruitful idea is systematically to remove the complications in the expression "$(1-\theta)^2$".  This leads to a sequence of questions:

How to find an unbiased estimator of $(1-\theta)^2$?
How to find an unbiased estimator of $1-\theta$?
How to find an unbiased estimator of $\theta$?

The answer to (3), at least, should be obvious: any of the $X_i$ will be an unbiased estimator because
$$\mathbb{E}_\theta(X_i) = \theta.$$
(It doesn't matter how you come up with this estimator: by guessing and checking (which often works), Maximum Likelihood, or whatever.  ML, incidentally, often is not helpful because it tends to produce biased estimators.  What is helpful is the extreme simplicity of working with a single observation rather than a whole bunch of them.)
Linearity of expectation tells us an answer to (2) would be any of the $1 - X_i$, because
$$\mathbb{E}_\theta(1-X_i) = 1 - \mathbb{E}_\theta(X_i) = 1-\theta.$$
Getting from this to an answer to (1) is the crux of the matter.  At some point you will need to exploit the fact you have more than one independent realization of this Bernoulli variable, because it quickly becomes obvious that a single $0-1$ observation just can't tell you much.  For instance, the square of $1-X_1$ won't work, because (since $(1-X_1)^2 = (1-X_1)$)
$$\mathbb{E}_\theta((1-X_1)^2) = 1-\theta.$$
What could be done with two of the observations, such as $X_1$ and $X_2$?  A little thought might eventually suggest considering their product.  Sure enough, because $X_1$ and $X_2$ are independent, their expectations multiply:
$$\mathbb{E}_\theta((1-X_1)(1-X_2)) = \mathbb{E}_\theta((1-X_1))\mathbb{E}_\theta((1-X_2)) = (1-\theta)(1-\theta)=(1-\theta)^2.$$
You're now good to go: apply the Rao-Blackwell process to the unbiased estimator $T=(1-X_1)(1-X_2)$ to obtain an UMVUE.  (That is, find its expectation conditional on $\sum X_i$.) I'll stop here so that you can have the fun of discovering the answer for yourself: it's marvelous to see what kinds of formulas can emerge from this process.

To illustrate the calculation let's take the simpler case of three, rather than four, $X_i$.  The sum $S=X_1+X_2+X_3$ counts how many of the $X_i$ equal $1$.  Look at the four possibilities:

When $S=0$, all the $X_i=0$ and $T = 1$ constantly, whence $\mathbb{E}(T\,|\,S=0)=1$.
When $S=1$, there are three possible configurations of the $X_i$: $(1,0,0)$, $(0,1,0)$, and $(0,0,1)$.  All are equally likely, giving each a chance of $1/3$.  The value of $T$ is $0$ for the first two and $1$ for the last.  Therefore
$$\mathbb{E}(T\,|\,S=1) = \left(\frac{1}{3}\right)\left(0\right)+\left(\frac{1}{3}\right)\left(0\right)+\left(\frac{1}{3}\right)\left(1\right) = \frac{1}{3}.$$
When $S=2$ or $S=3$, $T=0$ no matter what order the $X_i$ appear in, giving $0$ for the conditional expectation.

The Rao-Blackwellized version of $T$, then, is the estimator that associates with the sum $S$ the following guesses for $\theta$:
$$\tilde T(0)=1,\ \tilde T(1)=1/3,\ \tilde T(2)=\tilde T(3)=0.$$
As a check, the expectation of $\tilde T$ can be computed as
$$\eqalign{
\mathbb{E}(\tilde T) &= \Pr(S=0)\tilde{T}(0) + \Pr(S=1)\tilde{T}(1) + \Pr(S=2)\tilde{T}(2) + \Pr(S=3)\tilde{T}(3) \\
&= (1-\theta)^3 + \binom{3}{1}\theta(1-\theta)^2\left(1/3\right) + 0 + 0 \\
&=  1 - 3 \theta + 3 \theta^2 - \theta^3 + 3(1/3)(\theta - 2\theta^2 + \theta^2) \\
&= 1 - 2\theta + \theta^2 \\
&=(1-\theta)^2,
}$$
showing it is unbiased.  A similar calculation will obtain its variance (which is useful to know, since it is supposed to be the smallest possible variance among unbiased estimators).
Note that these calculations required little more than applying the definition of expectation and computing binomial probabilities.
Comment: What is "$t$"? Whatever it is, you can partially check your work by confirming that the expectation of your answer is $(1-\theta)^2$.
Comment: I think my "$t$" is (contextually) equivalent to the "$S$" variable you showed above. Going to check if the expectation shows its unbiased. Thanks for the cogent explanation!
Comment: That's a clever way of writing the estimator--and it generalizes to other values of $n$ :-).  A useful formula is $$\sum_{t=0}^n \frac{(n-t)(n-1-t)}{n(n-1)}\binom{n}{t}\theta^t(1-\theta)^{n-t} = (1-\theta)^2.$$
Comment: Ironically, the first time I tried the problem on my own, I got exactly what you wrote on the left side. So plugging in for $n=4$, it generalizes to what I put above. Fabulous! I also checked the expected values to see if I would get the $T(x)$ values I expect from my estimator, and I do. (T(0) = 1, T(1)=1/2, T(2)=1/6, T(3)=T(4) = 0). Thank you so much!
Comment: In that case I will venture the results of a calculation of the variance. If I did it correctly, it equals $$\frac{2 (\theta -1)^2 \theta  (-3 \theta +2 (\theta -1) n+2)}{(n-1) n}.$$
Comment: Thanks for this! I don't know if this is right, but I ultimately got $(4-t)(3-t)/12$ as my UMVUE. Not sure if/how I represent that as a function of my sufficient statistic.
Comment: @whuber Can you elaborate your steps for variance? $Var(\frac{(4-S)(3-S)}{12})$ does not seem to return the same, unless I am committing a mistake
Comment: @right I have computed this three different ways but always get the same answer. Letting $X=(4-S)(3-S)/12$, we know $\mathbb{E}(X)=(1-\theta)^2$ by design. $\mathbb{E}(X^2)$ is easily computed from first definitions: it is a sum over the five possibilities $S=0,1,\ldots,4$. I obtain $\frac{1}{6} \theta ^2(1-\theta )^2+(1-\theta )^4+\theta (1-\theta )^3$. Subtracting $(\mathbb{E}(X))^2$ gives the variance.
Comment: @whuber Shouldn't the first term in the sum have coefficient 1? $\frac{1}{6} \times \binom{4}{2}$
Comment: @right I'm not sure which sum you are referring to.  I don't see any typographical errors in the formulas given in my last comment.


Bounded idempotent on Hilbert space has closed range.

Question: Let $H$ be a Hilbert space and $p\in B(H)$ an idempotent on $H$, i.e. a continuous linear map satisfying $p^2 = p$. Is it true that $p(H)$ is a closed subspace of $H$?
Attempt:
Consider a sequence $p(h_n) \to h $. We show $h \in p(H)$. By continuity, $$p(h_n) = p^2(h_n) = p(p(h_n)) \to p(h)$$ but also $p(h_n) \to h$ so we obtain $h = p(h) \in p(H)$ and we are done.
Is this correct?
Answer: Yes, your proof is correct.
As an alternative approach, we could note that $p(H) = \ker(\operatorname{id}_H - p)$, and the kernel of any bounded linear map is closed.
Comment: Nice alternative solution. Thanks for sharing!


Monotone convergence for McShane (Lebesgue) integral (step in a proof)

Question: The theorem states

Let $f$ be a function on a cell $A$ and let $f_n$ be a sequence of McShane (Lebesgue) integrable functions such that, $f_n\le f$ and $f_n\to f$. Than, if $\lim_{n\to\infty} \int_A f_n d\alpha$ is finite, than $$\int_A fd\alpha =\lim_{n\to\infty} \int_A f_nd\alpha$$

Now, let
$$I=\lim_{n\to\infty}\int_A f_nd\alpha$$
and $$A=\cup_{i=0}^kA_i$$
The proof states

The theorem is proved by showing that $$|\sum_{i=0}^k f(x_i)\alpha(A_i) - I|<\epsilon|2-\alpha(A)|\tag{1}\label{1}$$

Question
As $\alpha(A_i)=\alpha(b)-\alpha(a)$ where $b$ and $a$ are the endpoints of the interval $A_i$, how can this be so? Suppose the range of $\alpha$ is $\mathbb{R}$. Does that not make the right hand side of \eqref{1} infinite? Surely the $\alpha(A)$ must be finite?
Please help me understand, I do not know why $\eqref{1}$ implies the theorem. As a self taught amateur, I have no one but stackexchange to ask...
Edit
To clarify, I know how to prove the theorem, if $I$ assume that the stateent \eqref{1} implies the theorem, as I know how to prove \eqref{1}. My problem is, that I do not understand why \eqref{1} implies the theorem, if, lets say, $\alpha(A)=\alpha(b)-\alpha(a)$ is not finite, because lets say, $a$ or $b$ are not finite. Than It would seem that the right hand side of \eqref{1} is not finite. So how does \eqref{1} imply the theorem even when $\alpha(A)$ is not finite?
Comment: Probably, you may want to recall how to define $\int f d\alpha$. Starting from simple functions, bounded functions, and non-negative functions...
Comment: @induction601 Thank you for your comment. Yes, I recall the definition, I am looking at it in the book as I write this. There is no mentioning of it having to be finite ($\alpha(A)$). Looking at my question, is it your opinion that $\alpha(A)$ has to be finite, for the (1) to imply the theorem?
Comment: @induction601 I added an edit to clarify my question. If you know, please provide an answer, I would be most grateful.
Comment: It is not necessarily to $\alpha(A)$ be finite. For example, let $A = [1,\infty)$. Then $\alpha(A) = \infty$, however, $\int f d\alpha < \infty$ when $f(x) = 1/n^2$ where $x \in [n,n+1)$.
Comment: In theorem, it is only required $\lim_n \int f_n d\alpha < \infty$ not $\alpha(A) < \infty$. $\alpha(A)$ could be infinte. For example let $f_n(x) = 1/k^2$ when $x \in [k,k+1)$ for $1\le k <n$ and $f_n(x) = 0$ when $x \in [n, \infty)$. Note that $\lim_n f_n = f$ as I defined above. Then as theorem stated, $\lim_n \int f_n d\alpha = \int f d\alpha < \infty$.
Comment: I think I misunderstood your question. I think that when $\alpha(A) < \infty$, (1) implies theorem. However, you can always divide integral into countable integal with finite $A_i$.
Answer: Let $A = \cup_{i=1}^n A_i$ with $\alpha(A_i) < \infty$ and $A_i$'s are disjoint.
WLOG, say $\alpha(A_i) = 1$.
Then suppose
$\int_A f_n d\alpha < \infty$. Then one can write
$$ \int_A f_n d\alpha = \sum_{i=1}^\infty \int_{A_i} f_nd\alpha.$$
Thus let $I = \sum_{i=1}^\infty I_i = \int_A f d\alpha$ where $I_i = \int_{A_i} fd\alpha$.
Thus it suffices to show that for each $i$,
$$ \left|I_i - \int_{A_i} f_n d\alpha \right| < \frac{\epsilon}{2^i}.$$
Because this implies
$$ \left|I - \int_A f_n d\alpha \right| \le \sum_{i=1}^\infty\left|I_i - \int_{A_i} f_n d\alpha \right| < \sum_{i=1}^\infty \frac{\epsilon}{2^i} \le \epsilon. $$
Comment: First, many thanks for your time! Please tell me if I understood correctly. In my question, (1) implies the theorem only when $A_i$ is finite. BUT, as you had shown, we can use such a theorem on an infinite collection of $A_i$, (where $A=\cup_{i=0}^\infty A_i$) and show that (as the theorem holds on any finite $A_i$) the sum over the $A_is$ must converge as well. Sorry for the follow up, I am pretty tired, and want to be sure I understood you, before I go to bed :)
Comment: Yes, you got my point!
Comment: Thank you! I am a self taught amateur, I really appreciate such help! Thanks again!


2 dimensional Smooth manifold of $ℝ^3$

Question: From this post ,
In attempt solve to this problem, I followed Yves Daoust's approach for parametise the torus as followed:

A circle of radius $a$ centered at $(b,0)$ in the plane $xz$ has the
  parametric equation
$$x=a\cos(\theta)+b,z=a\sin(\theta),$$ with $\theta$ in the range
  $[0,2\pi]$ for a full circle.
Now you rotate the plane $xz$ around $z$ by $x\leftarrow
> x\cos(\phi),y\leftarrow x\sin(\phi)$,  with $\phi$ in the range
  $[0,2\pi]$ for a full turn,
$$x=(a\cos(\theta)+b)\cos(\phi),\\ y=(a\cos(\theta)+b)\sin(\phi),\\
z=a\sin(\theta).$$
If you freeze $\theta$, you get a circle in a plane parallel to $xy$,
  of the form:
$$x=r\cos(\phi),y=r\sin(\phi).$$

I was trying to use Preimage theorem to prove the problem, however, I couldn't get far so when I went back to the original post and read Ted Shifrin's comment:

to apply the regular value theorem, you need a smooth function, so you
  do need to delete the z-axis from $ℝ^3$ before applying the theorem

I was wondering what does Ted mean by deleting the z-axis? I can't seem to grasp how it works. Much appreciated for any help
Answer: Two comments: Once you have the parametrization, you could use it to prove that the torus is a $2$-dimensional manifold.
EDIT: The main idea is to check that the mapping $g\colon (0,2\pi)\times (0,2\pi)\to\Bbb R^3$ has rank $2$ everywhere. It follows that, restricting to its image (the torus), the inverse mapping gives a coordinate chart on most of the torus. You can use periodicity of the trig functions to take care of the missing points. If you know about quotient topology, you get an induced homeomorphism from $[0,2\pi]\times [0,2\pi]\big/\big((0,\phi)\sim (2\pi,\phi) \text{ and } (\theta,0)\sim (\theta,2\pi)\big)$ to the torus in $\Bbb R^3$.
With regard to my comment about the $z$-axis, my point was that the function
$$f\colon\Bbb R^3\to\Bbb R\,, \quad f(x,y,z) = \big(\sqrt{x^2+y^2}-b\big)^2 + z^2$$
is only smooth away from $x^2+y^2=0$, i.e., the $z$-axis. To apply the regular value theorem, you have to start with a smooth function and then check that your value — in this case, $a^2$ — is a regular value. So I suggested deleting the $z$-axis and considering $f$ with domain $\Bbb R^3-\{x=y=0\}$; now $f$ is smooth. :)
Comment: So with the original approach, I am still not sure what to do after the parameterization.
Comment: My aim is to find a function f such that for f:$ℝ^3$ →ℝ so that when we  said $S=f^−1(c)$  which is a two-dimensional manifold. (n=3, m=1; 3-1 = 2) but I'm struggling to define what f is. Can you please help me?
Comment: @Kagami: I've edited to elaborate a bit on the first. To apply the regular value theorem, the $f$ is the one that appeared in the original post and that I gave you again above!
Comment: Thank you, Ted. After I have a think about it, I have realized that there are different ways of parameterizing the equation. The equation you wrote, it was actually in Caratesian form and it is the parametrized of the torus right? So if I make my f(x,y,z) = $\quad f(x,y,z) = \big(\sqrt{x^2+y^2}-b\big)^2 + z^2 - a^2$ , then would f be now smooth in domain  $ℝ^3$ or am I completely off?
Comment: You didn't change anything but a constant. This function is *still* not differentiable when $x=y=0$. You could do a bunch of algebra and get rid of the square root. Something like $g(x,y,z)=(x^2+y^2+z^2+b^2-a^2)^2 - 4b^2(x^2+y^2)=0$. (No guarantees!) But why bother? There are no points on your torus lying on the bad set $x=y=0$, so it's no problem.

2 dimensional Smooth manifold of $ℝ^3$


alterations in tpl file work, but not dpm();, dsm(); or drupal_set_message();

Question: This question here at DA has a popular suggestion to check page.tpl.php to see if it says print $messages;. I verified this and this is the case.
I cleared caches many times, btw after which there actually is a drupal message saying the caches are cleared.
I made sure the dpm(), dsm() or drupal_set_message() functions are nicely outside any conditional statement or php logic whatsoever. I also put all these functions on different places in the tpl file. Still no result.
The same theme also has another tpl file that I used before and had some commented dpm(); functions that I uncommented but these didn't work anymore either.
Devel module is enabled and I am logged in as admin the whole time.
Comment: I *think* what you are experiencing is a timing issue for no better explanation.  If you look in `includes/bootstrap.inc` you will see that all the various message functions populate or look at a session variable with or for the contents of the message.  These are then plucked via process_page() in `includes/theme.inc` which populates the `$messages` variable.  So, if you are calling these functions INSIDE the page template, this variable has already been set, so these new messages are either lost or should/will eventually appear when a subsequent page is loaded...
Comment: @Jimajamma is what you are suggesting still that the cause of my problem has much if not everything to do with the fact that I am trying to use, `dpm();`, `dsm();`, and *even* `drupal_set_message();` from a `tpl` file? I mean, for all anyone should care for in this purpose, my end goal could be that I just want to output a hardcoded string with `drupal_set_message();`. If you catch my drift.
Comment: without seeing what exactly you are doing in your template, that's most probably correct.  but since, once again, Drupal puts all of the output of these in `$messages` before the template it processed, using them inside the template will either, once again, not work, or will be delayed until a subsequent page load.  So, if within a template, you want to have further messages displayed, you could add in logic that appends information to the `$messages` variable and then they would show up when it is printed, or you could do any other php coding, eg a direct print of a message yourself, etc.
Comment: Possible duplicate of [dpm() does not display any results on screen](https://drupal.stackexchange.com/questions/24217/dpm-does-not-display-any-results-on-screen)
Comment: It's left unclear in your question if you also went through all other answers in the mentioned question, so I'm marking yours as possible duplicate.
Answer: You have access to the entire Drupal bootstrap within template files. Template files are loading at the very end of a page request post bootstrap. If dpm() or dpr() is not working it is most likely because you are viewing the site as an anonymous user. The devel module by default does not allow access to it's functionality for anonymous users. Try logging in as admin and you should see the output of your devel module function calls.
As an F.Y.I. template files are not the typical place for a dpm() as you either need to know the variable you are after or put a get_defined_vars() calls inside it which can be quite heavy depending on where you are in stack. It is more common to use dpm()'s in template hooks such as:

template_preprocess_page()
template_preprocess_node()
function template_preprocess_page(&$vars) {
  dpm($vars);
}

Then you can see all the variables that are available to your template files.
Comment: I should have mentioned I was logged in as admin the whole time(I do now). That said, It shouldn't matter if templates are not a typical place for `dpm();` functions. It's besides the point. The problem is I can't even use `drupal_set_message();`. What I want to output in these functions is besides the point too.
Comment: If that is the case I would suggest checking your Drupal log. There is an off chance errors are being thrown but they are not being displayed because drupal_set_message() is not working.
Comment: Thanks to your comment I noticed that even my database logging module was disabled. Enabled it off course. Also error logging was also set to 'none', which could have been a good candidate for a solution. So I also set this to 'display all'. Still though, no drupal_set_message(); results after setting both of these things straight. At the same time, if you take into consideration that the message 'Every cache cleared' actually *does* get output every time I clear the caches, the idea that something is holding back the messaging alltogether becomes less interesting don't you think?
Answer: Not a fix for your issue but a work around could be to use Devel Debug Log instead. You can use ddl($var) and will save to a log in which you can see the output on the log page. Much better than trying to spit out dpm messages in $messages variable.


Is there a function that allows you to generate the highest multiple of a number below a certain boundary?

Question: Say for example, that I want the highest multiple of 36 below 100. Is there a function that allows me to generate this with two arbitrary numbers?
Comment: $36\left\lfloor \frac{100}{36}\right\rfloor$.
Answer: If $x$ the number whose multiple you're trying to find and $y$ is the upper bound what you're looking for is
$$x{\left\lfloor{ y\over x}\right\rfloor}$$
where $\lfloor\cdot\rfloor$ is the floor function.


AutoComplete Material UI onNewRequest wrong behavior

Question: I am working in a little app with react-redux and material-ui and I am having problems with the autocomplete field when I use onNewRequest property. It is fired like onClick to the component and not when I select one of the elements in the list.
The code:
const test = () => {
  alert("Something");
}

And the component works with a service response to show the data
case Status.OK:
  return <AutoComplete
    floatingLabelText="Origin"
    filter={(searchText, key) => (searchText.length >= 3 && key.indexOf(searchText) !== -1)}
    dataSource={ renderOrigins(response.data) }
    openOnFocus={false}
    maxSearchResults={3}
    onNewRequest={ test() }
    onClick={onClick(dispatch)}
    style={{marginRight: '30px'}}
  />

It's basically that, but when I select the autocomplete field the function test() is fired, and when I select a element on the list nothing happen.
Regards.
Answer: My bad, onNewRequest={ test() } should be onNewRequest={ test }


Nginx Reverse Proxy as folders

Question: I'm trying to configure Nginx to proxy stuff on a subdomain: dev.int.com
I want dev.int.com to be proxied to IP:8080, and dev.int.com/stash to be proxied to IP:7990
Here's my current config file
<code>server {
listen   80;
server_name  dev.int.com;
access_log off;
location / {
    proxy_pass http://IP:8080;
    proxy_set_header    Host            $host;
    proxy_set_header    X-Real-IP       $remote_addr;
    proxy_set_header    X-Forwarded-for $remote_addr;
    port_in_redirect off;
    proxy_redirect   http://IP:8080/jira  /;
    proxy_connect_timeout 300;
    location ~ ^/stash {
        proxy_pass http://IP:7990;
        proxy_set_header    Host            $host;
        proxy_set_header    X-Real-IP       $remote_addr;
        proxy_set_header    X-Forwarded-for $remote_addr;
        port_in_redirect off;
        proxy_redirect   http://IP:7990/  /stash;
        proxy_connect_timeout 300;
    }
}

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
    root   /usr/local/nginx/html;
    }
}
</code>
However, /stash redirects are going to /. What am I doing wrong?
Answer: Define location ~ ^/stash outside the brackets of location /
Comment: Tried to no avail.

Nginx Reverse Proxy as folders


How to flatMap a function on GroupedDataSet in Apache Flink

Question: I want to apply a function via flatMap to each group produced by DataSet.groupBy. Trying to call flatMap I get the compiler error:
error: value flatMap is not a member of org.apache.flink.api.scala.GroupedDataSet

My code:
var mapped = env.fromCollection(Array[(Int, Int)]())
var groups = mapped.groupBy("myGroupField")
groups.flatMap( myFunction: (Int, Array[Int]) => Array[(Int, Array[(Int, Int)])] )  // error: GroupedDataSet has no member flatMap

Indeed, in the documentation of flink-scala 0.9-SNAPSHOT no map or similar is listed. Is there a similar method to work with? How to achieve the desired distributed mapping over each group individually on a node?
Answer: You can use reduceGroup(GroupReduceFunction f) to process all elements a group. A GroupReduceFunction gives you an Iterable over all elements of a group and an Collector to emit an arbitrary number of elements.
Flink's groupBy() function does not group multiple elements into a single element, i.e., it does not convert a group of (Int, Int) elements (that all share the same _1 tuple field) into one (Int, Array[Int]). Instead, a DataSet[(Int, Int)] is logically grouped such that all elements that have the same key can be processed together. When you apply a GroupReduceFunction on a GroupedDataSet, the function will be called once for each group. In each call all elements of a group are handed together to the function. The function can then process all elements of the group and also convert a group of (Int, Int) elements into a single (Int, Array[Int]) element.
Comment: Isn't this same as `GroupCombineFunction`?


XSL style sheet for XML to XSL-FO

Question: I need to convert XML files into PDF, going to do it through XSL-FO.
The source XML file have their structure and dictionary (NITF) and should not be changed. I have to create the specific XSL styler for these files. Out of the whole XML elements there are only a few I need:
text

tables

images < media-reference  mime-type="application/gif" source="foo.gif" >
So far I've managed to convert the textual part of the XML files. And I can process the files containing just a simple table with fixed column number. When I try to process both text and tables in the source file, I get transformation errors.
The (bad working) styler my.xsl is attached as well as the source file. The errors are kind of
org.apache.fop.fo.ValidationException: "fo:table-body" is missing child elements. Required content model: marker* (table-row+|table-cell+)
XML:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE nitf SYSTEM "nitf.dtd">
<nitf>

    <title type="main">Sub-title 1</title>
    <meta name="filetype" content="content"/>
    <docdata><document-id id-string="123456" /></docdata>

        <hedline><hl1>Sub-title 1</hl1></hedline>

Some long text 1

Some long text 2

                    Table tilte 1

                    Col title 1
                    Col title 2
                    Col title 3

                    Row title 1
                    cell text 1
                    cell text 2
                    cell text 3

                    Row title 2
                    cell text 4
                    cell text 5
                    cell text 6

                    Some footnote

                    One more footnote

Just a short text

Some long text 3

Some long text 4

XSL:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format"
                              xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" indent="yes"/>

<xsl:template match="nitf">
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

        <fo:layout-master-set>
            <fo:simple-page-master page-height="297mm" page-width="210mm"
                margin="5mm 25mm 5mm 25mm" master-name="simpleA4">
            <fo:region-body margin="20mm 0mm 20mm 0mm"/>
            </fo:simple-page-master>
        </fo:layout-master-set>

        <fo:page-sequence master-reference="simpleA4">
            <fo:flow flow-name="xsl-region-body" >
                <fo:block>
                    <xsl:apply-templates select="head"/>

                </fo:block>
                <fo:block>
                    <fo:table table-layout="fixed" border-style="solid">
                            <xsl:apply-templates select="tr" mode="theader"/>
                            <xsl:apply-templates select="tr" mode="tbody"/>
                        <fo:table-body>
                            <xsl:apply-templates select="body/table/tbody/tr"/>
                        </fo:table-body>
                    </fo:table>
                </fo:block>
            </fo:flow>
        </fo:page-sequence>
    </fo:root>
</xsl:template>

  <xsl:template match="tr">
       <fo:table-row>
      <xsl:apply-templates select="td"/>
    </fo:table-row>
  </xsl:template>

  <xsl:template match="td">
    <fo:table-cell border-style="solid">
      <fo:block><xsl:value-of select="."/></fo:block>
    </fo:table-cell>
  </xsl:template>

<xsl:template match="head">
    <fo:inline font-weight="bold">
        <xsl:apply-templates/>
    </fo:inline>
</xsl:template>

<xsl:template match="body.head">
    <fo:inline font-weight="bold">
        <xsl:apply-templates/>
    </fo:inline>
</xsl:template>

<xsl:template match="body.content">
    <xsl:apply-templates/>
</xsl:template>

<xsl:template match="p">
    <fo:block>
        <xsl:apply-templates/>
    </fo:block>
</xsl:template>
<xsl:template match="b">
    <fo:inline font-weight="bold">
        <xsl:apply-templates/>
    </fo:inline>
</xsl:template>

</xsl:stylesheet >
Comment: Your XSL has many issues. There are no templates with modes of "theader" or "tbody" so these do nothing. Your match inside the table-body is "body/table/tbody/tr" which also does not exist in your XML (it would be missing "body.content" at least. It would also combine many tables into one. The real issue is why try to write what already exists. See answer below.
Answer: Google is your friend. I searched for NITF XSL FO and found this https://github.com/ydirson/serna-free/tree/master/serna/dist/plugins/nitf/nitf-xsl-serna
If you are working with industry standard XML, then XSLs likely exist for HTML and many for XSL FO.
I cloned and downloaded that project from Github. The XSLs are there and reference some others. You only need the "dist" directory and down, but there are many, many things even in that you do not need. In reality, if you examine the root "nitf.xsl", you would see:
<xsl:import href="../../../xml/stylesheets/xslbricks/fo/fonts.xsl"/>
<xsl:import href="../../../xml/stylesheets/xslbricks/fo/common.xsl"/>
<xsl:import href="../../../xml/stylesheets/xslbricks/fo/layoutsetup.xsl"/>
<xsl:import href="../../../xml/stylesheets/xslbricks/fo/default-elements.xsl"/>
<xsl:import href="../../../xml/stylesheets/xslbricks/fo/page-sizes.xsl"/>
<xsl:import href="../../../xml/stylesheets/xslbricks/fo/xhtml-tables.xsl"/>

<xsl:include href="nitf-param.xsl"/>
<xsl:include href="nitf-common.xsl"/>
<xsl:include href="nitf-struct.xsl"/>
<xsl:include href="nitf-meta.xsl"/>
<xsl:include href="nitf-blocks.xsl"/>
<xsl:include href="nitf-inlines.xsl"/>
<xsl:include href="nitf-lists.xsl"/>
<xsl:include href="nitf-images.xsl"/>
<xsl:include href="nitf-tables.xsl"/>

Those imported/included files would represent all the XSLs (unless some of those also reference others, I did not check).
Running your XML above (after adding the close </nitf> tag you omitted) and formatting the resulting FO to PDF using Apache FOP, it yields this:

Now, of course you could examine those XSLs for observations in what you are doing wrong in your XSL if you prefer, but as you can see there is a lot of work put into those XSLs already. I would always try and avoid "reinventing the wheel."
To reorganize all of that, you could just isolate the XSLs you need, edit the main "nitf.xsl" to reference all of them in one directory if you like. I did that and it still all works (so none of the XSLs I did not examine reference other ones), my directory now has only the below and I have deleted everything else:
Comment: That is exactly what I need! Thank you very much, Kevin! The problem was that I had some nitf.xsl and it failed to work with my files. I should invest some time into the search - but I decided to write my own style sheet. Totally wrong, as I see now.
Comment: Kevin, may I ask a little more? Have you changed something in my XML (except of missed last line) to get a successful transformation? I've cloned the serna, used its nitf.xsl and got a lot of errors like "No attribute-set exists named xhtml-tbody (all are about "xhtml")
Comment: Above was the result with oXygen. When I tried the Apache FOP it threw a TransformerConfigurationException:
ERROR:  '.../xhtml-tables.xsl: line 18: Error parsing XPath expression 'caption[not(self::processing-instruction('se:choice'))]'.'
FATAL ERROR:  '.../nitf-tables.xsl: line 28: Required attribute 'test' is missing.'
Comment: What cost transform are you using. I would use saxon 6
Comment: Maybe you are running the xslt for html and not the one for FO. Check it and see if it is for FO.
Comment: I used Saxon-PE 18.104.22.168 in oXygen. Now I tried Saxon 6.5.5 and successfully! But I need to use it in Java code (Apache FOP or, maybe Aspose), where I don't see what is the way to make it work.
The path to nitf:  serna-free/serna/dist/plugins/nitf/nitf-xsl-serna/nitf.xsl
Comment: You now need to piece all that apart and only identify what is truly referenced. It is at least the ones above and maybe somethings they reference. Then you could adjust paths and put them all in a directory. As for getting it to work (in Java code) with Aspose or Apache FOP, I cannot answer but ask a new question for that. I know (and work for) RenderX, I do not know all the integration details of the other products.
Comment: Just to note for you ... I copied the files referenced above that all begin with "../../../xml/stylesheets/xslbricks/fo/" into the same directory as "nitf.xsl". I then deleted everything else. See answer above for edit.
Comment: Yes, Sir! I extracted all the needed into the separate resources directory (left the bricks/fo sub-folder though) and I created my nitf.xsl file importing the serna nitf.xsl. Now I can override any feature of the serna in my nitf.xsl (for example, remove the printing of the Document metadata page - that is sure not needed in my task). All the rest issues I'm going to discuss in other questions, as  you and SO propose :)

XSL style sheet for XML to XSL-FO


Erro Slide Show Java Script

Question: Então o meu slideshow só está funcionando a primeira imagem, as outras imagens não aparecem pra mim.
JAVASCRIPT

{
  let satual = 1;
  let smax = 3;
  let stmp = 3000;

  function troca() {

    document.getElementById("e1").style.visibility = "hidden";
    document.getElementById("e2").style.visibility = "hidden";
    document.getElementById("e3").style.visibility = "hidden";

    document.getElementById("e" + satual).style.visibility = "visible";

    satual = satual + 1;

    if (satual > smax) {
      satual = 1;
    }
  }

  function slider() {

    document.getElementById("e1").style.visibility = "hidden";
    document.getElementById("e2").style.visibility = "hidden";
    document.getElementById("e3").style.visibility = "visible";

    sLiderTimer = setInterval(troca, stmp);
  }
}

<meta charset="utf-8">

 <title>Controla</title>
 <link rel="stylesheet" type="text/css" href="index.css">
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Fjalla+One" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">

Página Inicial

Login

Cadastrar

Sobre Nós

 © Controla Estoque 2018

 Um sistema de controle de estoque adequável para comercio de pequenas e microempresas, sendo padaria, pet shop, papelaria entre outros comércios existentes.

/*-------section---------*/
section
{
    background-color: #008153;
    padding: 6em 201px 30px;
    width: 78.1%;
    margin-left: -100px;
    padding-bottom: 100px;

}

/*-------slideshow--------*/
*
{
    margin: 0px;
    padding: 0px;
}

#slider
{
    width: 842px;
    height: 312px;
    margin: 0px auto;
    overflow: hidden;
    position: relative;
}

#slider
{
    margin-left: 150px;
}
Comment: O script parece funcionar normalmente. Teria que postar na pergunta o CSS pra poder ver.
Answer: Em vez de utilizar visibility hidden/visible, use display none/block. O visibility hidden apenas torna o elemento invisível, mas ele continua ocupando espaço na página. Esta é a causa das outras imagens não aparecerem, pois ficam fora da área visível, ocupada apenas pela primeira imagem.
Substitua seu script por este:
let satual = 1;
let smax = 3;
let stmp = 3000;

function troca() {

   document.getElementById("e1").style.display = "none";
   document.getElementById("e2").style.display = "none";
   document.getElementById("e3").style.display = "none";

   document.getElementById("e" + satual).style.display = "block";

   satual = satual + 1;

   if (satual > smax) {
      satual = 1;
   }
}

function slider() {

   document.getElementById("e1").style.display = "none";
   document.getElementById("e2").style.display = "none";
   document.getElementById("e3").style.display = "block";

   sLiderTimer = setInterval(troca, stmp);
}

Erro Slide Show Java Script


Java array shift referencing

Question: I tried shifting an array but I'm having issues.
The code to shift the array is as follows:
for(int i = (size - 1); i >= 0; i--)
{
    data2[i+1] = data2[i];
}

Array init (Copied from another array)
obj[] data = new obj[size];

obj[] data2 = new obj[size + 1];

for(int i = 1; i <= size; i++)
{
    data2[i] = data[i-1];
}

data2[0] = data[0];

For example, if size = 3, I only want to manipulate and use the data for data[1] -> data[3]. But, if the data for data[0] changes, the data for data[1] changes as well. What causes this?
ex:

Data 2[0]: 6----1----0----0
Data 2[1]: 6----1----0----0
Data 2[2]: 4----8----0----0
Data 2[3]: 9----5----0----0

data2[0].setElementTwo(3);

Data 2[0]: 6----3----0----0
Data 2[1]: 6----3----0----0
Data 2[2]: 4----8----0----0
Data 2[3]: 9----5----0----0

I'm copying the first array to the second because data[] is generated in another class which generates from 0->size, while I need 1->size+1 for this part of the program.
-edit for clarity-
full pseudo-code:
obj[] data = new obj[size];

obj[] data2 = new obj[size + 1];

for(int i = (size - 1); i >= 0; i--)
{
    data2[i+1] = data2[i];
}

for(int i = 1; i <= size; i++)
{
    data2[i] = data[i-1];
}

data2[0] = data[0];

// print data2 0->3

// change data2[0] value

// print data2 0->3, values would have changed for data[0] and data[1]
// but I only want to change values for data[0] and not data[1]

Comment: Unclear from the question what most of these variables have been initialised to and where in the code sequence are they manipulated. Also do specify clearly what you are trying to achieve.
Answer: First, let me clarify some concepts. obj is a reference type. Variables of reference types hold references to the actual objects. When you do aRefVariable = anotherRefVariable, you are not creating a new object. Instead, you are saying that aRefVariable should hold the same reference as anotherRefVariable. Basically, the two variables points to the same object after that line is executed.
The problem lies on this line:
data2[i+1] = data2[i];

You are saying that data2[i+1] should hold the same reference as data2[i].
To simplify the situation, let's suppose i is 0, so the line now becomes:
data2[1] = data2[0];

As I said, the second and first element of data2 points to the same object now. Accessing data2[0] is exactly the same as data2[1] in terms of the object you got.
Great, let's modify the object that the first item of data2:
data2[0].setElementTwo(3);

Now the object that data2[0] is referencing has been modified. When you try to access data2[1], you see the modification as well. Why? Because data2[0] and data2[1] refer to the same thing!
To fix this problem, you need to replace this line:
data2[i+1] = data2[i];

with something like this:
data2[i+1] = new obj(...);
// you should create a new obj that has the same values as data2[i] using its constructor

Answer: The new data2[] is referencing the old data[], so changes in the old will reflect in the new.
If you don't want that use
 data[index] = new obj(data[i-1]) ;

This will create a new object, which will be basically a copy of the old object and mutually exclusive from one another.

Java array shift referencing


How to tell Swig to treat 'u_char *' as 'unsigned char *'

Question: I'm wrapping a C library using Swig to be able to use it in PHP. The library uses u_char * instead of unsigned char *. Swig treats the u_char as a structure that it doesn't know about.
This results in the generated code doing a check to for the argument type, which obviously fails when I pass in a string as char * data.
How do I tell Swig to that u_char pointers are just unsigned char pointers?
i.e. this C function
int c_library_function(u_char *data, size_t data_size);

has this check inside of the generated code:
if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_unsigned_char, 0) < 0) {
  SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of c_library_function. Expected SWIGTYPE_p_unsigned_char");
}

Which is where it fails.
I've tried adding %typemap(ctype) u_char "unsigned char" to the Swig template, and it seems to have no effect.
Edit  To clarify one thing, the u_char is definitely a unsigned char. The C files in the library are including sys/types.h which includes bits/types.h which has the entry:
typedef unsigned char __u_char;

Also, just writing a function to wrap the call to C function, to be able to cast the type, works as expected:
void libraryFunction(u_char *foo) {
    //Does stuff with foo
}

void castLibraryFunction(char *foo) {
     libraryFunction((u_char *)foo);
}

But I don't want to have to write a wrapper for every function that expects a u_char* parameter.
Even more obviously, the type that Swig is checking for is SWIGTYPE_p_unsigned_char i.e. it's understood that the data type is 'unsigned char' but not using an 'unsigned char' pointer, but instead a pointer to a custom structure.
Answer: According to Is u_char a standard?, u_char is equivalent to uint8_t (C99), not unsigned char. Hence if you have an array of unsigned char that you receive from PHP, you will have to copy the chars into a new array of uint8_t (u_char), call your lib's C function, and if it mods the data (since it takes a u_char* not a const uchar*) you have to copy the result into the original array so PHP sees the change. If PHP uses immutable strings, you will have to return the string instead.
SWIG can help with some of the above tasks (like via %inline and %extend; I don't think you need type maps).
If u_char really is an unsigned char, and PHP is giving you a char*, then the principle is the same, but you don't need the copy parts, because the size type is the same as char*. You could use %inline:
%inline %{
    int c_library_function(char* phpString, size_t stringSize) {
          return c_library_function((u_char*) phpString, stringSize);
    }
%}

If you don't want to have to do this for every function that expects u_char*, I think your only option is a typemap entry in the .i file, such as
%array_class(unsigned char, char);

or
%apply char*  {unsigned char*};

but I have never used these.
Comment: I clarified, it's definitely unsigned char data. In one of the tests for the library, the function I'm trying to call is passed "char *" data read from a file, and it's silently cast to u_char.
Comment: `uint8_t` is probably just a typedef for `unsigned char`. Since a typedef merely creates an alias for an existing type, not a new type, `uint8_t`, `unsigned char`, and `u_char` are very probably *the same type*. (Plain `char` is a distinct type that may be either signed or unsigned.) Pointer conversions that treat the same data as either `char` or `unsigned char` are problematic in principle, but they generally work.
Comment: @KeithThompson and Danack The technique still applies, just don't need the copy portions. Edited.
Comment: Thanks - it appears "%apply char*  {unsigned char*};" is the one that tell Swig to do the right thing.


What is the parametrisation of the flat torus: $\mathbb{T}^2 = \mathbb{E}^2/\mathbb{Z}^2$?

Question: Is the parametrization of the flat torus $$\mathbb{T}^2 = \mathbb{E}^2/\mathbb{Z}^2$$ just the set of charts
$$(\pi,U_{ij})\quad \pi(x)=x\quad U_{ij}=(i,i+1)\times(j,j+1)\quad i,j\in\mathbb{Z}^2$$
EDIT: I mistook the quotient group notation for the set minus notation. My revised answer is then
$$(\pi,U)\quad \pi(x)=x\quad U=[0,1)\times [0,1)$$
I omitted top and right edges, I'm not sure if this is correct?!
EDIT:
$$(\pi,U)\quad \pi_1(x)=x\quad U_1=(0,1)\times (0,1)$$
$$(\pi,U)\quad \pi_2(x)=x+1/4\quad U_2=(-1/2,1/2)\times (-1/2,1/2)$$
Comment: What is $\Bbb E$? By $\setminus$ do you mean $/$? What do you mean by **the** parametrisation - why would there be just one?
Comment: @ArnaudMortier sorry I made a mistake, I mean $/$ and $E^2$ is just $R^2$ equipped with euclidean metric.
Comment: Right. Now none of your $U_{ij}$ contains integers, therefore your chart system is incomplete.
Comment: Those charts are all the same in the quotient, and they miss the edges of the the square.
Answer: No, those charts are not enough.
First, each of the charts $(\pi,U_{ij})$ covers exactly the same orbits, and so they cover exactly the same points in $\mathbb{T}^2$. The reason this is true is because for each $i,j,i',j' \in \mathbb{Z}$ the translation $(x,y) \mapsto (x+i'-i,y+j'-j)$ takes $U_{ij}$ to $U_{i'j'}$. So this list of charts is redundant. You can throw away all but one of them, keeping $U_{0,0}$ say. The chart $U_{0,0}$ covers exactly the same point of $\mathbb{T}^2$ as are covered by your whole collection of charts.
However, that chart does not cover the orbit of the point $(0,0)$ itself, nor does it cover the orbit of any of the points of the form $(m,y)$ where $m$ is an integer, nor of the form $(x,n)$ where $n$ is an integer. The only points whose orbits are covered by your charts are those points of the form $(x,y)$ where neither $x$ nor $y$ is an integer.
Added to address edits: The trouble with the new charts that you propose in your new edit is that a chart in an atlas for $\mathbb{T}^2$ must be a homeomorphism from an open subset of $\mathbb{R}^2$ to an open subset of $\mathbb{T}^2$. But $[0,1) \times [0,1)$ is not an open subset of $\mathbb{R}^2$.
Comment: thanks, I mistook the notation for set minus notation. I edited my post with the new parametrization, can you please check whether it is correct?
Comment: I added comments to address your edit.


Debugging what has been submitted in a form

Question: I would like to like to be able to print out what has been submitted in my form in the submission form. How can I achieve this?
Comment: Is this a form created yourself, or do you want to hook into a form defined in another module? Is this for debugging purposes, or do you actually want the site to show this data to the end user?
Comment: a form that I created for debugging process
Answer: You can display the submitted values in your hook_form_submit() and set it like this (example):
function form_example_tutorial_7_submit($form, &$form_state) {
  drupal_set_message(t('The form has been submitted. name="@first @last", year of birth=@year_of_birth', array(
   '@first' => $form_state['values']['first'],
   '@last' => $form_state['values']['last'],
   '@year_of_birth' => $form_state['values']['year_of_birth'],
  )));
}

Comment: You can also use dpm function from devel module. It prints using Krumo all kind of variables, complex arrays included. So you can just dpm the $form_state in the submit handler as Djouuuuh suggests.
Comment: OKaaayyy! I didn't know it was for debugging process. Of course use dpm with Devel module in the hook I suggested you. It's way easier.
Comment: I really recommend spending some time setting up XDebug and using that. Here are some links. If you use a good IDE, like PHPStorm, you get great integration with XDebug and no need to mess up your code with debugging statements. :) http://code.tutsplus.com/tutorials/xdebug-professional-php-debugging--net-34396  http://xdebug.org/docs/install https://www.youtube.com/watch?v=LUTolQw8K9A
Answer: Its better to install devel module and use the dpm function.
function MYMODULE_FORMID_submit($form, &$form_state) {
  dpm(hook_form_id_submit);
}

Answer: Instead of printing stuff in the page output, I would recommend to use an IDE such as PhpStorm, Eclipse or Netbeans. Combined with Xdebug, you can set a breakpoint in the form submit function and inspect all variables available at that point. You'll find the submitted values in $form_State['values'].


How to initiate MS SQL trusted connection for PHP

Question: I have been trying to initiate database trusted connection to MS SQL using PHP but failed. My PHP development machine is not part of the domain and the MS SQL server is in a domain. Unfortunately I cannot join my development machine to the domain. My DBA is reluctant to change the authentication mode of the SQL server.
Is there anyway for me to connect to the MS SQL server with trusted connection using PHP with just a domain logon credential?
Thank you
Answer: In Asp.net we can use  Integrated Security=True";or Trusted_Connection=Yes;in your connection string
or Trusted Connection=SSPI" in connection string
in php
go to the php.ini and verify the mssql.secure_connection parameter :
[MSSQL]

mssql.secure_connection = On

Comment: Thanks Arun but my script is a PHP script. How do I add that?
Comment: @cheetooh sorry i mentioned only asp.net case, chek my updated ans it will deals php windows authentication too
Comment: Thanks for your reply again! Sorry forgot to mention I am running PHP on IIS 7.5. I found the setting in php.ini file and I have changed it. Then, I changed the Anonymous Authentication to a valid domain user login credential. But I am getting the error >Login failed for user ''. The user is not associated with a trusted SQL Server connection
Comment: This problem occurs if the user tries to log in with credentials that cannot be validated.

because of more than one resons the same error may occur. anyway try the following.

open your sql server management studio
then open Object explorer
then ight click on Server Node and select Properties
then go to Security Tab and go to Server Authentical Area.
then Select SQL Server and Windows Authentication Mode.
and press ok
then try to connect


How to close an app if I have an animation activity that calls another activity

Question: I created an app and the first page of the app is an animation that introduces my app. After 8 sec this activity calls the main activty; and it's working just fine. But when I close my app at the animation activity the main activity still gets called and the app opens again so how to fix that although I have added
android:launchMode="singleTask"
on my activities!!!
My code:
new Handler().postDelayed(new Runnable() {
              @Override
              public void run() {

                //Create an intent that will start the main activity.
                Intent mainIntent = new Intent(AnimationActivity.this, MainActivity.class);
                AnimationActivity.this.startActivity(mainIntent);

                //Finish splash activity so user can't go back to it.
                AnimationActivity.this.finish();

                //Apply splash exit (fade out) and main entry (fade in) animation transitions.
                overridePendingTransition(R.anim.mainfadein, R.anim.splashfadeout);
                //overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left);
              }
            }, 8000);

Comment: for the ones who are downvoting; it's ok but can you tell me the cause is there anything wrong with my question maybe that way I can fix the problem It's my first app anyway...
Answer: Reference your runnable and handler as a field, then when your activity close, just invoke handler.removeCallback(runnable) in the onDestroy method
Comment: thanks a lot it worked but just one question is there anything wrong with my question because I wanna know the reason of the downvotes.. so that I fix my questions next time.. thanks.


Why is my typescript file not getting generated correctly into js using gulp typescript?

Question: I am trying to convert a typescript file into js, using gulp-typescript.
It doesn't seem to translate.
gulp file:
var ts = require('gulp-typescript');
gulp.task('tsToJs', function () {
    return gulp.src('./config.ts')
      .pipe(ts({
          moduleResolution: 'node',
          target:'es5',
          allowJs:true
          //out: 'config.js'
      }))
      .pipe(gulp.dest('./'));
});

config.ts:
class Config{
    env:{
        readonly live: '.co.uk',
        readonly dev: '.dev.co.uk',
        readonly qa:  'qa.co.uk'
    };
};
export = new Config;

Seems to get converted to this:
(It's missing the data inside the class?)
conf.js:
"use strict";
var Config = (function () {
    function Config() {
    }
    return Config;
}());
;
module.exports = new Config;

Comment: [Does the same thing in the TypeScript playground](http://www.typescriptlang.org/play/index.html#src=class%20Config%7B%0A%20%20%20%20env%3A%7B%0A%20%20%20%20%20%20%20%20readonly%20live%3A%20'.co.uk'%2C%0A%20%20%20%20%20%20%20%20readonly%20dev%3A%20'.dev.co.uk'%2C%0A%20%20%20%20%20%20%20%20readonly%20qa%3A%20%20'qa.co.uk'%0A%20%20%20%20%7D%3B%0A%7D%3B).
Comment: ok, so how can I get the data to appear in the output?
Answer: You're declaring your env property to be of an anonymous type, rather than initializing it with an object with properties. Change : to =:
class Config{
    env = {
//      ^-------------------------------------- here
        readonly live: '.co.uk',
        readonly dev: '.dev.co.uk',
        readonly qa:  'qa.co.uk'
    };
}

Note, though, that the playground says that you can't use readonly there. I can't find any example in the TypeScript handbook using readonly on simple object properties. (Though conceptually it would be reasonable.) You may need to be a bit more old-fashioned:
class Config{
    env = Object.create(Object.prototype, {
        live: {value: '.co.uk', enumerable: true, configurable: true},
        dev:  {value: '.dev.co.uk', enumerable: true, configurable: true},
        qa:   {value: 'qa.co.uk', enumerable: true, configurable: true}
    });
}

(Of course, if you don't want the properties to be enumerable or configurable, just leave those off. They won't be writable, because the default is false for all of those flags.)

Side note: Since that's a declaration, not an expression, there's no ; after it. ; is a statement terminator; declarations are self-terminating.
Comment: @JamesMonger: Thank you! My TypeScript-fu is weak. That explains why the block containing labelled statements with commas between them wasn't a problem. It's not a block, and it doesn't contain labelled statements with commas between them. :-)
Comment: ok but readonly cannot be used here? That's the error message I get in vscode
Comment: @SteveTomlin: I was wondering about that, I couldn't find any example of it being used in that way in the TypeScript handbook. Just noticed in the playground that it says the same thing. I've updated the above.
Answer: I really wanted to keep the readonly, because it helps vscode display the value of the variables where they are used. There doesn't seem to be any other way of displaying javascript variables without compiling. This feature is the reason I am wanting to use typescript for this situation.
This is the closest to achieving what I want, which does work:
const env = new (class Env{
    readonly live = '.co.uk';
    readonly dev = '.dev.co.uk';
    readonly qa = '.qa.co.uk';
})();

const brand = new (class Brand{
    readonly cm = 'mysite';
})();

export {brand, env};


How do I start learning digital orchestration?

Question: I'm a high school student who's played piano for about a decade, and was hoping to learn orchestration. I've written several advanced piano compositions, so I'm familiar with the music-writing process, but haven't been able to translate that to orchestration very easily. I'll obviously need to use a digital orchestra rather than a live one, and have experimented with Garritan Personal Orchestra 5 and FL Studio 20, but haven't been able to achieve an authentic sound, so I have a few questions.

Is GPO5 a good digital orchestra software, or would something else be better? I'm willing to spend up to a few hundred dollars to upgrade, but can't afford much more than that.
How do I learn digital orchestration, such as with Garritan? I've experimented with it in the past, but always get overwhelmed by all of the options and everything I try sounds extremely fake. Is there any course that would teach what to do, or should I just continue to figure it out on my own? I'm really lost on how to progress at all in this area.
What's the best way for me to learn orchestration, from a general standpoint, rather than just a VST? I'm sure there are books and online courses, but I've gotten pretty confused on what to do, especially considering that I'm using a digital orchestra rather than a real one.

Any help would be much appreciated! Thanks!
Comment: For Q3, Garritan used to have an on-line version of Rimsky-Korsakov's book on orchestration, with all the music examples played in GPO and downloadable as MIDI files. It used to be on the "Northern Sounds" forum - no idea if it's still available, or where it is on the web now, but it was a very good resource to get started.
Comment: Don't expect a digital orchestra (or even a digital concert band) to sound like a real one. Even properly depicting slurs audio-wise (at least with woodwinds, where slurs mean no tonguing) is difficult with a digital orchestra. That problem often cannot be overcome with merely a better soundfont.
Comment: That makes sense. To be honest, I didn't really expect for there to be an easy solution to the "fake-soundingness", but I know there has to be some solution. I've heard songs with Garritan where it's sounded perfect, and I'm sure it took a lot of work, but my problem is that I don't even know where to start. Do books or courses exist that teach how to properly use a digital orchestra? I'm willing to put in lots of work to learn digital orchestration, but I would really appreciate any advice on what I can do to start.
Comment: Garritan is plenty good enough to learn with. Don't buy anything more expensive till you have hit the limitations of GPO and can judge *for yourself* whether a more expensive library will do what you want. IN general, the more expensive the library, the *more* learning you need to do to use it well. There are no magic bullets here!
Answer: You learn digital orchestration the same way you do the other kind.  Study how it HAS been done.
Go here https://imslp.org/
Download some orchestral scores.  Mozart and Beethoven would be good places to start.   See how orchestration 'works'.
Also look around this site.
https://www.garritan.com/blog/new-garritan-forum/
If your aim is a recording that could be mistaken for a live orchestra, you can spend a LOT of money and still be disappointed.  If your aim is to learn orchestration, GPO will give you a very useful idea of what your work will sound like.   You can then work on the tricks of 'writing for samples' that make it sound even more effective - but sometimes at the price of writing impossibly over-notated scores that will just annoy live players who are quite capable of being expressive without meticilous instruction!


How to sum this complex series?

Question: How might I find $\sum\limits_{n=-\infty}^\infty {z^n\over n}-\sum\limits_{n=-\infty}^\infty {z^{2n}\over 2n}$ where $z=Re^{i\theta}$? Thanks.
Comment: It'll diverge... unless you intended $n$ to be the index instead of $m$.
Comment: Actually, this sort of sum shows up in the theory of vertex algebras all the time.  Usually it would be taken to be $\log | \frac{1+z}{1-z} |$, with the understanding that one is not actually performing the sum, one is simply setting the commutator(?) of two current operators to be this function, which makes the rest of the mathematics consistent.
Comment: Thanks, J.M. and mixedmath. You are quite right in spotting the typo. Thanks! Edited. Assuming that $|R|<1$, what would the series converge to? Thanks.
Comment: It can't converge for $|R|<1$ since your exponent goes from $-\infty$.  It might converge for $|R|=1$ when $z\neq 1,-1$, in which case the value will be $\log{|\frac{1+z}{1-z}|}$
Comment: @saxa: If $|R|<1$ the negative index terms will diverge.  So your only hope is $|R|=1$.  Even so, the $n=0$ terms are troubling.  Generally for a series like this, you can use $\sum\frac{z^n}{n}=\sum \frac{1}{z}\int z^n\;dz$ if it converges
Comment: @RossMillikan - I was assuming that the two $n=0$ terms cancelled, and that you could rewrite this as one series, $\sum_{n=-\infty}^{\infty} \frac{z^{2n+1}}{2n+1}$
Comment: @ThomasAndrews: You incorrectly summed the series, a small sign error.  See my answer.  We have that $$\sum_{n=-\infty}^\infty=\frac{1}{2}\log\left(\frac{1+z}{1-z}\right)-\frac{1}{2}\log\left(\frac{1+z^{-1}}{1-z^{-1}}\right).$$  What you wrote above is $$\frac{1}{2}\log\left(\frac{1+z}{1-z}\right)+\frac{1}{2}\log\left(\frac{1+z^{-1}}{1-z^{-1}}\right)=\log\sqrt{\frac{(1+z)(1+z^{-1})}{(1-z)(1-z^{-1}}}=\log\biggr|\frac{1+z}{1-z}\biggr|$$ since $z^{-1}=\overline{z}$.  I think the reason for this sign error is forgetting that the negative $n$ contribute a negative sign to part of the series.
Answer: First, a few things: The index of summation appears to be wrong, and I hope we are not summing when $n=0$.  I assume we are looking at $$f(z)=\sum_{n\in\mathbb{Z}\backslash \{0\}}\frac{z^n}{n}-\sum_{n\in\mathbb{Z}\backslash \{0\}}\frac{z^{2n}}{2n}.$$
We have to be very careful.  First, if $|z|\neq 1$, this will diverge by the divergence test.  Both $z=1$ and $z=-1$ are  singularities, and it is not clear what kind.  From now on, lets assume that $|z|=1$ and $z\neq \pm 1$.
The Answer: The result is tricky and we will have $f(z)=\frac{\pi i}{2}$ when $|z|=1,\ \text{Im}(z)>0$ and $f(z)=-\frac{\pi i}{2}$ when $|z|=1,\ \text{Im}(z)>0$.  This can be extended to the unit disk, but it is very discontinuous.  The reason for this is subtleties with branch cuts, and the problems that they cause.
Proof: All the series conditionally converge, and we can justify rewriting $f(z)$ as
$$f(z)=\sum_{n=1}^\infty \frac{z^n}{n}-\sum_{n=1}^\infty\frac{z^{-n}}{n}-\sum_{n=1}^\infty \frac{z^{2n}}{2n}+\sum_{n=1}^\infty \frac{z^{-2n}}{2n}.$$
Using the fact that $$\sum_{n=1}^\infty \frac{z^n}{n}=-\log(1-z)$$ we see that the above is $$-\log(1-z)+\log\left(1-z^{-1}\right)+\frac{1}{2}\log\left(1-z^{2}\right)-\frac{1}{2}\log\left(1-z^{-2}\right).$$
Caution with branches: Notice that $f(z)=-f(z^{-1})$, and since we are working on the unit circle and $z^{-1}=\overline{z}$ we see that the function will take opposite values on the top and bottom halves.
Combining some terms this is
$$\frac{1}{2}\log\left(\frac{\left(1-z^{-1}\right)^2\left(1-z^{2}\right)}{\left(1-z\right)^2\left(1-z^{-2}\right)}\right)=\frac{1}{2}\log\left(\frac{\left(1-z^{-1}\right)\left(1+z\right)}{\left(1-z\right)\left(1+z^{-1}\right)}\right)=\frac{1}{2}\log(-1).$$  Hence the answer is in some sense $\frac{1}{2}\log(-1)$, but not quite.  We have to be very careful with Branch Cuts.  When we combined the above terms, the argument secretely changed by a whole factor of $2\pi$ because we were not keeping track.  If we very carefully work things out, we arrive at:
$$f(z)=\frac{\pi i}{2}\ \text{for} \ |z|=1,\ \text{Im}(z)>0\ \text{and} \ f(z)=-\frac{\pi i}{2}\ \text{for} \ |z|=1,\ \text{Im}(z)<0.$$
Comment: If $z=1$ everything does not cancel, because $\frac{1}{n}$ is not the same as $\frac{1}{2n}$
Comment: @ThomasAndrews: Well depending on how you look at it, yes it does.  The series $\sum_{n=-M,\ n\neq =0}^{n=M}\frac{z^n}{n}$ literally equals zero for $z=1$....  It has a singularity, but sure it is not clear what value should be assigned there.
Comment: So, you are defining the difference of two diverging series to be $0$?  That seems odd.
Comment: Also notice that if $|z|=1$, then $z^{-1}=\bar{z}$.  So the only meaningful values for these series are real numbers when $|z|=1$, but your answer is imaginary.  You've made a mistake somewhere.
Comment: Also, if $z=-1$, the first series (of $z^n/n$) converges, but $z^{2n}/2n$ diverges.
Comment: @ThomasAndrews: I don't mean to be rude, but I never defined the value to be imaginary for $z=\pm 1$.  It quite clearly says if $\text{Im}(z)<0$ or $>0$, both of which are strict inequalities.  As I mentioned, there are singularities at those points.   Also, if you had looked at what I wrote, I mentioned that the left hand series diverged anyway for $z=-1$, I never said it canceled out there.
Comment: But the value at *all* $|z|=1$ has to be real, not just $z=\pm 1$.  In general, if $f(z)=\sum_{i=1}^\infty a_i z^i$ with all $a_i$ real, then $f(z)+f(z^{-1})$ must be real when $|z|=1$.  This difference is the difference of two such series, so the value on all $|z|=1$ must be real.
Comment: @ThomasAndrews: Ok, I understand your complaint.  Please read this:  Your series posted as a comment to the question is incorrect by a minor sign error.  The series is $\tanh^{-1}(z)-\tanh^{-1}\left(\frac{1}{z}\right)$, NOT $\tanh^{-1}(z)+\tanh^{-1}\left(\frac{1}{z}\right)$.  The thing is here, because it is of the form $f(z)-f(z^{-1})$ it must be imaginary.  I think the problem is that when you computed the series, the negative sign coming from the negative $n$ was missed.
Comment: So, are you saying that if $f$ has a power series with only real coefficients, then $f(z)+f(z^{-1})$ can be non-real for some value $|z|=1$?  Because that is your result, and it is not possible.
Comment: @ThomasAndrews:  Please read my comments!  It is of the form $f(z)-f(z^{-1})$ NOT $f(z)+f(z^{-1})$, it is very different!!  The series is $$\sum_{n=-\infty}^\infty \frac{z^{2n+1}}{2n+1}$$ agreed?  Rearranging this is $$\sum_{n=0}^\infty \frac{z^{2n+1}}{2n+1}+\sum_{n=-\infty}^{-1} \frac{z^{2n+1}}{2n+1}=\sum_{n=0}^\infty \frac{z^{2n+1}}{2n+1}-\sum_{n=0}^\infty \frac{z^{2n+1}}{2n+1}$$ because a negative sign comes out of the denominator $2n+1$ when we rearrange.  Please, do you see why it is minus and not plus?  That is basically all we disagree on, you summed the series incorrectly to start!
Comment: Okay, you are right.  I missed that it was difference.  Got blinded by the fact that Craig came up with the same answer that I did in comments above.
Comment: `this will diverge by the divergence test`. Did you perhaps mean the [Term Test](http://en.wikipedia.org/wiki/Term_test)?
Comment: @robjohn: Ya, same thing.  I just remember my prof in first year always called it the divergence test, so that name stuck with me.
Answer: To get rid of the problem with the index $n=0$, we can rewrite the series, as you may have intended,
$$
\sum_{k=-\infty}^\infty\frac{z^{2k+1}}{2k+1}\tag{1}
$$
If $|z|\not=1$, the double-ended series diverges, so I will assume that $R=1$. Using the series
$$
\sum_{k=0}^\infty\frac{z^{2k+1}}{2k+1}=\frac{1}{2}\log\left(\frac{1+z}{1-z}\right)\tag{2}
$$
the series $(1)$ becomes
$$
\begin{align}
\sum_{k=-\infty}^\infty\frac{e^{i(2k+1)\theta}}{2k+1}
&=\sum_{k=0}^\infty\frac{e^{i(2k+1)\theta}-e^{-i(2k+1)\theta}}{2k+1}\\
&=\frac{1}{2}\log\left(\frac{1+e^{i\theta}}{1-e^{i\theta}}\right)-\frac{1}{2}\log\left(\frac{1+e^{-i\theta}}{1-e^{-i\theta}}\right)\\
&=\frac{1}{2}\log\left(\frac{e^{-i\theta/2}+e^{i\theta/2}}{e^{-i\theta/2}-e^{i\theta/2}}\right)-\frac{1}{2}\log\left(\frac{e^{i\theta/2}+e^{-i\theta/2}}{e^{i\theta/2}-e^{-i\theta/2}}\right)\\
&=\frac{1}{2}\log(i\cot(\theta/2))-\frac{1}{2}\log(-i\cot(\theta/2))\\
&=\left\{\begin{array}{}+\frac{\pi}{2}i&\text{ when }0<\theta<\pi\\-\frac{\pi}{2}i&\text{ when }-\pi<\theta<0\end{array}\right.\tag{3}
\end{align}
$$
This agrees with Eric Naslund's answer.

How to sum this complex series?