How should I do clustering when I have a mix of single-element and time series features?

Question: I'm trying to cluster together different short audio files based on the zero-crossing rate (an integer) and the energy, spectral centroid, and spectral bandwidth (time-variant values).  I've decided to use these time series as features rather than just taking an average and using that as a feature because one of the goals is, for example, to cluster together the audio files which rise in pitch over time but decay in energy.  I'm assuming that K-means clustering might not be the best algorithm here given that it's meant for low-dimensional spaces, and I'll at least need to do some specific preprocessing first (maybe not just because it's a time series but because it's audio).  What should I look into using here for what I'm trying to do?  Should I look into different features?
Cheers and thanks for any help!
Comment: How short/long are the files? What kind of audio in there, and what kind of patterns do you want your clustering to find?
Comment: @jonnor they're drum samples, like a kick or a snare, so usually about 0.5s or less.  I'm looking for interesting timbre patterns or anything that can further categorize these files
Answer: TL;DR: For clustering time-series data, as a baseline, you can try using Dynamic Time Warping (DTW) as a distance metric for your favorite clustering algorithm, say $k$-means.
DTW is commonly used in applications like ASR (automatic speech recognition), and other sequence alignment problems. I believe the Python package tslearn implements DTW, though I have not used it myself.
What is DTW?
At a very high level, DTW is a measure of how "aligned" two time-series are, so it can capture features like "rise in pitch over time + decay in energy;" i.e. two sequences are "close" if you can stretch/compress a source sequence in the time dimension into the target sequence. To compute this, let's define $x, y$ as sequences of length $n, m$ respectively, and $\pi = [\pi_1, \pi_2, \dots \pi_N]$, where $\pi_k = (i_k, j_k)$, a tuple of indices into $x, y$ respectively. Intuitively, $\pi$ defines a "path" through sequences $x, y$ by pairing up indices. Then you minimize the following objective:
$$ \underset{\pi}{\min} \sqrt{\sum_{(i, j) \in \pi} d(x_i, y_j)^2} \quad\text{subject to}$$
$$ i_{k-1} \leq i_k \leq i_{k-1} + 1,\;\; j_{k-1} \leq j_k \leq j_{k-1} + 1 \quad\text{for}\quad (i_k, j_k) \in \pi, 0 < k \leq N;\\
i_0 = 0, j_0 = 0;\\
i_K = n, j_K = m.$$
where $d$ is some distance metric (say $\ell_1, \ell_2$). The final two constraints are just boundary conditions that specify that the path $\pi$ must align with the beginnings and ends of $x, y$ simultaneously; the top constraint specifies that indices $i_k, j_k$ must be monotonically non-decreasing in $k$.
This schematic from Wikipedia illustrates this quite succinctly:

We can imagine each location where a dashed line originates/terminates as an element of a discrete time-series; these correspond to the various $i_k, j_k$ defined in $\pi$.
What about the curse of dimensionality?
Your intuition that $k$-means runs into the curse of dimensionality is generally correct in practice, and often becomes a problem when you're using Euclidean distance (see this previous answer for more details), but the curse of dimensionality is more nuanced than "more dimensions = bad;" it is important to realize that the curse of dimensionality affects different metrics in different ways. Very informally, DTW is a metric that is less "susceptible" to the same dimensionality problems with squared Euclidean distance, as it better preserves its "meaning" in high dimensional spaces.
More concretely, using nearest-neighbors search as an illustrative example, under reasonable assumptions about your data-generating distribution, data points tend to become uniformly distant from one another in Euclidean distance as your dimensionality (or in the context of time-series, sequence length) increases; i.e., most points are "almost-nearest" neighbors. DTW does not suffer as severely from this problem as sequence length increases. A more mathematical way to gauge the severity of the curse of dimensionality is shown in Section 3.4 of this paper.
Comment: That's a good question -- DTW is intended for sequential features, so it doesn't take of combining with single-element features out of the box. Since you have a few time-series features and one scalar feature, a naive solution might be to use DTW for the sequential features and a scalar metric for the scalar features; then, you could add/average the aggregate cost, which should give you a notion of pairwise distance. Essentially, this clusters sets of features independently. I don't know if this is rigorous/optimal -- this is my first instinct, as I'm not too familiar with this area.
Comment: How would I go from there?  I looked into DTW and tslearn but I can't figure out how to combine it with single-element features
Comment: i'll try this out!  it seems like there might be a better solution that i'll try to look for, but i appreciate this in-depth answer!


Confused about Cramer-Rao lower bound and CLT

Question: Learning statistics for application in the physical sciences. I am confused about the cramer-rao (CR) bound vs central limit theorem for estimating the variance of the sample mean. I thought that once we have enough samples, we can use CLT regardless of the shape of the distribution. When would we use the CR bound to calculate the confidence intervals vs CLT? Is it only when the number of samples are low which would lead the CLT to not converge?
Answer: The Cramèr-Rao lower bound (or Fréchet-Darmois-Cramèr-Rao lower bound) is a lower bound on the variance of a collection of estimators, for instance unbiased estimators or estimators with a given bias. In some cases, there exists an estimator within the collection that meets this lower bound, but in other cases, the lower bound may be strict. Using a Cramèr-Rao lower bound to construct a confidence interval is a very crude approach to confidence intervals.
The CLT is a version of a limiting theorem, which means that an estimator of $\theta$ $\hat\theta(x_{1:n})$, for instance the MLE, has a limiting distribution as the sample size $n$ grows to infinity, for instance $\sqrt{n}(\hat\theta(X_{1:n})-\theta)$ converges in distribution to a $\mathcal N(0,\sigma^2(\theta))$ distribution. For a collection of estimators of $\theta$, asymptotic variances $\sigma^2(\theta)$ may be compared, but this does not imply anything at the finite $n$ level.


mdadm warning after apt-get upgrade - can't boot RAID

Question: I'm running Ubuntu 12.04 precise. A recent apt-get upgrade ended successfully, but printed the following warning at the end:
update-initramfs: Generating /boot/initrd.img-3.2.0-21-generic
W: mdadm: the array /dev/md/odin:1 with UUID d65cf17d:fe860500:29648a86:d29c3195
W: mdadm: is currently active, but it is not listed in mdadm.conf. if
W: mdadm: it is needed for boot, then YOUR SYSTEM IS NOW UNBOOTABLE!
W: mdadm: please inspect the output of /usr/share/mdadm/mkconf, compare
W: mdadm: it to /etc/mdadm/mdadm.conf, and make the necessary changes.

I looked on serverfault and found this recent question. The accepted response suggested etc/mdadm/mdadm.conf was not properly updated, and the thing to do is to copy the list of active RAID arrays from the output of /usr/share/mdadm/mkconf to the appropriate place in /etc/mdadm/mdadm.conf.
In my case, the difference was one line: the output of /usr/share/mdadm/mkconf listed 2 arrays:
# definitions of existing MD arrays
ARRAY /dev/md/1 metadata=1.2 UUID=d65cf17d:fe860500:29648a86:d29c3195 name=odin:1
ARRAY /dev/md/0 metadata=1.2 UUID=859e9e8c:34e69e1e:d934738a:ebdf1249 name=odin:0

and /etc/mdadm/mdadm.conf only listed one of them:
# definitions of existing MD arrays
ARRAY /dev/md/0 metadata=1.2 UUID=859e9e8c:34e69e1e:d934738a:ebdf1249
name=odin:0

The system is configured to boot from /dev/md0.
Following the advice in the serverfault post, I added the missing ARRAY definition to /etc/mdadm/mdadm.conf and ran update-initramfs -u. There were no warnings. When I tried to reboot, however, the system could not do so from the RAID.
Interestingly, I was able to boot by

booting from an Ubuntu LiveCD
choosing "boot from hard disk" from the LiveCD's menu

so the server is running again, but I would like to be able to boot it normally.
As you can tell, I am new to dealing with RAID setups on Linux, and so I wish to proceed cautiously. Any advice or suggestions would be greatly appreciated!
Answer: As far as I know you can not directly boot from an array created with mdadm. You need to at least have a small boot partition outside the array in order to boot. That's why you can boot with a CD, it's serving as the boot volume outside the array. Then the array gets started and you're in.
For more information see: How to create a bootable redundant Debian system with a 3 or 4 (or more) disk software raid10?
This will tell you how to set it up so you can boot.
Comment: I did not set up the RAID, so I am sort of trying to reverse engineer everything at this point. This was helpful for my understanding. How can I determine if such boot partitions exist? I tried looking in mount, but there's no specific `/boot` partition, just `/`. The only entry in `/etc/fstab` mounts `/` at the UUID of one of the RAID arrays.


Retrieve information for the same DTO from two different databases

Question: I tried to make this as simple as possible with a short example.
We have two databases, one in MSSQLServer and other in Progress.
We have the user DTO as it follows that we shown in a UI table within a web application.
User

int, id
String, name
String, accountNumber
String, street
String, city
String, country

Now this DTO(Entity) is not stored only in one database, some information (fields) for the same user are stored in one database and some in the other database.
MSsql

Table user
int, id
String, name
String, accountNumber

Table userModel
int, id
String, street
String, city
String, country

As you can see the key is the only piece that link two tables in both databases, as I said before they are not in the same database and not using same database vendor.
We have a requirement for sorting the UI table for each column. Obviously we need to create user dto with the information coming from both databases.
Our proposal at this moment is if user want to apply sorting using street field, we run a query in the Progress database and obtain a page (using pagination) using this resultset and go directly to the MSSQLServer User table with those keys and run another query to extract the missing information and save it to our DTO and transfer it to the UI. With implies run a query in one database then other query based on the returned keys in the second database.
The order of the database could change depending in which column(field) the user wants to apply sorting.
Technically we will create a jparepository that acts as a facade and depending on the field make the process in the correct database.
My question is:
There is some kind of pattern that is commonly used in this scenarios, we are using spring, so probably spring have some out of the box features to support this requirement, will be great if this is possible using jparepositories (I have several doubts about it as we will use two different entitymanagers, one for each database).
Note: Move data from one database to another is not an option.
Comment: Have you looked at Hibernate multitenancy support?
Comment: I already read about it, but seems to be an strategy to retrieve information from two different sources (Spring routingDataSource work similar to this), in this case database, I don't have troubles with that part is more the next step in which I need to sort based on the column, but the column could be in the first or in the second database. so the full information depends in the first query adding the information for a second query
Comment: @Koitoer what is the size of the tables in both databases?
Comment: Size is more than 10,000 records
Answer: For this, you need to have separate DataSource/EntityManagerFactory/JpaRepository.
There is no out-of-the-box support for this architecture in the Spring framework, but you can easily hide the dual DataSource pair behind a Service layer. You can even configure JTA DataSources for ACID operations.
Comment: Seems that, for now, is there no out of the box support in spring, basically, that makes you the right answer, thanks. Probably in the future this will be a new feature, who knows
Answer: As you will always need to fetch data from both databases, why not populate local java User objects then sort these objects (using a comparator with the appropriate fields you want to sort on).
The advantage of sorting locally vs doing the sort in the database query is that you won't have to send requests to the database every time you change the sorting field.
So, to summarize:
1- Issue two sql queries for the two databases to get your users
2- Build your User objects using the retrieved values
3- Use Java comparators to sort the users on any field without having to issue new queries to the database.
Comment: To do that I believe I need to load all the records to the application and sorting in memory, move that data quantity I think is kind of inefficiently
Answer: My advice would be to find a way to link 2 databases together so that you can utilize database driver features without your code being affected.
Essentially if Progress database can be linked to SQL Server, you will be able to query both databases using a single SQL query with a join on id column and you will get a merged, sorted and paginated result set for your application to display.
I am not an expert in Progress database but it seems there is an ODBC driver for it so you might try to link it to SQL Server.


