Legendas não aparecem em HTML5 video tag

Question: Olá, estou a criar um sistema de filmes e queria colocar as legendas nos filmes ingleses mas por algum motivo elas não aparecem e quando as vou activar e clico no botão ele desaparece e as legendas não aparecem. Eu tenho um arquivo .vtt com as mesmas:
1
00:00:26,460 --> 00:00:30,434
Boa noite, senhoras e senhores.
Estamos prestes a aterrar em Seattle.

2
00:00:30,464 --> 00:00:33,270
Está bom tempo, com vento de leste.

3
00:00:33,300 --> 00:00:36,440
A temperatura no solo é de 20 graus

4
00:00:36,470 --> 00:00:39,347
Em nome da tripulação,
na cabina e no cockpit,

Codigo html:
<video width="1020" height="640" controls>
      <source src="Rings.mp4" type="video/mp4">
      <track label="Português" kind="subtitles" srclang="pt" src="Rings.vtt">
    Your browser does not support the video tag.
    </video>

Alguém sabe qual é o problema?
Comment: Qual navegador vc esta usando ?
Comment: Google Chrome Actualizado
Comment: Eu imagino que elas não são mostradas inicialmente (nem mesmo setando como `default`), o usuário tem de ativa-las. Veja [esse link](https://developer.mozilla.org/en-US/docs/Web/Apps/Fundamentals/Audio_and_video_delivery/Adding_captions_and_subtitles_to_HTML5_video#HTML_Markup) da documentação.
Comment: Mesmo Activando elas não aparecem, não sei porque
Comment: Veja no segundo bloco [dessa parte](https://developer.mozilla.org/en-US/docs/Web/Apps/Fundamentals/Audio_and_video_delivery/Adding_captions_and_subtitles_to_HTML5_video#Building_a_caption_menu), a partir da linha 16. A implementação mostra que vc pode definir o atributo `mode` como `showing` e `data-state` como `active`. Fora isso, se não houver nenhuma msg no console, não sei o que pode acontecer.
Comment: @IMM Acredito que você já tenha conseguido resolver o problema, se não, dê uma olhada na minha resposta.
Answer: Existem alguns pontos a serem corrigidos no seu arquivode legendas... O separador decimal para os millesegundos deve ser o . e não a ,. É recomendado que você inicie a primeira linha do seu .vtt com a assinatura WEBVTT. Seus arquivos podem ser validados nesse site.
WEBVTT

1
00:00:26.460 --> 00:00:30.434
Boa noite, senhoras e senhores.
Estamos prestes a aterrar em Seattle.

2
00:00:30.464 --> 00:00:33.270
Está bom tempo, com vento de leste.

3
00:00:33.300 --> 00:00:36.440
A temperatura no solo é de 20 graus.

4
00:00:36.470 --> 00:00:39.347
Em nome da tripulação,
na cabina e no cockpit,

Outros pontos importantes:

Tanto o vídeo quando os subtitles precisam ser disponibilizados através de um serviço http, não funciona localmente simplesmente abrindo o .html no browser.
Caso os arquivos não estejam disponíveis no mesmo domínio do seu site, é necessário adicionar o atributo crossorigin no seu elemento <video>.
Se você declarar a propriedade default em sua <track> o player já irá exibir aquela legenda por padrão na reprodução do conteúdo.

Veja uma demo funcionando logo abaixo, coloquei duas legendas iguais em tracks diferentes porque ainda não encontrei um exemplo melhor.

<video width="50%" src="//thepaciellogroup.github.io/AT-browser-tests/video/ElephantsDream.mp4" controls crossorigin="anonymous">
  <track kind="subtitles" src="//thepaciellogroup.github.io/AT-browser-tests/video/subtitles-en.vtt" srclang="en" label="Inglês" default>
  <track kind="subtitles" src="//thepaciellogroup.github.io/AT-browser-tests/video/subtitles-en.vtt" srclang="pt" label="Português">
</video>
Comment: @AugustoVasques Sim, eu sei, era apenas para demonstrar que ambas declarações funcionam com o carregamento do arquivo. Afinal, o player não sabe o que está exibindo, apenas relaciona as marcações com o andamento da execução do vídeo....
Comment: Leandro Angelo, as duas legendas estão em inglês, elas estão apontando para o mesmo endereço.


How do I add shapes from an Array to Stage Actionscript 3

Question: I am trying to create an array of squares and then add them to the stage in a 6x12 grid and later on be able to change their colours. I have managed to create an array of arrays and store the squares, but I am at a loss for how to now add them to the stage in a grid. I'm a new programmer so I apologize in advance if I have not formatted my code correctly. THank you for your time.
public class Main extends Sprite
    {
    public function Main():void
    {
        stage.scaleMode = StageScaleMode.NO_SCALE;
        stage.align = StageAlign.TOP_LEFT;
        stage.addEventListener(Event.DEACTIVATE, deactivate);

        // touch or gesture?
        Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

        //array of arrays
        var pixelArray:Array = [row1, row2, row3, row4, row5, row6, row7, row8, row9, row10, row11, row12]

        // Row arrays
        var row1:Array = [];
        var row2:Array = [];
        var row3:Array = [];
        var row4:Array = [];
        var row5:Array = [];
        var row6:Array = [];
        var row7:Array = [];
        var row8:Array = [];
        var row9:Array = [];
        var row10:Array = [];
        var row11:Array = [];
        var row12:Array = [];

        for (var i:int = 0; i < 6; i++)
        {

            // "Pixel"
            var pixel:Shape = new Shape; // initializing the variable
            pixel.graphics.lineStyle(1, 0x000000, 1);
            pixel.graphics.beginFill(0xFF0000); // fill colour
            pixel.graphics.drawRect(0, 0, 30, 30); // (x spacing, y spacing, width, height)
            pixel.graphics.endFill(); // end of fill
            //addChild(pixel); // adds to stage, all shapes will be in same place?

            row1.push(pixel);
            row2.push(pixel);
            row3.push(pixel);
            row4.push(pixel);
            row5.push(pixel);
            row6.push(pixel);
            row7.push(pixel);
            row8.push(pixel);
            row9.push(pixel);
            row10.push(pixel);
            row11.push(pixel);
            row12.push(pixel);

        }
        addChild(pixelArray [1][1]); //tried to add just one square to stage, I think syntax is wrong here

    }

    private function deactivate(e:Event):void
    {
        // make sure the app behaves well (or exits) when in background
        //NativeApplication.nativeApplication.exit();
    }

}

}
Answer: You're placing one and the same pixel into each of the rows. To make more pixels, you need to create a pixel per row per column. To avoid copypaste, you can make a function that will return a ready-made Shape object, and you will call that in all of your rowX.push() statements. Like this:
function makePixel(fillColor:int=0xff0000):Shape {
    var pixel:Shape=new Shape();
    pixel.graphics.lineStyle(1, 0x000000, 1);
    pixel.graphics.beginFill(fillColor); // fill colour
    pixel.graphics.drawRect(0, 0, 30, 30); // (x spacing, y spacing, width, height)
    pixel.graphics.endFill(); // end of fill
    return pixel;
}
row1.push(makePixel());
row2.push(makePixel());
// etc


Vector space of commuting matrices

Question: Let $A\in M_n(R)$, where $M_n(R)$ is a set of all regular matrices with a  rank $n$ and $A$ is a matrix from that set. Proof that the set of all matrices $X\in M_n(R)$, which commutates with $A$, is a vector space.
Well, the only matrix that commutates with $A$ is an identical matrix possibly multiplied with some scalar. How to prove it properly? Should I go from a definition, because it is pretty long, it has 7 or 8 parts. Thanks for helping me.
Comment: What makes you think the only matrices that commute with $A$ are those that are scalar multiples of the identity matrix?
Comment: You don't need to know what are the matrices commuting to $A$. What you have to do is to check the axioms of a linear subspace.
Comment: right, all the matrices that are inverse to A also?
Comment: Because the subspace is also a vector space, so as was written below (the answer by Chirantan Chowdhury): $(A+B)X = ... = X(B+A)$, it means $(A+B)$ is in that set and for $r$ from the real numbers (it is just a scalar) we have that $(rA)X = X(rA)$, so $(rA)$ in also in that set?
Answer: Well not only the identity ,all the diagonal matrices with  a fixed scalar $ \lambda$ on the  diagonal shall commute with it.You don't need to exactly what are the matrices ,just see that if A,B are in the set , then$ (A + B) X = AX + BX = XB + XA = X(B+A) $ ,so $A +B$ is also in the  set.Others also follow in the same manner.This is called the centralizer of $A$ .
Comment: Thank you very much for that help!

Vector space of commuting matrices


delete folder /usr/lib/systemd/system which consequence now

Question: last time i delete the folder system in /usr/lib/systemd/system.I don't know how, but how  important is the folder system for the ubuntu server 18.04 ?
What consequences should I expect?
kind regards,
blackbeard
Answer: Do this possibly destructive thing on a test system and see what happens. Either a host created for this purpose, or something with a known recovery plan.
A reason for uncertainty here would be that Fedora and EL try very hard to move all the things to /usr. On CentOS 7, /usr/lib/systemd/system definitely contains system units, and removing all of them would cause the system to not function.
Per Ubuntu's man page, they have not done it quite the same and have /lib/systemd/system.  Why exactly /usr/lib/systemd/system exists on Ubuntu I don't know. Look at whether its contents are a symlink to the actual location, or perhaps a couple misplaced units that are not packaged to Ubuntu's conventions.
On a system with package management, ideally /usr and /lib are only managed by installing and removing packages, with no need to directly deal with files. systemd's search paths support this very well, for example /etc/systemd/system/ is a good place for local custom units and overrides.
Answer: The folder /lib/systemd/system contains all configuration files for systemd. If you deleted the content of this directory, your system might never boot again.
The folder /usr/lib/systemd/system might be a symbolic link for /lib/systemd/system. If it wasn't everything should be alright, since it is not on systemd's search path. The question is why was there a /usr/lib/systemd/system in the first place.
Comment: i dont know, maybe default installation from my ubuntu headless server 18.04 .
You mean the folder /usr/lib/systemd/system is unimportant. I understand from wiki the systemd for user unit  should be us for session service like delete all temporary file after log out  from server.
Im using only lib/systemd/system and etc/systemd/system.
Comment: `/usr/lib/systemd/system` is not on the search path, but `/usr/lib/systemd/user`, where user units are stored, is!
Comment: What you mean? Is the folder now important?
Comment: `/usr/lib/systemd/user` contains user units and is important, `/usr/lib/systemd/system` does not exist or serve a purpose on a Debianoid.
Answer: I found my Problem, i created my own system file in usr/lib/systemd/System. Thanks everbody.


TShellListView create new folder & rename it

Question: Im working on a project in Delphi , I have TShellListView component (List) ,and Button to create New folder :
MkDir(List.RootFolder.PathName+'\New Folder');
List.Update;

But what I need is when the user create the new folder, then then the folder automatically show in edit mode, so he can change the folder name, as when you create New Folder in Windows.
How can I do that?
Answer: Try something like this:
var
  Path, PathName: string;
  Folder: TShellFolder;
  I: Integer;
begin
  Path := IncludeTrailingPathDelimiter(List.RootFolder.PathName) + 'New Folder';
  if not CreateDir(Path) then Exit;
  List.Refresh;
  for I := 0 to List.Items.Count-1 do
  begin
    Folder := List.Folders[I];
    if (Folder <> nil) and (Folder.PathName = Path) then
    begin
      List.Items[I].EditCaption;
      Exit;
    end;
  end;
end;

Alternatively:
var
  Path: string;
  Item: TListItem;
begin
  Path := IncludeTrailingPathDelimiter(List.RootFolder.PathName) + 'New Folder';
  if not CreateDir(Path) then Exit;
  List.Refresh;
  Item := List.FindCaption(0, 'New Folder', False, True, False);
  if Item <> nil then
    Item.EditCaption;
end;

Comment: I got an Error Type `String` and `Integer` on line , `Item := List.FindCaption('New Folder');` You miss the integer param for `FindCaption`
Comment: Should be like : `FindCaption(Integer,'New Folder',boolean , boolean, boolean);` , you pass just the string param.
Comment: I have fixed it
Comment: Thank you , but 1st you miss again , remove `:` and add `;`  in line `Item := List.FindCaption(0, 'New Folder', False, True, False):` , 2nd True this w'll create the folder but w'll not edit it. I mean `Item.EditCaption;` not working.
Comment: The True in the 4th parameter (`Inclusive`) tells `FindCaption()` to include the list item at the specified `StartIndex` (0) in the search.
Comment: I have tested both solutions now and they both work.  The problem is that `List.Update()` does not repopulate the ListView, so `'New Folder'` is not added to the list so it can then be found.  You have to use `List.Refresh()` instead. I have updated my answer.
Comment: Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/133165/discussion-between-sami-and-remy-lebeau).
Answer: I found a solution:
MkDir(List.RootFolder.PathName+'\New Folder');
List.Update;
List.ItemIndex:=0;
List.HideSelection:=True;
while List.ItemIndex<List.Items.Count-1 do
begin
  // Find the New Folder
  if List.SelectedFolder.PathName=(List.RootFolder.PathName+ '\New Folder') then
  begin
    //Set the Folder in Edit mode & exit the loop
    List.Items[List.ItemIndex].EditCaption;
    Exit;
  end
  else
    //Inc the Index
    List.ItemIndex := List.ItemIndex+1;
