Não estou conseguindo identificar este erro: [Vue warn]: Error in render: "TypeError: Cannot read property '$error' of undefined"

Question:     <template>

    <form class="form-horizontal" role="form">

          Nome: *

            <input type="text" class="form-control" id="nomer" v-model="remedio.nomer" autocomplete="off" @input="$v.remedio.nomer.$touch()" maxlength="50">
            Campo é obrigatório

          Descrição:

            <textarea
              type="text"
              class="form-control"
              id="descricao"
              autocomplete="off"
              v-model="remedio.descricao"
            ></textarea>

          Data de Validade: *

              <input
                type="text"
                class="form-control"
                id="dataDeValidade"
                autocomplete="off"
                v-model="remedio.dataDeValidade" />
              Campo é obrigatório

          Quantidade: *

              <input
                type="text"
                class="form-control"
                id="quantidade"
                autocomplete="off"
                v-model="remedio.quantidade" />
              Campo é obrigatório

Não consegui identificar o que está indefinido no meu código
Comment: É difícil responder sem ver mais código. Pode ser qualquer uma das seguintes propriedades: `nomer`, `dataDeValidade`, `quantidade`, `principioAtivo`. Pode até mesmo ser `remedio`.
Comment: Eu identifiquei que o problema está no principioAtivo, mas não sei o que eu esqueci de por no meu código,  vou mandar mais dele
Answer: <template>

    <form class="form-horizontal" role="form">

          Nome: *

            <input type="text" class="form-control" id="nomer" v-model="remedio.nomer" autocomplete="off" @input="$v.remedio.nomer.$touch()" maxlength="50">
            Campo é obrigatório

          Descrição:

            <textarea
              type="text"
              class="form-control"
              id="descricao"
              autocomplete="off"
              v-model="remedio.descricao"
            ></textarea>

          Data de Validade: *

              <input
                type="text"
                class="form-control"
                id="dataDeValidade"
                autocomplete="off"
                v-model="remedio.dataDeValidade" />
              Campo é obrigatório

          Quantidade: *

              <input
                type="text"
                class="form-control"
                id="quantidade"
                autocomplete="off"
                v-model="remedio.quantidade" />
              Campo é obrigatório

          Princípio Ativo: *

              <multiselect id="principioAtivo" :options="principios" placeholder="Digite para pesquisar" label="nomep" track-by="id" v-model="remedio.principioAtivo" :show-labels="false">
                  Nenhum registro encontrado
              </multiselect>
              Campo é obrigatório

          <button type="submit" id="btnSalvar" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ui-priority-primary button-form"
              @click.prevent="salvar(false)">
              Salvar
          </button>
          <button type="submit"  id="btnSalvarNovo" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only btn-verde button-form"
              @click.prevent="salvar(true)">
              Salvar/Novo
          </button>
          <button  id="btnVoltar" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-left button-form btn-voltar" @click.prevent="voltar">

              Voltar
          </button>

      </form>

</template>

Comment: O problema está no objecto `validations.remedio`, pois não tem nenhuma propriedade chamada `principioAtivo`.
Comment: Obrigado, era justamente isso que faltava =)


git diff shows difference after git pull from a branch

Question: I have a dev branch and a bugfix/a branch.
I want to sync up my bugfix/a with dev, so I do a
git pull origin dev

from my bugfix/a branch, but after that, I still see git diff shows differences:
git diff --name-only dev..bugfix/a
why git pull doesn't merge all the changes from dev to my branch?
Answer: Are you sure your dev branch is up to date?
When you do git pull origin dev on another branch, only that other branch is getting updated, not the local dev branch.
If you will checkout your dev branch and if it is a tracking branch, it will show a message on the lines of branch is behind by so many commits.
Even if it is not a tracking branch, you will still need to update your dev branch locally so that it matches the changes on the origin branch.
In future, you can avoid this confusion by checking out dev, pulling in the changes in dev, and then checking out your bugfix branch, and merging changes there:

git checkout dev && git pull origin dev
git checkout bugfix/a && git merge dev


Recommendations on good terminal multiplexer

Question: Please recommend me a good terminal multiplexer.  I'm new to sys admin work and need a good way to mange multiple boxes.
Edit:
Just be clear, I'm looking for something like PuTTy that can send commands to multiple boxes at once.
Usage example:  Installing an rpm on 10 different boxes.  It's tedious to have to do each one manually.
Comment: Just to be clear, are you looking for a piece of hardware that allows you to connect to RS232 interfaces of multiple devices?
Comment: You have this tagged as Linux but refer to Putty. Which client OS are you trying to run this on?
Answer: GNU Screen was invented just for this, it is indispensible and I use it every day.
Also Tmux has been getting a lot of attention lately, it is a lightweight version of screen.
Answer: A comprehensive best practice answer covering the management of multiple systems using methods like puppet, cfengine, Spacewalk, Kickstart, and other integral utilities would be appropriate.
Instead, I'll example the benefits of creating your own with:
<code>for H in `hosts`
do
     ssh $H "# do things and stuff ; yum -y update"
done
</code>
Thankfully, I've also covered the first one here:
Managing an application across multiple servers, or PXE vs cfEngine/Chef/Puppet
Answer: I think Cluster SSH works best in these situations. You get individual windows for each server, but a dialog transmits all of your keystrokes to all servers.
That way, if your 'rpm' command bombs out on one server, you can click on that server and investigate/resolve the issue.
http://sourceforge.net/projects/clusterssh/
Comment: I've found SSH pipes to be better suited for managing multiple servers.  While novel, this technology is fallible and less flexible.
Answer: I use dancer-shell on a small cluster, which can execute shell commands in parallel on a list of hostnames. If you have a lot of systems, dsh can be impeded by network throughput. It offers a tree topology option to have hosts call hosts and so-on, as long as they all have dsh installed.
Dsh is nice, but it has some drawbacks. If your network or systems are busy, failure will occur, leaving you with some systems in one state and other systems in another. You can try to write idempotent commands and just keep running it until everything comes back ok, I guess. But the common solution is to have some sort of agent which tries to bring the system from it's current state to the existing one; this approach allows it to retry if a transient network error occurs. This is the approach cfengine/puppet/chef take to varying degrees.


Split point - Ableton live

Question: I am a Grade I performer on the Keyboard and right now I am using Apple Mainstage as my performance tool. Lately I am feeling that i can get better performance on Ableton live, Since for my reaktor blocks, the CPU usage is shooting off.
I am thinking of using track activator buttons on tracks, with the help of Novation 61, which syncs with Ableton live nicely. My question is how to achieve split point in Ableton live and is there any performance improvement when it comes to Mainstage compared to Ableton live.
Answer: Load an Instrument Rack and in that load Reaktor. In that click the Key option and set the range in which this instrument will trigger sound.
Open the side chain and load another Reaktor, for the left hand chords, click on the "Key" option and set the keyboard range you want this to trigger.

Split point - Ableton live


Docusign api Folders: list subfolders not appearing

Question: I am trying to get all template folders including subfolders from the API. I attempted to use the folders:list api method https://developers.docusign.com/docs/esign-rest-api/reference/folders/folders/list/ setting the include parameter to "template_folders" which brings back the templates folder and the first level of user folders including the "hasSubFolders" boolean but I do not get a list of subfolders. Is there a way to get the whole hierarchy from the API? The documentation seems to indicate the whole list of folders and subfolders should be returned.
Answer: From postman or just calling raw APIs you need to do this:
/folders?user_filter=owned_by_me&include=envelope_folders,template_folders,shared_template_folders&sub_folder_depth=-1

I think the key is the sub_folder_depth=-1 which I assume -1 means to go as deep as needed.


Reconectar Websocket após perda de conexão

Question: Eu uso este código para me conectar ao meu servidor com WebSockets:
(function(nameSpace) {
  function createMethod(method, options, stateCallback) {
    var that = this;
    this[method] = function() {
      if (stateCallback && stateCallback.apply) {
        stateCallback(method);
      }
      console.info(method);
      if (options[method] && options[method].apply) {
        options[method].apply(that, arguments);
      }
    };
  }

  function SocketWrapper(options) {
    var ws,
      events = ['onopen', 'onmessage', 'onclose', 'onerror'],
      i, len, prop = {
        opened: false,
        closed: false,
        error: false
      },
      method;

    if (typeof options === 'undefined' || !options) {
      throw 'ArgumentException: please add default constructor options';
    }

    this.queue = [];

    this.onEventTrigger = function(eventName) {
      var i, len;
      if (eventName === 'onopen') {
        prop.opened = true;
        prop.closed = false;
        // openend send queue
        if (this.queue.length > 0) {
          for (i = this.queue.length; --i >= 0;) {
            this.send.apply(this, this.queue[0]);
            this.queue.splice(0, 1);
          }
        }
      }
      if (eventName === 'onerror') {
        prop.error = true;
      }
      if (eventName === 'onclosed') {
        prop.opened = false;
        prop.closed = true;
      }
    };

    this.init = function() {
      var cb = this.onEventTrigger.bind(this);
      ws = new WebSocket(options.url);

      for (i = 0; i < events.length; i++) {
        method = events[i];
        createMethod.apply(ws, [method, options, cb]);
      }
    };

    this.send = function() {
      if (prop.closed) {
        throw 'InvalidOperation: Cannot send messages to a closed Websocket!';
      }
      if (!prop.opened) {
        this.queue.push(arguments);
      } else {
        ws.send.apply(ws, arguments);
      }
    };

    this.init();
    return this;
  }

  window.SocketWrapper = SocketWrapper;
}(window));

var socket = new window.SocketWrapper({
  url: 'ws://127.0.0.1:1805',
  onopen: function() {
    this.send('message', 'hi');
  },
  onmessage: function() {
    console.log(arguments);
  },
  onclose: function() {
    socket = null;
  },
  onerror: function() {
    console.log('error occured, oh no!');
    console.error(arguments);
  }
});
socket.send('i am message send to soon, but since i check the state of the ws object, i will be queued and send when appropriate');