sed: -e expression unknown option to `s'

Question: I know this has been asked before, but im struggling to determine the root cause of the error with my script. Ive gone through the other questions and tried to convert this (switched the /\ for @) but it just doesn't work for me i still get the same error???
As soon as i added in the last 4(from the bottom) expressions i started getting errors,..
when i run this
clustername="'XXXCluster'"
seed=xx.xxx.xxx.xx
ip=xx.xxx.xxx.xx
hint="/opt/cassandra/data/hints"
data="/opt/cassandra/data/data"
commitlog="/opt/cassandra/data/commitlog"
cache="/opt/cassandra/data/saved_caches"

sed -i -e "s/\(cluster_name:\).*/\1$clustername/" \
-e "s/\(- seeds:\).*/\1$seed/" \
-e "s/\(listen_address:\).*/\1$ip/" \
-e "s/\(rpc_address:\).*/\1$ip/" \
-e "s/\(broadcast_rpc_address:\).*/\1$ip/" \
-e "s/\(hints_directory:\).*/\1$hint/" \
-e "s/\(data_file_directory:\).*/\1$data/" \
-e "s/\(commitlog_directory:\).*/\1$commitlog/" \
-e "s/\(saved_caches_directory:\).*/\1$cache/" /opt/cassandra.yaml

i get this
sed: -e expression #6, char 29: unknown option to `s'
but i cant see how to fix this, can someone help me please??
thanks in advance..
Answer: Use % instead of / in your sed.
sed -e 's%search_string%replace_with%'
I guess your problem line has slashes in it and sed will strugle with it.
Edit:
Since you are using variables for the replace string, your slashes in there matters.
My first answer was a bit missleading. Sorry for that.
Example:
We have a file nada.txt with content 'test: "/a/place/in/universe"'
$ cat nada.txt
test: "/a/place/in/universe"

A variable with a directory for the replacement
$ dir="/new/place/in/haven"
$ echo $dir
/new/place/in/haven

Let's try to fail
$ sed -e "s/\(test: \).*/\1$dir/" nada.txt
sed: -e expression #1, char 19: unknown option to `s'

Again but this time with replaced slashes with % ("s///" to "s%%%")
$ sed -e "s%\(test: \).*%\1$dir%" nada.txt
test: /new/place/in/haven

Or
$ sed -e 's%\(test: \).*%\1'$dir'%' nada.txt
test: /new/place/in/haven

See the single quotes, you need four to take out the variable. It looks like this 's% %'$dir'%'Because in a shell context single quotes will not resolve the variable:
$ echo 'Such a text and $dir'
Such a text and $dir

Where as double quotes do the job as expected.
$ echo "Such a text and $dir"
Such a text and /new/place/in/haven

Hope that helps
Comment: No need for guessing. It doesn't matter whether there are any `/` characters in the input. It does matter that there are `/` characters in the replacement strings. And the question does list the replacement strings.
Comment: He has a .* in his pattern, this pattern gets replaced by the line that is in the file. If this line has slashes in it, sed gets refused. Try it.
Comment: Upps, your right, i tried it and it works.
Comment: @Iamchecko - could you give me an example of what you are doing to get this to work please????
Comment: @iamchecko, thats a great explanation and very helpful, i appreciate your time spent on this!!! I have voted up the answer but dont have a high enough reputation...(fyi)
Comment: Your welcome. Thats fine.


Making ionic to open apps in landscape mode

Question: I wrote an app by using ionic framework. But it opens in portrait mode. I want it to open in landscape mode. In phonegap, we have a global config.xml file where we can use
<preference name="orientation" value="landscape" />. Is there any similar method for ionic?
Comment: Are you develop the app for android
Comment: yeah, I'm developing the app for android
Answer: add
<preference name="orientation" value="portrait" />

in config.xml  works for me
Comment: Small detail: the question was for landscape. So write landscape instead of portrait. But I can confirm this works.
Answer: In your android manifest file change this android:screenOrientation="portrait" to
android:screenOrientation="landscape".This will work fine for me
Comment: so my answer is helpful for you?
Comment: You shouldn't change anything in the android folder, because that gets (re-)generated by ionic and your changes will dissapear. Change it in the config.xml instead like @alexniver says in his answer.
Answer: No you can't force that with ionic. You have to use your config.xml file.


What's so different about limits compared to infinitesimals?

Question: If you find the limit is 2 for a given function, wouldn't this be the same as $2 + \epsilon$ with $\epsilon$ being a negligible value? This different way of defining limit-like behavior seems rigorous enough, but it took until Abraham Robinson in the 60s to really define the foundation for nonstandard analysis. My question is: what really is the difference?
Comment: The difference is that I could explain to you exactly what "limit" means, but "negligible value" doesn't mean anything.
Comment: I imagine the problem arises when you have a "negligible value" divided by a "negligible value" yielding a real number i.e. a derivative, or adding an infinite number of "negligible values" together to again yield a real number i.e. an integral.  This needs to be well defined, so we need rigorous definitions.
Comment: The difference is that $\varepsilon,\delta$ are real numbers, but infinitesimals are not real numbers with the exception of $0$. Then you need a new axiomatic set theory for this, to handle hyperreal numbers properly. This is a lot more than work and sophistication to something that can be explained easily just using real numbers.
Comment: @AndréNicolas, you need the axiom of choice even for such an innocuous fact that the Lebesgue measure is countably additive. Sometimes we see a double standard at work in applying the AC criticism.
Comment: @JackM thanks for your answer, but how exactly would a limit be different from a negligible value? I get epsilon-delta and that is rigorously defined, but we're essentially taking the standard part function of the infinitesimal to obtain the exact value of the limit, from my understanding. And thank you Jason, that does make sense. I just don't really understand how limits are very much different. The error terms become infinitesimal in an infinite Riemann sum, but we don't treat them as infinitesimal, we just say they are zero. That is the only difference I see.
Comment: The difference is the machinery to make the intuitive notion of an infinitesimal rigorous is more complicated,at least in the eyes of some, than the machinery of standard analysis.
Comment: Even for mere existence, we need (a weak form of) the Axiom of Choice.
Comment: If $2$ is the limit, then $2 + \epsilon$ is not the limit; $2 + \epsilon$ is only infinitesimally close to the limit.
Comment: @JackM In any field outside pure math 'negligible value' means irrelevant or immeasurable. In math it just means arbitrarily small.
Comment: https://math.stackexchange.com/questions/661999/are-infinitesimals-dangerous
Answer: There were various theories extending the real numbers to include infinitesimals throughout the period from 1870 until 1960, but Robinson was the first to introduce a system that can be used in analysis. Earlier systems were critized by Klein, Fraenkel, and others on the grounds that they were not proven to satisfy the mean value theorem for, e.g., infinitesimal intervals. Robinson's framework satisfies this and more.


The android emulator does't show the changes that occur in the code

Question: I am knew in react native and I need to run a project. I used the following command in the folder of my project:
1- npm start
2- react-native run-android
However, I have a strange problem. Whenever I change any thing in the code, nothing happen in emulator and the emulator show me the previous thing!
I have done it with cell phone connected to the PC and see the same result!
I even stop the emulator and start it again but, I see the same problem. The emulator do not show any changes in the code and show a constant project. Can you help me?
Update:
As I shake the cell phone and reload it, I see the following red screen error:
Could not connect to development server.

Comment: Did you try to open dev menu and activate hot reloading? Shake your device to do so, can't remember how to do it in emulator.
Comment: @Poptocrack: Thanks for your reply. Yes, I did that, please check the question again, I have updated it.
Answer: You need to enable either Live Reload or Hot Reloading. Within the simulator, you can access the menu with the Cmd+M combination or click the icon (see screenshot) then just choose the option you want.
Comment: Or just taping `Reload` from the developer menu above


Crypt::hmacBase64() versus CsrfTokenGenerator::get() and CsrfTokenGenerator::validate()

Question: In a module I am writing, I need to add a hidden field in the registration form, similarly to what the Honeypot module does.
$form['honeypot_time'] = [
  '#type' => 'hidden',
  '#title' => t('Timestamp'),
  '#default_value' => mymodule_get_signed_timestamp(time()),
  '#element_validate' => ['mymodule_signed_timestamp_validate'],
  '#cache' => [
    'max-age' => 0,
  ],
];

mymodule_get_signed_timestamp() concatenates the timestamp with a value used to avoid the timestamp is arbitrary changed. It could be computed in one of two ways:

Using Crypt::hmacBase64()
Using the csrf_token service, which by default provides CsrfTokenGenerator::get() and CsrfTokenGenerator::validate()

The choose is then between one of the following snippets.
use \Drupal\Component\Utility;

$token = Crypt::hmacBase64($value, \Drupal::service('private_key')->get());

use \Drupal\Core\Access;

$token = \Drupal::csrfToken()->get($value);

The difference is apparently just that the csrf_token service's methods use, as part of the key passed to Crypt::hmacBase64(), also the session's data and the hash salt set in the settings.php file.
Considering that, in most of the cases, I would be altering a form submitted from anonymous users who tries to register an account (but I cannot exclude I could be adding that form element to forms submitted from registered users), should I use the first method or the second one?
Answer: I made a quick test using the following code.
use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\Site\Settings;
use Drupal\Core\Access\CsrfToken;
use Drupal\Component\Utility\Crypt;

$autoloader = require_once 'autoload.php';

/**
 * Global flag to identify update.php and authorize.php runs.
 *
 * Identifies update.php and authorize.php runs, avoiding unwanted operations
 * such as css/js preprocessing and translation, and solves some theming issues.
 * The flag is checked in other places in Drupal code (not just authorize.php).
 */
const MAINTENANCE_MODE = 'update';

try {
  $request = Request::createFromGlobals();
  $kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');
  $kernel->prepareLegacyRequest($request);
}
catch (HttpExceptionInterface $e) {
  $response = new Response('', $e->getStatusCode());
  $response->prepare($request)->send();
  exit;
}

