Correlation between different types of variables( categorical/numerical) and a binary categorical one output

Question: i am doing research and in my articles i found that Pearson correlation can be applied between numerical variables and an output label variable.
in my case i have 72 variables (20 are numerical (float) and the rest are categorical non ordinal and i codified them to (0,1,2,...n)).My target output is a 0/1 result which represents category.
My question here Pearson correlation is it a good way to calculate the correlation between variables???
or i need to split my data based on type and then apply the appropriate correlation measurement like Chi sqaure for categorical/ categorical variable, Pearson corraltion between the numerical/numerical and anova between categorical/numerical variable
Thanks for explanation
Answer: Correlation as a dependency measure is effective only when the data is multivariate normal.
Multivariate normality also implies that individual marginal distributions are also normal.
Say, your data has a categorical independent variable with only two/three levels - Yes/No or Good/Bad/Worse. Clearly, with only two/three data points for this particular categorical variable, we cannot say it is marginally normal. Hence, the data might not be multi-variate normal. So, in your case, correlation may not be a good measure of dependency.
Even among the numerical variables, first check if they are individually (marginally) normal-ly distributed or not. If yes, then you can use correlation. Else go for the other metrics like Spearman's rho, etc.
Comment: This is very misleading. As a counter-example, suppose x is uniform, y = a + bx, and so y is uniform too, and correlation is 1. Are you saying that this is invalid because neither marginal distribution is normal? Correlation measures linearity of relationship and the marginal distribution of either variable is secondary. At worst, detailed inference may be a bit iffy without normality but we have had permutation tests and bootstrapping for over 40 years as alternatives.  (The correlation between binary variables is also well defined, so categorical variables aren't all out of the question.)


Which ports does NMAP scan for OS-detection

Question: nmap offers OS-detection functionality based TCP/IP fingerprinting by sending six probing packets and analyzing their responses. In the documentation is says that some of them are send to an open port and some are sent to a closed port.
Does anyone know how nmap decides which port to send the probes to? Does it just look for the first closed port and the first open ports it can find? Does it search for them in a certain order? Or does it randomly pick a port?
Comment: This link can help you.:
[nmap documentations](https://nmap.org/man/it/man-os-detection.html)
Comment: Thanks for your help. But that link basically mentions the same as the documentation I already found.
Answer: In this case, there is no better documentation than the code itself. Nmap relies on port scan results to determine a list of open and closed ports. It is looking for three things in particular:

an open TCP port
a closed TCP port
a closed UDP port

Generally speaking, it chooses the first of these (lowest number) that it knows of, but there are a couple of rules for things that it tries to avoid:

Do not use port 0. For most systems, this is not a valid port number. The chance is pretty high that if port 0 is found open, the thing using it to communicate is not the OS's native IP stack.
If service scan was performed, avoid ports that were labeled tcpwrapped. This can sometimes be a result of an IPS shutting down a connection, so skipping these ports helps assure that Nmap is getting an unmodified connection to the target.
Answer: If I well understood, nmap tries open or closed ports  only if isn't able to detect the OS via fingerprint, but the documentations doesn't explain the sequence of checked ports.
I think you could discover how,  tracking your own traffic during the scan.


ext3 format options

Question: I'm creating a ext3 filesystem on top of a software raid5 (md) and I'm wondering what are the best parameters when creating the filesystem (with mkfs.ext3) and while mounting.
RAID5 chunk size is 128k, array has 3 drives, 900 GB effective total. ext4 is not an option.
Edit: Filesystem has several VPS (virtual private machines), including a Gentoo VPS with lots and lots of small files. VPS don't use images, they store files directly on the file system. It also has many 500-1000 MB files.
Thank you,
Matic
Answer: The idea behind optimizing stripe sizes is to optimize it so, that in your typical workload most read requests can fulfilled by (a multiple of) a single read, evenly divided over all data disks. For a three disk RAID-5 set, the amount of data disks would be two.
For example, let's assume my typical workload makes I/O read requests that are on average 128kB. You would then want to make chunks of 64kB if I have a three disk RAID-5 set. Calculate it like this:
avg request size / number of data disks = chunk size
128kB / 2 = 64kB

This is the chunk size of your RAID set, we haven't arrived at doing the filesystem yet.
Next step would be to make sure the filesystem is aligned with the RAID set's characteristics. Therefore, we want to make sure the filesystem is aware of the chunk size of the RAID set. It can then evenly distribute superblocks over the three disks.
For this, we need to tell mke2fs what the size of a chunk is or, more exact, how many filesystem blocks will fit a chunk. This is called the 'stride' of the filesystem:
chunk size / size of filesystem block = stride size
64kB / 4kB = 16

You can then call mke2fs with the -E stride=16 option.
The page mentioned earlier also talks about the -E stripe-width option for mke2fs, but I have never used that myself, nor does the manpage of my version of mke2fs mention it. If we would want to use it though, we would be using it like with 32: the stripe width is calculated by multiplying the stride with the amount of data disks (two, in your case).
Now to the core of this matter: what is the optimal chunk size? As I described above, you would need the average size of an I/O read request. You can get this value by checking the appropriate column in the output of iostat or sar. You will need to do that on a system that has a comparable workload as the system you are configuring, over a prolonged period.
Make sure that you know what kind of unit the value uses: sectors, kilobytes, bytes or blocks.
Answer: Without more knowledge of your exact workload, I'd say that the defaults are likely to be the best option.  Maybe -m 0 if you're not worried about non-root users filling the disk, and/or setting dir_index if you're going to be doing silly things with the number of files in a directory.
Answer: Make sure you align the filesystem with the RAID stripe size -
http://wiki.centos.org/HowTos/Disk_Optimization
has a good summary.
By making sure the filesystem is aligned properly, you can avoid doing RMW on RAID5 which helps performance.
Comment: I created the FS with: "mkfs.ext3 -b 4096 -E stride=32 -E stripe-width=64 -m 0 -O dir_index /dev/storage/raid5" As said in the question, I have RAID5 with 3 drives and 128kB chunk size. Is this correct?

ext3 format options


How to shift coordinates in ggplot2 map for any arbitrary longitude range

Question: I'm making a map using ggplot and I want to be able to center the map around the Pacific Ocean while plotting points on the map.

It turns out I can do the map shifting by using the wrap option of maps::map. However, I'm not sure exactly how to shift the points to get them to match to my new shifted map. I found how to do that when I recreate a Pacific centered map with wrap(0, 360) but I'm not sure how to accomplish this for arbitrary shift units. I'm sure this is pretty straightforward but I can't seem to figure it out. Any ideas?
library(maps)
library(tidyverse)

# Pacific centered map
shift_value_1 <- 0
shift_value_2 <- 360

# Regular map, how about new values of shift_value_1 and shift_value_2? (e.g. -20, 325)
shift_value_1 <- -180
shift_value_2 <- 180

map_world_df <- map_data('world', wrap=c(shift_value_1, shift_value_2)) %>%
  dplyr::filter(region != "Antarctica")

country_shapes <-  geom_polygon(data = map_world_df,
                                aes(x=long, y = lat, group = group),
                                fill = "gainsboro",
                                color = "gainsboro",
                                size = 0.15)

nodes <- data.frame(names = c("A", "B", "C", "D"),
                    lat = c(64.220241, 10.278386, 64.710869, 19.432564),
                    lon = c(135.75572, 34.33927, -151.20003, -99.13323))

nodes$lon[nodes$lon <0] <- nodes$lon[nodes$lon <0] + (shift_value_1 + shift_value_2)

ggplot() +
  country_shapes +
  geom_point(data = nodes, aes(x=lon, y = lat))

I would love to be able to have a way of selecting arbitrary longitude ranges and shift the points accordingly, instead I get incorrectly placed points.
Answer: First of all, when using wrapping with two limits, you should make sure they add up correctly. Wrapping is not the same as just setting boundaries. For instance, in you're comment to the code you are asking the map to continue from -25 to 320, which is inconsistent. The resulting map will have some strange artefacts (more visible if you try larger errors, e.g. (-25, 150) ). You should always have shift_value2 - shift_value1 == 360, so for instance (-25, 335). Shifting longitudes by any other value will always give errors. You can add xlim=c(-25, 320) to the map() call if you wish, of course. But this should be done in a separate map() call (as explained in the documentation: xlim is applied before the wrapping, so combining them results in part of the map being dropped). So for a limited map, you should probably do
mymap <- map(wrap=c(-25, 335), fill=TRUE, plot=FALSE)
map(mymap, xlim=c(-25, 250),...)

But that is not necessary when using ggplot2 for plotting the map, because those map limits are applied after the call to map() and the wrapping.
Shifting an arbitrary point just means adding (or subtracting) 360 until it falls between the two values. In most cases, the following should work:
lon[lon < shift_value1] <- lon[lon < shift_value1] + 360
lon[lon > shift_value2] <- lon[lon > shift_value2] - 360

Comment: Thank you Alex! This is exactly what I needed.


Maven how to include a Java project as a dependency

Question: I have the following structure
<code>-->Project1 (Java SE Project)
---->src (My Java Code)

-->Project2 (Maven Project)
---->pom.xml
---->src
------->main
------->test
</code>
In Eclipse, I can configure the build path of the maven project to include Project1 and it runs fine in the IDE. However, I realized that it seems when I want to run it as a command
<code>mvn test-compile
</code>
the Project2 can't find the project. I am thinking I need to somehow reference it in my pom.xml (which then, I can ignore the step in Eclipse to configure it on the build path).
The error is
<code>[ERROR] package foo does not exist
</code>
The Project1 is not really being compiled into a .jar so that isn't the solution. I want the actual entire project as a reference somehow.
Comment: is it absolutely not an option to build jar from P1? Although it might be possible to do what you want, it would be a very dirty solution, esp for production use. Another approach would be to create a multi-module maven project and add P1 as a maven module.
PS: on a lower level, it would be possible to include the compiled classes of P1 into the classpath of P2
Comment: yes, after generating the jar and `mvn install`ing it, you should be able to reference it by its groupId & artifactId & version
Comment: I will try to generate a jar instead. So for my pom.xml, would I simply add a dependency to that jar?
Answer: Instead what I did was just convert the project1 to a maven project and in project2, added the dependency without needing to generate the jar. Seems like maven is smart enough to find the project and not look into the .m2 version (like if I did a mvn install).


my toast not working, strange

Question: my code:
int LastSet = 2;

        if(LastSet == '2'){
            Toast.makeText(PrintName.this, "Jack Johnson", Toast.LENGTH_LONG).show();
        }

I think I used the right syntax and logic? nothing appear..
Comment: Please post language and platform
Comment: 2 and '2' are not same in terms of data type because you're comparing an int ( which is LastSet variable ) to '2' (char type)

change that '2' to 2
Comment: try to use getBaseContext();

instead of PrintName.this;
Answer: You didn't specify which platform and programming language in the question (multiple platforms support toast notifications), so I'll assume Java on Android.  Look at the first two lines of your posted code:
int LastSet = 2;

if (LastSet == '2') {
    // Do something
}

You're setting LastSet to 2, which is an int, and then you're comparing it to the character '2', which is a completely different beast.  In Java, you can treat characters like ints for many purposes (including comparison with ints), but don't expect Java to treat 2 and '2' as the same thing because they aren't.  The number 2 is not the same as the character used to represent the digit 2.
Comment: just compare it to 2 not '2'... and please try to be more respectful
Comment: @Adam91 No, the solution is not to check against the string "2", because that's *a third thing*, different from either the number 2 or the character '2'.  Instead, check that `LastSet` is actually equal to the number 2.  There is rarely a good reason to compare an int to a char (and this is not such a situation).  Also, you can't write `LastSet = "2"` because the resulting program won't typecheck.  Or even better, just take out the if altogether - in the code you meant to write, the condition will always be true.
Comment: Just for the sake of being extremely explicit `LastSet == '2'` is wrong, `LastSet == "2"` is also wrong. `LastSet == 2` will work. However you don't need it, see above
Comment: LastSet = "2" like this?
Answer: Try this:
int LastSet = 2;

if(LastSet == 2){
    Toast.makeText(this, "Jack Johnson", Toast.LENGTH_LONG).show();
}

my toast not working, strange


Series of consecutive integers

Question: A series of 10584 consecutive integers has a sum that is a perfect cube. What is the smallest possible average of this series?
Answer: We are given $$a+(a+1)+...+(a+10583)=x^3$$
$$ (5292)(2a+10583)=x^3$$
Since $5292=3^3(14)^2$ we have $$2a+10583=14y^3$$
The above equation has no solution because of parity mismatch of the two sides.
Comment: OP has stated that the integers are consecutive not same.
Comment: Thanks for the comment, please check the edit
Comment: Yup  , nearly the same result as I got . Only much neater :)

Series of consecutive integers


2 websites under one domain

Question: In one domain I want 2 drupal it as follows:
www.example.com/index.php (not necessarily drupal), just a landing page
On the index page people have to chose between 2 Drupal Sites
www.example.com/salloon1/index.php
or
www.example.com/salloon2/index.php
Can I do this ass follow?
Step 1
Uploading all drupal files to www.example.com/saloon1/
Create Database saloon1_DB
settings.php pointing to saloon1_DB
Step 2
Uploading all drupal files to www.example.com/saloon2/
Create Database saloon2_DB
settings.php pointing to saloon2_DB
index.php
2 images: image 1 pointing to www.example.com/saloon1/index.php
          image 2 pointing to www.example.com/saloon2/index.php
Is this right or is there another solution?
Thanks guys in advance!!
Best regards,
Pieter-Jan Derks
Answer: One way to create multiple sites within one drupal instance is to use the domain access module.
https://www.drupal.org/project/domain
Using this you can create different sites with different domains on the same instance. You won't be able to do www.example.com/saloon1 and www.example.com/saloon2 (unless you use the subfolder domain module that extends domain access. Though I'm having trouble getting that module to work)
But you could do saloon1.example.com or saloon2.example.com or you could do saloon1.com and saloon2.com
On all content and blocks you'd be able to specify whether it's available to one domain, the other, or both. You could also restrict user privileges to one domain. You could also apply different themes to each domain.
Comment: Thanks fot the answer! It will help me and I am going tho think for the right solution!!

