Remove Google Form Submitted File

Question: WORKING CODE HERE: https://jsfiddle.net/nateomardavis/e0317gb6/
ORIGINAL QUESTION BELOW
How do I remove a form-submitted file from Drive itself?
I'm having trouble sorting out why a google form is submitting files to both my drive (not in a folder) but also into an auto-generated submission folder.
I've been able to move the renamed file to a new folder and delete the copy in the auto-generated submission folder. I cannot figure out how to remove the copy that's just listed in "Drive", not in any folder.
THE PROCESS (EDIT)
Let me try to explain the process more. I have a form that collects files. Google automatically makes a folder and sub-folders. I have successfully renamed the submitted files, moved them to a new folder, and deleted them from the Google-generated folder. However, a copy of the original, unchanged file is going to Google Drive, the root folder. Steps 1-3 (below) work as expected. Step 4 is where I'm running into issues.

The original file being uploaded to a form. Note the file name.

The Google-generated folder. The file is submitted this folder.

The renamed file in a new folder. The original file is deleted from the folder above.

The original file is now showing up in Drive, not in a folder but there. The name of this file is the same as the originally uploaded one. The one which went to the "passes" folder and was then deleted from that folder.

SNIPPET
//RENAME PASSES
if (itemResponses[f].getItem().getTitle() == "PASSES") {
var files = itemResponses[f].getResponse();
//Logger.log(files.length);
if (files.length > 0) {
  for (var n in files) {
    var dFile = DriveApp.getFileById(files[n]);
    dFile.setName("LSS - " + year + " - " + teamName + " - " + "PASSES - " + today );
    teamFolder.addFile(dFile);   //MOVE SUBMITTED DOCUMENTS TO THAT FOLDER
    passesFolder.removeFile(dFile); //REMOVE FROM SUBMISSION FOLDER
    DriveApp.getRootFolder().removeFile(dFile) // (DOES NOT WORK) REMOVE FROM DRIVE FOLDER
    DriveApp.removeFile(dFile) // (DOES NOT WORK) REMOVE FROM DRIVE FOLDER
  }
}

FULL CODE
function getLastResponse() {

  var form = FormApp.openById('ID');

  var today = Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "MM/dd/yyyy hh:mm a");
  var year = Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "YYYY");
  Logger.log(today);

  var formResponses = form.getResponses();
  //Logger.log(formResponses.length);
  var formResponse = formResponses[formResponses.length-1];
  var respondentEmail = formResponse.getRespondentEmail()
  var itemResponses = formResponse.getItemResponses();
  Logger.log(itemResponses.length);
  var teamName = itemResponses[2].getResponse();
  //Logger.log("team name: " + teamName);

  //CHECK FOLDERS
   var dropbox = "Lititz Summer Showcase Team Check In (File responses)";
    var folder, folders = DriveApp.getFoldersByName(dropbox);

    var teamBox = teamName;
    var teamFolder, teamFolders = DriveApp.getFoldersByName(teamBox);

    var passesFolder = DriveApp.getFolderById('ID');
    var rosterFolder = DriveApp.getFolderById('ID');
    var teamInfoFolder = DriveApp.getFolderById('ID');
    var permissionToTravelFolder = DriveApp.getFolderById('ID');

    if (folders.hasNext()) { //CHECK IF DRIVE HAS FOLDER FOR FORM
      folder = folders.next();
    } else { //IF NOT CREATE FOLDER
      folder = DriveApp.createFolder(dropbox);
    }

    if (teamFolders.hasNext()) {  //CHECK IF FOLDER FOR TEAM EXISTS
      teamFolder = teamFolders.next();
    } else { //IF NOT CREATE FOLDER
      teamFolder = folder.createFolder(teamBox);
      teamFolder.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.COMMENT);
    }

for (var f = 0; f < itemResponses.length; f++) {
    Logger.log(itemResponses[f].getItem().getType());
    Logger.log(itemResponses[f].getItem().getTitle());
  if (itemResponses[f].getItem().getType() == "FILE_UPLOAD") {
    Logger.log("THERE IS A FILE UPLOAD");

    //RENAME PASSES
    if (itemResponses[f].getItem().getTitle() == "PASSES") {
    var files = itemResponses[f].getResponse();
    //Logger.log(files.length);
    if (files.length > 0) {
      for (var n in files) {
        var dFile = DriveApp.getFileById(files[n]);
        dFile.setName("LSS - " + year + " - " + teamName + " - " + "PASSES - " + today );
        teamFolder.addFile(dFile);   //MOVE SUBMITTED DOCUMENTS TO THAT FOLDER
        passesFolder.removeFile(dFile); //REMOVE FROM SUBMISSION FOLDER
        DriveApp.removeFile(dFile); // REMOVE FROM DRIVE FOLDER
      }
    }
    //RENAME ROSTER
    } else if (itemResponses[f].getItem().getTitle() == "ROSTER") {
      var files = itemResponses[f].getResponse();
    //Logger.log(files.length);
    if (files.length > 0) {
      for (var n in files) {
        var dFile = DriveApp.getFileById(files[n]);
        dFile.setName("LSS - " + year + " - " + teamName + " - " + "ROSTER - " + today );
        teamFolder.addFile(dFile);

      }
    }
   //RENAME TEAM INFO SHEET
   } else if (itemResponses[f].getItem().getTitle() == "TEAM INFO SHEET") {
      var files = itemResponses[f].getResponse();
    //Logger.log(files.length);
    if (files.length > 0) {
      for (var n in files) {
        var dFile = DriveApp.getFileById(files[n]);
        dFile.setName("LSS - " + year + " - " + teamName + " - " + "TEAM INFO SHEET - " + today );
        teamFolder.addFile(dFile);
      }
    }

  //RENAME PERMISSION TO TRAVEL
  } else if (itemResponses[f].getItem().getTitle() == "PERMISSION TO TRAVEL") {
      var files = itemResponses[f].getResponse();
    //Logger.log(files.length);
    if (files.length > 0) {
      for (var n in files) {
        var dFile = DriveApp.getFileById(files[n]);
        Logger.log(ownerEmail);
        dFile.setName("LSS - " + year + " - " + teamName + " - " + "PERMISSION TO TRAVEL - " + today );
        teamFolder.addFile(dFile);
      }
    }
    }
}//END 'IF FILE UPLOAD'
}//END FOR LOOP

}//END FUNCTION

Comment: Can I ask you about ``the copy that's just listed in "Drive", not in any folder.``?
Comment: Sure. When I open drive, I see the original file listed among other unsorted files. The re-named file is where I expect it.
Comment: Thank you for replying. You want to delete the files in root folder. Is my understanding correct?
Comment: Let me try to explain the process more. I have a form that collects file. Google automatically makes a folder and sub-folders. I have successfully renamed the submitted files, moved them to a new folder, and deleted them from the Google-generated folder. However, a copy of the original, unchanged file is going to Google Drive, the root folder. That original file is the one I want to delete.
Comment: Thank you for replying. About ``a copy of the original, unchanged file is going to Google Drive, the root folder.``, when you move the uploaded files from the folder which was automatically created, the moved file is created to the root folder as the copy. Is my understanding correct? I apologize for my poor English skill.
Comment: No problem! I added in pictures above. Does that help?
Comment: Thank you for replying. By your support, I think that I could understand about your situation. 1. Upload a file from Google Form. 2. Uploaded file is created in the root folder and the created file is moved to the folder which was automatically created. At this time, the file in the root folder is left. You want to delete the remaining file in the root folder. Is my understanding correct?
Comment: I think so. I'm open to any suggestions different from what I've tried above!
Comment: Thank you for replying. I proposed a workaround. Could you please confirm it? I'm not sure whether this is the best method. So if this was not the result you want, I apologize.
Answer: How about this answer?
Issue:
The flow of upload from Google Form is as follows.

When the file is uploaded in the Form, the file is created to root folder.
When the form is submitted, the file in the root folder is copied by renaming the filename to the folder created by the form.

In above case, the file in root folder is different from the file in the folder created by Google Form. By this, DriveApp.getRootFolder().removeFile(dFile) in your "SNIPPET" didn't work. This is the reason of your issue of script.
Workaround:

You want to delete the file remained in the root folder.

In order to delete the file created in the root folder, how about this workaround?
Unfortunately, the original filename cannot be retrieved from the form response. But the file which was copied to the folder created by the form has the filename of the format like {original filename} - ####.{extension}. In this workaround, the original filename is retrieved from this filename, and move the file to the trash using the retrieved original filename.
Sample script:
This sample script is run by the installable form submit trigger. So when the form was submitted, the script is run and the uploaded file is moved to the destination folder and the original file in the root folder is moved to the trash.
Before run the script:
In this sample script, it supposes that the script is the container-bound script of Google Form. Please be careful this.

After cope and paste the script to the script editor, please set the destination folder ID to the script.
please install the installable form submit trigger. If the trigger has already been installed, please remove it and install again.
Please upload and submit a file using Google Form. By this, the script is run.

Script:
function formsubmit(e) {
  var destFolderId = "###"; // Destination folder ID

  if (e) {
    Utilities.sleep(3000); // This is required.
    var destfolder = DriveApp.getFolderById(destFolderId);
    var items = e.response.getItemResponses();
    for (var i = 0; i < items.length; i++) {
      if (items[i].getItem().getType() == "FILE_UPLOAD") {
        var files = items[i].getResponse();
        for (var j = 0; j < files.length; j++) {
          var file = DriveApp.getFileById(files[j]);
          var filename = file.getName();

          // Move uploaded file to the destination folder.
          var uploadedFile = DriveApp.getFileById(files[j]);
          var sourcefolder = uploadedFile.getParents().next();
          destfolder.addFile(file);
          sourcefolder.removeFile(file);

          // Retrieve original filename.
          var p1 = filename.split(" - ");
          var extension = p1[p1.length - 1];
          p1.pop();
          var name = p1.join(" - ");
          var p2 = "";
          if (extension.indexOf(".") > -1) {
            p2 = "." + extension.split(".")[1];
          }
          var orgFilename = name + p2;

          // Move uploaded file to the trash.
          var orgFiles = DriveApp.getRootFolder().getFilesByName(orgFilename);
          if (orgFiles.hasNext()) {
            var orgFile = orgFiles.next();
            orgFile.setTrashed(true);
          }
        }
      }
    }
  } else {
    throw new Error("This sample script is run by the installable form submit trigger.");
  }
}