\Drupal::moduleHandler()->addModule('system', 'core/modules/system');
\Drupal::moduleHandler()->addModule('user', 'core/modules/user');
\Drupal::moduleHandler()->load('system');
\Drupal::moduleHandler()->load('user');

drupal_maintenance_theme();

$csrf_token = \Drupal::csrfToken();

$content[] = [
  '#markup' => t('First method: %token.
', ['%token' => Crypt::hmacBase64(123456, \Drupal::service('private_key')->get())]),
  '#cache' => ['max-age' => 0],
];
$content[] = [
  '#markup' => t('Second method: %token.
', ['%token' => $csrf_token->get(123456)]),
  '#cache' => ['max-age' => 0],
];

$renderer = \Drupal::service('bare_html_page_renderer');
$response = $renderer->renderBarePage($content, 'Test results', 'maintenance_page', array(
  '#show_messages' => FALSE,
));

$response->setStatusCode(400);
$response->send();

I then opened three different Firefox windows pointing them at the test script I wrote. This is what I got:
First window

First method: r3xavuZbwgsk1RJTPm-zOs3kUSeSY4-BDnj-UCwgyr0.
  Second method: OndzLnnASZLsuzABJltD_HwK8dr48fEW_hdWG9Lu02I.

Second window

First method: r3xavuZbwgsk1RJTPm-zOs3kUSeSY4-BDnj-UCwgyr0.
  Second method: J6oHkKdXeL9RUKHX4B1Sn418Yh8XD0tJbRrs459BI7A.

Third window

First method: r3xavuZbwgsk1RJTPm-zOs3kUSeSY4-BDnj-UCwgyr0.
  Second method: TYvxZiF7xS6hD2nn8pfHu0GR9OPw0X8xT1HfVDNWkXc.

With the second method, different users are going to get different values, even in the case the input value is the same.
I would say that using the csrf_token service is preferable, in my case.


Why export env within tmux fails

Question: Command like the following:
ssh hostname 'tmux new -d "export A=whatever && echo $A && while true; do date; sleep 1; done"'

After executing this command, ssh to hostname and attach to the tmux session, you'll see that $A is empty.
Answer: The $ sign should be escaped.
ssh hostname 'tmux new -d "export A=whatever && echo \$A && while true; do date; sleep 1; done"'

Why export env within tmux fails


How to represent an alternate key in Entity-Relationship Model?

Question: If there is a relation between two entities that makes use of the primary keys of both entities, and you want to use other attributes of one of the entities to act as an alternate key, how would that be modeled?
I guess what I'm having trouble modeling is the equivalent of an 'OR' statement. Either the relationship requires the primary key, or it requires two or more particular attributes to serve as an alternate key for that entity.
Comment: What is the cardinality of the relation?
Answer: The simplest way to add an 'OR' in a relational model is to add another linking table that models the relation based on the alternative keys. To get all related rows, you query by linking thought the 'primary-keys linking table' and query by linking through the 'alternative-keys linking table' and union the results.


How can I translate the Profile 2 field labels?

Question: I can't find a way to translate the fields labels for the Profile 2 fields. I have activated the Profile 2 translation module, but I don't want to translate fields of the entity, I just want to show the labels translated in the user page and the user edit form.
Does anyone know how to do it?
Answer: EDIT: the following description describes the steps for Drupal 8, but they are similar for Drupal 7:

You need the potx module to extract a translation template which you can translate. Unfortunately there isn't an official Drupal 8 release available, but you can use this github fork, which works fine for my needs.
Here is a short procedure to handle translations of my modules:
1. extent your module with the Interface Translation Properties (only Drupal 8)
Example my_module.info.yml:
name: My Module
description: ''
type: module
core: 8.x

'interface translation project': my_module
'interface translation server pattern': modules/my_module/translations/%language.po

Now your module is available for the locale module and translation can be handled with drush locale-check resp. drush locale-update.
2. create a subfolder for your translations
In the subfolder ./modules/my_module/translations I put the generated template and the *.po files. Fore more information have a look at the documentation on drupal.org.
3. create your template
I'm using drush to create the template. The best way for me is the creation with
drush potx single --folder=modules/my_module/ --api=8

It generates a general.pot file at the root directory of your Drupal installation. I move it into the translation folder but it's not necessary.
4. create your translation
To create a translation I'm using Poedit as editor. You can create different language files from the general.pot template. The free version of Poedit is quiet useful for editing *.po files. Save your language files in the translation folder.
5. import the translations
Run the following commands to import the translations:
drush locale-check && drush locale-update

And clear the cache:
drush cr

That's it ;)
Comment: Oh sorry, I forgot to mention it is a Drupal  7 installation.
Comment: A sorry but then the procedure is similar. Then you can use the official potx module.


Dot Product and vector length

Question:
Hi! I am working on some online homework for my calc2 class that covers the dot product and I am really struggling with this one question. I understood how to solve part a, because we covered that in class, but I am not sure how to solve parts b and c. I tried plugging in the values that were provided for ||v||and ||w|| into the equations of parts b and c, but that did not work. If someone can help me solve parts b and c of this problem I would really appreciate it!
Answer: Hint:
If $\mathbf{a}$ and $\mathbf{b}$ are vectors and $\alpha$ and $\beta$ are scalars then
\begin{align}
\left\|\alpha\mathbf{a}+\beta\mathbf{b}\right\|^2&=(\alpha\mathbf{a}+\beta\mathbf{b})\cdot (\alpha\mathbf{a}+\beta\mathbf{b})\\
&=\alpha^2\left\|\mathbf{a}\right\|^2+2\alpha\beta\mathbf{a}\cdot\mathbf{b}+\beta^2\left\|\mathbf{b}\right\|^2\\
&=\alpha^2\left\|\mathbf{a}\right\|^2+2\alpha\beta\left\|\mathbf{a}\right\|\left\|\mathbf{b}\right\|\cos\color{red}{\theta}+\beta^2\left\|\mathbf{b}\right\|^2
\end{align}
Where $\theta$ is the angle between $\mathbf{a}$ and $\mathbf{b}$.
Answer: Note that $$||a+b||^2=||a||^2+||b||^2$$
Hope this helps,
Answer: Simplest way: WLoG, let $w=3\hat{x}$

Dot Product and vector length


How do I report Errata?

Question: I have come across instances of errors in scores (in editions I otherwise really like) that I can obviously correct for myself. The problems are twofold: First, it makes me wonder where the other errors - and the ones I might not find would be. Second, it'd obviously be better for somebody to be able to web search '[isbn] errata' for a list of all that's been found. I get that this is a problem with all of publishing (maybe not a good fit for music.stackexchange), but musical errors can have a much bigger impact: Most typos are the difference between a slur ending on this note or that, but a wrong accidental is the difference between 'blue' and 'orange' (and a wrong time signature, or an incomplete measure is like the difference between 'green' and 'recidivism').
Look, there's nothing to be ashamed of - there are a million notes to check on - it'd just be nice if there were errata, and I want to know how to report what I've found.
Answer: Send a note to the publisher and, if possible, the author/editor. I've done this a handful of times, and in each case the error was corrected in the next edition. (Plus, they put my name in the acknowledgments, which was cool.)
The problem of score-engraving errors, by the way, is one reason that many musicians own multiple editions of the same piece. It's also why scholarly editions include notes on the choices of editorial decisions, often discussion historical errors or uncertainties.

How do I report Errata?


Is $g(x^n)$ a convex function of $x$, if $g$ is a convex function of $x$ and $n>2$; given $x$ is nonnegative?

Question: Is $g(x^n)$ a convex function of $x$, if $g$ is a convex function of $x$ and $n>2$; given $x$ is nonnegative?
like $g(x^2)$ or $g(x^3)$
Comment: First, try to prove that is $f$ is convex nondecreasing and $h$ is convex then $f\circ h$ is convex. Then try to see why this is related to your problem.
Answer: Try $g(x) = -x$.
You might do better if $g$ is also nondecreasing.
Comment: I got it.But reading some unedited literature out there misled me.
Comment: Thanks a lot. so, the answer is probably that for nonnegative x, x^n is convex, if g is non-decreasing convex, then g(x^n) is convex, right?
Answer: A standard fact about convexity of composition is:

If $f$ is a convex function and $g$ is a convex non-decreasing function of one variable, then $g\circ f$ is convex.

For a proof, see The composition of two convex functions is convex.
This applies to your situation, if $g$ is also nondecreasing.


Understanding heartbeat in ASP.NET health monitoring

Question: Who's triggering the event? What are consequences/benefits of enabling it in <healthMonitoring enabled="true" heartbeatInterval="30"> except it appears every 30 seconds in the logs? Has it anything to do with NLB heartbeat?  What interval is better for production use?
Answer: Enabling it in this way in the web.config will cause the Application Domain to raise a WebHeartbeatEvent periodically (in your case every 30 seconds), basically to check if your application is 'still alive' (like checking a human's heartbeat). You can specify additional rules like this:
<healthMonitoring enabled="true" heartbeatInterval="100">
  <rules>
    <add name="Heart Beat Events"
      eventName="Heartbeats"
      provider="EventLogProvider"
      profile="Default"
      minInterval="00:01:00" />
  </rules>
</healthMonitoring>

Specifying 'EventLogProvider' will cause the events to be logged to the EventLog, but you could also write your own Provider, see here.
It has nothing to do with the NLB heartbeat by the way, which is only used for Load Balancing purposes.
Comment: Does that mean my app pool will never be recycled if recycle period is greater than heartbeatInterval?
Comment: @UserControl: What makes you think so?
Comment: I don't then understand "to check if your application is 'still alive'". So who's raising the event? ASP.NET worker process? Or is it raised by the application itself? If latter and the app is idle IIS will recycle it, won't it?
Comment: @UserControl: The events are raised by the application domain. So yes, I assume the application pool will be recycled by IIS. HeartbeatInterval is not a way to keep your app alive, only to monitor it.


Impossible to edit nodes, log to in etcetera after enabling Boost and editing .htaccess

Question: After installing and enabling Boost in my Drupal 7 site (locally on WAMP and I also tried it on a remote test site) it's not possible to send any forms, e.g. not possible to edit and save nodes, not possible to login etcetera.
The actual Boost caching works though. When I remove the generated htaccess rules from my .htaccess file, everything works as normal again (except that the Boost caching stops to work of course).
My guess is that it's something in the generated htaccess rules that my site does not approve of.
Here is how the added rows look like:
<code>  ### BOOST START ###

  # Allow for alt paths to be set via htaccess rules; allows for cached variants (future mobile support)
  RewriteRule .* - [E=boostpath:normal]

#  # Apache 2.4 bug workaround
#  # Enables Search from home page https://drupal.org/node/2078595#comment-8724321
#  RewriteCond %{REQUEST_METHOD} ^(POST)$
#  RewriteCond %{REQUEST_URI} /
#  RewriteRule .* / [S=3]

  # Caching for anonymous users
  # Skip boost IF not get request OR uri has wrong dir OR cookie is set OR request came from this server OR https request
  RewriteCond %{REQUEST_METHOD} !^(GET|HEAD)$ [OR]
  RewriteCond %{REQUEST_URI} (^/(admin|cache|misc|modules|sites|system|openid|themes|node/add|comment/reply))|(/(edit|user|user/(login|password|register))$) [OR]
  RewriteCond %{HTTPS} on [OR]
  RewriteCond %{HTTP_COOKIE} DRUPAL_UID [OR]
  RewriteCond %{ENV:REDIRECT_STATUS} 200
  RewriteRule .* - [S=2]

#  # Apache 2.4 bug workaround
#  # Enables caching of index/ home page
#  RewriteCond %{REQUEST_URI} ^/index\.php$
#  RewriteCond %{DOCUMENT_ROOT}/cache/%{ENV:boostpath}/%{HTTP_HOST}/\_%{QUERY_STRING}\.html -s
#  RewriteRule .* cache/%{ENV:boostpath}/%{HTTP_HOST}/\_%{QUERY_STRING}\.html [L,T=text/html]

  # NORMAL
  RewriteCond %{DOCUMENT_ROOT}/cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html -s
  RewriteRule .* cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html]

  ### BOOST END ###
</code>
Anyone who can help?
Comment: Since you are running WAMP, you are probably running Apache 2.4 and as such you should probably uncomment the Apache 2.4 lines (though that is probably not the cause of the problem, you might forget about it later if you don't do it now). Since form submission is a `POST` request to `user/login` boost should fail on the request method and the request uri rules. Are you sure you followed the [installation instructions](https://www.drupal.org/node/1459690) properly?
Comment: It turns out that this was an issue solved by this [thread](https://www.drupal.org/node/1416214). Sorry about the noise.
Answer: I finally found out that my question had an answer in this thread.
So I went back to Boost version 1.0, generated the htaccess code, pasted it in my .htaccess file and then updated to version 1.1 again (without changing the .htaccess file). Now everything seem to work fine.


In C#, should I use string.Empty or String.Empty or "" to intitialize a string?

Question: In C#, I want to initialize a string value with an empty string.
How should I do this?
What is the right way, and why?
string willi = string.Empty;

or
string willi = String.Empty;

or
string willi = "";

or what?
Comment: What's more important is the hilarious name of your variable.
Comment: better to use String.IsNullOrEmpty(string myString) though, surely?
Comment: See also this similar discussion for java: http://stackoverflow.com/questions/213985/is-making-an-empty-string-constant-worth-it
Comment: The thing that has interested me, is why is there even an Empty property. It is nice and everything, but not a necessary and a complete must.
Comment: I use [string.IsNullOrWhiteSpace(stringvalue)] ... works in .Net 4.0.
To initialize, I simply use:
[var text = "";]
Simple, readable and takes the least time to type :)
Comment: @ZombieSheep You can't use IsNullOrEmpty to set the value of a string variable...
Comment: Also, if you use code obfuscation. string.empty can be obfuscated where as "" won't be obfuscated. Again, not a huge difference nor will it matter that much if you are using some sort of obfuscation but it is a difference.
Comment: I just wish we could use simply `string willi;`
Comment: What's more important, is never to compare a string to Sting.Empty. Bad: if(s == "")
Good: if(s.Length == 0)
Comment: possible duplicate of [What is the difference between String.Empty and "" (empty string)?](http://stackoverflow.com/questions/151472/what-is-the-difference-between-string-empty-and-empty-string)
Comment: there _was_ a difference https://stackoverflow.com/questions/16618302/changed-behavior-of-string-empty-or-system-stringempty-in-net-4-5
Answer: Use whatever you and your team find the most readable.
Other answers have suggested that a new string is created every time you use "". This is not true - due to string interning, it will be created either once per assembly or once per AppDomain (or possibly once for the whole process - not sure on that front). This difference is negligible - massively, massively insignificant.
Which you find more readable is a different matter, however. It's subjective and will vary from person to person - so I suggest you find out what most people on your team like, and all go with that for consistency. Personally I find "" easier to read.
The argument that "" and " " are easily mistaken for each other doesn't really wash with me. Unless you're using a proportional font (and I haven't worked with any developers who do) it's pretty easy to tell the difference.
Comment: @tvanfosson: So have you (or a colleague) actually been bitten by this as a bug? I'm suspicious of this sort of claim without it actually having caused problems. I've been using "" for years without ever getting it wrong...
Comment: For some [obscure reason `string.Empty` is not a constant](http://stackoverflow.com/questions/507923/). That means that in a number of cases where a compile-time constant is required, `string.Empty` isn't even legal. This includes `case ""` blocks in **`switch`** statements, default values of **optional parameters**, parameters and properties in applying **attributes**, and a lot of other situations (left to the reader). So given that `string.Empty` is disallowed in some common situations, it is better to use the `""`-everywhere convention.
Comment: You have given me the inspiration to start developing in Times New Roman.
Comment: Your eyes can trick you when you are expecting to see "" you can easily mistake " " for "".  This is why it is easier to edit something that someone else has written.  Your brain doesn't have preconceived ideas about the text so it is easier to pick out the anonmalies.
Comment: Personally, I've always used String.Empty, I use capital 'S' whenever I want to use a static method on string, it's just a personal prefference that allows me to distinguish a type from a variable. But this is just a carry-over from using StringUtils.EMPTY in commons.lang from java. One point of interest is I'm almost blind and this definately does help with readability for me.
Comment: @Alan: I will try that to see what it's like. Personally I use spaces instead of tabs (and will fight to the death to do so ;) which I suspect makes it work less well for lining up bits parameters etc... worth a try though.
Comment: The biggest advantage of string.Empty is that you can more easily find the precise usages of it in an IDE such as Visual Studio.  A simple "find" operation for "" will return escaped quotes and "" representation in comments as well as the usages you're actually looking for.  Doing a code-inspection type of "find usages" of string.Empty will get you all of the usages of it solution-wide, where as finding usages of a string literal (like "") is limited to the scope of the assembly it's defined in.
Comment: Personally, I find my brain uses much less power interpreting a simple pattern `""` than String.Empty ("hey, there's a class and a property - what's it doing?") Does everyone who uses String.Empty also use String.Space(1)? If no space is hard to distinguish, then one or more might be also.
Comment: @MutantNinjaCodeMonkey: I can't remember ever searching for "" across a codebase, and if I did, my uses of "" in comments or verbatim string literals is sufficiently small that it wouldn't bother me much. If that's really the biggest advantage of `string.Empty`, it's a pretty miniscule one IMO.
Comment: Jon, I use Segoe UI 10 pt in VS. Beautiful, tabs line up perfectly anyway, and I can have much-much longer lines this way. Maybe I'm not a developer then :D
Comment: @gehho: *You* find it less readable - and that's fine - but I find it *more* readable than `string.Empty`. Using a monospaced font, the difference between "" and " " is very clear to me, and `string.Empty` is unnecessarily cluttered. But it's really just personal preference.
Comment: Why take the chance? Because I find "" more readable than string.Empty. Otherwise I'd definitely use the latter. Given a definite personal preference vs a *potential* risk that has never bitten me, however, I think it's reasonable to go for the code that the team finds most readable.
Comment: I think the "problem" is not that it *introduces bugs* (I also never had that), but that it is *less readable* and that you sometimes have to *look twice* whether the string is initialized as an empty string `""` or a space `" "`. Certainly, it is pretty rare that a string is initialized to a space, but I still often check that unconsciously. Therefore, I always go with `String.Empty` because it is clear from the first sight.
Comment: Debating on programming preferences is like debating on food preferences. It is impossible to prove one better than the other, because there is no _practical_ difference to those using it. It is certain that the consistent use of one over the other, will definitally cause to the less adaptive sort a bit of difficulty when they had to change their habbits, but, in truth, variaety is supposed to give each person freedom to develop its own style, although this freedom of choice has led to more wars(both armed and flame) than anything else.
Comment: I also develop in Javascript, VBScript, SQL, and VB6... and while string.Empty may only work in .Net, "" (or '') works everywhere. I like using the "", just for consistency across different languages in the same product.
Comment: The only probable point of confusion is between one double-quote and two single quotes... (" vs '') == WTF!?!?! Any "competent" programmer will deal equally easily with EITHER var s="" OR var s=String.Empty. But reading through the comments herein... it's nice to see confirmation that other folks have pathalogical, quasi-religious beliefs about program style, that really don't matter a rats bumpkin. I thought I was alone. Sigh.
Comment: `""` looks not much like `" "`, but it could possibly be confused with `'"'`.
Comment: I use string.Empty consistently, so no I haven't.  On the other hand, I frequently edit my SO posts because I screw up and double type words that I don't see until after I've posted it.  I'm just saying, why take the chance.  And, no, I don't get paid by the character.
Comment: @tvanfosson: I'll change my viewpoint when I see evidence that it causes a real rather than perceived problem :) I think that claiming it's relatively easy to introduce a bug when such a bug hasn't been seen is an overstatement. But yes, it's all personal opinion.
Comment: ① I use a proportional font and I have no trouble distinguishing `""` from `" "` (possibly depends on the font though); ② Even if it were hard to visually distinguish them, I think it would generally be clear from the code in context which one it should be.
Comment: @Ben: Can't say I've ever had a problem with that... especially as in many cases it wouldn't be valid due to the different type.
Comment: @Jon: I use spaces instead of tabs, too, I didn't mean literal tabs but indentation. Sorry for that. And please do try it---I used to be a Courier New/Monaco/Lucida Sans Typewriter fan, but I tried Segoe UI once and never looked back :)
Comment: @Alan: Have changed for the moment. May well use this for presentations - nice to get more on the screen, particularly when the font is all blown up...
Comment: @Jon: If you read my answer, you'll see that I expressed a personal preference with, to me, a rational reason.  You disagree.  Perhaps when you hit your 40's and your near vision starts to degrade you may change your viewpoint.  :-)
Comment: @Brett: On the other hand, in Visual Studio "string" ends up in a different colour. As you say, it's personal preference...
Comment: @Jon: Absolutely - personal preference! I just wanted to reply to your comment from `Nov 4 '08 at 20:27` where you ask whether it ever introduced a bug. It is not that it introduces bugs, but that I (unconsciously) need more time to interpret it (it is (milli)seconds, but still...). And I think that others who mentioned this case (like tvanfosson and Brett Ryan) meant just that. I did not want to try to convince you to use `String.Empty` - I just wanted to explain the reason why some people prefer it. :)
Comment: +1 for proportional font, but yeah, one needs to choose carefully or edit the font manually, since most have a space that's too narrow.
Comment: The Visual Studio 2015 update 3 C# editor's "Quick Actions" feature suggests to always "simplify" `String.Empty`, all over the place. when I accept the suggestion, it is converted to `string.Empty`. Would be interesting to know the rationale behind that.
Comment: _(and I haven't worked with any developers who do)_ well, I don't understand how people can use other fonts then Verdana for the sourcode ;-]
Comment: I had a PR issue asking me to change " " with string.Empty. Probably the most pedantic PR issue ever.
Comment: _"due to string interning, it will be created either once per assembly or once per AppDomain"_ That's true. But this possibly large pool has to be looked up everytime you use `""` instead of `string.Empty`. While this is micro optimization in most cases, it's worth noting that it's wasting cpu cycles. Or do current compilers replace `""` with `string.Empty` behind the scenes?
Comment: @TimSchmelter: When you say "everytime you use `""`" - I'd expect it to be once per time the string literal is used, per assembly load. So if you've got a method called in a loop, and that method uses `""`, it's not going to check it on every iteration of the method. I think the number of CPU cycles wasted here is likely to be utterly insignificant in the vast, *vast* majority of cases.
Comment: @JonSkeet: Thanks,  i was afraid that it needs to be looked up every time it is used. I just read that since  .NET 4.5 "ldstr "" is replaced with ldsfld string [mscorlib]System.String::Empty by the jitter" anyway.
Comment: After reading this, all I want to do is create a font that has a ligature to replace "" with string.Empty. For the LOLs of course
Answer: There really is no difference from a performance and code generated standpoint. In performance testing, they went back and forth between which one was faster vs the other, and only by milliseconds.
In looking at the behind the scenes code, you really don't see any difference either. The only difference is in the IL, which string.Empty use the opcode ldsfld
and "" uses the opcode ldstr, but that is only because string.Empty is static, and both instructions do the same thing.
If you look at the assembly that is produced, it is exactly the same.
C# Code
private void Test1()
{
    string test1 = string.Empty;
    string test11 = test1;
}

private void Test2()
{
    string test2 = "";
    string test22 = test2;
}

IL Code
.method private hidebysig instance void
          Test1() cil managed
{
  // Code size       10 (0xa)
  .maxstack  1
  .locals init ([0] string test1,
                [1] string test11)
  IL_0000:  nop
  IL_0001:  ldsfld     string [mscorlib]System.String::Empty
  IL_0006:  stloc.0
  IL_0007:  ldloc.0
  IL_0008:  stloc.1
  IL_0009:  ret
} // end of method Form1::Test1

.method private hidebysig instance void
        Test2() cil managed
{
  // Code size       10 (0xa)
  .maxstack  1
  .locals init ([0] string test2,
                [1] string test22)
  IL_0000:  nop
  IL_0001:  ldstr      ""
  IL_0006:  stloc.0
  IL_0007:  ldloc.0
  IL_0008:  stloc.1
  IL_0009:  ret
} // end of method Form1::Test2

Assembly code
        string test1 = string.Empty;
0000003a  mov         eax,dword ptr ds:[022A102Ch]
0000003f  mov         dword ptr [ebp-40h],eax

        string test11 = test1;
00000042  mov         eax,dword ptr [ebp-40h]
00000045  mov         dword ptr [ebp-44h],eax

        string test2 = "";
0000003a  mov         eax,dword ptr ds:[022A202Ch]
00000040  mov         dword ptr [ebp-40h],eax

        string test22 = test2;
00000043  mov         eax,dword ptr [ebp-40h]
00000046  mov         dword ptr [ebp-44h],eax

Comment: @PrateekSaluja: To see the IL you can use ildasm.exe, which ships with Visual Studio. To see diassembly, use the 'Disassembly' window on the debug menu when you hit a breakpoint (works in release code too).
Comment: Hate that i am about to recommend this product.. BUT .. reflector lets you choose your language when disassembling the source and IL is an option!  ILDASM is just dated feeling... MS tools team does not seem to polish or release the good tools!
Answer: The best code is no code at all:

The fundamental nature of coding is that our task, as programmers, is to recognize that every decision we make is a trade-off. […] Start with brevity. Increase the other dimensions as required by testing.

Consequently, less code is better code: Prefer "" to string.Empty or String.Empty. Those two are six times longer with no added benefit — certainly no added clarity, as they express the exact same information.
Comment: I agree that code should be as small as possible but wouldn't generally argue that less characters is always better code. When it comes to variable naming for example, a reasonable amount of characters generally result in better names than just using i and j.
Comment: To me:
string.Empty says this string is and should be Empty at all times, whereas "" says at the time of writing this string could be empty but you are free to change it.
Comment: @Markus That highly depends: for a loop variable representing an index, `i` *is* better than a long variable name. Even more general, shorter variable names *that convey the same information*, in the same clarity, are always preferable. It's just that to express the necessary information you *need* a certain character length, and I'm not denying this (nobody is).
Comment: but in C# we can just say string.IsNullOrWhitespace(s) :p
Comment: @Konrad: i is a good variable name only if the loop is small and it doesn't contain any other indices. But I agree that if sth. can be stated more briefly conveying the same information, that would be preferrable, like in the string.Empty / "" case. The string.Empty does not add any clarity.
Comment: Brevity should always be trumped by readability. There is a reason why the framework developers added `String.Empty` and that wasn't just for performance issues but also to make it very clear what the intent is. Whilst scanning through code it's much easier to identify (and search for) than `""`.
Comment: @aeroson Feel free to interpret everything the way you want but be aware that nobody else will share your highly idiosyncratic reading, and thus don't rely on it to communicate intent: Nobody will get it.
Comment: @aeroson Strings are immutable, so there is no changing them. If you are referring to changing what is in the _variable_, I would not presume such an intent from what is initially assigned to that variable.
Comment: @DanDiplo You cannot seriously argue that `String.Empty` is more readable than `""`. It plain *isn't*, and contrary to your claim there's no evidence that the framework developers think so (I can't read their minds but I'm pretty sure that they don't think that and that, if anything, they probably see its presence as a mistake in hindsight). Let's ping Eric Lippert — although the chances of reading this are probably slim.
Comment: @Dan Diplo They USE it but they don't EXPLAIN it. So you can safely consider it a coincidence.
Comment: @KonradRudolph In Microsoft's recent examples for "Best Practices Using String in .NET Framework" they use `String.Empty` - see https://learn.microsoft.com/en-us/dotnet/standard/base-types/best-practices-strings#recommendations_for_string_usage
Answer: One difference is that if you use a switch-case syntax, you can't write case string.Empty: because it's not a constant. You get a Compilation error : A constant value is expected
Look at this link for more info:
string-empty-versus-empty-quotes
Comment: The `switch` statement is one very good example. Also, if you make an optional parameter, like `void MyMethod(string optional = "") { ... }`, it's also not possible to use `string.Empty`. And then of course if you want to define a `const` field or local variable, `const string myString = "";` the again `""` is the only option. If only `string.Empty` were a constant field, there wouldn't be a difference. But it's not, so in some cases you have to use `""`. So why not use `""` all the time?
Comment: This is a really strong argument because using `string.Empty` prevents you from attaining **consistency** in your code base: you must use two different entities to express the same thing. And to add to the list of things you can't do: you can't use `string.Empty` with **attributes**.
Comment: Very good points! The link is broken. Here's a copy of the content: http://web.archive.org/web/20131230161806/http://kossovsky.net/index.php/2009/06/string-empty-versus-empty-quotes/
Comment: Sam issue with default arguments in functions. Needs to be a compile-time constant!
Answer: I'd prefer string to String. choosing string.Empty over "" is a matter of choosing one and sticking with it. Advantage of using string.Empty is it is very obvious what you mean, and you don't accidentally copy over non-printable characters like "\x003" in your "".
Comment: I'd argue that if you're accidentally copying non-printable characters into your code, you've got bigger problems than this question ;)
Comment: ASCII \003 happens to be a field delimiter for B2B Messages I've worked with :)
Comment: (I'd also suggest avoiding the \x escape, btw - it's too hard to spot the difference between "\x9Bad Compiler" and "\x9Good Compiler" which have *radically* different results!)
Comment: You use copy/paste to type `""`...?
Comment: @Jimmy Sure, but we were talking about the empty string. The argument that `""` is dangerous when copy/pasting is void, I claim, because you never copy/paste the empty string. For other strings, it is always something to be mindful of, of course.
Comment: Personally I prefer String over string whenever calling a static method on String. I'm almost blind however and this is a personal preference that I don't enforce on anyone.
Comment: I would probably declare a const over `"\x003"`. :)
Comment: I've been bitten by something similar, where I've got a document with strings with unprintable characters in a new job ... :)
Comment: @Timo Don't take the example literally. Pretend it was copying a blob of text with embedded non-printable characters from API documentation.
Comment: @Jimmy Why there are non-printable characters in a DOCUMENTATION?! That sounds so wrong...
Answer: I wasn't going to chime in, but I'm seeing some wrong info getting tossed out here.
I, personally, prefer string.Empty. That's a personal preference, and I bend to the will of whatever team I work with on a case-by-case basis.
As some others have mentioned, there is no difference at all between string.Empty and String.Empty.
Additionally, and this is a little known fact, using "" is perfectly acceptable. Every instance of "" will, in other environments, create an object. However, .NET interns its strings, so future instances will pull the same immutable string from the intern pool, and any performance hit will be negligible. Source: Brad Abrams.
Comment: I don't see why "technically" every instance of "" will create an object. It's not just chance that strings are interned - it's in the C# spec.
Comment: There is a difference between `string.Empty` and `String.Empty`. The first uses the C# language keyword `string` so it always works. The latter only works with `using System;` in the file. Prefer `string` over `String` always.
Answer: This topic is pretty old and long, so excuse me if this behavior has been mentioned somewhere else. (And point me to the answer that covers this)
I have found a difference in the behavior of the compiler if you use string.Empty or double quotes. The difference shows itself if you don't use the string variable initialized with string.Empty or with double quotes.
In case of initialization with string.Empty then the Compiler Warning
CS0219 - The variable 'x' is assigned but its value is never used

is never emitted while in case of initialization with double quotes you get the expected message.
This behavior is explained in the Connect article at this link: https://connect.microsoft.com/VisualStudio/feedback/details/799810/c-warning-cs0219-not-reported-when-assign-non-constant-value
Basically, if I get it right, they want to allow a programmer to set a variable with the return value of a function for debugging purposes without bothering him with a warning message and thus they limited the warning only in case of costant assignments and string.Empty is not a constant but a field.
SOME YEARS AFTER
Microsoft has retired the https://connect .microsoft.com website so the discussion there is no more available. However there is this article https://learn.microsoft.com/en-us/dotnet/csharp/misc/cs0219 with an interesting remark that seems to confirm the previous reasons:

The compiler generates this warning only when the variable value is a
compile-time constant. Assigning a non-constant expression or method
result to a local variable makes it easier to observe those
expressions in the debugger. It also makes the result reachable,
preventing garbage collection while that variable is reachable.
Comment: Interesting. Note that a declaration `var unused = "literal";` can be completely optimized away (removed) by the compiler. It can have no side effects. On the other hand, `var unused = MyClass.Member;` cannot be removed entirely. That is because reading `Member` could have side effects. If `Member` is a static property with a `get` accessor, it is clear that the call to the getter must be kept. But even if `Member` is a static field, there may be the side effect that the static constructor may run. Sure it would be _bad coding style_ to have it that way. But you need a dummy to read `Member`.
Comment: I believe you're the first one to mention. I have read through this Q&A several months ago and don't remember this difference, which I would if it had been mentioned.
Answer: I personally prefer "" unless there is a good reason to something more complex.
Answer: String.Empty and string.Empty are equivalent. String is the BCL class name; string is its C# alias (or shortcut, if you will). Same as with Int32 and int. See the docs for more examples.
As far as "" is concerned, I'm not really sure.
Personally, I always use string.Empty.
Answer: I performed a simple test using following method in a .NET v4.5 console application:
private static void CompareStringConstants()
{
    string str1 = "";
    string str2 = string.Empty;
    string str3 = String.Empty;
    Console.WriteLine(object.ReferenceEquals(str1, str2)); //prints True
    Console.WriteLine(object.ReferenceEquals(str2, str3)); //prints True
}

This suggests that all three variables namely str1, str2 and str3 though being initialized using different syntax are pointing to the same string (of zero length) object in memory .
So internally they have no difference. And it all boils down to convenience of which one you or your team wants to use. This behavior of string class is known as string interning in .NET Framework. Eric Lippert has a very nice blog here describing this concept.
Answer: Just about every developer out there will know what "" means.  I personally encountered String.Empty the first time and had to spend some time searching google to figure out if they really are the exact same thing.
Comment: You miss the point that @Jason makes. How do you know what it is the first time you see `string.Empty`? Did you know what `""` was the first time you saw it?
Comment: It is a public readonly string field and its values is ""... why would that change?
Answer: Any of the above.
There are many, many better things to pontificate. Such as what colour bark suits a tree best, I think vague brown with tinges of dulcet moss.
Answer: string is synonym for System.String type, They are identical.
Values are also identical: string.Empty == String.Empty == ""
I would not use character constant "" in code, rather string.Empty or String.Empty - easier to see what programmer meant.
Between string and String I like lower case string more just because I used to work with Delphi for lot of years and Delphi style is lowercase string.
So, if I was your boss, you would be writing string.Empty
Comment: I write "" if I mean "" and I assume that others also write what they mean - otherwise it's a bug. If you care about string.Empty as a boss you newer would be my boss and your company probably wouldn't exist very long. :)
Answer: I strongly prefer String.Empty, aside from the other reasons to ensure you know what it is and that you have not accidentally removed the contents,
but primarily for internationalization.
If I see a string in quotes then I always have to wonder whether that is new code and it should be put into a string table. So every time code gets changed/reviewed you need to look for "something in quotes" and yes you can filter out the empty strings but I tell people it is good practice to never put strings in quotes unless you know it won't get localized.
Answer: No one mentioned that in VisualStudio String is color coded differently then string. Which is important for readability. Also, lower case is usually used for vars and type, not a big deal but String.Empty is a constant and not a var or type.
Comment: String.Empty is not a constant: see https://stackoverflow.com/questions/507923/why-isnt-string-empty-a-constant
It's actually an instance of the String class, by design.
And coloring was mentioned before though a bit hidden: https://stackoverflow.com/questions/263191/in-c-should-i-use-string-empty-or-string-empty-or-to-intitialize-a-string#comment1251042_263257
Answer: I doesn't make a difference. The last one is the quickest to type though :)
Answer: It is totally a code-style preference, do to how .NET handles strings. However, here are my opinions :)
I always use the BCL Type names when accessing static methods, properties and fields: String.Empty or Int32.TryParse(...) or Double.Epsilon
I always use the C# keywords when declaring new instances: int i = 0; or string foo = "bar";
I rarely use undeclared string literals as I like to be able to scan the code to combine them into reusable named constants. The compiler replaces constants with the literals anyway so this is more of a way to avoid magic strings/numbers and to give a little more meaning to them with a name. Plus changing the values is easier.
Answer: I would favor string.Empty over String.Empty because you can use it without needing to include a using System; in your file.
As for the picking "" over string.Empty, it is personal preference and should be decided by your team.
Comment: I'm the only member of the team, how do I decide? throw a dice?
Comment: For those who might be wondering as to how it is possible to use `string.Empty` constant without importing `using System` namespace - Keywords in C# simply get converted to their fully qualified name which includes the namespace as well before being written as MSIL in the output *.dll or *.exe file. So effectively `string.Empty` gets written as `System.String.Empty` in the MSIL by the compiler. And as you already might be knowing that if you mention fully qualified type name then you can give a skip to importing namespaces at the top of your code file.
Answer: Either of the first two would be acceptable to me.  I would avoid the last one because it is relatively easy to introduce a bug by putting a space between the quotes.  This particular bug would be difficult to find by observation.  Assuming no typos, all are semantically equivalent.
[EDIT]
Also, you might want to always use either string or String for consistency, but that's just me.
Comment: I agree with this remark, but I still live dangerously when I'm lazy. In any event, I don't think I have occasion to write code that uses a string before assigning to it outside of the variable declaration. In fact, it's annoying to me that I have to initialize my strings at all, despite the risks.
Answer: It doesn't matter - they are exactly the same thing.
However, the main thing is that you must be consistent
p.s. I struggle with this sort of "whats the right thing" all the time.
Comment: In the modern world, "consistent" means consistent across all teams world-wide, which is one of the StackOverflow's goals.

If I may suggest, let's use String.Empty.
Comment: Some languages don't have an Empty constant, and all of the languages I can think of allow for "" a zero-length string. So I vote for "" for consistency with other languages. :)
Comment: You don't have to be consistent.
Answer: I have personally witnessed "" resulting in (minor) problems twice. Once was due to a mistake of a junior developer new to team-based programming, and the other was a simple typo, but the fact is using string.Empty would have avoided both issues.
Yes, this is very much a judgement call, but when a language gives you multiple ways to do things, I tend to lean toward the one that has the most compiler oversight and strongest compile-time enforcement. That is not "". It's all about expressing specific intent.
If you type string.EMpty or Strng.Empty, the compiler lets you know you did it wrong. Immediately. It simply will not compile. As a developer you are citing specific intent that the compiler (or another developer) cannot in any way misinterpret, and when you do it wrong, you can't create a bug.
If you type " " when you mean "" or vice-versa, the compiler happily does what you told it to do. Another developer may or may not be able to glean your specific intent. Bug created.
Long before string.Empty was a thing I've used a standard library that defined the EMPTY_STRING constant. We still use that constant in case statements where string.Empty is not allowed.
Whenever possible, put the compiler to work for you, and eliminate the possibility of human error, no matter how small. IMO, this trumps "readability" as others have cited.
Specificity and compile time enforcement. It's what's for dinner.
Answer: I use the third, but of the other two the first seems less odd.
string is an alias for String, but seeing them across an assignment feels off.
Answer: I was just looking at some code and this question popped into my mind which I had read some time before. This is certainly a question of readability.
Consider the following C# code...
(customer == null) ? "" : customer.Name

vs
(customer == null) ? string.empty : customer.Name

I personally find the latter less ambiguous and easier to read.
As pointed out by others the actual differences are negligible.
Answer: The compiler should make them all the same in the long run.  Pick a standard so that your code will be easy to read, and stick with it.
Answer: While difference is very, VERY little, the difference still exists.

"" creates an object while String.Empty does not. But this object will be created once and will be referenced from the string pool later if you have another "" in the code.

String and string are the same, but I would recommend to use String.Empty (as well as String.Format, String.Copy etc.) since dot notation indicates class, not operator, and having class starting with capital letter conforms to C# coding standards.
Comment: string.Empty *is* "", check the source
Answer: I use "" because it will be colored distinctively yellow in my code... for some reason String.Empty is all white in my Visual Studio Code theme. And I believe that matters to me the most.
Answer: I think the second is "proper," but to be honest I don't think it will matter. The compiler should be smart enough to compile any of those to the exact same bytecode. I use "" myself.
Answer: On http://blogs.msdn.com/b/brada/archive/2003/04/22/49997.aspx :

As David implies, there difference between String.Empty and "" are pretty small, but there is a difference. "" actually creates an object, it will likely be pulled out of the string intern pool, but still... while String.Empty creates no object... so if you are really looking for ultimately in memory efficiency, I suggest String.Empty.  However, you should keep in mind the difference is so trival you will like never see it in your code...
  As for System.String.Empty or string.Empty or String.Empty... my care level is low ;-)
Comment: That MSDN blog post was in 2003.... are you sure that this is still true for recent .NET versions?!
Comment: @sergiol If a field is more efficient than a literal then this is unambiguously a performance bug. So there's hoping that it would be fixed by now.
Comment: @CarstenSchütte: Seems to me that such a feature is not intended to change very much ... and if it was, there was some buzz on the Internet about it.
Answer: The empty string is like empty set just a name that everybody uses to call "". Also in formal languages strings created from an alphabet that have zero length are called the empty string. Both set and string have a special symbol for it. Empty string: ε and empty set: ∅. If you want to talk about this zero length string you will call it the empty string so everybody knows exactly what you are referring to. Now in case you name it the empty string why not use string.Empty in code, its shows the intention is explicit. Downside is that it's not a constant and therefore not available everywhere, like in attributes. (It's not a constant for some technical reasons, see the reference source.)
Answer: Possibly a controversial comment, but, generally, I find that my life is easier when I act consistently with Microsoft. We can't possibly know the full deeply embedded reasons (sometimes highly rigorous, and sometime kludgy, I imagine) for why they do things.
They use "" in automatically generated files like the Assembly file, so that is what I do. In fact, when I try to replace any below "" with String.Empty, Visual Studio crashes on me. There is probably a logical explanation for this, but with my limited knowledge, if I just do what they do, most of the time, things work out. (Contra: I am aware they some automatically generated files also use String.Empty, which kind of shatters my point. :) )
<Assembly: System.Reflection.AssemblyCulture("")>
<Assembly: System.Reflection.AssemblyDescription("")>
<Assembly: System.Reflection.AssemblyFileVersion("18.104.22.168")>
<Assembly: System.Reflection.AssemblyKeyFile("")>
<Assembly: System.Reflection.AssemblyProduct("")>
<Assembly: System.Reflection.AssemblyTitle("")>