end;
List.HideSelection:=False;

Comment: Why are you using `List.ItemIndex` and `List.SelectedFolder`? You should be able to loop through `List.Items[]` without changing the current selection.


Snapshot/rollback for libvirt+KVM?

Question: I've recently begun using KVM for my development/test environment on a Linux host system with 8G memory. Prior, I was using VMware Fusion for my virtual environment, but my Macbook only has 2G memory. I tried VMware Server and ESX on the host instead of KVM, but the webUI doesn't run on Mac OSX's Firefox, and we're going to be doing more with KVM anyway.
The main feature of VMware I miss is robust snapshot/rollback, but I'm missing this in KVM. I understand the snapshot command, but it shuts down the guest OS when complete, and then copying the disk image to preserve its state is cumbersome.
Is this really the best way to manage snapshots on KVM?
Comment: Your wish is my command, Server Horror!
Comment: Could someone please tag this "linux-kvm"?
Comment: Heh, thanks no "sudo go make me sandwich"
Answer: KVM has a much better snapshot capability than what's managed by libvirt; but it depends on qcow2 images.  if you use them, just do a savevm <name> on the command console (blocked by libvirt) it won't create a new file, it's a snapshot inside the qcow2 file.
test it first, because some KVM versions have it broken.
Comment: libvirt now has snapshot-create, snapshot-list, and snapshot-revert commands
Comment: qemu-img is the answer, if savevm is restricted. Still requires qcow2 or other COW image
Comment: Yeah, no dice.

$ sudo kvm app3.img -monitor stdio -k en-us
(qemu) savevm
Device ide0-hd0 does not support VM state snapshots
Comment: Will have to convert my images to qcow, or rebuild them entirely, but thanks for this.
Answer: You can combine KVM hosts with LVM technology.
If you install all your machines on a separated LV, using an Logical Volume for each machine, you can create hot backups / snapshots using LVM features.
Is like the solaris ZFS snapshot, try it ;)
Comment: That would only give you filesystem snapshots and not the state of the running system.
Comment: Wesley, that's not quite the same thing. VMWare snapshotting stores the machine's memory and CPU state so when you rollback it's like the entire VM has just jumped back in time to the point where you took the snapshot. With your method, when you boot from an LVM snapshot, you're doing the equivalent of bringing the virtual machine back from a crash. Hope you didn't have anything important in memory that hadn't been committed to the disk - and that you didn't have any filesystems that are susceptible to severe damage if that happens (eg. XFS).
Answer: Seems the only way to do it "properly" is to patch QEMU when you say no for qcowN formats.

Snapshot/rollback for libvirt+KVM?


Selecionar datas baseado na soma total de determinada coluna

Question: Boa noite. Baseado no cadastro de exemplo em anexo, eu teria que selecionar todas as datas que são iguais e estão no mesmo restaurante e que a soma da quantidade seja > 10, pois preciso desabilitar essas datas do meu datepicker.
Answer: Fala Marlon,
Acredito que precisa de algo assim:
<code>SELECT
    t.restaurante,
    SUM(t.quantidade) AS quantidade,
    t.dataReserva
FROM
    teste t
WHERE
    t.dataReserva >= NOW()
GROUP BY t.dataReserva, t.restaurante;
</code>
Laravel
<code>$reservas = teste::select("restaurante", DB::raw("SUM(t.quantidade) AS quantidade"), "dataReserva")
->where("dataReserva", ">=", date("Y-m-d"))
->groupBy("dataReserva", "restaurante");
</code>
Comment: Valeu demais Thiago. Funcionou perfeitamente!


Print Large SVG in multiple pages (A4)

Question: Good morning,
cere's my problem: I'm using Twoproject Gantt in my company website (link to gantt). I want it to be printable.
Problem: the gantt is a very long  and it gets printed only partially in a single A4 page. I would like it to be printable entirely, and even better if it extends in multiple A4 pages.
Is this possible?
Answer: I have found a solution: I used the technique written here to split the table across multiple pages link. Then foreach piece of table I cloned the svg and changed the visibile part accordingly using viewBox attribute
Comment: Mind sharing your solution? I need to split a SVG image up to print on multiple pages.
Answer: For HTML file containing SVG elements, I use Opera browser and Adobe Acrobat Reader application as explained on Superuser site.
https://superuser.com/questions/161313/print-a-huge-svg

Print Large SVG in multiple pages (A4)


append angular component on click

Question: I want to add a component inside the div with class myBLock on click of a button
code:

    <button (click)="addComponent()">
    </button>

Comment: Can you say a little more? you want to add a component inside the div with class `myBLock` on click of a button?
Comment: Exactly what I want
Answer: If you want to add html:
html

in component:
@ViewChild('block') block:ElementRef;

addComponent() {
  block.nativeElement.insertAdjacentHTML('beforeend', '

');
}

If you want to add a component you need to do it dynamically:
https://angular.io/guide/dynamic-component-loader
Comment: That's not gonna work buddy (That's not how you insert angular components dynamically)
Comment: @Dummy You're correct my bad.  I'm not 100% sure what he is asking so I changed it.
Answer: You could set a component variable to true / false based on button click. Then based on the variable value, show/hide component.

  <button (click)='showMyBlock = !showMyBlock'>
  </button>

<another-component *ngIf='showMyBlock'>
</another-component>

Comment: this is not what i need.  because i want to append different component on click, depend on the client

append angular component on click


Where to draw circumscribed circle tangent to 2 circles

Question: I'd like to figure out how and where to draw a circle which is tangent to two circles inside it. It looks kind of like this:

Basically in the diagram I'd like to make there are two circles (beige in the image) with known radii and a set distance between their centers. I'd like to draw a circle around them (blue in the image) which is tangent to both and whose center is on the line drawn between the centers of the smaller circles. What I need to know is, given those three parameters above, where the larger circle must be drawn on the axis between the centers of the other two circles, and what the radius of the larger circle is. I suppose the position might be a function of the radius but that's too big for my brain.
This is a link to the wolfram file I pulled that image from, if it helps at all.
Anyways, all help is appreciated!
Comment: The picture looks very different from your description. How is it supposed to help people understand what you are asking?
Comment: Perhaps you could use a tool like [GeoGebra](https://geogebra.org) to create a diagram that better illustrates your problem. (Playing a bit with GeoGebra may well help you discover the answer on your own.)
Comment: In your picture the center of the large circle lies  on a common tangent $AB$ rather than on the line connecting the centers of the smaller circles.
Answer:
The answer to your question can be found by using either an analytical method or a geometrical construction. An analytical solution has been already posted by @GeometryLover. We give below a simple construction, which will help you to determine both the radius and the center of the sought circle.
The Circle-1 and the Circle-2 are given as shown in $\mathrm{Fig.\space 1}$. Their respective radii and centers are known. We start our construction by drawing the line $PQ$, which passes through the two centers $O_1$ and $O_2$. As shown in the figure, we denote the two of the four points of intersection between the two circles and the line $PQ$ as $A$ and $B$. Finally, we find and label the midpoint of $AB$ as $O$.
$O$ is the center of the sought circle. Its radius is equal to $OA$ or $OB$.
I found this construction while playing with Geogebra as @Blue has instructed in his comment. It is always worthwhile to heed advises from experts.


Why well-defined function sometimes means a group homomorphism function?

Question: If we have the map $\phi_s$ that takes $\overline{1}\in\mathbb{Z}/p^a$ to $\overline{p^{s+b}/d}\in\mathbb{Z}/p^b$, where $d=\gcd(p^a,p^b)$. Why in order to see that $\phi_s$ is a well-defined map, we need to show that $\overline{p^a}\phi_s(\overline{1})=\overline{0}\in\mathbb{Z}/p^b$?
EDIT:
Is the meaning of well defined if we have $\mathbb Z_{n}'s$ as domain and target is just to send the identity to the identity?If so, for me, that definition of well defined is very different from the one ordinary used (if $x=y$ then $f(x) = f(y)$)
Is there any connection between both definitions?
Comment: I do not know why down voting the question here.
Answer: It seems that the question implicitly requires the map to be an abelian group homomorphism, i.e. $\phi_s(x+y)=\phi_s(x)+\phi_s(y)$ for all $x,y$ in the domain. In particular, if we write $n\cdot x$ for $x+\ldots+x(n$ times$)$ (which is essentially viewing abelian groups as $\def\Z{\mathbb Z}\Z$-modules), then $\phi_s(n\cdot x)=n\cdot\phi_s(x)$. In this case it is the same as $\bar n\phi_s(x)$.
For the map to be well-defined, the problem is $\phi_s(\bar0)$. In $\Z/p^a\Z$, $\bar0=\bar{p^a}=p^a\cdot\bar1$. Hence $\bar0=\phi_s(\bar0)=\phi_s(p^a\cdot\bar1)=p^a\cdot\phi_s(\bar 1)=\bar p^a\phi_s(\bar 1)$, which is what you want to check.
Comment: @Math I don't quite understand your confusion. $\bar 0=\bar p^a$ is an equation in $\def\Z{\mathbb Z}\Z/p^a\Z,$, and we want $f(\bar 0)=f(\bar p^a)$ to hold in $\Z/p^b\Z$.
Comment: So well defined in that case means an abelian group homomorphism? but how is well defined in that case related to our ordinary well-defined definition?
Comment: Since $\bar 1$ generates $\mathbb Z/p^a$, any abelian group homomorphism is determined by where it sends $\bar 1$. In other words, if you mandate where $\bar 1$ goes to, then that single requirement "induces" a unique homomorphism, i.e. $\bar n\mapsto n\cdot\bar 1$. This ensures uniqueness if it exists, but existence is ultimately guaranteed by well-defined-ness here: such a homomorphism might not exist if you chose a bad value.
Comment: @Math You can think of this as the rule of "inducing" a homomorphism makes the function potentially multi-valued (ill-defined). By definition $f(\bar 0)$ should be $\bar 0$, but a second possible value of $f(0)$ comes from "induction": $f(\bar 0)=f(\bar p^a)=p^a\cdot f(\bar 1)$. So you could say something like "$\bar 0=\bar p^a$, so $f(\bar 0)=f(\bar p^a)$.
Comment: but our function from $Z_p^a \rightarrow Z_p^b$
Comment: Oh I see. but we usually equate 2 arbitrary elements in the domain and then try to reach that their images are equal .... but you are telling me equate specifically 2 representatives of the **element 0** and try to reach to the equality of their images
Comment: @Math One can actually show this is equivalent. In the most general form, we want $\forall m,n\in\def\Z{\mathbb Z}\Z, m\equiv n\pmod{p^a}$ implies $f(\bar m)=f(\bar n)$. Subtract $n$ from the first equation and then you reduce to the case of $n=0$. But then $m$ must be a multiple of $p^a$, and it will automatically hold if you only prove $m=p^a$ (by induction or otherwise).
Comment: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/117226/discussion-between-tesla-daybreak-and-math).


Como exibir uma sequência de imagens a partir de um único link?

Question: Normalmente ao se utilizar plugins de galeria de imagens (Lightbox, Fancybox, etc), carregamos a imagem A a partir do thumb A, a imagem B a partir do thumb B e assim sucessivamente. Ao setarmos um relacionamento (rel="x"), conseguimos exibir diversas imagens da galeria utilizando "next" e "prev".
Até aí, ok... mas e quando eu tenho um set de imagens, mas não preciso exibir os thumbs do mesmo? Isso é, quero carregar esse set a partir de um único link específico?
Dando uma olhada na documentação dos plugins, não encontrei algo parecido. Consigo manipular o plugin dessa forma sem envolver desenvolvimento extra?
Comment: Gambiarra não testada, e se fizar só o primeiro `` com texto e o resto sem (invisivel)? `Ver Galeria`
Comment: Dê uma olhada aqui: http://pt.stackoverflow.com/a/10580/129 Entretanto coloque o seu HTML na pergunta para podermos ajudar mais.
Comment: @Sergio Obrigado pelo rápido retorno, mas não é exatamente esse o problema. Nesse momento estou no trabalho e não vou conseguir criar um "fiddle", mas farei isso a noite seguindo a sua sugestão.