Note:

This is a simple sample script for explaining this workaround. So please modify this for your situation.
In my environment, it was found Utilities.sleep(3000) was required. When the file is uploaded and the file is copied, the installable form submit trigger is run. At this time, if Utilities.sleep(3000) is not used, the file is moved before copying file is completed. By this, an error occurs. So I used it.

But I'm not sure whether the wait time of 3 seconds is the best. So if in your environment, an error occurs, please modify this.
I think that when a large file is uploaded, this value might be required to be large. Or also I think that running the script by the time-driven trigger might be better.

In this sample script, I used the installable form submit trigger. And when the form is submitted, the original file in the root folder is moved to the trash.

But I think that you can also run the script by the time-driven trigger. In this case, you can retrieve the response items by opening the form. About this, please select for your situation.

References:

Installable Triggers
setTrashed(trashed)
sleep(milliseconds)
Comment: I was able to modify it (I didn't need the `sleep`) to fit into my original code. The snippet you provided for finding the original file name is what I needed. Thanks!
Comment: @N.O.Davis Thank you for replying and testing it. I'm glad your issue was resolved.

Remove Google Form Submitted File


Call php function while variable is false

Question: I have a php function that returns a string and I need to display it to some html element until it contains keyword "finished" and also add something like:
the string is: <my string here>. Update after 5 (4, 3, 2, 1 sec.)

What I have so far:
while(!strpos(my_func(), ' finished')) {
    my_func();
     /*html code goes here*/
    sleep(5); // no reason to call it more often
}

But can't figure out how to finish the script. Thanks.
Comment: You need to show how your `my_func()` is implemented.
Comment: Keep in mind that using regular true/false comparison with strpos is a bad idea, because 0 is a possible position. Use === and !== instead.
Answer: You can use this.
while(strpos($result = my_func(), ' finished') === false) {
    sleep(5); // no reason to call it more ofthen
}
/*html code goes here, also $result also contains the result value*/

But if the result string never contains the string ' finished' it will run forever.
Comment: @Steve.B - I'm not sure what you mean by `outputting remaining time for the next call` . If you like to output something with a 5 second interval. You need to flush your output inside the loop `flush(); sleep(5);`
Comment: @Steve.B - You should read more about ajax. This seems like the correct way to achive this.
Comment: You can not do it like this, you need to use javascript to update the html and an ajax call to get the process.
Comment: thanks for you correction but the problem is with the outputting remaining time for the next call.
Comment: You mean you need to output the process to the user while the script is running on the server?
Comment: @BartHaalstra I mean that I display smthng like: "update after 5 (4, 3, 2, 1 sec.)" -> then output string and repeat it again until fine "finish"


Alternative for Redis SUB/PUB in Ruby for publish and subscribe events

Question: The problem I've run into is when using a free add-on for heroku I'm limited to 20 Redis connections. Each subscribe event is using a connection causing my application to max out with limited usage. The application is a messaging service using web-sockets. I understand refactoring for the reason of using a free hosting service may seem like a poor decision, however, this is the only thing Redis is being used for.
Comment: You shouldn't be creating a new connection to Redis for each subscribe, only one per process. Are you connecting clients directly to Redis?
Comment: Each subscribe would lock that Redis instance. Yes, I was creating a new subscribe for each websocket connection thus creating a new Redis instance for each one as well. Things started getting more complicated then I wanted when trying to share one subscribe for all websockets.
Comment: Well what you are doing is complicated and it only gets more complicated the more efficient you make it, this is how development works, haha.
Comment: Touché :) Fast, Good, or Cheap. I only get to pick two.
Answer: Try faye or em-websocket for pub/sub and then you can use redis or postgres for persistence if needed.
http://faye.jcoglan.com/
https://github.com/igrigorik/em-websocket
Comment: Faye looks really nice, but for my current situation I would like to avoid something that requires its' own server like Redis.
Comment: Aren't you already using Redis, in your question it says the problem is that you are limited to 20 connections.
Comment: This is the only thing I'm using Redis for so I would strip it out if another solution is found.
Comment: So Redis is a store, these other gems are websocket protocol implementations. They do different things. You can't just swap out Redis for Faye, Faye is not for storage. If you are ok with the messages disappearing as soon as the connection is closed and you don't need to store them then you can just use websockets without a store like Redis.
Answer: I ended up using the EventAggregator gem which was really easy to use in place of the Redis Sub/Pub code.


Inequality and absolute value: $p + |k| \gt |p| + k$

Question: Here is the problem I am confused about. The given relation is:

$p + |k| \gt |p| + k$

It is not mentioned whether $p$ and $k$ are integers.
I need to determine whether $p$ and $k$ are equal or one is greater than other. If the second is true which one is greater.
To solve this inequality problem I was trying to consider the values of $p$ and $k$ with all combinations of signs i.e. $p$ positive and $k$ negative; $p$ negative and $k$ positive; and $p$ and $k$ both negative and positive.
When I assume both $p$ and $k$ are negative, I could not find the solution. The solution is in the book too. But I failed to understand the solution. Can anyone please help me to solve the problem? Thanks.
Comment: Split the problem into 4 parts. $p <0, k<0$, $p \ge 0, k<0$, etc, and look for solutions in each quadrant. Then piece them together.
Comment: Rewrite the inequality as $p-|p|\gt k-|k|$. Let $p$ and $k$ be negative. Then $|p|=-p$, $|k|=-k$. So our inequality says $2p\gt 2k$, and therefore $p\gt k$.
Comment: Thanks a lot copper.hat and Andre Nicolas for your nice explanation. It is really helpful for me.
Answer: Here is another approach:
Let $\phi(x) = |x|-x$, and note that the problem is equivalent to determining $p,k$ such that $\phi(k) > \phi(p)$.
Now plot $\phi$ to get

So, from this we can see that $\phi(k)> \phi(p)$ iff $k<p$ and $k <0$.
Comment: Nice answer!  Often not enough attention is paid to the geometry.


Is it possible onKeypress have more than 1 event within one input box?

Question: This is what I tried, but it's not working.
<input type="text" name="name" onKeypress="return noComma(event);return handler_address(event);">

Answer: No, this is not possible - think about it, after the first function returns the 2nd function won't run - that's the whole point of a return statement, to return a value and control to the calling process.
It isn't really clear what you are trying to do, but I would suggest writing a single function that wraps the other two.
<input type="text" name="name" onKeypress="return wrapped(event);">

function wrapped(event) {
   noComma(event);
   return handler_address(event);
}

Comment: Hi @Jason, thanks for the explaination and solution. It's working.


How do I increase the time Visual Studio is allowed to be unresponsive?

Question: I am trying to develop an application in C# communicating via OData with Microsoft's Dynamics 365 for Finance and Operations solution. This uses a large (900,000+ lines) file produced by Microsoft's OData V4 Client Generator extension (V2.4.0).
Whenever I accidentally step into code in this file while debugging, or try to look at a definition in it (whether the application is running or not), or otherwise just open the file, Visual Studio 2017 (currently version 15.5.6) will become unresponsive and be restarted a few seconds later.
Visual Studio 2015 used to start getting various panels no being refreshed and flickering as complete blank before it failed. Visual Studio 2017 just locks up.
I have wondered if the timeout before it gets restarted could be increased, so that it has to complete whatever it's doing, assuming it will recover.
If anyone has another way to work with huge autogenerated files, I'd be willing to try them. Obviously, spending hours manually breaking up the file is not an option and my attempts to split the file into multiple files using partial classes simply wouldn't compile (as I recall, the error was that it ran out of string space - presumably, VS couldn't maintain all the cross-file information for over two thousand partial classes in its internal structures).
Comment: Restarting automatically sounds like a crash; if it's just hung, you should get prompted to wait or kill the process.  Can you see whether there are any crash events in your Event Viewer?  If so, I suggest sending feedback through VS.
Answer: You can try to close the large file window immediately on opening to prevent Visual Studio from processing it. For example in a IVsRunningDocTableEvents.OnBeforeDocumentWindowShow handler:
<code>public int OnBeforeDocumentWindowShow(uint docCookie, int fFirstShow, Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame pFrame)
{
    try
    {
        if (GetDocumentName(docCookie).EndsWith(fileToBlock, System.StringComparison.CurrentCultureIgnoreCase))
            pFrame.CloseFrame((int)Microsoft.VisualStudio.Shell.Interop.__FRAMECLOSE.FRAMECLOSE_NoSave);
    }
    catch (System.Exception e)
    {
    }
    return Microsoft.VisualStudio.VSConstants.S_OK;
}
</code>
See Block certain file from opening in a document tab sample extension for Visual Commander.
Answer: Searching the forums on MSDN I was able to find a high number of people with the same issue you're reporting. The VS Development team said they've fixed those issues back in August 2017.
You could try to update Visual Studio and get the release with the fix or try disabling diagnostics tools and elapsed time PerfTip:

If your project is compatible with VS 2015, I'd suggest going back to it if you still have a working license.
Source:
Slow IDE when Diagnostics Tools is turned on
Slow IDE when CodeLens is turned on
Slow IDE when fusion logging is turned on
Comment: Visual Studio 2017 version 15.5.6 is the latest version as of 20th Feb 2017. At least, the update installer doesn't offer a later one. The same issue occurs with the same file in VS2015. I haven't tried VS2013 and currently don't have VS2010 installed, but can't imagine they'd be any better.
Comment: I'll dig in a bit more. I'm experiencing some crazy bugs on VS 2017.


Python BeautifulSoup duvidas

Question: Estou fazendo um requests.post e ele me retorna as seguintes informações:
<code>{"Name":"Joey Triibianni","Vocation":"Knight","Level":"425","World":"Quelibra","Account Status:":"Free Account"}
</code>
Já tentei de algumas formas porém não estou conseguindo fazer a formatação por blocos. Eu queria apenas os valores World : {value}, Account Status: {value}.
Comment: Isso parece ser um JSON. Conhece esse formato?
Comment: muito pouco, sou iniciante em python.
Comment: JSON é um formato de texto estruturado, independente do Python. Sugiro que pesquise o básico sobre ele antes de continuar.
Comment: passei dessa forma p/ obter aquela resposta.
Comment: Obrigado Anderson, o JSON foi a resposta mesmo.. consegui resolver.
Comment: Aliás, se está utilizando o Requests, o BeatifulSoup é desnecessário.
Comment: Está ok, obrigado pelas dicas.
Answer: A URL que está requisitando retorna um JSON. A biblioteca BeatifulSoup serve para analisar documentos XML (e, por consequência, HTML). Ou seja, não precisa utilizá-la.
A própria biblioteca Requests já faz tudo o que precisa:
<code>import requests

response = requests.post(url, data)

if response.ok:
    json = response.json()
    world = json['World']
    status = json['Account Status']
</code>

Python BeautifulSoup duvidas


center a text inside a div

Question: i would like to know how could i center my text inside a div. in my code this isn't work will for every p-tag, cause text length are not the same.
HTML:-

text text text

CSS:-
#content .textBlock {
 position: relative;
 text-align: center;
 width: 100%;
 float: left;
 display: block;
 min-height: 160px;
}