2 websites under one domain


Intercept URLs based on patterns with Chrome extension

Question: Scenario:

filter some redirect URLs based on patterns
Show a message stating that a URL was blocked due to a redirect
"unblock" a request in the same tab if a previous request was blocked

My list of URL patterns to use in webRequest.onBeforeRequest contains bit.ly. Then I hit the URL bit.ly/2qlHCT which redirects to google.com. In this case, I'll show a message like "request was blocked", but I don't want to actually block the request by returning { cancel: true } in onBeforeRequest's callback.
If the user tries to normally access google.com in the same tab, then I'll show a message "nothing was blocked".
So, this is similar what Adblock does when you add filters for a specific domain. Adblock's icon goes green if the domain is allowed, otherwise it turns red.
I know that I can use chrome.storage to save information about a blocked request, but how can I achieve that when a URL pattern doesn't match?
Comment: When it doesn't match the page is loaded normally so all you need is a listener for any event that occurs later like onHeadersReceived or webNavigation.onCompleted and so on.
Comment: I tried that, but I wrapped chrome.storage get and set methods into Promises to avoid chrome.runtime errors. So, I'm dealing with async functions inside a sync function (onBeforeRequest). Basically, what I want is to know if my listener  was called.
Comment: That doesn't matter for the idea I suggested. Anyway, without code this question is unlikely to be answered.
Comment: I still need to block the tab until the user starts a new navigation from a different domain. If _bit.ly/2qlHCT_ redirects to google.com, the tab should remain blocked if the user searches for something on Google.
Answer: The solution was really straightforward. I was using chrome.tabs.query to block tabs, but it's an async method and I needed a sync response. Using localStorage did the trick.
function blockRequest(tabId) {
  let tabs = localStorage.blocked_tabs;
  tabs = (tabs !== undefined) ? JSON.parse(tabs) : [];
  tabs = tabs.filter(function (item) {
    return item !== tabId;
  });
  localStorage.setItem('blocked_tabs', JSON.stringify(tabs));
}

Then, I just added the function blockRequest as listener to chrome.webRequest.onBeforeRequest and some filters.
chrome.webRequest.onBeforeRequest.addListener(blockRequest, { urls: filters, types: ['main_frame'] });


LilyPond - changing the output format and resolution of a preview image

Question: I use the folowing command to get preview images of my scores: lilypond -d preview -o preview/ my_file.ly
-d sets the output to the first line including titles
-o to select a different output directory

then I get three files:
my_file.preview.pdf
my_file.preview.eps
my_file.preview.png

the resolution of the png file is pretty low, while the resolution of the eps file is much higher and the pdfs resolution is somewhere in between.
Is it possible to:

only get png files as output?
and raise the resolution of those?

or would it be better practice to use some command line tool to just convert the eps files into png? (thinking of ImageMagicks convert or such)

I know that with the option:
 --png   you can generate pictures of each page, in PNG format.

and you can use:
-dresolution=110

to set the resolution, here to 110.
Answer: The PDF file is generated directly from the EPS file, as far as I know. EPS and PDF files generated by LilyPond don't actually have a resolution, because EPS is a vector image file format that relies on paths instead of a pixel grid to display graphics. These paths can be scaled to any size without quality loss regarding resolution. The PDF file just contains the EPS file and should hence have the same quality.
If you only want to generate a PNG file, you can do this using the option -fpng, which should suppress the output of an EPS or PDF.
You can increase the resolution by setting a higher number to the -dresolution option, such as -dresolution=300 or you use even a higher value like 600 or even 1200. The value represents dpi (dots per inch), and 300 dpi is a fairly good resolution for printed matter.
Your complete command would then be:
lilypond -fpng -dresolution=300 -dpreview -o preview/ my_file.ly
See the documentation for details.


Best options for KVM/qemu/libvirt VM migrations without shared storage

Question: My team has recently been tasked with improving the virtualization infrastructure at the company and one thing we're looking into doing is speeding up migrations.  We use local storage only on all VM Hosts.  One challenge is that we have thousands of hosts running different versions (sad face) of CentOS, KVM, libvirt, and qemu.  All guests are CentOS as well.  The lowest versions we're running are:

CentOS 5.6
Kernel 2.6.18
libvirt 1.0.0
qemu 1.1.0

The current tool used to do migrations essentially uses netcat to send over the disk image file(s) and runs the appropriate virsh commands to bring the guest up on the new host (in addition to some config management tweaking).
We're trying to find ways to reduce guest downtime and/or speed up the transfer itself by any creative means necessary.  We've spent several days gobbling up information from various corners of the interwebs, but are curious if the fine denizens of Serverfault can share some knowledge.  We can use shared storage temporarily as a middle man if need be, but aside from changing hypervisors or implementing shared storage for all hosts anything is fair game.
A few current working ideas we have to explore:

Snapshot the guest, copy base image to new host, shutdown guest, copy snapshot to new host, commit snapshot on new host, delete snapshot, start
Explore using shared storage in some way as a middle man temporarily.  Unsure at this point on details, using something like temporarily mounted glusterfs shares is an idea.
Copying the disk image files over while the VM is live, shutdown guest, then using rsync to copy the changed bits.

We're open to having different methods/tools that only support newer versions of kvm/qemu/libvirt but would like to be able to move the older stuff in the best way possible as well.
Hoping some folks can share some examples of what they've done!  Thanks.
Comment: Putting the VM's disk image on GlusterFS is a very bad idea, even temporarily. Try NFS instead (the latency shouldn't be too bad if it's on the same network)
Comment: Why not use virsh live migration with storage? I use something like: *virsh migrate --live --copy-storage-all --undefinesource --verbose --xml /tmp/host.xml host qemu+ssh://other/system*. You'll need to copy host.xml and define host and storage on the new system. It works on Centos7/6, have not tried it in 5.
Comment: Thanks for the migrate --live command, we'll look into that more.  One issue is that our hosts are on different subnets but we can create the idea of "clusters" of hosts that are on the same subnet.  This will be useful for overprovisioning and needing to move things off one host for sure.
Comment: Andre, can you elaborate on why using GlusterFS is a bad idea please?  Thanks!
Comment: live storage migrate will not work on the EL5 hosts
Comment: Why can't you "change hypervisors"? This is the easiest solution. Get everything onto CentOS 7 and you have built-in storage migration for free.
Comment: Getting everything onto CentOS 7 is in fact the goal.  We have thousands of hosts, many of which are on CentOS 5.  The idea going forward is we will do rolling upgrades on hosts as we get new hardware, but part of that is moving off the VM's before upgrading the hosts.  It's unfortunately not as easy as just upgrading a few boxes.
Answer: You can wait a little longer, for oVirt to support hyperconverged virtualization, and migrate over. You will have a free opensource KVM based virtualization system, with local storage as gluster volumes, and central management for all. A bit of yum-updatesd or puppet/ansible/whatever, and the version control over the hosts is also established.
Comment: Can you define a "little longer"? =)

I'm assuming there will be some gotchas here and requirements we may not have in place, so I'm hesitant to even consider banking on a solution like this.  Nevertheless, I'm interested in learning more!
Comment: This is the featurepage: http://www.ovirt.org/Features/GlusterFS-Hyperconvergence  The target is v3.6, which is the next version to come out, unless they decide to postpone for some reason. To get more details, email email@example.com, engineers and PMs are both watching and replying to the list


