NgIf hide parent and show child

Question: I have a case i want to achieve and I do not know if it is possible. Basically I have something like this.

...long code

       ...long code

The Idea is to only show the child components and hide all the parents for some conditions.
How can I achieve something like this.
Comment: no, that's not possible even without Angular
Comment: maybe you don't need to hide the parent, just the contents of it, something like this `...`
Comment: I see. The only issue is that the code is very long. I can simply copy paste the child below the parent and show hide as the condition. I thought if I can keep the code only one place would be better.
Answer: As @Maximus suggested, you can hide portions of the parent's content instead of the parent itself.
So something like this

        ...long code

       ...long code

If you are going this route, I think the better way is to just remove the parent-child relationship and just have 2 divs.

        ...long code

       ...long code

I think it is much simpler. Hope this helps.
Comment: It drives us towards code duplicity. Is there any better way (I mean angular directive)?
Comment: @MCFreddie777 can you elaborate more on your use case?
Answer: You may be able to accomplish this by using ng-template outlets
<parent *ngIf="condition else child">
    <ng-container *ngTemplateOutlet="child"></ng-container>
</parent>
<ng-template #child>
    ...child contents
</ng-template>

NgIf hide parent and show child


YUM Config file for a repo in local drive

Question: I have a repo in my local computer .
I was told to create a config file like
<code>[Norf-repo]
name="Norf repo"
baseurl=http://location
enabled=1
</code>
But since it is a local package  , I cant probably look at having some local address instaed of http:// ?
In the latter case I need APACHE which needs to be configured /
Answer: Your baseurl is wrong
<code>baseurl=file:///path/to/repo/
</code>


Custom display for text field

Question: I am new at Drupal, so I apologize if I am missing something obvious.
I have a content type that has some fields. This field is text and I want to have a custom "Field Display" for it.
I can do the JavaScript JQuery stuff to have a div expandable with a click, etc, but I don't know how to make that happen.
How do I change the field display for a field so that I can customize its look (with css or some elements or javascript). I don't want to put this stuff in the content of the field, as I don't want the content author to have to put that in every time.
Thanks.
Comment: So what is your question? Please try to be specific.
Answer:
You can find the CSS class or id by installing firebug in your Firefox installation. It let's you point and click on every area of the page.
If this is not enoug install the Theme Developer module (http://drupal.org/project/devel_themer). It helps you to find the appropriate theme merhods and template files to tweak the output to your needs.

If this is all strange stuff, make yourself familiar with basics about drupal theming. This is a good starting point: http://drupal.org/documentation/theme

Custom display for text field


MatLab - accessing variables after a function is done with them

Question: I'm new to MatLab and having difficulties using the results of my functions.
My program loads a .mat file as an object, and then for each variable in the .mat, it runs an analysis. The actual analysis is done by a function called in the for loop. The results of the analysis are stored by the function in an array - or they should be! As follows:
function main()
    object = matfile('data.mat')
    vars = (fieldnames(object))
    resultarray = zeros(length(vars))
    for index = 1:length(vars)
        var = vars(index)
        x = object.var
        resultarray = analysis(x, index)
    end
end

function resultarray = analysis(x, index)
    %does stuff to x
    resultarray(index) = x
    disp(resultarray(index))
end

The problem is - none of my variables are visible! The workspace is empty. The disp() function prints the value I assigned so I know the function is working, but how do I access resultarray after the program has finished? I have tried declaring it as a global at the beginning of main(), which doesn't seem to do anything. My array should be passed back to main() - how do I get it to save so that I can actually use the output of my function after the program has terminated?
Thanks in advance for your help.
edit - I'm aware that the scope of main() is different, but if I get rid of it I am told that "function definitions are not permitted in this context." It looks like for some reason I can't have a script and some functions which the script uses in the same file.
Comment: The Worskpace has a different scope than the `main` function. That's why you don't see any variables. Remove `function main()`.
Comment: If I do that, the program will not execute, since apparently you can't have a script followed by function definitions in a matlab file. So I guess what I'm really asking is how to get variables from a function workspace into a form that is persistent.
Comment: You pass them back as return values from the function.
Comment: @Nate What you say is correct. If you remove the function header you must save the script and the `analysis` function in separate files. If want to keep the `main` function, you can add an output parameter like this: `function[resultarray] = main()` (see the [documentation](https://mathworks.com/help/matlab/ref/function.html)).
Comment: As a side note, including functions in scripts is allowed in MATLAB R2016b or later.
Answer: If you wish to keep main as a function with this syntax, then you should edit your code as follows (return resultarray from main):
function resultarray = main()
    object = matfile('data.mat')
    vars = (fieldnames(object))
    resultarray = zeros(length(vars))
    for index = 1:length(vars)
        var = vars(index)
        x = object.var
        resultarray = analysis(x, index)
    end
end

function resultarray = analysis(x, index)
    %does stuff to x
    resultarray(index) = x
    disp(resultarray(index))
end

The problem is that the workspace has different scope than the function you have defined.
Otherwise you can create a script called, let's say main.m:
object = matfile('data.mat')
vars = (fieldnames(object))
resultarray = zeros(length(vars))
for index = 1:length(vars)
    var = vars(index)
    x = object.var
    resultarray = analysis(x, index)
end

and create a separate file called analysis.m, which will contain the following code:
function resultarray = analysis(x, index)
    %does stuff to x
    resultarray(index) = x
end


Corrective action for file security after Windows server rename

Question: I have renamed a Windows Server using the Control Panel feature. This worked fine at first. Today I noticed that I was unable to rename a certain file that I always was able to rename before. This file was a SQL Server database file. The SQL Server service was successfully able to use the file. But even after shutting down the server I got the message:

You require permission from Administrator to make changes to this file

So the file clearly was not locked by a running program.
Reviewing the security settings in Windows Explorer I found out the following:

There was a noticable delay when resolving the SID's to user names
The SQL Server user still had the old server name in its name. However that seems to be harmless because the user name is an uninterpreted string (right?)
I saw nothing suspicious (like unresolved SID's or the old server name as the domain part of some user name)
Even giving Full Control to Everyone did not allow me to rename the file
Changing ownership to Administrators (and I am a member of that group) restored access

I ran SysInternals AccessEnum to enumerate the drive that the file in question was on. The output showed a few "???" markers.
I do not fully understand why I lost access to that file. Some permissions must have been lost when renaming the server. What happened?
Also, do I need to fix the server somehow after renaming it? I worry that there are a lot of latent permission issues now that I will only discover over time.
Comment: 1. Renaming the server should have no bearing on file and folder permissions. 2. The statement `I ran SysInternals AccessEnum to enumerate the drive that the file in question was on. The output showed a few "???" markers.` is meaningless because you don't have a comparative report from before the rename. 3. After renaming a server that is running SQL Server you also need to do this: http://strictlysql.blogspot.com/2010/03/changing-server-name.html
Answer: You didn't "lose" any permissions when renaming the server. Security principals are referenced by their SID in ACLs. The SID does not change when you rename a computer. Even if it did, that you'll only impact local users (but it doesn't). If there is a noticeable delay in translating security principals from SID to display name, then you've got a connectivity or AD problem somewhere.
The message You require permission from Administrator to make changes to this file is a UAC message that you are prompted with when modifying files in a protected file system location. Program Files is one such location, which is where your database files are, I am assuming. This is normal.
Comment: Thank you. First I want to clarify that I'm an "accidental" server admin. Not professional.; I have no DC/AD. This is a standalone server. I'll investigate this angle, though, and find out what caused the delay.; UAC: Yes, this was indeed turned on! Surprise. Any idea why the message disappeared after taking ownership? The DB files are on a separate drive. I do not fully understand the ACLs on it. I basically added an entry every time something needed access which is: me, SQL Server and IIS.
Comment: http://blogs.msdn.com/b/brian_dewey/archive/2004/01/20/60902.aspx http://technet.microsoft.com/en-us/library/bb727008.aspx http://en.wikipedia.org/wiki/User_Account_Control http://technet.microsoft.com/en-us/library/cc731416(v=ws.10).aspx
Comment: Thanks again. I believe the issue has been explained now: a) a server rename is highly likely not to disrupt permissions because they are based on SIDs. b) UAC caused the message. c) I probably did not have access to the file even before the rename (or UAC made me believe that I do not have access), and I miscorrelated the two events to due proximity in time.
Comment: That sounds about right to me :)


How to design a MongoDB for blog?

Question: I'm building a simple blog system for multiple users, they can access data by userID, username and nodeID(blog).
In RDBMS, normally we will have user/table/ownership tables. In mongoDB, some suggest to put them in a single users collection. However, as far as i know, it could be very slow if users want to access specific nodeID, since mongoDB may go through every document. Indexing will significantly drop the create speed, in my case, that means both createUser() and createNode(), right?
Therefore, is there any "Best Practices" we can follow?
Thanks.
Comment: *"Indexing will significantly drop the create speed"* – how often are you inserting new data that this is a concern? "Significantly" still just means a few milliseconds most likely.
Comment: Possible duplicate of [mongodb schema design for blogs](http://stackoverflow.com/questions/5224811/mongodb-schema-design-for-blogs)
Comment: There are a few posts that you can refer for that. Here I'm listing a few :

http://stackoverflow.com/questions/5224811/mongodb-schema-design-for-blogs

https://www.mongodb.com/presentations/mongodb-melbourne-2012/schema-design-example

https://docs.mongodb.org/ecosystem/use-cases/storing-comments/

http://blog.mongodb.org/post/87200945828/6-rules-of-thumb-for-mongodb-schema-design-part-1
Comment: @deceze: few milliseconds at worst :)
Comment: checkout this course that has a POC creating a mongodb for blog https://university.mongodb.com/courses/M101JS/about
Comment: Great! I'm going to read them 1 by 1. In fact I didn't find much official performance benchmark, therefore tutorials are the main sources. Some says _"If you use `ensureIndex()` for a field, you have half performance due to its mechanism, so just use `_id` to `find`"_. Well I have to say that's really confusing. Perhaps people exaggerate that performance issue.
Answer: Three Collections Inside the DB, Namely,
"Users",
"UserPosts",
"UserComments"

Users Collection's Field could be
"name",
"age",
"occupation",
"profileImage",
"numberOfPosts",
"birthdate",
"joiningDate",
"session"

etc.
UserPosts Collection's Field could be
    "Id",
    "revisionId",
    "author",
    "type",
    "language",
    "userId",
    "status",
    "title",
    "tags",
    "content"

etc.
UserComments Collection's Field could be
    "Id",
    "userPostId",
    "author",
    "type",
    "language",
    "userId",
    "status",
    "comment",

etc.
User Comment will be maintained by UserPostId Field It contains.
Comment: Thanks! That looks exactly what we did in RDBMS, isn't it? Do you think it's necessary to use `db.UserPosts.ensureIndex({author:1})` and  `db.UserComments.ensureIndex({author:1, userPostId:1})` for better performance(or just worse)?
Comment: No You did not need to do that.

How to design a MongoDB for blog?


Django Many to many how to give input to 3rd table

Question: class Author(models.Model):
    name = models.CharField(max_length = 100)
    def __str__(self):
        return self.name

class Book(models.Model):
    title = models.CharField(max_length = 100)
    authors = models.ManyToManyField(Author)
    def __str__(self):
        return self.title

    In [5]: Author.objects.all()
Out[5]: <QuerySet [<Author: Shanmukh>, <Author: Shyam>, <Author: sai>, <Author: VICKYS>, <Author: Himayu>, <Author: Himanya>, <Author: Srinivas>, <Author: LASKARATOYIBA>, <Author: ISI>, <Author: JAMI>]>

please help in solving this i dont understand how do i give data to 3rd table which is a combination of id bookid and authorid
Comment: what third table you mean, is it intermediate table??
Answer: If what you want is to add an Author to a Book. You can use this:
book.authors.add(author)

See this in the official docs


Redis-stack docker customize

Question: I want to customize the redis-stack using Dockerfile by adding config file but not work yet
FROM redis/redis-stack:latest

ENV PORT=6379
ENV RIPORT=8001

WORKDIR /db
COPY redis.conf ./redis-stack.conf

EXPOSE 6379 8001

CMD [ "redis-stack-server", "redis-stack.conf" ]

I can not access to redis insight port
Comment: Is there a reason you are not referencing the file you copied `redis-stack.conf`? Otherwise it works on my configuration. What does not work exactly, do you see logs in the container or can't you connect to it?
Comment: My mistake, I updated the Dockerfile info. The issue is unable to connect the Redis Insight (I used K8s and mapping `8001` with a specific port)
Answer: It seems that you are trying to use the redis-stack image to run both Redis Stack server and RedisInsight, but you are not exposing the correct port for RedisInsight. The default port for RedisInsight is 8001, but you are exposing 8001 as the port for Redis Stack server. This may cause a conflict or a connection error when you try to access RedisInsight.
To fix this, you need to change the port mapping in your Dockerfile, so that Redis Stack server uses 6379 and RedisInsight uses 8001. For example, you can do something like this:
FROM redis/redis-stack:latest

ENV PORT=6379
ENV RIPORT=8001

WORKDIR /db
COPY redis.conf ./redis-stack.conf

EXPOSE 6379 8001

CMD [ "redis-stack-server", "redis-stack.conf", "--port", "$PORT", "--riport", "$RIPORT" ]

Actually change:
CMD [ "redis-stack-server", "redis-stack.conf" ]

To:
CMD [ "redis-stack-server", "redis-stack.conf", "--port", "$PORT", "--riport", "$RIPORT" ]

This way, you can access Redis Stack server on localhost:6379 and RedisInsight on localhost:8001.

Redis-stack docker customize


Zip file with .csv extention lost somewhere in filesystem

Question: The file is also locked with winzip and I cant remember the name or directory, I hid it in a very obscure directory. Could be in the windows system files could be in a program directory file. I did a search for all .CSV files I have 4-5K to go through. Any suggestions on how this could be done?
I was opening up files in batches by highlighting a bunch that pressing edit with notepad plus plus. Than going  through each one. I know once the file is opened in notepad plus it will not show any words. It is pictures. I own an eCommerce site and I have my master copies that I bought $X,XXX and did not want to take any chances in them be found and resold by other people on my network. Any suggestions?
Answer: Opening any zip file in a hex editor suggests that every zip file starts with a data of PK. We can use it in our favour. :)
Download this software: EditPad Pro
What this software does is, it recurses through the whole filesystem starting from a specified base folder to search for any string residing in any of the child files, they maybe Text or Binary, it treats them the same, thus giving accurate results.
In our case, it's a regex: ^PK
When you'll execute this search, the software will return all the files that start with data PK, make sure you do a casesensitive search.
Comment: Awesome!! I have been trying to find this file for months off an on. Just tried it on a small scale on my laptop and it found my test file! now going to try on my server..
Comment: I think this will work as long as i start from the right start folder. What would check every single directory and file on the whole computer? I have no idea were it is.To bad this site didnt have a donate to user button!!
Comment: This software would check just anything in anynumber of folders. Just choose your base folder, then checkmark the option `Recurse through Subfolders`, all your Subfolders and their subfolders and their subfolders, so on.. will be checked for the string to exist. @Original-newbie
Comment: it wont let me says Vote Up requires 15 reputation
Comment: Choosing the right answer is different than Voting Up or Down. There must be an outlined Checkmark right under voting options. It says, **`click to set this answer as your accepted answer; click again to toggle`**, that's where you've to click to choose a correct answer. @Original-newbie
Comment: Got it :) This software is great but it will abort its search if it comes across a file in use by another program. You know anyway of fixing that? It goes for like 10 minutes finds a file in use by another program and than aborts the search
Comment: This is not a software issue, rather it's precaution measure. If it read a file already locked by any other program, it would be against OS policies and could lead to a system deadlock or failure of both the programs. You can ignore this just by closing all the other programs that could be using your files. :/ @Original-newbie
Comment: Yea I fured that but wasnt 100% sure. Anyhow thanks for the help. This will def give me a better chance on finding it. Wish I would have asked months ago. Just never did because i searched so long for a program that does what your program does. They really should put a donate to user button on this site.
Comment: It's ok, I'm out of a job, so if you ever need to hire a developer, consultant or a website deigner you can check me out. :) @Original-newbie
Comment: or if you just wanna donate something outta goodwill, then gimme your e-mail, I'll mail you my paypal ID. @Original-newbie
Comment: Sy fell asleep, how can i message you here on the site? I dont have enough reputation yet to chat with you (this is what the site told me) but if you know a way let me know. I prolly have work for you if you want it.
Comment: I meant, gimme your email address, and I'll mail you. haha :P @Original-newbie
Comment: i cant post my email on here..post urs :) n ill email u :)
Comment: got it...ill email u in a bit