Porém, para adiantar (se ajudar), veja o exemplo de uso apresentado no Lightbox2 (http://www.lokeshdhakar.com/projects/lightbox2) para um set de quatro imagens. Perceba que são exibidos 4 thumbs e ao clicar em um deles abre-se um lightbox com uma galeria com next e prev. O que eu preciso ter é apenas um link, carregando essa mesma galeria (sem que seja necessário exibir os thumbs).
Comment: Uma idéia que me ocorre, sem *thumbnails*, seria nos *callbacks* executados antes e depois das imagens abrirem, comumente presentes nesses plugins, você enviar via AJAX o *offset* da imagem atualmente exibida, se alguma e, no **success**, construir dinamicamente o DOM necessário para o plugin trabalhar. Essa aplicação, devolveria dois *offsets*, anterior e posterior, se houverem, como numa paginação.
Comment: Escolha um plugin feito para galeria de imagens, que permita passar uma lista de URLs na inicialização.
Comment: @BrunoAugusto daí você quebrou as minhas pernas... não sou DEV e entendi pouco o que disse... rs Mas vou guardar o comentário, pois pode ser útil em breve...
Comment: @bfavaretto vou tentar achar um com essa característica.
Comment: @brasofilo hahaha... Sensacional! Não tinha pensado nisso e pode ser que funcione. Vou testar hoje a noite. Tks!
Answer: Testei e é isso mesmo, é só fazer um conjunto de imagens, mas colocar conteúdo só no link da primeira. Usando o exemplo do Lightbox:

Simplificado:

    GALERIA

Conferindo o código do Lightbox, parece que é isso mesmo, não há função "criar galeria a partir de um único link". Ele busca todos os hrefs e adiciona ao album de cada data-lightbox. A não ser que outro plugin ofereça essa funcionalidade específica, este é o workaround.


Why would SQL server return double the line feeds for a string?

Question: I have a .NET 4.0 website, where there is some text on the login page and home page stored in SQL Server 2008.  There's a page in the site to edit both of these texts.
When I click the link to edit, they display fine in a multiline textbox.  However, all line feeds are doubled when the stored procedure retrieves them from the database.
ALTER PROCEDURE [dbo].[usp_WEB_getSiteConfig]
AS
    SELECT login_text, home_text FROM WEB_Site_Config
    RETURN

Text area contains:

RHIOTest Home Page Text
RHIOTest Home Page Text Line 2

Displayed on home page:
RHIOTest Home Page Text

RHIOTest Home Page Text Line 2

Comment: Did you actually look what content the table row contains? Was the text entered from the same browser/OS as you display it in?
Comment: Asp markup for part of the home page displaying those texts and the exact HTML generated could be helpful.
Comment: The behavior is the same regardless of Chrome or IE.  The ASP markup is `

`
Comment: HTML: `

RHIOTest Home Page Text   RHIOTest Home Page Text Line 2

`
Comment: To the naked eye the actual table row content appears to have 6 spaces between the lines...  of course that's not what's actually there.  Is there a better way to see what special characters SQL server is storing?
Comment: You can copy the contents over to a Text file or do this: `Right click in the query window -> Results To -> Results To Text`
Comment: Thanks.  Results to Text shows that the strings are storing correctly.  It's something in the rendering that is spacing it out.
Answer: The culprit was lines like these:
lblLoginMessage.Text = login_text.Replace ("\r\n", "

");

What I don't understand is how this has been in production all this time without the customer reporting the problem...


Adding a row at the begining of every day of a dataframe

Question: I would like to add a row at the begining of every day of a datetime indexed dataframe.
Example:
date  = ['2015-02-03 23:00:00','2015-02-03 23:30:00','2015-02-04 00:00:00','2015-02-04 00:30:00','2015-02-04 01:00:00','2015-02-04 01:30:00','2015-02-04 02:00:00','2015-02-04 02:30:00','2015-02-04 03:00:00','2015-02-04 03:30:00','2015-02-04 04:00:00','2015-02-04 04:30:00','2015-02-04 05:00:00','2015-02-04 05:30:00','2015-02-04 06:00:00','2015-02-04 06:30:00','2015-02-04 07:00:00','2015-02-04 07:30:00','2015-02-04 08:00:00','2015-02-04 08:30:00','2015-02-04 09:00:00','2015-02-04 09:30:00','2015-02-04 10:00:00','2015-02-04 10:30:00','2015-02-04 11:00:00','2015-02-04 11:30:00','2015-02-04 12:00:00','2015-02-04 12:30:00','2015-02-04 13:00:00','2015-02-04 13:30:00','2015-02-04 14:00:00','2015-02-04 14:30:00','2015-02-04 15:00:00','2015-02-04 15:30:00','2015-02-04 16:00:00','2015-02-04 16:30:00','2015-02-04 17:00:00','2015-02-04 17:30:00','2015-02-04 18:00:00','2015-02-04 18:30:00','2015-02-04 19:00:00','2015-02-04 19:30:00','2015-02-04 20:00:00','2015-02-04 20:30:00','2015-02-04 21:00:00','2015-02-04 21:30:00','2015-02-04 22:00:00','2015-02-04 22:30:00','2015-02-04 23:00:00','2015-02-04 23:30:00']

value = [33.24  , 31.71  , 34.39  , 34.49  , 34.67  , 34.46  , 34.59  , 34.83  , 35.78  , 33.03  , 35.49  , 33.79  , 36.12  , 37.09  , 39.54  , 41.19  , 45.99  , 50.23  , 46.72  , 47.47  , 48.46  , 48.38  , 48.40  , 48.13  , 38.35  , 38.19  , 38.12  , 38.05  , 38.06  , 37.83  , 37.49  , 37.41 , 41.84  , 42.26 , 44.09  , 48.85  , 50.07 , 50.94  , 51.09  , 50.60  , 47.39  , 45.57  , 45.03  , 44.98  , 41.32  , 40.37  , 41.12  , 39.33  , 35.38  , 33.44  ]
df = pd.DataFrame({'value':value,'index':date})
df.index = pd.to_datetime(df['index'],format='%Y-%m-%d %H:%M')
df.drop(['index'],axis=1,inplace=True)
print(df)

                     value
index
2015-02-03 23:00:00  33.24
2015-02-03 23:30:00  31.71
2015-02-04 00:00:00  34.39
2015-02-04 00:30:00  34.49
2015-02-04 01:00:00  34.67
2015-02-04 01:30:00  34.46

Expected result:
                     value
index
2015-02-03 23:00:00  10
2015-02-03 23:00:00  33.24
2015-02-03 23:30:00  31.71
2015-02-04 00:00:00  10
2015-02-04 00:00:00  34.39
2015-02-04 00:30:00  34.49
2015-02-04 01:00:00  34.67
2015-02-04 01:30:00  34.46

How can I do that efficiently? in this example I added the value 10 at the begining of each day.
Cheers,
Answer: You can try
s=df.groupby(df.index.date).first()
s.iloc[:,0]=10
s.index=pd.to_datetime(s.index,format='%Y-%m-%d %H:%M:%S')
df=pd.concat([df,s]).sort_index()


Como seria a estrutura de grandes projetos Java

Question: Em pequenos projetos web, geralmente separamos pacotes em DAO, Models e Controllers, mas em grandes sistemas do tipo ERP, com centenas de tabelas, controllers e lógicas de negócios, como ficaria essa estrutura?
Comment: Se o projeto é pequeno essas coisas que citou sõa canhões para matar passarinho. Alguns projetos modernos (feitos por engenheiros de verdade que não fazem só porque está todo mundo fazendo) já não usam essas coisas nem em projetos grandes quando eles não fazem sentido para aquele projeto. Então a pergunta já parte de premissa errada., ou pelo menos ruim. Talvez e só talvez o grande mostra como é uma loucura fazer uma arquitetura complexa dessas. No pequeno só parece ser tranquilo porque ele é tão pequeno que dá quase na mesma, afinal a pessoa só copia e cola coisas.
Comment: @Maniero o sentido da pergunta é de como seria a estruturação desses projetos. É somente uma dúvida. Lógico que não faria sentido utilizar isso para um projeto pequeno só por moda.
Answer: Depende da arquitetura, que depende dos requisitos
A resposta é independente da linguagem, observe que poderia ser C# ou outra, tendo em vista que os conceitos citados como DAO, Models e Controllers (imaginei MVC), não são específicos, próprios ou exclusivos para software desenvolvido em Java.
DAO, por exemplo, é um instrumento para implementar a camada de persistência de um software (wikipedia), assim como o padrão repository (esta questão do Stackoverflow esclarece a diferença entre ambos). Ou seja, são estratégias possíveis para lidar com o acesso a dados. O uso (qual delas empregar?), contudo, ou a indicação, vai depender do contexto (nenhuma delas é absolutamente melhor que a outra).
A pergunta tem como foco a arquitetura do software que, por sua vez, depende dos requisitos do software em questão. Veja que, caso empregue uma arquitetura baseada em micro-serviços, por exemplo, é possível que você não tenha mais "centenas de tabelas", mas um número menor por micro-serviço, o que talvez permita abordagens distintas por micro-serviço.
Enfim, se consultar alguns projetos do seu interesse no Github, provavelmente detectará que cada um possui uma arquitetura distinta dos demais, talvez alguns façam uso de DAO, por exemplo, enquanto outros não.


How might I limit my display:flex (css) to 2 divs per line?

Question: I am currently working on a site that shows some info in  boxes. My goal right now is to have 2 div boxes fit on each line. I made it so that more than one div can be on the same line with the code below, but I realized that if I had more than 2 they would all still stack on the same line.
I am not totally sure how I would limit my divs to 2 per line. Some help would be greatly appreciated!

.flex-container {
    display: flex;
}

.flex-child {
    flex: 1;
    /*border: 2px solid yellow;*/
    display: flex;
    justify-content: center;
    margin: 5px;
    margin-top: 20px;
    padding: 100px;
    background: #7d7d7d;
    border-radius: 30px;
    margin-left: 10px;
    margin-right: 10px;

    font-family: 'Ubuntu', Helvetica, Arial, sans-serif;
    font-size: 50px;
    color: white;
}

.flex-child:first-child {
    display: flex;
    justify-content: center;
    margin: 5px;
    margin-top: 20px;
    padding: 100px;
    background: #7d7d7d;
    border-radius: 30px;
    margin-right: 10px;
    margin-left: 10px;

    font-family: 'Ubuntu', Helvetica, Arial, sans-serif;
    font-size: 50px;
    color: white;
}

Answer: You should use flex-wrap CSS attribute, using it on flex display will force the elements to go new line when ever there is no space for more elements in one line:

.flex-container {
    display: flex;
    flex-wrap: wrap;
}

.flex-child {
    border: 2px solid yellow;
    justify-content: center;
    margin: 5px;
    margin-top: 20px;
    background: #7d7d7d;
    border-radius: 30px;
    margin-left: 10px;
    margin-right: 10px;
    font-family: 'Ubuntu', Helvetica, Arial, sans-serif;
    color: white;
    width: calc(50% - 24px);
    height: 200px;
}


Natural parameters of Bernoulli distribution

Question: In Bishop's Pattern Recognition and Machine Learning, he states that exponential family distributions over $\mathbf{x}$ given parameters $\boldsymbol{\eta}$ can be written as $p(\mathbf{x} | \boldsymbol{\eta}) = h(\mathbf{x})g(\boldsymbol{\eta})\exp\{\boldsymbol{\eta}^\top\mathbf{u}(\mathbf{x})\}$.
He gives the natural parameters for the Bernoulli distribution with probability of success $\mu$ as: $$\eta = \ln(\frac{\mu}{1 - \mu})$$ $$u(x) = x$$ $$h(x) = 1$$ $$g(\eta) = \frac{1}{1 + \exp{(\eta)}}$$
I was working this out myself and found $$\boldsymbol{\eta} = [\ln\mu,\: \ln(1 - \mu)]^\top$$ $$\mathbf{u}(x) = [x, \: 1-x]^\top$$ $$h(\mathbf{x}) = 1$$ $$g(\boldsymbol{\eta}) = 1$$ could also work.
How do you know when you've found the natural parameters and is there a rule preventing you from adding arbitrary scaling constants into the expressions for $\boldsymbol{\eta}$, $\mathbf{u}$, $h$, and $g$?
Comment: there's a typo, it must be $u(x)=x$
Comment: ...and unless I am mistaken, also $g(\eta) = \frac{1}{1 + \exp{(\eta)}}$
Answer: A natural exponential family is one in which the natural parameter $\eta$ and the statistic $u(x)$ are both the identity (see here), which is the case for Bishop's formulation, but not yours.
Comment: Yes, it is: https://en.wikipedia.org/wiki/Identity_function
Comment: Isn't Bishop's $u(x) = x$ though, which is not identity?


How to plot the graph for parameter vs x variable?

Question: I'm trying to plot the graph for a parameter vs x variable. I used Matlab software. But I did not get a graph that I want. Is there anything wrong with my code? Here I attached the parameter value and Matlab code that I used. Hope someone can help me.
Comment: So, what is the figure it gives?
Answer: The way you write your code, MATLAB will think that D is just a number that is, when all is said and done, set to 0.13. You probably want it to be an array to align with the values in the x array. So I suggest that you, in each for loop, change D = to D(i) =.
Comment: Thank you so much. I have followed your suggestion and I got the figure that I want.


Add description to files uploaded by the Media file selector widget

Question: I am using D7 with media module. I have a field for (multiple) files.
Instead of the built in "file" widget for the file field, I am using the "Media file selector" widget.
In drupal core's "file" widget, I am able to select the "Enable Description field" option to label the files. I am unable to find such an option with the "media file selector"
There is a whole section to add files with many fields. But I am looking for a field with some sort of description or title option. I will use it as the link text, instead of the file name.
Is there an option somewhere that I've been missing?
Thanks.
Answer: With the file_entity module you can add fields to files.  So in your case add a "Description" field to your image file type.
When selecting how the field will be rendered, make sure to choose "Rendered file" and it display the file with the extra fields.
Comment: Make sure that you are using the file_entity-2.x-dev and media-2.x-dev
Comment: yes, there is such a setting and I added a description field to the audio file type but still the description field is not available upon upload (or later).


Inferring dimension of a polyhedron from a point

Question: If we have a polyhedron $P = \{x\in\mathbb{R}^n \mid Ax \leq b \}$, and we find a point $x\in P$ such that $x$ satisfies at least $n$ of the $Ax\leq b$ (linearly independent) inequalities strictly, then does that mean that the dimension of $P$ is $n$?
More generally, if we can find a point $x\in P$ such that $x$ satisfies at least $k$ of the $Ax\leq b$ (linearly independent) inequalities strictly, then does that mean that the dimension of $P$ is at least $k$?
Comment: I guess it depends on whether or not you allow redundant inequalities in the representation of $P$. Do you make any additional assumptions on $A$ or $b$? Otherwise it is easy to come up with counterexamples.
Answer: The  answer is no, as the following examples show.

Example 1. Consider the polytope $P = \{x \in \mathbb{R}^n \, \mid \, Ax \leq b\}$, where $A \in \mathbb{R}^{4n \times n}$ and $b \in \mathbb{R}^{4n}$ are given by the block matrices
$$ A = \begin{pmatrix} I_n \\ -I_n \\ I_n \\ -I_n \end{pmatrix}, \qquad b = \begin{pmatrix} 0 \\ 0 \\ \pmb{1} \\ \pmb{1} \end{pmatrix}, $$
where $I_n$ is the $n \times n$ identity matrix and $\pmb{1}$ is the $n$-dimensional all-ones vector. In other words:

The first $n$ inequalities read $x_i \leq 0$ for all $i \in [n]$;
The next $n$ inequalities read $-x_i \leq 0$ for all $i \in [n]$;
The next $n$ inequalities read $x_i \leq 1$ for all $i \in [n]$;
The last $n$ inequalities read $-x_i \leq 1$ for all $i \in [n]$.

It is easy to see that $P = \{0\}$. Note that $0 \in P$ satisfies the last $2n$ inequalities strictly, and $n$ of these are linearly independent. Yet $P$ is $0$-dimensional, so your statement fails dramatically.

The preceding example is somewhat contrived, because the last $2n$ inequalities are redundant and can be removed. The following example shows that your statement might still fail if no single inequality can be removed.

Example 2. Consider the polytope $P = \{x \in \mathbb{R}^2 \, \mid \, Ax \leq b\}$, where $A \in \mathbb{R}^{4 \times 2}$ and $b \in \mathbb{R}^4$ are given by
$$ A = \begin{pmatrix} -1 & 0 \\ 0 & 1 \\ 1 & -1 \\ -1 & 1 \end{pmatrix}, \qquad b = \begin{pmatrix} 0 \\ 1 \\ 0 \\ 0 \end{pmatrix}. $$
The first inequality reads $x_1 \geq 0$, the second inequality reads $x_2 \leq 1$, and the last two inequalities read $x_1 = x_2$. So $P = \{(t,t) \, \mid \, t \in [0,1]\}$ is $1$-dimensional. Nevertheless, the first two inequalities are linearly independent, and they are strict for the point $(\frac{1}{2},\frac{1}{2}) \in P$.

In the second example, I don't think there is another half-space representation of the same polytope such that every point of $P$ satisfies at most one inequality strictly. However, you can replace the inequality $x_2 \leq 1$ by the inequality $x_1 \leq 1$, and then the two inequalities that are strict for the point $(\frac{1}{2},\frac{1}{2})$ are linearly dependent. I think you can do something similar for a general polyhedron. In any case, my examples show that the answer depends on the halfspace-representation of $P$.


A relationship to the latest referencing entity in views

Question: I am not quite sure how to do this. I have content type A and another content type B which references content type A using an entity reference field. So A can have multiple nodes of type B referencing it. Not B has a date field.
Now what I want to do is create a view that lists content of type A but sorted based on the date field of the latest node of type B that references it.
I am not really sure what is the best way to achieve that. Any help is highly appreciated.
Answer:
Make a view that lists nodes of Type B.
Sort this view based on date.
Add relationship based on the reference field which reference content type A.
Now list the fields you want from Content type A.
If you don't need fields from Content type B, hide them.
Comment: But since content type A can have multiple nodes of type B referencing it, the view would have duplication of type A in the list.
Comment: You can then apply distinct on that particular field.


Recording a CD with piano improvisations

Question: I have been playing piano for about 14 years and I am thinking to record a CD/album with piano improvisations.
Is this a common thing to do? These songs will not necessarily have sheet music.
I am thinking to simply stay at the piano and record music for about 2 hours and then process and eventually fix/improve the MIDI notes in some places and make a ~1 hour long album with ~14 songs, let's say.
My questions are:

Is this a good idea at all? Or should I write the sheet music first and then record the songs?
I is recommended to add other instruments such as bass or strings/pads to improve the background?
Comment: All these are really up to you. You want to write sheet music? Go for it. You want to add  other instruments? Go for it. There have been numerous pieces with solo piano, there have been numerous improvisational pieces
Comment: This is an artistic decision you have to make for yourself. We can't tell you what feels right for you. Whether it's a "trend" or not doesn't help either, since you might have the personal desire to follow the trend or to avoid following the trend. Questions and answers on this site are not really meant to work for only certain situations, so if it's the trend right now where you are working and releasing music, but it's not the trend elsewhere or won't be the trend in two years, then that's not a good fit here.
Comment: @Shevliaskovic Well, I'm asking because I'm unsure about the current trend in the field...
Answer: There is absolutely no point in writing out the dots before you record. Unless you need them yourself! There is a lot of recorded music out there already, that actually, the dots were written after the recordings had been made. Transcriptions.
There's always a recommendation to add strings/bass/drums/etc. to a lot of recordings. You could do that, and then decide whether they work better - or not. Everything recorded doesn't have to be on a track.
Best listen to some existing CDs with the same sort of piano music, and decide which impress most. Then use those ideas - mixes, other instruments, et al, on your own D tracks.


How to display an animated Gif in React Native

Question: Before you link me to another question similar to this one, such as this or that. I will say that I have done exactly what the answers said, but my gif won't animate as it should (It is displayed though).
Here is what I've done in a function, which is displayed through the main App function  Stack.Screen within a NavigationContainer and Stack.Navigator. (I'm using React Navigation to move across screens, the context here is that a button is pressed and it displays the contents of the DetailsScreen function)
function DetailsScreen({ navigation }) {
  return (
    <View style={{ flex: 2, alignItems: 'center', justifyContent: 'center' }}>
      <Image source={require('./src/gif/moving.gif')} />
      <Text>Here is a gif</Text>
    </View>
  );
}

This displays the first still image of my gif, but doesn't animate it.
I also already went ahead and placed the implementations in the build.gradle dependencies, but it didn't do anything for me. I have a feeling the problem lies there.
implementation 'com.facebook.fresco:fresco:1.+'

// For animated GIF support
implementation 'com.facebook.fresco:animated-gif:1.+'

// For WebP support, including animated WebP
implementation 'com.facebook.fresco:animated-webp:1.+'
implementation 'com.facebook.fresco:webpsupport:1.+'

(I already checked fresco's new implementation version 2, but it still didn't help. I also tried changing from a specific version, still doesn't work)
I am using React Native version 0.67. (I tried starting it again while downgrading react-native to 0.66 and it still doesn't work.)

Also, not sure if this has to do with anything in this screenshot here, this is what I had by default and gave me this error message as soon as I opened the file, but the program launches just fine even with that on
Doing it normally in the main App() function starting first displays the gif, but still remains as a still image.
What should I do? I mean... what else can I do?
Edit:
I found the solution to the problem... it was a simple case of just cold booting the emulator I was using from android studio.
However, Tadej's answer is valid, as the view style aligning messes up the gif a bit. If you are having a similar problem and the answer doesn't help, try cold booting your emulator, or even reinstall a newer one... or alternatively, use a real android phone to test these sorts of things.
Anyway, thanks a lot for the help Tadej ! I hope this question has helped others in my situation.
Tadej Slemenšek
Comment: Feel free to leave a comment asking a question about what I've done, or where something is; I can provide additional information for better clarity
Answer: This worked for me. Setting height and width on Image prop did not show the gif. So I flexed it and added maxWidth and maxHeight.
const imageUrl = 'https://media.giphy.com/media/xT0xeCCINrlk96yc0w/giphy.gif';
const App = () => {

  const { width } = useWindowDimensions();

  return (
    <View style={{flex: 1}}>
      <Image style={{flex: 1, maxWidth: width, maxHeight: width}} source={{uri: imageUrl}}/>
    </View>
  );
};

Comment: Nevermind, I just found the solution. After waking up from bed, I had the idea of maybe cold booting my android emulator... then when I started the react-native app, the gif just started moving. Nice.
Comment: Strange, I did the equivalent as you in my function, I also used your link and did a uri just in case it wasn't a problem with my local gif, and then I tried doing exactly the same thing as you, with the "const App = () => {". But I still don't see the gif move, but its still displayed, its still a non-moving image.

Can I see the contents of your package.js? Maybe I'm missing some modules..
Comment: I created a fresh project. Are you using Android or iOS? Beacuse on Android you have to do some extra things. Checkout image component documentation on React Native page. Its all listed there.
Comment: I've edited my post regarding your response, is my build.gradle dependencies set correctly for supporting animated images?
Comment: Oh ok. Try a real device next time :D
Comment: Haha.. Yeah. That is a better idea, I should just go ahead and buy a phone for this sort of thing x) Thanks a lot for your help though! What I was doing with the style in View actually was making the gif not show up at all, so your answer should help those who are going through similar problems


Dúvida sobre código em C

Question: Olá. Estou com dúvidas sobre este código.
No "case 1", ao executar, me aparece isto:

O problema é que nenhum dos descontos é aplicado. Já tentei outras formas de montar esta operação, mas todas resultam em erro.
Já no "case 2", queria saber se existe uma forma de, " if (c==987)" virar " if (c==0987)", sem que ocorra erros referentes à base octal. E, de preferência, tem que ser da forma como está no código, já que foi a forma como o professor nos instruiu a fazer, inicialmente.
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <math.h>

int main () {
setlocale(LC_ALL, "Portuguese");

int quant, questoes,codigo;
float preco, valor, calculo, desconto, salario, valor1, valor2, valor3;
char nome_produto;

puts("----- RESOLUÇÃO DE PROBLEMAS -----");
puts("Digite o número da questão desejada:\n1 - Desconto em Produtos\n2 - Códigos de Produtos \n3 - Rejuste de Salário \n4 - Maior valor \n5 - Soma de Valores ");
scanf("%d",&questoes);

       switch(questoes){
                        case 1:
                                system("cls");
                                puts("Digite o nome do produto");
                                scanf(" %[^\n]c ",&nome_produto);
                                puts ("Digite a quantidade adquirida");
                                scanf ("%i",&quant);
                                puts ("Digite o preço do produto");
                                scanf ("%f",&preco);
                                if ("quant<=10") {
                                                  calculo = preco * quant;
                                                  printf ("Seu produto não pode obter desconto. O preço total é de: %.2f",calculo);
                                              }
                                else if ("quant<=20") {
                                                  desconto = preco * quant * 10/100;
                                                  calculo=preco*quant-desconto;
                                                  printf ("Seu produto obteu um desconto de 10%. O preço total é de: %.2f",calculo);
                                  }
                                else if ("quant<=50") {
                                                  desconto = preco * quant * 20/100;
                                                  calculo = preco * quant - desconto;
                                                  printf ("Seu produto obteu um desconto de 20%. O preço total é de: %.2f",calculo);
                                  }
                                else if ("quant>50") {
                                                  desconto = preco * quant * 25/100;
                                                  calculo = preco * quant - desconto;
                                                  printf ("Seu produto obteu um desconto de 25%. O preço total é de: %.2f",calculo);
                                  }
                        break;

                        case 2:
                                system("cls");
                                puts("Digite o código do produto");
                                scanf("%i",&codigo);
                                puts("Digite a quantidade adquirida");
                                scanf("%i",&quant);
                                if (codigo==1001) {
                                    calculo=quant*5.32;
                                    printf("O valor total é %.2f",calculo);
                                }
                                if (codigo==1324) {
                                    calculo=quant*6.45;
                                    printf("O valor total é %.2f",calculo);
                                }
                                if (codigo==6548) {
                                    calculo=quant*2.37;
                                    printf("O valor total é %.2f",calculo);
                                }
                                if (codigo==987) {
                                    calculo=quant*5.32;
                                    printf("O valor total é %.2f",calculo);
                                }
                                if (codigo==7623) {
                                    calculo=quant*6.45;
                                    printf("O valor total é %.2f",calculo);
                                }
                                else
                                    puts("Código Inválido");
                        break;

                        case 3:
                                system("cls");
                                puts("Digite o código funcional");
                                scanf("%i",&codigo);
                                puts("Digite o salário atual do funcionário");
                                scanf("%f",&salario);
                                if (codigo==01) {
                                    calculo=salario*1.15;
                                    printf("O salário atual, após o reajute de 15 por cento é de: %.2f. Seu cargo é de operador.",calculo);
                                }
                                if (codigo==02) {
                                    calculo=salario*1.1;
                                    printf("O salário atual, após o reajute de 10 por cento é de: %.2f. Seu cargo é de supervisor.",calculo);
                                }
                                if (codigo==03) {
                                    calculo=salario*1.05;
                                    printf("O salário atual, após o reajute de 5 por cento é de: %.2f. Seu cargo é de gerente.",calculo);
                                }
                                if (codigo==04) {
                                    printf("O salário atual é de: %.2f. Seu cargo é de diretor.",salario);
                                }
                                else
                                    puts("Código Inválido");

                        break;

                        case 4:
                              system("cls");
                              puts("Entre com o primeiro valor");
                              scanf("%f",&valor1);
                              puts("Entre com o segundo valor");
                              scanf("%f",&valor2);
                              puts("Entre com o terceiro valor");
                              scanf("%f",&valor3);
                              if (valor1>valor2, valor1>valor3) {
                                puts("O primeiro valor é maior");
                              }
                              else if (valor2>valor1, valor2>valor3) {
                                puts("O segundo valor é maior");
                              }
                              else if (valor3>valor1, valor3>valor2) {
                                puts("O terceiro valor é maior");
                              }
                              else
                                puts("Os valores são iguais");
                        break;

                        case 5:
                              system("cls");
                              puts("Entre com o primeiro valor");
                              scanf("%f",&valor1);
                              puts("Entre com o segundo valor");
                              scanf("%f",&valor2);
                              puts("Entre com o terceiro valor");
                              scanf("%f",&valor3);
                              if (valor1>valor3, valor2>valor3) {
                                calculo=valor1+valor2;
                                printf("%.0f + %.0f = %.0f",valor1,valor2,calculo);
                              }
                              else if (valor1>valor2, valor3>valor2) {
                                calculo=valor1+valor3;
                                printf("%.0f + %.0f = %.0f",valor1,valor3,calculo);
                              }
                              else if (valor3>valor1, valor2>valor1) {
                                calculo=valor2+valor3;
                                printf("%.0f + %.0f = %.0f",valor2,valor3,calculo);
                              }
                              else
                                puts("Os valores são iguais");
                        break;

                        default:
                                puts ("Opção Inválida");
                        }

}

Para deixar mais claro, tudo isso faz parte de questões acadêmicas. Estou aprendendo agora. Deixarei o comando correspondente ao case 1 abaixo:

Case 1

Faça um programa que leia o nome de um produto, o preço e a quantidade comprada. Escreva o nome do produto comprado e o valor total a ser pago, considerando que são oferecidos descontos pelo número de unidades compradas, segundo dados abaixo:

Até 10 unidades - valor total
De 11 a 20 unidades - 10% de desconto
De 21 a 50 unidades - 20% de desconto
Acima de 50 unidades - 25% de desconto
Comment: `%d, &c `? Você está jogando codificação binária de um decimal de (possivelmente) 4 bytes em um endereço interpretado como ponto flutuante IEEE de 4 bytes, essa leitura não vai retornar um resultado como confiável
Comment: Olá. Adicionei os comandos das questões. Espero que esteja de melhor entendimento agora.
Answer: Caso 1
Voce tem que printar na tela a mensagem para digitar nome.
Depois usar o scanf para receber o resultado.
Depois printar na tela a mensagem para digitar preço.
Depois usar o scanf para receber o resultado.
Caso 2
Primeira coisa que você deve fazer que vai te ajudar e ajudar os outros a ler seu código é colocar nomes compreensíveis em suas variáveis. Nomes como a,x,y,z não ajudam em nada entender o que esta acontecendo. Coloque nomes como "produto", "quantidade", "preco".
Bom, no caso dois eu não vou resolver para você porque é uma questão academica, mas vou te dar os passos para resolver a questão:
1- Peça pro usuario digitar o código do produto e receba o valor
2- Peça para ele digitar a quantidade e receba o valor
3- Faça um switch para pegar o preco do produto que ele escolheu, apenas o preço. Não precisa colocar os IFS dentro do switch senão vai ficar repetindo código. Algo assim ó:
double preco;

switch(codigo) {

    case 1001:
        preco = 5.32;

E ASSIM POR DIANTE....

4- Depois disso crie a verificação da quantidade. Se ela for até dez pega a quantidade e multiplica pelo preço, se for de 11 a vinte faz quantidade vezes preco menos 20% e por aí vai.
Bom espero que consiga resolver mas é muito importante que você mesmo resolva porque vai te ajudar imensamente no futuro.
Comment: Olá. Bem, no que se refere ao caso 1, eu editei o post, já que agora o erro é diferente. Mas eu descobri o porque de não estar conseguindo inserir caracteres. Já o caso 2, eu consegui que funcionasse, mas continuo com o problema referente a base octal. Ah, e obrigada pela dica! Já modifiquei o código, realmente facilita a leitura.
Comment: Tira esse if else de dentro do switch e deixa ele apenas pra determinar  preço igual te mostrei na resposta.

Depois do switch faz o seu if apenas pra ver o desconto.

if(preco <= 10) {
    nao tem desconto
} else if (preco >10 && preco <= 20) {
    precoFinal = preco blablabla
}

Entendeu?
Comment: [Dessa](http://i.imgur.com/vaMqx4h.png) forma?
Comment: Isso e seu erro de octal é que ta iniciando uma variavel com 0 como primeiro numero e quando inicia ela com ela é tratada como numero de base 8. Remova o 0 da frente.
Comment: Pois é, era essa minha dúvida. O problema é que a atividade pede esse código. Acho que o melhor seria me informar com meu professor. De qualquer forma, obrigada.
Comment: Transforma seu código em uma string ou invés de um inteiro que resolve o problema
Answer: Uma dica para você solucionar esse problema é determinar uma variavel para unidade e preco.
Exemplo:
float quantidade = 0;
float preco = 0;

Sendo assim,
Voce pega o codigo do produto, verifica  o preco do produto e incrementa esse valor na variavel preco, e incrementa 1 na variavel quantidade.
No final é só checar.

Dúvida sobre código em C


Calculating the x,y,z position of solar bodies using ruby

Question: I am using the equations and data for Mars here
http://ssd.jpl.nasa.gov/txt/aprx_pos_planets.pdf
and the solution for the eccentric anomaly kepler equation given here at the top of page four
http://murison.alpheratz.net/dynamics/twobody/KeplerIterations_summary.pdf
And checking the output by modifying the date in the get_centuries_past to the following dates and looking at page E-7 for the actual x,y,z coordinates of Mars (sample data below, but link for the curious:
http://books.google.com/books/about/Astronomical_Almanac_for_the_Year_2013_a.html?id=7fl_-DLwJ8YC)
date 2456320.5 is 2013, 1, 28 and should output
x = 1.283762
y = -0.450111
z = -0.241123

date 2456357.5 is 2013, 3, 6 and should output
x = 1.300366
y = 0.533593
z = 0.209626

date 2456539.500000 is 2013, 9, 4 and should output
x = - 0.325604
y = 1.418110
z = 0.659236

I tested mean anomaly equation and it was fine.  However, I cannot get a good set of x,y,z coordinates.  I have been tweaking my kepler and coordinate function but cannot get them to match the tables in the astronomical almanac.
Any suggestions or advice on solving the positions of the stars is greatly appreciated. The code below can be put in a .rb file and running it on the command line will output the x,y,z values.
def get_centuries_past_j2000()
        #second number is from DateTime.new(2000,1,1,12).amjd.to_f - 1 the modified julian date for the J2000 Epoch
        #Date.today.jd.to_f - 51544.5
        (DateTime.new(2013,1,28).amjd.to_f - 51544.5)/36525
end

class Planet
    attr_accessor :semi_major_axis, :semi_major_axis_delta, :eccentricity, :eccentricity_delta,
    :inclination, :inclination_delta, :mean_longitude, :mean_longitude_delta, :longitude_of_perihelion,
    :longitude_of_perihelion_delta, :longitude_of_ascending_node, :longitude_of_ascending_node_delta, :time_delta
def initialize(semi_major_axis, semi_major_axis_delta, eccentricity, eccentricity_delta,
inclination, inclination_delta, mean_longitude, mean_longitude_delta, longitude_of_perihelion,
longitude_of_perihelion_delta, longitude_of_ascending_node, longitude_of_ascending_node_delta, time_delta)
    @semi_major_axis = semi_major_axis + (semi_major_axis_delta * time_delta)
    @eccentricity = eccentricity + (eccentricity_delta * time_delta)
    @inclination = inclination + (inclination_delta * time_delta)
    @mean_longitude = mean_longitude + (mean_longitude_delta * time_delta)
    @longitude_of_perihelion = longitude_of_perihelion + (longitude_of_perihelion_delta * time_delta)
    @longitude_of_ascending_node = longitude_of_ascending_node + (longitude_of_ascending_node_delta * time_delta)
    @argument_of_perhelion = @longitude_of_perihelion - @longitude_of_ascending_node
end

def mean_anomaly
    ((@mean_longitude - @longitude_of_perihelion)%360).round(8)
end

def eccentric_anomaly
    mod_mean_anomaly = mean_anomaly
    if mod_mean_anomaly > 180
        mod_mean_anomaly = mod_mean_anomaly - 360
    elsif mod_mean_anomaly < -180
        mod_mean_anomaly = mod_mean_anomaly + 360
    end
    e34 = @eccentricity**2
    e35 = @eccentricity*e34
    e33 = Math.cos(mod_mean_anomaly*Math::PI/180)
    mod_mean_anomaly + (-0.5 * e35 + @eccentricity + (e34 + 1.5 * e33 * e35) * e33) * Math.sin(mod_mean_anomaly*Math::PI/180)
end

def J2000_ecliptic_plane
    x_prime = @semi_major_axis * (Math.cos(eccentric_anomaly*Math::PI/180) - @eccentricity)
    y_prime = @semi_major_axis * Math.sqrt(1-@eccentricity**2) * Math.sin(eccentric_anomaly*Math::PI/180)
    z_prime = 0
    x = x_prime * (Math.cos(@argument_of_perhelion*Math::PI/180) * Math.cos(@longitude_of_ascending_node*Math::PI/180) - Math.sin(@argument_of_perhelion * Math::PI/180) * Math.sin(@longitude_of_ascending_node * Math::PI/180) * Math.cos(@inclination * Math::PI/180)) + y_prime * (-Math.sin(@argument_of_perhelion* Math::PI/180) * Math.cos(@longitude_of_ascending_node * Math::PI/180) - Math.cos(@argument_of_perhelion * Math::PI/180) * Math.sin(@longitude_of_ascending_node * Math::PI/180) * Math.cos(@inclination * Math::PI/180))
    y = x_prime * (Math.cos(@argument_of_perhelion*Math::PI/180) * Math.sin(@longitude_of_ascending_node*Math::PI/180) + Math.sin(@argument_of_perhelion * Math::PI/180) * Math.cos(@longitude_of_ascending_node * Math::PI/180) * Math.cos(@inclination * Math::PI/180)) + y_prime * (-Math.sin(@argument_of_perhelion* Math::PI/180) * Math.sin(@longitude_of_ascending_node * Math::PI/180) + Math.cos(@argument_of_perhelion * Math::PI/180) * Math.cos(@longitude_of_ascending_node * Math::PI/180) * Math.cos(@inclination * Math::PI/180))
    z = x_prime * Math.sin(@argument_of_perhelion*Math::PI/180) * Math.sin(@inclination*Math::PI/180) + y_prime * Math.cos(@argument_of_perhelion*Math::PI/180) * Math.sin(@inclination*Math::PI/180)
    return x, y, z
end
end

time = get_centuries_past_j2000
mars = Planet.new(1.52371034, 0.00001847, 0.09339410, 0.00007882, 1.84969142, -0.00813131, -4.553443205, 19140.30268499, -23.94362959, 0.44441088, 49.55952891, -0.29257343, time)
puts time
puts mars.mean_anomaly
puts mars.eccentric_anomaly
puts mars.J2000_ecliptic_plane

Answer: This may be helpful although I don't agree with arguments of perihelion for Earth. Longitude of perihelion is fine. The inclination is so small that it doesn't really apply for Earth as it does for other planets. And finding values for Omega is challenging. The perihelion is ever changing. FYI in 1248 AD it coincided with the winter solstice.
Firstly IAU has free SOFA C and FORTRAN lib's with standardized astronomical functions. Matric tables are included in certain routines so you don't have to go look them up.
But if you are so inclined to use old school methods then this site has what you need http://www.stjarnhimlen.se/comp/tutorial.html
NOVA C and JAVA, MICA, JPL catalogs, Jean Meeus book, AA USNO and a host of others beside wikipedia have tons of information. It looks like you want rectangular values  so I think Paul Schlyter can help you out.
SOFA has these as well but documentation on how to use them is not going to teach the techniques. It will take a lot of research to understand them.
It looks like you are using Ruby and there is a wrapper gem for the SOFA lib named Celes. Just gem install celes and you'll have it.
Try looking at the fundamental arguments which all begin with fa:
**     iauFal03     mean anomaly of the Moon
**     iauFaf03     mean argument of the latitude of the Moon
**     iauFaom03    mean longitude of the Moon's ascending node
**     iauFame03    mean longitude of Mercury
**     iauFave03    mean longitude of Venus
**     iauFae03     mean longitude of Earth
**     iauFama03    mean longitude of Mars
**     iauFaju03    mean longitude of Jupiter
**     iauFasa03    mean longitude of Saturn
**     iauFaur03    mean longitude of Uranus
**     iauFapa03    general accumulated precession in longitude
Have fun!
Edit Update:
Two functions in this gem that will give you heliocentric and barycentric x,y,z for Earth.
p is position and v is velocity.
h is heliocentric and b is barycentric.
pvh = Celes.epv00(jd_now, 0.0)[0]
pvb = Celes.epv00(jd_now, 0.0)[1]

sc = Celes.pv2s(pvh)

sc means spherical coordinates.
As you can see, all you need to provide is a JD time value.
So lots of good stuff in that gem and the SOFA C code.
I have yet to learn how to use them all.


MegaCli64 -PDInfo shows drive but other commands says device does not exist

Question: A drive recently went missing on our IBM server. It has happened on other servers in the past and I usually just replace them with out a problem. On one it is not automatically adding the new drive.
I run the command:
MegaCli64 -PDInfo -PhysDrv [252:0] -a0

and I receive the drive information:
Enclosure Device ID: 252
Slot Number: 0
Enclosure position: N/A
Device Id: 11
WWN: 5000C50055138398
Sequence Number: 17
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SAS

Raw Size: 0 KB [0x0 Sectors]
Non Coerced Size: 0 KB [0x0 Sectors]
Coerced Size: 0 KB [0x0 Sectors]
Firmware state: Unconfigured(good), Spun Up
Device Firmware Level: B559
Shield Counter: 0
Successful diagnostics completion on :  N/A
SAS Address(0): 0x5000c50055138399
SAS Address(1): 0x0
Connected Port Number: 1(path0)
Inquiry Data: IBM-ESXSST9300605SS     B5596XP3S49F0215B559
FDE Capable: Not Capable
FDE Enable: Disable
Secured: Unsecured
Locked: Unlocked
Needs EKM Attention: No
Foreign State: None
Device Speed: Unknown
Link Speed: Unknown
Media Type: Hard Disk Device
Drive Temperature : N/A
PI Eligibility:  No
Drive is formatted for PI information:  No
PI: No PI
Port-0 :
Port status: Active
Port's Linkspeed: Unknown
Port-1 :
Port status: Active
Port's Linkspeed: Unknown
Drive has flagged a S.M.A.R.T alert : No

If I try to add the drive as a replacement/hot spare/ or any form of manipulation I receive the error.
sudo MegaCli64 -PdReplaceMissing -PhysDrv [?:0] -Array0 -Row1 -a0

Adapter: 0: Failed to replace Missing PD at Array 0, Row 1.

FW error description:
 The requested command cannot be completed, as the specified device does not exist.

Exit Code: 0x0c

How do I replace the missing disk in the raid?
Comment: How do I replace the missing disk in the raid?
Comment: What is your question?
Answer: I got the same error today.
On solution for me was to dump the events on the RAID Card:
megacli -AdpEventLog -GetEvents -f events -aAll

After reading the events, I found my problem:
Event Description: Inserted: PD 07(e0x20/s7)
Event Description: PD 07(e0x20/s7) is not a certified drive

My RAID Card, on my DELL server, is a H700 RAID Card. It only support specific DELL Disks.
I have read that a Firmware upgrade can remove this limitation, I will try. I hope you will have a better solution in your case...


MergeSort algorithm - java

Question: I have a problem with MergeSort implementation in Java. My code looks like this and I have no idea where I made a mistake.
public List sort(List list) {
        return mergesort(list, 0, list.size() - 1);
    }

    private List mergesort(List list, int startIndex, int endIndex) {
        if (startIndex == endIndex) {
            List temp = new ArrayList();
            temp.add(list.get(0));
            return temp;
        }
        int splitIndex = ((startIndex + endIndex) / 2);
        List list1 = mergesort(list, startIndex, splitIndex);
        List list2 = mergesort(list, (splitIndex + 1), endIndex);
        return merge(list1, list2);
    }

    private List merge(List left, List right) {
        List result = new ArrayList();
        ListIterator l = new ListIterator(left);
        ListIterator r = new ListIterator(right);
        l.first();
        r.first();
        while (!l.isDone() && !r.isDone()) {
            if (comparator.compare(l.current(), r.current()) <= 0) {
                result.add(l.current());
                l.next();
            } else {
                result.add(r.current());
                r.next();
            }
        }
        while (!l.isDone()) {
            result.add(l.current());
            l.next();
        }
        while (!r.isDone()) {
            result.add(r.current());
            r.next();
        }
        return result;

    }

To test my algorithm I used list of people and sort them ascending by age:
0. Jan, Kowalski, 60
1. Jerzy, Adamczewski, 59
2. Jan, Kowalski, 48
3. Adam, Malysz, 40
4. Bartosz, Tusk, 50
5. Zygmunt, Jacewicz, 41

And the output looks like this:
0. Adam, Malysz, 40
1. Adam, Malysz, 40
2. Adam, Malysz, 40
3. Adam, Malysz, 40
4. Adam, Malysz, 40
5. Adam, Malysz, 40

Answer: This block doesn't look right.
if (startIndex == endIndex) {
    List temp = new ArrayList();
    temp.add(list.get(0));
    return temp;
}

Perhaps, you meant temp.add(list.get(startIndex)); ?
Answer: It seems that you merge function always takes the same smallest elements until the lists are empty. This gives me the impression that there is an issue with your usage of "ListIterator::current()" and "ListIterator::next()".
I am not very proficient with ListIterators, so my proposal is to operate directly on the lists. This also simplifies adding the remaining elements of the two lists after one of them runs out of elements:
private List merge(List left, List right) {
    List result = new LinkedList();

    while (!left.isEmpty() && !right.isEmpty()) {
        if (comparator.compare(left.get(0), right.get(0)) <= 0) {
            result.add(left.remove(0));
        } else {
            result.add(right.remove(0));
        }
    }

    // add what is left in the lists
    result.addAll(left);
    result.addAll(right);

    return result;
}

PS: I didn't check this code in my IDE, so use with care. Ideally you should have tests ready that check your code - TDD is a really good approach that every software developer should follow :)

MergeSort algorithm - java


How can I find choir sheet music?

Question: I am looking for sheet music for a particular song I'd like to sing with my choir.
I tried googling and searching in some online shops but wasn't lucky.

Is there some sort of specialized search engine, or catalog to search for choral sheet music?
--
Sidenote: I am looking for a general answer to the question 'How to search for choir sheet music?' But if anyone happens to know the choir arrangement I'm looking for, I'd be happy of course :-) The song is "Wonderful dream" (aka. Holidays are coming, the song Coca-Cola is using in their Christmas Commercial).
Comment: Well, there's always the option (if you can get ahold of any arrangement) to hire some music major to arrange it for you.  Undergrads are cheap :-)
Comment: The US customer service didn't know what commercial I was talking about. The german customer service did, but they don't have the sheet music available. It was worth a try, nevertheless.
Answer: The song "Wonderful Dream" was written by Melanie Thornton (1967-2001). She was an American singer who had commercial success in Europe while remaining unknown in the USA; most published information about her seems to be from Germany.
I found a vocal solo and piano arrangement published by Hal Leonard. It appears to be out of print from Hal Leonard, but if you click on the link it will take you to the J.W. Pepper music distribution company in the US, which has copies for sale.
It does not appear that there is a published choral arrangement.
I live in the USA, and in this country, if there is a choral arrangement in print, it is highly likely that it will be for sale at jwpepper.com.
Answer: The most extensive site is http://www.cpdl.org . There are also many chorale arrangements on IMSLP (http://www.imslp.org/) but that site also has orchestral, solo, opera, pieces, etc. CPDL is specifically focused on choral music.  What you will not find on either site is most music published in the past 50 years (or since 1923 for American users) since that music is in copyright. For that music you will probably have to purchase it online.
Comment: I know (hence the last two sentences) and thank you for the clarification -- I was trying to answer the main question about centralized databases for finding music and not so much the side note. To be totally pedantic, IMSLP has CC-licensed music in addition to music in the public domain, but most of that musc is by up and coming composers and not major figures.
Comment: CPDL and IMSLP only have music that is in the public domain; broadly speaking, music composed before the year 1920. The song that this questioner is asking about was composed about fifteen years ago, and is under copyright, so it certainly would not appear on CPDL or IMSLP.
Answer: The sheet music with simple guitar chords and the vocal melody are in this link. https://www.musicnotes.com/sheetmusic/mtd.asp?ppn=MN0119679

How can I find choir sheet music?


how do I organize the input fields in fieldset?

Question: I have a node form in Drupal 7, in order to simplify it for the user I want to break it up into sections using the vertical tabs feature.
Using hook_form_FORMID_alter() I can move the fields with difficulty.tha following is my code.:
function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'test_node_form') {
    $form['cpmonth'] = array(
      '#type' => 'fieldset',
      '#title' => t('test'),
      '#weight' => 5,
      '#collapsible' => TRUE,
    );
$form['cpmonth']['field-14sq']=array();
$form['cpmonth']['field-510sq']=array();

  }

}

"field-14sq" and "field-510sq" are my input text fields. Do you have any idea?
Comment: The question is too broad. Changing the form fields of an existing form is not different from creating your own form; the only difference is that the form already exists.
Answer: If I understand correctly you want to move existing form elements into the fieldset you created.  Try this, I'm assuming the fields you want to move are $form['field-14sq'] and $form['field-510sq']
function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'test_node_form') {
    $form['cpmonth'] = array(
      '#type' => 'fieldset',
      '#title' => t('test'),
      '#weight' => 5,
      '#collapsible' => TRUE,
    );
    $form['cpmonth']['field-14sq'] = $form['field-14sq'];
    unset($form['field-14sq']);
    $form['cpmonth']['field-510sq'] = $form['field-510sq'];
    unset($form['field-510sq']);
  }
}