Comment: Expand your knowledge by reading the other answers and by taking your time to actually understand them. :-) Maintaining consistency with the rest of your codebase and with other codebases (.NET itself, generated code...) is a good rule of thumb, but it is not always clearly applicable and sometimes even harmful -- e.g. you need to do something very specific or you are the first one to spot a deficiency in current practices on the team. Moreover, consistency with something you don't understand may lead to [cargo cult programming](https://en.wikipedia.org/wiki/Cargo_cult_programming).


Call to function's are not responding

Question: HTML CODE of the slider

<button id="l"  onClick="imagem()"><</button>

<button id="r" onClick="image()">></button>

JavaScript Code Of the slider

Kindly someone help me to figure out this problem. The call to function auto() and call to "function imageShow" is not responding.
Comment: I haven't tried to run any of this, but you are calling auto before declaring what auto is. That will be a problem.
Comment: try `setTimeout(auto(),5000);`
Answer: You should call auto() function after define it.
var aa = ["im1.jpg", "im2.jpg", "im3.jpg", "im4.jpg", "im5.jpg", "im6.jpg"];
var a = 1;

function image() {
    a++;
    imageShow(a);
}

function imagem() {
    a--;
    imageShow(a);
}

function imageShow(r) {
    if (r > aa.length) {
        a = 1;
    }
    if (r < 1) {
        a = aa.length;
    }
    document.getElementById("aaa").src = aa[a - 1];
}