Reset View result counter after changing page (manually or with Twig)

Question: Drupal 8
I have a View that uses the View result counter starting at '0'. It works great, except for the fact that when you change to Next page the counter doesn't start off at '0' again, but rather continues on.
I tried using Twig modulus to get a circular-list (always reset back to 0), the reason I use 10 is because my pager displays 10 items.
{{ counter % 10 }}

It doesn't work, it always prints 0 for some reason. But if I do {{ 11 % 7 }} it prints the correct result which is '4'.
Does anyone know either of these:

Can I force view to restart counter at '0' when it goes to other pages int he pager?
Why is Twig not printing the proper math result of {{ counter % 10}} ? (Keep in mind that doing things like {{ counter + 1 }} don't work either. For some reason it only works when you use only numbers like {{ 1 + 3 }}  )

Thanks.
Answer: It doesn't work because counter is actually an object with the value as a property, that's done to properly handle markup or special characters and preventing them from being escaped multiple times.
Depending on what template you're overriding and where, you could possibly do this in twig, especially if you are where you are loop over the rows already, although that might be a bit complicated.
My/the backend developer approach would be to make your own counter views field/plugin that doesn't consider the pager. This logic happens in \Drupal\views\Plugin\views\field\Counter::getValue(). So you can copy this  class into a custom module, rename to NoPagerCounter or so, and change the annotation to @ViewsField("no_pager_counter"). Then you remove the pager related part in the getValue(). Now you just need to implement hook_views_data() and define this as a field, just like views_views_data does with the counter:
  $data['views']['no_pager_counter'] = array(
    'title' => t('View result counter (no pager)'),
    'help' => t('Displays the actual position of the view result'),
    'field' => array(
      'id' => 'no_pager_counter',
    ),
  );

(Possibly with a better title/help, I just switched the ids)
Another variant of that would be to add an option for this to the existing class and provide a core patch/feature request for this. If others agree that it is useful then it might eventually get committed and you don't need to maintain custom code, but you will have to maintain the patch until then.
Comment: It's an excellent option (upvoting), though I ended up removing the Counter field and using preprocess_views_view_field template hook and accessing row->index. I'll be posting the answer with the code in case anyone can use it.


How to include in a regression two factors where one level of one factor is necessarily nested with one level of another factor?

Question: I've got a situation where I have a series of individuals who have two factors describing their health.  Factor A has 3 levels while factor B has 4 levels.  Biologically, level 1 of factor A appears if and only if factor B is level 1.  Therefore, I have data structured like this:
ID   Factor A  Factor B   Score
1      a        alpha       0.1
2      a        alpha       0.2
3      b        beta        0.3
4      b        gamma       0.4
5      b        delta       0.5
6      c        beta        0.6
7      c        gamma       0.7
8      c        delta       0.8

I'm interested in studying the effects of both factors, but I'm struggling with how to properly code this.  Giving each factor their own full set of dummy codes is rank deficient and leaving out a level of either factor creates a model with impossible combinations (ie level a ONLY occurs with level alpha, and vice versa).  How could I code these fixed effects so that I can investigate the impact of both factors on our score?  Additionally, how would I interpret this coding scheme?
EDIT:  To give some further context on how this happens, Factor A is series of related diseases (each phenotypically similar, but genetically different) while Factor B is severity of that diseased state.  So a is the control group while alpha is healthy severity.  These two occur contemporaneously by necessity (ie a healthy severity must be a control while a control can be nothing but healthy).
Comment: You can try the approach here:  https://stats.stackexchange.com/questions/372257/how-do-you-deal-with-nested-variables-in-a-regression-model
Answer: After some pondering, I have an answer to my own question (to which I welcome feedback).  I think the most straight-forward way to handle this is to create a new factor that is a cross-combination of the two factors of interest.  And so, the data would look like this:
ID   Factor A  Factor B   Score    Cross-Factor
1      a        alpha       0.1       a-alpha
2      a        alpha       0.2       a-alpha
3      b        beta        0.3       b-beta
4      b        gamma       0.4       b-gamma
5      b        delta       0.5       b-delta
6      c        beta        0.6       c-beta
7      c        gamma       0.7       c-gamma
8      c        delta       0.8       c-delta

The model would then include a single factor with 7 levels.  I can interpret the factor relative to the a-alpha level using contrasts to extract the change from baseline to whatever combination of the cross-factor I'm interested in, or between means of other level comparisons.  In fact, I could set up the following contrast matrix using the method outlined on the UCLA page, as one example of a contrast matrix.
Original Matrix
     [,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,]    1    3    3    1    0    0    0
[2,]    0   -1    0    0    0    0    1
[3,]    0   -1    0    0    1    0   -1
[4,]    0   -1    0    0   -1    0    0
[5,]    0    0   -1    0    0    0    1
[6,]    0    0   -1    0    0    1   -1
[7,]    0    0   -1    1    0   -1    0

If this matrix is transposed, solved, and the first column removed to create a contrast matrix, the resulting coefficients would be the following comparisons:

Intercept is the baseline mean value (a-alpha)
Coefficient 1: Difference between baseline and average of all severity levels of b
Coefficient 2: Difference between baseline and average of all severity levels of c
Coefficient 3: Difference between baseline and the most severe form of c (c-delta)
Coefficient 4: Difference between the moderate and most severe forms of b
Coefficient 5: Difference between the moderate and most severe forms of c
Coefficient 6: Difference between mean of both mild forms and the mean of the moderate forms.
Comment: Shamelessly accepting my own answer, but will consider both feedback and other answers if they appear.


Additional time stats in football

Question: Are there any statistics about the additional time that European referees give at the end of both the first and second half of a football game?
I mean for example ,what is the percentage of 1' added time in first half, it must be pretty high! What is the percentage of 3' or 4' added time in second half etc...
Comment: I kept some stats during the first leg of the EURO 2016 taking place these days at France.And here are the results:
In 36 matches 56% of them the referee gave 1' of added time for the first half,36% gave 0 minutes and 8% of them ,the added time for the first half was 2'.
As for the second half , 61%-3' , 17%-5+ , 14%-4' , 8%-2'
Answer: After a long search finally found it. Statsbomb Article clearly explain the extra time minute percentage in European 5 top leagues.
These two picture obtained from Statsbomb website clearly shows the percentage of time added.

I am not a original author of these two picture and are obtained from statsbomb.com and apparently were made with the data from Opta.

Percentage time added in first half:

Percentage time added in second half:

Additional time stats in football


integrating $\displaystyle\int_{\gamma}\frac{1+(-iz-2)^9}{16-(-iz-2)^2}\,dz$

Question: $$\int_{\gamma}\frac{1+(-iz-2)^9}{16-(-iz-2)^2}\,dz$$
Where $\gamma$ is a half circle entered at $2i$ of radius $2$ connection $0$ to $4i$
$$\int_{\gamma}\frac{1+(-iz-2)^9}{16-(-iz-2)^2}\,dz=\int_{\gamma}\frac{1+(-iz-2)^9}{16-(iz+2)^2}\,dz$$
To find points where the function is not analytic:
$$16-(iz+2)^2=0\iff 16-(-z^2+4iz+4)=0\iff z^2-4iz+12=0$$
So $z=\dfrac{4i\pm\sqrt{-16-48}}{2}=\dfrac{4i\pm 8i}{2}$
$z_1=6i$ and $z_2=-2i$
So we get
$$f'(2i)=\frac{-9i(-iz-2)^8(z-6i)+1+(-iz-2)^9}{(z-6i)^2}=-\frac{1}{16}$$
Is it correct?
Answer: You might want to check again your calculation when you plug in $2i$, but this is basically how you solve. Don't forget to multiply by $2\pi i$If you had the pole $2i$ inside the domain you would get  that $$I=2\pi i \frac{-72\cdot4^8+1+4^9}{-64}$$
But since there are no poles the integral is 0 due to Cauchy theorem since no poles are inside the domain of integration.
Comment: Sec, $6i$ and $-2i$ are not in the $\gamma$
Comment: you are right. Il edit


Xamarin iOS Storyboard having rendering error NullReferenceException

Question: When opening storyboard recently, the ViewController in the Storyboard will have problem rendering. It is showing NullReferenceException.

What can be the problem?
Answer: Found out that we need to disable the rendering of screen in UI Designer (Recent version of Xamarin will add the screen into Custom Components too).
To turn off the rendering, we need to set the DesignTimeVisible flag to false.
<code>[System.ComponentModel.DesignTimeVisible(false)]
public partial class ViewController : UIViewController
</code>
I have also written more details in my blog HERE.


But how can I calculate the coordinates of a point $Q$ wich lies on $\frac13$ of line $PD$ with $P(2,3)$ and $D(4,-8)$?

Question: To calculate the middle of a line you can just average the points: $x = \dfrac{x_1 + x_2}{2}$ and $y = \dfrac{y_1 + y_2}{2}$
But how can I calculate the coordinates of a point $Q$ wich lies on $\frac13$ of line $PD$ with $P(2,3)$ and $D(4,-8)$?
The next technic does not work is this case:
Answer: The section formula gives a formula for a point $Q$ between $P = (x_1, y_1)$ and $D = (x_2, y_2)$ such that $\frac{PQ}{QD} = \frac{m}{n}$ as:
$$Q = \left(\frac{mx_2 + nx_1}{m+n}, \frac{my_2 + ny_1}{m+n}\right)$$
so in our case we have $\frac{PQ}{QD} = \frac12$ so
$$Q = \left(\frac{1\cdot 4 + 2\cdot 2}{1+2}, \frac{1\cdot (-8) + 2\cdot 3}{1+2}\right) = \left(\frac83, -\frac23\right)$$
Comment: @WinstonCherf True, if $PQ$ is $\frac13$ of $PD$, then $\frac{PQ}{QD} = \frac12$. Fixed now.
Comment: The answer should be (8/3,-2/3)..
Answer: It's simply, in  terms of vectors:
$$Q=P+\frac13\overrightarrow{PD}$$
or in terms of barycentres:
$$Q=\frac23P+\frac13D.$$
Answer: $$x=x_1+\lambda(x_2-x_1),~y=y_1+\lambda(y_2-y_1).$$


GPO and Security Groups in multiple domain

Question: I have 2 forests, each with one domain with a bidirectional trust.
I have created security groups in forest A, to access folders, where I have added both users from forest A and B, the accesses are working for every user of both forest.
I have created a gpo in order to automatically map the drives. The policy has been created and applied to forest A with item level targeting to the different security groups.
The policy works for all users of forest A, but not for users of forest B, the drives are not mapped.
How can I let the policy to be applied also on forest/domain B ? Is it possible ?
I have even tried to recreate the same gpo on domain B but there I cannot add the security groups from domain A, but under level targeting-> locations I see only one domain, not both.
I hope my issue is easy to understand :)
Thanks
Comment: Group Policy does not apply to accounts in a different domain.
Comment: I believe at a minimum the following policy would need to be enabled: System > Group Policy > Allow cross-forest user policy and roaming user profiles
Comment: @GregAskew the policy you mention has to be enabled on both domains, right ?
Comment: @chart: I haven't used it so I'm not sure. I suspect this is for users that may be on a system in another forest to apply user policies from their home/account forest. My experience has been most people make a copy of a GPO in each forest/domain where it's needed though.
Answer: As @Semicolon said, Group Policys do not apply to accounts in a different domains. You need to create a GPO in both domains. If the group in Domain B does not show up in the GPO editor, triple check your Domain trust and that ouy can actually use both groups in both domains.