Esse código me cai bem, foi a solução que eu encontrei pro meu caso, porém eu queria que ele se reconectasse assim que a conexão fosse perdida, ele ficasse tentando reconectar até conseguir..não sei muito como adaptar porque não é meu, como proceder?
Comment: Diferente dessa sua outra [pergunta](http://pt.stackoverflow.com/a/55082/6454), aqui você deve verificar isso no evento [**Onclose**](http://www.w3.org/TR/2011/CR-websockets-20111208/#dom-websocket-close).
Comment: @Qmechanic73 sim isso eu sei, mas como força-lo a refazer a conexao apartir dai?
Comment: Tenho uma ideia, mas tenho como testar, não sei se é viável também, posso arriscar uma resposta. =/
Comment: @Qmechanic73 qualquer idéia vale uma resposta haha
Comment: Dessa linha(`var socket = new window.SocketWrapper({`) para baixo delete e tente implementar esse [**código**](http://pastebin.com/4GpmxC5E), não cheguei a testar, veja se algo ocorre. =)
Comment: @Qmechanic73 funcionou, bela idéia! Vou ficar testando, obrigado!!
Comment: @Qmechanic73 testei testei e funciona corretamente, obrigado dnv =)
Comment: Postei a resposta. Eu sem querer usei `return socket = new window.SocketWrapper..` no início da função, retire o `socket = `.
Answer: Quando a conexão é perdida o evento onclose é acionado, para fazer a reconexão você deve trabalhar em cima desse evento.
Um modo que você pode utilizar para conectar novamente é por meio da função setTimeout, ela vai executar uma ação a cada n segundos.
Ao invés declarar a variável socket com todo aquele código, faça isso numa função:
function CreateSocketWrapper(){
    return new window.SocketWrapper({
      url: 'ws://127.0.0.1:1805',
      onopen: function() {
        this.send('message', 'hi');
      },
      onmessage: function() {
        console.log(arguments);
      },
      onclose: function() {
        setTimeout(function(){CreateSocketWrapper()}, 5000); // 5 segundos
      },
      onerror: function() {
        console.log('error occured, oh no!');
        console.error(arguments);
      }
    });
}

E para usá-la:
var socket = CreateSocketWrapper();
socket.send('i am message send to soon, but since i check the state of...');


Migrating Roaming Profiles from one drive to another

Question: As the title suggests, how can I migrate roaming profiles located in one drive (starting to fill up already) to another?
Current share is like this "SVR1\Shares\UserProfiles\%username%\
But of course, this is located in C:/Shares/UserProfiles/%username%/
What do I need to do? Do I simply copy/paste into the bigger(RAID1) drive and then repoint all the profile paths (using AD Users&Computers profile properties)?
What if I can point this to a different file server all together?
Best practices? tips? anything you guys can suggest. Thanks!
Comment: Anyone? I'm trying to hold off on doing this as I'm afraid I might break something...
Answer: This is not as tough as it may seem.

You need to copy the profiles with their NTFS file system permissions. Robocopy is a good tool for that job. Try something like this:
robocopy /mir /sec "source folder" "destination folder" /r:0 /np /log+:logfile.txt
Remove the file share from the old profile directory
Share the new profile directory under the same name as the old directory before.

You are done.
Additionally, here are some guidelines on user profile design.
Comment: I assume that it would also be alright if I used NTBACKUP? So it seems that moving Roaming Profiles folders, one has to be careful about retaining the permissions and the actual re-point of the "share".
Comment: Yes, NTBackup is another viable option. And yes, permissions and the share should stay the same.


Tab vs. espaços, para indentação de código

Question: Existe alguma recomendação sobre o que é mais apropriado? Caractere de tabulação (<code>\t</code>) ou espaços?
Pelo que vejo, costuma-se ter convenções por linguagem:

Ruby: dois espaços
Delphi: dois espaços
Python: quatro espaços
Java: tabulação
etc

No caso do Python temos uma particularidade, a indentação é levada em conta pelo compilador, mas ele é inteligente para reconhecer tanto espaços como tabulação.
Answer: Desconheço uma recomendação padrão para identação. Cada linguagem usa a sua.
O que eu costumo praticar é seguir a convenção de cada linguagem. Em geral é mais comum usar espaços que tabs.
O que sempre foi uma boa prática pra mim é no começo de um projeto, envolvendo mais de um desenvolvedor, sempre escrever um documento de "code standards" que não só define identação, como também nomes usados em variáveis, métodos, onde usar camelCase, onde usar PascalCase, etc.
A primeira regra desse documento é: para qualquer situação que não se tem algo combinado, combinar.
Pra mim sempre funcionou bem trabalhar desse jeito.


Push parent arrays element and chidren array into new array in javascript

Question: <code>"items": {
"hotdrinks": [
  {
    "id": "9aa113b4-1e4e-4cde-bf9d-8358fc78ea4f",
    "price": 20,
    "name": "Tea",
    "img": "../assets/img/HotDrinks/1_udupibhavan.jpg"
  },
  {
    "id": "9aa113b4-1e4e-4cde-bf9d-8358fc78ea4f",
    "price": 25,
    "name": "Coffee",
    "img": "../assets/img/Hot Drinks/2_udupibhavan.jpg"
  },
  {
    "id": "9aa113b4-1e4e-4cde-bf9d-8358fc78ea4f",
    "price": 50,
    "name": "Hot Milk",
    "img": "../assets/img/Hot Drinks/3_udupibhavan.jpg"
  },
  {
    "id": "9aa113b4-1e4e-4cde-bf9d-8358fc78ea4f",
    "price": 70,
    "name": "Horlicks",
    "img": "../assets/img/Hot Drinks/4_udupibhavan.jpg"
  },
  {
    "id": "9aa113b4-1e4e-4cde-bf9d-8358fc78ea4f",
    "price": 80,
    "name": "Badam Milk",
    "img": "../assets/img/Hot Drinks/5_udupibhavan.jpg"
  }
],
</code>
}
json i want to achieve using javascript. im just new to handling arrays and objects. thanksfound the answer given by Jeeva which works perfectly
future answers are welcome since we can know diffferent methods to achieve the same json object
<code> dataArray = [
 {title:"Hotdrinks",
 content: [{
        "id": "9aa113b4-1e4e-4cde-bf9d-8358fc78ea4f",
        "price": 20,
        "name": "Tea",
        "img": "../assets/img/HotDrinks/1_udupibhavan.jpg"
      },
      {
        "id": "9aa113b4-1e4e-4cde-bf9d-8358fc78ea4f",
        "price": 80,
        "name": "Badam Milk",
        "img": "../assets/img/Hot Drinks/5_udupibhavan.jpg"
      }
]}
</code>
Comment: which language you are using?
Comment: Can help you https://stackoverflow.com/questions/4825899/how-to-push-both-key-and-value-into-an-array-in-jquery
Comment: @Shravan Jain javascript.!
Comment: okay. I guess you got the answer?
Answer: You can use like this. This can be achieved by iterating the object.

<code>const data = {
              "items":{
                "hotdrinks":[
                  {
                  "id":"9aa113b4-1e4e-4cde-bf9d-8358fc78ea4f",
                  "price":20,
                  "name":"Tea",
                  "img":"../assets/img/HotDrinks/1_udupibhavan.jpg"
                  },
                  {
                  "id":"9aa113b4-1e4e-4cde-bf9d-8358fc78ea4f",
                  "price":25,
                  "name":"Coffee",
                  "img":"../assets/img/Hot Drinks/2_udupibhavan.jpg"
                  },
                  {
                  "id":"9aa113b4-1e4e-4cde-bf9d-8358fc78ea4f",
                  "price":50,
                  "name":"Hot Milk",
                  "img":"../assets/img/Hot Drinks/3_udupibhavan.jpg"
                  },
                  {
                  "id":"9aa113b4-1e4e-4cde-bf9d-8358fc78ea4f",
                  "price":70,
                  "name":"Horlicks",
                  "img":"../assets/img/Hot Drinks/4_udupibhavan.jpg"
                  },
                  {
                  "id":"9aa113b4-1e4e-4cde-bf9d-8358fc78ea4f",
                  "price":80,
                  "name":"Badam Milk",
                  "img":"../assets/img/Hot Drinks/5_udupibhavan.jpg"
                  }
                ]
              }
            }

var dataArray = []

for(k in data.items){
  var dataObj = {}
  dataObj.title = k
  dataObj.content = data.items[k]  //You can also access the object values by using bracket ([]) notation
  dataArray.push(dataObj)

}

console.log(JSON.stringify(dataArray))            </code>
Answer: The above expected output json is not valid. We can achieve the following.
<code>[{"title":"Hotdrinks"}, {"content": [
     {
        "id":"9aa113b4-1e4e-4cde-bf9d-8358fc78ea4f",
        "price":20,
        "name":"Tea",
        "img":"../assets/img/HotDrinks/1_udupibhavan.jpg"
     },
     {
        "id":"9aa113b4-1e4e-4cde-bf9d-8358fc78ea4f",
        "price":25,
        "name":"Coffee",
        "img":"../assets/img/Hot Drinks/2_udupibhavan.jpg"
     },
     {
        "id":"9aa113b4-1e4e-4cde-bf9d-8358fc78ea4f",
        "price":50,
        "name":"Hot Milk",
        "img":"../assets/img/Hot Drinks/3_udupibhavan.jpg"
     },
     {
        "id":"9aa113b4-1e4e-4cde-bf9d-8358fc78ea4f",
        "price":70,
        "name":"Horlicks",
        "img":"../assets/img/Hot Drinks/4_udupibhavan.jpg"
     },
     {
        "id":"9aa113b4-1e4e-4cde-bf9d-8358fc78ea4f",
        "price":80,
        "name":"Badam Milk",
        "img":"../assets/img/Hot Drinks/5_udupibhavan.jpg"
     }
  ]}]
</code>
If you are okay with this then i'll give you the sample code for the same.


Facebook login button does not go to Safari, but goes to app instead, then glitches back

Question: I'm not sure how to replicate the bug consistently yet, but it happens sometimes when I delete the app and reinstall it on a device:
So once in a while when I login with the Facebook button. the Facebook app opens.  Usually the way it works is that it is suppose to open the facebook browser on safari.
Anyway it opens the Facebook app, and then goes back to my app without doing anything. And it just keeps doing that over and over every time I press the login button until I delete my app and redownload it. Is anybody else experiencing that? I am using Swift 3.
Here is a gif of the problem:
Gif of Facebook login problem
and here is my code for the Facebook login:
fbLoginManager.logIn(withReadPermissions: ["public_profile", "email", "user_friends"], from: self) { (result, error) -> Void in
        if (error != nil){
            print(error)

            let loginManager = FBSDKLoginManager()
            loginManager.logOut()
            var controller:LoginController
            controller = self.storyboard?.instantiateViewController(withIdentifier: "LoginController") as! LoginController
            SCLAlertView().showWarning("Login Error #23", subTitle: "Could not log you in, this one is on facebook")
            self.present(controller, animated: true, completion: nil)
        } else {
            print("logging in")

        }
    }

Comment: you can do using set  behaviour of FBSDKLoginManager to FBSDKLoginBehaviorWeb. ans also refer following link : http://stackoverflow.com/questions/31311125/how-to-integrate-facebook-without-redirect-safari-browser-in-ios-app-with-latest
Answer: There are serval behavior options to login with Facebook SDK, you can choose one by setting loginBehaviorproperty of fbLoginManager:
typedef NS_ENUM(NSUInteger, FBSDKLoginBehavior) {
  /*!
  */
  FBSDKLoginBehaviorNative = 0, /*!
  */
  FBSDKLoginBehaviorBrowser, /*!
  */
  FBSDKLoginBehaviorSystemAccount, /*!
  */
  FBSDKLoginBehaviorWeb,
};

In your case, you can set it to FBSDKLoginBehaviorBrowser, an example could be :
func fbLogin(){
    //firstly check whether system fb account available, if so use it
    if SLComposeViewController.isAvailableForServiceType(SLServiceTypeFacebook){
        fbLoginManger.loginBehavior = FBSDKLoginBehavior.SystemAccount
    }
    //then check whether fb app available, if so open it
    else if UIApplication.sharedApplication().canOpenURL(NSURL(string: "fb://")!){
        fbLoginManger.loginBehavior = FBSDKLoginBehavior.Native
    }
    //lastly, present a popup web inside app
    else{
        fbLoginManger.loginBehavior = FBSDKLoginBehavior.Web
    }

    fbLoginManger.logInWithReadPermissions(["public_profile"], fromViewController: self) { (result:FBSDKLoginManagerLoginResult!, error:NSError!) -> Void in
       ...
    }


What should a guitarist learn first: Rhythm or Lead?

Question: It is a slightly subjective question, however, there is, I'm sure, a common consensus as to what lends itself better to a beginner so as not to get frustrated with the instrument.  I'm curious as to what the Teachers in the audience have found over the years to be the case with their students.
So, to make it less subjective - technically what would work better for beginners: Rhythm or Lead so that they want to keep playing and not get frustrated.
Comment: I just want to say as a guitarist of about 25 years and a teacher of about seven years, I object to the idea that guitar is divided up between "rhythm" and "lead". It's all guitar. Sometimes "rhythm" guitar involves playing single notes (e.g., James Brown backing), and sometimes "lead" guitar involves playing chords (Zeppelin and Pink Floyd among others), and it doesn't make sense IMHO to arbitrarily divide them up into not-so-meaningful categories.
Answer: You should definitely start with rhythm.
For a beginner it is one the most valuable things: to understand that music is all about rhythm. Song can exists without a guitar solo, but definitely cannot exists without a solid rhythm line.
Another issue for beginner guitarists is that they rarely have someone to jam with. Playing a solo without any backing up is not very entertaining, while single rhythm section can create a whole full-sounding song.
Even if your aim is to become a great lead guitarist, a good knowledge of rhythm guitar will give you a perfect sense and understanding on how solo lines work. You will feel, when the chord change is coming up and when it is time to change the mode. your lead playing can be only as good as your rhythm playing is.
And finally, the quote by one of the famous guitar teachers:

The solo is only 10 seconds of a song.
  If a sting will break on your guitar,
  you can use those 10 seconds to grab
  another one and successfully finish
  the song.
Comment: I don't understand why you would want to break a string on your guitar. Seems like a strange thing to do.
Comment: I have nothing substantial to add, but I'd love to see a video of someone changing his guitar string as fast as possible. I guess 30 seconds, under prepared conditions, could possibly be enough?
Comment: on a workbench with a string winder, about 20 seconds.
Answer: I have helped a few people find their feet with the guitar.  Generally I have found that new starters  often need something to keep them on the proverbial hook; so its better to find something that they already like and listen to, that they can realistically learn pretty quickly.  Whether this is rhythm or not inst so important.
Each new fully formed tune that they can actually play and recognise as a tune keeps the learner on the hook and wanting more.  The longer and more monotonous the road to their first 'victories', the more likely they are to get bored and find another hobby.
Another thing I have found it that people tend to be able to tolerate fretting chords better after their fingers have seen some scale type fretwork; which goes some way towards warming their hands up before the pressure of chords.
Generally I would start someone of with some 12 blues in E, with some small licks using the open E Pentatonic scale.   This is because the 12 bar is a common musical theme even across a lot of styles; and its pretty difficult to find someone who cant identify with it in some way or other.  Its also very malleable and extendible; you can build on it, such that the learner is jamming with you very quickly, I have never known anyone to give it up completely after having got far enough to be able to jam.   Even if its not played in a blues style, it still works.  Hey Joe(Hendrix) is good one for this, people love the fact they can play that intro basically straight away.
I wouldn't necessarily recommend the blues for everyone as a starting point though, you need to ask the person and decide what to do from there.
Answer: I personally think that rhythm is the way to go since a strong harmonic foundation is needed to successfully improvise.
BUT this doesn't mean you can't practice them together! Learn some rhythm for a backing track then attempt to play some lead over it! Just focus on rhythm so you learn to play with the changes instead of against(which isn't terrible but requires much more talent to make it work).
The reason rhythm is better is because it provides the foundation for knowing the "right" notes to solo with. When you are soloing you are not just randomly picking notes from a scale or the neck. You are playing a melody that must fit over the changes(it doesn't always(usually depends on style) have to but it generally sounds better when it does).
Jazz and Country are almost exclusively based on the use of "chord-scale" where the chord is the root for choosing the melody. If you start with learning your scales first, like I did, you might be able to play a billion notes and get some good licks in but it will be harder to make those licks fit over the proper chord. You'll be emphasizing non-chord tones notes too much and while sometimes it can sound cool it generally more than not sounds too random and/or non-stylistic.
When you learn rhythm you'll develop that ability faster and center your thinking around it. When it comes time to solo, it's not much more difficult to do so(at least for some people).  The idea is that a "lead" in country and jazz is more about playing notes of the chords rather than of the scales. So when you already know the chords well you simply play them and learn little tricks to use the more "melodic" like(Hendrix did this a lot and you can learn a lot from him).
Also you generally wanna see scales as belonging to chords and not the other way around. This helps knowing which scales go with which chords. When you learn it the other way around you just see a scale and a key without connection to the momentary chord and it can be hard to get used to thinking about it otherwise.
That is, it's generally not preferable(Although it is easier) to think in terms of scales instead of chords. You'll sound better and more like you know what your doing if you think in terms of chords because you'll always fit with the rhythm. Why? Because essentially you are playing the rhythm. If you are simply playing the rhythm then you can't be wrong. When you think in terms of scales though, You have many more notes to chose from and are more likely to get it wrong.
In Jazz and Country there are 4 notes over each chord that are most important. In fact 2 if these are generally regarded as the "key" notes. In jazz it's the 3rd and 7th and in country it's the root and 7th(Blues too).
A scale generally has 5 to 7 notes. If you think in terms of scales you more than likely not be focusing on those more important tones because you see a scale as simply a collection of notes. If you can see the chords in the scales and see them and the scale change when the harmony does then you'll be doing much better. Learning rhythm "first" will help this.
But if you do not learn your scales and do not focusing on soloing you may develop the opposite problem I have described above. Seeing the Chords too much and not the scales in them. In this case your "solo's" may sound way to much like rhythm because your not able to add non-chord tones to make it more interesting and melodic(melody tends to have a lot of step-wise movement).
Just about any fingering picking tune is based on these principles. This is because they have to provide the harmony, rhythm, and melody at the same time. When you learn these songs you immediately can see how they are doing this. They generally play chords and use the right hand to pick out the melody from the chord and use the fingers of the left hand to add melodic notes not in the chord when they can.
Then again, if rhythm is very easy for you and learning progressions and such are easy then maybe focusing on scales will be more beneficial. The ultimate goal is not to think of chords and scales but to allow the music to flow through unimpeded by conscious thought. One thing you don't want to do is get lost on a progression and just ramble in the correct scale. If you have a strong since of rhythm you'll more likely just go to playing it and possibly adding some simple chord fill that will probably sound good and no one will know you got lost because it fit exactly with the harmony.
If I were just starting out I would spend about 80% on rhythm and 20% on lead. Once I was able to play just about any rhythm and in simple chordal fills(playing notes not in the chord in a melodic like way while still playing the chord) I would change it to about 65% rhythm. I would then work on making the my rhythm sound as good as I can get it and at some point later I would bring it to about 50/50 and possibly start focusing more on soloing.
Comment: "I personally think that rhythm is the way to go since a strong harmonic foundation is needed to successfully improvise."

Why the assumption that every guitarist's aim is to improvise?  Don't some of them want to become employable musicians?
Answer: I think knowing how to play rhythm well is extremely important. There are a lot more gigs available to a good rhythm player, and, in almost every song you play, you'll be covering a rhythm part for most of the soft, occasionally stepping out to cover the lead part.
In every band I've been in, country, jazz or rock, I concentrate on good rhythm parts that are dead-on with the drummer, that are rhythmically interesting, and that add something to support the melody. I've been the lead player in almost every band I've been in, but it's the rhythm parts I play that I consider more important.
A good rhythm player has to be there, but almost invisible. The part they play helps hold the song up, keeps it moving, ties the bass and drums and keyboards together, and, when the lead player starts playing, feeds them ideas if they're improvising.
My favorite rhythm player is Robbie McIntosh, from The Pretenders, who's done work with Paul McCartney and John Mayer. The man is amazing; His guitar parts are absolutely beautiful and played perfectly. He can play lead, but knows how to step back and play rhythm without detracting, and that's what we should aspire to.
So, I always recommend knowing how to play rhythm well, and learn it first. Once you know the chords and rhythm patterns it becomes easy to build on top of that and step into playing lead.
Answer: I used to think rhythm and chords are the best way for most people to start. And they do form a very important foundation. But after teaching hundreds of students how to play the guitar, I have realized that it's most important to learn what is in your grasp to learn, right now.
That means that learning a few simple chords and how to play them rhythmically is important. But after that, the next step may not be to learn the "Open Campfire Chords", but instead to do what is next in your grasp. And that very well may be learning some simple lead parts, such as the catchy-but-simple intro to Jason Mraz' "I'm Yours", or even the hokey but memorable "Twinkle-Twinkle Little Star" melody. When you can rise to these challenges, you realize that playing simple melodies on the guitar is not all that difficult.
Either way, I disagree with the notion that guitar is best divided into the functions of "rhythm" and "lead", and also with the idea that one of these should  be somehow "learned" before giving thought to the other.
Most of the beginner students I see are learning both simple chords and simple within 1-2 weeks, and they begin extending these into simple rhythmic parts and simple lead parts, respectively.
Within about 4 weeks, most of my students can read many simple melodies by following along with the scale patterns that they learned, and play a simple block-chord accompaniment for a few of the most common chord progressions, like G, C, D. I feel that it's important to concentrate on specific key areas for improvement, but it's also important not to neglect some aspect of your playing and be caught in a rut. If you learn a ton of chords and can play alot of interesting rhythms, but can't do much else, you'll likely get bored. And worse, when you realize you're starting all over again at the beginning to learn lead, that can be very discouraging if you're already really good at chords. And that can lead you to neglect lead practice and go back to strumming the chords you're good at. Many, many, many guitar players (most?) seem to get stuck once they find their "comfort zone", unless there's some compelling reason for them to leave their comfort zone again.
Answer: In my experience as a teacher, a student who is not interested in understanding the structure of a song is never going to play anything interesting as a "lead guitarist", and in my experience as a musician a "rhythm guitarist" who can't come up with a lead part is probably not someone who's going to play anything you'd want to hear as an accompanist, so I think there's a large red herring built into the question.
In short, I can't imagine trying to teach "lead" as distinct from "rhythm" playing, any more than I can imagine trying to teach someone multiplication as something distinct from division.
Less briefly: when I was teaching, I typically started with a parallel path which involved developing finger strength to play the basic open chords (which were given as arbitrary patterns, at first) and also learning the fundamentals of the major scale and how to find the scales on the fretboard. This obviously led to the discovery that the chords and the scales were related, and usually the students would realize in the course of their exercises that they could move both scales and chords around, which typically gave them great joy. Obviously, we'd continue in this way, teaching new ideas and developing both the scalar concepts and the chordal concepts as though they were two sides of the same coin, which of course they are.
Answer: It is true that rhythm guitar keeps the background of any music, but to my own opinion, you first learn how to crawl before learning how to walk. Remember that chord has it lessons which is derived from the basics of guitar lesson. In the case like this you need the basics to lay the rhythm foundation.
Answer: Evolution wise humans created melody before harmony and it is definitely easier to play simple melodies before putting together chord progressions without that annoying stoppage between chord changes. what are chords anyway? chords are supposed to be the bringing together of different voices(melodies). Many guitarists never see that picture yet they happily hammer out blocks and chunks of chords.
nothing wrong with happily strumming of course but lets appreciate context.


producing EntityManager throws __FIRST_PHASE__ is missing

Question: Here's my error
ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 2) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "test.war")]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"test.war#primary\".__FIRST_PHASE__ is missing [jboss.naming.context.java.jboss.datasources.KitchensinkQuickstartTestDS]"]}
ERROR [org.jboss.as.server] (management-handler-thread - 2) JBAS015870: Deploy of deployment "test.war" was rolled back with the following failure message: {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"test.war#primary\".__FIRST_PHASE__ is missing [jboss.naming.context.java.jboss.datasources.KitchensinkQuickstartTestDS]"]}