#content .textBlock p {
 position: absolute;
 top: 50%;
 -webkit-transform: translateY(-50%);
 -ms-transform: translateY(-50%);
 transform: translateY(-50%);
 font-size: 28px;
 font-family: Helvetica, Arial;
 font-weight: 100;
 padding: 0 5%;
 line-height: 34px;
 letter-spacing: 0.1em;
}

Answer: not sure what all the other code is for if you're only aligning text?

.textBlock {
 text-align: center;
 min-height: 160px;
}

.textBlock p {
 font-size: 28px;
 font-family: Helvetica, Arial;
 line-height: 34px;
 letter-spacing: 0.1em;
}

text text text

Comment: That's right, it's the absolute positioning that causes the problem. Not sure if this is the answer though; what if the OP does need the absolute positioning?
Answer: please Try this one:
Html:

text text text

Css:
.textBlock {
 text-align: center;

    background-color:gray;
}

.textBlock p {
 font-size: 28px;
 font-family: Helvetica, Arial;
 line-height: 34px;
 letter-spacing: 0.1em;
    color:white;
}

DEMO

center a text inside a div


Why do old russian guitar songs sound out of tune?

Question: I'm not actually 100% sure these are out of tune, but they sound out of tune to me. Here are some examples on YouTube:

Example 1 (1943)
Example 2 New example 2 (1970)
Example 3

It's a bit harder to tell in the third example, because it might be that the weird chords contribute to this effect. But the first example seems pretty clear. One thing all such recordings share is that they're all very old, so could it be an artifact of old recording technology?
Most of all, are these guitars actually out of tune, or do they just sound different?
Comment: First song: http://en.wikipedia.org/wiki/Dark_Is_the_Night_%28Soviet_song%29
Answer: Sound in tune to me. The second example is a semitone down on standard 440Hz pitch,but still in tune. It may be that Russian tuning is/was not the same as Western standard, but still in tune with itself. Spot the 7 string guitars? Standard low B strung when I bought mine in Leningrad, in 1964 !! So it's not such a modern idea.
The videotapes must be 40-50 yrs old, so a bit of wow and flutter are to be expected, surely?
Answer: The strings sound quite thin - they have that twangy feel which you get if you string a steel acoustic with very light strings.
Also some of the guitars look quite small meaning a short neck, which means the strings can be looser to get the same note. The looseness adds to the effect Tetsujin mentions :
When you hit the string to get volume, for a moment it stretches while it's vibrating a lot (a bit like bending the string very slightly) and the note is slightly sharpened until the string settles down and gives a more reliable note. It makes things sound slightly out of tune.
The third example (possibly others too) has 'wow' on the recording. This is usually caused where the spindle which drives the tape feed in the recorder is very slightly not perfectly circlular meaning the tape just marginally runs fast-slow-fast, usually about 4 or 5 times a second, as the high spot on the spindle hits the tape.
The end result if that the recording (or maybe just playback) ends up with a vibrato effect because the speed of the tape is varying. Wow is a slow variation - if it gets faster, it's called 'flutter'.
It's a subtle effect and something we're not used to these days because digital media has eliminated it completely. It's more noticable on piano music.
On a guitar, sometimes people play with a bit of vibrato, and often use it vocally, and maybe your mind puts it down to that. There's no "whammy bar" on a piano (there's an idea..) so the notes are very steady, making it much more noticable if they do waver owing to 'wow'.
The 3rd example also seems to have something which is just plain out of tune, though.
Answer: First example:
This is a Soviet war-time song "Тёмная ночь" (Dark Is the Night), the soldier is singing about bullets flying outside, his longing to see his love, who he knows is not sleeping and is crying near their baby's crib.
Several considerations come to mind:

In the movie, it is shown as a song that is sung by a soldier, and it would be weird if the guitar was ideally in tune and everything sounded polished. The soldier probably had a very cheap guitar, which is bound to have intonation problems (I know my first Russian guitar had). Those who recorded the song for the movie probably had that in mind.
I suspect good quality Russian-made acoustic guitars were hard to come by in general, especially in 1930s-1950s.
It seems that the video is sped up slightly so that the sound is about a halftone higher than I'd expect it to be (2nd and 3rd open strings should be G and B, not G# and C). Since this is a restored video that has probably been re-recorded and re-encoded multiple times (including digital recording from some mechanically-driven format), it's not really surprising that the pitch moves up and down slightly.
It sounds like open 2nd and 3rd string (G and B, both in Russian 7-string tuning and in classical guitar tuning) are slightly out of tune, which is most obvious in the intro. On cheap guitars with high action that could be a result of a compromise in tuning: a proficient guitar player could tune so that open strings are slightly out of tune, but the intonation on some specific frets (typically, 1, 3 for B, 1, 2 for G) is not completely horrible.

Examples 2 and 3:

Both are sung by Vladimir Vysotsky, who was known for preferring a slightly out-of-tune guitar (here is a story about Vysotsky getting angry and stopping during a song to detune the guitar when he discovered that someone from the orchestral band he was playing with tuned his guitar before the performance).
Example 2 has extremely poor quality, with compression damaging the sound badly.
Similarly to Example 1, most of these songs were sold on LPs, which implies mechanically-driven conversion to get the digital version, that could possibly introduce slight pitch shifts which would produce an effect similar to being out of tune.
Comment: Here's [another Vysotsky video](https://youtu.be/vA0aWBGqTR4?t=30) with better sound quality (bar the annoying high pitched whine). His voice sounds amazing, but the guitar sounds pretty odd to my western ear.
Comment: Ah, that annoying high pitched whine brings back some memories from my childhood: as I expected when I just heard it, it's around 15.625KHz —the sound that old TV flyback transformers produced, that corresponded to the horizontal line scan frequency of PAL TV transmission. That suggests that this video was recorded from a TV, or a TV acoustic noise was present at some stage during rerecording.
Answer: In addition to the excellent answers given by others, there are reasons why "in-tune" old Russian songs might sound "out-of-tune" to a modern western ear.
At a basic level, a guitar is made for western chromatic scales. However bends are very easy to achieve, and players in some styles do them almost without thinking. This is all over blues guitar playing, for example.
This semi-traditional Russian music is in a mode that's moderately unfamiliar to the Western ear; but in addition to that, the heritage of the music flows back to traditions that weren't based around the 12 semitone chromatic scale. Russia borders China and Mongolia; Stalin suppressed hundreds of indigenous languages and cultures, but didn't quite manage to stamp them out -- these had their own music which left its mark on Russian music.
Early balalaikas had movable frets (just rings of gut wrapped around the neck).
I think that some of the notes you hear as "out of tune" are in-tune, within a microtonal scale that would be familiar to Russian ears of the period.
Comment: It's worth noting, in this context, that 12-edo tuning was actually invented in China, long before western music started to take it up! Arguably, the tuning is _better_ suited for many far-eastern styles (which tend to be mostly 3-limit), than for western classical music (whose 5-limit thirds are not represented so well by 12-edo). Of course, this doesn't mean far-eastern influences (which may include excessive pitch bends, and some styles probably also have higher limits like in Indian music) are not a factor which might make Russian music sound off to western ears in the age of autotune.
Answer: There's no reason why a Russian guitar should sound any more out of tune than Western six string, but there are many reasons why it might...
Firstly, consider that all guitars, even perfectly built and tuned ones,  sound slightly out of tune to harmonic purists on account of their equal temperament tuning, without which they would not sound "in tune" to anyone.  This is not a technical deficiency of the guitar, but of the music and the way in which we perceive harmony, which forces us to relentlessly seek out intervals whose base frequencies exist in the perfect integer ratios of the harmonic series; intervals which fixed pitch instrument such as pianos and guitars cannot accomodate.
Secondly, the guitars in these videos may not be very well built. In the early part of the 20th century many manufacturers were still using the archaic rule of 18 to place the frets. Even today, many Gibsons still use this formula in place of the 12th root of 2.
The players in the videos may not have tuned their guitars properly. Most guitar technicians are familiar with the phenomenon where guitarists tune their guitar so that the E chord sounds "right" only to find that the open C and G chords sound dissonant. The Russian guitar is traditionally tuned to a G chord. Doing this by ear results in a similar problem: the frets divide the strings by equal temperament intervals but the courses are tuned to natural harmonic intervals. This results in fretted notes on adjacent strings being different, particularly in relation to open strings. Furthermore, if the guitar hasn't been well built - the bridge/saddle combination may not be located properly, the frets placed according to an outdated formula, the neck is bent or has too much arc relief, all of which are common issues on early 20th century guitars - then tuning the guitar to the standards expected by modern musicians raised with digital tuners and precision CNC build technology may be literally impossible.
Comment: Pretty sure I myself can't really hear the difference between equal temperament chords and "just" chords. Good point that these guitars could have simply been made very badly and impossible to tune well! That could explain why I can't find a recent video with the same effect just as well as the theory that it's the poor old-tech recording that makes it sound weird.
Answer: The gliss hurts; cheap strings, hit too hard - after half a second or so they settle down to tuning (ish), but both 1 & 2 are a bit painful for me.
I'm not sure I can bear to listen to 3...
Edit 1 bar of 3, switched it off.
Answer to the question... "Yes, they are out of tune"


Is the sum of rational exponentials a rational exponential?.