surroundContents() make changes `live`?

Question: Links to live examples @ jsfiddle & jsbin.
So this function:
function symbolize(e){
    var elements = e.childNodes; // text nodes are necessary!
    console.log(elements);
    for(var i=0; i < elements.length; i++){
        t = elements[i];
        var range = document.createRange(), offset = 0, length = t.nodeValue.length;
        while(offset < length){
            range.setStart(t, offset); range.setEnd(t, offset + 1);
            range.surroundContents(document.createElement('symbol'));
            offset++;
        }
    }
}

..should iterate over every letter and wrap it in a <symbol/> element. But it doesn't seem to be working.
So I added the console.log(); right after the *.childNodes have been fetched, but as you'll see in the example site above, the log contains 2 unexpected elements in front(!) of the array. And yeah, because of this, I have a feeling that surroundContents(); make the changes live(!). couldn't find any reference on this though
One of the elements is an empty Text node, the other is my <symbol/>. But yeah, this is totally unexpected result and messes up the rest of the function.
What could be wrong with it?
Thanks in advance!
Update
Oh, looks like the elements are added on Chrome, Firefox doesn't add the elements, but still halts the function.
Comment: How is jsfiddle too much of a hassle? I love it!
Comment: @Juan, it's slow over here (and no, the internet works flawlessly). Plus I tried copying the functions, and `window.onload` didn't work over at Fiddle's place.
Comment: Yeah, I tried creating it for you but jsfiddle was dead. In any case, I think the question is answered.
Answer: Element.childNodes is indeed a live list , it could not be otherwise (that would mean an incorrect list of nodes). The easiest solution is to freeze (make a copy of) it before you mess with it (by surrounding existing ranges).
var elements = Array.prototype.slice.call(e.childNodes, 0);

https://developer.mozilla.org/en/childNodes it's of type NodeList
https://developer.mozilla.org/En/DOM/NodeList those are live lists
Comment: Ah, would be awesome if browser log would display some kind of identifier next to an element if it's `live`. Thanks!
Comment: I disagree with you.True that it's not obvious that document.getElementsByTagName('p') returns a live list. However, childNodes would not make sense if it were not live. Most would consider it a bug that childNodes does not update correctly as you insert new children.

surroundContents() make changes `live`?


Equivalent of Ahead Of Time Compilation in React

Question: Like we have AOT in angular where the HTML and typescript code is converted into efficient JS code during the build phase which makes the app load faster.
Do we have something similar in React?
Comment: Isn't it Server Side Rendering you're looking for?
Answer: There's just the Typescript or Babel transpilation, which transforms JSX code into common JavaScript.
So for example the code
import React from 'react';
import ReactDOM from 'react-dom';

const App = () => {
    return
Hello World

}

ReactDOM.render(
    <App />,
    document.getElementById('root')
)

is compiled to
import React from 'react';
import ReactDOM from 'react-dom';
var App = function () {
    return React.createElement("h1", null, "Hello World");
};
ReactDOM.render(React.createElement(App, null), document.getElementById('root'));

So basically
Hello World
 into React.createElement("h1", null, "Hello World");. That's all.
You could add more stuff to your Babel/Typescript-Compiler (like presets and plugins, eg. babel-plugin-relay), but over all it's nothing more than a simple transpilation step.
See also:

JSX-Concept
Babel Compiler
Comment: I always make a difference between transpilation and compilation, but maybe you're right. I removed the paragraph.
Comment: I believe it's exactly AoT. If it was JiT we would have browser transpiling JSX.


What is the difference between Cm7 and Eb/C?

Question: The other day I was looking at the song "On Green Dolphin Street". For the first line there have been the following chord-symbols:
Cmaj9 - Eb/C - D/C - Db/C
As far as I know, the slash-chords are meant to be read this way:
[chord]/[basstone]
So the second chord (Eb/C) is an Eb-major triad with a C in the bass (C - Eb - G - Bb). That are the same notes a Cm7 is made of.
So if my previous suggestions are correct, the question is where the difference between these two notations is. Should I approach these symbols differently?
First I thought that for the Cm7 I would use the c-minor blues scale for improvising and for the Eb/C I would use the Eb-major blues scale. But they have the same set of notes, so what's the difference?
Comment: Those chords constitute nearly the first line, not the first bar!
Answer: C - E♭ - G - B♭ = Cm7.
E♭ - G - B♭ - C = E♭6.
Cm blues scale uses the same notes as E♭maj blues scale.
So, either (or both) as they use the same notes, will obviously work! As will, in fact, all the rest of the notes in the chromatic scale, if you know how and where they'll go!!
Green Dolphin Street uses a sort of C pedal effect, so obviously in this tune, C will be regarded as the root rather than Eb (or any other). Or, looking at it another way, there's a chromatic drop from E♭ back down to the root, C. So it really doesn't make any difference, only where in the bar you put the notes you feel you want to emphasise - for starters, beat one - but not necessarily...
Comment: Slash chords basically tell which note is underneath the others - often it shows an inversion, but sometimes, as here, it isn't quite the same, and others, the bass note doesn't really belong to the chord it's slashed with. Context!
Comment: Okay, as i understand your answere, in this case it makes no difference. But does this apply to any case where slash-chords appear? Or does it depend on the context?
Comment: To be exact,  C natural minor uses same notes as Eb Major :-)
Comment: @CarlWitthoft - and also to be exact, Cm blues uses the same notes as Eb maj blues. C D Eb F Gb G Bb in each. Take more time with comments, please!
Comment: Fair enough - tho' I'd expect to find a  C-harmonic minor blues sometimes.
Comment: @CarlWitthoft - in which case, why would you quote natural minor? Too much computer stuff again?
Answer: I read the "Eb/C - D/C - Db/C" like, "bass stays at C and piano or guitar or whatever can play these chromatically descending major chords, in order to produce essentially the kind of barebones accompaniment that the composer or arranger had in mind."
Eb/C creates a Cm7, but spelling out the Eb, D and Db is a helpful hint for seeing how you can or perhaps even should look at it. It might also make some players play the chords with a bit more open voicings, not cramming all four notes of the Cm7 together inside one octave, but dropping the C to bass.
You could also take advantage of the chords written as Eb - D - Db by outlining or arpeggiating those triads in your solo? Why not even dissect the Cmaj9 as something like Em/C or Em7/C or G6/C? More possibilities for outlining chords as arpeggios.
Chord symbols should be seen as guidelines for accompaniment, not as theoretic harmony specifications for feeding into a musician-guidance autopilot computer that calculates the "correct" scales to use. :)
You can read and write chord symbols in many different ways, like:

a pianist can play the thing before the slash with her right hand, and the thing after the slash with her left hand
guitarist plays the thing before the slash, bassist plays the thing after the slash
that's how the composer or arranger thought of it, separating a bass movement (or pedal tone) from stuff happening higher up

As a player and improviser you're supposed to understand the bigger picture, i.e. what it all sounds like when put together as accompaniment to the melody. Make up your own mind as to where the harmony could lean on at each point, and where it seems like going to. I kind of like the attitude that you shouldn't try to spell everything out and spoon-feed particular exact harmonies to jazz players who are supposed to be able to improvise their own arrangements on the fly. How often is it actually necessary to write a maj9, and a maj7 wouldn't be enough to deliver the essential idea, letting the players add 9ths and whatever seasoning they want? Isn't that like listing each individual note where a guitarist should use vibrato, and if he should pick with an upstroke or downstroke? :)


Eliminar uma chave de todos os arrays caso esteja nula ou em branco

Question:
Array
(
    [0] => Array
        (
            [Foto] => imagem.jpg
            [Código] => 311102
            [Tipo] => Meu tipo
            [Cidade] => Araçatuba
            [Valor] =>
            [Mais Info] => Todos juntos
        )

    [1] => Array
        (
            [Foto] => imagem2.jpg
            [Código] => 3111022
            [Tipo] => Meu tipo2
            [Cidade] => Araçatuba2
            [Valor] =>
            [Mais Info] => Todos juntos2
        )

    [2] => Array
        (
            [Foto] => imagem3.jpg
            [Código] => 3111023
            [Tipo] => Meu tipo3
            [Cidade] =>
            [Valor] =>
            [Mais Info] => Todos juntos3
        )
)

Gostaria que a saída fosse assim, elimiando o campo valor pq em todos os subarray esta em branco ou nulo

Array
(
    [0] => Array
        (
            [Foto] => imagem.jpg
            [Código] => 311102
            [Tipo] => Meu tipo
            [Cidade] => Araçatuba
            [Mais Info] => Todos juntos
        )

    [1] => Array
        (
            [Foto] => imagem2.jpg
            [Código] => 3111022
            [Tipo] => Meu tipo2
            [Cidade] => Araçatuba2
            [Mais Info] => Todos juntos2
        )

    [2] => Array
        (
            [Foto] => imagem3.jpg
            [Código] => 3111023
            [Tipo] => Meu tipo3
            [Cidade] =>
            [Mais Info] => Todos juntos3
        )
)

alguém já passou por isso?
marco
Answer: Galera abei tentando aqui e consegui
supomos que o $arr_comp é o meu array acima citado.

        foreach($arr_comp as $cha => $val){
            foreach($val as $cha2 => $val2){
                $arr_new[$cha2][] = $val2;
            }
        }

        unset($arr_comp);
        foreach($arr_new as $cha => $val){
            if (count(array_filter($val)) > 0){
                foreach($val as $cha2 => $val2){
                    $arr_comp[$cha2][$cha] = ($val2 == '' ? '-' : $val2);
                }
            }
        }

Valeu..


Javascript rotate on mouse-down drag

Question: Im trying to make a spinning wheel rotate when dragging the mouse on it. The wheel is formed by 3 pieces so I mapped each image independently in order to target the section of the wheel which I want to rotate. Right now it is working pretty good. The only problem being that im using event.clientX for the rotation parameter and it can be kinda random at times, sometimes the wheel moves to a random angle on start but for the most part it works. I would just like a formula to feed a better rotation parameter to my script. Here is the code I currently have:
var isDragging      = false;

var innerWheelActive    = false;
var middleWheelActive   = false;
var outerWheelActive    = false;