If you have custom submit and validation functions this shouldn't affect them, since fields in fieldsets still come back in the root level of $form_state['values'] .
Answer: what about using the Field Group module Start with creating the node that has the field groups attached to it. Then the each Field Appears like a very cool edit in place feature. It's a cool way of looking at that problem.
Answer: i would print each input individually with something like :
print drupal_render ($form['cpmonth']['field-14sq'])

This way you have lot of flexibility and then can organize your form the way you want.
Although make sure to also print the form ID and tokens to be able to validate the form using that techinc.
print drupal_render($form['form_id']);
print drupal_render($form['form_build_id']);
print drupal_render($user_edit['form_token']);


$G$ finite group, $H \trianglelefteq G$, $\vert H \vert = p$ prime, show $G = HC_G(a)$ $a \in H$

Question: Let $G$ be a finite group. $H \trianglelefteq G$ with $\vert H \vert = p$ the smallest prime dividing $\vert G \vert$. Show $G = HC_G(a)$ with $e \neq a \in H$. $C_G(a)$ is the Centralizer of $a$ in $G$.
To start it off, I know $HC_G(a)\leq G$ by normality of $H$ and subgroup property of $C_G(a)$. So I made the observation that
$\begin{align*} \vert HC_G(a) \vert &= \frac{\vert H \vert \vert C_G(a) \vert}{\vert H \cap C_G(a) \vert}\\&=\frac{\vert H \vert \vert C_G(a) \vert}{\vert C_H(a)\vert}\end{align*}$
But, from here on I never reach the result I'm looking for. Any help would be greatly appreciated!
Note: I posted a similar question earlier, except that one had the index of $H$ being prime, this has the order of $H$ being prime: Link
Comment: You want $a$ to be nonidentity. Also you will in fact just get $G = C_{G}(a)$. Hint for soluton: $a$ has fewer than $p$ conjugates.
Comment: Ok, that makes sense, I also got $\vert HC_G(a) \vert = \vert C_G(a) \vert$. And I see what you mean, it follows that $C(a) = \{a\}$ but that one of the things I'm trying to show after proving this property.
Comment: Well, all conjugates of $a$ are in $H$, so there are less than $p$ of them as $a \neq 1_{G}.$ . On the other hand, their number is $[G:C_{G}(a)]$ which is a divisor of $|G|$. Since $p$ is the smallest prime divisor of $|G|,$ we must have $[G:C_{G}(a)] = 1.$
Answer: Since $N_G(H)/C_G(H)$ injects in $Aut(H)\cong C_{p-1}$ and $p$ is the smallest prime dividing $|G|$, it follows that $N_G(H)=C_G(H)$. But $H$ is normal, so $G=N_G(H)$ and we conclude that $H \subseteq Z(G)$. In particular $G=C_G(a)$ for every $a \in H$.