and the caused by portion of the stack trace
Caused by: java.lang.Exception: "JBAS014807: Management resource '[(\"deployment\" => \"test.war\")]' not found"
    at org.jboss.as.controller.client.helpers.standalone.impl.ServerDeploymentPlanResultFuture.getActionResult(ServerDeploymentPlanResultFuture.java:134) ~[wildfly-controller-client-8.0.0.Final.jar:8.0.0.Final]
    at org.jboss.as.controller.client.helpers.standalone.impl.ServerDeploymentPlanResultFuture.getResultFromNode(ServerDeploymentPlanResultFuture.java:123) ~[wildfly-controller-client-8.0.0.Final.jar:8.0.0.Final]
    at org.jboss.as.controller.client.helpers.standalone.impl.ServerDeploymentPlanResultFuture.get(ServerDeploymentPlanResultFuture.java:85) ~[wildfly-controller-client-8.0.0.Final.jar:8.0.0.Final]
    at org.jboss.as.controller.client.helpers.standalone.impl.ServerDeploymentPlanResultFuture.get(ServerDeploymentPlanResultFuture.java:42) ~[wildfly-controller-client-8.0.0.Final.jar:8.0.0.Final]

and relevant log output
2014-03-25 00:06:26,543 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 3) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "test.war")]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"test.war#primary\".__FIRST_PHASE__ is missing [jboss.naming.context.java.jboss.datasources.KitchensinkQuickstartTestDS]"]}
2014-03-25 00:06:26,544 ERROR [org.jboss.as.server] (management-handler-thread - 3) JBAS015870: Deploy of deployment "test.war" was rolled back with the following failure message: {"JBAS014771: Services with missing/unavailable dependencies" => jboss.persistenceunit.\"test.war#primary\".__FIRST_PHASE__ is missing [jboss.naming.context.java.jboss.datasources.KitchensinkQuickstartTestDS]"]}
2014-03-25 00:06:26,551 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-8) JBAS015877: Stopped deployment test.war (runtime-name: test.war) in 7ms
2014-03-25 00:06:26,552 INFO  [org.jboss.as.controller] (management-handler-thread - 3) JBAS014774: Service status report
JBAS014775:    New missing/unsatisfied dependencies:
      service jboss.naming.context.java.jboss.datasources.KitchensinkQuickstartTestDS (missing) dependents: [service jboss.persistenceunit."test.war#primary".__FIRST_PHASE__]
      service jboss.persistenceunit."test.war#primary".__FIRST_PHASE__ (missing) dependents: [service jboss.deployment.unit."test.war".POST_MODULE]