Question: Prove or disprove that $\forall a,b \in \mathbb{Q}^+$ and $ \forall p,q \in \mathbb{Q}$ there exists $c \in \mathbb{Q}^+$ and  $r \in \mathbb{Q}$ such that:
$$
a^p+b^q=c^r
$$
Comment: Have you made any attempts on this problem?
Answer: Hint: Suppose that $\sqrt{1}+\sqrt{2}$ is of the shape $c^r$, where $c$ is a positive rational and $r=\frac{m}{n}$ where $m$ and $n$ are integers, with $n\gt 0$. Show by taking the $n$-th power of both sides that this implies that $\sqrt{2}$ is rational.
Comment: Yes!! In the binomial formula for $(1+\sqrt{2})^n$ there's always some $\sqrt{2}$.
Comment: Yes, that's right, in the expansion all terms are positive, so there cannot be cancellation.


I am having trouble in knowing the correct way to play this legato on a guitar tablature.

Question:
What is the accurate way to play this. I'd appreciate it very much if the explanations were kept to layman terms. I am a complete beginner, with 0 background in music theory. Only been playing the guitar for just under a year.
Thanks in advance people.
Answer: You're thinking it's legato(smooth), as there's a slur between the notes on the G on the top string. It's actually a tie, as usually you can't slur two notes that are the same. The tie it there because the note at the beginning of the second bar is 'pushed' - it gets played a little before the first beat, and is held on until the next note (not shown) is played. So simply hold it down on the 3rd fret, and play whatever comes next after it.
The D on the 2nd string stops at the end of the bar, and the open D gets played while the top G is still sounding.
This is good tab, as it actually shows timing along with where the notes are fretted.


Incoming calls dialplan with asterisk and chan_mobile

Question: I managed (with very much joy :D) to configure chan_mobile with asterisk 1.8 and my iPhone 4 and outgoing calls work nicely.
I have issues with automatic answering incoming calls.
This is what my chan_mobile.conf looks like:
<code>[adapter]
address = 11:11:11:11:11:11
id = box-1

[iphone]
address = 22:22:22:22:22:22
port = 8
context = from-test-phone
adapter = box-1
</code>
and in /etc/asterisk/extensions.conf I added
<code>[from-test-phone]
exten => s,1,Answer()
exten => s,n,Wait(1)
exten => s,n,Hangup()
</code>
But when I call my mobile phone there is no answer.
The bluetooth device is paired and active
<code># rasterisk
> mobile show devices

ID              Address           Group Adapter         Connected State      SMS
iphone      22:22:22:22:22:22      0     box-1            Yes     Free       No
</code>
Am I missing something?
Comment: If you open up Asterisk CLI with rasterisk, run "core set verbose 4" and "core set debug 4" and call your iPhone, what do you get in your terminal?
Comment: ok this is really a mistery, with verbose and debug 4 it works, back to 0 it doens't!!! Anyway really thank you dude :)
`debian*CLI> core set verbose 4
Verbosity was 0 and is now 4
debian*CLI> core set debug 4
Core debug was 0 and is now 4
    -- Executing [s@from-test-phone:1] Answer("Mobile/iphone-6e3e", "") in new stack
    -- Executing [s@from-test-phone:2] Wait("Mobile/iphone-6e3e", "1") in new stack
    -- Executing [s@from-test-phone:3] Hangup("Mobile/iphone-6e3e", "") in new stack
  == Spawn extension (from-test-phone, s, 3) exited non-zero on 'Mobile/iphone-6e3e'`
Comment: Don't edit questions with words "SOLVED", but rather provide an answer, so it's highlighted as such automatically.. This is a Q&A site.
Answer: Apparently it was enough to type
<code>rasterisk
> core set verbose 4
> core set debug 4
</code>
thanks user1938742!


Eclipse, ant and custom tasks

Question: Sorry, I'm not terribly experienced with Ant.
I like the eclipse "Export ant buildfile" function, but I need to insert a few custom tasks (Copying files, calculating checksums that are used at runtime, etc).
How do I integrate custom ant tasks with the antfile that Eclipse exports?  Also, once I've done so, will the internal build (Run...) pick it up or will I always have to use the external ant file to build from now on?
Oh, and I don't want to edit the build.xml that is exported from Eclipse, because I'd like to be able to regenerate it later.
Edit/Update:
It took me a while to figure out what was going on--so I thought I'd put some notes here to clarify.
When you create a new ant file in your directory and put <?eclipse.ant.import ?> on the first line of your custom ant script (I called mine test.xml), next time you export the buildfile from Eclipse into that directory, it'll see that tag and add <import file="test.xml"/>
With that Import, the targets in your "Custom" file (test.xml) become valid targets in your exported build.xml (or whatever name you chose when you exported it).
After this, anytime you select "build.xml" in Eclipse, the targets pane will also include targets from "test.xml"
Also, after that, you can go into your project properties/Builders and add a new builder of type "Ant Build", then select targets to use for building, clean, etc.
Comment: I have tried this on Eclipse 3.4.1 and figured out, that my custom build file was only included when its name started with build. For example, build-custom.xml was imported correctly, but custom_build.xml was ignored...
Maybe this helps anyone...
Comment: Same with me, I am using Eclipse 3.5.2 on Ubuntu, and had to rename my file to build-custom.xml instead of custom-build.xml
Answer: The ant export filter will include any xml file in the same directory which has the special
<?eclipse.ant.import?>

element as its first child.
Example:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse.ant.import?>
<project name="project" default="default" basedir=".">
    ...
</project>

Eclipse will now include the following line in build.xml:
<import file="custom_build.xml"/>

Comment: @Derek all examples are gone, can you please include the examples again?
Comment: Geocities is gone, so find the example [here](http://timealias.bplaced.net/eclipse2ant/doc/build-user.xml) and the site [here](http://timealias.bplaced.net/eclipse2ant/)
Comment: @JesperE What values should be assigned to the name and default? Also, I want this target (say targetA) to depend on another target (say targetB) defined in the main build.xml file but eclipse shows an error saying that the targetB doesn't exists in this project.
Answer: If you write your own Ant script, you can write your own targets that use the Ant task to delegate to the generated build.xml.
Also, you can configure a project's 'builders' (project properties » Builders) to run any something different when you build the project, manually or automatically.
Answer: PDE has support for custom callbacks from the generated build.xml into your own custom ant script. Copy the file "templates/plugins/customBuildCallbacks.xml" from the org.eclipse.pde.build in your eclipse install, and set "customBuildCallbacks=true" in your build.properties file.
See also the Eclipse help page
Answer: You can have a separate ant build file for these tasks. Thats all you need.

Eclipse, ant and custom tasks


Erro ao iniciar ApplicationContext através de uma aplicação Spring

Question: Boas colegas. Estou a começar a desenvolver com o spring, porem estou com um problema não estou a conseguir executar a minha aplicação web, sempre que executo lança a seguinte mensagem de erro no spring:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-10-12 11:00:08.063 ERROR 13660 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   :

***************************
APPLICATION FAILED TO START
***************************

Description:

Field catDAO in mz.com.centropontoencontro.service.CategoriaLivroServiceImpl required a bean of type 'mz.com.centropontoencontro.dao.CategoriaLivroDAO' that could not be found.
The injection point has the following annotations:
    - @org.springframework.beans.factory.annotation.Autowired(required=true)

Action:

Consider defining a bean of type 'mz.com.centropontoencontro.dao.CategoriaLivroDAO' in your configuration.

Abaixo deixo as classes e interfaces.
classe CategoriaLivroDAOImpl
@Repository
public abstract class CategoriaLivroDAOImpl extends AbstractDAO<CategoriaLivro> implements CategoriaLivroDAO {
}

interface CategoriaLivroDAO
public interface CategoriaLivroDAO {

            void save(CategoriaLivro catLivro);

            void update(CategoriaLivro catLivro);

            void delete(Long id);

            CategoriaLivro findById(Long id);

            List<CategoriaLivro> findAll();
        }

Interface CategoriaLivroService
public interface CategoriaLivroService {

        void salvar(CategoriaLivro categoriaLivro);

        void editar(CategoriaLivro categoriaLivro);

        void excluir(Long id);

        CategoriaLivro procurarPorId(Long id);

        List<CategoriaLivro> pesquisarTodos();

    }

Classe CategoriaLivroServiceImpl
@Transactional(readOnly = false) @Service public class CategoriaLivroServiceImpl implements CategoriaLivroService {

        @Autowired
        private CategoriaLivroDAO catDAO;

        @Override
        public void salvar(CategoriaLivro categoriaLivro) {
            catDAO.save(categoriaLivro);
        }

        @Override
        public void editar(CategoriaLivro categoriaLivro) {
            catDAO.update(categoriaLivro);
        }

        @Override
        public void excluir(Long id) {
            catDAO.delete(id);
        }

        @Transactional(readOnly = true)
        @Override
        public CategoriaLivro procurarPorId(Long id) {

            return catDAO.findById(id);
        }

        @Transactional(readOnly = true)
        @Override
        public List<CategoriaLivro> pesquisarTodos() {
            return catDAO.findAll();
        }

    }

Classe de execução da aplicação
package mz.com.centropontoencontro;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class CentroPontoEncontroApplication {

    public static void main(String[] args) {
        SpringApplication.run(CentroPontoEncontroApplication.class, args);
    }

}

arquivo POM.XML
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.9.RELEASE</version>
        <relativePath />
    </parent>
    <groupId>mz.com.centropontoencontro</groupId>
    <artifactId>centro-ponto-encontro</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>centro-ponto-encontro</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>webjars-locator</artifactId>
            <version>0.37</version>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
            <version>4.3.1</version>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>popper.js</artifactId>
            <version>1.15.0</version>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>jquery</artifactId>
            <version>3.4.1</version>
        </dependency>

        <dependency>
            <groupId>nz.net.ultraq.thymeleaf</groupId>
            <artifactId>thymeleaf-layout-dialect</artifactId>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>font-awesome</artifactId>
            <version>5.11.2</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

O que devo fazer? Obrigado
Comment: Poste sua configuração de scan dos pacotes (ou classe de configuração / aplicação)
Comment: desculpa eu não sou experiente, estás a referir a classe que está anotada com a anotação  @SpringBootApplication??
Comment: Sim, e mais alguma `@Configuration` se houver
Comment: editei na própria mensagem a classe de execução e o arquivo POM.xml
Comment: Inclua a classe toda, inclusive declaração de pacotes e imports
Comment: já acrescentei na mensagem
Answer: Pelo que entendi do seu problema, o Spring não está conseguindo injetar uma instância do tipo CategoriaLivroDAO no atributo "catDAO" na classe "CategoriaLivroServiceImpl".
Olhando o seu código, eu moveria a anotação @Repository da classe CategoriaLivroDAOImpl
 para a interface CategoriaLivroDAO:
public abstract class CategoriaLivroDAOImpl extends AbstractDAO<CategoriaLivro> implements CategoriaLivroDAO {
}

@Repository
public interface CategoriaLivroDAO {

    void save(CategoriaLivro catLivro);

    void update(CategoriaLivro catLivro);

    void delete(Long id);

    CategoriaLivro findById(Long id);

    List<CategoriaLivro> findAll();
}

Answer: Amigo, seu dao não sabe a implementação, sendo assim ele não consegue "dar new"
Você pode injetar o seu dao das seguintes maneira
1  -  remova o abstract do seu IMPL
 @Qualifier("categoriaLivroDAOImpl")
 private CategoriaLivroDAO catDAO;

Ou
2 Crie um bean na mão
@Bean public CategotiaLivroDao categoriaLivroDAOImpl(){return new CategoriaLivroDAOImpl()}

Outro ponto, o jpa do spring já vem com um query buider pronto
https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#reference


How to insert a UITextView to a UIImageView

Question: I'm programming an application, in wich you create UIImageView-objects.
The color of these objects can be set.
But the next step I am trying to do is: set a TextView in the imageView, but this text should entered by the user (certainly realized with the class UIKeyboard.)
Im sum: I have a imageView, which needs an editable UITextView in it.
Do you have any idea how it could be realized?
Comment: have you tried `[myUIImageView addSubView:myUITextView]` by chance?
Comment: Wouldn't placing a UITextView on top over your UIImageView solve the problem?
Comment: Tom Jowett thanks, it is working. Just working on optimizing the whole thing :)
Answer: Your approach is wrong.
You want an image view because the app lets you "create an image"
In reality and technically this isn't correct, what you will want to be doing is using a simple UIView to set he colour of an area, and you an place a UITextField or UITextView over that.
A UIImageView is a very specific UIView subclass for displaying images. You can't add your other UI inside of it, the best you could do is over it.
I you do use a UIView, when you're done you need to "convert" your UIView to an image which you can then use to save, send etc
For more about that check out Save UIView's representation to file
Answer: You simply want to subclass UIImageView and add a UITextView during init. Like this
@interface MyImageView : UIImageView {

}
@property (nonatomic, strong) UITextView *textView;
@end