How do I link in functions from a .cpp source file that also has a 'main'?

Question: I want to use some functions from a .cpp source file that has a main function in my .cpp source file.  (I'm building with make and gcc.)
Here's the rule from my Makefile:
$(CXX) $(CXXFLAGS) $(INCLUDES) $(SRCS) $(LIBS) -o $@

And here's the output (with some names changed to prevent distraction):
$ make foo
g++ -g -Wall -m32 -Ilinux/include foo.cpp bar.cpp -o foo
/tmp/ccJvCgT3.o: In function `main':
/home/dspitzer/stuff/bar.cpp:758: multiple definition of `main'
/tmp/ccUBab2r.o:/home/dspitzer/stuff/foo.cpp:68: first defined here
collect2: ld returned 1 exit status
make: *** [foo] Error 1

How do I indicate to gcc that I want to use the main from foo.cpp?
Update: I should have added that "bar.cpp" is "someone else's" code, and has it's own reason for a main.  (It sounds like I should work with that someone else to have him split the shared functions into a separate file.)
Answer: what you could do is wrap each main() function in an #ifdef block, then use the command line to define the symbol which will cause the relevant main to be used.
#ifdef USE_MAIN1
int main(void)
{

}
#endif

Then ensure the gcc command line gets something like this added to it
-DUSE_MAIN1

Or just restructure your code!
Comment: If he can modify the code to put in a compiler macro, then he can modify the code to split off the functions he wants into a separate file and let the linker do its job. That way he doesn't clutter his own code base with an unwanted `main` or pollute the other guy's code with a meaningless `#ifndef`.
Comment: The answer was written before the OP indicated modifications were not possible. I agree it's not ideal, but it answered the question of how to compile and link two files which define the same function.
Comment: I'm going to accept this answer because it allows me to solve the problem "quick and dirty" now before working with the other engineer later to solve it correctly.
Answer: It's not about which main to use as your "main", because you won't even get that far.
You can't have redefinitions of functions, it breaks the One Definition Rule. In the same way you can't do:
void foo(void)
{
    // number one
}

void foo(void)
{
    // number two
}

// two foo's? ill-formed.

You can't try to compile multiple main's. You'll need to delete the other ones.
Answer: The simplest would be to delete the second main(...){ ...}, and keep the rest of the functions. This solves the problem easily
Answer:
It sounds like I should work with that someone else to have him split the shared functions into a separate file

Exactly, thats the best option. If you both need seperate mains for testing, different products or other reasons, factor the commonly used code and the mains out in seperate files and only use the one you need according to some build setting.


My dependent variable is classified in categories ,which regression model to use

Question: My dependent variable is classified in categories as 5-10, 10-15 . Which is the best regression model for this kind of analysis.my dependent variable  asks the participant of the survey to mark the percentage of turnover due to innovations and the options are (1)less than 1% (2) 1%-5% (3)5%-15% (4) 15%-30% and(5) above 30% . Now please please help me to find the correct regression model, should I dummy code them and use them in linear regression or I should dummy code them and use for multinomial. my independent variables are all in likert scale. please help
Comment: The question is quite unclear to me. Try adding details regarding the following - - What are these dependent variables representing - are they just random names or is there some ordinality to them? - What is the range of this variable? - Is the dataset balanced if they are classes? - Any kind of special cases like large dataset, high cardinality of features etc? Depending on these questions the answers and best model will change.
Comment: If you have only two levels in the dependent variable then why should it follow multinomial instead of binomial?
Comment: My dependent variable is classified in categories as 5-10, 10-15 . Which is the best regression model for this kind of analysis.my dependent variable asks the participant of the survey to mark the percentage of turnover due to innovations and the options are (1)less than 1% (2) 1%-5% (3)5%-15% (4) 15%-30% and(5) above 30% . Now please please help me to find the correct regression model, should I dummy code them and use them in linear regression or I should dummy code them and use for multinomial. my independent variables are all in likert scale. please help
Comment: One option could be linear regression with maximum likelihood for an *interval censored response*
Answer: For the dependent variable, I would start with ordinal logistic regression and see if the assumptions are met. There are various sorts of ordinal logistic, but the most common (and the place I'd start) is proportional odds logistic.
Likert scaled IVs are interesting. There's no common method, but I've sometimes used optimal scaling with some good results.
All then above is quite general - it may not be good with your particular data set. You might want to hire a consultant.


Java on Linux unable to read process inputstream

Question: I'm spawning a process using ProcessBuilder in Java and trying to read its output:
public static void main(String... args) throws IOException, InterruptedException {

    ProcessBuilder builder = new ProcessBuilder("test.exe");
    Process process = builder.start();

    InputStream stdout = process.getInputStream();
    final BufferedReader reader = new BufferedReader(new InputStreamReader(stdout));
    final List<String> queue = new ArrayList<String>();

    Thread ioThread = new Thread() {
        public void run() {
            System.out.println("STARTED THREAD");
            String line = null;
            try {
                while ((line = reader.readLine()) != null) {
                    System.out.println("ADD: " + line);
                    queue.add(line);
                    Thread.yield();
                }
            } catch (IOException exception) {
                System.err.println("Fatal Error: " + exception.getMessage());
            }
        }
    };
    ioThread.start();

    Thread.sleep(10000);
    System.out.println("GOT: " + queue);
}

This works perfectly fine on my Windows machine, and also on a local Linux installation.
On my Linux VM's (DigitalOcean and Linode), it does not work, however, meaning that the process gets started, but the running thread is unable to add a single line to the queue (after waiting ten seconds in the main program, queue is empty whereas in Windows, the queue contains the read lines).
Thinks I've tried so far:

redirecting the error stream to the output stream (even although I'm sure the test program is outputting lines on STDOUT
using stdbuf with -oL and -eL... doesn't work
trying to read byte by byte manually instead of using BufferedReader, same issue
converting thread to a FutureTask
switching between OpenJDK and Oracle VM

It definitely works in Windows and on some Linux machines.
Answer: It turned out to be a buffering issue after all: one stdbuf couldn't fix in this case.
Using a pseudo terminal with script did the trick, however, using:
ProcessBuilder builder = new ProcessBuilder();
builder.command().add("script");
builder.command().add("-c");
builder.command().add(command);
builder.command().add("-f");
builder.command().add("-q");


Find the perpendicular line to the line parallel to axis

Question: I see the solution but, can't explain mathematically.
Given the triangle ABC with the verticec A(3;1), B(-2;0), C(8;-8). Determinate the intersection point of the median AM and the line l if l perpendicular AM and C€l.
M is middle point on BC.
M(3;-4)
The equation for AM is:
(x-x1)(y2-y1)-(x2-x1)(y-y1)=0
(x-3)(-4-1)-(3-3)(y-1)=0
AM:x=3
l: y=mx+b
y=0.x-8
l: y=-8
Answer: There's no need to do any further algebra. The line $AM$ ($x = 3$) and the line $\ell$ ($y = -8$) intersect at the point $(3, -8)$.


What are "Benson Chords"?

Question: George Benson was a jazz guitarist well before he became known as mainly an R&B vocalist and guitarist.   His guitar playing style incorporates distinctive chords sometimes called "Benson Chords" or "Benson Shapes"
What are the templates for Benson Shapes?
Comment: Hi,  please post the citatations for this chord name.  Are you sure that none of the biographical material explains what the chords are.
Comment: The presence of answers elsewhere (e.g., in bibliographic material) is not a reason to avoid posting a question here that hasn't yet been asked on this site.
Answer: Don Latarski, in his (highly recommended) book Chord Embellishments for Guitar defines Benson Shapes as:

I don't even know Don Latarski but if you think this is useful, check out his other chord embellishments and support him.
Answer: I don't think that the term "Benson chords" is actually used or refers to anything special (obviously, Benson didn't "invent" any new chords). I've found one single reference that refers to "Benson shapes", but that's just (minor or major) thirds with the highest note doubled one octave lower, so I wouldn't say they are anything special or anything that is very idiosyncratic to Benson's playing style. A citation where and in which context you found those terms would be helpful.
Answer: My researching suggests
minor 9th,   or a  detailed book explaining his styles,
Comment: While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference.  Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/50479)
Comment: Comment would have been better, but I do realise that it's a google sort of question.
Comment: @Shevliaskovic that's why I physically typed "minor 9th"  there :-)

What are "Benson Chords"?


SET LANGUAGE in SQL-Prozedure

Question: I have tried to use "SET LANGUAGE Italian" in MSSQL Procedure in order to get the month name on Italian.
However stored procedure after executing does not return the query result. In case SET LANGUAGE is not used, the query result is displayed as usually.
<code>CREATE PROCEDURE language
AS
BEGIN
SET LANGUAGE Italian;

...
SET query ='SELECT ....'
EXEC (query)

END
</code>
Comment: This is something your presentation layer should take care of. Let your DB return a typed date and do the formatting externally.
Comment: I found the other way - using FORMAT(@thedate, 'dddd', 'it-it') within SELECT statement you can get the day of the week on Italian.
Comment: Dana, I know this, but the approach is wrong... Just imagine, your project is really great and some day you are asked to use this in USA, Russia, Germany, China... What about the output? The Database should return typed data, while the presentation layer (a GUI, a report engine, whatever) should deal with formatting and localisation. Returning with `FORMAT()` will return a string (which looks like a date). Any further processing will have to be aware of italian to understand this.
Comment: Shnugo I get your point and I agree that the presentation layer should deal with formatting. But in this case the procedure is used only for research purposes in SQL Server.
Answer: because EXEC uses different context, just add set language inside : SET query = 'set language italian;SELECT ...'
you can also set the default language in the connexion user login properties

SET LANGUAGE in SQL-Prozedure


I want to reach for a route from a form

Question: I'm new to laravel and i wanna make a sign up form. But i dont manage to acces the route from my form.
This is my form:
<form method="POST" action="{{ route('subscription.save') }}">
     @csrf
     @method('post')
....
     <button type="submit" class="btn btn-primary">Sign Up</button>
</form>

and this is my route:

Route::post('/subscription', function() { dd(33); })->name('subscription.save');

On button submit, it should display the dd(33)
If i delete the route entirely, it gives the error:"Route [subscription.save] not defined."
I actually want to reach for a function 'store' in 'SubscriptionController', where i also have a dd, but I adapted my code to search for the error.
Comment: "_But i dont manage to acces the route from my form_" Why not? What happens? Blank page? Wrong route? An error shows up (which one)?
Comment: What error are you getting?
Comment: no error, it just closes my modal and doesn't do my dd
Comment: php artisan r:l try
Comment: Did you try the same form outside the modal? It looks like your action only close your modal and don't do the post.
Comment: i try know from outside of the modal
Comment: yes, it works from outside of the modal and after i added the route there, it works from the modal too. Why is that? And how to make it work from inside the modal
Comment: The problem isn't from Laravel. You should have some javascript somewhere preventing the form to be posted
Comment: ok. what javascript
Comment: Is the modal placed inside of another form maybe?
Answer: I think you should not use @method('post'), as you already use method attribute in form tag. we use @method() in case we are sending PUT/PATCH request from form tag.
<form method="POST" action="{{ route('subscription.save') }}">
     @csrf
     @method('PUT/PATCH')

     <button type="submit" class="btn btn-primary">Sign Up</button>
</form>

Note: incase you use PUT/PATCH make sure you are using PUT/PATCH with ROUTE in web.php.
Comment: I don't think this is an answer to the question. The OP is using POST and not PUT. The `@method()` is not needed, but not a problem.
Comment: yes you are right, i just want to say that @method() will be used in case of PUT/PATCH, but not with POST.
this is optional only incase of PUT/PATCH request

I want to reach for a route from a form


Using Drupal Bootstrap, I want the 'title' of my parent menu item to be a glyphicon and to drop to the search bar!

Question: I am having 2 issues with Drupal Bootstrap, I have no idea how to set a leaf specifically in the menu to not only be a glyph of a search icon, but also how to add the search block to the dropdown.
I am going to probably stop using the main-menu and just add a few regions for it!
Answer: If you're wanting to theme the menu items, you can:

Use theme_menu_link() in your theme template to alter markup / attributes before rendering
Use a contrib module https://www.drupal.org/project/menu_attributes to add a custom class name e.g. icon-left icon-myname
Select the menu item via css and manually inject it there e.g.:
<code>.menu-class .mid-class:before {
font-family: 'glyphicon';
content: '\utf-char-code';
/* other css here */
}
</code>

Adding the search block to the dropdown depends how you want to set this up, we'd need more specifics on what behaviour you're trying to achieve. Bear in mind that you can alter individual menu items through hooks in your template (e.g. theme_menu_link() above), and you can also render blocks programatically.
Comment: I am sorry my question was written incredibly poorly!  I should have mentioned I am trying to use superfish, and what I am talking about is doing something like they do on this site http://www.highexistence.com/ with the search glyphicon dropping down into the search bar.  thanks!


Removing some files in /home increases free space on /?

Question: Basically I have this simplified file systems:
File system           Dim. Usati Disp. Uso% Montato su
/dev/md1               10G  4,0G  5,5G  43% /
/dev/md2              683G  438G  211G  68% /home

I am now removing some files within my /home dir, and I see that the free space of the first partition increases (/)
Is there any correlation between files stored in /dev/md2 and /dev/md1 ?
Maybe inodes of /home files are stored within /dev/md1 ?
Comment: _I am now removing some files within my /home dir, and I see that the free space of the first partition increases (/)_ -- Can you provide a 'before' and 'after' picture showing this? The filesystem size of / will change throughout the day, because it includes directories which change often, like /var and /tmp .
Answer: There is nothing that relates the filesystems like that except for possibly symlinks. Hopefully you don't have too many of those from /home to big files in / that you are removing (maybe logs?)
The other potential cause is that files you rm'd from / are being cleared as the last handle on them closes.


Replace thumbnail in EXIF with Python

Question: I'd like to replace the thumbnail in an image file's EXIF.
I've tried several libraries: exif, piexif, Pillow/PIL, none were able to write the thumbnail to the EXIF.
Few examples from what I've tried so far:
import piexif
from PIL import Image
import exif

def replaceThumbnailMode1(sourceImageFilePath, targetImageFilePath):
    exifImage = exif.Image(sourceImageFilePath)
    thumbnailBytes = exifImage.get_thumbnail()

    piexif_dict = piexif.load(targetImageFilePath)
    piexif_dict["thumbnail"] = thumbnailBytes
    piexif_dict["1st"][513] = 1 # JPEGInterchangeFormat
    piexif_dict["1st"][514] = 1 # JPEGInterchangeFormatLength
    piexif_bytes = piexif.dump(piexif_dict)
    piexif.remove(targetImageFilePath)
    piexif.insert(piexif_bytes, targetImageFilePath)

def replaceThumbnailMode2(sourceImageFilePath, targetImageFilePath):
    exifImage = exif.Image(sourceImageFilePath)
    thumbnailBytes = exifImage.get_thumbnail()

    piexif_dict = piexif.load(targetImageFilePath)
    piexif_dict["thumbnail"] = thumbnailBytes
    piexif_dict["1st"][513] = 1 # JPEGInterchangeFormat
    piexif_dict["1st"][514] = 1 # JPEGInterchangeFormatLength
    piexif_bytes = piexif.dump(piexif_dict)

    im = Image.open(targetImageFilePath)
    im.save(targetImageFilePath + "2.jpg", exif = piexif_bytes)

sourceImageFilePath = "source_image.jpg"
targetImageFilePath = "target_image.jpg"

replaceThumbnailMode1(sourceImageFilePath, targetImageFilePath)
# replaceThumbnailMode2(sourceImageFilePath, targetImageFilePath)

What I've noted is that after loading the piexif_bytes with piexif.load(), in the
returned exif_dict the JPEGInterchangeFormat, JPEGInterchangeFormatLength TAGs have seemingly correct / calculated values.
Please let me know what should I do differently. I don't know what I'm missing. Worths noting that I'm new to Python, sorry if I'm asking something basic.
UPDATE
I've tried the following and observed that the 2 dictionaries do not match:
values for JPEGInterchangeFormat and JPEGInterchangeFormatLength in piexif_dict_from_bytes are way smaller compared to piexif_dict_from_image.
For JPEGInterchangeFormat the value is around 1500, whereas it has a value of around 42 000 in piexif_dict_from_image:
def piexif_dict_test(sourceImageFilePath):
    piexif_dict_from_image = piexif.load(sourceImageFilePath)
    piexif_bytes = piexif.dump(piexif_dict_from_image)
    piexif_dict_from_bytes = piexif.load(piexif_bytes)

    print

pixeif.transplant() on the other hand, correctly copies the thumbnail from one image to the other, but I want to set a new one.
Currently I'm stuck. I'll try to find another library which does the job, if there will be no solution for piexif.
Comment: Did you check [`piexif.dump()`](https://piexif.readthedocs.io/en/latest/functions.html#piexif.dump) example? We don't know what `thumbnailBytes` is, post [mre]
Comment: Yes, I've tried piexif.dump(), it didn't work unfortunately. As for thumbnailBytes, it contains the bytes of the thumbnail I want to insert into an image. Sorry, I thought that wouldn't be of much help. I've updated the example, so it can be executed.
Answer: This code works fine. You probably missed out on some exif required data that is essential. Try this:
piexif_dict["Exif"][36864] = b'0221'  # Exif.Photo.ExifVersion

If not, look at the exif2 standard: https://exiv2.org/tags.html
Comment: Unfortunately it still does not work. Thank you for the idea. Please see the updated question for additional information. I think there is a bug in piexif.dump().
Comment: How do you check the thumbnail in targetImageFilePath? Did you check it using this example? https://piexif.readthedocs.io/en/latest/functions.html#piexif.load
Comment: Actually I'm using this class for reading the thumbnail: [Android ExifInterface](https://developer.android.com/reference/androidx/exifinterface/media/ExifInterface.html), as I need the generated data for testing the application.

Also, the result file size is ~40 KB smaller than the original one. My expectation is that it should be the same, especially in case of the second test case in the question's _update_ section.

Replace thumbnail in EXIF with Python


Paul Hindemith & Omitted Fifths

Question: Three note voicings of seventh chords where the perfect fifth above the root has been omitted are common in jazz piano because the ear does a good job interpreting the function of the chord with or without it. In Paul Hindemith's 'Craft of Musical Composition' he expresses that because it is limiting to think of chords as being constructed in stacks of thirds, the root may not be determined by doing so and simply seeing what tone ends up on the bottom. Instead we look at the root of whatever the "best interval" within the chord is.

If there is a fifth in the chord, then the lower tone of the fifth is the root of the chord. Similarly, the lower tone of a third or aseventh (in the absence of any better interval) is the root of the chord. Conversely, if a fourth, or a sixth, or a second is the best interval of a chord, then its upper tone is the root of the chord. Doubled tones count only once; we use the lowest one for our reckoning. If the chord contains two or more equal intervals, and these are the best intervals, the root of the lower one is the root of the chord (Hindemith 97).

In a (major or minor) 7th chord with an omitted fifth, the "best interval" would be the perfect fifth between the 3rd and the 7th, the 3rd being the lower tone, then, would be the actual root of the chord. Why then would the ear hear the root of a CΔ7, for example, as C and not E? This book has been extremely illuminating so far & I'm sure there is an explanation for this inconsistency that I'm missing.
Answer: The theories of harmony of Hindemith, Schoenberg and Janacek were attempting to make sense of the music of the time. They came from a heritage where thinking about lines in counterpoint was more dominant than it is in the music of today. The music of Debussy and other composers was challenging old ways of understanding harmony... unresolved dissonances etc... and they tried to understand these changes through the movement of lines that form re-occurring vertical arrangements (chords).
Jazz music, at least how it seems to be taught in the academy, takes the chords much more as units in their own right, to be assembled and re-assembled into progressions. The function of the chords are often (not always) "in" the chords, rather than between the chords...
So... C Eb Bb in jazz might be heard as dropping the fifth... whilst in the music of Mahler, it might be heard as Eb add 6 without the third, all depending on what else was going on in the music with motives or whatever.
This is a quick response with some hunches. Of course, there was a good amount of cross-fertilisation between jazz and classical music. One area in common is lines/voices that move symmetrically via chromatic motion. The key is that classical musicians play parts... and jazz musicians charts...
My understanding is that dropping the fifth in jazz piano can be done because the bass player might play the fifth... the ways chords are used comes from the different kinds of musicianship expected - comping vs doing a solo etc.
PS have you read Persichetti?
Answer: Hindemith wrote textbooks on harmony, then proceeded to ignore much of what he wrote in his own compositions.  Or so my old music professor used to tell us!  And his 'best interval' theory certainly falls down when confronted with a (5th omitted) maj7 chord.  But there's good ideas in his books. Use them as a resource, not a bible.  (Same, but even more so, with George Russel's 'Lydian Chromatic Concept'.  Definitely had a bee in his bonnet, but some of the buzzing is interesting.)
To sidetrack a little into the practicalities of jazz piano playing:  Yes, you'll find yourself playing 3rds and 7ths a lot in your left hand.  Not so much because of any harmonic theory, but because you want to keep the texture light and un-muddy, and you want to keep out of the way of the bass.   There's another technique when comping behind someone else's solo where you avoid playing the 3rd of a major chord, because the soloist is very likely going to play it 'blue' or elaborate it with suspensions.  So you keep out his way.
Answer: The explanation is that Hindemith (not surprisingly!) believed in the theory he had invented. But don't forget Bertrand Russell's definition: "belief" is "that for which there is no evidence".
From the paper Hindemith's Contribution to Music Theory, William Thomson, Journal of Music Theory, Vol. 9, No. 1 (Spring, 1965), pp. 52-71:

The population of speculative theorists is split like that of other
  ontological realms into those who are "believers" and those who are
  not. The faithful, in this case, hold that music operates within a
  closed system, its basis unchanging through the ages and potentially
  demonstrable. Those who entertain such immutable "truths" are known as
  natural theorists, for a usual concomitant of their speculations has
  been the derivation of all manner of "laws" from the known, assumed,
  or merely the fancied "facts" of the natural world.
If natural theorists were organized in a manner befitting their
  allegiance to dogma, Paul Hindemith would be recognized as the most
  recent addition to their Pantheon; his life as a theorist was
  dedicated to an attempt to demonstrate music's participation in
  natural laws, ...

If you like this sort of stuff, google for terms like "density degree theory". The nicest things about pure speculation are (1) anybody can do it, and (2) nobody can be proved wrong.
Comment: This is a rant that may express a valid opinion, but it doesn't adress the concrete question.
Comment: does this group of 'natural theorists' include the folks who like to explain music by referring to the harmonic series?
Answer: The answer is easy - because C is the lowest note. Hindemith talked about the correlation between tone register and functional importance. C, being the lowest tone and a fundamental, provides a relevant fifth twice (3rd and 6th overtone). Harmonically speaking, the bass tone determines functionality, it gives context to the other tones (even if it's not the root). Also chords are naturally build by thirds, and the only way you can get these three notes by stacking 3rds is in Cmaj7 chord. Sure, you can have non-chord tones too, but cloud the function of the chord and the ear is tuned to recognise triads best. There is no way anyone can claim that C-E-B sounds like Eadd6 (if not preceded by anything). This analysis is concerned with the chord as a separate unit, but in music this is rarely the case.
In the bigger picture it depends on context - where the chord stands in a progression. I'm sure you know that in jazz you can easily outline a chord with two notes (especially 3rd and 7th) and the ear can fill it out based on the logic of the progression, which in most cases is very common and familiar. In cases where the progression is more complex and unfamiliar (try outlining Giant steps for someone who is not that into jazz) this effect is lost though. A more trivial reason for omitting the fifth in jazz is that it sounds too stable, consonant and doesn't need a resolution, making it less appealing and stifling forward momentum (and you could use that finger to play a non-chord/altered tone).
Answer: Hindemith used the theory of "the lowest strongest interval to name the root of chords and clusters based on combination tones resulting from intervalic frequencies combining to produce an audible sub octave note.
The entire ensemble would need to be considered not just the piano in this instance.

Paul Hindemith & Omitted Fifths


Set Difference proof via NFA

Question: I need to prove $L_1L_3$ − $L_2$ where $L_1,L_3,L_2$ are regular languages. I proved via intersection way, but I need to show it with NFA. Because of complementary in intersection proof, I cannot prove it with NFA. Can anybody help me?
Maybe this is more understandable with all question.
Question: Prove that if $L_1,L_3$ and $L_2$ are regular languages over the alphabet Σ = {a, b} , then so is
L = ($L_1L_3$−$L_2$) ∪ $L_4$ in which $L_4$ = {$w | w = bx(ab)^∗$, x ∈ L2} by using NFA.
Comment: A DFA is a special case of NFA, and whenever complementation is involved, you determinize and complement.
Comment: I know what is DFA or NFA. Thank you for information, but how can I draw it by using NFA? Could you draw it here? @FabioSomenzi
Answer: You only know that $L_1$, $L_2$, and $L_3$ are regular.  Hence, you can prove that $L_4$ is also regular, but you cannot draw automata that accept those languages unless you are given their definitions.
What you could do is describe a construction that, applied to automata for $L_1$, $L_2$, and $L_3$---whatever they may be---computes an automaton for $L_4$ and eventually an automaton for $(L_1L_3 - L_2) \cup L_4$.
The existence of such a construction is guaranteed by the closure properties of regular languages, and by Kleene's theorem, which says that the regular expression appearing in the definition of $L_4$ has an equivalent automaton.
However, describing such a construction is not necessary to prove the regularity of $(L_1L_3 - L_2) \cup L_4$.  For instance, $L_1L_3$ is regular because regular languages are closed under concatenation.
I'm in no position to divine what your instructor or textbook authors meant by the words "by using NFA."  A lot of the communication that takes place in a course relies on context and on a set of conventions that are specific to that course.  Maybe the purpose of the exercise is to test your understanding of closure properties by having you rehash the proofs?  The most qualified people to answer this question are your instructor and teaching assistants.
As for the doubt you express at the beginning of your post about complementation and NFAs, here's what I meant in my comment.
To complement a regular language given an NFA for it, we construct a DFA from the NFA and complement the DFA.  (I assumed that you knew that.) Determinization may incur an exponential blow-up, but as long as we are merely proving the existence of an automaton, we don't care.
Besides, a DFA is also an NFA, which means that, strictly speaking, all steps of the construction of an automaton for $L_1L_3 - L_2$ from automata for $L_1$, $L_2$, and $L_3$ manipulate NFAs.
Bottom line: the need to complement one operand to show the regularity of the difference of two regular languages is not an issue, and you shouldn't worry about it.

Set Difference proof via NFA


Stieltjes integral and conditional expectation

Question: The following statement shows up in the proof of the Strengthened Fefferman Inequality in Protter's Stochastic Integration and Differential Equations.

Let $f$ be a random variable in $\mathcal{F}_\infty$ and $A_t$ be an increasing process with $A_0=0$ such that
\begin{align*}
E\left[\int_0^\infty |f| dA_t\right]<\infty
\end{align*}
Then we have the following:
\begin{align*}
E[fA_\infty] = E\left[\int_0^\infty f\ dA_t\right]= E\left[\int_0^\infty E[f|\mathcal{F}_t]\ dA_t\right]
\end{align*}

However, the second identity is not obvious. The conditional expectation depends on $t$, so in this case we cannot exchange the conditional expectation and the integral to conclude the result. My question is how can we conclude the second identity?
Thanks in advance!
Answer: One possible proof I can think of is applying Integration by part formula:
Let $M_t=E[f|\mathcal{F}_t]$. It is sufficient to prove the result for bounded $f$, then we can apply dominated convergence theorem for general $f$. $M_t$ is then bounded. Therefore, since $A_0=0$
\begin{align*}
\int_0^\infty M_{s^-}dA_s = M_\infty A_\infty-\int_0^\infty A_{s^-}dM_s-[M,A]_\infty
\end{align*}
Since $M$ is a martingale and $A$ is locally bounded, $\int_0^t A_{s^-}dM_s$ is a local martingale. Note from the above formula, we can see $E[\sup_{[0,\infty]}|\int_0^t A_{s^-}dM_s|]<\infty$. This implies this local martingale is a true martingale.
Next since $A$ is finite variation, $[M,A]_\infty=\sum \Delta M\Delta A$. Therefore, we have
\begin{align*}
\int_0^\infty M_{s}dA_s = M_\infty A_\infty-\int_0^\infty A_{s^-}dM_s
\end{align*}
Take expectation on both sides, we have
\begin{align*}
E\left[\int_0^\infty E[f|\mathcal{F}_s]dA_s\right]=E\left[\int_0^\infty M_{s}dA_s\right]=E[M_\infty A_\infty]=E[E[f|\mathcal{F}_\infty] A_\infty]=E[fA_\infty]
\end{align*}
Answer: Do we know that $A_t$ is adapted? If we can approximate the integral by
$\sum_{i=0}^{i=n} f(w)(A_{t_{i+1}}(w)-A_{t_{i}}(w))$ and if we know $A$ is adapted, then
$E[\sum_{i=0}^{i=n} f(w)(A_{t_{i+1}}(w)-A_{t_{i}}(w))]\\
=E[\sum_{i=0}^{i=n} E[f(w)|F_{t_i}](A_{t_{i+1}}(w)-A_{t_{i}}(w))]\\$.
Then we should be able to show that the right handside converges to $E[\int_{0}^{\infty}E[f|F_{t}]dA_{t}]$
Comment: Thanks for answering!. I think the right side will converge to $E[\int_0^\infty E[f|F_{t-}]dA_t]$. The only problem left is to prove $E[f|F_{t}]$ has continuous sample path (however, I thought about this problem before and have no clue).
Comment: For $F_n$ increasing, we know $E[f|F_n]$ converges in L1 and a.s. to $E[f|\cup F_n]$. while for  $F_n$ decreasing, we know $E[f|F_n]$ converges in L1 and a.s. to $E[f|\cap F_n]$. Does that help?


Why is odds ratio an estimate of relative risk?

Question: This link says

In epidemiological terms, the odds ratio is used as a point estimate of the relative risk in retrospective studies.

I understand that odds ratio is calculated in case control studies, while relative risk is calculated in cohort studies. Calculating incidences and risks in case control studies doesn't make sense because we ourselves are choosing the ratio of cases and controls which is never how it happens in nature. But it is usually taught that, odds ratio gives an estimate of this.
Why is this so?
Comment: The risk ratio is a quick and dirty estimate of the odds ratio.  The odds ratio is more of a gold standard because it is capable of representing a wider variety of subjects without restricting their base risk.
Comment: Related: https://stats.stackexchange.com/questions/350445/binary-logistic-regression-interpreting-odds-ratio-vs-comparing-predictive-pro
Answer: It is not true in all situations. The odds ratio only gives an estimate of the relative risk if the outcome is a low probability outcome. (Same insight as Poisson approximation to the binomial distribution).
Imagine a case-control study for lung cancer, then we check the number of smokers in both groups. Technically, the only thing we can test is given that an individual has lung cancer, what is the probability that they smoke. We can do the same for the non cancer group, and obtain a ratio of the both probabilities. This would be the relative risk. But we do not really care about this quantity. We actually want, given that an individual smokes, what is the probability that they have lung cancer divided by the same probability for non-smokers.
The nice thing about the odds ratio is that it is bi-directional. So: the odds of smoking given lung cancer divided by the odds of smoking given control is actually equivalent to the odds of lung cancer given smoking divided by the odds of lung cancer without smoking. This bi-directionality of the odds ratio allows us to obtain the comparison we want from case-control studies.
Now, if we know the outcome to have a low rate in both groups $-$ the proportion of individuals with lung cancer is small among smokers and non-smokers $-$ then the odds ratio approximates the relative risk. This is the one time we can use the odds ratio to approximate the relative risk in case-control studies. I'm assuming that in case-control studies, the cases are rare events. So certain persons may skip this caveat and state what the OP stated.
The best resource I've found for questions like the one here is Agresti's book on Categorical Data Analysis.
Comment: Thanks for the answer. "Now, if we know the outcome to have a low rate in both groups .... then the odds ratio approximates the relative risk." - can you tell how this happened?? Also, is it a low prevalence rate in the whole population or individual groups?
Comment: Is it just that a/a+b will tend to a/b as a gets smaller? Is it just that?
Comment: Also, if we know P(smoker|cancer), can't we calculate P(cancer|smoker) using Bayes rule?
Comment: Yes, it is that formula, and as you can see, a has to be small in individual groups for both ratios to be similar.  Also, if we know P(cancer), then we can work from P(smoke|cancer) to P(cancer|smoke) using Bayes rule.
Answer: The quote surely just means to say that the odds ratio is a relative risk measure - rather than an estimate of the relative risk, which as already point out is only approximately the case in cohort studies/randomized trials for very low proportions.
By relative risk measure I mean something that is given relative to some comparison group in a way that the absolute difference depends on the value for the comparison group.
I.e. if the odds ratio is 2, then if the odds of an event are 1:1 (50% probability) in the control group, they are 2:1 (67% probability) in the test group for a 17% absolute risk difference, but for control group odds of 1:99 (1%), it is a 2:99 (2%) test group odds for a 1% absolute risk difference. The relative risk has a similar property - except that it cannot remain constant across all control group probabilities, a relative risk of 2 is only possible for a control group probability $\leq 50\%$ - and so do the hazard ratio, as well as the rate ratio. I believe these four measures of usually meant when people talk about measures of relative risk. It is of course confusing that one of them is called "relative risk".
Answer: This was an interesting question so I did a little digging.  The first link I found gave a little bit of insight.

The basic difference is that the odds ratio is a ratio of two odds (yep, it's that obvious) whereas the relative risk is a ratio of two probabilities  (the relative risk is also called the risk ratio).
The odds ratio is the ratio of the odds of an event in the Treatment group to the odds of an event in the control group. The term 'Odds' is commonplace, but not always clear, and often used inappropriately.  The odds of an event is the number of events / the number of non-events.

The article also gave the following equations, which make the difference a bit easier to understand:

Suppose you have a school that wants to test out a new tutoring program.  At the start of the school year they impose the new tutoring program (treatment) for a group of students randomly selected from those who are failing at least 1 subject at the end of the 1st quarter.  The remaining students receive the customary academic support (control group).
At the end of the school year the number of students in each group who fail any of their classes is measured. Failing a class is considered the outcome event we're interested in measuring. From these data we can construct a table that describes the frequency of two possible outcomes for each of the two groups.

Based on the definition from this site, OR and RR are two fundamentally different concepts.
$$
OR = \frac{a d}{b c} \\
RR = \frac{\frac{a}{a+b}}{\frac{c}{c+d} } = \frac{a \cdot (c+d)}{c \cdot (a+b)} = \frac{ac + ad}{ca + cb}
$$
This may not be particularly helpful yet, but I found another article that was more insightful.  It was aptly named Relative risks and odds ratios:
What's the difference?, and explains the ratios in the following way...

Probability is the likelihood of an event in relation to all possible events. If a horse wins 2 out of every 5 races, its probability of winning is 2/5 (40%). Relative risk is a ratio of probabilities. It compares the incidence or risk of an event among those with a specific exposure with those who were not exposed (eg, myocardial infarctions in those who smoke cigarettes compared with those who do not).  RR is based upon the incidence of an event given that we already know the study participants' exposure status. It is only appropriate, therefore, to use RR for prospective cohort studies.
Odds compare events with nonevents. If a horse wins 2 out of every 5 races, its odds of winning are 2 to 3 (expressed as 2:3). An odds ratio is a ratio of ratios. It compares the presence to absence of an exposure given that we already know about a specific outcome (eg, presence-to-absence ratio of cigarette smoking in those who had an MI compared with the same ratio in those who did not have an MI).  OR can be used to describe the results of case control as well as prospective cohort studies.
OR and RR are usually comparable in magnitude when the disease studied is rare (eg, most cancers). However, an OR can overestimate and magnify risk, especially when the disease is more common (eg, hypertension) and should be avoided in such cases if RR can be used.

From this article, we can see that one would be able to reasonably estimate relative risk with the odds ratio if the disease is rare.  This addresses the "the odds ratio is used as a point estimate of the relative risk in retrospective studies" quote in your original question.  Though we are not provided with the original source of your quote, one could assume you pulled the quote from a source relating to relatively rare diseases, or disease outbreaks.
As a caveat, note the following information from this document, which also examines these two terms:

The RR and the OR should always be examined in the context of the absolute risk.  For example, in a case-control study, Louik at al. found that the use of sertraline during pregnancy substantially increased the risk for omphalocele (OR=5.7; 95% CI, 1.6-20.7).  Omphalocele is rare in the population, and so, in this situation, the OR and the RR would probably be similar.  If the risk of omphalocele in the general population is 0.02%, the 5-fold increased risk with sertraline would result in an incidence of 0.01%.  At the individual patient level, 0.1% is an almost negligible risk.  Therefore, when the absolute risk is low, even a large increase in the RR or OR may not be clinically significant.
The absolute risk of an event is the likelihood of occurrence of that event in the population at risk.


Why is GUI thread blocked from worker thread when calling waitForReadyRead?

Question: EDIT: I completly restructured the question because I can be much more precise after build up a reprex.
I want to do some synchronous network calls, therefore I created a worker thread and moved the object to the thread.
However when I try to change the Text in the QLineEdit the GUI gets blocked when using the waitForReadyRead in the worker thread. If I use the loop with retries and a smaller timeout for waitForReadyRead the GUI does not get blocked.
As you can see, if I do not connect the textChanged (hence the name of the function) Signal of the QLineEdit everything works fine and I can edit the text field in the GUI. Which afaik means, that as soon as the GUI needs to process events, it gets blocked.
Why is this happening?
If the the GUI thread and worker thread are not executed concurrent my assumption is that the loop with retries would also block for the whole time. At the current state of my knowledge somehow the exectuon of waitForReadyRead blocks both threads or at least the execution of the event loop in the GUI thread.
form.ui:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>1292</width>
    <height>791</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralwidget">
   <layout class="QVBoxLayout" name="verticalLayout_2">
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout_4">
      <item>
       <layout class="QVBoxLayout" name="verticalLayout">
        <item>
         <layout class="QHBoxLayout" name="horizontalLayout">
          <item>
           <widget class="QLabel" name="label">
            <property name="text">
             <string>Textfield</string>
            </property>
           </widget>
          </item>
          <item>
           <widget class="QLineEdit" name="line_edit">
            <property name="text">
             <string>Some Text</string>
            </property>
           </widget>
          </item>
         </layout>
        </item>
       </layout>
      </item>
     </layout>
    </item>
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout_5">
      <item>
       <widget class="QPushButton" name="btn_btn">
        <property name="enabled">
         <bool>true</bool>
        </property>
        <property name="text">
         <string>Button</string>
        </property>
        <property name="checkable">
         <bool>false</bool>
        </property>
       </widget>
      </item>
     </layout>
    </item>
   </layout>
  </widget>
  <widget class="QMenuBar" name="menubar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>1292</width>
     <height>22</height>
    </rect>
   </property>
  </widget>
  <widget class="QStatusBar" name="statusbar"/>
 </widget>
 <resources/>
 <connections/>
</ui>

main.py:
# This Python file uses the following encoding: utf-8
import os
import sys
from PySide6.QtCore import QFile, QObject, QThread, Slot
from PySide6.QtUiTools import QUiLoader
from PySide6.QtWidgets import QApplication, QMainWindow
from pathlib import Path
from PySide6.QtNetwork import QTcpSocket

class WorkerClass(QObject):
    def __init__(self):
        super().__init__()

    @Slot()
    def do_work(self):
        print("Worker Thread: " + str(QThread.currentThread()))

        self._socket = QTcpSocket()
        self._socket.connectToHost("example.com", 80)
        if self._socket.waitForConnected(5000):
            print("Connected")
        else:
            print("Not Connected")

        # none blocking ui
        # retries = 1000
        # while retries:
        #     retries -= 1
        #     if self._socket.waitForReadyRead(50):
        #         answer = self._socket.readAll()
        #         break
        #     elif retries == 0:
        #         print("Timeout")

        # blocking ui for 10 seconds
        if self._socket.waitForReadyRead(10000):
            print("Answer received")
        else:
            print("Timeout")

class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.__load_ui()
        self.ui.btn_btn.clicked.connect(self.start_worker)
        self.ui.line_edit.textChanged.connect(self.why_blocks_this_connection)

    def __load_ui(self):
        loader = QUiLoader()
        path = os.fspath(Path(__file__).resolve().parent / "form.ui")
        ui_file = QFile(path)
        ui_file.open(QFile.ReadOnly)
        self.ui = loader.load(ui_file, self)
        ui_file.close()

    def show(self):
        self.ui.show()

    @Slot()
    def start_worker(self):
        print("GUI Thread: " + str(QThread.currentThread()))
        self._worker = WorkerClass()
        self._network_thread = QThread()
        self._network_thread.started.connect(self._worker.do_work)
        self._worker.moveToThread(self._network_thread)
        self._network_thread.start()

    def why_blocks_this_connection(self, new_val):
        print(new_val)

if __name__ == "__main__":
    app = QApplication([])
    widget = MainWindow()
    widget.show()
    sys.exit(app.exec())

Answer: Explanation
There seems to be a bug with PySide6 (and also PySide2) that causes the waitForReadyRead method to block the main thread (or the main eventloop) causing this unexpected behavior. In PyQt it works correctly.
Workaround
In this case a possible solution is to use asyncio through qasync:
import asyncio
import os
import sys
from pathlib import Path

from PySide6.QtCore import QFile, QIODevice, QObject, Slot
from PySide6.QtWidgets import QApplication
from PySide6.QtUiTools import QUiLoader

import qasync

CURRENT_DIRECTORY = Path(__file__).resolve().parent

class Worker(QObject):
    async def do_work(self):
        try:
            reader, writer = await asyncio.wait_for(
                asyncio.open_connection("example.com", 80), timeout=5.0
            )
        except Exception as e:
            print("Not Connected")
            return
        print("Connected")
        # writer.write(b"Hello World!")
        try:
            data = await asyncio.wait_for(reader.read(), timeout=10.0)
        except Exception as e:
            print("Timeout")
            return
        print("Answer received")
        print(data)

class WindowManager(QObject):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.ui = None
        self.__load_ui()
        if self.ui is not None:
            self.ui.btn_btn.clicked.connect(self.start_worker)
            self.ui.line_edit.textChanged.connect(self.why_blocks_this_connection)

    def __load_ui(self):
        loader = QUiLoader()
        path = os.fspath(CURRENT_DIRECTORY / "form.ui")
        ui_file = QFile(path)
        ui_file.open(QIODevice.ReadOnly)
        self.ui = loader.load(ui_file)
        ui_file.close()

    def show(self):
        self.ui.show()

    @Slot()
    def start_worker(self):
        self.worker = Worker()
        asyncio.ensure_future(self.worker.do_work())

    def why_blocks_this_connection(self, new_val):
        print(new_val)

def main():
    app = QApplication(sys.argv)
    loop = qasync.QEventLoop(app)
    asyncio.set_event_loop(loop)

    w = WindowManager()
    w.show()

    with loop:
        loop.run_forever()

if __name__ == "__main__":
    main()

Comment: @Enak I just reported it: https://bugreports.qt.io/browse/PYSIDE-1640
Comment: Is this a known bug or should I report that?
Answer: The reason why your worker stopped is because the function waitForReadyRead is blocking.

waitForReadyRead() blocks calls until new data is available for reading.

I know that you can put a timeout as a parameter, but I had this problem of blocking function too.
Plus, this function returns true if a ready signal is emitted.
source : https://doc.qt.io/qt-5/qserialport.html#waitForReadyRead
So maybe, instead of using waitForReadyRead(), use a ready signal directly :
connect(deviceControl_SerialPort, &QSerialPort::readyRead, this, &Class::readData_slot);

void Class::readData_slot()
{
    qDebug() << "Ready Read" << endl;
    deviceControl_readData.append(deviceControl_SerialPort->readAll());
}

If any troubles, this issue may help
Comment: THX for your answer. I know that is the "usual" way but before my big restructure of the question, I mentioned that I have to implement a certain process. It consists out of many, many steps, each step needs to send a tcp packet to one out of two available devices. It is much more easier to write code from "first line to last line" with blocking calls instead of having a big if then else struct and keep track of the states to know which device needs to be communicate with next and what is the next packet.
Comment: I know that when you wait for ready read, you have to read all the data when the function returns true, like you did in your comments. As you have to use waitForReadyRead,  an other way is to call bytesAvailable > 0 to check if there is bytes to read
Comment: Since you edit your first paragraph: A blocking call, in my understanding, is a call which blocks further execution of the thread. Hence, it should not block other threads. This is exactly the reason why I moved the blocking calls to another thread.
Comment: I never use sockets with Qt, but I think in some ways, your threads are connected to each other and if one is blocked, the other will wait. (edit because enter key saved the message ) : Did your program continues after the 10000 timeout or is it constantly blocking ? Did you run it on Windows ? There is a known issue about waitForReadyRead timeouts on Windows


How to pass a newline character in Redis with Lua script

Question: I set records in Redis database with a Lua script.
Some records may contain newline characters.
How can I set a new record with body containing a newline character using Lua?
My code is:
redis.call("set", "text", "First line\nSecond line" );

But when I examine this record in redis-cli> get "text", I'd like it to be:
First line
Second line

But I get:
First line\nSecond line

Comment: I use redis-cli> get "text"
Answer: The text is being stored as expected, literally.  If you want to store the formatted string you need to do just that
redis.call("set", "text", string.format("First line\nSecond line") );

Comment: @Ivan that's right, if you want you can turn it off w the `--raw` switch
Comment: I've done redis.call("set", "text", string.format("First line\nSecond line") ); but get text gives First line\nSecond line. But I need to have a newline character to be in this record (insted of 2 symbols '\' and 'n' I need one symbol that is a newline symbol)
Comment: Thanks, now I understand that it's just redis-cli who prints "\n" symbols instead of printing text on the new line


Can I save the value of a textbox?

Question: I have one text box and have written "ABC" in the text box, but I want to obtain the text using jQuery
<input type=text value="ABC">

But when I use jQuery's .html() it returns null
Comment: `.val()` you want to use
Comment: Input tags have no content as they are self closing. Thus `text()` and `html()` will return nothing.
Comment: @Enijar Quotes are optional
Comment: is this really hard to research online?
Answer: Here's a FIDDLE
<input type="text">

$('input').keyup(function() {
  $('span').text($(this).val());
});

or
$('input').keyup(function() {
  $('span').html($(this).val());
});

Can I save the value of a textbox?