function auto() {
    if (a > aa.length) {
        a = 1;
    }
   document.getElementById("aaa").src = aa[a - 1];
   a++;
   setTimeout(auto, 5000);
}
auto();

Comment: It works on my browser. Maybe other codes causes the problem.

Call to function's are not responding


Why is a violin so loud compared to a guitar?

Question: The violin is comparatively louder than a guitar.
This is a surprising fact, given that:

the violin instrument is generally smaller than, say, a typical classical or folk guitar,
both use strings.

In other words, how can such a small instrument as a violin be so loud? Is the fact that the strings of a guitar are pinched compared to the bowed strings of a violin the main and only reason?
Comment: How can one 12 -inch piccolo be heard over a 96-piece symphony orchestra plus a piano and two harps, not to mention the ten or more brass instruments and about 60 string players? Triangle ditto? Your question is founded on a false assumption. Several.
Comment: So that deaf people can hate them too....?
Comment: Try comparing a guitar with pizzicato violin.
Comment: It isn't.  You are making a blanket statement that simply is not true.  I think any attempt to answer it would be chasing a red herring.  You need to compare apples to apples.  I've never heard a plucked violin be louder than a plucked guitar.  The bow means energy is continually being added so it will sustain longer.  But peak volume can be greater for the guitar.  It also depends on frequency since the ear responds to low freq differently than high freq.  There are so many diffs how do you know what you are comparing?
Comment: @ggcg Indeed. I wonder if this question is asked after comparing a guitar and a violin in real life from nearby. I have attended unamplified solo classic guitar concerts that are loud enough to entertain a 2000-seat hall, where a symphony orchestra would need a battery of violins. As to size, is a piccolo not loud? Is a contra-bass very loud? Yes, a single pluck cannot transfer that much energy, but how about a lot of plucks in a piece with a lot of notes? And how about jamming with say three fingers over all strings at once?
Comment: Any nearer look at the strings of those instruments, will make evident, that the name is the most similar part, see [this question](https://music.stackexchange.com/q/41705/2600).
Comment: I was tempted to say turn the amp up, but Jean luc ponty has an electric violin.
Answer: Without researching the matter (and thus preserving Internet Tradition), I'd say that it's because the input energy to a guitar is a single pluck whereas a violin is bowed giving a continuous energy transfer. Pizzicato violins are not as loud a bowed.
Comment: I do know from experience that playing a double bass sounds much louder when using the bow than when plucking. Plucking puts a large amount of sound energy in but for a small amount of time, then the sound decays. Bowing puts in perhaps a smaller amount of energy but this continues and there is no decay.
Comment: On the other hand, when striking a guitar with a pick you can also impart a fairly powerful impulse, compared to the relatively constrained motion used on a violin. I wonder if it would be more accurate to say that when the same amount of work is done on either instrument, the guitar will have a louder note onset and faster decay while the violin will have a more modest onset but consistent sustain. The total amount of sound energy produced would be similar in both cases.
Comment: @IlmariKaronen no, guitar played with bow is not louder, because **a)** the strings are aligned in a way that makes it impossible to properly apply bow pressure **b)** the guitar's bridge is not very suitable for picking up the transversal motion that a bow induces.
Comment: I suppose the obvious test would be whether [playing a guitar with a bow](https://en.wikipedia.org/wiki/Bowed_guitar) makes it sound louder than plucking it. (FWIW, while there are plenty of videos online of people playing guitar with a bow, unfortunately none of those I've seen so far really provide a good loudness comparison.)
Comment: From my experience playing with violin and guitar instrumentalists, I think that's the correct answer. I don't know how loud a bowed guitar sounds, but a pizzicato violin sounds very quiet compared to an acoustic guitar. Violin players use pizzicato whenever they want to think about tones "aloud but to themselves" (check something related to the use of given tones, fingerboard positions, etc.) Also if you listen to a guitar + violin duo (à la Reinhardt + Grappelli, for example), the result is pretty balanced. Here in Madrid we have one of such duos performing so they prove this regularly...
Comment: The bow does NOT make it louder it creates a sustained note.  That means it will have a particular volume for essentially an indefinite amount to time.  But that does not mean that the max volume or loudness of the violin is greater than that of a guitar.  The OP and this answer are very ill conceived.
Comment: The plucked string decays in volume. Thus a sustained tone becomes relatively louder as time passes. The maximum volume isn't necessarily higher, but the time integrated volume is. This can make the violin sound louder. There a complicated relation between peak and sustained volume (which I don't know enough about go into details.)
Comment: Time integrated volume means nothing.  Comparing signals collected by an array of mics you peak is what matters.  And the bowed string does NOT increase in volume unless the player is increasing pressure as they play for dynamics.
Answer: You are asking for loudness, not volume, correct? Volume is refering to physical properties (i.e. the amplitude of the sound waves), whereas loudness is the perceived volume which can differ a lot from the actual SPL (sound pressure level), althoug the SPL is still a major factor.
The loudness is also dependent on frequencies and bandwidth of the audio signal. One other factor, which can play a significant role, is your ears. With age some form of hearing loss occurs. Some people hear certain frequencies much louder than others. I, for example did a hearing test and found out that I perceive a 2 kHz signal as loudest compared to other frequencies at the same SPL.
When I play my electric guitar without an amp, I clearly perceive the higher strings to be much louder than the lower strings. But I have a calibrated decibel meter and I have just run a test: it showed the same dbA value for the lowest and highest string (I know that dbA is different from db SPL but for the sake of this argument, the difference does not play a great role in this situation.) This clearly proves that perceived loudness is highly subjective and it all happens in our brains.
Comment: Yes, this.  Same thing with light - green light seems "brightest" to human eyes because we're most sensitive to it.  Guitars play in a lower register than the violin - those higher notes we're more sensitive to and perceive as louder.  Like standing at talking distance from a tenor singing a C5 fortississimo and an oktavist doing G1 the same.  You'd want earplugs for the tenor, certainly.
Answer: According to this post, higher-pitched sounds seem to the human ear to be louder than lower-pitched ones. In general, a violin is going to be playing in a higher register than a guitar.
Comment: This points out one of the main problems with the original question in the first place.  I cannot believe it got so many votes and the accepted answer says absolutely nothing useful.  + 1
Comment: Thanks! I was also tempted to include something regarding the effect of multiple strings creating sound vs. one string creating sound and/or the fact that a violin is traditionally a melodic instrument vs. a guitar can be either melodic or harmonic, but that's all anecdotal.
Comment: It's such a bad question.  It begs an answer that isn't true based on physics.  I recently answered one regarding the high and low pitch strings of a piano that was likewise a red herring.  I'd like some proof that the OP statement is actually true.
Comment: They're marked as a new contributor, so they may not have familiarity with music. As such, the question may simply be based on a faulty assumption.
Comment: I am sure there are many faulty assumptions.  New or not we don't know if the person is only new here and otherwise knowledgeable of physics or acoustics.  In general one can word a question so that it isn't a red herring regardless of their proficiency in a set of subjects.  They could have asked whether or not their perception of volume is known to be true universally, if there are known studies about this.  There are so many variables and the opening statement is provided as a self evident truth.  If someone can provide measured values that would be GREAT!
Answer: The idea, that the the size of an acoustic instrument is an indication of its loudness is somewhat astonishing. It simply effects (based on trustworthy physical laws), that is maximum resonance frequency is in a different range. So violas are typically likely less loud than violins.
As hinted in my comment, the material of the string can't be neglected either in respect to color of tone and volume, as the pure guitar-based comparison of nylon and steel strings shows.
Comment: Yes. (The real reason viola is less loud than violins, however, is that half the players in the section only pretend to be playing, while the other half keep it down to hide their bad intonation...)
Comment: This is wrong. See https://music.stackexchange.com/a/77480/9480 .
Comment: @BenCrowell: Your comment (and presumed downvote) lacks specificity, your referred answer is also not beyond  discussion.
Answer: How loud an instrument sounds is not determined by its size. It's determined by the amount of coupling between the string (or whatever is generating the tone) and the air around the instrument.
Compare an acoustic guitar with an electric guitar: They are both of the same size, they both may use exactly the same strings (though they prefer different gauges). But one is loud enough to sing along (the acoustic guitar) while the other can hardly be heard unless you plug it into an amp. The difference? The electric guitar is basically a solid slap of wood that's purposefully way too heavy to vibrate significantly. As such, the vibration energy stays in the strings for a longer time, giving the instrument a much longer sustained sound than the acoustic guitar does. The acoustic guitar, by contrast, is built such that the thin planks of wood vibrate along with the strings, so that the vibrations can actually be turned into sound waves efficiently. The acoustic guitar has a much, much higher coupling between the strings and the surrounding air than the electric guitar.
Of course, this coupling is a continuous scale. You can find guitars that are louder (stronger coupling), and you can find violins that are quieter (weaker coupling) than other instruments of the same sort. But the violin has seen very intensive use as an orchestra instrument where a certain amount of volume is a must. And a strong coupling is not a problem for a violin because energy is constantly being supplied by the bow: There is no need to sustain a sound for a while. The guitar, on the other hand, is a plucked instrument, and as such the amount of available energy is fixed. The longer a note sounds, the quieter it gets. And the stronger the coupling is, the quicker the note will fade away. Which is not what most guitarists want: When they were able to reduce the coupling by relying on electric amplification instead, they almost immediately reduced the coupling to effectively zero in order to get a good, long sustain.
Comment: An interesting demonstration of the relationship between volume and sustain can be observed in some handbell pieces where players ring a bell and then, on a later beat, touch the bell very lightly to a padded table.  This actually causes the volume of the bell to increase momentarily, though it will greatly reduce the sustain.
Comment: Use a bow on an acoustic guitar and the neighbors will call the cops.
Answer: If you want to reduce the amount of sound a violin makes then move the soundpost. If you want to drastically reduce the amount of sound then remove it altogether (but be careful of the bridge falling down if you do that).
OK, not a serious suggestion to try on a good violin but it makes the point that the quality and amount of sound a violin makes is determined by the way the instrument is "set up" and in particular the positioning of the soundpost.
According to Wikipedia:

The position of the sound post inside a violin is critical, and moving
  it by very small amounts (as little as 0.5mm or 0.25mm, or less) can
  make a big difference in the sound quality and loudness of an
  instrument.

For non-violinists, the soundpost is a small wooden dowel which is placed (not glued) roughly under the bridge. When the strings are tuned (i.e. tightened) this applies pressure to the soundpost and it performs acoustic coupling with the back of the violin transferring additional sound energy.
A guitar doesn't have a soundpost and hence produces less sound.
Comment: This is not really correct. The soundpost is a feature of the instrument structure which allows a much thinner, weaker top. The difference is the entire structure, not just the soundpost.
Comment: Both is not correct. The soundpost is a feature that changes the transversal bowed-string motion into usable altitudinal motion of the top. It does _not_ magically make an instrument louder per se, specifically it would not make a guitar louder, rather the other way around: _without_ the sound post, phase cancellation would make the violin much quiter than it should be. https://music.stackexchange.com/questions/23613/whats-the-purpose-of-a-sound-post — So, giving the sound post as the reason why violin is louder makes no sense (though it's true that removing it would quiten the violin).
Answer: Resonance. Range and bow help too.


How to know that jquery is executed successfully and now i can trigger any other action

Question: I am doing a module in which jquery plugin is installed on webpage and being executed in javascript.
I am having trouble in finding whether the jquery have been executed full successfully or is still in working....
Thanks in advance
Comment: Please show some code, your question is too vague
Comment: You'll have to be elaborate...
Comment: As long as you include the script for the jQuery plugin before your script, you should be fine
Comment: please elaborate , what is it working on and you want to check if it finished successfully exactly  ? and add your code to the question
Answer: See http://api.jquery.com/ready/
By running your code off a handler such as in
$(document).ready(handler)
you can know it's been called by jQuery after jQuery was loaded.
Comment: thanks wulf solter.... it worked for me