A specific change of variable, similar to spherical coordinates

Question: Is it possible to get an explicitly formula for the following change of variable (formula for the Jacobian or for the inverse. I would even accept results from mathematica or other software, which I never use and I'm not proficient in).
Let me first introduce the following function $\omega : \left\lbrace \begin{aligned} \mathbb{R}^3 & \longrightarrow \ \mathbb{R}\\ \mathbf{k}\; & \longmapsto  \sqrt{\mathbf{k}^2 + m^2} \end{aligned} \right. $. I'm now considering
$$ \int_{\mathbb{R}^{3\times 3}} \frac{ \varphi\big(\omega(\mathbf{k}_1) + \omega(\mathbf{k}_2) +\omega(\mathbf{k}_3), - \mathbf{k}_1 - \mathbf{k}_2 - \mathbf{k}_3 \big)}{ \omega(\mathbf{k}_1)\hspace{1pt} \omega(\mathbf{k}_2) \hspace{1pt} \omega(\mathbf{k}_3)\, \big[ \big(\omega(\mathbf{k}_1) + \omega(\mathbf{k}_2) + \omega(\mathbf{k}_3) \big)^2 - \omega(\mathbf{k}_1+ \mathbf{k}_2 + \mathbf{k}_3)^2 \big]^2}\, d\mathbf{k}_1\,d\mathbf{k}_2\, d\mathbf{k}_3 $$
where $\varphi$ is a function of 4 variables. It seems natural to consider
$$ \Phi: \left\lbrace \begin{aligned}
 U \subset \mathbb{R}^9
  & \longrightarrow V \subset \mathbb{R}^3 \times [m,+\infty[^3 \times ]0,\pi[^3 \\
 \begin{pmatrix}
  \mathbf{k}_1 \\ \mathbf{k}_2 \\ \mathbf{k}_3
 \end{pmatrix}\
  & \longmapsto
 \begin{pmatrix}
  \mathbf{k} \\ \omega_{\mathbf{k}_1} \\ \omega_{\mathbf{k}_2} \\ \omega_{\mathbf{k}_3}\\ \theta_{12} \\ \theta_{23} \\ \theta_{31}
 \end{pmatrix}
 := \begin{pmatrix}
  \mathbf{k}_1 + \mathbf{k}_2 + \mathbf{k}_3\\
  \omega(\mathbf{k}_1) \\ \omega(\mathbf{k}_2) \\ \omega(\mathbf{k}_3)\\
  \arccos \big( \mathbf{k}_1 \cdot \mathbf{k}_2 \big/ \left\lVert\mathbf{k}_1 \right\rVert \left\lVert\mathbf{k}_2\right\rVert \big)\\
  \arccos\big( \mathbf{k}_2 \cdot \mathbf{k}_3 \big/ \left\lVert\mathbf{k}_2\right\rVert\left\lVert\mathbf{k}_3\right\rVert \big)\\
  \arccos\big( \mathbf{k}_3 \cdot \mathbf{k}_1 \big/ \left\lVert\mathbf{k}_3\right\rVert \left\lVert\mathbf{k}_1\right\rVert \big)
 \end{pmatrix}
 \end{aligned} \right. $$
where $U:= \left\lbrace (\mathbf{k}_1 , \mathbf{k}_2 , \mathbf{k}_3)\in \mathbb{R}^9,\ \operatorname{det}(\mathbf{k}_1 , \mathbf{k}_2 , \mathbf{k}_3) >0 \right\rbrace$ is just half the space and the image $V$ a little complicated.
I'm not entirely sure this a $\mathcal{C}^1$-diffeomorphism. The Jacobian looks like
$$ \begin{vmatrix}
 1 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 \\
 0 & 1 & 0 & 0 & 1 & 0 & 0 & 1 & 0 \\
 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 1 \\
 k_1^1 / \omega_{\mathbf{k}_1} & k_1^2 / \omega_{\mathbf{k}_1} & k_1^3 / \omega_{\mathbf{k}_1} & 0 & 0 & 0 & 0 & 0 & 0\\
 0 & 0 & 0 & k_2^1 / \omega_{\mathbf{k}_2} & k_2^2 / \omega_{\mathbf{k}_2} & k_2^3 / \omega_{\mathbf{k}_2} & 0 & 0 & 0\\
 0 & 0 & 0 & 0 & 0 & 0 & k_3^1 / \omega_{\mathbf{k}_3} & k_3^2 / \omega_{\mathbf{k}_3} & k_3^3 / \omega_{\mathbf{k}_3} \\
 \frac{\cos \theta_{12}\hspace{.8pt} \frac{k_1^1}{\lVert\mathbf{k}_1\rVert}- \frac{k_2^1}{\lVert\mathbf{k}_2\rVert}}{\lVert\mathbf{k}_1\rVert\, \sin \theta_{12}} & ''
 %\frac{\cos \theta_{12}\, \frac{k_1^2}{\norm{\mathbf{k}_1}}- \frac{k_2^2}{\norm{\mathbf{k}_2}}}{\norm{\mathbf{k}_1} \sin \theta_{12}}
 & ''
 % \frac{\cos \theta_{12}\, \frac{k_1^3}{\norm{\mathbf{k}_1}}- \frac{k_2^3}{\norm{\mathbf{k}_2}}}{\norm{\mathbf{k}_1} \sin \theta_{12}}
 & 0 & 0 & 0 & 0 & 0 & 0\\
 0 & 0 & 0 & \frac{\cos \theta_{23}\hspace{.8pt} \frac{k_2^1}{\lVert\mathbf{k}_2\rVert}- \frac{k_3^1}{\lVert\mathbf{k}_3\rVert}}{\lVert\mathbf{k}_2\rVert\, \sin \theta_{23}} & '' & '' & 0 & 0 & 0\\
 0 & 0 & 0 & 0 & 0 & 0 & \frac{\cos \theta_{31}\hspace{.8pt} \frac{k_3^1}{\lVert\mathbf{k}_3\rVert}- \frac{k_1^1}{\lVert\mathbf{k}_1\rVert}}{\lVert\mathbf{k}_3\rVert\, \sin \theta_{31}} & '' & ''
 \end{vmatrix}$$
where $''$ stands for similar and not identical and where I used the convention from physics that $k^i_j$ is the $i^{\text{th}}$-component of $\mathbf{k}_j$ and not something to the power $i$.
Answer: Finally I get
$$\operatorname{det}\,\left( \mathrm{d}\Phi \right) = \frac{\operatorname{det}^2\big(\mathbf{k}_1 , \mathbf{k}_2 , \mathbf{k}_3\big)}{\omega_{\mathbf{k}_1}\,\omega_{\mathbf{k}_2}\,\omega_{\mathbf{k}_3}\, \lVert\mathbf{k}_1\rVert^2\hspace{.9pt}\lVert\mathbf{k}_2\rVert^2 \hspace{.9pt}\lVert\mathbf{k}_3\rVert^2\sin \theta_{12}\, \sin \theta_{23}\, \sin \theta_{31}}$$
and I suspect the determinant is exactly the product norm of $\mathbf{k}_i \times \sin \theta_{ij}$. Here are the details of my calculations. One could in fact simplify further before introducing the $\Delta_{99}$.

1) Determinant: let us denote it $J_{\Phi}$. By line operations, we obtain
$$ J_{\Phi} = \begin{vmatrix}
 1 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 \\
 0 & 1 & 0 & 0 & 1 & 0 & 0 & 1 & 0 \\
 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 1 \\
 0 & 0 & 0 & - k_1^1 / \omega_{\mathbf{k}_1} & - k_1^2 / \omega_{\mathbf{k}_1} & - k_1^3 / \omega_{\mathbf{k}_1} & - k_1^1 / \omega_{\mathbf{k}_1} & - k_1^2 / \omega_{\mathbf{k}_1} & - k_1^3 / \omega_{\mathbf{k}_1}\\
 0 & 0 & 0 & k_2^1 / \omega_{\mathbf{k}_2} & k_2^2 / \omega_{\mathbf{k}_2} & k_2^3 / \omega_{\mathbf{k}_2} & 0 & 0 & 0\\
 0 & 0 & 0 & 0 & 0 & 0 & k_3^1 / \omega_{\mathbf{k}_3} & k_3^2 / \omega_{\mathbf{k}_3} & k_3^3 / \omega_{\mathbf{k}_3} \\
 0 & 0 & 0 & \frac{\frac{k_2^1}{\lVert\mathbf{k}_2\rVert} -  \cos \theta_{12}\hspace{.8pt} \frac{k_1^1}{\lVert\mathbf{k}_1\rVert}}{\lVert\mathbf{k}_1\rVert\, \sin \theta_{12}} & '' & '' & \frac{\frac{k_2^1}{\lVert\mathbf{k}_2\rVert} -  \cos \theta_{12}\hspace{.8pt} \frac{k_1^1}{\lVert\mathbf{k}_1\rVert}}{\lVert\mathbf{k}_1\rVert\, \sin \theta_{12}} & '' & ''\\
 0 & 0 & 0 & \frac{\cos \theta_{23}\hspace{.8pt} \frac{k_2^1}{\lVert\mathbf{k}_2\rVert}- \frac{k_3^1}{\lVert\mathbf{k}_3\rVert}}{\lVert\mathbf{k}_2\rVert\, \sin \theta_{23}} & '' & '' & 0 & 0 & 0\\
 0 & 0 & 0 & 0 & 0 & 0 & \frac{\cos \theta_{31}\hspace{.8pt} \frac{k_3^1}{\lVert\mathbf{k}_3\rVert}- \frac{k_1^1}{\lVert\mathbf{k}_1\rVert}}{\lVert\mathbf{k}_3\rVert\, \sin \theta_{31}} & '' & ''
 \end{vmatrix} \\
 $$
Develop w.r.t the last line, denoting $\Delta_{ij}$ appropriate minor
$$J_{\Phi} = \frac{\cos \theta_{31}\hspace{.8pt} \frac{k_3^3}{\lVert\mathbf{k}_3\rVert}- \frac{k_1^3}{\lVert\mathbf{k}_1\rVert}}{\lVert\mathbf{k}_3\rVert\, \sin \theta_{31}}\, \Delta_{99} - \frac{\cos \theta_{31}\hspace{.8pt} \frac{k_3^2}{\lVert\mathbf{k}_3\rVert}- \frac{k_1^2}{\lVert\mathbf{k}_1\rVert}}{\lVert\mathbf{k}_3\rVert\, \sin \theta_{31}}\, \Delta_{98} + \frac{\cos \theta_{31}\hspace{.8pt} \frac{k_3^1}{\lVert\mathbf{k}_3\rVert}- \frac{k_1^1}{\lVert\mathbf{k}_1\rVert}}{\lVert\mathbf{k}_3\rVert\, \sin \theta_{31}}\, \Delta_{97}$$
Now
$$ \Delta_{99} = \begin{vmatrix}
 - k_1^1 / \omega_{\mathbf{k}_1} & - k_1^2 / \omega_{\mathbf{k}_1} & - k_1^3 / \omega_{\mathbf{k}_1} & - k_1^1 / \omega_{\mathbf{k}_1} & - k_1^2 / \omega_{\mathbf{k}_1} \\
 k_2^1 / \omega_{\mathbf{k}_2} & k_2^2 / \omega_{\mathbf{k}_2} & k_2^3 / \omega_{\mathbf{k}_2} & 0 & 0 \\
 0 & 0 & 0 & k_3^1 / \omega_{\mathbf{k}_3} & k_3^2 / \omega_{\mathbf{k}_3} \\
 \frac{\frac{k_2^1}{\lVert\mathbf{k}_2\rVert} -  \frac{\cos \theta_{12}\hspace{.8pt} k_1^1}{\lVert\mathbf{k}_1\rVert}}{\lVert\mathbf{k}_1\rVert\, \sin \theta_{12}} & \frac{\frac{k_2^2}{\lVert\mathbf{k}_2\rVert} -  \frac{\cos \theta_{12}\hspace{.8pt}  k_1^2}{\lVert\mathbf{k}_1\rVert}}{\lVert\mathbf{k}_1\rVert\, \sin \theta_{12}} & \frac{\frac{k_2^3}{\lVert\mathbf{k}_2\rVert} -  \frac{\cos \theta_{12}\hspace{.8pt} k_1^3}{\lVert\mathbf{k}_1\rVert}}{\lVert\mathbf{k}_1\rVert\, \sin \theta_{12}} & \frac{\frac{k_2^1}{\lVert\mathbf{k}_2\rVert} -  \frac{ \cos \theta_{12}\hspace{.8pt} k_1^1}{\lVert\mathbf{k}_1\rVert}}{\lVert\mathbf{k}_1\rVert\, \sin \theta_{12}} & \frac{\frac{k_2^2}{\lVert\mathbf{k}_2\rVert} - \frac{\cos \theta_{12}\hspace{.8pt}  k_1^2}{\lVert\mathbf{k}_1\rVert}}{\lVert\mathbf{k}_1\rVert\, \sin \theta_{12}} \\
 \frac{\frac{\cos \theta_{23}\hspace{.8pt}  k_2^1}{\lVert\mathbf{k}_2\rVert}- \frac{k_3^1}{\lVert\mathbf{k}_3\rVert}}{\lVert\mathbf{k}_2\rVert\, \sin \theta_{23}} & \frac{\frac{\cos \theta_{23}\hspace{.8pt}  k_2^2}{\lVert\mathbf{k}_2\rVert}- \frac{k_3^2}{\lVert\mathbf{k}_3\rVert}}{\lVert\mathbf{k}_2\rVert\, \sin \theta_{23}} & \frac{ \frac{\cos \theta_{23}\hspace{.8pt} k_2^3}{\lVert\mathbf{k}_2\rVert}- \frac{k_3^3}{\lVert\mathbf{k}_3\rVert}}{\lVert\mathbf{k}_2\rVert\, \sin \theta_{23}} & 0 & 0
 \end{vmatrix}$$
Let us factorize what can be factorized and develop it w.r.t. the third line
$$ \begin{split}
\Delta_{99} & = \frac{1}{\omega_{\mathbf{k}_3}\,\omega_{\mathbf{k}_1}\,\omega_{\mathbf{k}_2} \lVert\mathbf{k}_1\rVert \sin \theta_{12}\, \lVert\mathbf{k}_2\rVert \sin \theta_{23}}\, \times \Bigg( \\
 &\enspace k_3^2\,\begin{vmatrix}
 - k_1^1  & - k_1^2  & - k_1^3  & - k_1^1   \\
 k_2^1  & k_2^2  & k_2^3  & 0 \\
 \frac{k_2^1}{\lVert\mathbf{k}_2\rVert} -  \frac{\cos \theta_{12}\hspace{.8pt} k_1^1}{\lVert\mathbf{k}_1\rVert} & \frac{k_2^2}{\lVert\mathbf{k}_2\rVert} -  \frac{\cos \theta_{12}\hspace{.8pt}  k_1^2}{\lVert\mathbf{k}_1\rVert} & \frac{k_2^3}{\lVert\mathbf{k}_2\rVert} -  \frac{\cos \theta_{12}\hspace{.8pt} k_1^3}{\lVert\mathbf{k}_1\rVert} & \frac{k_2^1}{\lVert\mathbf{k}_2\rVert} -  \frac{ \cos \theta_{12}\hspace{.8pt} k_1^1}{\lVert\mathbf{k}_1\rVert}\\
 \frac{\cos \theta_{23}\hspace{.8pt}  k_2^1}{\lVert\mathbf{k}_2\rVert}- \frac{k_3^1}{\lVert\mathbf{k}_3\rVert} & \frac{\cos \theta_{23}\hspace{.8pt}  k_2^2}{\lVert\mathbf{k}_2\rVert}- \frac{k_3^2}{\lVert\mathbf{k}_3\rVert} &  \frac{\cos \theta_{23}\hspace{.8pt} k_2^3}{\lVert\mathbf{k}_2\rVert}- \frac{k_3^3}{\lVert\mathbf{k}_3\rVert} & 0
 \end{vmatrix} \\
&\enspace - k_3^1\,\begin{vmatrix}
 - k_1^1  & - k_1^2  & - k_1^3  & - k_1^2   \\
 k_2^1  & k_2^2  & k_2^3  & 0 \\
 \frac{k_2^1}{\lVert\mathbf{k}_2\rVert} -  \frac{\cos \theta_{12}\hspace{.8pt} k_1^1}{\lVert\mathbf{k}_1\rVert} & \frac{k_2^2}{\lVert\mathbf{k}_2\rVert} -  \frac{\cos \theta_{12}\hspace{.8pt}  k_1^2}{\lVert\mathbf{k}_1\rVert} & \frac{k_2^3}{\lVert\mathbf{k}_2\rVert} -  \frac{\cos \theta_{12}\hspace{.8pt} k_1^3}{\lVert\mathbf{k}_1\rVert} & \frac{k_2^2}{\lVert\mathbf{k}_2\rVert} -  \frac{ \cos \theta_{12}\hspace{.8pt} k_1^2}{\lVert\mathbf{k}_1\rVert}\\
 \frac{\cos \theta_{23}\hspace{.8pt}  k_2^1}{\lVert\mathbf{k}_2\rVert}- \frac{k_3^1}{\lVert\mathbf{k}_3\rVert} & \frac{\cos \theta_{23}\hspace{.8pt}  k_2^2}{\lVert\mathbf{k}_2\rVert}- \frac{k_3^2}{\lVert\mathbf{k}_3\rVert} &  \frac{\cos \theta_{23}\hspace{.8pt} k_2^3}{\lVert\mathbf{k}_2\rVert}- \frac{k_3^3}{\lVert\mathbf{k}_3\rVert} & 0
 \end{vmatrix} \Bigg)
\end{split}$$
We use again line operations to cancel what can be cancelled:
$$ \begin{split}
\Delta_{99} & = \frac{1}{\omega_{\mathbf{k}_3}\,\omega_{\mathbf{k}_1}\,\omega_{\mathbf{k}_2} \lVert\mathbf{k}_1\rVert \sin \theta_{12}\, \lVert\mathbf{k}_2\rVert \sin \theta_{23}}\, \times \\
 &\enspace \left( - k_3^2\,\begin{vmatrix}
 k_1^1  &  k_1^2  &  k_1^3  &  k_1^1   \\
 k_2^1  & k_2^2  & k_2^3  & 0 \\
 0 & 0 & 0 & \frac{k_2^1}{\lVert\mathbf{k}_2\rVert} \\
 - \frac{k_3^1}{\lVert\mathbf{k}_3\rVert} & - \frac{k_3^2}{\lVert\mathbf{k}_3\rVert} &  - \frac{k_3^3}{\lVert\mathbf{k}_3\rVert} & 0
 \end{vmatrix} + k_3^1\,\begin{vmatrix}
 k_1^1  & k_1^2  & k_1^3  &  k_1^2   \\
 k_2^1  & k_2^2  & k_2^3  & 0 \\
 0 & 0 & 0& \frac{k_2^2}{\lVert\mathbf{k}_2\rVert} \\
 - \frac{k_3^1}{\lVert\mathbf{k}_3\rVert} & - \frac{k_3^2}{\lVert\mathbf{k}_3\rVert} &  - \frac{k_3^3}{\lVert\mathbf{k}_3\rVert} & 0
 \end{vmatrix} \right)\\
 & = \frac{1}{\omega_{\mathbf{k}_3}\,\omega_{\mathbf{k}_1}\,\omega_{\mathbf{k}_2} \lVert\mathbf{k}_1\rVert \sin \theta_{12}\, \lVert\mathbf{k}_2\rVert \sin \theta_{23}}\, \left( \frac{- k_3^2\, k_2^1}{\lVert\mathbf{k}_2\rVert \lVert\mathbf{k}_3\rVert} \operatorname{det}(\mathbf{k}_1,\mathbf{k}_2,\mathbf{k}_3) + \frac{ k_3^1\, k_2^2}{\lVert\mathbf{k}_2\rVert \lVert\mathbf{k}_3\rVert} \operatorname{det}(\mathbf{k}_1,\mathbf{k}_2,\mathbf{k}_3)  \right)
\end{split}$$
I also wonder if one could find a useful interpretation for the factor $\cos \theta_{31}\hspace{.8pt} \frac{k_3^3}{\lVert\mathbf{k}_3\rVert}- \frac{k_1^3}{\lVert\mathbf{k}_1\rVert}$...

2) Inverse: in the plane, if one knows the length of the 3 sides of a triangle than the triangle is known. Setting arbitrarily that one vertex is 0 and one side correspond to the (Ox) axis, one could calculate the sum of the vectors going from (O) to the vertices. We just have to do this on the sphere $S^2$, the role of length being played by the $\theta_{ij}$.
I tried doing this explicitly but it seems really too tedious... Assume $\mathbf{k}_1$ is along the (Oz) axis and $\mathbf{k}_2$ is in the (Ozx) plane. The intersection of the circle with "radius" $\theta_{23}$ around $\frac{\mathbf{k}_2}{\lVert \mathbf{k}_2\rVert}$ with the circle of "radius" $\theta_{31}$ around $\frac{\mathbf{k}_1}{\lVert \mathbf{k}_1\rVert}$ (on the surface of the sphere of radius 1) is given by
\begin{equation}
 \begin{pmatrix}
 \cos \theta_{12} & 0 & \sin \theta_{12} \\
 0 & 1 & 0 \\
 -\sin \theta_{12} & 0 & \cos \theta_{12}
 \end{pmatrix} \cdot \begin{pmatrix}
 r \sin \theta_{23}\, \cos \tau\\
 r \sin \theta_{23}\, \sin \tau\\
 r \cos \theta_{23}
 \end{pmatrix}
 = \begin{pmatrix}
 r \big(\cos  \theta_{12}\, \sin \theta_{23}\, \cos \tau + \sin \theta_{12}\, \cos \theta_{23}\big)\\
 r \sin \theta_{23}\, \sin \tau\\
 r \big(-\sin \theta_{12}\, \sin \theta_{23}\, \cos \tau + \cos\theta_{12}\, \cos \theta_{23}\big)
 \end{pmatrix}
 \overset{!}{=}
 \begin{pmatrix}
 r \sin \theta_{31}\, \cos \varphi\\
 r \sin \theta_{31}\, \sin \varphi\\
 r \cos \theta_{31}
 \end{pmatrix}
 \end{equation}
I want to find $\varphi$ (azimutal angle as named by wikipedia) as a function of $\big(\theta_{12}, \theta_{23}, \theta_{31}\big)$. Auxiliary variable $\tau \in ]0,\pi[$ determined by the fact the two first component lie in a circle of radius squared $r^2 \sin^2 \theta_{31}$
$
% r\big(\cos  \theta_{12}\, \sin \theta_{23}\, \cos \tau + \sin \theta_{12}\, \cos \theta_{23}\big)^2 + \sin^2 \theta_{23}\, \sin^2 \tau  \overset{!}{=} \sin^2 \theta_{31}
% \cos^2  \theta_{12}\, \sin^2 \theta_{23}\, \cos^2 \tau + 2\, \cos  \theta_{12}\, \sin \theta_{23}\, \cos \tau \sin \theta_{12}\, \cos \theta_{23} + \sin^2 \theta_{12}\, \cos^2 \theta_{23} + \sin^2 \theta_{23}\, \sin^2 \tau  \overset{!}{=} \sin^2 \theta_{31}
$
Carrying on calculation without much care about existence etc. we find
$
% \frac{\Delta}{4} &= \cos^2 \theta_{12}\, \sin^2 \theta_{23}\, \sin^2 \theta_{12}\, \cos^2 \theta_{23} - \big(\cos^2  \theta_{12}-1 \big) \sin^2 \theta_{23} \Klammer{\sin^2 \theta_{12}\, \cos^2 \theta_{23} + \sin^2 \theta_{23} - \sin^2 \theta_{31}} \\
% & =  \sin^2 \theta_{12}\, \sin^2 \theta_{23} \Klammer{ \cos^2 \theta_{12}\, \cos^2 \theta_{23} - \sin^2 \theta_{12}\, \cos^2 \theta_{23} - \sin^2 \theta_{23} + \sin^2 \theta_{31} } \\
% & = \sin^2 \theta_{12}\, \sin^2 \theta_{23} \Klammer{ \cos \big(2 \theta_{12}\big) \cos^2 \theta_{23} - \sin^2 \theta_{23} + \sin^2 \theta_{31} }
 $
$$
 \cos \tau %& = \frac{-2\, \cos  \theta_{12}\, \sin \theta_{23}\, \sin \theta_{12}\, \cos \theta_{23} \pm \sin \theta_{12}\, \sin \theta_{23} \sqrt{ \cos \big(2 \theta_{12}\big) \cos^2 \theta_{23} - \sin^2 \theta_{23} + \sin^2 \theta_{31} }}{2 \, \sin^2  \theta_{12} \, \sin^2 \theta_{23}}
  = \frac{-2\, \cos  \theta_{12}\, \cos \theta_{23} \pm \sqrt{ \cos \big(2 \theta_{12}\big) \cos^2 \theta_{23} - \sin^2 \theta_{23} + \sin^2 \theta_{31} }}{2 \, \sin \theta_{12} \, \sin \theta_{23}}
 $$
...
Assuming that we have obtained our three vertices $\frac{\tilde{\mathbf{k}}_i}{\lVert\tilde{\mathbf{k}}_i\rVert}$, we have to multiply them by their norm (given by the $\omega_{\mathbf{k}}$) and determine the rotation that brings $\tilde{\mathbf{k}}_1 + \tilde{\mathbf{k}}_2 + \tilde{\mathbf{k}}_3$ to the sum which was denoted $\mathbf{k}$...
Ok, I stop here, it becomes nonsense