$(document).ready(function() {

    /*------------------------------------------*/

    $("#mapping map #middleArea").mousedown(function() {
            isDragging  = true;
            middleWheelActive   = true;

            return false;
    });

    $("#mapping map #innerArea").mousedown(function() {
            isDragging  = true;
            innerWheelActive    = true;

            return false;
    });

    $("#mapping map #outerArea").mousedown(function() {
            isDragging  = true;
            outerWheelActive    = true;

            return false;
    });

    $(document).mousemove(function(event) {
        if (isDragging) {

            var rotateCSS = 'rotate(' + event.clientX + 'deg)';
            if(innerWheelActive)
                $('#innerWheel img').css({ '-webkit-transform': rotateCSS });
            else if(middleWheelActive)
                $('#middleWheel img').css({ '-webkit-transform': rotateCSS });
            else if(outerWheelActive)
                $('#outerWheel img').css({ '-webkit-transform': rotateCSS });

            return false;
        }
    });

    $(document).mouseup(function() {
        if (isDragging){
            console.log('stopped');
            isDragging  = false;
            innerWheelActive    = false;
            middleWheelActive   = false;
            outerWheelActive    = false;
            return false;
        }
    });

});

Comment: with regards to your edit, it may work better if you spell "dragging" correctly -- "gragging" in `mouseup`.
Comment: [Does it help you](http://ammarshaikh.wordpress.com/2011/12/20/drag-object-in-circular-motion-using-jquery-ui-draggable/)
Answer: Try to add event.preventDefault and event.stopPorpagation in your callback function :
$('img').draggable({
    drag: function(event, ui){
        var rotateCSS = 'rotate(' + ui.position.left + 'deg)';
        $(this).css({ '-webkit-transform': rotateCSS });
        event.preventDefault();
        event.stopPropagation();
    }
});

Comment: tried it, it did two things, 1st it moved it to some random point but it remained there, 2nd it no longer rotates on drag just on click :( Im guessing that preventing default stops the drag tracking?
Answer: Your logic has a problem, it relies solely on x ordinate which does not always increase when you rotate things.
Try this instead. It calculates the distance moved my mouse from initial point and thus considers both the x and y coordinates. It should work fine.
function getDistance(x1,y1,x2,y2){
    return Math.sqrt((x1-x2) * (x1-x2) + (y2-y1) * (y2-y1));
}
var div = $("#mydiv");
var rotation = 0;
var isDragging = false;
div.mousedown(function(event) {
    isDragging = true;
    lastX = event.clientX;
    lastY = event.clientY;
}).mouseup(function(event) {
    isDragging = false;
}).mousemove(function(event) {
    if (isDragging) {
        var curX = event.clientX;
        var curY = event.clientY;
        rotation += getDistance(curX,curY,lastX,lastY);
        var rotateCSS = 'rotate(' + rotation + 'deg)';
        $(this).css({
            '-webkit-transform': rotateCSS
        });
        lastX = curX;
        lastY = curY;
    }
})

Demo
Comment: It should, as its jQuery. Why dont you test it ?
Comment: I tested it on desktop and it was really bad, the wheel would move but in a very choppy way. I just edited my main post so you can see what I currently have which works at the moment it just needs some refining calculating the rotation. I tried your post with last and current coordinates and like I said it just didnt work too well.
Comment: @CarlosR.Batista, I've edited my code. It works smoothly as you wanted.
Comment: it spins to the right but it refuses to spin to the left. I noticed that if I remove the last two lines of code in your code and it does spin back and forth but when I drag the mouse back the point where I first clicked before dragging it reverts the direction of the rotation for some reason. Im thinking this is happening because the calculated distance is always positive? So when I go back to point 0,0 which instead of getting negatives values it keeps throwing positive ones. Maybe the distance script needs to supply a negative value when you counter rotate? I dont know im still stuck
Comment: @CarlosR.Batista, distances are never negative. Finding a way to predict the direction of mouse movement is little bit tough and tricky too. Cant we constraint the mouse movement ?
Comment: ya i know distances are supposed to be positive, it just doesnt help me if it always is. Its a spinning wheel so I have to be able to spin right and also left.
Comment: I cannot think of a way by which I can predict the direction of mouse movement.Suppose if we assume 4 quadrants in my circle (0,0 as center of circle).Now,clientX & clientY decreases in first quadrant (for ACW direction but clientX and clienty decreases in third quandrant (for CW direction).Thus, by looking at point, we cannot predict the direction of mouse movement. But yes, if you can constraint the mouse movement to first quadrant only, we can predict the direction.In nutshell,if you say that dragging can only be start with the place where `hello` is written, we can predict direction.
Comment: I can now if the mouse is moving the left by simply comparing currentX and previousX. Depending on whether one is greater than the other it can definitely tell me which way the mouse is moving, however when I try to minus that distance to rotate it just doesnt look good. I guess it needs more math involved in some way.
Comment: If you move mouse from up to down, there's no change in X position . Also, if currentX is greater than previousX, it will be clockwise when moving on top of circle, but anticlockwise at bottom of circle :) Think again closely. Also, we need both X and Y position and too is not enough here
Comment: well i dont care about rotation when y changes, i only care about x now that i think about it. So ignoring y is a non-issue.
Comment: @CarlosR.Batista, Read again ` if currentX is greater than previousX, it will be clockwise when moving on top of circle, but anticlockwise at bottom of circle`.Also, see [this](http://jsfiddle.net/jashwant/AM5tU/1/), its exactly as you asked (ignoring Y) but it wont work when you move mouse up to down and will work in reverse direction when you move mouse at bottom of circle. I hope this should clear you logic
Comment: thats the thing though, I never have to interact with the bottom area of the circle only the top.
Comment: Doesn't properly work. Lacks the math (it is only partial => this is why is only spins to the right)
Comment: @Symba, yeah. It doesnt properly work. As I've mentioned in comments that it's not possible to predict the direction by x and y position only.

Javascript rotate on mouse-down drag


What are the differences between the alpine skiing events?

Question: The Olympics has five different alpine (downhill) skiing events:

Downhill
Slalom
Giant Slalom
Super Giant Slalom (Super-G)
Super Combined

What are the differences between these different events?  I know that the number and spacing of the gates are different. Is that all it is, or is there more to it than that?
Answer: There some more differences:

Slalom and giant slalow are technical events, super-G and downhill are speed events. Super combined, as the name implies, combines runs of slalom and downhill.
Downhill and super-G events have one run, slalom and giant slalom events have two runs - different courses on the same ski run.
Even the skis are different. Slalom skis are shorter and narrower, the better to manoeuvre quickly through gates which are close together without catching a tip on a gate. Giant slalom skis are longer and wider, but still not as long and wide as downhill skis.
Slalom skiers need more protection - helmets, face guards, hand guards, and shin pads are compulsory. The extra equipment lets slalom skiers physically knock the poles out of the way as they pass, a special technique known as blocking.
Comment: It should also be noted that slalom and giant slalom events combine the times of the 2 runs (unlike other events where they only take your best run and throw away your worst runs).
Answer: The main differences are about number of gates, distance from each gate, vertical drop and length of the course.

Downhill
Has the maximun of the lenght and the maximun distance from each gate. It runs on a single manche. It has the maximun speed.

Super Giant Slalom (Super-G)
It runs on a single manche.

Giant Slalom
The vertical drop for a GS course must be 250–450 metres (men), 250–400 m (women). The number of gates is 56–70 (men) and 46–58 (women). It runs on two manches, times of both runs is added up.

Slalom
Has the minimum of the length and the minimum distance from each gate. The course has 55-75 gates (men) and 40-60 (women). The vertical drop is 180-220 m (men) and slightly less for women. It runs on two manches, times of both runs are added up. It has the minimum value of speed.

Super Combined
It is a "small" downhill + a manche of slalom


Lilypond tuplets

Question:
As can be seen in the image, some composers mix the note types used in tuplets.  In this case, there are two eighths and a half note (equal to 4 eighths).  The total duration is 6 eighths in triplet time.  Thus, ignoring the last four eighth notes in the bar, the first part of the phrase could be written in Lilypond as:
\tuplet 3/2 {e'8 b8 g8} \tuplet 3/2 {g8 g8 g8}

This, however, changes the phrasing, displaying it as two sets of triplets.  Is there a way for Lilypond to produce the output as in the display?
Answer: Of course there is. Why don't you just write what you see? \tuplet 3/2 { e'8 b8 g2 } will do the job and give the following result:
Answer: Some more details:
Tuplets in Lilypond are far more powerful than they are in most other notation software. A tuplet in Lilypond is essentially nothing but music with a scaling factor and a bracket above. If you set the property tupletSpan or use the optional argument \tuplet ratio duration music Lilypond will automatically split the tuplet into multiple tuplets of given duration. If you do not you can create tuplets of arbitrary dimensions such as this:
\tuplet 3/2 {
  c' d' e' f' g' a' | g' f' e' d' c' b | c'1.
}

Also you can do any sort of tuplets crossing measures, and even do tuplets with irregular duration:
{
  c'4 d' \tuplet 3/2 e' d' \tuplet 3/2 c'8 |
  d'4 \tuplet 3/2 e'2 d'8 c' \tuplet 3/2 d'4
}

Combine this with irregular time signatures, and you can do stuff like this:
\new RhythmicStaff {
  \numericTimeSignature
  \time 4/4
  \repeat unfold 4 { 8-> 8 }
  \tuplet 3/2 4 \repeat unfold 4 { 8-> 8 8 } |
  \time 4/6
  \tuplet 3/2 4*2/3 \repeat unfold 4 { 8-> 8 }
  \time 3/6
  \tuplet 3/2 4*2/3 \repeat unfold 3 { 8-> 8 }
  \time 6/12
  \tuplet 3/2 4 \repeat unfold 2 { 8-> 8 8 }
  \time 4/4
  \tuplet 3/2 4 \repeat unfold 4 { 8-> 8 8 }
  \repeat unfold 4 { 8-> 8 }
}

So in Lilypond you can have a Tuplet do quite arbitrary things, and doing what is seen in this excerpt is simply done by entering what you see and slapping a Tuplet onto it.
But even more even if you take a different piece of software like MuseScore (where a tuplet is music made up of n units taking the space of m units (where a unit is a power of 2 division)), which does not allow everything Lilypond would allow, will have no problems creating a tuplet such as the one you've shown.

Lilypond tuplets


gevent does not install properly on Ubuntu

Question: I want to experiment with gevent, but after installing it I can't load any gevent module.
The installation steps are:
sudo apt-get install libevent-dev
sudo pip install greenlet
sudo pip install gevent

The environment setup is Ubuntu 10.10 x86_64 GNU/Linux.
When I try to do a simple test, I get:
>>> import gevent
>>> from gevent import socket
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name socket

I suspect the installation not doing what it should, but I'm not sure what wrong.
Answer: On Ubuntu 10.04 with python 2.6 I had to do:

apt-get install libevent-dev
apt-get install python-all-dev
easy_install greenlet
easy_install gevent

By the way, nice tutorial on Gevent: http://sdiehl.github.com/gevent-tutorial/
Answer: In Ubuntu 10.10 (and later), gevent (and dependencies) is packaged in the Ubuntu repositories.
on 11.04:
$ sudo apt-get install python-gevent
...
$ python
corey@lenovo:~$ python
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gevent
>>> from gevent import socket
>>> print gevent.__version__
0.13.0

Comment: That's right, though it's not the latest. The repository's v0.13.0 dates from July 2010... a year old.
Answer: I managed to succeed to install in a "python way" using pip. Here is what I did:
I read somewhere that it seems like Ubuntu's setup tools are broken. When you want to install a package, it reports

UserWarning: Unbuilt egg for setuptools [unknown version] (/usr/lib/python2.6/dist-packages)

These commands repare the setup tools:
sudo rm -rf /usr/lib/python2.6/dist-packages/setuptools.egg-info/
sudo apt-get install --reinstall python-setuptools

After this, I tried to reinstall the two packages with pip's --upgrade argument. It didn't help, but I tried easy_install and it worked. I had tried it before pip, but the broken setup tools prevented it from working.
sudo easy_install greenlet
sudo easy_install gevent

There you go, with the latest version (0.13.6 as of now).
Answer: Tried what zzart posted, but still got an error on Ubuntu Trusty Tahr (14.04):
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2583, in scan_list
    "Expected ',' or end-of-list in",line,"at",line[p:]
ValueError: ("Expected ',' or end-of-list in", "cffi >= 1.11.5 ; sys_platform == 'win32' and platform_python_implementation == 'CPython'", 'at', " ; sys_platform == 'win32' and platform_python_implementation == 'CPython'")

This fixed it:
sudo pip install --upgrade setuptools pip
sudo easy_install gevent


Is there a way to solve congruences?

Question: Ofter i come across things like this:
$$7^x\equiv 1 \pmod{180} $$
$$x^3\equiv7 \pmod{13}$$
Are there easy ways to solve in general these kinds of congruences:
$$a^x\equiv b \pmod{n} $$
$$x^a\equiv b \pmod{n}$$
For example $7^x\equiv 1 \pmod{180} $ has as solution $x\equiv 0 \pmod{12}$, I checked with Wolfram. But how can I do these?
Thank you for your time :)
Comment: Please ask only one question per post. Also it is better not to give specific instances of general problems else you'll get answers that solve only the specific instance. I suggest you read the literature linked in the dupes and then if you have further questions about the known algorithms then post further questions on each.
Comment: this could be considered two questions, one where $x$ is exponent and one where $x$ is base
Comment: @J.W.Tanner it's like saying that a problem that has 2 or $x$ requests must be considered as $x$ questions.
Answer: Hint
Using http://mathworld.wolfram.com/CarmichaelFunction.html
$\lambda(180)=12$
So, $x$ must divide $12$
$7^3\equiv-17\pmod{180}$
$7^4\equiv-17\cdot7\not\equiv1$
$7°6=(7^3)^2\equiv(-17)^2\not\equiv1$
Comment: Beautiful, is there a way in the more general case? +1
Answer: In view of $a^x\equiv b\mod n$, the problem is to solve the discrete log problem in the ring ${\Bbb Z}_n$.
More specifically, given a group $G$ and $a,b\in G$, solving $a^x=b$ for some integer $x$ is the discrete log problem for the group $G$. There is no efficient method for solving it. Number-theoretic cryptography relies on it.
Answer: Another way
As $180=5\cdot36$
$7\equiv2\pmod5,7^2\equiv2^2\not\equiv1,7^4\equiv1$
$7^x=(1+6)^x\equiv1+6x\pmod{36}$
So, $6$ divides $x$
For $\pmod{180}, x=[4,6]=?$
Comment: The question is not about this *specifc case*, but about *general* methods.

Is there a way to solve congruences?


Dependency Injection in Laravel 4 controllers instance all of the objects

Question: I want to make testable code in Laravel 4 controllers. I know DI(Dependency Injection), and I know testable code may look like:
class UsersController extends BaseController
{
    public function __construct(User $user, Notice $notice)
    {
        $this->user = $user;
        $this->notice = $notice;
    }

    public function getIndex()
    {
        ...
        $this->user
        ...
        $this->notice
        ...
    }

    public function getPage()
    {
        ...
        $this->user
        ...
    }
}

As you can see I injected two objects into the controller.
For getIndex function, it's perfect, I use two object in it.
But please noted that for getPage function, I just use $this->user, I don't need the $this->notice.
However, the $this->notice object was instantiated already, that's really not good.
Is there a better way to not instance all of the objects?
Answer: In most cases I would argue this is premature optimization because seriously the overhead is probably so negligible you are just wasting your time.
If this is a performance issue in your application, then you have the following solutions:

lazy injection. I don't know if Laravel DI container offers this feature, but the idea is to inject a Proxy that will load the service lazily. If the service is not used, it's not loaded.
separate controllers. You can split your controller in two so that you only inject the services you really use. Sometimes the fact that some dependencies are not used is a sign that the class/controller does too many things, so splitting it is anyway a good thing.

But you should probably not care about creating an injecting an object you don't use, because you will only save 0.00001 second and nobody will see the difference.
Comment: If you structure your code right in laravel then yes, lazy loading is possible. You just need to explicitly instantiate your files needed at runtime in the start global.php then load others with the normal namespacing call. also, for testing I suggest putting custom classes in the composer.json files as instatiating them in global wont intialize them in time for the test run time
Answer: Laravel 5 is going to have controller method injection.
http://laravel.com/docs/master/releases#laravel-5.0
Comment: It's called Laravel 5 now, and here's a good vid describing the new method injection: https://laracasts.com/series/whats-new-in-laravel-5/episodes/2
Comment: Ok. I amended my answer.


Input attributes not visible via onclick event

Question: I have a simple radio button form in jade/pug view like this:
form
  input(type='radio',id="0", group="group0", value="some string" my_prop="hello", onclick='radioClick(this)')

In my js script, I have defined radioClick function like this:
function radioClick(e){
  console.log(e)
  console.log(e.my_prop)
  console.log(e.group)
  console.log(e.type)
  console.log(e.id)
}

The output looks like this:
<input type="radio" my_prop="hello" group="0" id="0" value="some string" onclick="radioClick(this)">
undefined //<--- Why are these undefined?
undefined //<--- Why are these undefined?
radio
0

Why are the attributes group and my_prop undefined? How can I access them when the event onclick is triggered?
Answer: You can use getAttribute() and place the desired attribute in the string.

function radioClick(e){
  console.log(e.getAttribute('my_prop'));
  console.log(e.getAttribute('group'));
  console.log(e.getAttribute('type'));
  console.log(e.getAttribute('id'));
}
<input type="radio" my_prop="hello" group="0" id="0" value="some string" onclick="radioClick(this)">
Comment: That works! why are some attributes accessible and others not?


Meaning of ;-symbol in math

Question: Learning about the formal definition of the derivativ, I am asked to find the derivative at the indicated point from the graph of the function.
However in the following problems, I do not understand what the ";"-symbol mean
f(x)=5;x=1
f(x)=4x-3;x=-1
Of course the meaning of ; is something I should remember, but any help would be much appreciated as google search and lists of mathematical symbols didn't help!
Comment: My previous guess at the meaning was wrong, so I deleted that comment.  The question is asking you to calculate the derivative of the function that's written before the semicolon and then to evaluate that derivative at the value of $x$ that's written after the semicolon.
Comment: Following @AndreasBlass I suspect that the ";" is not mathematical but belongs to the "surrounding" natural language
Comment: Where did you find such a notation...?
Answer: It seems that it want the derivative of the given function at the point with a given $x$. So $f(x)=5 ; x=1$ means $f'(1)$ where $f'$ is the derivative of $f(x)=5$, and $f(x)=4x-3 ; x=-1$ means $f'(-1)$ where $f'$ is the derivative of $f(x)=4x-3$.
So,here, the symbol ''$;$'' is not really a mathematical symbol, but simply a punctuation mark.

Meaning of ;-symbol in math


Establish SSH connection when two servers all behind firewalls both don't accept incoming connections

Question: Here is ths network diagram
<code>
|--local network A--|                                                   |--local network B--|
|      Server A     | firewall A |-- ipv6 only internet -- | firewall B |      Server B     |
|-------------------|                                                   |-------------------|
</code>
Both Firewall A and B are only allow outcoming connections and don't accept incoming connections. Both server runs Ubuntu 18.
Is that possible to Establish a SSH connection from A to B or B to A? I want the two server clould talk to each other directly.
If not, I have a server C on Internet could accept incoming connections from both server A and B, but server C have limited bandwith, is there a way to let server C help A and B establish a SSH connection without relaying by C?
I've Goolged about VPN. As far as I know it also requires at least one server could accept incoming connections, or relay by a Server C. I hope they can communicate directly.
Comment: is using ngrok an option? https://ngrok.com
Comment: Just read the introduction about ngrok. It might not an option. I think it will transmit all traffic through a public server? I need transport a lot of data (hundreads GB) as fast as posibble. @BANJOSA
Comment: I understand, and at the end of the day this also poses a security risk, since you are sending your data through an "unknown" server.
Answer: If you need to transfer a lot of data, i would suggest using Syncthing.
By default it will use public relays if no direct connectivity between hosts. Protocol and transfer are encrypted, but if you're still worried, you could run your own relay on C, and setting it on A and B.
Answer: To get A or B to see each other's LANs, opening the firewall to allowed traffic is the easy way. If your organization has a use case for connecting these networks, the firewall policy should be changed.
Could be implemented in several ways: a VPN (IPSec, OpenVPN, WireGuard), some SD-WAN controller that manages VPN links for you, or perhaps direct from the Internet to the applications if they are encrypted and hardened (https web apps).
Both connecting to C grants them access to C's network. Think connecting to a cloud. However, you requested direct from A to B. Also, infrastructure hosts in using C as a hub node.


Exclude content referenced by content whose author is current logged in user

Question: I try to solve question - answer scenario with views.
2 content types: question and answer. (answer is connected to question by entityreference)
User can check themes of interests (taxonomy) in profile and a view is displayed in his profile with relevant questions. Creating this view was simple: I made a user view with UID as contextual filter and added a entity reference relationship and taxonomy term:content with term. Then it is easy to display list of relevant questions.
Problem: I want to filter out questions already answered by current user. In other words - to filter out all questions which are referenced from answer content type and answer's author is current user.
I tried to add new relationship - content referencing content from xy field, tried to add contextual filter - node author. None of this seems to work.
EDIT: adding contextual filter user:author with excluded option works ONLY if there is reference (answer) made by current user. If other content(answer) by other user is referencing the content(question), it shows the question in the list again. Of course, because context filter only removes current user's nodes.
I need views to exclude content by other users as well. Does someone know answer to this? thank you
Answer: Try this,

Add a contextual filter of Content: Author uid.
Under "WHEN THE FILTER VALUE IS NOT AVAILABLE", select "provide default value", and then select "User ID from logged in user".
Under MORE, select "Exclude".
Save.

P.S. This should work. Haven't tried myself.
Comment: Hi, I tried it before. Problem is that it works if there is only one user with answer. If more than 1 content is referencing back (answers from more users) then it shows again in the list.


widgetTests console output: What does the number after the `~` refer to?

Question: We're running widgetTests and I'm seeing output like
        :
00:08 +76: /Users/<path>/sliver_app_bar_test.dart: <test description>
00:08 +77 ~1: /Users/<path>/sliver_app_bar_test.dart: <test description>
00:08 +78 ~2: /Users/<path>/sliver_app_bar_test.dart: <test description>
00:08 +79 ~3: /Users/<path>/sliver_app_bar_test.dart: <test description>
00:08 +80 ~3: /Users/<path>/sliver_app_bar_test.dart: <test description>
        :
00:33 +386 ~3: All tests passed!

The number after the + is the test counter. What's the number after the ~ refer to?
Answer: It's the number of skipped tests.


How to prove the preimage of a sequentially-closed set under a linear mapping is also sequentially-closed?

Question: Preimage is defined as $X = \{x \in \mathbb{R}^n:Ax \in S\}$, where $A$ is a linear mapping $A \in \mathbb{R}^{m,n}$, and $S \subseteq \mathbb{R}^m$ is a sequentially-closed set.
The definition of sequential-closedness is that $S$ is sequentially-closed iff every convergent sequence in $S$ has its limit in $S$.
What I tried:
Suppose $X$ has a convergent sequence whose limit is not in $X$, then since the mapped sequence is in S, whose limit is not in $S$ (1). This is contradicted to what we assume that $S$ is a closed set, so all convergent sequences in $X$ has their limits in $X$, which proves that $X$ is a closed set.
Now my question is how can I prove (1) is true?
Comment: Do you know that linear maps are continuous? This is the key.
Comment: @Crostul Thank you. I have updated the question.
Comment: @Crostul Thanks! Then why the linear mapping of a closed set is not always a closed set?
Answer: Suppose $\{x_k\}_{k\in\mathbb{N}}$ is a sequence in $X$, converging to $x\in X^c$. We will show that $Ax_k$ converges to $Ax$. Let $\{e_1,..., e_n\}$ be the standard basis for $\mathbb{R}^n$ and $\|\cdot\|$ denote the Euclidian norm, then:
$$\|Ax_k-Ax\|=\|A(x_k-x)\|=\|\sum_{i=1}^n(x_{ik}-x_i)Ae_i\| \leq \sum_{i=1}^n|x_{ik}-x_i|\|Ae_i\| \leq \max_i\|Ae_i\|\sum_{i=1}^n|x_{ik}-x_i|$$
$$\leq \max_i\|Ae_i\| \: \sqrt{n} \: \|x_k-x\|$$
where the last line follows from Cauchy-Schwarz inequality. Hence $\|Ax_k-Ax\| \rightarrow0$. Since $Ax \in S^c$, $\{Ax_k\}_{k\in\mathbb{N}}$ is a sequence in $S$, whose limit is not in $S$
Answer: You attempted a proof by contradiction. There's nothing wrong with taking this approach.
You correctly started from a sequence $x = (x_1, x_2, \dots)$ in $X$, which you assumed to be convergent to a limit, call it $L$, that does not lie in $X$. So far, so good. Let's stop for a brief moment to make a note of the assumption that we are making, that
$$
L\text{ does not lie in }X. \tag{*}\label{star}
$$
You correctly realized that the contradiction we aspire to arrive at, is that the sequence $Ax = (Ax_1, Ax_2, \dots)$ is a convergent sequence in $S$, whose limit does not lie in $S$.
You couldn't figure out how to show that $Ax$'s limit does not lie in $S$. However, you seem to have missed the point that you additionally need to show that $Ax$ is convergent.
The reason why $Ax$ is convergent derives from the fact that the mapping $f:\mathbb{R}^n \rightarrow \mathbb{R}^m$ that assigns to every $v \in \mathbb{R}^n$ the value $f(v) := Av$, is continuous (it is continuous since it is linear, as all linear mappings are continuous). In fact, $Ax$'s limit is $AL$:
$$
AL = f(L) = f\left(\lim_{n\rightarrow\infty} x_n\right) \overset{\text{continuity}}{=} \lim_{n\rightarrow\infty} f(x_n) = \lim_{n\rightarrow\infty} Ax_n.
$$
So we wish to show that $AL$ does not lie in $S$, and, indeed, it can't lie in $S$, since, if it did, than $L$ would have been in $S$'s preimage, $X$, in contradiction to assumption \eqref{star}.
Comment: Thanks a lot! My confusion about this continuous mapping theorem is why, for a closed set $S$ and $A$ is a linear mapping, $B = \{Ax : x \in S\}$ is not always a closed set?
Comment: Aren't those the same problems we are solving with image and preimage?


How to recover files to staging area after commit?

Question: Using GitBash, after I used the command git commit -m "some message" the files on staging area disappeared.  They cannot be added back even though I used the command git add filename.  How should I do to take those file back?
Thanks.
Comment: The thing is that _normally_, the files on your working tree are like the ones in the last revision.... so sure, if you add them, git won't do a thing because they are already like in the last revision... and also the index (a.k.a. staging area... because the index actually has the information about all files from last revision _plus_ what you add to create the next revision).... so, what you see is expected. What are your expectations?
Comment: I am relatively new to Git and don't know much.  What I would expect is, after a commit, it should be possible that I will modify those files again in the future.  I have to be able to put those file back onto the staging area.  How can I do this?  Thanks.
Comment: Sure.... in order for you to be able to put them in the staging area after you commit, you need to set them with a different content from what you have in the last commit. Then you will be able to add them into the staging area.
Comment: I think this link can partially solve my query. https://stackoverflow.com/questions/12564855/git-rm-cached-and-fatal-pathspec
Answer:
the files on staging area disappeared

No, the files did not disappear. Say
<code>git ls-files --cached
</code>
The output is a list of the files in the staging area. As you will see, all your files are there.


Need to convert duplicate column elements to a unique element in R

Question: I need to convert the table A to table B. How can I do that using R?
TABLE A
Y 10
Y 12
Y 18
X 22
X 12
Z 11
Z 15

TABLE B
X 22 12
Y 10 12 18
Z 11 15

Comment: table B is not a table, and probably you have the letters mixed up.
Comment: the best you can do is get a list: `tapply(tb$value,tb$name,function(x)x)`, where `tb` is the your table A with 1st and 2nd columns named `name` and `value`.
Comment: yeah its not a table but I need the answer in 2 columns, first one should have the alphabets and the second one should have the corresponding values either in comma separated or tab delimited.
Answer: Here is the possible solution with taking a clarification in comment in mind, but still I think that the question is invalid as it stands.
##This gives the table A with both columns in character, which we will use
df<-rbind(c("Y",10),c("Y",12),c("Y",18),c("X",22), c("X",12), c("Z",11), c("Z",15))
> df
     [,1] [,2]
[1,] "Y"  "10"
[2,] "Y"  "12"
[3,] "Y"  "18"
[4,] "X"  "22"
[5,] "X"  "12"
[6,] "Z"  "11"
[7,] "Z"  "15"

##break the table into the list
l <-tapply(df[,2],df[,1],function(l)l)

##calculate the maximum length of the list element
n <- max(sapply(l,length))

##pad the elements of the list with empty strings
tbB<-t(sapply(l,function(x){res <- rep("",n);res[1:length(x)]<-x;res}))
> tbB
  [,1] [,2] [,3]
X "22" "12" ""
Y "10" "12" "18"
Z "11" "15" ""

##Comma separated file
write.table(tbB,file="tableB.csv",quote=FALSE,col.names=FALSE,sep=",")

##Tab delimited
write.table(tbB,file="tableB.txt",quote=FALSE,col.names=FALSE,sep="\t")

If we read the table A from the file, then df is a data.frame with first column a factor and second column numeric (this is a default R behaviour). To apply the code above it is necessary to transform the columns to character:
df <- sapply(df,as.character)

Comment: Thanks mpiktas! As you said the question was not correct in the way I wanted, I agree with you but you answer is what I needed.Thanks again
Comment: @Jana, you're welcome. If this is the answer you need I suggest you accept it, this is how this site works. Look at the faq how to do that. You might want to accept answers to your other questions.
Comment: @Jana: click on the checkmark just below the vote up/down buttons.
Comment: @Jana, you might also want to read the [faq](http://stats.stackexchange.com/faq). It gives a pretty good summary how this site works.
Answer: Similar to what @mpiktas proposed, but using aggregate
# Construct the data frame
let <- c("Y", "Y", "Y", "X", "X", "Z", "Z")
num <- c(10, 12, 18, 22, 12, 11, 15)

df <- data.frame(let, num)

# Aggregate data by the first column.
# Do not apply any transformation to the data (use the identity function)
ag <- aggregate(df$num, FUN=identity, by=list(let))
# Find the line with maximum number of elements
maxlen <- max(sapply(ag$x, length)))
# Transform the list to a matrix
res <- t(sapply(ag$x, function(x){c(x, rep(NA, maxlen-length(x)))}))
row.names(res) <- ag[,1]

Outputs:
1> res
  [,1] [,2] [,3]
X   22   12   NA
Y   10   12   18
Z   11   15   NA


hook_menu_alter not working

Question: I'm trying to alter tab names ("view current" and "edit current") but it is just not working.
function MY_MODULE_custom_menu_alter(&$items) {
    $items['node/%node/view']['title'] = t('View Event');
    $items['node/%node/edit']['title'] = t('Edit Event');
}

Module implementation is good. Cache is cleared. Tried it milion times, but still nothing!
Wondering is it possible that this code is being overriden somewhere, and how can I check that?
Comment: Are you positive the function is named right? What's the name of your function (as it is in your code), and what's the filename of the .module file? If you chuck a `drupal_set_message('blah');` in, and clear the caches through the UI, do you see the message?
Comment: @Clive my naming convention is correct. (Function name is: entity_registration_custom_menu_alter and module name is: entity_registration_custom.module). Module is working.
When I set `drupal_set_message('blah');` in hook_menu_alter and clear cache, I see msg however only here: /admin/config/development/performance.
Comment: That makes sense - `hook_menu_alter()` will only be invoked when the caches are cleared (not on every page). The hook's definitely firing then, so it's something else.
Comment: Did you maybe forget to include the "&" in "&$items" in the actual function declaration? I know I've done that more than once.
Comment: No, I didn't forget to include a reference.
Answer: If your hook implementation is definitely being fired then it does seem likely that another module (or even a theme, potentially) is overriding your changes.
To ensure your module's implementation runs last, you can implement hook_module_implements_alter():
function MYMODULE_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'menu_alter') {
    $group = $implementations['my_module'];
    unset($implementations['my_module']);
    $implementations['my_module'] = $group;
  }
}

If that isn't the problem, it might be something simpler...if your code is copied verbatim then you're setting the title twice for the same path. You might have meant
$items['node/%node/view']['title'] = t('View Event');

Or it might even be a combination of both of those.
Comment: Thx! Tried with this hook, but no effect whatsoever.
Comment: Hmmm something strange then. Double check there are no typos in your code, and then try Les Lim's answer. That'll give you a better idea what's going on
Answer: The {menu_router} table contains the compiled result of hook_menu() and hook_menu_alter() implementations throughout your enabled modules. You can look at the entry for "node/%/edit" to see what's actually stored there for the "title" column; if it's "Edit Event", then your code is fine, and your problem is elsewhere.
If you suspect another hook_menu_alter() implementation is overriding you, you might try to grep for "node/%node/edit" throughout your codebase. You might also see if you have any Views page displays that are set with a path of "node/%/edit" - Views registers those routes programmatically using hook_menu_alter().
Comment: Les yes, I use Views page display to render a custom content type (events). I've also noticed that on built-in entities I see "View" and "Edit" titles in tabs, but on custom node types I see "View current" and "Edit current". So it seems that Views are overiding my hook_menu_alter. How do I remedy that? Can you give me more details? Thx!
Answer: All right guys, I fixed it by installing Tab Name Tweaker module.
I still do not understand what is wrong with my code though. Note that Tab name tweaker module did not work all until I removed my custom hook_menu_alter(). That leads to conclusion that something must be wrong with this implementation:
    function MY_MODULE_menu_alter(&$items) {
        $items['node/%node/view']['title'] = t('Blah View');
        $items['node/%node/edit']['title'] = t('Blah Edit');
     }

I had also installed Modules Weight module, and tried putting my custom module at the end of list. No effect!
And even more strange, I use exactly the same code above to alter User profile tabs (in separate module), and it works there. Go figure out that! Insane!
Answer: Once I have the same problem and I solved it in an ugly way, but it works. I think that @Clive is right, some module is overriding your implementation so basically you have to update the module weight to run it at the end. To do it you can run:
update schema.system set weight = '99' WHERE name = "MODULE_NAME";

If this is working, you may look for some hooks to change the module weight.
Comment: Thx Ivan! Just FYI there is a module "Modules Weight" that allows for changing modules' weight through UI. Very handy! pozz! :)

hook_menu_alter not working


How can I fit the app to full screen size when app is opening with .NET MAUI

Question: When the app is opened, the app is not opened in full-screen size. I want to open the app in full-screen size when it is opening. How can I set it to full screen when the app is opening in Blazor hybrid app using .net 7?
This is the code of the function that I implemented in App.xaml.cs file to solve this issue but it didn't work. How to fix it?
protected override Window CreateWindow(IActivationState activationState)
{
    Window window = base.CreateWindow(activationState);
    window.Activated += Window_Activated;
    return window;
}

private async void Window_Activated(object sender, EventArgs e)
{
    const int DefaultWidth = 1024;
    const int DefaultHeight = 800;

    var window = sender as Window;

    //change window size
    window.Width = DefaultWidth;
    window.Height = DefaultHeight;

    await window.Dispatcher.DispatchAsync(() => { });

    var disp = DeviceDisplay.Current.MainDisplayInfo;

    //move to screen center
    window.X = (disp.Width / disp.Density - window.Width) / 2;
    window.Y = (disp.Height / disp.Density + window.Height) / 2;
}

Comment: Can the code in my answer help you?
Comment: I am pleased to inform you that both methods you suggested have been successful. Thank you
Answer: You can try to put the following code in the MauiProgram.cs:
var builder = MauiApp.CreateBuilder();
            builder

                  .UseMauiApp<App>()
                  .ConfigureFonts(fonts =>
                  {
                        fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                  });
#if WINDOWS
        builder.ConfigureLifecycleEvents(events =>
        {
            events.AddWindows(wndLifeCycleBuilder =>
            {
                wndLifeCycleBuilder.OnWindowCreated(window =>
                {
                //    window.ExtendsContentIntoTitleBar = false;
                    IntPtr hWnd = WinRT.Interop.WindowNative.GetWindowHandle(window);
                    Microsoft.UI.WindowId myWndId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(hWnd);
                    var _appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(myWndId);
                    _appWindow.SetPresenter(Microsoft.UI.Windowing.AppWindowPresenterKind.FullScreen);
                 //if you want to full screen, you can use this line
               // (_appWindow.Presenter as Microsoft.UI.Windowing.OverlappedPresenter).Maximize();
                //if you want to Maximize the window, you can use this line
                });
            });
        });
#endif

Or you can try to put the following code in the MainPage.cs:
protected override void OnHandlerChanged()
      {
            base.OnHandlerChanged();
#if WINDOWS
                  var window = App.Current.Windows.FirstOrDefault().Handler.PlatformView as Microsoft.UI.Xaml.Window;
                  IntPtr windowHandle = WinRT.Interop.WindowNative.GetWindowHandle(window);
                  Microsoft.UI.WindowId windowId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(windowHandle);
                  Microsoft.UI.Windowing.AppWindow appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(windowId);
                appWindow.SetPresenter(Microsoft.UI.Windowing.AppWindowPresenterKind.FullScreen);
            //   (appWindow.Presenter as Microsoft.UI.Windowing.OverlappedPresenter).Maximize();
            // this line can maximize the window
#endif
      }


How to write if else statement in laravel 8

Question: See I can write some code in PHP I want to write the same code in laravel-8 how can I?
My PHP code

<?PHP
   if($Runs>0 and $Balls==0){
      echo $Runs*100;
   }elseif($Balls>0 and $Runs==0){
      echo $Balls*$Runs;
   }elseif($Balls==0 and $Runs==0){
      echo $Balls*$Runs;
   }
    elseif($Runs>0 and $Balls>=0){
      echo $Runs/$Balls*100;
   }
?>

I want to write this same code in laravel-8
This is what I can do

{{ $value->runs/$value->balls*100 }}

I can't write if else condition there How can I?
Comment: In blade template use `@if(something) your code @endif`. Refer to [Laravel docs](https://laravel.com/docs/8.x/blade#if-statements)
Answer: You can use as like below.
@if($Runs>0 and $Balls==0)
        {{ $Runs*100 }}
@elseif ($Balls>0 and $Runs==0)
        {{ $Balls*$Runs }}
@else
  your else code
@endif

You can check all blade template condition in document to


editing apache vhosts and ubuntu hosts file?

Question: I have just installed ubuntu (11.04).
I have installed apache/mysql/php etc.
I have a few sites sitting in
/var/www/site1
/var/www/site2
/var/www/site3
I want to be able to access these at
http://site1.local
http://site2.local
http://site3.local
So in my hosts file I have
127.0.0.1   site1.local
127.0.0.1   site2.local
127.0.0.1   site3.local
Then I have copied /etc/apache2/sites-available/default 3 times.
so now I have
/etc/apache2/sites-available/site1
/etc/apache2/sites-available/site2
/etc/apache2/sites-available/site3
These all look like (with appropriate sitex names)
<VirtualHost site1.local>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/site1
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/site1/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

In the terminal I then call
sudo a2ensite site1 site2 site3 && sudo /etc/init.d/apache2 reload
Which seems to work,
except only one of the vhosts works at the same time (including default),
What am I doing wrong?

When I run the reload command I get

Reloading web server config apache2
  apache2: Could not reliably determine the server's fully qualified domain name,
  using 127.0.1.1 for ServerName
  [Fri Apr 15 10:45:27 2011] [warn]
  NameVirtualHost *:80 has no
  VirtualHosts
Answer: Based on your hosts file, you map this line:
<VirtualHost site1.local>
to this:
<VirtualHost 127.0.0.1>

What you want is:
<VirtualHost *:80>
    ServerName site1.somesite.com

You may also need:
NameVirtualHost *:80
Comment: To elaborate on this, the reason that this is the case is that the bind address for the `VirtualHost` must match the `NameVirtualHost` statement, which is probably in your `ports.conf` file.  See [here](http://httpd.apache.org/docs/2.2/mod/core.html#namevirtualhost) for reference.
Answer: I faced the same problem. After multiple trial and errors, I fixed the issue by adding NameVirtualHost *:80 to sites-available/default. And removing/not-adding the same line in any other files in sites-available/
I don't know why that worked though.
Answer: The error message of: "Could not reliably determine the server's fully qualified domain name..." is a quirky issue in the apache2 server and would not prevent or stop the apache2 server from locally "VirtualHost" ing your "ServerName".  Read the link that Shane Madden gave as the solution is in there.  The other "warn" message of: "NameVirtualHost *:80 has no VirtualHosts" will prevent you from having success.
Problem 1: The solution to the FQDN is simple and the two solutions seems to each have success for different users - so do both:  Add the text string "ServerName localhost" (without quotes) to either (or both) of two files; the /etc/apache2/http.d.conf file, which is blank out of the box.  And add it at the bottom of the /etc/apache2/apache2.conf file.
Problem 2: Reading the manual you will see examples on various setups for Apache2, but the one thing you really need to keep in mind is that the directive "NameVirtualHost" (which is located in /etc/apache2/ports.conf) needs to be EXACTLY the same as what you specify in the directive  (located in the etc/apache2/sites-available/siteFile, where "siteFile" is your "site1", "site2" and "site3" in your example).  Don't use boolean values in one and a static IP address or a static IP:Port in another.  Once you understand the severity of that relationship then reading the manual and trying their setups will work.
Problem 3: The hidden problem: Knowing Problem 2, you now need to make sure it does not happen in your OTHER site files - namely, your default file.  If the Default file has a VirtualHost *:80 and your site1 has a VirtualHost 127.0.0.1 AND your ports.conf has a NameVirtualHost 127.0.0.1 then the site1 and ports.conf are in harmony BUT the default is now no longer good and will cause the error.
Hang in there!  It ain't easy...


How to get the last updated time stamp of a field in field collection

Question: How to get  the last updated time stamp of a field in field collection.Is there any drupal built in function to get the timestamp
Comment: Entities have "updated" column in the database, fields and field-collecions not, so basically I think it is not possible.
Answer: There is no timestamp for field collection items. (Drupal 7)
Answer: To add "last updated time" on a post,
use the Timestamp field.
(I'm using Drupal 10)
This will not update past posts, but it will prompt the writer to select to update the stamp when editing (if you make it mandatory).
Here are the steps to implement this field (I'm using Drupal 10):

Structure
Content types
Select desired Content type
Add field
Select Timestamp and follow given instructions.
Label it "Last update" or anything you wish.

You may then rearrange where the field will show to a reader
by going to Manage display
(Structure/Content types/You content type/Manage display).


How much NICs for NLB (ISA-Server) / Best Practice?

Question: I'm not familiar with Windows servers (I'm some kind of networking guy) but have to setup an ISA server from the networking point of view. It will connect an internal LAN to a DMZ.
There will be a cluster of two ISA servers using NLB. Obviously, the cluster will have 2 NLB "sessions", one for internal and one for DMZ zone. My question is concerning the heartbeat:
What (and why) would be the best way to go out of the following possibilities:

4 NICs per server: dedicated heartbeat segments for both zones (unicast)
3 NICs per server: shared/multinetted heartbeat segment (multicast or unicast?)
3 NICs per server: dedicated heartbeat segments using VLANs on heartbeat NIC (unicast)
2 NICs per server: mixed heartbeat and production traffic on the same NIC (multicast)
anything else?

Any pointers are greatly appreciated.
Answer: Talking to a number of windows guys the 3 NIC solution with a shared multicast segment for the heartbeat has been chosen. There is no advantage in having two separate hearbeat links, if one side fails, the other one should failover, too. But heaving heartbeat traffic on the production networks is generally a bad idea.


Can stationary time series contain regulary cycles and periods with different fluctuations

Question: I just started trying to undestand the notion of stationary in time series. Basically I have 2 questions:

Can stationary time series contain regulary cycles and thus seasonality patterns? For exmaple in this tutorial it is stated that stationary time series can not have seasonal components (predicitable cycles) https://otexts.com/fpp2/stationarity.html whereas in this figures (https://i.stack.imgur.com/Q7B8c.png) the green time series that clearly has cycles (and thus seasonality) is labeled as 'stationary'
(and I have seen these kind of figures quite often if you just google 'stationary time series)
Can a stationary time series have periods with no fluctuations and periods with high fluctuations? As far as I understood the variance and the (aut)covarianz should not change over time making such a time series not stationary. But here in this picture (https://www.researchgate.net/profile/Hazrat_Ali3/publication/326619835/figure/fig10/AS:654171351044097@1532978012116/Non-stationary-and-stationary-time-series-As-CDR-activities-of-users-are-aggregated-on.png) the time series below is labeld as stationary altough it has periods with changing fluctuations.

I hope you can help me as I am confused about the concept of stationarity. I'd appreciate every comment.
The bounty is to expire quite soon. So I'd be happy if some could at least give me one answer to my questions. It will help me a lot.
Why is nobody answering the questions? Are they not clear enough? If so, please tell me. I think they are important and fundamental as the concept of stationarity is quite important.
Comment: If a series contains "seasonality patterns," then *a fortiori* it is not stationary.  The underlying concept of stationarity is that statistical properties of the series do not change over time, while the underlying concept of seasonality is that those properties do change, but in a periodic way.  The ResearchGate image you reference appears to focus solely on the location (perhaps the mean) of each marginal distribution, wholly ignoring other statistical properties (such as the dispersion, which *obviously* is not stationary). This is known as "first order" stationarity.
Comment: A regular cycle is manifestly not stationary.  However, it is difficult to interpret those pictures because they are extremely sketchy.  If the colored curves are intended to represent either (a) data or (b) expected values, then their regular variation is strong, clear evidence of non-stationarity.
Comment: As I indicated, there are various definitions of "stationary."  They vary according to which statistical properties must remain unchanged.  But none of the examples in your image would  even satisfy one of the loosest definitions, "weak first order stationarity."  Those images don't tell you much about how the variance changes over time, though.
Comment: Thanks whuber for your answer. So would you say that the green time series in (https://i.imgur.com/3lKCxEn.png is not stationary because it is seasonal? And for me the ResearchGate picture is not stationary per definition. The variance it not constant over time (at all). I think it is wrong to say that this time series is stationary because if you only require the stationary attributes to be valid for a certain portion of the time series, the stationary requirements can be fullfield by almost every time series
Comment: Thanks whuber. So did I understand correctly that the two time series that are labeled stationary are not-stationary (meaning that the pictures are wrong)? I ask this because especially this figures https://i.imgur.com/3lKCxEn.png can be seen many times on the internet and they are always labeled as stationary (the green line). Is it not stationary because of the regular cycles because that is what I thought after reading the tutorial I gave a link to in the post?
Comment: Okay thanks whuber for your answers. I'd like to also know the impressions of others because as said before, the one green time series figur can be found quite frequenly in many tutorials in the Internet and it is labeled as stationary whereas you (and I) have a tendency to not call this stationary.
Answer:
Stationary series cannot have a fixed seasonal component, which is saying, if you take a stationary series and you sum it to $sin(t)$, the result will not be stationary. Stationary series can be seasonally autocorrelated, which means that what happens one month is correlated with what will happen the next year in the same month. For stationarity to hold, however, in the long run (after some number of years) this autocorrelation must vanish. It's often hard to tell from sampled data if the time process behind it is stationary or not (it's a matter of statistical tests, not about precise measuring) but that green series in the imgur image does not seem stationary, not anymore than the lower-right red series anyway (the upper two red series show even worse behavior allright).

A premise for the second answer: there is more than one definition of stationarity, but generally both the unconditional mean and variance (and also the auto-covariance function) must be constant over time. This doesn't mean that fluctuations can't happen, but that if you don't know any value of the series around time $t$, knowing $t$ itself doesn't tell you anything about the moments of $Y_t$. This is weak stationarity, strong stationarity is similar but is not limited to first and second order moments (mean, variance, covariance), but the whole distribution. You can relate this to the first answer, as $sin(t)$ would tell you something about the expected value of $Y_t$, so that component makes the series non-stationary.

In that image both series have strong fluctuations in mean (upper series) or variance (lower series), you may say that the lower series is stationary in mean (that's what Whuber has being saying in the comments), but, as we have seen, this is not sufficient for even the weaker commonly accepted definition of stationarity, that requires also second moment consistency. It's hard to say if either of the two plotted series is stationary, because fluctuations are possible in theory, but must be brief in relation to the length of the whole series, in order to have a good degree of confidence that the series is indeed stationary. In the case of both series plotted in the image that you linked, the "fluctiations" end before the end of the series, and that hints for stationarity, but those could also not be fluctuations at all, but random wandering, they are to long to be considered just fluctuations.
Comment: Thanks carlo for your answer (I upvoted it). I have follow up questions: to 1) So whenever we have regular cycles throughout the whole time series we can say that it is not stationary? And when we have regular cycles for a short time span, it can still be stationary (when there is no trend)? Is that correct? To 2) In the lower time series you can clearly see that the fluctuations (and thus the variance) between 0-40 is way lower than the ones between e.g. 60-100. Thus imho, per definition it can't be stationary as the statistical properties are definitely not constant over time.
Comment: Further: do you know a good website where examples of stationary and non-stationary time series are displayed? Maybe this would help me understanding the notion of stationarity. Of course I also did an Internet search but all of the websites I found (see the links in the question) seem to use different (seemingly wrong) concepts of stationarity which is a main reason for my confusion.
Comment: Sorry, I don't know such a site. Anyway, regular cycles are not such a great problem for analysis generally, the period must be regular though (the covariance structure is constant). The intensity of the "wave signal" is considered to be random and autocorrelated, but the fact that it never switches sign is left ignored. This typical example is about a non-stationary process very often trated as stationary: depending on what are your goals, this flaw in your methodology may or may not be a problem.
Comment: Thanks carlo for your answer and effort. You said that "regular cycles are not such a great problem". But if we have regular cycles the time series is not stationary, right?
Comment: And what about the 2nd additional quesiton "In the lower time series you can clearly see that the fluctuations (and thus the variance) between 0-40 is way lower than the ones between e.g. 60-100. Thus imho, per definition it can't be stationary as the statistical properties are definitely not constant over time. " From what I read about stationarity the time series can't be regarded as stationary
Comment: I awarded the bounty to you for your answer and I hope you still have time to answer my follow up questions
Comment: @PeterBe well, you can't *be sure* of what were the moments of the process that generated that series because of, you know, randomness. In principle that output could have been caused by a random fluctuation of variance that could have happened in any moment, not necessarily at that time. In that case the process could be stationary, and then it would be expected to return to a lower variance at some point (and also have other fluctuations at random time intervals). In practice it's quite a long shot to treat that series as stationary, its variance may ass well continue to vary whithout limits


Unable to load fonts on Ubuntu

Question: Using R version 4.1.2 on Ubuntu 20.04, I run hist(10). The error says
X11 font -adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*, face 2 at size 14 could not be loaded

I find two things on google. This thread I can't understand, and this thread suggests I build R differently. I did recently build R from source, without the cairo flag recommended by the Bio-Deago github thread, but I have now replaced it with a binary from Rstudio, and the problem persists. Any suggestions? Thanks!
EDIT: the problem only occurs in Rstudio, not when I run R through a terminal.
Answer: R gets installed to different places depending on whether you install from source or as a binary: see this, which says:

For versions of R installed by system package managers (e.g. r-base on Debian or Ubuntu) this will be /usr/bin/R. For versions of R installed from source this will typically (but not always) be /usr/local/bin/R.

Rstudio looks first at which R, which in this case is the version from source. I deleted the source version (target of symlink at which R). Then when I ran R in a terminal, said R is not installed. Then, I followed the Rstudio binary install instructions mentioned in the question. I followed them from the beginning even though I had already installed an Rstudio binary. Now I can run hist(10) and get a plot as expected.

Unable to load fonts on Ubuntu


jQuery refresh var from different functions

Question: Let's say I got this code:

click

As you can see I try to refresh the var time from a function (click) with time.refresh(); but it's not working. How could I do this? PS: I dont really need the current second onclick it's just an example
Comment: you need this http://jsfiddle.net/vdLwvmxp/57/?
Comment: Thanks :D But can't accept because it's a comment
Answer: In your script tag :
var time = new Date().getTime();

function jo(){
    $('#mydiv').html(time);
}

function refresh()
{
    return new Date().getTime();
}
$("#click").click(function(){
    jo();
    time=refresh();
});

or if you not need refresh() then just time=new Date().getTime();
Demo in Fiddle
Answer: How about you can do this without using refresh function
var time;
function jo(){
    $('#mydiv').html(time);
}

$("#click").click(function(){
    time = new Date().getTime();
    jo();
});

Comment: Nice solution too but kupendra was faster ^^