Change all characters in a column over multiple lines

Question: I'm not sure how to explain what I'd like to do, but I've seen this in Textmate and it was quite useful. Let's say I have this text:
:aa => foo,
:ab => foo,
:ac => foo,
:ad => foo

Now I want to select all first characters of the keys (the 4 'a' in the lne) and remove them, so that the result looks like this:
:a => foo,
:b => foo,
:c => foo,
:d => foo

Some kind of visual mode accounting columns not lines.
Answer: Use Ctrl+V to enter blockwise visual mode. You can then select a block of text using the normal movement keys and press x to delete it. I will perform a multi-line insert.
See :help ^V and :help visual-operators in vim for full details.
Answer: Use vim in column mode. To use it, press:

Ctrl+V to go into column mode.
Select the columns and rows where you want to enter your text.
Shift+I to go into insert mode in column mode.
Type in the text you want to enter.
Note: Don't be discouraged by the fact that only the first row is changed.
Esc to apply your change (or alternately Ctrl+C).

You will now see your changed applied.

Source: Column Edit Mode in VI.
Comment: Please explain the solution here, do not just link to it.
Comment: The current location of the article is https://blog.pivotal.io/labs/labs/column-edit-mode-in-vi but the answer is too short to fix it.
Answer: Use Ctrl-V to select in block mode, then directional and editing commands to do the rest. See
How to remove quotes surrounding the first two columns in Vim?
Answer: You're looking for Visual Block mode, which is accessible by Ctrl+V in Normal mode. Works just like Alt+select in TextMate.
Answer: As others have said Ctrl-V is the answer.  For a tutorial see Vimcast episode "Selecting columns with visual block mode"
Answer: In your special case:
:% s/a/