And the implementation
@implementation MyImageView
- (id)init {
    if ((self = [super init])) {
        self.textView = [[UITextView alloc] initWithFrame:CGRectMake(...)];
        [self addSubview:self.textView];
    }
    return self;
}
@end

Comment: I really don't suggest subclassing UIImageView here, please see my thoughts below.


Defining multiples of principal-region angles in inverse trig terms

Question: Consider $tan^{-1}x = \theta$. Then apparently $3\theta=tan^{-1}{}\frac{3x-x^{3}}{1-3x^{2}}$.
How does this work out if $3\theta$ doesn't end up in the first or third quadrant, i.e., if it's not in the range of arctan?
Answer: The arctangent is a multivalued function since $\tan$ is periodic with period $\pi$. Thus, to get the correct value of $3\theta$, we have to add or subtract $\pi$ repeatedly.
Comment: Yeah, so isn't the formula in the question inadequate?
Comment: @HarryHolmes Not exactly inadequate, but it would have been better to write $\tan3\theta=\dots$


Cartesian products and families

Question: I have some trouble trying to understand Halmos' explanations about generalized Cartesian products. I've read these entries already:

Cartesian products of families in Halmos' book. This also has
the page I'm stuck on.
One-to-one correspondence between a Cartesian
product and a set of families
set theoretic function, products
of sets (product versus Cartesian product)

Is his generalization the same as a Cartesian product of several sets? As here: Multiple products
What puzzles me is $\{a,b\}$. Where does it come from, what does it do? I know that it is supposed to be arbitrary. How does it identify distinct elements of $X \times Y$? Does some function map each $a \in A$ to an element in $X$? Or is it always the same $a$?
What does he mean by

the set $Z$ of all families $z$, indexed by $\{a,b\}$, such that $z_a \in X$  and $z_b \in Y$

? What does does an element of $Z$, namely one family $z$, consist of? By family, does he mean an indexing function or the indexed elements?
This comes to a very important question for me: Does family mean a function or the set of all indexed elements?
I will try to explain how I understand it thus far: $Z$ contains elements of the form $\{(a,x),(b,y)\}$. The choice of $x$ depends on $a$, so an $x$ in a $z \in Z$ equals the $z_a$ of $X$. Now, we want to map these pairs to $X \times Y$, so we have a function $f$ that takes $z \in Z$ and connects it to the corresponding ordered pair $(z_a, z_b)$, where $z_a \in X$. $X \times Y$ is not the same as $Z$; they only, effectively, contain equal elements.
He goes on:

If $\{X_i\}$ is a family of sets ($i \in I$), the Cartesian product of the family is, by definition, the set of all families $\{x_i\}$ with $x_i \in X_i$ for each $i$ in $I$.

How I understand it: $\{X_i\}$ contains, as elements, several sets, each single one a set $X$ identified by an index/element of $I$. Then, we go over all indeces $i$ in $I$, take from each set $X$, namely $X_i$, an element $x$ and add it to current set of the newly created sets/families. So, the lower index $i$ does not refer to an element of $X_i$ indexed by $i$, but rather calls all elements of $X_i$ $x_i$. We end up with a set, defined as Cartesian product, of sets, in which each element (set) contains ordered elements, each from a different $X_i$.
How does the ordering occur?
$\prod_i X_i$, the Cartesian product, becomes equal to $X^I$, if all $X_i$ are the same set $X$. $X^I$ means all possible combinations of mapping from $I$ to $X$. We randomly take an elements $x$ from some $X_i$, put it in a set/family with other randomly obtained $x$, put the entire set into a set denoted $X^I$, and continue doing so, till we have no more options. Then, each set in the new $X^I$ contains a mapping of some $i$ to some $x$. Since we exhausted the options, they are indeed all combinations.
Where did I go wrong? Someone needs to spoonfeed my the answer; I am completely confused by now.
Answer: A few simple steps: A family of elements of $A$ that is indexed by $I$ is just a function $f\colon I\to A$, however, usually writing $f_i$ instead of $f(i)$. Thus a "family $z$, indexed by $\{a,b\}$ such that $z_a\in X$ and $z_b\in Y$" is nothing but a function $z\colon \{a,b\}\to X\cup Y$ with $z(a)\in X$ and $z(b)\in Y$. Indeed, $a$ and $b$ are arbitrary (but distinct). Some authors use a fixed choice $a=\emptyset$ and $b=\{\emptyset\}$, but $a=\text{horse}$ and $b=\text{apple}$ would fulfill the same purpose if applicable.
After seing this, $Z$ is the set of all such families (but still with fixed choices of $a$ and $b$). Indeed, this is essentially the same as $X\times Y$, as the author continues, if one identifies such a family $z$ with the ordered pair $(z(a),z(b))=(z_a,z_b)$. There is no ordering in $z$ unless we say that $a$ "precedes" $b$. Yet the identification with $X\times Y$ depends on the fact that we associate $a$ with $X$ and $b$ with $Y$, so this makes $a$ somewhat the first element and $b$ the second, if we want to identify $Z$with $X\times Y$ because $X$ is the first and $Y$ the second factor in this artesian product. We can also identify $Z$ with $Y\times X$ (then having ipso facto $b$ "preceeding" $a$). (Now what if $X=Y$?).
Note that in general, a family of sets $\{A_i\}_{i\in I}$ indexed by some index set $I$ is not really ordered unless $I$ is ordered. But nevertheless we know what it means that $\{B_i\}_{i\in I}$ is ordered "in the same way" even though neither is actually ordered. That is, we associate $A_i$ with $B_i$ for the same index $i$ (and not permuting the elements of $I$ on the way).
Comment: Now I think I know what I got wrong: $z$ does not, at once, go from a set $\{a,b\}$ but from the individual elements. That is actually obvious, I guess. $z_a$ is the same as $z(a)$? That clears it up. $a$ and $b$ are used to distinguish $X$ and $Y$. Then, $z(a)$, each time, refers to a different element in $X \cup Y$ or $X$.
So, $Z$ is a set of functions (the families)? And it can be interpreted as a set of pairs, though the elements as such are not actually pairs?

Cartesian products and families


String ..params not working on PHP 5

Question: My code is here
<?php

        select("id","name");
        function select(string ...$value){
        var_dump($value);
    }

But it's only working on php 7 . When I working on PHP 5.6 machine , I got fatal error like this.
Catchable fatal error:  Argument 1 passed to select() must be an instance of string, string given, called in [...][...] on line 2 and defined in [...][...] on line 3

When I working on php 7 machine the output is
array(2) {
  [0]=>
  string(2) "id"
  [1]=>
  string(4) "name"
}

Doesn't php 5.6 support such kind of thing?
Comment: It would be helpful if you also posted the error.
Answer: You can't use 'string', or any other primitive types, as typehints in PHP versions before 7.  See PHP type-hinting to primitive values?.
You can just use the non-typehinted version if you need compatibility:
  <?php

        select("id","name");
        function select(...$value){
        var_dump($value);
    }

Comment: Thanks Badzen . I got it .

String ..params not working on PHP 5


How to assess skewness from a boxplot?

Question: How to decide skewness by looking at a boxplot built from this data:
340, 300, 520, 340, 320, 290, 260, 330
One book says, "If the lower quartile is farther from the median than the upper quartile, then the distribution is negatively skewed." Several other sources said more or less the same.
I built a boxplot using R. It's like the following:

I take that it's negatively skewed, because the lower quartile is farther from the median than the upper quartile.
But the problem is when I use another method to determine skewness:
mean (337.5) > median (325)
This indicates the data is positively skewed.
Did I miss something?
Answer: One measure of skewness is based on mean-median - Pearson's second skewness coefficient.
Another measure of skewness is based on the relative quartile differences (Q3-Q2) vs (Q2-Q1) expressed as a ratio
When (Q3-Q2) vs (Q2-Q1) is instead expressed as a difference (or equivalently midhinge-median), that must be scaled to make it dimensionless (as usually needed for a skewness measure), say by the IQR, as here (by putting $u=0.25$).
The most common measure is of course third-moment skewness.
There's no reason that these three measures will necessarily be consistent. Any one of them could be different from the other two.
What we regard as "skewness" is a somewhat slippery and ill-defined concept. See here for more discussion.
If we look at your data with a normal qqplot:

[The line marked there is based on the first 6 points only, because I want to discuss the deviation of the last two from the pattern there.]
We see that the smallest 6 points lie almost perfectly on the line.
Then the 7th point is below the line (closer to the middle relatively than the corresponding second point in from the left end), while the eighth point sits way above.
The 7th point suggests mild left skew, the last, stronger right skew. If you ignore either point, the impression of skewness is entirely determined by the other.
If I had to say it was one or the other, I'd call that "right skew" but I'd also point out that the impression was entirely due to the effect of that one very large point. Without it there's really nothing to say it's right skew. (On the other hand, without the 7th point instead, it's clearly not left skew.)
We must be very careful when our impression is entirely determined by single points, and can be flipped around by removing one point. That's not much of a basis to go on!

I start with the premise that what makes an outlier 'outlying' is the model (what's an outlier with respect on one model may be quite typical under another model).
I think an observation at the 0.01 upper percentile (1/10000) of a normal (3.72 sds above the mean) is equally an outlier to the normal model as an observation at the 0.01 upper percentile of an exponential distribution is to the exponential model. (If we transform a distribution by its own probability integral transform, each will go to the same uniform)
To see the problem with applying the boxplot rule to even a moderately right skew distribution, simulate large samples from an exponential distribution.
E.g. if we simulate samples of size 100 from a normal, we average less than 1 outlier per sample. If we do it with an exponential, we average around 5. But there's no real basis on which to say that a higher proportion of exponential values are "outlying" unless we do it by comparison with (say) a normal model. In particular situations we might have specific reasons to have an outlier rule of some particular form, but there's no general rule, which leaves us with general principles like the one I started with on this subsection - to treat each model/distribution on its own lights (if a value isn't unusual with respect to a model, why call it an outlier in that situation?)

To turn to the question in the title:
While it's a pretty crude instrument (which is why I looked at the QQ-plot) there are several indications of skewness in a boxplot - if there's at least one point marked as an outlier, there's potentially (at least) three:

In this sample (n=100), the outer points (green) mark the extremes, and with the median suggest left skewness. Then the fences (blue) suggest (when combined with the median) suggest right skewness. Then the hinges (quartiles, brown), suggest left skewness when combined with the median.
As we see, they needn't be consistent. Which you would focus on depends on the situation you're in (and possibly your preferences).
However, a warning on just how crude the boxplot is. The example toward the end here -- which includes a description of how to generate the data --
gives four quite different distributions with the same boxplot:

As you can see there's a quite skewed distribution with all of the above-mentioned indicators of skewness showing perfect symmetry.
--
Let's take this from the point of view "what answer was your teacher expecting, given that this is a boxplot, which marks one point as an outlier?".
We're left with first answering "do they expect you to assess skewness excluding that point, or with it in the sample?". Some would exclude it, and assess skewness from what remains, as jsk did in another answer. While I have disputed aspects of that approach, I can't say it's wrong -- that depends on the situation. Some would include it (not least because excluding 12.5% of your sample because of a rule derived from normality seems a big step*).
* Imagine a population distribution which is symmetric except for the far right tail (I constructed one such in answering this - normal but with the extreme right tail being Pareto - but didn't present it in my answer). If I draw samples of size 8, often 7 of the observations come from the normal-looking part and one comes from the upper tail. If we exclude the points marked as boxplot-outliers in that case, we're excluding the point that's telling us that it is actually skew! When we do, the truncated distribution that remains in that situation is left-skew, and our conclusion would be the opposite of the correct one.
Comment: @jsk That depends on how you want to measure skewness. Since degree of skewness is partly determined by outlying points (a tendency to be more outlying one direction than another), removing them arguably misses the point of measuring skewness. A more detailed discussion and analysis is in my updated post. If you're unconvinced, please feel free to disagree, such exchanges are often valuable.
Comment: @Glen_b While I certainly respect and understand the stance you are taking, I do believe there is a reasonable argument to be made for judging skew after removing the outlier as opposed to before.  After removing the outlier, the distribution will even still be negatively skewed after removing the 7th point (260).  Did you check the qqplot and/or compare the mean and median?
Comment: Perhaps the case is quite weak after removing the 7th, but I see no reason to justify judging the skew after removing it.  It's not an outlier, though the point is well-taken that the measures of skew, no matter how you look at them in this case, are being driven by single points.
Comment: @Glen_ b Q3 + 1.5IQR is the typical rule of thumb taught at this level for identifying outliers in the upper tail. Whether or not to remove them is another matter.  Are you arguing that the distribution is right skewed because the mean is larger? Why ignore the fact that Q1 is further from Q2 than Q3 is?
Comment: I want to spell out what is near the surface here but not quite: often boxplots condense too much, so you may need to look at all the data too.
Comment: @jsk It really depends on context. Without some basis to call it an atypical point, how would one declare it so? If I know it's a count, or a physical measurement of something, I might have some basis for understanding what a truly atypical value is. If I have a model - such as 'the data are normal' then I also have a basis. If I were computing a sample mean, I might even have some way of deciding. If I don't know what I am dealing with and I only have n=8? It would have to be pretty darn big for me to say "no matter what I am dealing with, no matter what my model, that point doesn't belong'
Comment: @jsk Many of my answers conflict with information that is often given to students. And information here should be useful to a variety of people. I have sympathy with not confusing students (having had many myself), but there are also other considerations.
Comment: Wow! What a thorough answer. I have much clearer understanding of skewness now. Thank you very much.
Comment: @Glen_b Do you think comparing the mean to the median is an appropriate measure of skewness in the presence of an extreme outlier?
Comment: I just started to learn statistics and skewness is one of the concepts that I thought that I had a solid grasp on. Now look at this and your other post on skewness. I couldn't possibly have imagined that a seemingly basic statistical concept could become so tricky.
Comment: @jsk There's a mild suggestion of left skewness there, I'd agree, but it's quite weak without the seventh point, and I'd be unwilling to declare the distribution left or right skew on the basis of those six points. With the six points that are left you have a result that could easily come from distributions that are right skew by all three measures I mentioned.  I just now generated 3 uniform samples of size 6 and one of them looked more left skew than that. If I was asked to stipulate what the sample skewness was, I'd have to ask by what measure. Certainly by some measures, it's negative.
Comment: @jsk How do you judge what's an outlier in a right-skewed distribution (as it appears to be with the 8th point there)?
Comment: The boxplot rule-of-thumb is based on a robust approximation to a rule using normality. I'm arguing it's right skew from the appearance of the QQ plot when all data is included.
Comment: @Nick A good point to make.
Comment: @jsk I added a little to my answer to address some of your points. I think you make some good ones!
Comment: @Glen_b You make good points regarding not using the 1.5 IQR rule of thumb. I would however point out that we have likely gone past the level at which the material was taught to the student and that the student may no longer get the answer the teacher intended. This is not a homework help site, but it's quite possible that the views presented here, however reasonable they are, may be in conflict with the material presented to the student.
Comment: @Glen_b How large would the max have to be in this case before you would feel comfortable calling it an outlier?
Comment: Although we remember Pearson's re-invention of moment-based skewness -- Thiele got there first -- he seems to have regarded skewness relative to the mode as more fundamental, which is well defined in his family of distributions, which have (almost) faded from use or interest within statistical science.  He didn't quite advocate (mean $-$ median) / SD, but he came close.
Answer: No, you did not miss anything: you are actually seeing beyond the simplistic summaries that were presented.  These data are both positively and negatively skewed (in the sense of "skewness" suggesting some form of asymmetry in the data distribution).
John Tukey described a systematic way to explore asymmetry in batches of data by means of his "N-number summary."  A boxplot is a graphic of a 5-number summary and thereby is amenable to this analysis.

A boxplot displays a 5-number summary: the median $M$, the two hinges $H^{+}$ and $H^{-}$, and the extremes $X^{+}$ and $X^{-}$.  The key idea in Tukey's generalized approach is to choose some statistics $T_i^{+}$ reflecting the upper half of the batch (based on ranks or, almost equivalently, percentiles), with increasing $i$ corresponding to more extreme data.  Each statistic $T_i^{+}$ has a counterpart $T_i^{-}$ obtained by computing the same statistic after turning the data upside-down (by negating the value of $T_i^{+}$ computed on the negative of the data).  In a symmetric batch, each pair of matching statistics must be centered at the middle of the batch (and this center will coincide with $M = M^{+}=M^{-}$).  Thus, a plot of how the mid-statistic $(T_i^{+} + T_i^{-})/2$ varies with $i$ provides a graphical diagnostic and can furnish a quantitative estimate of asymmetry.
To apply this idea to a boxplot, just draw the midpoints of each pair of corresponding parts: the median (which is already there), the midpoint of the hinges (ends of the box, shown in blue), and the midpoint of the extremes (shown in red).

In this example the lower value of the mid-hinge compared to the median indicates the middle of the batch is slightly negatively skewed (thereby corroborating the assessment quoted in the question, while at the same time suitably limiting its scope to the middle of the batch) while the (much) higher value of the mid-extreme indicates the tails of the batch (or at least its extremes) are positively skewed (albeit, on closer inspection, this is due to a single high outlier).  Although this is almost a trivial example, the relative richness of this interpretation compared to a single "skewness" statistic already reveals the descriptive power of this approach.
With a small amount of practice you do not have to draw these mid-statistics: you can imagine where they are and read the resulting skewness information directly off any boxplot.

An example from Tukey's EDA (p. 81) uses a nine-number summary of heights of 219 volcanoes (expressed in hundreds of feet).  He calls these statistics $M$, $H$, $E$, $D$, and $X$: they correspond (roughly) to the middle (50th percentile), the upper and lower quartiles (75th and 25th percentiles), the eighths (87.5th and 12.5th percentiles), the sixteenths (you get the idea), and the extremes, respectively.  I have indexed them in this order by $i=1, 2, 3, 4, 5$.  The left hand plot in the next figure is the diagnostic plot for the midpoints of these paired statistics (the "mid-letter statistics").  From the accelerating slope, it is clear the data are becoming more and more positively skewed as we reach out into their tails.

The middle and right plots show the same thing for the square roots (of the data, not of the mid-number statistics!) and the (base-10) logarithms.  The relative stability of the values of the roots (notice the relative small vertical range and the level slope in the middle) indicates that this batch of 219 values becomes approximately symmetric both in its middle portions and in all parts of its tails, almost out to the extremes when the heights are re-expressed as square roots.  This result is a strong--almost compelling--basis for continuing further analysis of these heights in terms of their square roots.
Among other things, these plots reveal something quantitative about the asymmetry of the data: on the original scale, they immediately reveal the varying skewness of the data (casting considerable doubt on the utility of using a single statistic to characterize its skewness), whereas on the square root scale, the data are close to symmetric about their middle--and therefore can succinctly be summarized with a five-number summary, or equivalently a boxplot.  The skewness again varies appreciably on a log scale, showing the logarithm is too "strong" a way to re-express these data.
The generalization of a boxplot to seven-, nine-, and more-number summaries is straightforward to draw.  Tukey calls graphs of the mid-letter statistics "schematic plots."  Today many plots serve a similar purpose, including standbys like Q-Q plots and relative novelties such as "bean plots" and "violin plots."  (Even the lowly histogram can be pressed into service for this purpose.)  Using points from such plots, one can assess asymmetry in a detailed fashion and perform a similar evaluation of ways to re-express the data.
Answer: The mean being less than or greater than the median is a shortcut that often works for determining the direction of skew so long as there are no outliers. In this case, the distribution is negatively skewed but the mean is larger than the median due to the outlier.
Comment: I agree that small datasets like this can make it challenging, but it's perfectly possible to construct continuous distributions which are equally challenging.
Comment: That explains. The books I read didn't mention this at all!
Comment: Hopefully the books at least mentioned how the mean is much less resistant to outliers than the median!
Comment: Whether that counts as negatively skewed depends on how you measure skewness.
Comment: Fair enough. It's a small dataset which makes it especially challenging to judge skewness.  I would guess this example was unfortunately thrown in there just for the reason of having conflicting rules of thumb for determining skew

How to assess skewness from a boxplot?


Differentiating First/Second order logic

Question: I am trying to get a grasp about the mechanicly difference between First order logic (FOL) and Second order logic (SOL). From my understanding objects within them can be divided into these parts

Constants
Variables
Predicates
Functions

At which formula/terms are constructed recursively. My understanding is that FOL allows the quantifiers, $\exists,\forall$, can range over variables, while in SOL it can range over predicates too, is that correct? I don't want to understand it as "ranging over sets" because that is when we go for a set theoretical intepretation of it but I want to understand it mechanicly.
Onto set theory though as it baffles me.
Two simple sentences
$$\forall x\forall y\exists z(x\in z\land y\in z)$$
$$\forall P\forall x(x\in P\lor x\notin P)$$
The former is a FOL statement, the latter a SOL statement. The first is axiom of pairing in ZFC and the latter is an example from wikipedia. If my previous understanding is correct, then how is the latter SOL but not the former, or vice versa? They both talk about objects being in sets that they range over and in ZFC all objects are sets.
A hypothesis I had for it is that the predicate $\in$ is usually seen as binary but you can technically have it as an unary by having it be $\in P$ instead, at which it would range over a form of predicate to be SOL, but then we get the same intepritation for the former as well.
I have tried rewriting it as
$$\forall x\forall y\exists z(P(x,z) \land P(y,z))$$
$$\forall z\forall x(P(x,z)\lor \neg P(x,z))$$
to get rid of the set theoretical view of it, and quite frankly it only makes them look even more the same.
Any clearification on this would be most appriciated!
Comment: "while in SOL it can range over predicates too" is correct.
Comment: @JeanMarie That makes my latter question all the more so, why is it that the second sentence is ranging over predicates but the former is not?
Comment: $∀x∀y∃z(x∈z ∧ y∈z)$ is a formula in FOL set theory.  And also $∀P∀x(x∈P ∨ x∉P)$ is. A correct SOL formula will be $∀P∀x(Px ∨ \lnot Px)$
Comment: In SOL we quantify predicate symbols (i.e. "properties and relations"). In FOL we quantify only individual variables (i.e. "objects"). In FOL set theory, sets are objects, i.e. represented by individual variables and constans.
Comment: See [Second-order and Higher-order Logic](https://plato.stanford.edu/entries/logic-higher-order/).
Answer: Quantifiers don't "range over variables", they range over individuals of the domain. (In a standard set-theoretic semantics, these will be elements of the domain class.) Variables refer to those individuals in formulas. In Second-order Logic, variables can additionally refer to predicates. (In a standard set-theoretic semantics, these will be subsets of the domain class or more generally $n$-ary relations on the domain class.) It may be clearer to separate quantification ranging over individuals from quantification ranging over predicates, and similarly separate variables that refer to individuals from variables that refer to predicates, but this is often left implicit since it is clear whether a variable refers to an individual or a predicate depending on how its used (and it's disallowed to use it in an inconsistent manner).
For a variety of reasons, I don't recommend using set-theoretic notation for second-order logic formulas. I would write your SOL example as: $$\forall P.\forall x.P(x)\lor\neg P(x)$$
This unambiguously places this formula in (at least) second-order logic as first-order logic does not allow variables as names of predicates. ZF(C), on the other hand, is a theory of first-order logic and your original rendition of that formula is indeed a formula of (the first-order theory of) ZF(C).
If you want to use set-theoretic notation rather than logical notation for SOL, then $\in$ is now not an arbitrary relation between any terms. Instead, you can think of it as being "typed", something like ${\in} \subseteq D\times\mathcal{P}D$ where $D$ is the sort of the domain and $\mathcal{P}D$ is the sort of predicates on the domain. This makes something like $P\in P$ and ill-formed formula (while in the first-order theory of ZF(C), it's a completely legitimate formula). Again, I don't recommend using this notation for SOL. The set-theoretic notation, besides being ambiguous, carries a lot of connotations that don't necessarily hold for SOL.
Comment: Your rendition makes it very clear it is second order. So just so I get it straight, in ZFC axioms $\in\subseteq D\times D$ but in the example it would be $\in\subseteq D\times PD$, just that they use both t once as from context, the exact meaning can be salvaged?
Comment: With respect to the first part of your second sentence, yes except $\in$ in the SOL example would not be just some relation symbol like $\in$ is in ZF(C), but part of the syntax of the logic itself like the logical connectives. I'm not saying $\in$ has that sort in that particular example, but that it would be that way in every second-order theory using that notation. This means $D$ is free to be interpreted as anything, e.g $\mathbb{N}$ while the interpretation of the domain for ZF(C) is a model of set theory. The meaning of $\in$ for ZF(C) comes from the axioms, not from the notion of model.
Comment: I don't understand the latter part of your sentence beginning "just that..."
Comment: What I meant with "just that" was that it is in a way "abuse of notation", using the same thing for vastely different concepts in mathematics in a formalized way, but out of linguistic and psychological needs it is ignored for general ease of reading. So $\in$ in both cases are very different relations/predicates, but because they are usually conceptually very close in peoples minds, the two things are symbolized identicly.
Comment: In this case, I think the motivation for using $\in$ in SOL is related to the standard semantics where predicates will be modeled by subsets (or, equivalently, characteristic functions which is more in-line with the logical notation). Relatedly, set theory is essentially an implementation of higher-order logic, so if we were working within set theory we would model those those predicates as subsets (which, of course, is exactly what the standard semantics of SOL is doing). Personally, I think an extremely clear separation between logic and set theory should be maintained.
Comment: I agree which is why I am trying to disentangle them in my head.
Answer: Let's forget the first statement for a while and consider another one:
$$\tag{1} (\forall x)(\forall y)(\exists z)(x \leqslant z \wedge y \leqslant z).$$
Here $x, y, z$ are variables that stand for elements of the universe and $\leqslant$ is a fixed binary relation, which we think of as some partial order. The above is a first order statement, since it only quantifies over first order variables $x, y, z$ - elements of the universe.
That statement also has some meaning for us - it states that every pair in the order has an upper bound. It is about some property of our partial order.
Now back to the original statement:
$$\tag{1'} (\forall x)(\forall y)(\exists z)(x \in z \wedge y \in z).$$
Here again $x, y, z$ are meant for elements of the universe and $\in$ is a binary relation, which we think of as set membership. It is also in the first order logic for the exact same reason as in $(1)$.
I assume there is no problem with understanding why $(1)$ is in first order. The confusion may arise in $(1')$ because of our understanding of the relation $\in$ in ZFC as a membership relation, which implies that we think of $z$ as a set containing elements $x, y$. But formally it's not so; $\in$ is just a binary relation, satisfying some axioms which we would expect from a membership relation. To summarize: the membership quality of $\in$ is a meaning we attach to the relation, which is not reflected in any way in the underlying formalism.
As to your second statement, I would write it differently:
$$(\forall P)(\forall x)( P(x) \vee \neg P(x) ).$$
Here $P$ stand for a subset of the universe and $x$ is an element of the universe. Now the notion of membership is embedded into the logic: $P(x)$ formally means "element $x$ belongs to the set $P$". Since the subset $P$ is quantified over, the statement is in second order logic.
Comment: But what does "subset of the universe" even mean when we remove set theory?
Comment: I understand that the first statement is FOL, it makes perfect sense to me, but with the understanding of second order being quantifiers over predicates I lose how the latter statement is second order but the first one is not. There is something in the translation there that eludes me.
Comment: @ZelosMalum Why would we remove set theory? We always have this set theoretical foundation when speaking of mathematics, like functional analysis, topology, differential geometry and finally - logic. And within set theory we can speak of predicates & first order or second order formulas, define what it means that a formula is satisfied in a model, etc. Sometimes we happen to study set theory itself. But studying some other theory, like the theory of partial orders or some second order theory, only makes us remove the set theory as the object of study, but not as the tool with which we study.
Comment: If you're a bit into computer science, let me make an analogy. Compilers can process every correct source code in a particular programming language. When the compiler itself is written in that programming language, the compiler can even compile it's own source code. But while it's compiling something else, it doesn't mean the compiler isn't there: it's  just not the source of it being compiled. P.S. Please let me know if I completely missed the point you were making. :p
Comment: Yeah that analogy went way past my head.As for removing set theory, if set theory is founded in first order logic, then using set theory to describe first order logic makes it circular. I m interested in logic here as foundation, before set theory has even been constructed with the axioms.
Comment: @ZelosMalum I see. As to my knowledge, second (and higher) order logic by it's nature must be entangled in set theory. So we have to start with first order logic (the only one which doesn't require set theory), then do the set theory and then higher order logic.
Comment: That variables can range over predicates doesn't strike me as needing set theory.


An exercise from Sarason's complex function theory book

Question: Let $f$ be a holomorphic map from the half-plane $Rez>0$ into the open unit disc. Prove that $|f'(z)| \leq \frac{1-|f(z)|^2}{2Rez}$
I think that I must modify the proof of Pick's lemma somehow but I have no clue how.
Answer: Fix $z_0$ with $\operatorname{Re}\,z_0>0$ and we define $$
\phi(z)=\frac{z-z_0}{z+z_0},$$
which maps the right half-plane onto the unit disc $\mathbb{D}$. Let $\alpha =f(z_0)$ and also we define
$$
\varphi (z)=\frac{z-\alpha }{1-\bar{\alpha} z}
$$
for $z\in \mathbb{D}$.
Consider $g(z)=\varphi \circ f\circ \phi^{-1}(z)$, which maps $\mathbb{D}$ into $\mathbb{D}$ with $g(0)=0$. We can apply Schwarz's lemma to see that$$
|g^\prime (0)|=|\varphi ^\prime (\alpha )\cdot f^\prime(z_0)\cdot (\phi^{-1})^\prime (0)|\le 1.$$
This shows that $$
|f^\prime (z_0)|\le \frac{1-|\alpha |^2}{2\operatorname{Re} z_0}.$$


What is an NBA Rodeo Road Trip?

Question: Recently I have heard sports broadcasters referring to the San Antonio Spurs as being on a "Nine Game Rodeo Road Trip", but I'm not sure what that term means or where it came from. The Spurs are on a nine game road trip where they have so far won all of their games.
Does "Rodeo Road Trip" simply mean that they have won every game on their road trip?
Comment: The Chicago Bulls and Chicago Blackhawks go on a Circus trip every fall in mid-November because a circus is occupying the United Center for those two weeks.
Comment: The Lakers and Clippers have weeklong road trip every February because of the Grammys.
Answer: AT&T Center hosts the San Antonio Stock Show & Rodeo.  While this event is happening the Spurs are forced to take an extended series of away games. This is informally known as the "Rodeo Road Trip."

What is an NBA Rodeo Road Trip?


CASE Statement with multiple outcomes - some outcomes overlooked

Question: I have a case statement such as the one below that has multiple outcomes. Unfortunately, due to the first three outcomes being satisfied, the other options are being ignored. Is there some way of the statement considering all outcomes?
 ,CASE WHEN T.T1_HoNOSCA_Score IS NULL THEN 'Missing T1'
    WHEN T.T2_HoNOSCA_Score IS NULL THEN 'Missing T2'
    WHEN T.T1HonosValidity IN ('NULL','Invalid 9','Invalid Null')
    OR T.T2_HonosValidity IN ('NULL','Invalid 9','Invalid Null') THEN 'Invalid Data'
    WHEN T.T1_HoNOSCA_Score IS NULL AND T.T2_HoNOSCA_Score IS NULL THEN 'Missing T1 & T2'
    WHEN T.T1_HoNOSCA_Score IS NULL AND T.T1HonosValidity IN ('NULL','Invalid 9','Invalid    `enter code here`Null')
    OR T.T2_HonosValidity IN ('NULL','Invalid 9','Invalid Null') THEN 'Missing T1 & Invalid Data'
    WHEN T.T2_HoNOSCA_Score IS NULL AND T.T1HonosValidity IN ('NULL','Invalid 9','Invalid Null')
    OR T.T2_HonosValidity IN ('NULL','Invalid 9','Invalid Null') THEN 'Missing T2 & Invalid Data'
    WHEN T.T1_HoNOSCA_Score IS NULL AND T.T2_HoNOSCA_Score IS NULL AND T.T1HonosValidity IN ('NULL','Invalid 9','Invalid Null')
    OR T.T2_HonosValidity IN ('NULL','Invalid 9','Invalid Null') THEN 'Missing T1 & T2 & Invalid Data'
    ELSE NULL END AS Data_Quality_Type

Comment: Please add example data and expected output.
Comment: Change the order of `when..then` clauses so more complex ones come first.
Comment: As soon as the first CASE is satisfied, the others are not even checked. Keep that in mind and re-design your query. Either changing order of clauses - or - using CASEs within the CASE.
Answer: Your CASE statement contains boolean expressions that are not mutually exclusive. Some of these expressions are stronger than others.
A condition X is said to be stronger than a condition Y if X implies Y. In other words, Y is true every time the X is true.
For example, consider two conditions:
T.T2_HoNOSCA_Score IS NULL                                -- Condition 1

and
T.T1_HoNOSCA_Score IS NULL AND T.T2_HoNOSCA_Score IS NULL -- Condition 2

Every time condition 2 is satisfied, condition 1 will be satisfied as well, because condition 1 is AND-ed with some additional criteria to form condition 2. Therefore, condition 2 is stronger than condition 1.
When you have a case statement with non-mutually exclusive conditions like yours, you need to order them from strongest to weakest. Otherwise, your weaker conditions would "shadow" the stronger ones, never letting them to execute.
Answer: you can dissect the case expresssion into a set of 3 individual tests, joining the result as needed.
the example is provided in oracle syntax. however, your dbms will provide similar string formatting functions, otherwise choose the functionally equivalent but less readable version in pure sql.
, RTRIM (
     RTRIM (
         SUBSTR(
                CASE WHEN T.T1_HoNOSCA_Score IS NULL THEN ' Missing T1 &'   ELSE '' END
             || CASE WHEN T.T2_HoNOSCA_Score IS NULL THEN ' Missing T2 &'   ELSE '' END
             || CASE WHEN    T.T1_HonosValidity IN ('NULL','Invalid 9','Invalid Null')
                          OR T.T2_HonosValidity IN ('NULL','Invalid 9','Invalid Null')
                                                     THEN ' Invalid Data &' ELSE '' END
           , 2
         )
       , '&'
     )
  )

sql:
 SUBSTR(
        CASE WHEN T.T1_HoNOSCA_Score IS NULL THEN ' Missing T1 &'   ELSE '' END
     || CASE WHEN T.T2_HoNOSCA_Score IS NULL THEN ' Missing T2 &'   ELSE '' END
     || CASE WHEN    T.T1_HonosValidity IN ('NULL','Invalid 9','Invalid Null')
                  OR T.T2_HonosValidity IN ('NULL','Invalid 9','Invalid Null')
                                             THEN ' Invalid Data &' ELSE '' END
   , 2
   , LENGTH (
            CASE WHEN T.T1_HoNOSCA_Score IS NULL THEN ' Missing T1 &'   ELSE '' END
         || CASE WHEN T.T2_HoNOSCA_Score IS NULL THEN ' Missing T2 &'   ELSE '' END
         || CASE WHEN    T.T1_HonosValidity IN ('NULL','Invalid 9','Invalid Null')
                      OR T.T2_HonosValidity IN ('NULL','Invalid 9','Invalid Null')
                                                 THEN ' Invalid Data &' ELSE '' END
     ) - 3
 )


Best Liquid Layout CSS Framework?

Question: Is there an active/solid cross browser css framework on par with blueprint/yui/960 that supports percent based liquid layouts?
I've seen Emtastic, but it doesn't look like it's been active for about a year.  What do you think about Matthew James Taylor's Liquid Layouts?
Answer: see this http://www.designinfluences.com/fluid960gs/
Answer: Blueprint has a "liquid" plugin. Works very well.  Get it here.
Answer: Centage! is my fluid framework built on less.js. It's not thoroughly tested cross browser yet and is in early Alpha state, but check it out!
Answer: You can try to use foundation
It's just not liquid column design, but also include other common design like grid, form, etc.
Answer: That's the best one I've seen up to now.
The widest (1140px) and compatibile with mobile and tablets
Link: 1140CS
Comment: Checked this out while browsing this page and just letting everyone know not to use this anymore.
"I'm not comfortable with people continuing to use the framework. It was never really a great solution; just an early experiment that a lot of people participated in. It was a one size fits all, desktop first, templated grid system. In short, not how you should make a responsive website."  Taken from their homepage.

Best Liquid Layout CSS Framework?


Related to matrix equations

Question: Let $p$ and $q$ be real numbers such that $x^2+px+q\ \not= \ 0 $ for all real x. Prove that if n is an odd positive integer , then $X^2+pX+qI_n\ \not= \ 0_n$ for real matrices $ X$ of order n×n.
I am not able to show my attempt because I don't have any idea where to start . Thanks for the help.
Answer: Guide:
Suppose $X^2+pX+qI =O$
Since $n$ is odd, it must have a real eigenvalue, multiply it with the corresponding eigenvector to obtain a contradiction. I wll leave the details to you.
Edit:
Since $n$ is odd, then the charactheristic equation, $\det(x I-X)=0$, which is an odd degree polynomial must have a real root, $\lambda$.
That is we can find a real number $\lambda$ such that $\det(\lambda I-X)=0$,
Hence if you consider the linear system, $(\lambda I-X)v=0$,  we must be able to find a non-zero vector $v$ that satisfies the equation. That is we must have such $v$ such that $Xv=\lambda v$.
Now, suppose that we have $X^2+pX+qI=O$, post multiply the equation by $v$ and try to simplify the system.
Comment: where does the question come from? any particular topic that you are studying?
Comment: I looked at your previous posts and realized that you have the concept of Cayley Hamilton, perhaps you might like to think along that line. It's very strange that you learn Cayley Hamilon without knowing about eigenvalues though.
Comment: Actually our sir told us to just accept it as a fact ,But how do i use cayley hamilton theorm for a general n order matrix when i have been given a quadratic equation.
Comment: I can't think of how to use that directly now, but I have tried to avoid using the term "eigen" and tried to explain assuming that you have the concept of determinant and non-trivial solution.
Comment: Can we say for a matrix equation be zero , the polynomial must have $\lambda$ as it's root ?
Comment: hmmm.... i can't understand your question. what matrix equation, which polynomial?
Comment: $\lambda$ is the real value for which det|$\lambda I - A|$ is zero, polynomial equation is  $x^2+px+q$ and the matrix equation is $A^2+pA+qI_n=0$
Comment: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/104524/discussion-between-siong-thye-goh-and-aryan-bansal).

Related to matrix equations