2014-03-25 00:06:26,558 DEBUG [org.jboss.as.controller.management-operation] (management-handler-thread - 4) JBAS014616: Operation ("undeploy") failed - address: ([("deployment" => "test.war")]) - failure description: "JBAS014807: Management resource '[(\"deployment\" => \"test.war\")]' not found"
2014-03-25 00:06:26,586 DEBUG [org.jboss.as.controller.management-operation] (management-handler-thread - 2) Entered VERIFY stage; waiting for service container to settle
2014-03-25 00:06:26,595 INFO  [org.jboss.as.controller] (management-handler-thread - 2) JBAS014774: Service status report
JBAS014776:    Newly corrected services:
      service jboss.naming.context.java.jboss.datasources.KitchensinkQuickstartTestDS (no longer required)
      service jboss.persistenceunit."test.war#primary".__FIRST_PHASE__ (no longer required)

Here's the contents of my Jar
ar = 64668e4f-f815-495a-a612-bc1c9c87b4cc.jar:
/com/
/com/lm/
/com/lm/infrastructure/
/com/lm/infrastructure/Regex.class
/com/lm/infrastructure/SystemServices.class
/com/lm/infrastructure/RegexTest.class
/com/lm/infrastructure/JacksonProducer.class
/com/lm/model/
/com/lm/model/Identifiable.class
/com/lm/model/Page.class
/com/lm/model/Entity.class
/com/lm/model/Buildable.class
/com/lm/model/Wirer.class
/com/lm/model/BaseIdentifierDTO.class
/com/lm/model/Factory.class
/com/lm/model/EntityBuilder.class
/com/lm/model/Director.class
/com/lm/model/Builder.class
/com/lm/model/Identifier.class
/com/lm/model/Repository.class
/com/lm/test/
/com/lm/test/TestBase.class
/com/lm/test/UnitTest.class
/com/lm/test/RESTCtrlTestBase.class
/com/lm/test/TestUtil.class
/com/lm/activity/
/com/lm/activity/persistence/
/com/lm/activity/persistence/inmemory/
/com/lm/activity/persistence/inmemory/ActivityInventoryMemUnitTest.class
/com/lm/activity/persistence/inmemory/ActivitiesMemUnitTest.class
/com/lm/activity/persistence/inmemory/ActivityInventoryMem.class
/com/lm/activity/persistence/inmemory/ActivitiesMem.class
/com/lm/activity/UnitTestBaseForActivity.class
/com/lm/activity/SimplyDescriptive.class
/com/lm/activity/Activity$Builder.class
/com/lm/activity/ActivityId.class
/com/lm/activity/ActivitiesRepo.class
/com/lm/activity/FactoryBuilderActivity.class
/com/lm/activity/ActivityInventory.class
/com/lm/activity/Activity$DTO.class
/com/lm/activity/Activity.class
/com/lm/activity/ActivityCompleted.class
/com/lm/activity/Activity_.class
/com/lm/activity/ActivityId$DTO.class
/com/lm/activity/ToDoUnitTest.class
/com/lm/activity/ActivityUnitTest.class
/com/lm/activity/TestBaseForActivity.class
/com/lm/activity/ActivityEvent.class
/com/lm/activity/BuilderActivityPermaURI.class
/com/lm/activity/Descriptive.class
/com/lm/activity/ToDo.class
/com/lm/activity/DomainEvent.class
/com/lm/activity/Individual.class
/META-INF/
/META-INF/logback.xml
/META-INF/test-ds.xml
/META-INF/beans.xml
/META-INF/persistence.xml

here's my persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
             version="2.1">
<persistence-unit name="primary">
    <jta-data-source>java:jboss/datasources/KitchensinkQuickstartTestDS</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>

        <property name="hibernate.hbm2ddl.auto" value="create-drop" />
        <property name="hibernate.show_sql" value="false" />
    </properties>
</persistence-unit>
</persistence>

test-ds.xml
<?xml version="1.0" encoding="UTF-8"?>

<datasources xmlns="http://www.jboss.org/ironjacamar/schema"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">

   <datasource jndi-name="java:jboss/datasources/KitchensinkQuickstartTestDS"
      pool-name="kitchensink-quickstart-test" enabled="true"
      use-java-context="true">
       <connection-url>jdbc:h2:mem:kitchensink-quickstart-test</connection-url>
      <driver>h2</driver>
      <security>
         <user-name>sa</user-name>
         <password>sa</password>
      </security>
   </datasource>
</datasources>

SystemServices class
public class SystemServices {

    @SuppressWarnings( "unused" )
    @Produces
    @PersistenceContext
    private EntityManager em;

    @Produces
    public Logger prLogger( InjectionPoint ip ) {
        return LoggerFactory.getLogger(
                ip.getMember().getDeclaringClass().getName()
        );
    }
}

I don't have any entities yet that have any annotations, so I'd think that it should be able to produce the EntityManager without it causing problems.
Answer: The error says that jboss is missing your datasource. Which JBoss/Wildfly version are you using?
Please check first whether JBoss can work with your datasource using f.i. the web console (localhost:9090/console -> Profile -> Datasources).
You can also configure your datasource in standalone.xml but whether this is an appropriate approach or not depends on your setup but I would prefer the standalone.xml approach.
I thought the *-ds.xml datasource configuration file has to be deployed separately, not with the jar. Please have a look here for datasource configurations. I think this could cause your problem since JBoss parses the persistence.xml before deploying the datasource definition and failing at the Persistence manager initialization.
Comment: wildfly 8 CR1 (there's a bug in final that's preventing me from using it). The kitchensink app seems to suggest it's ok to deploy with the datasource as part of the jar? (reading the docs now)
Comment: "Starting with WildFly 8, you have the ability to deploy a -ds.xml file"
Comment: If you configure the datasource in the web console (localhost:9090/console -> Profile -> Datasources), but forget to click "Enable", the same error will occur.


Sprite Kit/Swift Stars Effect

Question: this is what I'd like to achieve:

Stars spawning randomly, resizing an image of a little dot so it seems like the "stars are glowing" in random positions.
I just started working with Swift few weeks ago, and I'm working on this cool game project, this could be a great feature, and I'm sure some of the other users could use and answer to this too.
Any ideas?
edit: And sorry for being such a newbie.
Comment: http://www.techotopia.com/index.php/An_iOS_7_Sprite_Kit_Particle_Emitter_Tutorial
Comment: Check out SKEmitterNode that is built into sprite kit.
Comment: Still, I don't really know how to use documentation.
Answer: Consider using CAEmitterLayer, documented here. It's quite straight forward.
In case you have doubts, I have combined SpriteKit, even OpenGL with standard Core Animation without any issues.
Comment: That looks great. Could you please provide any code sample? I don't really know how to get my head around it.
Comment: I could not "get my head around it" either in 63 seconds, lol. You are expected to do a minimum of your own research. - That being said, check out [Dazzle](https://github.com/lichtschlag/Dazzle), and accept this answer.
Comment: Please don't get me wrong, problem is not with CAEmitterLayer, it's I don't really know how to use documentation to use it in real code.
Answer: Speaking about Sprite-kit now you can use SKEmitterNode.
Make a new Xcode file:

let stars : SKEmitterNode = NSKeyedUnarchiver.unarchiveObjectWithFile(NSBundle.mainBundle().pathForResource("stars", ofType: "sks")!) as! SKEmitterNode
stars.position = CGPointMake(CGRectGetMidX(self.frame),CGRectGetMidY(self.frame))
stars.zPosition = 1
self.addChild(stars)

Sprite Kit/Swift Stars Effect


How to assign a number to return value of a function

Question: The code below is to define the value of the given index in array, and I want if the index out of range, the return value assigned to 0:
cc::[a]->Int->a
cc [] b = 0
cc (x:xs) 0 = x
cc a b = cc (tail a) (b-1)

It causes an error:
* No instance for (Num a) arising from the literal `0'
Possible fix:
     add (Num a) to the context of the type signature for:
         cc :: forall a. [a] -> Int -> a
* In the expression: 0
 In an equation for `cc': cc [] b = 0

Comment: This can only work if `a` is always of the same type as `0`. Consider using `Maybe a` instead.
Answer: Returning 0 is not possible because 0 is not always of type a.
However, you can return Maybe a instead:
cc :: [a] -> Int -> Maybe a
cc [] b = Nothing
cc (x:xs) 0 = Just x
cc a b = cc (tail a) (b-1)

Alternatively, if a is always of type Int, then you can change the signature:
cc :: [Int] -> Int -> Int
cc [] b = 0
cc (x:xs) 0 = x
cc a b = cc (tail a) (b-1)


3rd axiom of probability for discrete distribution

Question: it might be a stupid question but I was discussing with a colleague when the 3rd axiom of probability (sigma additivity) is really needed.
I argue that in the case of a discrete distribution, say a single die, the first two axioms are sufficient as this distribution has a finite number of events. Is this right?
And then I am stretching it a bit by arguing that for simple/well behaved continuous distributions, such as the uniform distribution, the first two axioms are sufficient to ensure a proper probability distribution. Is that right?
I always had the idea that the 3rd axiom was rather there to ensure that more cumbersome distributions or convolutions of distributions would still be proper probability distributions (although I don't have an example at hand). Or is axiom 3 much more vital than I understand?
Thanks for any input!
Best,
Stefan
Comment: Note that discrete distributions need not be finite.  Perhaps your point is that for a finite event space, finite additivity will suffice.
Comment: I don't understand what "for simple/well behaved continuous distributions... the first two axioms are sufficient to ensure a proper probability distribution" means.  Surely "satisfies sigma-additivity" is a necessary condition for being simple and/or well-behaved.
Answer: The first two axioms given on Wikipedia don't imply finite additivity, which you seem to be assuming.  This assumption is enough to do probability with a finite sample space but not with a countable sample space; you need the assumption of $\sigma$-additivity here or else you can't do simple intuitive things like compute the expected number of times you have to roll a die to get a certain result.
If you only assume finite additivity, you get a lot of weird measures; for example any non-principal ultrafilter on an infinite set defines a finitely additive measure.  Whether you want to allow these as probability measures is up to you, but the fact is that it's harder to prove theorems in this generality.
Answer: The power of the third axiom is illustrated here.
Comment: You can make a link directly to a section like this: http://en.wikipedia.org/wiki/Probability_axioms#Proofs
Answer: Without the third axiom we can define many distributions that don't work like probabilities are supposed to.  For example, the distribution where we assign 1 to all subsets of the universe.  That doesn't look like a probability, but it satisfies the first two axioms, so we need an axiom to rule it out.
Answer: I am suspecting that you are really asking whether $\sigma$-additivity is really necessary when simple additivity might be enough. If we exclude third axiom as it is defined in wikipedia, then the probability need not to be additive, which is definitely not something you want. Now for finite sample space $\sigma$-additivity and simple additivity coincides, but for infinite sample space $\sigma$-additivity is necessary as other posters pointed out. Take for example probability space $(\Omega, 2^\Omega, P)$ where $\Omega=\{\omega_1,...,\omega_n,...\}$. Now
$$\Omega=\bigcup_{i=1}^\infty\{\omega_i\}$$
and
$$\{\omega_i\}\cap\{\omega_j\}=\varnothing,i\neq j$$
Now $\sigma$-additivity implies
$$P(\Omega)=\sum_{i=1}^\infty P(\omega_i)=1$$
without $\sigma$-additivity this statement need not be true, contradicting axiom 2.


Prob. 10, Sec. 3.5, in Bartle & Sherbert's INTRO TO REAL ANALYSIS: If $x_1 < x_2$ are arbitrary real numbers and . . .

Question: Here is Prob. 10, Sec. 3.5, in the book Introduction to Real Analysis by Rovert G. Bartle and Donald R. Sherbert, 4th edition:

If $x_1 < x_2$ are arbitrary real numbers and $x_n \colon= \frac{1}{2} \left( x_{n-2} + x_{n-1} \right)$ for $n > 2$, show that $\left( x_n \right)$ is convergent. What is its limit?

My Attempt:

As $x_1 < x_2$, so
  $$ x_1 < \frac{1}{2} \left( x_1 + x_2 \right) < x_2, $$
  that is,
  $$ x_1 < x_3 < x_2. \tag{1} $$
  And also
  $$ \left\lvert x_3 - x_2 \right\rvert = x_2 - x_3 = \frac{1}{2} \left( x_2 - x_1 \right). \tag{2} $$
Now as $x_3 < x_2$, so
  $$ x_3 < \frac{1}{2} \left( x_3 + x_2 \right) < x_2, $$
  that is,
  $$ x_3 < x_4 < x_2. \tag{3} $$
  And also
  $$ \left\lvert x_4 - x_3 \right\rvert = x_4 - x_3 = \frac{1}{2} \left( x_2 - x_3 \right) = \frac{1}{2} \left\lvert x_2 - x_3 \right\rvert = \frac{1}{2^2} \left( x_2 - x_1 \right). \tag{4} $$
Now as $x_3 < x_4$, so
  $$ x_3 < \frac{1}{2} \left( x_3 + x_4 \right) < x_4, $$
  that is,
  $$ x_3 < x_5 < x_4. \tag{5} $$
  And also
  $$ \left\lvert x_5 - x_4 \right\rvert = x_4 - x_5 = \frac{1}{2} \left( x_4 - x_3 \right) = \frac{1}{2} \left\lvert  x_4 - x_3 \right\rvert = \frac{1}{2^3} \left( x_2 - x_1 \right). \tag{6} $$
Now as $x_5 < x_4$, so
  $$ x_5 < \frac{1}{2} \left( x_5 + x_4 \right) < x_4, $$
  that is,
  $$ x_5 < x_6 < x_4. \tag{7} $$
  And also
  $$ \left\lvert x_6 - x_5 \right\rvert = x_6 - x_5 = \frac{1}{2} \left( x_4 - x_5 \right) = \frac{1}{2} \left\lvert x_5 - x_4 \right\rvert = \frac{1}{2^4} \left( x_2 - x_1 \right). \tag{8} $$
From (1), (3), (5), and (7), we get
  $$ x_1 < x_3 < x_5 < x_6 < x_4 < x_2. \tag{9} $$
Now let $k \in \mathbb{N}$ such that $k \geq 3$, and suppose that
  $$ x_1 < x_3 < x_5 < \cdots < x_{2k-1} < x_{2k} < x_{2k-2} < \cdots < x_4 < x_2. \tag{10} $$
  And suppose also that
  $$ \left\lvert x_{2k} - x_{2k-1} \right\vert = \frac{1}{ 2^{2k-2} } \left( x_2 - x_1 \right). \tag{11} $$
Then as $x_{2k-1} < x_{2k}$, so
  $$ x_{2k-1} < \frac{1}{2} \left( x_{2k-1} + x_{2k} \right) < x_{2k}, $$
  that is,
  $$ x_{2k-1} < x_{2k+1} < x_{2k }. \tag{12} $$
  And also
  $$ \left\lvert x_{2k+1} - x_{2k} \right\rvert = x_{2k}  - x_{2k+1} = \frac{1}{2} \left( x_{2k} - x_{2k-1} \right) = \frac{1}{2} \left\lvert  x_{2k} - x_{2k-1} \right\rvert = \frac{1}{ 2^{2k-1} } \left( x_2 - x_1 \right). \tag{13}  $$
Now as $x_{2k+1} < x_{2k}$, so
  $$ x_{2k+1} < \frac{1}{2} \left( x_{2k+1} + x_{2k} \right) < x_{2k}, $$
  that is,
  $$ x_{2k+1} < x_{2k+2} < x_{2k}. \tag{14} $$
From  (10), (12), and (14), we can conclude that
  $$ x_1 < x_3 < x_5 < \cdots < x_{2k-1} < x_{2k+1} < x_{2k+2} < x_{2k} < \cdots < x_6 < x_4 < x_2 \tag{15} $$
  for all $k \in \mathbb{N}$. [I'm not really sure what to do with this relation though.]
Also from (11) and (13), we can conclude that
  $$ \left\lvert x_{n+1} - x_n \right\rvert = \frac{1}{2^{n-1} } \left( x_2 - x_1 \right). \tag{A} $$
  for all $n \in \mathbb{N}$ such that $n \geq 2$.
So for any natural numbers $m$ and $n$ such that $m > n$, we obtain
  $$
\begin{align}
\left\lvert x_m - x_n \right\rvert &\leq \left\lvert x_m - x_{m-1} \right\rvert + \cdots + \left\lvert x_{n+1} - x_n \right\rvert \\
&= \left( \frac{1}{2^{m-2} } + \cdots + \frac{1}{2^{n-1} } \right) \left( x_2 - x_1 \right) \\
&= \left( \frac{1}{2^{n-1} } + \frac{1}{2^{n} } \cdots + \frac{1}{2^{m-2} } \right) \left( x_2 - x_1 \right) \\
&= \frac{1}{2^{n-1}} \left( 1 + \frac{1}{2} + \cdots + \frac{1}{2^{m-n-1}} \right) \left( x_2 - x_1 \right) \\
&= \frac{1}{2^{n-1}} \frac{ 1 - \frac{1}{2^{m-n}} }{ 1 - \frac{1}{2} } \left( x_2 - x_1 \right) \\
&= \frac{1}{2^{n-2}} \left( 1 - \frac{1}{2^{m-n}} \right) \left( x_2 - x_1 \right) \\
&< \frac{1}{2^{n-2}}  \left( x_2 - x_1 \right). \tag{B}
\end{align}
$$
So, given $\varepsilon > 0$, if we choose a natural number $N$ so that
  $$ N > \frac{ 4 \left(x_2 - x_1 \right)  }{ \varepsilon }, $$ then
  $$ 2^N > N > \frac{ 4 \left(x_2 - x_1 \right)  }{ \varepsilon }, $$
  and so
  $$ \varepsilon > \frac{ 4 \left( x_2 - x_1 \right) }{ 2^N}.$$
  and then we see from (B) that, whenever $m$ and $n$ are any natural numbers such that $m > n > N$, we have
  $$ \left\lvert x_m - x_n \right\rvert < \frac{1}{2^{n-2}} \left( x_2 - x_1 \right) = \frac{4 \left( x_2 - x_1 \right) }{ 2^n} < \frac{4 \left( x_2 - x_1 \right)}{2^N} < \varepsilon. $$
Thus our sequence is a Cauchy sequence of real numbers. Therefore, this sequence is convergent. Let $x$ be the limit of this sequence. Then the subsequences
  $\left( x_{2k-1} \right)_{k \in \mathbb{N}}$ and $\left( x_{2k } \right)_{k \in \mathbb{N}}$ also converge to this same limit $x$.
Now $$ x_3 = \frac{x_2 + x_1 }{2}, $$
  and so $$ x_4 = \frac{x_3 + x_2}{2} = \frac{ \frac{x_2 + x_1 }{2} + x_2  }{2} = \frac{ 3x_2 +  x_1 }{4},$$
  and hence $$ x_5 = \frac{ x_4 + x_3 }{2} = \frac{ \frac{ 3x_2 +  x_1 }{4} + \frac{x_2 + x_1}{2} }{2} = \frac{ 5 x_2 + 3 x_1 }{8}. $$
  Thence $$ x_6 = \frac{ x_5 + x_4 }{2} = \frac{ \frac{ 5 x_2 + 3 x_1 }{8} + \frac{ 3 x_2 +  x_1 }{4} }{2} = \frac{ 11 x_2 + 5 x_1 }{16}, $$
  and so
  $$ x_7 = \frac{ x_6 + x_5 }{2} = \frac{ \frac{ 11 x_2 + 5 x_1 }{16} + \frac{ 5 x_2 + 3 x_1 }{8} }{2} = \frac{ 21 x_2 + 11 x_1 }{32}. $$
  Then
  $$ x_8 = \frac{ x_7 + x_6 }{2} = \frac{ \frac{ 21 x_2 + 11 x_1 }{32} + \frac{ 11 x_2 + 5 x_1 }{ 16 } }{2} = \frac{ 43 x_2 + 21 x_1 }{ 64}, $$
  and so
  $$ x_9 = \frac{ x_8 + x_7 }{2} = \frac{ \frac{ 43 x_2 + 21 x_1 }{64} + \frac{ 21 x_2 + 11 x_1 }{32} }{2} = \frac{ 85 x_2 + 43 x_1 }{128}. $$
Generalising from these formulas for $x_3$ through $x_9$, we suppose that $k \in \mathbb{N}$ such that $k > 1$ and that
  $$ x_{2k - 1} = \frac{ \frac{ 2^{2k-2} - 1}{3} x_2  +  \frac{ 2^{2k-3} + 1}{3}  x_1  }{ 2^{2k-3} } = \frac{  \left( 2^{2k-2} - 1 \right) x_2 + \left( 2^{2k-3} + 1 \right) x_1   }{ 3 \times 2^{2k-3} }, $$
  and
  $$ x_{2k} = \frac{ \frac{ 2^{2k-1} + 1}{3} x_2 + \frac{ 2^{2k-2} - 1}{3}  x_1  }{2^{2k-2}} = \frac{  \left( 2^{2k-1} + 1 \right) x_2 + \left( 2^{2k-2} - 1 \right)  x_1  }{ 3 \times 2^{2k-2} }. $$
Then we find that
  $$
\begin{align}
x_{2k+1} &= \frac{ x_{2k} + x_{2k-1} }{2} \\
&= \frac{ \frac{  \left( 2^{2k-1} + 1 \right) x_2 + \left( 2^{2k-2} - 1 \right)  x_1  }{ 3 \times 2^{2k-2} } +  \frac{  \left( 2^{2k-2} - 1 \right) x_2 + \left( 2^{2k-3} + 1 \right) x_1   }{ 3 \times 2^{2k-3} } }{2} \\
&= \frac{ \left( 2^{2k-1} + 1 \right) x_2 + \left( 2^{2k-2} - 1 \right)  x_1  + 2 \left( 2^{2k-2} - 1 \right) x_2 + 2 \left( 2^{2k-3} + 1 \right) x_1   }{ 3 \times 2^{2k-1} } \\
&= \frac{ \left( 2^{2k} - 1 \right) x_2 + \left( 2^{2k-1} + 1  \right) x_1  }{ 3 \times 2^{2k-1} },
\end{align}
$$
  and hence
  $$
\begin{align}
 x_{2k+2} &= \frac{ x_{2k+1} + x_{2k} }{2} \\
&= \frac{ \frac{ \left( 2^{2k} - 1 \right) x_2 + \left( 2^{2k-1} + 1  \right) x_1  }{ 3 \times 2^{2k-1} }  + \frac{  \left( 2^{2k-1} + 1 \right) x_2 + \left( 2^{2k-2} - 1 \right)  x_1  }{ 3 \times 2^{2k-2} } }{2}  \\
&= \frac{ \left( 2^{2k} - 1 \right) x_2 + \left( 2^{2k-1} + 1  \right) x_1   + 2 \left( 2^{2k-1} + 1 \right) x_2 + 2 \left( 2^{2k-2} - 1 \right)  x_1  }{ 3 \times 2^{2k}  } \\
&= \frac{ \left( 2^{2k+1} + 1 \right) x_2 + \left( 2^{2k} - 1 \right)x_1 }{ 3 \times 2^{2k} }.
\end{align}
$$
Thus the induction is complete, and so we can conclude that, for every natural number $k > 1$, we have
  $$ x_{2k-1} = \frac{  \left( 2^{2k-2} - 1 \right) x_2 + \left( 2^{2k-3} + 1 \right) x_1   }{ 3 \times 2^{2k-3} } =
\frac{1}{3} \left[  \left( 2 - \frac{1}{2^{2k-3}} \right) x_2 + \left( 1 + \frac{1}{2^{2k-3}} \right) x_1 \right], \tag{C} $$
  and
  $$ x_{2k} = \frac{  \left( 2^{2k-1} + 1 \right) x_2 + \left( 2^{2k-2} - 1 \right)  x_1  }{ 3 \times 2^{2k-2} } = \frac{1}{3} \left[ \left( 2 +  \frac{1}{2^{2k-2}} \right) x_2 + \left( 1 - \frac{1}{ 2^{2k-2} } \right) x_1  \right]. \tag{D} $$
Now as
  $$ \lim_{k \to \infty} \frac{ 1 }{2^{2k-2} } = 0 = \lim_{k \to \infty} \frac{1}{2^{2k-3}}, $$
  so from formulas (C) and (D), we can conclude that
  $$ \lim_{k \to \infty} x_{2k-1} = \frac{ 2x_2 +  x_1 }{3} = \lim_{ k \to \infty} x_{2k}. $$
  Therefore,
  $$ \lim_{n \to \infty} x_n = \frac{ 2x_2 +  x_1 }{3}. $$

Is what I've done correct? I know I have protracted my solution way way beyond the solution expected, but what is the shorter approach to it, I wonder?
Answer: Yes, your attempt is correct, and you made a mistake and I don't really want to find it. But it is very tedious. Here is another approach: First note that for $n\geq 3$ you get
$$
x_n = x_1 + \frac{4(x_2-x_1)}{3}\left( \left(-\frac{1}{2}\right)^n + \frac{1}{2} \right)
$$
(look for the first terms of the sequence until you find the pattern, then prove it by induction). So, as the sequence $(a^n)$ converges to $0$ for every $a\in ]-1,1[$, you obtain that the sequence $(x_n)$ is convergent by elementary algebra of sequences and that.
$$
x_n \to x_1 + \frac{4(x_2-x_1)}{3}\left( \frac{1}{2} \right) = \frac{x_1+2x_2}{3}.
$$
As yo will see, this is exactly what you have done, but there is no need to prove the convergence of $(x_n)$ at first as this can be done from this closed expression for $x_n$.
Answer: This can be easily solved considering it as a difference equation
$$
x_n -\frac{1}{2}x_{n-1}-\frac{1}{2}x_{n-2} = 0
$$
Making $x_n = a^n$ and substituting
$$
a^n-\frac{1}{2}a^{n-1}-\frac{1}{2}a^{n-2} = 0 \Rightarrow a^2-\frac{1}{2}a-\frac{1}{2} = 0 \ \ \ \hbox{this guarantees the difference recursion}
$$
then the solution is
$$
x_n = C_1 (-1) ^n 2^{-n}+1 \cdot C_2
$$
now we can conclude about convergence
Comment: @CarlosAjila I have corrected the mistake(s) that you've pointed out.


SuiteScript 2.0: Rescheduling a Scheduled Script With Checkbox Parameter

Question: I have a scheduled script that does two things. I have checkbox parameters to determine if those things are require on this run of the script. The first time around both are defaulted to true.
function execute(scriptContext) {
    var script = runtime.getCurrentScript();
    doTask1 = script.getParameter({name: "custscript_tmh_do_task1"});
    doTask2 = script.getParameter({name: "custscript_tmh_do_task2"});

    if(doTask1){
        //Do something
    }
    if(doTask2){
        //Do something
    }

    //Determine if task1 or task2 needs to happen and set them to true or false.

    //Reschedule script if required
    if(doTask1 || doTask2){
    var scheduledScriptTask = task.create({
        taskType: task.TaskType.SCHEDULED_SCRIPT
    });
    scheduledScriptTask.scriptId = runtime.getCurrentScript().id;
    scheduledScriptTask.deploymentId = runtime.getCurrentScript().deploymentId;
    scheduledScriptTask.params = {'custscript_tmh_do_task1': doTask1 ,
                                    'custscript_tmh_do_task2': doTask2 };
    return scheduledScriptTask.submit();
    }
}

The problem is the second time around, it is not doing the tasks when the booleans are set to true. It just skips over them. I have used the debugger to confirm at the point of rescheduling the script the booleans are true.
Question: How do I reschedule a scheduled script with setting a boolean value.
Side Question" I have the parameters created as a script parameter. Is it possible to do this without setting the script parameters in NetSuite?
Comment: I recommend logging out the parameter values to confirm they actually hold the values you expect. There are also certain situations where checkboxes still need to use the old 1.0 `"T"` or `"F"` values instead of `true` and `false`, so perhaps try setting them that way in your rescheduling logic.
Answer: that's not the correct constructor for generating the task. I always use:
var scheduledScriptTask = task.create({
    taskType: task.TaskType.SCHEDULED_SCRIPT,
    scriptId: runtime.getCurrentScript().id,
    deploymentId: runtime.getCurrentScript().deploymentId,
    params: {'custscript_tmh_do_task1': doTask1 ,
             'custscript_tmh_do_task2': doTask2 }
});

Also script parameters are passed as strings so you need to convert.
either:
doTask1 = 'T' == script.getParameter({name: "custscript_tmh_do_task1"});

or
doTask1 = script.getParameter({name: "custscript_tmh_do_task1"});
...
if('T' == doTask1){ ...

Checking when you use them ('T' == doTask1) lets you just round trip the string values into your next iteration. If you use them as booleans so you can decide whether the next iteration needs to do both tasks then you'll need to turn them back to strings when you pass them to the next iteration: custscript_tmh_do_task1 : doTask1 ? 'T' : 'F'
You do not need to give the parameters default values in order to pass them on to the next iteration. And any values you give in the task.create method will override the configured values.


What is the graph of $r \cos \theta = 3$?

Question: What is the graph of $r \cos \theta = 3$?
I don't get why there is a $\cos \theta$ in the side of $r$, even if I divide both sides by $\cos \theta$, the right side will be $3/\cos \theta$, which makes no sense. What is the graph of this equation?
Comment: Always remember the key points of polar coordinates: $$x = r \cos \theta \quad y = r \sin \theta$$
Comment: Why do you say $r=3/\cos\theta$ "makes no sense?"
Comment: Ah, that's different from "not making sense." "I can't figure out what to do next" is not usually written in English as "It does not making sense." "Not making sense" is reserved for things which are illogical, not things we don't understand or can't figure out.
Comment: I know the formulas, but what do I plug in the theta part?
Comment: If I will divide it by 3, I'll only get r but not the theta part, leaving me no clue about its graph.
Answer: Recall that:

$x = r \cos \theta$
$y = r \sin \theta$

Thus, your equation is simply $x = 3$, a simple vertical line.
Comment: Holy crap it was that simple. Thanks!


How do I call __import__ when dynamically importing in python

Question: I am just playing around with the dynamically importing a module example as they do in 16.15 of dive into python.
I am doing something like
modulenames = ['my_module']
modules = list(map(__import__, modulenames))
modules[0].process()

However my model is in a subdirectory (called 'modules') so instead of
import my_module

I would do
from modules import my_module

The import dunder accepts a fromlist where I (presumably?) can pass the subdirectory but I cant quite figure out the syntax to add it inside the map() call
Answer: From what I understand in the documentation, you can just do :
modules = __import__("modules", fromlist=["my_module"])

and then acces it with modules.my_module
Comment: Thanks, that works. I found in the docs somewhere a note saying using importlib is preferred to using __import__ so I'll accept the answer below that does this.
Answer: Another way:
from importlib import import_module

module_list = ('package.a', 'package.b')
modules = [import_module(module) for module in module_list]
modules[0].process()


Multidimensional list

Question: I'm am creating a multidimensional list where rows and columns are taken into consideration. The code would require the user to enter n number of times of digits depending on the count.
Example: The user is required to enter numbers 5 times and then the number is displayed as a list of list.
UserInput: 1 2 3
           4 5 6
           5.5 1 2
Output: [[1,2,3],[4,5,6],[5.5,1,2]]

I'm able to do one dimensional list but when it comes to multidimensional list I'm lost in it. Here's my code i worked out so far:
rows = 5
table = rows*[0]
rowNumber = 0

while rowNumber < rows:
    userInput = input("Enter a number:").split()

    for i in range(len(userInput)):
         for j in range(len(userInput[i]):
                 table[i][j] = userInput

rowNumber +=1
print(table)

Any help is much appreciated. :)
Answer: Smells like homework :)
You need to create a list of lists. Right now your table is just a single dimensional list which has 0s. You'd want to create a list in the outer loop, and add to that in the inner ones. And when inner loop finishes, add that newly created list to the main list.
Answer: Since this does feel like an assignment question I'll keep this discussion higher-level.
A multidimensional list is a list of lists (of lists..., as deep as required). Traditionally this would be created through a nested loop structure.
With list comprehensions it's pretty easy to create a two-dimensional list, although higher-order multidimensional lists can begin to look pretty ridiculous and can become difficult to read ([ [ [ [ x ] for x in source_0 ] for y in source_1 ] for z in source_3 ] to create a four-dimensional list).
It should be noted the constructs for making a fixed-depth multidimensional list are more obvious than a variable-depth multidimensional list.
Suppose you had to input the number of dimensions of the multidimensional list. There are a couple different ways to solve this problem, but my favorite uses a loop and a stack; the loop watches the length of the stack and keeping adding an additional list to the top item in the stack, then pushing the new list onto the stack. For example:
    def create_multidimensional_list( depth ):
        result = []
        stack = [ result ]
        while len( stack ) < depth:
           new_list = []
           stack[ -1 ].append( new_list )
           stack.append( new_list )
        return result

There's another aspect of multidimensional lists to mention: if they are rectangular or jagged. In a rectangular multidimensional list all of the siblings of a list item have the same depth, whereas a jagged multidimensional list (sometimes also referred to as a sparse multidimensional list) can have list items whose siblings have different depths; the above code for creating a multidimensional list creates a rectangular multidimensional list. Code for handling a rectangular multidimensional list is easier to write (especially if you know the depth beforehand), but jagged multidimensional lists can use less memory since you do not necessarily populate the list to its rectangular capacity.
Answer: The key here is that userInput = input("Enter a number:").split() returns you a list. You can just use this list in the table directly, without having to parse it!
A 'row' of the table will then have userInput as its value. Also keep in mind the incorrect tabulation you have for nowNumber += 1
while rowNumber < rows:
    userInput = input("Enter a number:").split()

    table[rowNumber] = userInput

    rowNumber +=1

Answer: It's not completely straightforward to get strings of 5.5, 1, 2 to turn into a float, int, and int, but this gets it done:
rows = 5
table = []

print('Enter a number:')
while len(table) < rows:
    userInput = input().split()
    table.append([int(x) if int(float(x))==float(x) else float(x) for x in userInput ] )

print(table)

If I was reading too much into the details and something like this is ok:
[[1.1, 2.0, 3.0], [2.0, 3.0, 4.0], [3.0, 4.0, 5.0], [4.0, 5.0, 6.0], [5.0, 6.0, 7.0]]

then this code is a little simpler:
rows = 5
table = []

print('Enter a number:')
while len(table) < rows:
    userInput = input().split()
    table.append( list( map( float, userInput ) ) )

print(table)

Multidimensional list


Ride Cymbal in notation Sibelius

Question: Hello I have this notation:
Notation
But someone told me that is wrong notated the ride cymbal and is incorrect. And that must be notated of the G space above the staff. Can someone tell me illustrated how to put in the correct place? Or what I need to change from that two measures to accomplish that?
Thank you
Comment: You may wish to offer a better description of the notation you made *(in words)*, because when your link is broken (I can't access it), the question makes no sense.
Answer: Sibelius uses this system. It's fine.  But it's worth adding 'ride', 'crash', 'HH' etc above the first entry of each instrument.  As @MattPutnam says, there are other systems.
Don't normally use the alternative Ride and Crash positions several ledger lines above the stave.  They're just so Sibelius can offer alternative sounds.
Answer: Drum notation is notoriously unstandardized. I was taught that the ride cymbal goes on the top line like you have, and that the "G space" is for the hi hat, but I've seen those two reversed many times. I've even seen ride on the "A line" a few times, though I think that's incorrect by most standards. The safest thing to do is make a note like you have.
Drummers are very aware of these inconsistencies and are amenable to any reasonable scheme that is consistent. They're also quite good at inferring what things should be.
So in all, you're fine.
Answer: As Matt says, there seems to be no real standardisation for drum dots. Except x means a cymbal or a hi-hat. I've always used x on the top F line for hi-hat, and ride on the leger line A above. Crash goes in the B space. But that's just me. And probably pre-Sibelius. One has to use powers of deduction, and find patterns that give clues as to what means what.

Ride Cymbal in notation Sibelius


Formula INDIRETO dando erro em Português, mas em Inglês funciona

Question: Tenho uma planilha que funciona normalmente quando aberta em um Excel em inglês, porém quando muda a linguagem para Português ocorre um erro na fórmula.
Eu consegui reduzir o problema à formula abaixo, mas não consegui decifrar o que ela significa ou como funciona.
=INDIRETO('2021'!R6C36:R29C36;FALSO)

2021 = Nome da planilha
R6C36:R29C36 = Essa parte não entendi
R6:R29 = Seria o range desejado para a consulta
A fórmula para o Excel em inglês é a seguinte:
=INDIRECT('2021'!R6C36:R29C36;FALSE)

Tentei alterar o separador de ; para , como sugerido e apresenta esse erro.
Comment: o separador de parâmetros na fórumuals é diferente entre PT e EN, num é `;`  no outro é `,`
Comment: Adicionei duas imagens, com o Excel em inglês a fórmula esta funcionando com o separador `;`
Comment: https://support.microsoft.com/pt-br/office/indireto-fun%C3%A7%C3%A3o-indireto-474b3a3a-8a26-4f44-b491-92b6306fa261
Comment: Então Gabriel, releia o primeiro comentário que provavelmente resolverá o problema.
Comment: Bom dia Woss, quando eu tento alterar o `;` por `,` o excel não aceita, mensagem de erro "Encontramos um problema nesta fórmula."
Comment: `;` é para o Excel em português mesmo, e `,` para o inglês. Quanto a citação à documentação, infelizmente ela é uma mistura de inglês e português... Há partes que chama o comando de `INDIRETO`, outras de `INDIRECT`, e não há menção à "tradução" da referência (`R` e `C`) conforme foi respondido pelo AP abaixo. Não acho que a pergunta deva ser fechada.
Answer: Problema resolvido, o que acontece é que utilizando FALSO na fórmula =INDIRETO... o excel utiliza a referência L1C1 que até então eu não conhecia, ele referência um endereço na planilha por LINHA e COLUNA ou seja R6C36:R29C36 R = Row , C = Column em inglês, mas em português a referência muda, L = Linha e C = Coluna.
Exemplo:.
Excel em inglês : =INDIRECT(R6C36:R29C36;FALSE)
Excel em português : =INDIRETO(L6C36:L29C36;FALSO)


Dynamically loading a component in Angular 2 requires Traceur?

Question: My code should load a component based on a customer name and a setting, both received as strings from the backend.

I tried using the Compiler to compile the module and then get the component factory, however when trying to compile, angular seems to require Traceur which I didn't install or reference. Angular 2 docs don't mention it at all.

Is Traceur mandatory for runtime compilation of a module, or am I doing something wrong?

Error loading http://localhost:8099/customers/zd/march/traceur
Unable to load transpiler to transpile http://localhost:8099/ng_app/app/customer-page/zd/zd.module.ts
Error loading http://localhost:8099/ng_app/app/customer-page/zd/zd.module.ts

Traceur is obviously not at /customers/zd/march/traceur, but why is it required?

Code (only the dynamic loading part, for brevity):
The failure results of the call to compiler.compileModuleAndAllComponentsAsync(module).
                let customer = self.service.getCustomerName();
                let customer_view = feedbackChannel.customSettings.view;
                console.log('loading module for customer ' + customer);
                System.import('/ng_app/app/customer-page/' + customer + '/' + customer + '.module.ts')
                    .then((module) => {
                        console.log('compiling module for customer ' + customer);
                        return self.compiler.compileModuleAndAllComponentsAsync(module);
                    })
                    .then((moduleWithFactories) => {
                        console.log('loading class for customer view ' + customer_view);
                        self.componentFactory = moduleWithFactories.componentFactories.find((factory) => {
                            return (factory.componentType.name === customer_view);
                        });
                        console.log('Is customer view loaded? ' + (self.componentFactory != null));

                        // try loading the component here
                        let viewContainerRef = this.customerViewHost.viewContainerRef;
                        viewContainerRef.clear();

                        viewContainerRef.createComponent(this.componentFactory);
                    })
                    .catch((err) => {
                        console.log('Error when loading component: ' + err);
                    });

The module being loaded:
import { NgModule }           from '@angular/core';

import { ZDPageComponent }     from './zd-page.component';

@NgModule({
  declarations: [ ZDPageComponent],
  exports:      [ ZDPageComponent ]
})
export class ZDModule { }

package.json, in case I'm missing/misusing some angular reference:
    {
  "dependencies": {
    "@angular/animations": "^4.1.3",
    "@angular/common": "^4.1.3",
    "@angular/compiler": "^4.1.3",
    "@angular/compiler-cli": "^4.1.3",
    "@angular/core": "^4.1.3",
    "@angular/forms": "^4.1.3",
    "@angular/http": "^4.1.3",
    "@angular/platform-browser": "^4.1.3",
    "@angular/platform-browser-dynamic": "^4.1.3",
    "@angular/platform-server": "^4.1.3",
    "@angular/router": "^4.1.3",
    "angular-in-memory-web-api": "^0.3.1",
    "body-parser": "1.10.x",
    "bootstrap": "^3.3.6",
    "browserify": "^14.1.0",
    "busboy": "^0.2.9",
    "chart.js": "^2.5.0",
    "compression": "^1.6.2",
    "configstore": "^2.1.0",
    "connect-loki": "^1.0.9",
    "cookie-parser": "^1.4.3",
    "core-js": "^2.4.1",
    "email-addresses": "^2.0.2",
    "express": "^4.10.3",
    "express-session": "^1.15.1",
    "express-xml-bodyparser": "^0.3.0",
    "fs-extra": "^1.0.0",
    "konfig": "^0.2.0",
    "multer": "^1.3.0",
    "node-sass-middleware": "^0.9.8",
    "passport": "^0.3.2",
    "passport-local": "^1.0.0",
    "plivo": "^0.4.1",
    "reflect-metadata": "^0.1.8",
    "request": "^2.79.0",
    "request-promise-native": "^1.0.3",
    "rxjs": "5.0.0-rc.4",
    "sendgrid": "^4.7.1",
    "systemjs": "^0.19.41",
    "typescript": "^2.3.2",
    "uglify-js": "^2.7.5",
    "useragent": "^2.1.11",
    "winston": "^2.3.0",
    "winston-loggly-bulk": "^1.3.4",
    "xlsx": "^0.9.8",
    "xml2js": "^0.4.17",
    "zone.js": "^0.7.2"
  },
  "scripts": {
    "postinstall": "node npm_scripts/postinstall.js",
    "startDev": "concurrent \"tsc -w\" \"node tm_web.js\"",
    "clean": "rm -rf dist",
    "build": "npm run clean && tsc",
    "browserify": "browserify -s main client/public/ng_app/dist/main.js > client/public/ng_app/dist/bundle.js",
    "minify": "uglifyjs client/public/ng_app/dist/bundle.js --screw-ie8 --compress --mangle --output client/public/ng_app/dist/bundle.min.js",
    "build_prod": "npm run build && npm run browserify && npm run minify",
    "start": "node tm_web.js",
    "migrate": "node ./server/model_migartion/migrate.js"
  },
  "devDependencies": {
    "concurrently": "^3.4.0",
    "rxjs-system-bundle": "^5.1.1-2"
  }
}

system.js loader, in case I'm missing something here:
  (function(global) {
    System.config({
        paths: {
            // paths serve as alias
            'angular:': '/assets/javascript/angular/'
        },
        bundles: {
            "angular:Rx.system.min.js": [
                "rxjs",
                "rxjs/*",
                "rxjs/operator/*",
                "rxjs/observable/*",
                "rxjs/scheduler/*",
                "rxjs/symbol/*",
                "rxjs/add/operator/*",
                "rxjs/add/observable/*",
                "rxjs/util/*"
            ]
        },
        map: {
            'app': 'app',

            '@angular/core': 'angular:core.umd.js',
            '@angular/common': 'angular:common.umd.js',
            '@angular/compiler': 'angular:compiler.umd.js',
            '@angular/platform-browser': 'angular:platform-browser.umd.js',
            '@angular/platform-browser-dynamic': 'angular:platform-browser-dynamic.umd.js',
            '@angular/http': 'angular:http.umd.js',
            '@angular/router': 'angular:router.umd.js',
            '@angular/forms': 'angular:forms.umd.js',

            // other libraries
            //'rxjs': 'angular:Rx.min.js',
            'angular-in-memory-web-api': 'angular:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
        },
        // packages tells the System loader how to load when no filename and/or no extension
        packages: {
            app: {
                defaultExtension: 'js',
                meta: {
                    './app/*.js': {
                        loader: './systemjs-angular-loader.js'
                    }
                }
            },
            rxjs: {
                //defaultExtension: 'js'
                defaultExtension: false
            }
        }
    });
})(this);

tsconfig, in case the issue is with how typescript compilers should be defined:
{
    "compileOnSave": true,
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": false,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "lib": ["es2015", "dom"],
        "noImplicitAny": false,
        "suppressImplicitAnyIndexErrors": true,
        "outDir": "client/public/ng_app/dist"
    },
    "include": [
        "client/public/ng_app/app",
        "client/public/ng_app/main.ts"
    ]
}

Comment: Why do you use `self`?
Comment: old practice across js environments - `this` is sometimes not correctly bound within promises / callbacks, so I store `this` in `self`
Answer: I suspect you should import transpiled js file instead of origin ts
Moreover i would compile NgModule class
System.import(...)
  .then((module: any) => module['ZDModule'])
  .then((module) => self.compiler.compileModuleAndAllComponentsAsync(module))
  .then(...

Comment: Now the module is loaded but throws an error - No NgModule metadata found for 'Module'.
My module is rather simple (see above).

Any ideas?
Comment: You need to compile `ZDModule`. Check `.then((module) => { console.log(module);`
Comment: Seems it should be `return self.compiler.compileModuleAndAllComponentsAsync(module['ZDModule']);`
Comment: You're on the right track - JSON.stringify(module) shows only {"__esModule":true}
Looks like the module.exports is not there for some reason... looking into it, will update once I figure it out
Comment: OK, your solution works even though JSON.stringify doesn't show the property, thanks
Comment: Put `debugger` and you will see the whole object


Is GbM7 to DbM7/F also a chromatic movement?

Question: I was writing a song in Bbm key.
And the chord progression goes something like.
Bbm,GbM7, DbM7/F
In this situation does the GbM7 going to DbM7/F
also consider as chromatic progression ?
If it is,why ?
Answer: "Chromatic" suggests that what you're describing involves pitches outside of the key. The pitches of your two chords—G♭ B♭ D♭ F followed by D♭ F A♭—are all included in B♭ minor. Thus there are no pitches outside the key, and thus it wouldn't be considered chromatic. Instead, we call it diatonic, which is the opposite of chromatic.
To give you a visual representation, we can also say that "chromatic" suggests the use of accidentals. Let's look at these two chords in the context of B♭ minor:

Since there are no accidentals outside of the key signature, we would not call this chromatic.
Comment: Any reason why you specified Bbm rather than Db major?
Comment: @Tim Do you mean when I say that the pitches "are all included in B♭ minor"? I only use that because the OP stated their song is in B♭ minor.
Comment: Yes. The thing was muddied because the question was about two other (diatonic) chords, which both belong to both keys. Your reasoning is as usual - impeccable! Has already been +1d.
Answer: 'Chromatic' has a very simple definition - 'using notes outside the scale of the current key'.  If you're using a key signature it's chromatic if accidentals occur, it isn't if they don't.  (Let's dodge the issue of harmonic minor scales for now!)  I think you may have invented a different definition of 'chromatic'?


k-ary bracelets with conserved/fixed indexes

Question: Im using the formula from here:
https://en.wikipedia.org/wiki/Necklace_(combinatorics)#Number_of_bracelets
to calculate the number of unique bracelets, accepting all rotation/mirroring as identical, for a given length n with a given character set of length k
One thing this formula doesnt include, and I cant work out how to add, is what if c number of positions within n have a fixed value? Eg if k = [A, B, C, D, E] and n = 5, how would the bracelet formula be updated to indicate the maximum number of unique bracelets possible with the character "A" (or any other of the characters from set k) fixed at 1 position?
edit
perhaps this doesnt exactly make sense, since all rotation/translation is considered equivalent, but what im saying is that the function that creates these bracelets will always put "A" into the first index, and then randomly assign characters from k to all other indexs of n
initially i thought i could just do n-c (c being the number of fixed points), but this is incorrect, it appears the number of unique bracelets that can be generated for n with c=1 is more than n-1
Answer: Your edited question effectively says that you want to count the bracelets that contain at least one 'A'. This is the number of bracelets that you can form with $k$ letters minus the number of bracelets that you can form with the $k-1$ letters excluding 'A'; in the notation of the Wikipedia article: $B_k(n)-B_{k-1}(n)$.
Comment: Would this hold true if the fixed A was in any position of the bracelets? What about if multiple A's were in fixed positions? Or if some of the fixed characters were Bs or Cs?

Would it just be $B_k(n)-B_{k-c}(n)$ - with $c$ being the number of fixed positions?
Comment: Eg if $n$ was 5, $k$ contained $[A, B, C, D]$, and position 1 was fixed to A and position 4 was fixed to B, would it simply be $B_4(5)-B_{3}(5)$?
Comment: OK I ran some tests and it appears that if im only fixing _one_ of the characters from $k$, then $B_k(n)-B_{k-c}(n)$, with $c$ being any number of the _same_ fixed character, then that does indeed tell me the correct number of unique bracelets possible. However, if i fix several _different_ characters, then that formula is no longer accurate, I end up getting more unique bracelets than it would seem to indicate
Comment: @MatthewPrasinov: I'm not sure I'm following you. If you fix more characters, you should have fewer, not more bracelets; whereas in $B_k(n)-B_{k-c}(n)$, the greater $c$, i.e. the more characters you fix, the less you're subtracting, i.e. the more you're leaving, until for $c=k$ you're not subtracting anything and just ending up with $B_k(n)$, which surely can't be right?
Comment: @MatthewPrasinov: I also don't understand your question "Would this hold true if the fixed A was in any position of the bracelets?". I don't see how you intend to distinguish between the positions. The whole point of necklaces and bracelets is that there's no distinction between the positions. If you're talking about the generating process again, as in the edited question,then yes, since we don't distinguish between the positions, it's irrelevant whether the generating process spuriously does.
Comment: @MatthewPrasinov: If you require that the bracelet contains at least one 'A' and at least one 'B', then the number of admissible bracelets is $B_k(n)-2B_{k-1}(n)+B_{k-2}(n)$: The number of all bracelets minus the number of bracelets that contain no 'A's minus the number of bracelets that contain no 'B's, but that subtracts the bracelets that contain neither twice, so we have to add them back in the last term. If you fix the distance between the 'A' and the 'B' (as your "function that creates these bracelets" approach appears to indicate), I'm afraid things will get rather messy.
Comment: ye my function that generates the bracelets does so in a linear fashion, eg it strings characters from the set of $k$ together randomly until length $n$ is achieved, then checks to see if this new bracelet is unique against a running list of existing bracelets, then if it IS unique, adds all rotations/translations of the current bracelet to the running list. When you add "fixed" positions, all that means is as the linear 'pre bracelet' string is being generate, any one of the positions along the linear string can be locked down to only every choose a specific character from set $k$
Comment: And yes, this fixing/locking does allow you to fix the distance between locked indexes, eg you can lock position 2 in the linear prenecklace string as one character, then position 4 and 5 as another character. it seems to alse depend on the length of $n$ (even or odd perhaps is important), as well as the number of _unique_ characters in fixed positions in the prenecklace


Extract the CSS class depending on the user type

Question: Is it possible to extract the PHP string for user type, when the user is not an administrator user?
I need to discern between staff or non-staff users. I am aware of $is_admin, but in this case I would need something like $is_staff.
I need this so I can apply CSS styles to hide/show some fields that I want to be visible only to staff users.
Is anyone aware if there's anything that might help me?
Answer: If $user is the user object, then $user->roles is an array containing all the roles the user has. Drupal doesn't have the concept of user type, and the user roles are the closest it has.
If you want to check if the user has the "editor" role, for example, you can use code similar to the following one:
$global $user;

if (in_array(array_values($user->roles), "editor")) {
  // The user has the "editor" role.
}

Depending on what you are trying to achieve, you could also be interested in checking if the user has a specific permission, which is what is normally done in Drupal, where instead of checking the role assigned to a user, it is checked which permission the user has (using user_access()).
As for hiding a form field, this can be done implementing hook_form_alter(), or hook_form_FORM_ID_alter() and altering the property "#access" of the form field.
Supposing that "example_form" is the form ID for the form you want to modify, and "file" is the ID for the form field to change, then you can use code similar to the following one ("mymodule" is the name of the module; change it to match the name of the module that contains the hook):
function mymodule_form_example_form_alter(&$form, &$form_state) {
  $form['file']['#access'] = user_access('administer file');
}

"Administer file" is the permission that the user needs to have.
Alternatively, if you want to only check if the user has the "editor" role, you can use code similar to the following one:
function mymodule_form_example_form_alter(&$form, &$form_state) {
  global $user;

  $form['file']['#access'] = in_array(array_values($user->roles), "editor");
}

The global variable contains the user object for the currently logged in user.


Java stored procedure running slow

Question: I have a java web application that uses the next function to execute a stored procedure, it connects to SQL Server 2008:
<code>Class.forName(sDriver_Reportes);
conn = DriverManager.getConnection(sDB_URL, sUSER, sPASS);
sQuery = "{call procGetResult(?)}";
proc = conn.prepareCall(sQuery);
proc.setString("pDate", sDate);
proc.execute();
rs = proc.getResultSet();
</code>
but it takes about 7 minutes to return the resultset, if I execute the sp it takes just 10 seconds to show the result.
I were looking for some similar case but only found post about parameter sniffing and connection pool but anyone seems to be like mi case because the sp is running fast, could you give me some info about where else to look about this issue.
Thank you in advance.
Comment: The sp it's working fine, it just take 10 secs to execute in SQL Server, the problem it's when it runs in code, it takes 7 mins to complete.
Comment: There is an error in your code, please correct it.
Comment: If you talk about the missing ", it was a typo.
Comment: setString can be used with this 2 forms: public void setString(int parameterIndex, String x) throws SQLException or public void setString(String parameterName, String x) throws SQLException, this is the reference https://docs.oracle.com/javase/tutorial/jdbc/basics/storedprocedures.html   public static void getSupplierOfCoffee
Comment: The question mark it's the placeholder for the parameter.
Comment: Only the execute line takes a long time? Put some time info around it. Getting the connection is fast? Other SQL on that connection run from java are fast?
Comment: I smell parameter sniffing. http://sqlinthewild.co.za/index.php/2007/11/27/parameter-sniffing/
Answer: It seems to be a problem of  SQL Server Parameter Sniffing. The first thing you need to check is the execution plan for your stored procedure.You can view it using the following icon in SQL Server Management Studio:

Now being exposed to the problem here are a few methods to address it:

Create SQL Server Stored Procedures using the WITH RECOMPILE Option

Use the SQL Server Hint OPTION (RECOMPILE) Use the SQL Server Hint

OPTION (OPTIMIZE FOR) Use Dummy Variables on SQL Server Stored

Procedures Disable SQL Server Parameter Sniffing at the Instance

Level Disable Parameter Sniffing for a Specific SQL Server Query

For implementation and better understanding you can refer the below link :
https://www.mssqltips.com/sqlservertip/3257/different-approaches-to-correct-sql-server-parameter-sniffing/
Comment: Hi guys, thank you all for you help, indeed it was parameter sniffing, I modifiy the sp to use dummy variables and it's working perfectly, Thank you.
Comment: @JCM You can express your thanks by upvoting me...This was my first answer on Stack Overflow...Just Kidding...You can share your exact solution as it might help others
Comment: I up voted your answer, I don't know why it's not showing it.

Java stored procedure running slow