Are there vocal exercises that can be done through the course of the day while doing other things?

Question: I'm a computer science student and I spend a big part of my day sitting in a classroom or typing at a computer. I like to sing and play instruments as a hobby, but it's not always that I have time to stop everything and just practice.
So I'm asking for suggestions of vocal exercises that can be done on a regular basis, while sitting down. What I'm trying at the moment are some breathing exercises that I learned from the brief period that I took singing lessons.
Answer: Well, you probably don't want to actually make sounds, so here are two exercises that will help without that:
Proper posture:
Sit up.  There should be a vertical line running through your head, neck, chest, and butt. (your spine is supposed to curve, so let that happen naturally).
Proper breathing:
I've been taught to use "yoga breaths" while singing--that is, keep your chest high, and take deep breaths, such that the only moving part of your body is your stomach.  At the same time, make sure that your airway is completely relaxed, without any tension.  If in the off chance you are alone in a sound-proof room, you can take that opportunity to practice singing with these breaths and without tensing up.  It's hard to do!
EDIT:
I should probably clarify that these exercises were taught to me for the purpose of learning how to sing in a choir.  If you're trying to sing in a death-metal band, it might not be for you, and you should probably wait for more applicable advice.
Also, some more exercises:
Easy Onset:
The idea is to avoid glottal strokes (this video explains a glottal stop; a glottal stroke is the same concept, but at the beginning of the sound formation.

). To do this, waste air.  Take a deep yoga breath, and establish airflow across your vocal cords before letting them vibrate.  I tend to relate this to using the clutch on a stick-shift car.
Pharyngeal space:
Opera singers, especially basses, have a crazily dark vocal quality.  How do they do this?  They increase their vocal resonance by increasing their pharyngeal space.  To put it simply nearly to the point of incorrectness, the pharynx is the back of your throat, starting from about where the roof of your mouth goes squishy.  You can consciously raise the squishy roof of your mouth (a.k.a. your soft palate) and drop the base of your tongue to increase the resonance of your voice.  It requires some fairly infrequently used muscles, so you'll have to build some musculature.
Comment: Actually sometimes it's ok to make sounds. For example when I'm sitting alone in my room.
Comment: I really liked the advice, even if it's a little more general then what I expected. I've been trying doing this and I think it's helping me get the airflow right when I'm going to sing "for real". I wish I could get more answers here, but I guess this question was too specific.
Comment: I'm shocked that you didn't get more answers.  I guess we just don't have that many vocalists on this site.
Answer: It's been a long time since I asked this and since I've learned many more exercises for the purpose of singing. Here are some that can be done while sitting down through the course of the day:

Like Babu explains in his answer, try to keep a good posture and use diaphragmatic breathing.
Set a period of time, say 10 seconds. Breath in for 10 seconds, hold your breath without tensing the throat or other upper muscles for 10 seconds, release the air in 10 seconds. Try to do everything without making noises and very softly as to not tense. Vary the time period as you become more comfortable.
Take big gulps of air during 10 or 15 seconds and release it slowly in 30-45 seconds.  You may feel out of breath for a few seconds after finishing, just breath normally until you feel normal again. The focus here as with the last exercise is to internalize how this breathing feels and enhance your breathing capacity.
If it's okay to make a little bit of noise hum notes through your range very quietly and try to keep them going for as long as you can without them sound "creaky" or "breaking". This is good for warming up or relaxing when your voice doesnt feel so good. (Reference video)
This is a more psychological one, but here we go. If during the day you think of yourself as a student (or employee) with a singing hobby try to reverse the logic and think of yourself as a singer with a day job. Treat your body and your voice as if your livelihood depended on it. Speak softly, don't sit with a bad posture, drink lots of water, stretch from time to time, etc... This is taken from The Rock 'n Roll Singer Survival Manual

These work for me and I use some variations of them when I spend lot's of time sitting at work or at home, I encourage you to try.


Is there a way to do multiple "sed" at once in bash?

Question: So I am looking to edit a number of bits of a file prior to using it as an input file for model simulations. At the moment I am passing it back and forth between a couple of temporary files (it was a bit buggy when I tried to write to the same temporary file) before finally making a file I can use to run the model. Is there a way to get all this alterations made simultaneously? I reckon doing it the way I am now is probably quite inefficient. Example of code below:
sed -e "s/9000000.0/${naerval}/" MC_NAMELIST_Pin14_Run3.IN > /tmp/temp1.in
                #sed is away to change a string in a text file
sed -e "s/8000000.0/${sig_aer}/" /tmp/temp1.in > /tmp/temp2.in

sed -e "s/7000000.0/${d_aer}/" /tmp/temp2.in > /tmp/temp1.in

sed -e "s/6000000.0/${t_twall}/" /tmp/temp1.in > /tmp/temp2.in

sed -e "s/5000000.0/${RH}/" /tmp/temp2.in > /tmp/temp1.in

sed -e "s/4000000.0/${Therm_Coeff}/" /tmp/temp1.in > /tmp/temp2.in

sed -e "s/3000000.0/${press_decay}/" /tmp/temp2.in > /tmp/temp1.in

sed -e "s/2000000.0/${kappa}/" /tmp/temp1.in > /tmp/NAMELIST.IN

./main.exe /tmp/NAMELIST.IN

I have additionally attempted replacing this code with:
sed -i.bak s~9000000.0~${naerval}~;s~8000000.0~${sig_aer}~;s~7000000.0~${d_aer}~;s~6000000.0~${t_twall}~;s~5000000.0~${RH}~;s~4000000.0~${Therm_Coeff}~;s~3000000.0~${press_decay}~;s~2000000.0~${kappa}~;" MC_NAMELIST_Pin14_Run3.IN > /tmp/NAMELIST.IN

./main.exe /tmp/NAMELIST.IN

However, this causes an error in main.exe while the original code does not. I assume therefore that this code does not alter MC_NAMELIST_Pin14_Run3.IN in the expected way.
Comment: Definitely looks that way, I didn't find it when I went hunting for it though. Baybe it needs a retitle/retag? In fairness I'm finding the answer to that question pretty difficult to read probably because of the example being given.
Comment: I found it using a well-known search engine but I'm surprised it didn't come up when you were writing the question. It's possibly not the best duplicate, I'm sure there are several. Anyway, it looks like the answers there are in agreement with what you have here.
Comment: Interesting: best guess you're doing better at searching for this kind of stuff than a rank beginner, that seems plausible. Maybe it's because I was searching for bash?
Comment: For the record, my search was "sed multiple commands".
Answer: You can combine several sed commands like this:
sed -i.bak "s/9000000.0/${naerval}/; s/8000000.0/${sig_aer}/" /tmp/temp1.in

i.bak will enable inline editing and save original file with .bak extension
Keep in mind that your replacement strings cannot create a slash or new line.

You can use an alternate delimiter like this:
sed -i.bak "s~9000000.0~${naerval}~; s~8000000.0~${sig_aer}~" /tmp/temp1.in

Comment: And create a backup of the original file as `/tmp/temp1.in.bak`
Comment: Sorry, I'm not that good at programming so please bear with me. Will this save to the file /tmp/temp1.in or will it save to i.bak (presumably in the current directory)?
Comment: It will save the replaced data in `/tmp/temp1.in` itself.
Comment: Yes that is correct, it saves a backup with the name: `/tmp/temp1.in.bak`
Comment: I'm going to let the current run finish and then I'll try it out.
Comment: Not yet... hitting error messages.
Comment: That is very informative. What errors you're getting?
Comment: The model runs with the original code, with the new code I get: "At line 54 of file MAIN.f90 (unit = 8, file = '/tmp/NAMELIST.IN')"

I may not have applied the suggested solution correctly. I replaced the code in the question (apart from the last line) as follows:"sed -i.bak "s~9000000.0~${naerval}~; s~8000000.0~${sig_aer}~;s~7000000.0~${d_aer}~;s~6000000.0~${t_twall}~;s~5000000.0~${RH}~;s~4000000.0~${Therm_Coeff}~;s~3000000.0~${press_decay}~;s~2000000.0~${kappa}~;" MC_NAMELIST_Pin14_Run3.IN > /tmp/NAMELIST.IN"
Comment: I don't know how to make it look like code in a comment so the outer "" are not in the code. Thought it was worth clearing that up. I've set the next run going so there will be a 4 hour lag time between now and my being able to do anything again.
Comment: You can edit your question add this attempted code with formatting.
Comment: I've managed to get this to work if I put it all in the one line and use "sed -e" but if I try "sed -i.bak" it never runs.
Comment: Probably your sed version is old and not supporting inline editing option. If it worked out then you mark the answer as accepted by clicking the tick mark on left side of my answer.
Answer:
At the moment I am passing it back and forth between a couple of temporary files

Writing and reading all those temp files is crazy, that's what pipes are for!
sed -e "s/9000000.0/${naerval}/" MC_NAMELIST_Pin14_Run3.IN | \
sed -e "s/8000000.0/${sig_aer}/" | \
sed -e "s/7000000.0/${d_aer}/" | etc.

But you can combine all the edits into one sed invocation with multiple scripts, preceding each one with -e:
sed -e "s/9000000.0/${naerval}/" -e "s/8000000.0/${sig_aer}/" -e "s/7000000.0/${d_aer}/" -e etc. etc. MC_NAMELIST_Pin14_Run3.IN > /tmp/NAMELIST.IN

Or as a single script with many commands, separated by semi-colons:
sed -e "s/9000000.0/${naerval}/;s/8000000.0/${sig_aer}/;s/7000000.0/${d_aer}/;..." MC_NAMELIST_Pin14_Run3.IN > /tmp/NAMELIST.IN

Comment: I don't think there's any advantage to the method using pipes.
Comment: @TomFenech it demonstrates how to combine the output from several commands instead of using temp files. In this case it isn't needed but if the filters are not all using `sed` then it's useful, and much better than temp files.
Comment: Yes, fair point about combining different commands.
Answer: Try something like:
sed -i.bak -e 's/9000000.0/${naerval}/' -e 's/8000000.0/${sig_aer}/' MC_NAMELIST_Pin14_Run3.IN


Unable to build Xcode project in iOS simulator

Question: I wrote an app for visionOS and I decided I want to add iOS and iPadOS support for the app. I added iPad and iPhone for supported destinations, but when I try to build it via the iPhone or iPad simulator, I get error:

Building for 'iphonesimulator', but realitytool only supports [xros, xrsimulator]

Nothing in my code is specific to visionOS and I can't see anything mentioning realitytool. I've tried messing around with build architecture settings, but nothing seems to work.
Comment: Have you got any assets that may depend on realitytools ?
Answer: I faced the same issue when trying to port a visionOS-only app to iPhone and iPad. This is because you need to modify the build phases of your target so that it only loads RealityKitContent when on visionOS, not on iOS. Here's how to fix it:

Click on the root of your project in the project navigator.
Go to your target.
Go to the "Frameworks, Libraries, and Embedded Content".
On the "RealityKitContent" row, click on the filters icon next to "Always Used", uncheck "All Platforms" and check only "visionOS".

Next, you'll likely have different build errors, like "No such module 'RealityKitContent'". To fix this, you'll want to replace the import statement from
import RealityKitContent