does the job.
Answer: You can also use a search and replace to specifically remove the first letter of the lines that start with a colon:
:%s/:./:


Proving the Convergence: $\sum_{n=1}^{\infty}(\sqrt{n + r} - \sqrt{n})$.

Question: I'm having trouble proving the convergence for this series using real analysis methods: $$\sum_{n=1}^{\infty}a_n$$where for $r > 0$ a positive real number,$$a_n = \sqrt{n + r} - \sqrt{n}$$

My approach so far has been to use the ratio test for $\frac{a_{k+1}}{a_k}$, which gives me the fraction $\frac{\sqrt{k + 1 + r} - \sqrt{k + 1}}{\sqrt{k + r} - \sqrt{k}}$. I multiply the top and bottom by the denominators conjugate, which conveniently leaves just $r$ on the bottom, but it leaves a pretty gross numerator: $$\frac{\sqrt{k^2 + 2kr + k  + r^2 + r} + \sqrt{k^2 + kr + k} - \sqrt{k^2 + k + k + r} - \sqrt{k^2 + k}}{r}$$
At this point, a high school calculus style analysis would be content with me just saying that the limit of this is zero based on the degrees of the terms. But I'm totally lost on how I should prove that the limit for this is $0$ based on the $\epsilon$ definition for limits.

Is there some sort of algebraic manipulation that we can do here to make the $\epsilon$ inequality for the limit definition turn out nicely? Alternatively, is there some other method I should be trying to use?
Thank you for your time and help:)
Comment: Hint: $\sqrt {n + r}  - \sqrt n  = \frac{r}{{\sqrt {n + r}  + \sqrt n }}$.
Comment: Are you really sure the sum converges? The ration test is the necessary condition not sufficient. I think the sum is divergent.
Comment: Please notice that if $n>\frac{1}{r-2}$ assuming $r>2$ then $\sqrt{n+r}-\sqrt{n}>\frac{1}{n}$ which is harmonic series and divergent. I used MATLAB for calculating sum and I'm sure it grows boundless when you increase $n$. For example $r=5$ and $n=1:10^4$
Comment: That $a_n$ itself converges to $0$ is *not* the Cauchy criterion. It only means that, for each $\epsilon>0$, for some $N$, for each $n\geq N$, $\lvert a_n\rvert<\epsilon$.  The Cauchy criterion starts out similar, but it ends with $\lvert\sum_{k=n}^{m}\rvert<\epsilon$ for each $m\geq n$, a much stronger statement. Thus it is a theorem (the $n$th-Term Test for divergence) that *if* $\sum_{n=i}^\infty a_n$ converges, then $\lim_{n\to\infty}a_n=0$, but the converse does *not* hold.
Comment: Ah! Thank you! I'm always struck by identities like this. Deriving useful ones without reference seems like a tough skill to train.
Comment: @K.K.McDonald The graph of $a_n$ itself converges to 0, so I figured that this means that the series satisfies the Cauchy criterion for sums, since summations starting near the 'tail' of the series would be less than $\epsilon$. Am I mistaken in believing this?
Comment: Okay, got it. Thanks so much to all of you! It means a lot that you're willing to help a confused stranger like me :)
Answer: It is a divergent series. One has
$$
\sum\limits_{n = 1}^\infty  {(\sqrt {n + r}  - \sqrt n )}  = \sum\limits_{n = 1}^\infty  {\frac{r}{{\sqrt {n + r}  + \sqrt n }}}  > \frac{r}{2}\sum\limits_{n = 1}^\infty  {\frac{1}{{\sqrt {n + r} }}}  > \frac{r}{{2\sqrt {1+r} }}\sum\limits_{n = 1}^\infty  {\frac{1}{{\sqrt n }}} ,
$$
and the last series is obviously divergent.
Comment: Thanks for the help! One question: I don't follow how $$\sum_{n=1}^{\infty}\frac{r}{\sqrt{n+r} + \sqrt{n}} > \frac{r}{2} \sum_{n=1}^{\infty}\frac{1}{\sqrt{n+r}}$$ Isn't it the case that $\frac{1}{\sqrt{n+r} + \sqrt{n}} < \frac{1}{\sqrt{n+r}}$? If so, why would dividing the second series by 2 change anything?
Comment: Nevermind, I got it!
Answer: Let $n >n_0 >r$ ($n_0$ exists, Archimedean principle)
$a_n=\dfrac{r}{\sqrt{n+r}+√n}>$
$\dfrac{r}{2\sqrt{n+r}}>\dfrac{r}{2\sqrt{n+n}}=$
$\dfrac{r}{2√2√n}= \dfrac{r}{2√2}\dfrac{1}{√n}$.
$\sum a_n$ diverges (comparison test), since $\sum \dfrac{1}{√n}$ diverges
Comment: Thanks! What was the purpose of $n_0$ here? Is it just a formality to show that there *can* be something greater than $r$?
Comment: Barbaric.A pleasure. In proves like this usually one writes: For $n >r$(real>0), without $n_0$. Actually given $r >0$, the Archimedean principle assures a $n_0 >r$(you can look it up).Then for all $n >n_0$ we have $n>r$. You can leave it($n_0$) out here , and just say: For $n>r$. Cheers.
Answer: Since $r>0$ thus $\sqrt{n+r}-\sqrt{n}>0$. Let's find the $n$ for which $\sqrt{n+r}-\sqrt{n}>\frac{\alpha}{n}$ where $\alpha>0$ is some positive constant. Therefore
$$n+r+n-2\sqrt{n(n+r)}>\left( \frac{\alpha}{n} \right)^2\Rightarrow 2n+r-\left( \frac{\alpha}{n} \right)^2>2\sqrt{n(n+r)} \\ \Rightarrow 4n^2+r^2+\left( \frac{\alpha}{n} \right)^4+4nr-2r\left( \frac{\alpha}{n} \right)^2-4n\left( \frac{\alpha}{n} \right)^2>4n^2+4nr\\ \Rightarrow \left( r-\left( \frac{\alpha}{n} \right)^2 \right)^2>\frac{4\alpha^2}{n}\Rightarrow r>\left( \frac{\alpha}{n} \right)^2+\frac{2\alpha}{\sqrt{n}}$$
For large $n$ this is inevitable and the series is comparable to harmonic series which diverges. For example if we assume $n$ is large enough such that $\left( \frac{\alpha}{n} \right)<\left( \frac{\alpha}{\sqrt{n}} \right)$ (i.e. $n>1$) then
$$r+1>\left( \frac{\alpha}{\sqrt{n}}+1 \right)^2\Rightarrow \sqrt{r+1}>\left( \frac{\alpha}{\sqrt{n}} +1\right)\Rightarrow \sqrt{n}>\frac{\alpha}{\sqrt{r+1}-1}$$
Thus if $n>\left(\frac{\alpha}{\sqrt{r+1}-1}\right)^2$ then $\sum_{n=1}^{\infty}a_n>\sum_{n=1}^{\infty}\frac{\alpha}{n},\alpha>0$
Answer: There are different ways to prove that the series diverges.
For natural $r$, the series telescopes, leaving you  with
$$\lim_{n\to\infty}\sqrt{n+r}+\sqrt{n+r-1}+\cdots\sqrt{n+1}-f(r).$$
For non-natural $r$, you can use squeezing between the series for two naturals.