to
#if os(visionOS)
import RealityKitContent
#endif

Comment: Not working for me, and also getting 'None of the input catalogs contained a matching stickers icon set or app icon set named  "AppIcon"' even when there's an AppIcon
Comment: I had the same issue. It's because the visionOS AppIcon asset is different than the iOS AppIcon one. Go to Assets > + > iOS > iOS App Icon. That fixed it for me.
Comment: Thank you @benb. You are right, adding the iOS App Icon solves this particular issue, but unfortunately still complaining about the RealityKit even after following your steps. Only creating a separate target worked for me by now.
Answer: @benb suggestion makes totally sense, but it seems there're are still some bugs here. According to this thread, this block:
import SwiftUI
#if os(visionOS)
import RealityKit
import RealityKitContent
#endif

May be incorrectly parsed, and apparently adding an extra line break might help:
import SwiftUI

#if os(visionOS)
import RealityKit
import RealityKitContent
#endif

But even with the extra line break, I needed to create a separate target for iOS (the #if directive is still needed, though).


The multi-part identifier could not be bound(SQl Server 2005)

Question: Her is the query
SELECT NX.FileId, NX.SheetName, NX.SubmitId, NX.SubmitTimeA, NX.UpdateTimeA, NX.UpdateUserId, NX.FileSubmitId, NX.Tags, NX.UserId, NX.FileName, NX.UpdateFirstName, NX.UpdateLastName,  NX.NG, NX.Complete, NX.FirstName, NX.LastName
                                        FROM(
                                             SELECT X.FileId, X.SheetName, X.SubmitId, X.SubmitTimeA, X.UpdateTimeA, X.UpdateUserId, X.FileSubmitId, X.Tags, X.UserId, X.FileName, X.FirstName AS UpdateFirstName, X.LastName AS UpdateLastName, X.NG, X.Complete,  U.FirstName, U.LastName
                                             FROM(
                                                  SELECT SS.FileId, SS.SheetName, SS.SubmitId, SS.SubmitTimeA, SS.UpdateTimeA, SS.UpdateUserId, SS.FileSubmitId, SS.Tags, SS.UserId, SS.FileName, SS.NG, SS.Complete, US.FirstName, US.LastName
                                                  FROM SubmitSheets AS SS
                                                  Left Join Users as US
                                                  ON  SS.UpdateUserId =  US.UserId
                                             ) as X
                                             Left Join Users As U
                                             On X.UserId = U.UserId
                                        ) AS NX
                                        INNER JOIN Files AS F
                                        ON NX.FileId=F.FileId
                                        WHERE F.Locked =0 AND 1=1 AND 1=1 AND 1=1 AND NX.UpdateTimeA >= Cast('2014/10/30'as datetime) AND NX.UpdateTimeA < DateAdd("d", 1, Cast('2014/10/31'as datetime)) AND (1=1) AND SS.Complete=1 OR SS.NG=1
                                        ORDER BY NX.UpdateTimeA DESC

Here is the error
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "SS.Complete" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "SS.NG" could not be bound.

Type of NG and Complete field is "bit"
Comment: @wewesthemenace : No, it didn't worked... the respective inner query is working fine separately..
Answer: Try replacing SS.Complete and SS.NG with NX.Complete and NX.NG respectively in the WHERE clause.
SELECT NX.FileId, NX.SheetName, NX.SubmitId, NX.SubmitTimeA, NX.UpdateTimeA, NX.UpdateUserId, NX.FileSubmitId, NX.Tags, NX.UserId, NX.FileName, NX.UpdateFirstName, NX.UpdateLastName,  NX.NG, NX.Complete, NX.FirstName, NX.LastName
FROM(
     SELECT X.FileId, X.SheetName, X.SubmitId, X.SubmitTimeA, X.UpdateTimeA, X.UpdateUserId, X.FileSubmitId, X.Tags, X.UserId, X.FileName, X.FirstName AS UpdateFirstName, X.LastName AS UpdateLastName, X.NG, X.Complete,  U.FirstName, U.LastName
     FROM(
          SELECT SS.FileId, SS.SheetName, SS.SubmitId, SS.SubmitTimeA, SS.UpdateTimeA, SS.UpdateUserId, SS.FileSubmitId, SS.Tags, SS.UserId, SS.FileName, SS.NG, SS.Complete, US.FirstName, US.LastName
          FROM SubmitSheets AS SS
          Left Join Users as US
          ON  SS.UpdateUserId =  US.UserId
     ) as X
     Left Join Users As U
     On X.UserId = U.UserId
) AS NX
INNER JOIN Files AS F
ON NX.FileId=F.FileId
WHERE F.Locked =0 AND 1=1 AND 1=1 AND 1=1 AND NX.UpdateTimeA >= Cast('2014/10/30'as datetime) AND NX.UpdateTimeA < DateAdd("d", 1, Cast('2014/10/31'as datetime)) AND (1=1) AND NX.Complete=1 OR NX.NG=1
ORDER BY NX.UpdateTimeA DESC

Comment: Use `NX.NG` and `NX.Complete`


Como não apresentar no html as chaves de um vetor em aplicação VUE.js

Question: Estou mexendo em uma aplicação simples com Vue.js, ao marcar alguns checkbox as opções marcadas são apresentadas no Html, até aí funciona normal, só que o problema é que os colchetes do vetor ficam aparecendo tbm. Tem como não apresentá-los.

var app = new Vue({

  el: '#app',
  data: {
    frames: Array()
  }

})
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap/dist/css/bootstrap.min.css"/>
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.css"/>
<link rel="stylesheet" href="assets/css/main.css"/>

QUAIS FRAMEWORKS MAIS GOSTA?

<input type="checkbox" value="VUE" v-model="frames">VUE
<input type="checkbox" value="REACT" v-model="frames">REACT
<input type="checkbox" value="ANGULAR" v-model="frames">ANGULAR

 Resposta: {{ frames }}

Answer: Apenas utilize o método join para transformar o array em uma string, separando os elementos pela virgula ( ou qualquer outro separador que deseje ).

 Resposta: {{ frames.join(', ') }}

Veja funcionando

var app = new Vue({

  el: '#app',
  data: {
    frames: Array()
  }

})
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap/dist/css/bootstrap.min.css"/>
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.css"/>
<link rel="stylesheet" href="assets/css/main.css"/>

QUAIS FRAMEWORKS MAIS GOSTA?

<input type="checkbox" value="VUE" v-model="frames">VUE
<input type="checkbox" value="REACT" v-model="frames">REACT
<input type="checkbox" value="ANGULAR" v-model="frames">ANGULAR

 Resposta: {{ frames.length === 0 ? 'Selecione um Framework': frames.join(', ') }}

Referência:

Array.prototype.join()
Comment: Obrigado man, realmente não tinha pensado em utilizar algum método js para tratar o conteúdo do array.


Tips for playing outdoors in cold weather?

Question: A few years ago our church band had a gig playing early in the morning to a volunteer crew to get them pumped for the day ahead. It was about 7AM and in the 30s F. It's a good thing I was only playing for one song and it wasn't lead because I could barely feel the strings let alone play well. I asked the lead guitarist how he did it and he just said it didn't bother him. So I figure it's not impossible.
Is there anything I can do to play better in cold weather short of lugging an outdoor heater around?
Comment: I know of no real good answer to this dilemma, except to bring the volunteers inside for the performance, everybody wins.
Answer: I had to do an hour set under those sort of conditions once. It was absolute misery: besides the guitar freaking out and needing to be tuned several times as it adjusted to the cold, I couldn't feel my fingers.
The instrument needs a chance to acclimate to the temperature. Major temperature swings can cause finish checking/cracking, and/or make inlay pop out, so give it lots of time to adjust slowly.
Don't open the case to let air circulate around it until the instrument is close to the temperature of the air; Remember, air circulating will speed up the temperature change.
The same caution is needed when returning the instrument to a normal temperature. If the instrument is cold and you move to a warm room and open the case and see the finish start to turn hazy, close the case and let it sit longer.
Amps can be cold but give tubes a while on standby to gradually warm up.
If playing indoors, I don't think I'd want to take a hot amp outside into cold air to sit either; That cold air would cause the amp's circuit board and components to go through some major thermal cycling.
As far as trying to stay warm, there are big gas-powered space heaters used to warm convention tents and such. They put out enough heat but you'd need a way of enclosing the space to keep the heat from escaping. Trying to do it with an electric-powered heater would use a lot of electricity with no benefit if the heat isn't trapped.
Personally, I would refuse that sort of situation based on my own experience. There isn't a good way to protect the instruments, there isn't a good way to keep YOU feeling good, and, all in all I think you'd put on a mediocre performance for what reason? Better than playing one song in those conditions, go serve hot-chocolate and play DJ, spinning tunes off your portable computer into a PA.
Answer: Maybe not the tip you're looking for, but:
Don't play in 30-degree weather.  That temperature would be devastating to the woods on an acoustic guitar.  I suspect that it's not ideal for an electric guitar either.  If you must play in low temperatures, bring a cheap guitar that you don't mind having cracks in the wood of.
Answer: I have Raynaud's disease. Thus, my digits get unnaturally cold, faster than the rest of my body, gloves or no gloves. I myself have had to play in similar situations, with cold winds cutting through my flesh (sub 30F for an hour, and the only guitarist). And, of course, one cannot wear full gloves in these situations. A few suggestions:

Strum hard and fast with a pick
Keep your right fist tightened (assuming you're a right-handed player)
Yes, the fingers on your left hand will hurt when you fret but keep them as close as possible to the fretboard.
Focus on the atmosphere and the singing/worship; you deal with the pain better as your digits grow numb and you can worry about the painful thawing process later
Outdoor heaters won't help; better to acclimate than anything else
Thus, it may not be a bad idea to practice regularly in cold or gusty conditions
Answer: Keep the blood flowing (run your arms in circles right before you go on).  Don't linger in the cold or take your hands out of gloves until its time to go.
I played out in a Christmas parade in northwestern wisconsin last night.  It was in the 25F range.  I tried fingerless gloves and hand warmers on their back, but they were too bulky.  I was able to barre a Bm and F w a set of one size fits all gloves, but i had to concentrate and wanted to finger pick a couple songs.  So no gloves.  The run for our float was only about 10-12 minutes but it hurt.
I was more worried about my cedar top guitar.  That part, it turns out I was able to safely solve by putting the cased guitar in my mildy warmed up car after running an errand and letting them both cool down for a few hours (overnight would have been fine i think now).  When I finally took it out of its case, it was air temp (call it 25F) and was in tune w itself, but about a quarter step sharp.  After the parade, I cased it up brought it home and just played it now.  Not a crack (sigh of relief).  It was about a quarter step flat.
In retrospect, i should have dropped it a step before I did the whole thing.  Other than that and some slow to warm limbs, it was all good.
If I do it again, I'll either cut the fingers off really cheap gloves or buy some fingerless ones that are thing and put a pouch on the back to hold a couple hand warmers on the back of my hand.  I also realized my right hand (strumming) was colder than my left.  My left was mostly bunched up and fingers together, right right i have the habit of stretching out all my fingers - and figured out half way through that habit needed a rest for the evening.
Answer: Fingerless gloves can help, particularly for simple things like strumming open chords on an acoustic guitar. Not so good for barre chords or palm muting.
Answer: I  too suffer from cold hands, worst thing is it can happen at any temperature. I have a long wrist band which I put rice or another grain then sew up the hole and microwave. It heats the blood in the wrist as it enters the hand. Not a real solution but if the venue has a microwave it's an instant fix. I have searched for years trying to find a battery powered wrist warmer that heats to a high temp as most are lukewarm at best. If you have raynaud's you can go Frim hero to zero in a matter of minutes. Anyway try the rice in large sweatband. Good luck
Answer: Pre covid lock down, the UK brass band I play in organised small ensembles to go out in the streets throughout December to do Christmas Carolling.
Tips for performing outdoors:

Thermal underwear
Multiple thin layers
Good gloves (consider warning two or three pairs of thin gloves). You don't need exposed fingertips to perform on a brass instrument, and that's fine because your hands get cold faster in fingerless gloves
Pocket-sized charcoal burner. Camping shops well sell you a metal tin lined with glass fibre into which you put a glowing charcoal stick. This burns for at least an hour, so if you keep it in your pocket you can warm your hands on it.
Thick-soled shoes. Don't lose your heat through your feet.
Woolly hat and scarf, properly tied.
Don't stand in wet grass.
Raising your hands above waist-height to perform means they get colder faster than if they were down by your sides. Give yourself some recovery time so your hands never get really cold. One advantage of street carolling over performing in a fixed spot is that you have to walk from one spot to another, and that can keep you warmer than standing in one place for a long time.
Answer: Keep a lot of hand warmers around!
Answer: I'm just random person who also came looking for help with playing in the cold. Thought i'd need special strings or and oil to stop it from de-tuning.
But have a possible outcome for the cold fingers thing... maybe.
dunno if it has been tried, but there's some gloves that amazingly keep my hands quite warm, considering how thin they are. and because they're so thin, they are actually pretty good at play the guitar with.
just a little average, not so professional guitarists questions/answer/thing... okay goodday...
Answer: I play outside gigs often in 40 degree temps and it is a challenge
The best thing I do is take a few extra breaks and use hand warmers inside winter gloves in between sets
Normally I would play 45 minute set I cut them to 30 minutes
Answer: Beyond the great practical tips already presented, I have always found it easier to play outside in winter after a couple of shots of hard liquor. Nothing like alcohol to dilate those capillaries!


Exibir api com Ionic

Question: Boa Tarde a todos, estou consumindo uma api, porém não consigo exibi-la no meu template, ela esta sendo consumida, aparece no console, porém não consigo no template.
Component :
import { PaisesProvider } from './../../providers/paises/paises';
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
  cotacao: string [];
  constructor(public navCtrl: NavController,
              private paisesProvider: PaisesProvider) {

  }

  ionViewDidLoad() {
    this.listaCotacao();

  }

  listaCotacao() {
    this.paisesProvider.listaPaises()
    .subscribe(data => {
      this.cotacao = data;
      console.log(this.cotacao);

    });
  }
}

Template:

<ion-header>
  <ion-navbar>
    <ion-title>Home</ion-title>
  </ion-navbar>
</ion-header>

<ion-content padding>

    <ion-item  *ngFor="let c of cotacao">
      Data : {{c.date}} Valor Compra {{c.buy}} Valor Venda {{c.sell}}
    </ion-item>

</ion-content>

Aparece o erro :

Cannot find a differ supporting object '[object Object]' of type
  'object'. NgFor only supports binding to Iterables such as Arrays.
Comment: Nessa linha `Data : {{c.date}} Valor Compra {{c.buy}} Valor Venda {{c.sell}}  ` você está dizendo que no seu array existe um objeto com as propriedades buy, sell e date. Como é a resposta de `console.log(this.cotacao);`?  Talvez basta trocar seu array de cotações para  `cotacao: string [{ }]}}`;
Comment: Esta assim amigo :

{"ticker": {"high": "29399.00000000", "low": "28234.00000000", "vol": "126.05166124", "last": "29000.12224000", "buy": "29000.13024000", "sell": "29282.98250000", "date": 1535741070}}
Comment: Notou que isso é um objeto javascript e não um array?
Comment: Você está usando TypeScript ou Javascript?
Comment: Notei sim. Estou usando TypeScript
Comment: Você itera com `ngFor` sobre um array
Answer: Você está dando um *ngFor em alguma resposta que não é um array, é disso que ele está reclamando, ele está vindo como objeto. Se você quiser exibir os campos desse objeto.
No caso dessa response aí que você informou, ele é um objeto, logo não precisa percorrer os valores dele, basta acessá-los diretamente como por exemplo:
c.date c.buy  e assim por diante.
Comment: Exato, é um array super simples , mas nao consigo exibir.
Comment: Segue api: https://www.mercadobitcoin.net/api/BTC/ticker/ .

Eu não estou conseguindo exibir no template de jeito nenhum
Comment: Ela não parece  ser um vetor mas como vou exibi - la no template ?
Comment: Nesse caso você não precisa dar um ngFor, basta dar um `c.ticker.date` `c.ticker.buy` e assim por diante.

Exibir api com Ionic


Combinations, a Deck with Separate Hands and Players

Question: The main issue I'm having is trying to solve this scenario below where we have multiple decks between multiple players, with left over cards that remain in no player's hand. With this I've tried to determine the probabilities of the scenarios below, but I am almost certain that my answers are wrong. I'll show how I came to my answers, pointing out any flaws in my logic would be greatly appreciated.
A euchre deck contains the cards {9, 10, jack, queen, king, ace} of each of the four suits (diamonds, spades, hearts, clubs). A hand contains 5 cards. There are four players. One card of the undealt four cards is revealed (which is relevant to the game, but we don't need to know how the game works to answer these questions).
Given that one king is revealed and you have no king, what is the probability that each other player has one king?
$\frac{{18 \choose 3}*3}{{24 \choose 5}}$ = 5.76%
24 cards in deck, 5 in own hand subtracted from available total = 19, -1 from one revealed = 18, 3 kings still left over out of 18 cards with 3 players, out of the available 5-card decks.
The most obvious problem with this answer is the fact that you can't simply multiply by 3 in the numerator like that I believe, as it would be more likely to be $\frac{{18 \choose 3}^3}{{24 \choose 5}}$, which would be 1278323%, so obviously that doesn't work. Also, how would we account for the fact that each of their individual decks have 5 cards? Would the 3 cards that nobody has need to be factored separately instead of just subtracted from the total?
What is the probability that your hand has only red (hearts and diamonds) cards?
$\frac{{12 \choose 24}}{{24 \choose 5}}$ = 6362%
So obviously this approach doesn't work, as ${12 \choose 24}$, which would be the 12 red cards out of the 24 cards in the deck, is much greater than the ${24 \choose 5}$ total 5-card hands that can be configured from the 24 card deck. So how would we incorporate that the 3 other players who each also have their own 5-card deck and the fact that there would be 4 cards left that belong to no player if none are revealed?
Would it perhaps be that you need to account for each card as you go such that
$\frac{{12 \choose 1}{11 \choose 1}{10 \choose 1}{9 \choose 1}{8 \choose 1}}{{24 \choose 5}}$? That would equal 356.47%, so there's still something.
How many ways can every player have only cards of a one suit? (For example, player 1 has only spades, player 2 only diamonds, player 3 only hearts, player 4 only clubs in a single deal.)
$\frac{{12 \choose 4}^4}{{24 \choose 5}^4}$ = 1.84*10^(-6)% or $\frac{{24 \choose 5}{19 \choose 5}{14 \choose 5}{9 \choose 5}}{{24 \choose 5}^4}$ = 0.003820%
The second between these 2 options seems to be much more correct and intuitive, and I think perhaps the way to account for the 4 separate decks my be as I've done here, but I'm not sure if it takes into account the 4 cards claimed by no player, or if that is a factor that we need to be concerned with at all.
What is the probability your hand contains only 9s and 10s?
$\frac{{24 \choose 12}}{{24 \choose 5}^4}$ = 2.25*10^(-11)% or $\frac{{8 \choose 1}{7 \choose 1}{6 \choose 1}{5 \choose 1}{4 \choose 1}}{{24 \choose 5}}$ = 224.07%
Here I tried a both approaches again trying to incorporate the 4 separate hands by setting the total configurable decks to the 4 power, and the percentage probability again seems much too small, and it still doesn't account for the 4 left over cards, this is, if that factor needs to be accounted for at all. The second method was again from the second half of the second question.
So for all these example would it be mostly like the second example for the third question? That one seemed the most intuitive of them all but I'm still not sure if I'm tackling this in the correct manner.
Comment: Please ask one question in one post.
Comment: A good rule of thumb is to focus a Question on the first problem (in a chain of related exercises) that actually gives you difficulty.  Seeing the solution of that explained will often allow you to continue on your own working the remaining parts.  If you do need further help, you can include a link in a new Question to the previous one.
Comment: This is a long post and hard to quickly read, but you should look into [hypergeometric distributions](https://en.wikipedia.org/wiki/Hypergeometric_distribution#:~:text=In%20probability%20theory%20and%20statistics,that%20contains%20exactly%20objects%20with).  In the case of "What is the probability your hand only contains 9s and 10s, there are $8$ cards "of that type" out of $24$ available cards, the probability your five cards will be $\dfrac{\binom{8}{5}}{\binom{24}{5}}$.  That is... we look at the number of ways of choosing five of those target cards out of the ways of choosing five cards
Answer:
Given that one king is revealed and you have no king, what is the probability that each other player has one king?

$$ \frac{\binom{15}{4}\binom{11}{4}\binom{7}{4} \times (3!)}
{\binom{18}{5}\binom{13}{5}\binom{8}{5}}. \tag1 $$
Note that no information regarding your hand is available, other than that it does not contain a King.  You can assume, without loss of generality therefore, that your hand specifically contains $(4)$ 9's and the 10-spades.
This very handy assumption does not alter the computations.  That is, if instead, your hand contained $4$ Jacks and a Queen, that would not alter the computation of the probability that each of the other $3$ players has a King.
In (1) above, the denominator indicates how many different distributions of the $(18)$ remaining cards there are, to the $(3)$ players, distributing the cards $(5)$ at a time.
Note also that for convenience, when computing the denominator, the order of distributions of the cards is deemed relevant.  So, player-1 getting a certain group of $5$ cards is deemed distinct from player-2 getting these same $5$ cards.
Consequently, the numerator must be computed in a consistent manner.  Note that of the $(18)$ cards remaining, $15$ of them are non-Kings, and the $3$ Kings can be assigned in $(3!)$ ways.

What is the probability that your hand has only red (hearts and diamonds) cards?

The probability is
$$\frac{\binom{12}{5}}{\binom{24}{5}}.$$
That is, the numerator indicates how many ways there are of selecting $(5)$ cards out of $(12)$.

How many ways can every player have only cards of a one suit? (For example, player 1 has only spades, player 2 only diamonds, player 3 only hearts, player 4 only clubs in a single deal.)

There is confusion about whether you are asking about the number of different distributions (where presumably) the players are distinguishable from each other, or the probability of the event occurring.
If you are asking about the probability of the event occurring, then the answer will be
$$\frac{N\text{(umerator)}}{D\text{(enominator)}},$$
where
$$D = \binom{24}{5} \times \binom{19}{5} \times \binom{14}{5} \times \binom{9}{5}.$$
So, it only remains to compute $N$, which will correspond to the number of different distributions, if this is what you are asking.
First, you have a factor of $(4!)$, which represents that the $(4)$ suits can be distributed among the players in $(4!)$ ways.  Then, since each player will get $5$ of the $6$ cards in that suit, you also have a factor of $~\displaystyle \left[\binom{6}{5}\right]^4.$
Putting this all together,
$$\frac{N}{D} = \frac{(4!) \times 6^4}{\binom{24}{5} \times \binom{19}{5} \times \binom{14}{5} \times \binom{9}{5}}.$$

What is the probability your hand contains only 9s and 10s?

This is straightforward.  You have to select $5$ cards from the 9's and 10's.
$$\frac{\binom{8}{5}}{\binom{24}{5}}.$$
Answer:
Given that one king is revealed and you have no king, what is the probability that each other player has one king?

The deck contains 4 kings, and 20 non-kings. Four hands of five cards are dealt, one card is revealed, and 3 cards remain.  One among the hands is "yours", three are "not yours".
So, you seek the probability for obtaining one place among each of three hands of five cards (and none among the three remainders), when given that these three kings may placed among any from these $18$ places in the deck that are not "yours" or the revealed card ($24-5-1$).
$$\dfrac{\dbinom 51^3\dbinom 30}{\dbinom{18}{3}}\qquad\raise{5ex}{\gets 5\times 3+3=18\\\gets1\times 3+0=3\\\text{check sum }\checkmark}$$

Solve the rest of your problems similarly.  Make sure the favoured event being counted in the numerator is a subset of the "total" event being counted in the denominator, and that they are being counted in the same general manner.
In the above, we are selecting 3 things from 18 in the denominator and the numerator, just with the favoured selection being a more specific arrangement of that : 1 from 5 in each of 3 hands, and 0 from 3 in the 1 group of 'unrevealed'.
Including factors that equal 1, such as $\binom 30$, will help make your counting logic clearer, and ensure the "check sum" test works.

What is the probability that your hand has only red (hearts and diamonds) cards?

What is the probability for obtaining 5 from 12 cards in "your" hand (and none from the other 12 cards), when "your" hand may select 5 from all 24 cards?
What is the probability for obtaining 5 among 5 places in "your" hand and 7 among 19 places elsewhere, when selecting 12 among 24 places in the deck for the red cards?
Comment: In case you are puzzled, I left a comment following your answer, and then deleted it.  I had misinterpreted question-1.
Answer: For the main question of "do I need to worry about other hands?  do I need to worry about what's buried?"  The answer is generally no.  "Do I need to worry about the order in which cards appear in my hand (or other hands)?"  Again, generally no.
Could you make it such that those things are relevant?  Sure, but you need to ensure that your numerator and your denominator are both encapsulating the same type of information to the same degree of specificity.  If you treat order as relevant in the numerator you must also treat order as relevant in the denominator.  If you worry about the cards in the other players' hands in the numerator, you must also keep track of cards in the other players' hands in the denominator.  If done correctly, regardless what decisions you make with regards to these the answers will be correct and you are free to make decisions as to the relevance however you like to make things easier on yourself so long as the question you are trying to answer does not require certain levels of specificity.

Problem 1:  What is the conditional probability that the three remaining kings are sent one each to the other three players given the turn is not a king and you have no king in your hand.
We can do this more carefully with $\Pr(A\mid B)=\dfrac{\Pr(A\cap B)}{\Pr(B)}$, but I will ignore that approach and do this directly instead.  We have treat this as though we intentionally searched for five non-king cards and one king and gave five non-kings to us and one king placed as the turn and shuffled the remaining $18$ cards and dealt them out.
There are $\binom{18}{5,5,5,3}=\frac{18!}{5!5!5!3!}=\binom{18}{5}\binom{13}{5}\binom{8}{5}\binom{3}{3}$ ways to distribute the remaining cards among the other players and the buried deck where we do care about who gets which card but don't care about the order in which they received said cards.  Note... this is not $\binom{24}{5}^3$ or $\binom{24}{5}^3\binom{24}{3}$ or some other expression like you were trying to use... once a card is in someone's hand, that card is not eligible to appear in anyone else's hand.
There are $3\cdot \binom{15}{4}\cdot 2\cdot \binom{11}{4}\cdot 1\cdot \binom{7}{4}\cdot \binom{3}{3}$ ways to choose a king to go to the second player and then four more cards from those remaining, then 2 ways to choose the king to go to the third player and four more cards from those remaining, the last king goes to the fourth player and choosing the other four cards to them, and then the final three cards to go the buried deck.  This gives us a probability of:
$$\frac{3\cdot \binom{15}{4}\cdot 2\cdot \binom{11}{4}\cdot 1\cdot \binom{7}{4}\cdot \binom{3}{3}}{\binom{18}{5}\binom{13}{5}\binom{8}{5}\binom{3}{3}} = \frac{3!\binom{15}{4,4,4,3}}{\binom{18}{5,5,5,3}}$$
Again, I will reemphasize that we could just as well have done this as order in which the cards appear in people's hands as mattering and gotten a larger expression  which I leave to you to fiddle with if you like... however you can also treat order as relevant and only care about the kings having ignored where any of the rest of the cards are sent.
With order relevant within the hand, there are $\binom{18}{3}$ different collections of positions where the kings could have been sent.  Among those, there are $5^3$ different sets of positions which would have been favorable where all kings go in different hands, giving a probability of $\dfrac{5^3}{\binom{18}{3}}$.  Similarly, we could have done this by distributing the cards to random positions and gone one card at a time having started by distributing the kings.  The first king is sent to a "good" spot with probability $\frac{15}{18}$.  Given the first king is sent to a good spot, there are $10$ good spots remaining and we will continue by sending the second king to a good spot with probability $\frac{10}{17}$ and then the third after this with probability $\frac{5}{16}$ giving the final probability as $\frac{15\cdot 10\cdot 5}{18\cdot 17\cdot 16}$.  Of course, all of these approaches give the same final answer.

Problem 2 is a textbook example of a hypergeometric distribution.  The cards in the other players' hands don't need to be relevant so we can focus on our hand only.
There are $12$ red cards and we want to choose five of them to go to us.  There are $\binom{12}{5}$ ways to do this.  This is compared to the $\binom{24}{5}$ ways we could have given ourselves five cards.  This gives our probability as $\dfrac{\binom{12}{5}}{\binom{24}{5}}$.
If you insist on making the other hands relevant... then again, the correct way to do this is with multinomial coefficients rather than taking the denominator to a higher power because, again, the cards can not be reused multiple times.  If you really insist, the answer will look closer to $\dfrac{\binom{12}{5}\binom{19}{5,5,5,4}}{\binom{24}{5,5,5,5,4}}$ but this is far messier to work with and the extra arithmetic needed is not worth it.

Problem 3: What is the probability every player has cards entirely of a single suit?  (I assume we will ignore the special behavior of Jacks as left-bowers in Euchre)
Your numerator here in your second attempt was actually what the denominator was supposed to be.  The numerator was supposed to be the number of ways of sending five of the same suit to the first player, second player, etc...
For this, first decide who is designated to receive which suit in $4!$ ways.  Then, choose which ranks those cards were for the first player in $\binom{6}{5}$ ways.  Similarly for the other players.  This is in comparison to the $\binom{24}{5,5,5,5,4}$ ways in which the deck can be distributed (order within hands not mattering) giving a probability of $\dfrac{4!6^4}{\binom{24}{5,5,5,5,4}}$

Problem 4: you only get 9's and 10's, again this is a textbook example of hypergeometric probability.  $\dfrac{\binom{8}{5}}{\binom{24}{5}}$


I'm lost in Crossover design-repeated measurements and mixed modelling

Question: I am searching for days now, in what I think is a repeated measurements crossover design but I think I got mixed up reading up on it and I'm now going in circles so I was wondering if anyone could point me in the right direction.

I was also wondering whether I should use interactions in my model and what the 1|subject means in a linear mixed model.
I think that I need to include interactions for the sequence groups with the treatment received and an interaction for the days (?).
I am worrying that in the end I include too many components to my model.
I am also confused as to whether I should convert my factors to numeric variables.

I have a design which gives two treatments A and B in an uneven amount of patients. Each patient was given both treatments twice.
The patients were split in two groups with a different sequence of treatments (this was given as a text) administered and the outcome is numeric.
It looks like this:

Patient
Treatment
Phase
Group
Day
Outcome

1
A
1
1
1
38

1
B
1
1
2
8

1
A
2
1
3
29

1
B
2
1
4
5

2
B
1
2
1
28

2
A
1
2
2
41

2
B
2
2
3
33

2
A
2
2
4
45

3
A
1
1
1
68

3
B
1
1
2
8

3
A
2
1
3
69

3
B
2
1
4
4

I'm interested in seeing if there is a difference in the Outcome from the Treatments and what is this difference. Also a directions in the assumptions needed would be appreciated. Finally, an idea on how to plot the differences?
I am using R  (preferred) and from what I understand  lme4 has the required commands but have access to SPSS (24).
Thanks a lot!
Answer:
I was also wondering whether I should use interactions in my model and what the 1|subject means in a linear mixed model.

We fit an interaction between two variables when we expect the "effect" of one variable on the outcome to differ, depending on the value of the other.
1|subject means that we are fitting random intercepts for subjects. This is typically done when we have repeated measures or some other kind of clustering within subjects.

I am also confused as to whether I should convert my factors to numeric variables.

I think that I need to include interactions for the sequence groups with the treatment received and an interaction for the days (?).

Again, if we expect the "effect" of one variable on the outcome to differ, depending on the value of the other, then we fit an interaction.

I am worrying that in the end I include too many components to my model.

You don't say how many observations in total and how many subjects, but based on the information given, this does not seem to be a concern.

I am also confused as to whether I should convert my factors to numeric variables.

Patient: this will be used for random intercepts, so should remain a factor
Phase and Group: these seems to be both binary, so it won't make any difference
Treatment: this is a grouping variable so should remain a factor

In R, you could start with this model:
lmer(Outcome ~ Treatment + Phase + Group + Day  + (1|Patient), data = mydata)

but of course you should also add interactons, if these are of interest.
Comment: Great, thank you for your answer, particularly about the random intercept for subjects, because at the lmer's vignette they fitted it also like this "day|patient" and I was wondering whether I should do it because I get measurements for the same treatment at different days.
Comment: I know that this turns into another question about random slopes and intercepts but there are so many groupings here
Comment: You're welcome :) We fit random slopes for a variable when we expect the response to that variable to differ by subject.


MongoDB: $match with $or aggregation optimization

Question: I faced an issue how optimize this  $match.
Currently I have this code
{ $match: {
            $or: [
                { 'card': { $eq: 'card1'},
                 $and: [
                         { 'createdAt': { $gte: three_months }},
                         { 'createdAt': { $lte: createdAt }}
                        ]
                },
                { 'client': { $eq: 'client1'},
                 $and: [
                         { 'client': { $ne: null }},
                         { 'createdAt': { $gte: three_months }},
                         { 'createdAt': { $lte: createdAt }}
                        ]
                },
            { 'destination_card': { $eq: 'destination_card1'},
                 $and: [
                         { 'createdAt': { $gte: three_months }},
                         { 'createdAt': { $lte: createdAt }}
                        ]
                },

            ]
           }
{ $limit: 300},
{ $sort: { createdAt: -1 } },

But sometimes calculation is wrong or it executes too long.  Please could you give some idea how to optimize it somehow? Many thanks in advance!
Comment: Use analyzer to check for bottlenecks https://docs.mongodb.com/manual/tutorial/analyze-query-plan/
Answer: If you are using a newer version of MongoDB (3.6+, I think), the query planner can use multiple indexes to handle the $or.  Each branch uses the same criteria on createdAt, so you could collect that together to list only once, like:
{$match: {
     {'createdAt':{$gte: three_months, $lte: createdAt}},
     {$or:[
        {'card': 'card1'},
        {'client': 'client1'},
        {'destination_card': 'destination_card1
     ]}
}}

If you create 3 indexes, each with one of the exact match fields and createdAt, like {card:1, createdAt:1} it will improve selection and reduce the number of documents examined, which may help execution time.
Note that using $or usually prevents the query executor from using the index to perform the sort, requiring an in-memory sort each time this query is run, which increases the RAM needed to execute this query, which may slow down the execution when the server is busy.
Comment: Dear Joe, thank you very much for your answer! It helped me a lot!


Archiving forums on time basis in drupal 7

Question: I am using advance forum on drupal 7. I want to add following functionality to it:
Archiving:
I could define forum posts older than 6 months or so should be automatically be archived and visible only to admin.
Any module or pointers to achieve same highly appreciated.
Answer: You could use the Rules module.
Create a rule to set the node status to "unpublished" when the node is older than 6 months and make it execute every time the cron runs.
Also, make sure you allow only the admin to see the unpublished content
Comment: i don't want to unpublish them, i want to have a different state- "archive" which will not be visible in search and will only be read-only by some user-roles on site.


Verify the formula of bivariate Poisson distribution

Question: suppose that $X$ has a Poisson distribution with the rate $\lambda $ and suppose the conditional distribution of $Y$, given $X=x$, is binomial with parameters $x$ and $p$.
Problem: Let $Z=X-Y$ and $q=1-p$, verify $$p _{Y,Z}(y,z)=\frac{(p \lambda)^y}{y!} e^{-p \lambda} \frac{(q \lambda)^z)}{z!} e^{-q \lambda}$$ for non-negative integers $y$ and $z$.

I know that \begin{align} p_{Y,Z}(y,z) & =P(Y=y,Z=z)  \\ &= P(Y=y,X=y+z)  \\& =P(Y=y \mid X=y+z) P(X=y+z) \end{align}

But I am still not sure how to tackle this problem, any help is appreciated.
Comment: Perhaps you should begin by finding the (unconditional) distribution of $Y$.
Answer: Hint:  "[T]he conditional distribution of $\ Y\ $ given $\ X=x\ $ is binomial with parameters $\ x\ $ and $\ p\ $" means
$$
P(Y=y|X=y+z)={y+z\choose y}p^yq^z\ ,
$$
and "$\ X\ $ has a Poisson distribution with the rate $\ \lambda\ $" means
$$
P(X=y+z)=\frac{\lambda^{y+z}}{(y+z)!}e^{-\lambda}\ .
$$
If you substitute these expressions into your formula for $\ p_{Y,Z}(y,z)\ $, the rest should be fairly straightforward algebra.


Is There a Generic Theme Duplication Module or Drush Command

Question: As I understand there are Drush commands for Adaptive Theme, Omega, Zen and maybe other themes for creating subthemes, but is there a more generic module/way to create/duplicate a theme?  It would be nice to give clients a way to mirror their theme within the interface.
Comment: I don't think so, the closest I've seen is https://www.drupal.org/project/module_builder which can be hard to make work, but claims rudimentary support for theme generation.
Comment: If found this #!/bin/bash script reference to the ZEn them that looks like it would serve as base - https://www.drupal.org/node/276120 - although that brings up the question "can a bash script be run from PHP/Drupal" and/or why bother if it can be done in PHP.
Answer: No but you can copy the theme folder and then replace the name of the theme in all hooks and of course rename yourtheme.info to yourcopy.info. in order not to miss any hook you may use a prog like wingrep and search-replace the yourtheme string
Comment: Thank you, I am aware of this but it does not give client "feel good" perception of Drupal in my experience.  Clients can use "save as" on their documents or copy folders of docs and rename folders/ files so they expect similar simplicity or i would like to give that option.
Comment: Seems module builder module might provide some tricks...


ASP.NET MVC Active Directory Authentication return URL issue

Question: I am using ASP.NET MVC for Active Directory Authentication and its working well, the only problem I have is the return URL on Login Method:
[HttpPost]
        public ActionResult Login(LoginClass model, string ReturnUrl)
        {

            if (ModelState.IsValid)
            {
                if (Membership.ValidateUser(model.UserName, model.Password))
                {
                    FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                    if (Url.IsLocalUrl(ReturnUrl) && ReturnUrl.Length > 1 && ReturnUrl.StartsWith("/")
                        && !ReturnUrl.StartsWith("//") && !ReturnUrl.StartsWith("/\\"))
                    {
                        return Redirect(ReturnUrl);
                    }
                    else
                    {
                        return RedirectToAction("Index", "Home");
                    }
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect");
                }
            }

            return RedirectToAction("Index", "Home");
        }

The problem I am experiencing is that my ReturnUrl is alwasy null when the URL looks like this:
Login/Index?ReturnUrl=%2fConsultant%2fIndex

Why is my ReturnUrl always null when the parameter is populated?
Here is my view:

    <form action="~/Login/Login" id="Login" method="post">

                    Username
                    <input type="text" id="username" name="username" class="form-control" />

                    Password
                    <input type="password" id="password" name="password" class="form-control" />

                    <input type="submit" id="submit" name="submit" value="Login" class="btn btn-default" />

                    Remember Me?
                    <input type="checkbox" id="chkPersist" name="chkPersist" />

    </form>

Here is some code from web.config:
<authentication mode="Forms">
      <forms name=".ADAuthCookie" loginUrl="~/Login/Index" timeout="45" slidingExpiration="false" protection="All" />
    </authentication>
    <membership defaultProvider="ADMembershipProvider">
      <providers>
        <clear />
        <add name="ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider" connectionStringName="ADConnectionString" attributeMapUsername="sAMAccountName" />
      </providers>
    </membership>

Comment: Can you post the code of your view (.cshtml) file?
Comment: If it helps, query string values are parsed using the [`QueryStringValueProvider`](https://stackoverflow.com/a/36606015/181087). It is possible (though unlikely) that another provider that is registered before `QueryStringValueProvider` is providing a `null` value before it has a chance to run.
Comment: Try to use RedirectToLocal(ReturnUrl);
Comment: @JCM ReturnUrl is null before it hits that point.
Comment: @KrishnrajRana I posted my view code.
Answer: You need to mention ReturnUrl in your form tag.
try this -

 @using (Html.BeginForm("Login", "Login", new { ReturnUrl = Request.QueryString["ReturnUrl"] }, FormMethod.Post, new { @id = "Login" }))
 {

                    Username
                    <input type="text" id="username" name="username" class="form-control" />

        ... blah... blah....
  }


How to make cordova local notification on android sticky

Question: I am using this cordova plugin and wondering if it is possible to make the local notifications sticky/non-removable?
Answer: It wasn't that bad. Just set the native option "ongoing: true" in the plugin:
<code>scheduleActiveAlarm = function () {
  cordova.plugins.notification.local.schedule({
      id: 1,
      text: 'Test text',
      ongoing: true
  });
};
</code>
https://github.com/katzer/cordova-plugin-local-notifications/wiki/04.-Scheduling


Looking for effiicient way to pull data from facebook graph api

Question: I've been recently working with facebook graph api , when I'm pulling user's recents status messages using https://graph.facebook.com/me/statuses?access_token=...  all I get is a long list which contains details about the status content, and I want to pull the names of people who liked the status.
The current solution I've been thinking about is using preg match,
I'd like to know if you guys have any other suggestions,
Thanks in advance
Answer: I'm not sure what path you're using, but you can fetch the list of users who like a particular status update by requesting the likes connection on an update.
For example, requesting https://graph.facebook.com/10150710880081168/likes yields something like the following for me:
{
  "data": [
    {
      "id": "276700623",
      "name": "Vikki Carter"
    },
    {
      "id": "1514365200",
      "name": "Darren Bean"
    },
    {
      "id": "539760281",
      "name": "Ian Sidaway"
    }
  ],
  "paging": {
    "next": "https://graph.facebook.com/10150710880081168/likes?format=json&limit=25&offset=25&__after_id=539760281"
  }
}

You'll need the ID of the status update, but also the user_status permission from the logged-in user.
EDIT: Iterating over the returned data and assigned users into an array:
<?php

$result = $facebook->api('[status_id]/likes');

$names = array();
foreach ($result['data'] as $user) {
    $names[] = $user['name'];
}

You should now have an array of names of users who liked the status in question.
Comment: Just iterate over the returned data and assign them into an array yourself. I've updated the answer to show this.
Comment: I guess I didn't explain myself well -
I've already got the list of users who liked the status, now I want to arrange them in an array , is there any other way to do it instead of using preg match  ? Any built-in facebook function ? Thanks in advance !


At most countably many mutually disjoint Borel sets have nonzero $\mu$-measure

Question: I'm proving this lemma

If $\mu$ is a finite Borel measure on a metric space $X$ and $\mathcal{A}$ a collection of mutually disjoint Borel sets of $X$, then at most countably many elements of $\mathcal{A}$ have nonzero $\mu$-measure.

This boils down to below result.

Let $(a_i)_{i\in I}$ be a collection of non-negative real numbers. Let's define $$\sum_{i\in I} a_i := \sup \left \{\sum_{i\in J} a_i \,\middle\vert\, J \text{ is a countable subset of } I \right\}.$$ If $\sum_{i\in I} a_i < \infty$, then at most countably many $a_i$'s are positive.

Could you have a check on my attempt?

Let $J := \{i \in I \mid a_i >0\}$ and $J_r := \{i\in I \mid a_i \ge r\}$ for $r \in \mathbb Q_{>0}$. Then $$J= \bigcup_{r\in \mathbb Q_{>0}} J_r.$$
It follows from $\sum_{i\in I} a_i < \infty$ that $J_r$ is countable for all $r\in \mathbb Q_{>0}$. Then it follows from $\mathbb Q_{>0}$ is countable that $J$ is countable.
Comment: Your proof is correct.
Answer: The proof is correct.
Mind, each $J_r$ is not only countable, but actually finite.


How can I get the checkbox element value from a submission handler?

Question: I have a single checkbox field. When I try to get its value in a submission handler, the value I get is always 0 whether it has been selected or not.
/**
 * {@inheritdoc}
 */
public function buildForm(array $form, FormStateInterface $form_state) {
  $form['item_specifics'] = [
    '#type' => 'checkbox',
    '#title' => t('Sync item specifics'),
    '#attributes' => [
      'name' => 'field_item_specifics',
    ]
  ];

  $form['fieldset_item_specifics'] = [
    '#type' => 'fieldset',
    '#title' => $this->t('Item Specifics'),
    '#attributes' => [
      'class' => ['form-wrapper', 'js-form-wrapper'],
    ],
    '#states' => [
      'visible' => [
        ':input[name="field_item_specifics"]' => ['checked' => TRUE],
      ],
    ],
  ];

  $form['submit'] = [
    '#type' => 'submit',
    '#value' => $this->t('Sync'),
  ];

  return $form;
}

How can I get the checkbox value from a submission handler?
Comment: If I remove the attributes key and just use the default name value for the state on the other field it works.
Answer: Instead of setting $form['item_specifics']['#attributes']['name'] to 'field_item_specifics', you need to set it to 'item_specifics'.
/**
 * {@inheritdoc}
 */
public function buildForm(array $form, FormStateInterface $form_state) {
  $form['item_specifics'] = [
    '#type' => 'checkbox',
    '#title' => t('Sync item specifics'),
    '#attributes' => [
      'name' => 'item_specifics',
    ]
  ];

  $form['fieldset_item_specifics'] = [
    '#type' => 'fieldset',
    '#title' => $this->t('Item Specifics'),
    '#attributes' => [
      'class' => ['form-wrapper', 'js-form-wrapper'],
    ],
    '#states' => [
      'visible' => [
        ':input[name="item_specifics"]' => ['checked' => TRUE],
      ],
    ],
  ];

  $form['submit'] = [
    '#type' => 'submit',
    '#value' => $this->t('Sync'),
  ];

  return $form;
}


invalid expression: Unexpected token '.' in raw expression

Question:

This is giving me this error:
 Errors compiling template:

  invalid expression: Unexpected token '.' in

    { form.errors.username[0]: Boolean(form.errors.username[0]) }

  Raw expression: :message="{ form.errors.username[0]: Boolean(form.errors.username[0]) }"

I am new to Vue and have been stuck on this problem. Can anyone please help?
Answer: if you are trying to have the message prop being an object having form.errors.username[0] as a key, you need to wrap it with [ and ] eg:
:message="{ [form.errors.username[0]]: Boolean(form.errors.username[0]) }">


Intuitive explanations of differences between Gradient Boosting Trees (GBM) & Adaboost

Question: I'm trying to understand the differences between GBM & Adaboost.
These are what I've understood so far:

There are both boosting algorithms, which learns from previous model's errors and finally make a weighted sum of the models.
GBM and Adaboost are pretty similar except for their loss functions.

But still it is difficult for me to grab an idea of differences between them.
Can someone give me intuitive explanations?
Answer: I found this introduction which provides some intuitive explanations:

In Gradient Boosting, 'shortcomings' (of existing weak learners) are identified by gradients.
In AdaBoost, 'shortcomings' are identified by high-weight data points.

By means of an exponential loss function, AdaBoost gives more weights to those samples fitted worse in previous steps. Today, AdaBoost is regarded as a special case of Gradient Boosting in terms of loss function. Historically it preceded Gradient Boosting to which it was later generalized, as shown in the history provided in the introduction:

Invent AdaBoost, the first successful boosting algorithm [Freund et
al., 1996, Freund and Schapire, 1997]
Formulate AdaBoost as gradient descent with a special loss
function [Breiman et al., 1998, Breiman, 1999]
Generalize AdaBoost to Gradient Boosting in order to handle a
variety of loss functions [Friedman et al., 2000, Friedman, 2001]
Answer: An intuitive explanation of AdaBoost algorithn
Let me build upon @Randel's excellent answer with an illustration of the following point

In AdaBoost, 'shortcomings' are identified by high-weight data points

AdaBoost recap
Let $G_m(x) \ m = 1,2,...,M$ be the sequence of weak classifiers, our objective is to build the following:
$$G(x) = \text{sign} \left( \alpha_1 G_1(x) + \alpha_2 G_2(x) + ... \alpha_M G_M(x)\right) = \text{sign} \left( \sum_{m = 1}^M \alpha_m G_m(x)\right)$$

The final prediction is a combination of the predictions from all classifiers through a weighted majority vote

The coefficients $\alpha_m$ are computed by the boosting algorithm, and weight the contribution of each respective $G_m(x)$. The effect is to give higher influence to the more accurate classifiers in the sequence.

At each boosting step, the data is modified by applying weights $w_1, w_2, ..., w_N$ to each training observation. At step $m$ the observations that were misclassified previously have their weights increased

Note that at the first step $m=1$ the weights are initialized uniformly $w_i = 1 / N$

AdaBoost on a toy example
Consider the toy data set on which I have applied AdaBoost with the following settings:
Number of iterations $M = 10$, weak classifier = Decision Tree of depth 1 with 2 leaf nodes. The boundary between red and blue data points is clearly non linear, yet the algorithm does pretty well.

Visualizing the sequence of weak learners and the sample weights
The first 6 weak learners $m = 1,2,...,6$ are shown below. The scatter points are scaled according to their respective sample weight at each iteration

First iteration:

The decision boundary is very simple (linear) since these are weak learners
All points are of the same size, as expected
6 blue points are in the red region and are misclassified

Second iteration:

The linear decision boundary has changed
The previously misclassified blue points are now larger (greater sample weight) and have influenced the decision boundary
9 blue points are now misclassified

Final result after 10 iterations
All classifiers have a linear decision boundary, at different positions. The resulting coefficients of the first 6 iterations $\alpha_m$ are :
<code>1.041, 0.875, 0.837, 0.781, 1.04, 0.938...
</code>
As expected, the first iteration has largest coefficient as it is the one with the fewest misclassifications.
Next steps
An intuitive explanation of gradient boosting - to be completed
Sources and further reading:

python code and original figures here
https://www.cs.cmu.edu/~aarti/Class/10701/slides/Lecture10.pdf


Predicting the Weather

Question: Given a tree trunk with concentric circles, can we predict the weather for each year? Each concentric circle accounts for a year that the tree has been on the Earth. The innermost circle is the oldest year and the outermost circle is the current year.
I have a data set that tells how much rainfall there was for every year since rainfall could be measured. Given this information can we predict rainfall for the innermost years?
I thought maybe the size of the concentric circles were dependent upon the rainfall for that year. This assumes a direct relationship. I was asked to think of this more broadly and in particular to think about this as a Markov Model.

How could I go about doing this prediction? Is a Markov model a good place to start, or are there simpler ways to approach the problem?
Even if there are other ways, I want to explore the Markov model as well. Where is a good place to start learning about Markov models?

Any help and comments would be greatly appreciated!
Answer:
1.How could I go about doing this prediction? Is a Markov Model a good place to start? Or are there more simplistic ways to approach the
  problem?

You need a Hidden Markov Model, the weather is the hidden state, the widths of the concentric circles are your observed variables, i.e. emissions. As a matter of fact, the problem you describe is literally a textbook example of HMM's.

2.Even if there are other ways I want to explore the Markov Model as well. Where is a good place to start learning about Markov Models?

And this is the textbook (actually paper) with the solution to your question, exactly.

Predicting the Weather


SonarQube: uploading Cobertura results using Maven

Question: I am using Maven with the Cobertura and SonarQube plug-ins. I want the results in cobertura.ser to be uploaded to SonarQube. This is my pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>delta.coverage.mvp</groupId>
  <artifactId>delta.coverage.mvp</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
    </dependency>
  </dependencies>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <sonar.host.url>http://192.168.1.10:9000</sonar.host.url>
    <sonar.jdbc.driverClassName>org.h2.Driver</sonar.jdbc.driverClassName>
    <sonar.language>java</sonar.language>
    <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
    <sonar.login>admin</sonar.login>
    <sonar.password>adminpwd</sonar.password>
    <sonar.projectKey>delta.coverage.mvp</sonar.projectKey>
    <sonar.projectName>delta.coverage.mvp</sonar.projectName>
    <sonar.projectVersion>test</sonar.projectVersion>
    <sonar.sources>src/main/java</sonar.sources>
    <sonar.java.coveragePlugin>cobertura</sonar.java.coveragePlugin>
    <sonar.junit.reportsPath>${project.basedir}/target/surefire-reports</sonar.junit.reportsPath>
    <sonar.surefire.reportsPath>${project.basedir}/target/surefire-reports</sonar.surefire.reportsPath>
    <sonar.cobertura.reportPath>${project.basedir}/target/cobertura/cobertura.ser</sonar.cobertura.reportPath>
  </properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>cobertura-maven-plugin</artifactId>
            <version>2.7</version>
            <configuration>
                <instrumentation>
                    <includes>
                        <include>**/*.class</include>
                    </includes>
                </instrumentation>
            </configuration>
            <executions>
                <execution>
                    <id>clean</id>
                    <phase>pre-site</phase>
                    <goals>
                        <goal>clean</goal>
                    </goals>
                </execution>
                <execution>
                    <id>instrument</id>
                    <phase>site</phase>
                    <goals>
                        <goal>instrument</goal>
                        <goal>cobertura</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.sonarsource.scanner.maven</groupId>
            <artifactId>sonar-maven-plugin</artifactId>
            <version>3.0.2</version>
        </plugin>

    </plugins>
</build>

<reporting>
    <plugins>
        <plugin>

            <groupId>org.codehaus.mojo</groupId>
            <artifactId>cobertura-maven-plugin</artifactId>
            <version>2.7</version>
        </plugin>
    </plugins>
</reporting>
</project>

I am running mvn clean cobertura:cobertura sonar:sonar in order to build, unit-test (with coverage) and analyze the code+upload the unit test results. The analysis (SonarQube scan) is uploaded successfully. However, the Cobertura results are not uploaded to SonarQube. Instead, the log shows that Maven actually looked for JaCoCo files:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building delta.coverage.mvp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ delta.coverage.mvp ---
[INFO] Deleting /home/phil/git/delta-coverage-mvp/target
[INFO]
[INFO] >>> cobertura-maven-plugin:2.7:cobertura (default-cli) > [cobertura]test @ delta.coverage.mvp >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ delta.coverage.mvp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ delta.coverage.mvp ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/phil/git/delta-coverage-mvp/target/classes
[INFO]
[INFO] --- cobertura-maven-plugin:2.7:instrument (default-cli) @ delta.coverage.mvp ---
[INFO] Cobertura 2.1.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
[INFO] Cobertura: Saved information on 1 classes.
[INFO] Cobertura: Saved information on 1 classes.

[INFO] Instrumentation was successful.
[INFO] NOT adding cobertura ser file to attached artifacts list.
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ delta.coverage.mvp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ delta.coverage.mvp ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/phil/git/delta-coverage-mvp/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ delta.coverage.mvp ---
[INFO] Surefire report directory: /home/phil/git/delta-coverage-mvp/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running delta.coverage.mvp.package1.Test1
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.202 sec
[INFO] Cobertura: Loaded information on 1 classes.
[INFO] Cobertura: Saved information on 1 classes.

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO]
[INFO] <<< cobertura-maven-plugin:2.7:cobertura (default-cli) < [cobertura]test @ delta.coverage.mvp <<<
[INFO]
[INFO] --- cobertura-maven-plugin:2.7:cobertura (default-cli) @ delta.coverage.mvp ---
[INFO] Cobertura 2.1.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
[INFO] Cobertura: Loaded information on 1 classes.
Report time: 108ms

[INFO] Cobertura Report generation was successful.
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building delta.coverage.mvp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- sonar-maven-plugin:3.0.2:sonar (default-cli) @ delta.coverage.mvp ---
[INFO] User cache: /home/phil/.sonar/cache
[INFO] Load global repositories
[INFO] Load global repositories (done) | time=517ms
[INFO] User cache: /home/phil/.sonar/cache
[INFO] Load plugins index
[INFO] Load plugins index (done) | time=116ms
[INFO] SonarQube version: 5.6.1
[INFO] Default locale: "en_US", source code encoding: "UTF-8"
[INFO] Process project properties
[INFO] Load project repositories
[INFO] Load project repositories (done) | time=193ms
[INFO] Load quality profiles
[INFO] Load quality profiles (done) | time=143ms
[INFO] Load active rules
[INFO] Load active rules (done) | time=1824ms
[WARNING] 'sonar.dynamicAnalysis' is deprecated since version 4.3 and should no longer be used.
[INFO] Publish mode
[INFO] -------------  Scan delta.coverage.mvp
[INFO] Language is forced to java
[INFO] Load server rules
[INFO] Load server rules (done) | time=966ms
[INFO] Base dir: /home/phil/git/delta-coverage-mvp
[INFO] Working dir: /home/phil/git/delta-coverage-mvp/target/sonar
[INFO] Source paths: src/main/java
[INFO] Test paths: src/test/java
[INFO] Binary dirs: target/classes
[INFO] Source encoding: UTF-8, default locale: en_US
[INFO] Index files
[INFO] 2 files indexed
[INFO] Quality profile for java: Cloud Managed Services - 201503
[INFO] JaCoCoSensor: JaCoCo report not found : /home/phil/git/delta-coverage-mvp/target/jacoco.exec
[INFO] JaCoCoItSensor: JaCoCo IT report not found: /home/phil/git/delta-coverage-mvp/target/jacoco-it.exec
[INFO] Sensor JavaSquidSensor
[INFO] Configured Java source version (sonar.java.source): none
[INFO] JavaClasspath initialization...
[INFO] JavaClasspath initialization done: 12 ms
[INFO] JavaTestClasspath initialization...
[INFO] JavaTestClasspath initialization done: 4 ms
[INFO] Java Main Files AST scan...
[INFO] 1 source files to be analyzed
[INFO] Java Main Files AST scan done: 193 ms
[INFO] 1/1 source files have been analyzed
[INFO] Java bytecode scan...
[INFO] Java bytecode scan done: 18 ms
[INFO] Java Test Files AST scan...
[INFO] 1 source files to be analyzed
[INFO] Java Test Files AST scan done: 56 ms
[INFO] 1/1 source files have been analyzed
[INFO] Package design analysis...
[INFO] Package design analysis done: 4 ms
[INFO] Sensor JavaSquidSensor (done) | time=560ms
[INFO] Sensor Lines Sensor
[INFO] Sensor Lines Sensor (done) | time=1ms
[INFO] Sensor SurefireSensor
[INFO] parsing /home/phil/git/delta-coverage-mvp/target/surefire-reports
[INFO] Sensor SurefireSensor (done) | time=54ms
[INFO] Sensor SCM Sensor
[INFO] SCM provider for this project is: git
[INFO] 2 files to be analyzed
[INFO] 0/2 files analyzed
[WARNING] Missing blame information for the following files:
[WARNING]   * /home/phil/git/delta-coverage-mvp/src/main/java/delta/coverage/mvp/package1/Class1.java
[WARNING]   * /home/phil/git/delta-coverage-mvp/src/test/java/delta/coverage/mvp/package1/Test1.java
[WARNING] This may lead to missing/broken features in SonarQube
[INFO] Sensor SCM Sensor (done) | time=112ms
[INFO] Sensor Zero Coverage Sensor
[INFO] Sensor Zero Coverage Sensor (done) | time=5ms
[INFO] Sensor Code Colorizer Sensor
[INFO] Sensor Code Colorizer Sensor (done) | time=1ms
[INFO] Sensor CPD Block Indexer
[INFO] JavaCpdBlockIndexer is used for java
[INFO] Sensor CPD Block Indexer (done) | time=159ms
[INFO] Calculating CPD for 1 files
[INFO] CPD calculation finished
[INFO] Analysis report generated in 57ms, dir size=13 KB
[INFO] Analysis reports compressed in 14ms, zip size=8 KB
[INFO] Analysis report uploaded in 218ms
[INFO] ANALYSIS SUCCESSFUL, you can browse http://192.168.1.10:9000/dashboard/index/delta.coverage.mvp
[INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
[INFO] More about the report processing at http://192.168.1.10:9000/api/ce/task?id=AVbYSBOBTyY3I5vbl2iO
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.175 s
[INFO] Finished at: 2016-08-29T16:50:17-05:00
[INFO] Final Memory: 31M/666M
[INFO] ------------------------------------------------------------------------

Comment: In Sonar examples it is configured to generate XML report. We are using it like this: https://github.com/SonarSource/sonar-examples/blob/master/projects/languages/java/code-coverage/ut/ut-maven-cobertura/pom.xml
Comment: @GonzaloMatheu I tried that very same example. I can see the Cobertura report as HTML under `target/site/cobertura` but I can't find `cobertura.xml` anywhere and the results definitely don't show up in SQ. Thanks.
Answer: The problem was that the the Cobertura plug-in on the SQ server was not installed. I installed it and everything worked fine.
Unfortunately nothing in the mvn log showed that Cobertura was invoked, and I assumed that the SQ server would support Cobertura by default since it's one of the main coverage tools for Java. Very counter-intuitive, but at least there is a simple solution.


Record for player hitting the woodwork most number of times in a season in top European leagues?

Question: Robin van Persie hitting the woodwork 10 times in a Premier League 2011/12 is the biggest one that I have found so far for Premier League. Is this the record for Premier League, and what is the record for other European Leagues?
Answer: La Liga:
In 2017/18 season, Lionel Messi hit the woodwork 18 times, which according to Opta, is the most in La Liga season since 2003/2004.
Premier League:
In 2011/12 season, Robin van Persie hit the woodwork 10 times, which according to premierleague.com, is the most in a Premier League season since 2006/2007.

Bundesliga:
In 2017/18 season, Pierre-Emerick Aubameyang hit the woodwork 5 times (I couldn't find anyone else with more and this is most probably not a record).
Comment: I couldn't find any records for Serie A or Ligue 1, but will keep an eye on stats.


How to clear a Text Box in angularJS, when click any link in the page AngularJS

Question: I've a search box and multiple categories links available in the HTML page.
as soon as user input in searchBox, i want to show:
p in Products | filter {serachedText}

When user clicks a category hyperlink, i want to show
p in Products | filter {categoryID}

But because serachedText is still avialble, result showing for
p in Products | filter {categoryID} | filter {serachedText}

Is there any way i can clear the serachedText as soon as user clicks on anylink.
Comment: When a user clicks on the link, set the variable that is bound as the ngModel of the search box as an empty string ('').
Answer: That would be really easy to do in angularjs.
In html.
<input ng-model="mytext">
Clear Text

jsfiddle is here.
Comment: Even if we have many text boxes, we can use the same solution. [jsfiddle is here for multiple text version.](https://jsfiddle.net/yazaki/sk1bqmmL/2/)
Comment: Nope, what we do if I have lot of texbox but i have only one button. :(
Comment: The point of this example is to set the value of scope somehow. [jsfiddle is here for multiple text box and one clear button.](https://jsfiddle.net/yazaki/sk1bqmmL/3/)
Answer: Your filter expression is wrong.
if your data is a JSON array having category and name properties like so:
self.Products = [
  { category: 1, name: 'Pencil' },
  { category: 1, name: 'Notebook' },
  { category: 2, name: 'Kitten' }
];

And you are binding the following things for the selected category and search text:
self.category = 1;
self.searchText = 'pen';

You could create a complex filter expression like so:
filter: { category: vm.category | name: vm.searchText }

This will filter both on category and searchText or in combination.
To clear out the searchText, you can watch if category changes using $scope.$watch and when it changes, clear up the searchText.
Take a look at the example below or at http://plnkr.co/edit/OEDvOn.  In the example, my filter expression is a bit more complicated since the selected category is actually an object containing value and name properties for the selected category, thus I need to add .value to get the right thing to pass to the filter.
Another point: For doing client side filtering, this is fine, but if you are filtering on server side, I'd rather get the filtering done on a service layer and just returned the filtered result instead of all possible data... save bandwidth and transfer time.

(function(undefined) {
  'use strict';

  angular.module('myApp',[]);

  angular.module('myApp')
    .controller('searchCtrl', searchCtrl);

  searchCtrl.$inject = ['$log', '$scope'];

  function searchCtrl($log, $scope) {
    /* jshint validthis: true */
    var self = this;

    self.searchText = undefined;

    self.categories = [
      { value: undefined, name: 'All' },
      { value: 1, name: 'Fruit' },
      { value: 2, name: 'Snacks' },
      { value: 3, name: 'Flower' },
      { value: 4, name: 'Pet' },
      { value: 5, name: 'Stationary' }
    ];

    self.category = self.categories[0];

    self.data  = [
      { category: 1, name: 'Apple' },
      { category: 1, name: 'Grapes' },
      { category: 2, name: 'Dorito' },
      { category: 2, name: 'KitKat' },
      { category: 3, name: 'Roses' },
      { category: 3, name: 'Orchid' },
      { category: 4, name: 'Hamster' },
      { category: 4, name: 'Kitten' },
      { category: 5, name: 'Pencil' },
      { category: 5, name: 'Notebook' }
      ];

    $scope.$watch(function() { return self.category; }, function(val, old) {
      self.searchText = undefined;
    });
  }

}());
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet"/>

        Category
        <select class="form-control" ng-options="cat.name for cat in vm.categories" ng-model="vm.category">
        </select>

        <input class="form-control" type="textbox" ng-model="vm.searchText" placeholder="Search text here..." />

          <button type="button" class="btn btn-primary">
             Search</button>

{{item.name}}

Answer: I'd suggest directive will be the best option
MarkUp
<input ng-model="mytext">
Clear Text

Directive
app.directive('a', function() {
    return {
        restrict: 'E',
        scope: {
            clear: '='
        },
        compile: function(scope, ele, attrs) {
            ele.on('click', function() {
                scope.$apply(function() {
                    scope.clear = undefined;
                })
            })
        }
    }
})


Cannot pass $pdo as parameter in function triggered with onclick()

Question: I have a html button that has an onclick method, which triggers some things to happen with ajax. The variables passed through the function, however, are in php. Here is the code:
Html/PHP
<code>#Do not mind the first forward slash#
/<button type="submit"
    name="follow_button"
    onclick= <?php
        echo "'follow_alert(" . $pdo . ", " . $_SESSION['user_id'] . ", " . $value['user_id'].");'"
        ?>
>Follow
</button>
</code>
Both variables $_SESSION['user_id'] and $value['user_id'] are passing fine. I have tried the code and it works without $pdo, but the problem is I need $pdo to be called to access it in my php function which fetches data from my mysql table.
Here is the JS.
JS
<code>function follow_alert(pdo, user_id, following_id) {
    var ajax = ajaxRequest();
    ajax.onreadystatechange = function() {
        if (ajax.readyState === 4) {
            alert(ajax.responseText);
        };
    };
    ajax.open('GET', 'function.php?pdo='+pdo+'&user_id='+user_id+'&following_id='+following_id, true);
    ajax.send(null);
};
</code>
My problem is : I keep getting a "Catchable fatal error : Object of class PDO could not be converted to string" error. when I pass $pdo as parameters in all my other functions, they work fine. The problem just seems to be that I'm passing it through a string to be run onclick(); At least that is what I think it is.
Any thoughts? I've been wracking my mind over this all morning!
Comment: You need to remember that JS runs on the client and PHP runs on the server.
Comment: @nickb hey can you expound on the ramifications of that statement? I'm very new to PHP and JS, and even newer to programming in general.
Answer: You can't pass a resource, like a PDO instance, to a JavaScript function. It doesn't exist by the time the HTML is rendered. You'll need to create the PDO instance in the PHP script your JavaScript function calls.
Comment: Let me try that out right now! I will get back to you, thanks a lot!
Comment: you are such a blessing to have on this site. Thank you SO FREAKING MUCH. Keep doing what you do man. will accept the answer in 7 minutes!


Solve the differential equations:

Question: $$y' = {y \over {\sin x}}+\tan{x \over 2}$$
I was trying to do this by substitution $u=y/x $ and it did not work and also with
$$y' - {y \over {\sin x}} = 0$$
$${dy \over dx} = {y \over {\sin x}} $$
$${\ln(y) = \ln\left|\tan\frac{x}{2}\right|+c } $$
$${y = c\cdot\tan\frac{x}{2} } $$
but then when im trying to calculate $y'$ I have a problem and I have too many equations. Is there some easier way or am I making some mistakes.
Comment: I think you can rewrite it as a polynomial equation in the complex exponential function of x or maybe x/2 becomes easier, aka "Eulers formulas" and then multiply so that nothing is in a denominator any longer and see if you can identify anything.
Answer: Providing you're well versed with the concept of solving via an integrating factor.

Rewrite in a linear form
\begin{equation}
    \frac{dy}{dx}-y\left(\frac{1}{sin(x)}\right)=tan(\frac{x}{2}).
\end{equation}
We identify the integrating factor $\mu (x)$ as (I'll leave it as an exercise for you to verify this):
\begin{equation}
\mu (x)= exp\left(\int(\frac{-1}{sin(x)})\right) \Rightarrow \mu (x) = exp\left(-\int(cosec(x)dx\right) \Rightarrow \mu(x)= cot\left(\frac{x}{2}\right).
\end{equation}
Then, if we multiply our differential equation through by our integrating factor we get
$$cot(\frac{x}{2})\frac{dy}{dx}-ycot\left(\frac{x}{2}\right)\frac{1}{sin(x)}=tan\left(\frac{x}{2}\right)cot\left(\frac{x}{2}\right).$$
Now by virtue of the product rule (and I suggest you check this out for yourself to verify), we have that
$$\left(cot\left(\frac{x}{2}\right)y\right)'=cot\left(\frac{x}{2}\right)\frac{dy}{dx}-ycot\left(\frac{x}{2}\right)\frac{1}{sin(x)},$$
which is equivalent to the left hand side of our equation. Then making the appropriate replacement and observing the right hand side cancels out to $1$ we have
$$\left(cot\left(\frac{x}{2}\right)y\right)'=1,$$
and it should be trivial from here
$$cot\left(\frac{x}{2}\right)y=x+c_1,$$
that is
$$y=\frac{x+c_1}{cot\left(\frac{x}{2}\right)}=tan\left(\frac{x}{2}\right)(x+c_1),$$
where $c_1 \in \mathbb{R}.$
Comment: why $$cot\frac{x}{2}$$ in the second product of 3rd line is in nominator?
Comment: @c0rv apologies, made a formatting error. has been amended accordingly.
Comment: If you precede three-letter functions with a backslash, they will correctly appear upright, as in `r\cos\theta` $r\cos\theta$ as opposed to $rcos\theta$
Answer: I don't think there "too many equations"
$${ y=C\left( x \right) \tan  \frac { x }{ 2 }  }\\ y'=C'\left( x \right) \tan { \frac { x }{ 2 }  } +C\left( x \right) \frac { \sec ^{ 2 }{ \frac { x }{ 2 }  }  }{ 2 } \\ C'\left( x \right) \tan { \frac { x }{ 2 }  } +C\left( x \right) \frac { \sec ^{ 2 }{ \frac { x }{ 2 }  }  }{ 2 } =\frac { C\left( x \right) \tan  \frac { x }{ 2 }  }{ \sin { x }  } +\tan { \frac { x }{ 2 }  } \\ \\ C'\left( x \right) \tan { \frac { x }{ 2 }  } =\tan { \frac { x }{ 2 }  } \\ C\left( x \right) =x+{ C }_{ 1 }\\ { y=C\left( x \right) \tan  \frac { x }{ 2 }  }={ \tan  \frac { x }{ 2 }  }\left( x+{ C }_{ 1 } \right) \\ \\ $$

Solve the differential equations:


How do I identify common features/similarities of members in a class?

Question: If I need to go over the actual data which I have, I have employee data of our company.
Employees are divided into two groups, binary(1,0). Some of them are 1 and the rest are in 0 class. The data set includes a lot of basic data for each employee, such as age, gender, the school they graduated from, time spent in the company or position. I also want to learn and see the common features of those who are in this 1 class, for example, age range, gender, universities, etc.
I know this looks like a classification problem, but isn't it possible to find these similarities without using any machine learning algorithms?
Do you think it is sufficient to perform frequency analysis and chi-square test, or is there any other analysis method or statistical test you can recommend?
Comment: It sounds like you can just look at histograms and bar charts for your two groups. Plot a bar chart comparing the ages of groups 0 and 1; plot a bar chart comparing the genders;...
Answer: This is really more of a comment than a full response. You could try cross-classifying combinations of the 0,1 features. Next, ranking the frequencies of employees falling into a given bucket would give insight into any redundancy in the groupings. Since it isn't possible to illustrate what I mean by this suggestion within the context of a comment, as noted, it's been expanded into a response.

While this table shows univariate data, it is possible to convert it into a two-way table upon which odds ratio or chi-square tests, e.g., of independence, can be applied.

Conversion of more such binary features into three- and higher way tables would be an easy extension, permitting even more complex tests of significance.


What is a good for system for learning theory through improvisation?

Question: I have been playing the guitar for many years yet I find music theory elusive.  Consequently, my musical vocabulary is limited.  But I still love to improvise and, through trial-and-error, compose music that I think sounds good. Sometimes I get lucky.
I'm wondering if there is an approach to learning music theory by applying it to my haphazard composition "technique."  For example, I would love to be able to collect an assortment of chords and scales that are theoretically compatible, and then experiment within those constraints to build a composition. I have the Guitar Grimoire and some other resources, but I find their scope too broad and intimidating.  I would prefer to "dial up" a set of tinker toys in a particular key to play with, for lack of a better analogy. Where would I start?
Comment: Based on your comment to Kevin's answer it looks you want to learn theory without actually studying theory? I guess I do that sometimes by learning songs I like and trying to figure out why the artists do what they do when writing a song. You won't learn the names for everything but you'll see a lot of different techniques in action.
Answer: Find an article or book about music theory. When you read about a new concept, put the book down and improvise with the new material you just learned.
I'm doing this myself right now. I never actually learned many typical rock or traditional Western harmonies, preferring to use modal chords and exotic modes instead. A few days ago, I realized this was something I'd like to change, so I went to a local bookstore, looked through books on theory, and picked one up that covered harmony in rock. Now I'm going through it, playing the chord progressions on my piano and occasionally stopping to improvise a song with some of the chords and ideas I'm learning about.
Likewise, I need to learn about Celtic music for a project I'm involved in. I bought a book about how to play rhythm section in a Celtic band, and as soon as it arrives, I'm planning on reading it in the same way.
Answer: You can learn theory by ear training. Playing songs just by ear and learning them is learning theory by instincts. But you couldn't communicate with anyone what you know verbally. People like Hendrix or James Hetfield from Metallica are known not to have any training but used their ears for composing or improvising music. They gained a huge vocabulary of musical phrases and songs to come up with ideas of their own that are theoretically correct by most standards.
But if you want to understand what you are doing then you need to get lessons or read material, hence learning theory. I don't think theory is essential if you have a great ear, but your curiosity will drive you to find information on it.
Comment: +1 but one thought.  Theory should be used to describe why something sounds good, not what is acceptable, so your comment "theoretically correct" does not sit well with me.  I definitely understand your meaning though.  I just hate when people think of theory as rules because they are only rules when you are trying to replicate a specific style, hence the theory behind Classical and Jazz being almost entirely different.


Three columns header with nav

Question: I am in need of help regarding a three columns header with an image.
I need that the middle column be able to hold an image that has the dimension 166px x 156px. I want to have navigation in the right and left columns. All of the columns header will contain a background-color of black.
The nav is a drop down menu and as much as I toggle with it, I cannot make all of the 4 go horizontally across the page, resting at the same height on the page next to the image and the entire thing centered.
The code I currently have is:

.wrapper {
    width:100%;
    height:50px;
    display: table;
}
.central {
    width:166px;
    height:156px;
    background-color:#000;
    display: table-cell;
}
.left, .right {
    height:156px;
    display: table-cell;
    background-color:#000;
}
.right {
    background-color:#000;
}

Comment: What is the problem?
Comment: Can you please let us know what do you want to do and where is the problem
Comment: The nav is a drop down menu and as much as I toggle with it, I cannot make all of the 4 go horizontally across the page, resting at the same height on the page next to the image.
Comment: @LydiaMorales you need to be more clear in the definition of your problem. Doing a simple copy-n-paste from your original question for a response to a question in comments for more information for the people who are *trying to help you* does not suffice. Please provide more details, add some code (jsFiddle) or possibly a simple diagram of current state vs desired state. Thank you.
Answer: Check with the below CSS
.wrapper {
    width:100%;
    height:50px;
}
.central {
    float: left;
    width:166px;
    height:156px;
    background-color:#000;
    margin-left:5px;
}
.left, .right {
        float: left;
    height:156px;
    width: 30%;
    background-color:#000;
}
.right {
    background-color:#000;
    margin-left:5px;
}

Three columns header with nav