Adding a custom header to HTTP request using angular.js

Question: I am a novice to angular.js, and I am trying to add some headers to a request:
   var config = {headers: {
            'Authorization': 'Basic d2VudHdvcnRobWFuOkNoYW5nZV9tZQ==',
            'Accept': 'application/json;odata=verbose'
        }
    };

   $http.get('https://www.example.com/ApplicationData.svc/Malls(1)/Retailers', config).success(successCallback).error(errorCallback);

I've looked at all the documentation, and this seems to me like it should be correct.
When I use a local file for the URL in the $http.get, I see the following HTTP request on the network tab in Chrome:
GET /app/data/offers.json HTTP/1.1
Host: www.example.com
Connection: keep-alive
Cache-Control: max-age=0
If-None-Match: "0f0abc9026855b5938797878a03e6889"
Authorization: Basic Y2hhZHN0b25lbWFuOkNoYW5nZV9tZQ==
Accept: application/json;odata=verbose
X-Requested-With: XMLHttpRequest
If-Modified-Since: Sun, 24 Mar 2013 15:58:55 GMT
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22
X-Testing: Testing
Referer: http://www.example.com/app/index.html
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

As you can see, both of the headers were added correctly. But when I change the URL to the one shown in the $http.get above (except using the real address, not example.com), then I get:
OPTIONS /ApplicationData.svc/Malls(1) HTTP/1.1
Host: www.datahost.net
Connection: keep-alive
Access-Control-Request-Method: GET
Origin: http://mpon.site44.com
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22
Access-Control-Request-Headers: accept, origin, x-requested-with, authorization, x-testing
Accept: */*
Referer: http://mpon.site44.com/app/index.html
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

The only difference in code between these two is one is for the first the URL is a local file, and for the second the URL is a remote server. If you look at the second Request header, there is no Authentication header, and the Accept appears to be using a default instead of the one specified. Also, the first line now says OPTIONS instead of GET (although Access-Control-Request-Method is GET).
Any idea what is wrong with the above code, or how to get the additional headers included using when not using a local file as a data source?
Comment: This looks like a CORS issue - take a read through this discussion for some background: https://groups.google.com/forum/#!topic/angular/CSBMY6oXfqs
Comment: Chrome is preflighting the request to look for CORS headers if the request is cross domain. Check my answer.
Comment: It was indeed a CORS issue. The server was not configured to return the Access-Control-Allow-Origin: header. If you want to write up an answer with your comment and a little bit of detail on CORS, I'll accept your answer. The answer below from Dmitry Evseev and edited by you was close, but not really the actual problem.
Answer: I took what you had, and added another X-Testing header
var config = {headers:  {
        'Authorization': 'Basic d2VudHdvcnRobWFuOkNoYW5nZV9tZQ==',
        'Accept': 'application/json;odata=verbose',
        "X-Testing" : "testing"
    }
};

$http.get("/test", config);

And in the Chrome network tab, I see them being sent.
GET /test HTTP/1.1
Host: localhost:3000
Connection: keep-alive
Accept: application/json;odata=verbose
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22
Authorization: Basic d2VudHdvcnRobWFuOkNoYW5nZV9tZQ==
X-Testing: testing
Referer: http://localhost:3000/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

Are you not seeing them from the browser, or on the server?  Try the browser tooling or a debug proxy and see what is being sent out.
Comment: I don't have access to the server, and on the browser I am using Firefox, but I'm seeing the headers I added to the original question above. I don't see where you can view the headers on the resource tab in Chrome.
Comment: Sorry, I added an edit to your answer that was meant to go in my original question.
Comment: I meant the network tab of the developer tools, not resources - updates answer
Comment: I added more information to the question. It looks like the headers are added in one case, but not another.
Answer: Basic authentication using HTTP POST method:
$http({
    method: 'POST',
    url: '/API/authenticate',
    data: 'username=' + username + '&password=' + password + '&email=' + email,
    headers: {
        "Content-Type": "application/x-www-form-urlencoded",
        "X-Login-Ajax-call": 'true'
    }
}).then(function(response) {
    if (response.data == 'ok') {
        // success
    } else {
        // failed
    }
});

...and GET method call with header:
$http({
    method: 'GET',
    url: '/books',
    headers: {
        'Authorization': 'Basic d2VudHdvcnRobWFuOkNoYW5nZV9tZQ==',
        'Accept': 'application/json',
        "X-Login-Ajax-call": 'true'
    }
}).then(function(response) {
    if (response.data == 'ok') {
        // success
    } else {
        // failed
    }
});

Comment: The best answer.
Answer: If you want to add your custom headers to ALL requests, you can change the defaults on $httpProvider to always add this header…
app.config(['$httpProvider', function ($httpProvider) {
    $httpProvider.defaults.headers.common = {
        'Authorization': 'Basic d2VudHdvcnRobWFuOkNoYW5nZV9tZQ==',
        'Accept': 'application/json;odata=verbose'
      };
}]);

Comment: ALL but OPTIONS requests that is
Comment: nice example. can this be used to cache token for redirecting pages?
Answer: my suggestion will be add a function call settings like this
inside the function check the header which is appropriate for it. I am sure it will definitely work. it is perfectly working for me.
function getSettings(requestData) {
    return {
        url: requestData.url,
        dataType: requestData.dataType || "json",
        data: requestData.data || {},
        headers: requestData.headers || {
            "accept": "application/json; charset=utf-8",
            'Authorization': 'Bearer ' + requestData.token
        },
        async: requestData.async || "false",
        cache: requestData.cache || "false",
        success: requestData.success || {},
        error: requestData.error || {},
        complete: requestData.complete || {},
        fail: requestData.fail || {}
    };
}

then call your data like this
    var requestData = {
        url: 'API end point',
        data: Your Request Data,
        token: Your Token
    };

    var settings = getSettings(requestData);
    settings.method = "POST"; //("Your request type")
    return $http(settings);

Answer: What you see for OPTIONS request is fine. Authorisation headers are not exposed in it.
But in order for basic auth to work you need to add: withCredentials = true; to your var config.
From the AngularJS $http documentation:

withCredentials - {boolean} - whether to to set the withCredentials
  flag on the XHR object. See requests with credentials for more
  information.
Answer: And what's the answer from the server? It should reply a 204 and then really send the GET you are requesting.
In the OPTIONS the client is checking if the server allows CORS requests. If it gives you something different than a 204 then you should configure your server to send the correct Allow-Origin headers.
The way you are adding headers is the right way to do it.
Answer: Chrome is preflighting the request to look for CORS headers. If the request is acceptable, it will then send the real request. If you're doing this cross-domain, you will simply have to deal with it or else find a way to make the request non-cross-domain. This is by design.

Unlike simple requests (discussed above), "preflighted" requests first
  send an HTTP request by the OPTIONS method to the resource on the
  other domain, in order to determine whether the actual request is safe
  to send. Cross-site requests are preflighted like this since they may
  have implications to user data. In particular, a request is
  preflighted if:
It uses methods other than GET, HEAD or POST. Also, if POST is used to
  send request data with a Content-Type other than
  application/x-www-form-urlencoded, multipart/form-data, or text/plain,
  e.g. if the POST request sends an XML payload to the server using
  application/xml or text/xml, then the request is preflighted. It sets
  custom headers in the request (e.g. the request uses a header such as
  X-PINGOTHER)

Ref: AJAX in Chrome sending OPTIONS instead of GET/POST/PUT/DELETE?
Answer: You are just adding a header which server does not allow.
eg - your server is set up CORS to allow these headers only (accept,cache-control,pragma,content-type,origin)
and in your http request you are adding like this
 headers: {
        'Authorization': 'Basic d2VudHdvcnRobWFuOkNoYW5nZV9tZQ==',
        'Accept': 'application/json',
        'x-testing': 'testingValue'
    }

then the Server will reject this request since (Authorization and x-testing) are not allowed.
This is server side configuration.
And there is nothing to do with HTTP Options, it is just a preflight to server which is from different domain to check if server will allow actual call or not.
Answer: For me the following explanatory snippet worked. Perhaps you shouldn't use ' for header name?
{
   headers: {
      Authorization: "Basic " + getAuthDigest(),
      Accept: "text/plain"
   }
}

I'm using $http.ajax(), though I wouldn't expect that to be a game changer.


h2o AutoML use in class imbalance mode

Question: i have a usecase of very imbalace data set , i undersampled the training dataset ,
and tried running the automl in h2o, but it gave me great AUC results (over 0.99) but very bad aup_pr results (0.09).
is it related to the imbalance issue ?
i ran with weight_column option (http://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-science/algo-params/weights_column.html)
but it didn't help.
should i use the balance_classes option instead (when i run both options it fails with "h2oFrame is empty" message) .
the train and test are splitted on date time range , and the test dataset has the proper ration between majority and minority classes.
Answer: The large difference between AUC and AUCPR is most likely caused, as you suggest, by the class imbalance. You can either try to set balance_classes = True or set weights to a column that would weight the minority class more, e.g. taking the inverse of the class frequency. If you have really small number of observations for the minority class, you can try to synthesise more using e.g. SMOTE.
Comment: tried the balance_classes but still , ROC AUC was 0.99 and the AUCPR was 0.03 .... so or the measurment is problematic or there is something not right with the balance classes, is there a limit to how much it can balance, if the data set is highly imbalance, does it still works ?
Comment: ROC AUC is not a good metric for highly imbalanced classes, so I would recommend not even looking at it. The low AUCPR suggests your model simply does not work well. What exactly is the proportion of the classes? If you have a very rare event/class to detect, you can also consider casting the problem as an anomaly detection. There's Isolation Forest model available in H2O that can do that.

h2o AutoML use in class imbalance mode


Master theorem: $T(n)=10T(n/9)+n\lg(n)$

Question: I am told to solve the recurrence
$$T(n)=10T(n/9)+n\lg(n)$$
using the Master theorem. I then try to use case 3. However, I am unable to show that for $f(n)=n\lg(n)$ then $10f(n/9) \leq cn\lg(n)$ for $c < 1$ and all sufficiently large $n$. Is it wrong to use case 3? Or does the Master theorem even apply?
Comment: You should state the exat version of the master theorem you are using, there is a raft of them.
Answer: Case 3 does not apply. Indeed:
$$
f(n) = n \log n \not\in \Omega(n^{\log_9 10}) = \Omega(n^{\log_b a}).
$$
However case $1$ applies since, for $0<c \le 0.01$
$$
f(n) = n \log n \in O(n^{1.04 - 0.01}) \subset O(n^{\log_9 10 - 0.01} ) \subseteq O(n^{\log_b a - c} ).
$$
This shows that $T(n) \in \Theta(n^{\log_9 10})$.

Master theorem: $T(n)=10T(n/9)+n\lg(n)$


Non monotonic feature selection decision

Question: Why is it bad to have a non monotonic feature when attempting to determine an output. For example why would it be bad to select a temperature for determining a patients health?
Answer: In opposit I say.
Suppose we consider two features F1(time),F2(temprature) that F2 varies monotically with F1.
Simple answer:

Entropy of F2 given F1 is low.
Correlation of F1 and F2 is too high.

Don't worry cause the first feature selection algorithm removes it! :)


Word for bigotry towards someone of political beliefs

Question: Ageism is the word for bigotry towards people of an age group, racism towards people of a race, sexism towards people of a certain gender, etc.  Is there a word for bigotry towards someone of certain political beliefs, such as towards liberals/democrats?
Comment: [Related](http://meta.english.stackexchange.com/questions/4732/word-for-disrespecting-eldest-half-sister-by-referring-to-her-husband-as-girly-g#comment16076_4732).
Answer: A  sectarian may fit your description:

one characterized by bigoted adherence to a factional viewpoint.

Sectarianism:

is bigotry, discrimination, or hatred arising from attaching importance to perceived differences between subdivisions within a group, such as between different denominations of a religion, class, regional or factions of a political movement.
Answer: Consider political zealotry, political activism, and political militancy

zealot: a person who has very strong feelings about something (such as religion or politics), and wants other people to have those feelings.
zealotry: excessive intolerance of opposing views
activism: a doctrine or practice that emphasizes direct vigorous action in support of or opposition to one side of a controversial issue
militancy: the active championing of a cause or belief

Still and all, zealotry seems what comes the closest to what you're looking for, as long as neither activism nor militancy connotes a deep-seated prejudice against political opponents.
Answer: The term chauvinism can cover it

smug irrational belief in the superiority of one's own race, party, sex, etc.

However, the term is not limited to views about political allegiances. To be explicit, you would have to preface it with a delimiting term, such as ideological chauvinism.
Also consider partisan

A strong supporter of a party, cause, or person.

This does not necessarily mean the adherent is blindly prejudiced against different points of view, but the usual connotation is one of a narrow-minded devotion to a cause.
A more colloquial term is drumbeater

One that supports a cause, especially vehemently.
Answer: Intolerance refers to an

unwillingness to accept views, beliefs, or behavior that differ from one's own.

The implication is that this is undesirable. I'm not sure there is a word for being intolerant of things that we should refuse to tolerate (such as intolerance itself).


Why I was blocked to ask questions?

Question: I recently posted a question about getting help to conver a programming language onto another and was blocked to ask again. Why is that ?
Comment: [related](https://meta.stackoverflow.com/a/296126/839601)
Answer: You were blocked for the reasons laid out here.
A few notes:

self deleted zero/negatively scored questions count towards the ban
You can get out of the ban by improving your questions.

Here are the questions you can't see because they're too old:

https://stackoverflow.com/questions/19532284/c-to-plain-c-error
https://stackoverflow.com/questions/43404451/whatis-the-full-content-of-context-structure-extendedregisters

For your other negatively scored questions, a few tips:

Ask about the specific issue you have. In your case you had a question about equality but your question was broader than that (though not 'too broad' in our textual definition). Consider editing the question down to the specific issue you have.
If your question is programming related, make that abundantly clear. This Question does not look like it's related to programming (but I don't know enough to say that authoritatively).
This question meets all of our requirements; looking at it I am unclear as to why it was downvoted.
Some need to be targetted to a programming language to be on topic; in this case it isn't.
This question has the same issue your first question above did; scope the question down to the specific part you have an issue with.

Why I was blocked to ask questions?


X-Cache Header Explanation

Question: I was going through the firefox local cache folder and found a lot of files containing the X-cache header. Can someone explain the purpose of this header ?
thanks
Answer: CDN (Content Delivery Network) adds X-cache header to HTTP Response. X-cache:HIT means that your request was served by CDN, not origin servers. CDN is a special network designed to cache content, so that usr request served faster + to unload origin servers.
Comment: Furthermore, there are a bunch of "X- " headers provided by CDNs. They indicate HIT, MISS etc. You can simply install firebug plugin in firefox and request some progressive download video, probably it'll be served by cdn node, so the HOST header in response might contain smth like cdn.rt.com and there will be "X- " headers
Answer: Prefix 'X' in X-Cache indicates that the header is not a standard HTTP Header Field. Also its meaning vary from one proxy implementation to another. A common place to find these header fields is in squid servers. Organizations and universities place proxy (squid) servers between their and
outer network. This serves two purposes. One of security, and other of caching more frequent web pages (in order to limit network traffic).

X-Cache corresponds to the result, whether the proxy has served the result from cache (HIT for yes, and MISS for no)
X-Cache-Lookup represents if the proxy has a cache-able response to the request (HIT for yes and MISS for no)

Both HITs means that the client has made a cache-able request and the proxy had a cache-able response that matched, and was forwarded back to the client.
In case X-Cache is MISS and X-Cache_Lookup is HIT, then the client made a request that had a cache-able response but was forced by the client to bypass the cache. This is hard refresh, which can be simulated by Ctrl + F5 or by sending headers:
Pragma: no-cache (in HTTP/1.0) and Cache-Control: no-cache
(HTTP/1.1)
If both are MISS(es) then the request by the client doesn't have any valid object corresponding to the request.
Some Useful Resources:

X-Cache and X-Cache-Lookup Headers
Understanding cache HIT and MISS headers with shielded services
Comment: Also remember that cache is being maintained on different levels. This is more related to squid servers and proxy.
Answer: X-Cache "is NOT a standard HTTP header field".
Also, check out X-Cache and X-Cache-Lookup headers explained.
Answer: for me me this was  related to  fastcgi cache header existing on Nginx server block
  add_header X-Cache $upstream_cache_status;

just removing commenting this line and restart nginx the header were removed  .

X-Cache Header Explanation


Tough Probability Question.

Question: Box 1 and Box 2 exist. Box 1 contains 4 red balls and 1 blue ball. Box 2 contains 5 blue balls and 3 red balls. Draw from box one first. The next box drawn from is determined by the color of the ball drawn. A red ball will lead you to draw from Box 1, while a blue ball will lead you to draw from box 2. What is the chance a red ball is drawn on the 100th draw?
Comment: Have you heard of Markov chains?
Comment: I wasnt aware of them, but now that I have educated myself on the matter, how can i form such a recursive formula if thats even what I should be doing?
Comment: Isaac's answer is probably the way to go
Answer: I assume we draw with replacement, since otherwise there would not be 100 draws.
Anyways, to solve this question, we will need to use something called a matrix. If you don't know what that is, watch a Khan Academy video or something. Pay special attention to how matrices are multiplied, as that is important to constructing something called the transition matrix.
$$
\left[ {\begin{array}{cc}
   a_{1,1} & a_{1,2} \\
   a_{2,1} & a_{2,2} \\
  \end{array} } \right]
$$
Here is a transition matrix, where Entry $a_{i,j}$, is the chance that something in state $i$ will move to state $j$ in the next step. We can iterate this transition matrix by multiplying it by itself, and we can iterate it $n$ times by raising it to the $n$th power.
So, in our case, our starting position is the vector $[1,0]$ since we start with a $100$% chance that we are picking from the first box. And our transition matrix is
$$
\left[ {\begin{array}{cc}
   4/5 & 1/5 \\
   3/8 & 5/8 \\
  \end{array} } \right]
$$
So now we have all the tools we need, and we perform the following computation (preferably on a calculator).
$$
[1,0]\cdot
\left[ {\begin{array}{cc}
   4/5 & 1/5 \\
   3/8 & 5/8 \\
  \end{array} } \right]^{100}
\approx [.6522, .3478]
$$
Thus, our chance of just having picked the red ball last time is simply the chance of us being in the first state. Thus, the probability is $\approx65.22$%.
It may be interesting to note that a matrix to the n power seems to converge to a limiting transition matrix as n goes to infinity. I suggest you investigate this further, as it is probably what this problem would be leading up to.

Tough Probability Question.


Fail2ban 0.9.0 enabling jails

Question: I updated my server to 16.04 and it only installs fail2ban 0.9.0. There is no option to enable jails and when I add it manually it fails to load. Any help much appreciated.
Answer: Yeah, Fail2ban configuration files has changed a lot since V.0.9.X.
After V.0.9.X you should NOT change the original config file, that is located in
/etc/fail2ban/jail.conf
this is from Fail2ban jail.conf
# WARNING: heavily refactored in 0.9.0 release.  Please review and
#          customize settings for your setup.
#
# Changes:  in most of the cases you should not modify this
#           file, but provide customizations in jail.local file,
#           or separate .conf files under jail.d/ directory, e.g.:
#
# HOW TO ACTIVATE JAILS:
#
# YOU SHOULD NOT MODIFY THIS FILE.
#
# It will probably be overwritten or improved in a distribution update.
#
# Provide customizations in a jail.local file or a jail.d/customisation.local.
# For example to change the default bantime for all jails and to enable the
# ssh-iptables jail the following (uncommented) would appear in the .local file.

Ubuntu 16.04 installs Fail2ban V.0.9.3-1
To config it, do the following:
apt update
apt install fail2ban

after Fail2ban has been successfully installed:
cd /etc/fail2ban/

we now create some local jail, to override the default configurations
sudo nano /etc/fail2ban/jail.local

no copy and paste the following
[DEFAULT]
# Ban hosts for two days:
bantime = 172800

# Override /etc/fail2ban/jail.d/00-firewalld.conf:
banaction = iptables-multiport

[sshd]
enabled = true

now write to the file (ctrl + o) and close it (ctrl + x)
restart fail2ban service
sudo systemctl restart fail2ban

check fail2ban status
sudo fail2ban-client status

you should get a output like this:
Status
|- Number of jail:  1
`- Jail list:   sshd

now you check individuals jails e.g.
sudo fail2ban-client status sshd

with the above commands you can see which IP addresses has been blocked Fail2ban service!
you can control with systemctl is fail2ban is running or not
sudo systemctl status fail2ban

this is it.
PS: you can add other parameters like mail sending, find time, max-retry and ... if you would like!
Sources:
How To Protect SSH With Fail2Ban on CentOS 7
Fail2ban with FirewallD
Using Fail2ban to Secure Your Server
PS2: There is a newer version of Fail2ban available -> v0.9.4
If you would like, you can compile it yourself (read the Fail2ban github page) - though compiling IS NOT recommended
From Fail2ban Github Page

It is possible that Fail2ban is already packaged for your
  distribution. In this case, you should use it instead.

OR
you can use the .dep package for the next version of Ubuntu (which is Yekkety)
Package: fail2ban (0.9.4-1) [universe]
Comment: ban host for two days :) awesome!
Comment: But how do i add the jail for apache. Every time i add enabled = true. Fail2ban fails to start. I use basic authentication with apache so this is a necessity. Currently i just reverted to 0.8 and put the update for fail2ban on hold with apt. I don't understand why they removed the ability to copy the .conf to a jail.local and manipulate the settings there. All the settings were already in the file. Maybe i am missing something. I have researched and couldn't find it on my own
Comment: @ILOVEKODI sorry man for answering late. Just Copy the apache section or whatever the webserver section is, to the jail.local and add enabled = true / like we did it with the SSH. Hope this help. :) [http://notes.sagredo.eu/node/170] you may check out this website.
Answer: In addition to bossModus's info, note that there is no apache jail in the newer versions of fail2ban.  I believe it was renamed to apache-auth.

Fail2ban 0.9.0 enabling jails


linux cron: want to backup a folder

Question: I would like to backup a folder using cron on a centos. The folder c2duo_mms is located in /usr/local/src/djcode/c2duo_mms. I would like it backed ip every 1:00pm on Tuedays to my home folder /home/sh.
Comment: Are you backing up a folder or a file? Your question has contradictory bits. For a single file `cp` is fine, for a directory `rsync` is a better too. Please fix your question to get a precise answer.
Comment: @Caleb `c2duo_mms` it is a folder -- fixed
Answer: A good thing to do would be to create a new compressed archive in your home.
Create this script named for exmaple */home/sh/c2duo_mms_backup.sh*:
#!/bin/bash

cd /usr/local/src/djcode/
tar zcf /home/sh/c2duo_mms-`date +%Y%m%d`.tar.gz c2duo_mms

Be sure to add the executable permission to the script:
chmod +x /home/sh/c2duo_mms_backup.sh

Then add the relevant crontab entry with the crontab -e command:
0 13 * * 2 /home/sh/c2duo_mms_backup.sh

The script will create a new compressed archive every Tuesday with the date in the filename, so that you can keep older backups if you want. File name will look like this:
c2duo_mms_20110719.tar.gz

Comment: This is what I have been looking for!!! thanks a lot.
Comment: a better solution would be to use rsync or unison.
Answer: $ crontab -e
0 13 * * 2 cp -b /usr/local/src/djcode/c2duo_mms /home/sh/

The crontab -e command should pull up the crontab file for editing in your preferred editor (Set by the EDITOR or VISUAL environment variabels). The crontab line says to run the command on the 0th minute, 13th hour, 2nd day of the week, any day of the month any year. The command itself is a simple single file copy, except that I added the -b argument so that cp makes a backup file. This should leave you with TWO backups at all times, the current one and the previous one (with a .bk extension).
Edit: For a folder instead of a file, try rsync:
0 13 * * 2 rsync -av /usr/local/src/djcode/c2duo_mms/ /home/sh/c2duo_mms/

Comment: That would be "perform this on the second day of every month at 1am", right?
Comment: @caleb: For some reason it is not copying the folder to my home directory. Is there like some way that I can find what is causing this problem?
Comment: @Shehzad009: If you are using the rsync, you might make sure the target folder exists first before syncing it. Some will create it, but some won't. Also, to debug this, run th rsyncs e command manually yourself instead of from cron to see the output and make sure the backup part does what you want before sticking it in cron.
Comment: @caleb: After using `rsync e` I get this `"/home/sh/e" failed: No such file or directory (2)`. Not so sure what that e is.
Comment: The `e` is a bogus typo on your end somewhere, it doesn't appear in the command I suggested. The syntax is `rsync -[options] [source] [target]`, and it's important to end with trailing slashes on the source and targets if you are syncing directories.
Answer: Use command crontab -e and add this line to your crontab:
0 13 * * 2 cp -pra /usr/local/src/djcode/c2duo_mms /home/sh

linux cron: want to backup a folder


What is domain logic?

Question: What is domain logic?  The Wikipedia page for domain logic redirects to business logic.  Are they the same thing, and, if not, how do they differ?
Comment: Here's a blog post on that topic: http://enterprisecraftsmanship.com/2016/08/25/what-is-domain-logic/
Answer: The domain is what you are modelling.
If you are modelling a business problem, they are the same thing.
If you are modelling something else, physics for instance, there is probably no business logic in your system, but the physics parts are still domain logic.
Comment: I wouldn't call Brian Knoblauch's answer incorrect, it is just a slightly narrower view of the concept. If you are building a CRM system, then your problem domain is CRM and your domain logic is business logic specific to the area of CRM.
Comment: Is business logic a subset of domain logic? This seems to contradict Brian Knoblauch's answer, if so
Answer: Domain is the world your application lives in. So if you are working on say a flight reservation system, the application domain would be flight reservations.
Business Logic on the other hand is a more discrete block of the entire Application Domain. Business Logic is usually a section of code built to perform one specific business process. So you would have business logic to take a reservation. Another bit of business logic would be code to refund cancelled tickets.
The objects that support your business process then become your business objects!
Answer: Business logic is teleological (concerned with how to achieve an objective) while domain logic is ontological (what exists, or the object model that's used to reason with)
Comment: If they were to be different, I think this would be the best answer as to how. Domain logic would encapsulate your different domain objects and their relation to one another. While Business Logic would describe how each object uses those relations to achieve a specific objective.
Comment: The clearest answer so far, thanks! So, in this regard, data layer would concern itself with the persistence (and access, query etc.) of objects of the domain logic, right?
Answer: Let's cover a scenario.
You have a client for XYZ restraint and he wants you to make his system online.
Where user can place an order online, track them, make payment etc.
For a client point of view this system would be called Business Idea
while "place order online" said to be one of the business process and
if user place order online, client wants each detail of user, want to display it on screen etc said to be Business logic.
Now you will model his business idea into your point of view in a way that your system can accomplish his all business process or his complete business idea said to be Problem Domain or Application Domain or Domain of your Application.
Now you will first identify all the business processes. And identify entities or object to accomlish business processes. Those object said to be Business Obect or Domain Object and method or logic that implement business process like placeOrder said to be Domain Logic.
So business logic is what client wants because its in client business domain and domain logic is how you implement it. because it's in your application domain.
Comment: The best answer, everything is clearly written, thank you very much!
Answer: Domain logic applies to the problem domain, e.g. "order processing". Domain logic is about  the entities you work with (the object model), and their relationships.
Business logic contains rules specific to your context, e.g. "orders from customers of group X are to be processed using discount Y when exceeding amount Z". Business "logic" is about encoding facts about your business (or the business of the customer who uses the program).
Answer: Business logic specific to one particular field/area of expertise.
Comment: So is domain logic a subset of business logic? This seems to contradict jakber's answer if so.
Answer: I would say the Business Logic is related to:
Any logic or association between entities in the Domain.
So how does a Student relate to a Class or a Student.
How is a new Class created and how do you Register a Student for that Class
Anything to do with business rules, determining outcomes, services, events, processes, calculations, transformation and related data manipulations/creation.
I have found it hard to find good books/teachers to help structure domain logic. It's easy to structure the domain. But domain logic seems to me a place no one wants to go.
Answer: My domain is pharmaceutical. It deals in compartments, doses, differential equations, and statistics. If you want to call that my "business", then I guess it's "business logic".
Answer:
Business logic is concerned with coordinating valid interactions between view and model (ui and data).
Domain Logic is about keeping an internally consistent model representation on both sides of the app (client and server).

What is domain logic?


Can I access terminal 2 arrivals from terminal 3 arrivals in Heathrow without a UK visa?

Question: I will be arriving in London Heathrow airport from terminal 3, and after 8 hours departing from terminal 5. Can I walk to terminal 2 arrivals and use the paid lounge there without a UK visa?
Comment: What's your nationality?
Answer: You cannot use an arrivals lounge without passing through immigration. You will probably need a UK visa to pass through immigration, although in some circumstances visas for other countries are acceptable for a same-day landside transit. See the UK's official webpage but ignore the large text on the last page and read the full answer beneath if you have a visa for USA, Canada, Australia, New Zealand, Ireland, the EU (category D) or Switzerland.

I would advise you to use the lounges in terminal 5 instead, which are generally more pleasant than the landside lounges. The arrivals lounges are not intended to be pleasant places to wait eight hours before your next flight but are intended to be somewhere to have breakfast and freshen up quickly before a long day of meetings in London.
There are now two paid lounges in Terminal 5, the Aspire Lounge and the Plaza Premium lounge. The Aspire Lounge in T5 airside is the same brand who runs the paid landside lounge in T2. I think everyone agrees that the Plaza Premium lounge is better.
Review of the Aspire Lounge. / Priority Pass accepted / £40 / £20 surcharge for showers.
Review of the Plaza Premium lounge. / £40 / Free entry for Amex Plat holders / £15 surcharge for showers.
Official Heathrow information.


Embedd cwbdc.dll from IBM i Client Access manually to console application

Question: Is it possible, wo reference the cwbdc.dll which comes with the i Client Access from IBM manually in a console application with C# .Net? I would like to connect to a AS400 database without installing i Client Access but only by using
IBM.Data.DB2.iSeries and the provider which comes with the cwbdc.dll.
When I directly copy the cwbdc.dll to the bin directory I get following exception:

{"An unexpected exception occurred.  Type:
System.BadImageFormatException, Message: Es wurde versucht, eine Datei
mit einem falschen Format zu laden. (Ausnahme von HRESULT:
0x8007000B)."}
Answer: I've had a similar problem with the cwbx.dll from IBM. And yes, it's possible.
If you want to copy the dll files without install Client Access, you have to add a Microsoft Patch because this old DLL files are "umanaged dll's" and can't not be loaded directly.
Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package ATL Security Update : https://www.microsoft.com/en-us/download/details.aspx?id=14431
Then you must copy all 320 DLL Files who start with cwb****.dll from the Client Access Installation into your folder with the IBM.Data.DB2.iSeries.dll file.
( they all are referenced in different ways into each other ).
For me has this worked, i could use the iSeries Connection without installing Client Access. But it's a very unstable way.
Be sure that when you copy the dll files, that Client Access is not installed on the target machine!
If Client Access is already installed, and you have the dll files included, your application crash. If the Client Access Version from your copied dll's is different from the installed version, your application crash too.
I've fixed this with a check on start => if you find a Client Access Installation, then delete all included dll files and use the installed one.
But even if it works, i do not recommend this way.


Getting rid of noises after RC low pass filter stage

Question: I am outputting a 40kHz square wave from arduino and passing it through an RC circuit in order to get a clean 40kHz sinusoid out. However, the output wave I am getting is noisy.(see picture) Any advice on how to get rid of noise?
Comment: How/where have you earthed the scope probe? Those spikes are almost certainly the edges from the square wave, getting into your measurement somehow.
Comment: Move the ground probe to the filter part of your circuit. You are getting logic noise into your probes.
Comment: Show how/where you measured it.
Comment: Did you choose the wrong parts  and layout?
Comment: You're probably utilizing the Arduino's Digital GND pin, which truthfully, is not the best common to use.
Comment: What is the entire filtering circuit? A square wave into a single pole RC will only produce a triangle wave.
Answer: Radiated or Conducted?
True error or measurement error?
Ground shift ? probing error**?  induction loop current , capacitive coupling?
Also avoid long grounds on scope probe gnd loop near switched inductive sources.
For a 10:1 probe** ground lead , 10cm is too long.  Best Test Eng practise is  by removing gnd clip and probe tip and use twin test points to tip pin and barrel. If not avail make them with resistor wire leads by cut and solder as test points.
Or get the accessory for the probe or make one.

Use twisted pair for all sources of interference and use low ESR caps on Supply.    Use braided or heavy ground conductors.
Keep wiring short and neat.
Show schematics and photo of possible source and of interference.
Comment: Thanks for the replies, that mat be a grounding issue. I guess I first need to make sure the square wave is clean, I'll give it a try
Comment: it's not the square wave but the rather the ground and radiated induced transients with high impedance.  Probe close to output for signal and Analog ground or directly across cap in the case of a passive filter with pins  1cm apart using exposed probe tip.


"Values" of divergent integrals

Question: Are there existing theories of integration in which $I_0 = \int_0^{\infty} dx$ and $I_1 = \int_0^{\infty} x \ dx$ are well-defined infinite elements in a non-archimedean extension of the reals?  I can think of at least two different ways to set up such a theory; in one, $I_1 = I_0^2$, and in the other, $I_1 = I_0^2/2$.  (Both are based on mollification.  In the first framework, you introduce a mollified version of $dx$, namely $e^{-\lambda x} dx$, and you look at the behavior of the mollified integral for $\lambda$ near $0^+$; in the second case, you think of the integral as the area under the graph, and you mollify in the $y$-direction as well.)  There are no problems as long as the integrand is sufficiently nice, e.g., a polynomial function.  I'm wondering if any such theories have been written down and/or been found to be useful.
Comment: Sounds like a duplicate of this older question:
http://mathoverflow.net/questions/115743
Comment: Updated my answer
Comment: My answer to this question is very outdated. In my current research, the quantities have alternative representations: $I_1=\int_0^{\infty } \, dx=\int_0^{\infty } \frac{1}{x^2} \, dx=\tau=\pi\delta(0)$ and $I_2=\int_0^{\infty} x \, dx=\int_0^\infty \frac2{x^3}dx=\frac{\tau ^2}{2}+\frac{1}{24}=\frac{\omega_+^3-\omega_-^3}6$. And, in general, $\int_0^\infty x^n dx=\frac{\left(\tau +\frac{1}{2}\right)^{n+2}-\left(\tau -\frac{1}{2}\right)^{n+2}}{(n+1)(n+2)}=\frac{\omega _+^{n+2}-\omega _-^{n+2}}{(n+1)(n+2)}$. I am not sure whether I should make a new answer.
Answer: For an attempt of such a theory, see http://carlossicoli.free.fr/B/Burgin_M.-Hypernumbers_and_Extrafunctions__Extending_the_Classical_Calculus-Springer(2012).pdf
(Hypernumbers and Extrafunctions: Extending the Classical Calculus, by Mark Burgin).
Link in amazon:
http://www.amazon.com/Hypernumbers-Extrafunctions-Extending-SpringerBriefs-Mathematics/dp/1441998748
Answer: As I recall from QFT class the basic idea is to set the bound of integration to be $L$ and let $L \to \infty$.
$$ \int_{-L}^L dx = 2L \quad\text{ and }\quad \int_{-L}^L x \, dx = L^2 $$
The integrals in physics are badly divergent.  The usual way is to set a parameter $\epsilon$   And there is a lot of talk about this method or that method being the canonical way of assigning a value.
Dual to these are badly oscillatory integrals.  Revolving around the idea that $\sin n x \to 0$ is weakly convergent in $L^2[-\pi, \pi]$.  And  physicist might extract this limit exists generally over $\mathbb{R}$.

I think there is too much attention drawn to zeta function regularization  which is intimately  involved with the eq $\zeta(-1) = - \frac{1}{12}$.  As you note there are careful, it's possible to illustrate two plausible values for the same diveergent integrals and then you are in trouble.

Henle & Kleinberg Infinitesimal Calculus
John Bell A Primer of Infinitesimal

And the warning here is they use two different types of infinesimals.  As I learned... one uses non-standard analysis, the other uses smooth infinitesimal analysis.  In particular, there's difficulty with the mean value theorem.

I have a feeling you know much more than this but I am not sure what to recommend.  Lately there is the fascinating theory of resurgence.  As one might know:
$$ \log n! = \sum_{k=1}^n \log k \approx \int_1^n \log x \, dx = n \log n - n $$
However if you try to "correct" this series too much, the answer on the right hand side is horribly divegent.  And this is tied to essential singularities such as $e^{-1/z}$.
Answer: Using [this approach][1] the values of these integrals are as follows:
$$\int_0^\infty 1\, dx = \omega_-+1/2=\tau$$
Its standard part (analog of regularization in case of series) is zero.
Here $$\omega_-=\sum_{k=1}^\infty 1$$,
the quantity of natural numbers, while $\tau$ is the quantity of all even or all odd numbers, half of the quantity of all integers.
$$\int_0^\infty \sin x\,dx=1$$
$$\int_0^\infty \cos x\,dx=0$$
The standard part of arbitrary improper integral of an analytic function can be calculated from this rule from divergent series:
$$\operatorname{st}\int_0^\infty f(x)\,dx=\lim_{s\to0} \operatorname{st} s\sum_{k=1}^\infty f(sk)$$
The following Mathematica code does the trick:
<code>Sum[f[s x],{x,1,Infinity},Regularization->"Borel"]//FullSimplify
Limit[s %,s→0]
</code>
Thus,
$$\operatorname{st} \int_0^\infty e^x\, dx=-1$$
which coincides with analytic continuation, by the way.
Comment: I think I now see why your posts got downvoted; the page you link to as a reference is unpublished and takes over-bold steps like "Now we define that to any divergent series there corresponds a non-standard number." This forum has a low level of tolerance for speculative, non-mainstream work, and I think your post fell afoul of that. If these rough ideas were developed more rigorously and published in a reputable peer-reviewed journal, they'd probably get more respect. Email me if you want to pursue this further.
Comment: I think the downvoters object to metaphorical phrases like "the quantity of all even or all odd numbers".  I hope the downvoters will phrase their objections in constructive fashion. Meanwhile, let me ask a concrete question: if the term in the RHS of the first equation has a plus-sign, why should its standard part have a minus sign?
Comment: I just found out about your October updates to this question (I'm not sure why the Stack Exchange software didn't notify me sooner). You say "I wrote a e-mail to you" but I never received it. Please use my gmail address, and be sure to use the word "divergent" somewhere so I can search for it.
Comment: Why the downvotes and the delete vote? Something is unclear?
Comment: @James Propp powers of $\omega_-$ have standard part equal to Bernoulli numbers. First power has standard part -1/2, as you can see following the link. If we add 1/2, the standard part is zero. The standard part is what corresponds to the regularization of the series (as you can see https://en.wikipedia.org/wiki/1_%2B_1_%2B_1_%2B_1_%2B_%E2%8B%AF ). This integral is 1/2 greater than the quantity of positive integers, 1/2 less than quantity of non-negative integers and twice less than the quantity of all integers (integral over all real line would be equal to the sum of all integers).
Comment: @James Propp $\sum_{k=1}^\infty 1 = \omega_-$, its standard part is -1/2, $\sum_{k=0}^\infty 1 = \omega_+=\omega_-+1$, its stantard part is 1/2. $\omega_-^2$ has standard part of 1/6, so $-\frac{\omega_-^2}2$ has standard part -1/12. Actually, it is the value of the regularization of this series: https://en.wikipedia.org/wiki/1_%2B_2_%2B_3_%2B_4_%2B_%E2%8B%AF
Comment: @James Propp I modified my answer to give the explicit formula for transforming an integral to a series.
Comment: @James Propp I wrote a e-mail to you. I would discuss these ideas with pleasure
Comment: @James Propp I have added the easier method of calculating the thing.
Comment: @James Propp done.

"Values" of divergent integrals


My HP PageWide Pro Printer's ethernet port is constantly flashing

Question: The ethernet port LED (green) of my HP PageWide Pro Printer is constantly flashing in a very high frequency. Permanent, it seems to be 24 hours x 365 days even though the printer is not in use most of the time. This extreme flash is visible on the back wall and very annoying. I can't move the printer. I could cover the LED somehow but I really would like to know what the h*** this printer is communicating all day all year so that the ethernet port shows traffic with constantly flickering LED. No other web based device I own or ever owned did this. Can I stop it? Could it even be that something strange is going on (spyware)?
Comment: Check for unwanted broadcast traffic on the printer's network segment.
Answer: There's a pretty serious potential security exploit (CVE-2017-2741) for this (and other similar HP models) that could allow remote code execution.
If this device has been internet accessible and seems to be communicating with something, I would suggest investigating the following HP Security Bulletin, and taking steps to ensure that it is no longer vulnerable to this attack.


Can I replace the home button on the  iPhone 3G without removing the glass digitizer?

Question: My iPhone 3G home button broke so I bought a new one online and all the repair guides require me to remove the glass digitizer, which seems very tough (hair drying glue etc.) and harder than I expected. Does anyone know a way or a guide of replacing it without removing the glass?
Comment: As you can see here, the home button is held in place by the digitizer: http://www.ifixit.com/Guide/Installing-iPhone-3G-Front-Panel/587/6
Answer: No - if you can't effect a repair using a clear film or some sort of adhesive with the phone intact, you'll have to totally disassemble the 3G/3GS display unit to get better access to the home button.
The teardown guides from iFixit are accurate - as is your reading of the difficulty of successfully doing the repair and having things work when put back together.
Do check with Apple on the replacement price of that part before you dive in. Last I checked, it was $99 for parts and labor for an entire new display assembly.
Comment: Yeah i wound up just hiring a guy to do it for me for $30. Well worth it..


I need to add finger rig to a model that is already rigged

Question: I am reusing a rigged model I got from Blendswap. It is fully rigged (by rigify it seems) with the exception of the fingers. The rig comes with controls and shows no actual bones (which I judge would be easily extendable). It also has a complete armature ref bones that is already scaled to the model in a different layer. I took this armature's hand bones and skinned them to the model. The finger then seemed to work/pose ohk but the problem is that I cannot get them to follow when posing the model using the main rig controls (which yield weird deformation when posing the fingers after). I Googled and tried out what seemed to be solutions (like Child of bone constrains, Ctrl + J, ...) to no proper avail. Any assistance will be appreciated. Happy to provide more info that may be deemed needful toward offering the desired assistance.
Answer: I Googled further > found that I can select the main rig/metarig > go to Edit Mode > Go to Object Data > scroll to Rigify Buttons > Add two palms bones and the 10 fingers (by selecting each and clicking Add Sample) > scale them and link the joints respectively after. Doing this now and expect it will be all I needed. Just wished I could mirror and thus cut the work in half :)
Answer: Thanks for answering the question because I also had the same problem. For your problem with mirroring you could rename the sample(in your case palms) to (the original name.L) and symmetrize the bones and you could work with them like other parts of the rig.
And thank you for your answer you don't know how much it helped me.
And yes I'm a bit late to view this post.


Office 365 - Excel Advanced Filter - Mass Multiple Entries

Question: I've got over 16 000 line entries (stock). Out of the 16 000 I only want to filter 320 of the multiple stock codes in the "ITEM_CODE" column. Instead of selecting one at a time going through that huge list using the drop down filter, I want to select all at once (multiple stock codes). They do run in sequence i.e. row 620 to row 940. I only want to select that specific codes as I need to run a formula for those ones only. PS. I have never used or studied VBA to help me out so I have to do it with formulas etc. if possible.
Comment: Could you share some sample data with us along with the field name on which you want to filter records, will help  us to fix the issue.
Answer: You could say
  if(and(row()<x,row()>y),formula, 0)

If you want to be able to sort the list (I will assume it's an Excel table, not a standard range), start by creating a list of the items codes you want to calculate the formula on...
Then add a formula like
   If(iserror(match(@[item_code],{created list},0)),0, formula)

If it's just filtering the list you are after, and it is all sorted, you could select the lot using Ctrl + g; a640:a480.
Then copy those cells to a new location, and use a slight variation on the second formula.
Answer: I usually solve these type of problems by adding another column in the table.
In this column I add an if that will be true on the rows that I need.
Example if the number you are looking for is between 100 and 200 then use:
=IF(AND(A2>99,A2<201),"true","false")

Change "A" to the column you want to filter on. I assume your table starts at row 2.
And just fill down the column.
Then you can filter on this new column.
Answer: Probably the simplest way to filter for a contiguous range of values is to select them, change their fill colour and then filter by colour.
A quick way to do this would be, for your example:

Select the ITEM_CODE cell of row 620
Shift+Page Dn multiple times and then Shift+Up and/or Shift+Down until the range down to row 940 is selected
Change the fill colour of the selection
Filter for that colour


Mail Server configuration to accept all incoming message but option to Send Outgoing to a specific set of users?

Question: Is there any Mail Server which can accept all incoming message to a user and to a outgoing message should be sent to a particular usernames not to other accounts .
Answer: yes. exim, sendmail, postfix, qmail... most commonly used MTA's on a linux box can be configured to restrict relaying as you have described above, and for all of the examples above, documentation on relay control is pretty good.


How to update Services in silverlight?

Question: The problem is simple yet complicated. I have Created a data model in silverlight and its services. Now I've changed the Database. Added a field in one of the table, and updated the data model. Now I've to update the services that i'd created before. I don't want to delete the previous service. Is there any way through which i can update the service?
Comment: Do you mean a WCF RIA service?
Answer: If you mean a WCF RIA Services Domain Context, then your best bet is to keep your modifications in a separate partial class file.
That way you can recreate the Domain Context when you make data changes (such as your adding of a new field) and not have to do so much reworking to fit it back in.

How to update Services in silverlight?


Two column article with CSS

Question: I would like to have a single in post in two columns automaticly (not with 2 divs) like in a newspaper article. Is there any way to achive this?
Comment: The [CSS multiple column layout module](http://caniuse.com/#search=columns), which has limited browser support.
Answer: You can, using CSS3. There is a new module called 'Multi-Column Layout' that serves specifically that purpose. Here is the link to the W3C recommendation.
You can use it now in Firefox, Safari, Chrome, Opera and Inernet Explorer 10. Take a look at this web page to check compatibilites for the CSS3 recommendations across several browser versions.
The text is supposed to flow from one column to the other and you won't need to use two different DIVs to fake two columns in your page design. You can apply the multiple columns in this way:
column-count: 2;
column-gap: 15px;
column-rule: 1px solid black;

-moz-column-count: 2;
-moz-column-gap: 15px;
-moz-column-rule: 1px solid black;

-webkit-column-count: 2;
-webkit-column-gap: 15px;
-webkit-column-rule: 1px solid black;

Each main rendering engine (like Mozilla's gecko and Chrome's webkit) has made its own property to support this, that's why you have to use the different prefixes -webkit and -moz.
Apart from that, you could also specify the width of the column (instead of the number of columns):
-moz-column-width: 300px;
-moz-column-gap: 15px;

-moz-column-width: 300px;
-moz-column-gap: 15px;

-webkit-column-width: 300px;
-webkit-column-gap: 15px;

In any case, you probably want to use several DIVs because, sadly, Internet Explorer 9 and below don't support all this gorgeous multi-column magic.
Answer: You can use CSS3 multi-columns, though support isn't very good
div {
-webkit-column-count: 2;
-moz-column-count: 2;
column-count: 2;
-webkit-column-width: 20em;
-moz-column-width: 20em;
column-width: 20em;
/* IE10 & Opera 11.1 + support this property unprefixed */
}

Example: http://jsfiddle.net/eFznL/2/

Two column article with CSS


Samba fileshare accessible from certain Windows user

Question: I'm using VirtualBox to run Ubuntu Desktop 16.04. I shared folder and can access it from any Windows user, but I really want so only one specific user can access it and others will get denied. I know how to set password to that share but that's not it.
I tried to search similar question all day but without results. Thanks!
Answer: I don't understand this part of your post:
I know how to set password to that share but that's not it.
It's not clear to me how one sets a password to a share.
Anyway, the classic way of doing this is to edit /etc/samba/smb.conf and create a share definition that in its simplest form looks something like this:
[ShareName]
path = /path/to/folder
read only = no
valid users = bob

Then restart smbd: sudo service smbd restart
You would have to:
** Create a local user on the Ubuntu box named: bob
** Then add him to the samba password database: sudo smbpasswd -a bob
Note: If you created the shares from Nautilus ( Files ) you need to go back and unshare it in Nautilus. Nautilus as currently configured does not have the ability to specify only one user for access.


Does "emergent mother" mean 'woman who has just given birth'?

Question: I'm looking for a word or phrase that refers specifically to women who have just given birth, and I've found "emergent mother", but I haven't been able to confirm whether it's  used only for women who have just given birth, or whether it also refers to expectant mothers (towards the end of pregnancy). If it refers to expectant mothers as well as to mothers who have just given birth, is there another word or phrase that is used only for mothers who have just given birth?
Answer: Like SoronelHaetir, I have never heard that phrase. I suspect that it is a typographical error for "expectant mother." Auto-corrupt strikes again.
The medical adjective for a woman who has recently given birth is "postpartum." I am not sure how many native speakers know that Latin loan word.
The natural, native phrase is "newly delivered mother." She has delivered a baby and been delivered from the final weeks of pregnancy.
I slightly disagree with SH's answer because "new mother" may mean a "mother with a first infant." So, there is an ambiguity in her suggestion, but it was not sufficient to prevent me from up-voting her answer.
Comment: Thank you! "Newly delivered mother" sounds perfect! (I don't think "emergent" in this context is a typo though, seeing as it gets about 70 hits on UK pages only)
Answer: I have never encountered that coupling and if I did I'd have no idea what was being expressed.
The usual phrasing I have encountered )AME speaker) is "new mother". It would not cover those still expecting but the time that someone remains covered would be highly variable. Perhaps "brand-new mother" if you want to limit it to very shortly following giving birth.
If you want to cover just the time that the actual birthing process is underway, "in labor" is very typical.
Comment: @SoronelH. I have upvoted your answer, but I do think "new mother" is somewhat ambiguous.. It may mean "the mother of a newly born **first infant**" or "the mother of a newly born infant." Usually, context will clarify which meaning is intended.
Comment: Thank you! what I'm after is a word/phrase that specifically refers to a woman who has **just** given birth though (hence not a woman in labour (but thanks for the suggestion!)); I guess new mother would work, but – as you say – it's much vaguer. "Brand-new mother" is more specific, but sounds a bit colloquial to me (and I need it for a more formal/clinical context) – but perhaps it works in a clinical context too?


Is RNase AWAY in the lab dangerous?

Question: I use RNase AWAY in the lab. I would like to know how dangerous this chemical is for health. For example, when I remove my gloves my hands smell because of the RNAse AWAY
Comment: @TanMath. Everyone in a lab is entitled to be provided with the equipment and take the necessary precautions to protect their health or address concerns related to their health. If the OP has concerns about the nature of RNase Away in regards to their health, then the smart thing for them to do is ask the questions and get the information that they need to evaluate the risk that they are putting themselves under. That being said, it would likely be better to raise the concern with her lab head or a university safety officer than on a forum.
Comment: "Also, when i removed my gloves my hands smell because of the RNase AWAY." - so?
Comment: Have you read the MSDS (Material Safety Data Sheet) for the product? In general RNAse-Away (or whatever brand specific variant) is just considered an irritant.
Answer: RNase AWAY is marked for Category II skin corrosion/irritation and Category II eye irritation/serious eye damage. Recommendations by the MSDS followed by definitions as follows:

Skin contact Wash off immediately with plenty of water for at least 15 minutes. Remove and wash contaminated clothing before re-use. Immediate medical attention is required.
Eye contact Rinse immediately with plenty of water, also under the eyelids, for at least 15
minutes. Immediate medical attention is required.

SOURCE
DEFINITIONS FOR GHS LABELING
More information is included in the MSDS provided.
As for any smell, RNase away is reported to be a proprietary alkali hydroxide solution, so without any additional information it's difficult to tell.
Comment: You mean I wasn't supposed to be spraying my hands before I gloved? Oops....
Answer: If you are doing RNA preps, there isn't much of a way around it. RNase are everywhere and the only way not the degrade your sample is to use proper technique, barrier protection such as nitrile gloves, certified RNase free containers (macrophage tubes, pipet tips, etc.), and saturate your work surface and instruments with RNAse away.
If you really have a concern and it is available to you, a BSL-2 tissue culture hood with laminar air flow, that you get permission to use for the purpose of an RNA prep, is an option for an added level of safety. You still have to prepare your work surface with it, but the laminar air flow will keep any fumes away from you. A regular fume hood would probably be enough of a precaution, again if you are concerned, and it is less likely that anyone would take issue to you working in it if the BSL-2 hood is set aside for the exclusive use of tissue culture work.
Comment: Using something like RNAse Away is not always necessary, we don't use it at all. Working entirely with disposable containers or containers that were treated with DEPC or heated up high enough, as well as starting with RNAse free water and chemicals is generally sufficient.
Comment: @MadScientist - Who, we? You talk like Louis the Eleventh. user17471 does use RNAse AWAY.
Comment: That is fine if you are working in an area that is set aside specifically for RNA work and is isolated so that contamination is limited, and that area was likely treated in some way to begin with to destroy all biological contaminants. But if you are working on your day-to-day bench, you need to treat the work surfaces with something that will get rid of the enzymes and Ethanol will not cut it. I guess you could bleach everything, but bleach is far more corrosive and toxic that RNase Away.
Comment: And it is up to your labs protocol anyway. If your lab has decided that RNase Away is not a part of your protocol and you have engineering controls in place that can mitigate contamination, then that is great. Most labs don't and user17471's lab protocol is to prep with RNAse away, so using a fume hood or BSL-2 cabinet is about the only alternative available to them to protect their health if they are concerned.
Answer: You should, in general read the Material Safety Data Sheet for whatever chemical you are using. This is always provided by the vendor.
For RNAse-AWAY (Sigma-Aldrich):

Gloves should be worn when handling this product. RNase
  Decontamination Reagent is alkaline in nature and will cause
  irritation if prolonged contact with the skin is allowed. In case of
  contact with eyes, immediately flush with water for fifteen minutes
  and contact a physician. If swallowed, do not induce vomiting. Give
  plenty of water and contact a physician immediately.

According to the MSDS:

Not a hazardous substance or mixture according to Regulation (EC) No.
  1272/2008. This substance is not classified as dangerous according to
  Directive 67/548/EEC.

First Aid measures as per the MSDS.

If inhaled If breathed in, move person into fresh air. If not breathing, give artificial respiration.
In case of skin contact Wash off with soap and plenty of water.
In case of eye contact Flush eyes with water as a precaution.
If swallowed Never give anything by mouth to an unconscious person. Rinse mouth with water.
Comment: I would however say that even if the MSDS says the chemical is not hazardous, a person should make the risk assessment themselves and decide how comfortable they feel working with the substance under certain conditions. Take Ethidium Bromide. While it is a known mutagen that intercalates DNA, if you read the MSDS, it is only dangerous if inhaled of if it comes in contact on an area of the skin that is broken, (cuts, cracks, etc.). Yet most people treat it like the plaque, and while it is irrational and not supported by the known science, they should have the prerogative to protect their...
Comment: ... health how they see fit. And I am not saying your answer isn't implying that, I am only adding that even if the MSDS says its probably safe, it is still up to the person to decide what is best for them.
Comment: @AMR In reality EtBr is not as hazardous as people panic about it. It was used as an antiparasitic drug in cattle.
Comment: I am one of those who is not panicked by EtBr, but in fairness to those who are, we mark out the area where it is used and only use dedicated equipment. I am far more concerned and careful with bleach, having evolved Cl gas after washing a container, that had been washed before with bleach, that was not supposed to contain an acid, but had residue from someone who performed a plasmid prep.

Is RNase AWAY in the lab dangerous?


Help with note grouping in 6/4 time

Question: I'm currently preparing music for a rehearsal and recording session, and I want my charts to be easy and clear to read without any problems.
I have a tune in 6/4 and am a little unsure of what looks best, or if there's a rule when it comes to quarter note off-beats in 6/4.
Here's 2 examples, the top is notated with ties, and bottom is notated with off-beat quarter notes:
Comment: I'm not an expert but I personally prefer the second by a long way. If you have a reason to do the first, I strongly suggest breaking the beams also… although I guess I'm not sure the best way to break them.
Comment: Thanks mate! Yes I agree after looking at them both.
Comment: And you mean breaking the beams as in not having them beamed with 5 8th notes? I'll see if that can be done in Sebelius.
Answer: In both cases showing the 4th beat with an imaginary bar line is the way to go. You did it at times but not consistently. The beamed 8ths look strange with the ties. If you want to use ties like in the top example show every beat like in my circled correction, otherwise there is no real reason to beam them. The bottom one is cleaner and players are not going to complain about off beat quarter notes if they can see beat 4. Bar 34 also needs the same correction.
Comment: Awesome mate, thanks so much, I've made these edits and it's looking heaps better!
Answer: Neither of your solutions is optimal although the second one is better.
In 6/4 the middle of the bar (i.e. between the third and fourth quarter) should be visible. So you should take your second solution and split the B in the first bar with a tie (as in your first version). Similarly for the C in the second bar and the B-flats in the fourth. The third bar is already good.
Also, don't forget to give the sax player a transposed part.
Comment: Great, thanks so much for that, I've got a quite a lot more of this in my sibelius file to correcr now, just having to go back through it now and I might post it once I'm done.

Help with note grouping in 6/4 time


If a solidity library function is marked as public does it inline the function or call it with a delegatecall from the calling contract?

Question: I am aware that a solidity library function marked as external will be deployed separately and called with delegatecall from the calling contract. Whereas a function marked as internal will just be inlined into the calling contract with no need to deploy the library separately. What happens if it is marked public?
Answer: public and external behave the same as each other in solidity library. you could the bytecode of two contracts that the only difference are one is used public another one is used external visibility in the library function. or even you could check the gas cost of each one by a function call, the result is the same. i mean the gas costs don't have any differences.
Note: i didn't find any official documents which is related to this comparison, by testing and experimenting, i got these results.
Please vote up if it helps you :)
Answer: In your "callling contract" you can have internal/public/external, In the case that are internal, only other functions inside the contract can call them.
If they are public or external can also be called externally, this is how your users interact with the contract.
Hope it helps!


How to add subdirectory in google cloud storage using flask in python 2

Question: Im using cloudstorage module for uploading files to google cloud storage since am using python 2.x. And I need to create a subdirectory in my bucket and list all the contents in webpage.
Answer: You don't create directories in Google Cloud Storage (GCS).
GCS is a flat namespace.
GCS buckets contain objects and object names may include "/".
See here for more details.
gsutil and the Console browser make it appear as if buckets contain directories.


Dragon NaturallySpeaking: Speak the punctuation while training?

Question: When performing the general training in Dragon NaturallySpeaking, the user must read from passages of text such as from "2001: A Space Odyssey". When reading these passages, should the user pronounce punctuation? Should the user state "period", "comma", and "quote"?
Answer: Speaking the punctuation is the norm. IIRC, there is a mode that will insert commas and periods automatically, but it's not enabled by default in the new v12.0.
Answer: Speaking the punctuation while training is optional as you can see in the screenshot below taken during training. I personally never do it and I have no issue when dictating punctuations afterward (French and English with Dragon 10, 11, 11.5, 12 and 12.5).
Answer: That is what is normally done in training and in normal use.
Comment: What is normally done in training and in normal use? Speaking the punctuation, or not speaking the punctuation?


Would non-neural physiological insights be considered to be in the field of neuroscience?

Question: For example, would e.g. SCR (skin conductance response) or hormone level be considered to be "neuroscientific measures" according to general definition of neuroscience?
Comment: Why does it matter if it's in the field of neuroscience or not? These are just labels.
Comment: What is SCR? It's best practice to limit the use of acronyms in questions, or at least explain them. Regarding the question - have you done some research yourself? What did you find? Adding your findings may also specify the question. Are you specifically interested in hormones? I'm asking because *'non-neural physiological insights'* is very vague.
Comment: The best part of writing a literature review is that you get to choose the scope.
Comment: I want to know the scope of neuroscience for a literature review.
Comment: I know that. But I still want to know what is the "usual" definition.
Answer: There is increasing scientific evidence to incorporate other organ systems when considering the whole function of the nervous system. Neuroendocrinology, neurogastroenterology, and neuroimmunology are burgeoning fields of research.
If for instance, you were interested in the effects of stress on neurodevelopment, you would likely want to be measuring cortisol levels in your animal model.
If you were performing a study on human fear response, you might want to record SCR in addition to other measures (EEG, fMRI, etc.).
The definition of neuroscience is intentionally broad. There are many biochemists, for instance, who are interested primarily in cell structure, stability, and the transport mechanisms within who study neural tissue specifically because neurons happen to be interesting cases (axons can be very long, how do nutrients and proteins get to where they need to be?).
--
Clin Psychopharmacol Neurosci 2013; 11(3): 107-117  https://doi.org/10.9758/cpn.2013.11.3.107
Ann Clin Biochem. 2017 May;54(3):308-322. doi: 10.1177/0004563216687335. Epub 2017 Mar 16
J Del Signore, Steven & Rodal, Avital. (2016). The membrane strikes back: phosphoinositide binding regulates Skywalker function. Nature Structural & Molecular Biology. 23. 956-957. 10.1038/nsmb.3313.
J. Herzog, Josiah & Deshpande, Mugdha & Shapiro, Leah & Rodal, Avital & Paradis, Suzanne. (2017). TDP-43 misexpression causes defects in dendritic growth. Scientific Reports. 7. 10.1038/s41598-017-15914-4.


Tinyint structure is confusing

Question: I am confused to see this tinyint(3) structure. If tinyint can store only 1 byte then what is the purpose of giving the size in brackets? Is there something special with this parameter in MySQL?
Answer: That's not bytes, it's display width.  It's used as a hint for the maximum expected typical character width of values for the column, to applications that care to actually use the metadata -- which many don't.
As explained in the documentation:

MySQL supports an extension for optionally specifying the display width of integer data types in parentheses following the base keyword for the type. For example, INT(4) specifies an INT with a display width of four digits. This optional display width may be used by applications to display integer values having a width less than the width specified for the column by left-padding them with spaces. (That is, this width is present in the metadata returned with result sets. Whether it is used or not is up to the application.)
The display width does not constrain the range of values that can be stored in the column. Nor does it prevent values wider than the column display width from being displayed correctly. For example, a column specified as SMALLINT(3) has the usual SMALLINT range of -32768 to 32767, and values outside the range permitted by three digits are displayed in full using more than three digits.

The default value for an unsigned tinyint is (3) because that's the size of "255" which the widest number (in displayed character positions) that can be stored in an an unsigned tinyint.
The display width also does not change the storage requirements for the data types; so, for example, an INT(1) still takes up 4 bytes of storage.
Answer: It's just used when zerofill is activated, see bellow:
mysql> DESCRIBE zero_fill;
+-------+------------------------------+------+-----+---------+-------+
| Field | Type                         | Null | Key | Default | Extra |
+-------+------------------------------+------+-----+---------+-------+
| a     | tinyint(3)                   | YES  |     | NULL    |       |
| b     | tinyint(3) unsigned zerofill | YES  |     | NULL    |       |
+-------+------------------------------+------+-----+---------+-------+

we have 2 fields with same size, but b has zerofill activated, lets insert some rows in this table
mysql> INSERT INTO zero_fill SET a=1, b=1;
Query OK, 1 row affected, 2 warnings (0.06 sec)

mysql> INSERT INTO zero_fill SET a=11, b=11;
Query OK, 1 row affected (0.03 sec)

mysql> INSERT INTO zero_fill SET a=111, b=111;
Query OK, 1 row affected (0.03 sec)

and now when we retrieve this row we see the difference:
mysql> SELECT * FROM zero_fill;
+------+------+
| a    | b    |
+------+------+
|    1 |  001 |
|   11 |  011 |
|  111 |  111 |
+------+------+

on b column mysql add left zero's if the size is less the what is inside the brackets tinyint(3)

Tinyint structure is confusing


Haskell on Windows Setup

Question: Unfortunately I don't have access to a *nix box at work or at home.  The only way I can play with Haskell is on windows.  Anyone here using Haskell on Windows? What's your setup?
Answer: DISCLAIMER: What's below was valid in Oct, 2013. So there is a good chance it might get outdated soon. Your edits and comments are welcome.
This is what I have done in order to get Haskell set up on my Windows 7 x64
1. Install Haskell Platform
Download and install the Haskell Platform from http://www.haskell.org/platform/windows.html
2. Install Sublime Text 3
Download and install Sublime Text 3 from http://www.sublimetext.com/3
3. Enable the Package manager in Sublime

Run Sublime
Open the console: View >> Show console
Paste the following code to the console and hit Enter (according to this):

import urllib.request,os; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); open(os.path.join(ipp, pf), 'wb').write(urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ','%20')).read())

Open the command palette: Tools >> Command palette
In the command palette popup type in: Package Control: Install Package
Select the package: SublimeHaskell

4. Install Haskell tools
Cabal is the standard package manager for Haskell. What you need to do is:

Start a console with administrative permissions
Run:
cabal install cabal-install
cabal update
cabal install aeson
cabal install haskell-src-exts
cabal install ghc-mod
cabal install cmdargs
cabal install haddock

5. Install hdevtools
You can NOT install hdevtools on Windows by running: cabal instal hdevtools. What you need to do instead is:

Download the source code of hdevtools for Windows from https://github.com/mvoidex/hdevtools*
(* Currently does not work with GHC 7.10. See this fork for building with GHC 7.10 and above)
Unpack it to some folder
Go to that folder and run:
runhaskell Setup.hs configure --user
runhaskell Setup.hs build
runhaskell Setup.hs install

Watch for the path (in the console output) where the hdevtools have been installed. You will need this path when setting up the SublimeHaskell plugin in Sublime. The path should look something like this: C:\Users\Aleksey Bykov\AppData\Roaming\cabal\bin where Aleksey Bykov is the name of the current user.

6. Setting up the SublimeHaskell plugin in Sublime:

Start Sublime
Go Preferences >> Package settings >> SumblimeHaskell >> Settings - User
Make sure you configuration looks like:
{
    "add_to_PATH":
    [
        "C:/Users/Aleksey Bykov/AppData/Roaming/cabal/bin/"
    ],
    "enable_hdevtools": true
}

where C:/Users/Aleksey Bykov/AppData/Roaming/cabal/bin/ is that path (you got at step 5) where hdevtools (all all other toolls have been installed)
4. Save the file and restart Sublime
7. Hello world

Start Sublime
Create a new file and save it immediately as hello-world.hs
Put the following code there:
main::IO()
main = putStrLn "Hello world!"

Build and run by going Tools >> Build x 2 times (first it builds, second it runs)

8. See also
There is another great article: http://howistart.org/posts/haskell/1
Comment: This should be the accepted answer imo. As of 2014-05-02 it still works exactly like outlined above except one small caveat - if you're running the latest Haskell Platform installer you might not be able to run `cabal install haddock`, instead run:
 `cabal install haddock --constraint=haddock==22.214.171.124`.
Comment: Most of what you and @AndersHolmström said works but for me sublime was not finding hdevtools or the other cabal packages I had installed, turns out it didn't have permission to access cabal's bin folder, probably because I downloaded and ran the portable version of sublime. to solve it I just had to run sublime as admin, don't know if this is safe but it solved the problem for me. as an aside everytime I start sublime it does the task "loading standard modules cabal" for a while is this expected behaviour?
Comment: I agree with @AndersHolmström - i think this is the best answer, however i think the cabal installer must have been upgraded as i didn't have any trouble with hdevtools today. Once i had installed the haskell environment all i needed to do was open cmd.exe and run 'cabal install' and it resolved and installed hdevtools for me. after that i configured the sublimehaskell plugin, and it now all works!
Comment: got deprecated this year.
Answer: I've used Haskell on Windows, but only when forced to.  Not because the combination Haskell+Windows is particularly bad, but just because I don't really like Windows.
My setup was basically the following:

GHC
Vim
MinGW
Console
CMake
Visual Studio Express

As you can see I was trying to get an environment that was as similar to Unix as possible (without using cygwin, because I find it utterly confusing).  Vim is my favourite editor.  The reason for Visual Studio was that the C environment shipped with GHC doesn't cover all of Win32API.  I used CMake to get a decent build environment.
Comment: The Windows "dos box" is a pile of crap, IMNSHO :-)  Console is a properly resizable terminal window.  MinGW does come with a terminal, but it mixes in some Unix-ness that isn't always desired.
Comment: Add the powershell to the mix to get a decent shell, and you got a pretty strong developing environment for Haskell on windows.
Answer: Haskell Platform is now more or less the standard distribution of haskell, and it has a windows installer.
Comment: The main advantage of Haskell Platform over plain GHC installation is that the Platform contains precompiled packages which is hard to compile on Windows because they require MSys toolchain.
Comment: Sadly, Haskell Platform is deprecated as of 2022 - see https://www.haskell.org/platform/
Answer: GHC is a state-of-the-art, open source, compiler and interactive environment for the functional language Haskell.
There is a Windows installer for GHC, but it for Version 6.4.2 .
A Windows .exe (not an .msi installer) for version 6.10.1 is at http://www.haskell.org/ghc/dist/6.10.1/
It is not clear when the current (GHC 6.10.1) version will offer a Windows installer.
Answer: No one seems to have mentioned Atom yet, which I've been using for a few weeks now. It's not quite as stable and mature as ST3 yet, but it looks promising and offers cabal (partial) and ghc-mod (good) integration via plugins.
Answer: How to install Haskell in windows10 :
Step01: open windows powershell (run as administrator) and run the following command as instructed:
command 1 : command = Get-ExecutionPolicy, If it returns "Restricted" then run this command = Set-ExecutionPolicy AllSigned
command 2 : command = Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
(note: type "Y" whenever it asks and click enter )
step02:run the following command(in windows powershell (run as administrator)):
command = choco install haskell-dev haskell-stack
(note: type "Y" whenever it asks and click enter )
after running this command close the powershell
step03: verification if you did everything right:
open command prompt and run the following code:
command = ghc --version
output should be = The Glorious Glasgow Haskell Compilation System, version 9.2.1
(minimize the command prompt)
how to run a simple code and get output :
step01: open command prompt and run the following commands one by one:
cd \
cls
mkdir dev
cd dev
cls
notepad hello.hs
notepad will open and now write the following program and save it :
program:
main = do
print "My first Haskell program"
name <- getLine
print ("Hello, " ++name)
write this and save
step 02 : to run the program open command prompt that was minimized before and run the following commands:
commands=

ghc hello.hs
hello
You should get the output as : My first Haskell program.

To use the same in vs code: after you do the above steps open(open with vs code) hello.hs file in c drive dev folder and then in extentions install Haskell Syntax Highlighting  and run the same commands in terminal choose command prompt as default rather than windows powershell.
(note before you open the .hs in vs code make sure you delete every other file expect the hello.hs file)
Answer: I recall using hugs with some success a while ago. I was just playing around though.
Comment: The problem with hugs is that is... well a bit out of data. I was using ghc and then I had to come back on hugs for university course. I felt how many things is missing (to be honest - even downgrade from 6.10 to 6.8 was felt).
Answer: I based on Magnus solution. I have to state that I'm normally GNU/Linux user and I had to port low level packages (like this one).

Console
Haskell Platform (it contains GHC and, on Windows, MinGW)
Cygwin with X
XEmacs
Answer: Installing it on windows is much more difficult and painful that on a Mac (as it is with almost all dev software). That being said, here is the simplest way to set up a Haskell environment on Windows 10:
Open Powershell as Aministrator (right click, and "Run as Administrator").
1 In Powershell, check your execution policy as follows:
Get-ExecutionPolicy

2 If you get "Restricted", you need to change it. Execute this command:
Set-ExecutionPolicy Bypass -Scope Process

3 When you get a question prompt, type:
A

Hit Enter.
4 Verify your policy again with Get-ExecutionPolicy. Now your policy should be "Bypass".
5 Double check that you have Chocolatey:
choco

6 Install Haskell:
choco install haskell-dev

It takes a while..
7 Start coding in Haskell!
http://learnyouahaskell.com/starting-out
Answer: Or You could partition your hard-drive a duel boot between linux and windows :)
Doesn't answer your question, but it is an alternative.
Comment: I second this suggestion.

I've just install a new partition with Fedora 11, and Haskell. It took me about an hour (most of which was just machine time).

A direct Windows installation of Haskell requires Cygwin, or MinGW. I've used both of these in the past. They work OK, but require a lot of fiddling, and, last time I checked, didn't work under Vista.

If you've never installed a Linux partition, it may seem scary, but I think you'll find it easier than Cygwin or MinGW + Haskell.
Comment: I find this kind of answers counter-productive. That's great you use Linux. Or FreeBSD. Or OS X, or Solaris, or Haiku, or whatever. But this is just annoying to ignore "The only way I can play with Haskell is on windows" and suggest otherwise.
The actual problem I find with this kind of answers is that they do not provide *any* value to the OP or the SO community.
Comment: @kgadek Except, if he's got a PC, with windows on it, he can make it both windows and linux. It's a valid alternative that he may not have fully realised was possible. Though, 7 years later, my advice now, should he come across something that ideally requires *nix, would be to use a vm, and maybe even something like Vagrant. But that's neither here nor there.
Answer: You could install Sun's VirtualBox, and install Linux on it.

Haskell on Windows Setup


Optimal method of storing image thumbnails

Question: I'm working on an application with a database containing many recipes. The API is written in Django (with Django REST Framework) and frontend in React.Each recipe is assigned a high-quality image. In React application, the user can see all the recipes with their images in a list view. The problem is that they take too long to load. The solution I came up with is storing two images for each meal. One is the high-resolution image which is only loaded in detail view, and a thumbnail which is simply a smaller version of that picture that shows in the list view.

How would you go about this? Is it the optimal solution? Or is there a way to downscale the image already in the frontend, without having to store two images in the database?
Comment: A couple of more practical points: (1) in my experience, images can very often be compressed a lot better by certain tools or with newer formats with no loss of quality. compressor.io does some really amazing things, but simply converting JPEG to WEBP can make a significant difference aswell. (2) There is a relatively new approach for handling use cases like yours, using `srcset`, see [here](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images). Regardless, you should have more than one size available, it's not a bad thing. Also gzip..
Comment: To add to the above, you can sometimes also get speed improvements by serving from cloud storage solutions like S3, depending of course on what the bottleneck is.
Answer: Having multiple different resolution images is a very good idea. Perhaps 2, perhaps more, in your use case probably those 2.
The problem with downscaling on the fly is that you have to:

Wait for network capacity to give you the images from the database
Wait for JPEG decompression to decompress each high-resolution image
Wait for resizing algorithm to make them into lower resolution

The first takes network bandwidth, the remaining two take CPU time. I'm certain that some of those three is your bottleneck. If you downscale images in the frontend, all of those are repeatedly taking resources.
If you already know what resolution you need and the requirements won't change, store just those resolutions. If you don't, then it's possible to store powers of two, e.g. 2048x2048, 1024x1024, 512x512, 256x256, 128x128.
Answer: The biggest issue you will run into is bandwidth.  Quite simply larger images require more bytes than smaller images.  Having a down-scaled image for your listing helps save that bandwidth until a user actually picks a recipe to open.  You don't need the high resolution photo at that time.  The downside is that you are storing more bytes in your database.  Many times the bandwidth is worth it.
You have a couple of options available to you:

If you store your images in a cloud blob store, most cloud providers allow you to create an asynchronous job to downscale and store the smaller image without changing your code
If you store images in a database, you have to build that infrastructure yourself
On the upload side, have the client perform the image scaling and upload both images at that time

Bottom line is that you need to process the photos, the only difference being the mechanism you choose to do it.  If you have something in place to asynchronously generate thumbnails, then you do need a placeholder image that is displayed until the thumbnail is ready.
Answer: There is the concept of progressive image encoding. This essentially splits the image into layers, where each layer contains additional details. This can allow a lower quality image to be downloaded first, and the additional detail downloaded at some later time. This could save a bit of data compared to using a separate thumbnail. This technique can be a major benefit you want to quickly display a full resolution image at lower quality, adding more details as more data have time to download.
But it might require a more complex system, and some components might not support progressive encoding. So using a separate thumbnail will probably be easier. And if the size ratio between the full resolution image and thumbnail is large, then the additional overhead will be small.
Comment: If the page contains 50 thumbnails, I'm pretty sure the software to display that page such as a web browser only fetches few thumbnails at a time and when this limited number of thumbnails have been downloaded, proceeds to download the next. I don't believe any software creates 50 connections to the server, which would be required to display all images first at low resolution and then at high resolution.


Will eukaryotic RNA fold in the same way in prokaryotes?

Question: As far as I know, there are no specific eukaryotic or prokaryotic factors that aid in RNA folding other than cellular environment (salt and ion concentrations, dissolved molecules, etc). Are there any factors to consider when introducing eukaryotic RNA in prokaryotes? Is it possible to predict the proper shape and folding upon introduction to a prokaryotic cell?
Comment: Interesting question. Ionic concentrations and temperature will certainly affect RNA folding. There may well be other constraints as well.
Comment: RNA chaperones will be different as well. I'm not sure how much the relevant ion concentrations vary, but Mg concentration is certainly a very important factor in RNA folding. And are you asking about secondary or tertiary structure by the way?
Comment: @MadScientist, in my specific case I was more interested in secondary structure, but an answer addressing tertiary would be ideal
Comment: Fast googling: http://www.nature.com/nature/journal/v505/n7485/full/nature12894.html#ref3 this might help
Answer: As you have mentioned ions and temperature affect RNA structure. There are also different types of RNA structures and their dependence on ions are different. Mg2+, as Mad Scientist mentioned, stabilizes duplexes; so do monovalent cations like K+ and Na+. However, Mg2+ favors duplex over quadruplex if the same RNA can adopt both these conformations.
Dependence on temperature is a trivial case.
Ions and temperature should be more or less same for prokaryotes and eukaryotes unless we are talking about extremophiles.
Apart from these factors I can think of two other factors that can cause difference in RNA structure between prokaryotes and eukaryotes:

Osmolytes
RNA binding proteins/chaperones (Already mentioned in comments by Mad Scientist)

Osmolytes
It has been shown that TMAO (Trimethylamine N-oxide) stabilizes RNA secondary structures. The metabolism of TMAO is different in prokaryotes and eukaryotes.
From this paper:

Although eukaryototes can endogenously produce L-carnitine, only
  prokaryotic organisms can catabolize L-carnitine11. A role for
  intestinal microbiota in TMAO production from dietary carnitine was
  first suggested by studies in rats; moreover, while TMAO production
  from alternative dietary trimethylamines has been suggested in humans,
  a role for microbiota in production of TMAO from dietary L-carnitine
  in humans had not yet been demonstrated30-32. The present studies
  reveal an obligatory role of gut microbiota in the production of TMAO
  from ingested L-carnitine in humans (Fig. 6c)

I cannot ascertain that this will affect RNA folding but is possible.
RBP
This is something that you can be certain about. Some RNAs require protein counterparts to adopt a functionally capable structure. In the absence of the protein they may not form the relevant structure. So if an RNA needs Hfq then you have to express it in the eukaryotic system where you want to use the RNA (and converse).


Coutnifs in Excel VBA is Not Working

Question: I'm having trouble with getting my code to work (see below). The problem is the countifs function in the last section of the code. I feel that I have formatted it right but an error message is thrown up each time it gets to this part of the code. Error message is "Run-time error '438': Object doesn't support this property or method." Any suggestions are appreciated.
Sub manipulate()

Dim wkb1, wkb2 As Workbook
Set wkb1 = ThisWorkbook
Set wkb2 = Workbooks.Open("F:\Flat Panel Engineering\09 MIT\Data\Yield-
    Symptom_Report_rev05.xlsx")

wkb2.Activate
Sheets("Raw Data - MES Yield").Activate
Range("E1").EntireColumn.Insert
Range("E2").Select

Dim cell, column As Range
Set column = Range("E1:E416650")
For Each cell In column
    cell.Value = Application.VLookup(cell.Offset(0, 1), _
    wkb1.Sheets("PF").Range("A1:B80"), 2, False)
Next cell

wkb1.Activate
Range("A3").End(xlToRight).Offset(0, 1).Select
ActiveCell.Value = WorksheetFunction.CountIfs(wkb2.Range("E:E"), _
    Range("A3"), wkb2.Range("J:J"), Range("B3"), _
    wkb2.Range("K:K"), Range("C2"), wkb2.Range("N:N"), Range("D1"))

wkb2.Close savechanges:=False

End Sub

Comment: It is Application.WorksheetFunction.Countifs as well as whatever else is the problem.
Comment: Did you mean to have the CountIfs criteria to be on different rows?  A3/B3/C2/D1?
Answer: for only the error described you need to add Application before WorksheetFunction and all the ranges need a worksheet name between the workbook part and the range part. You are currently frequently saying Workbook.Range which is invalid.
ActiveCell.Value = Application.WorksheetFunction.CountIfs(wkb2.Worksheets("insertworksheetname").Range("E:E"), wkb1.Worksheets("insertworksheetname").Range("A3"), wkb2.Worksheets("insertworksheetname").Range("J:J"), wkb1.Worksheets("insertworksheetname").Range("B3"), _
    wkb2.Worksheets("insertworksheetname").Range("K:K"), wkb1.Worksheets("insertworksheetname").Range("C2"), wkb2.Worksheets("insertworksheetname").Range("N:N"), wkb1.Worksheets("insertworksheetname").Range("D1"))

You will get away with the ones where you have just put Range as they reference the active sheet but it is always better to explicitly reference the sheet by name.
Answer: As already answered, Workbook's don't have Range's, Worksheets do.
Where you use wkb2.Range("E:E") etc, add a reference to the required sheet
eg
wkb2.Worksheets("Raw Data - MES Yield").Range("E:E")

Some side notes

where you use Dim wkb1, wkb2 As Workbook only wkb2 is declared as Workbook (wkb1 will be a Variant).  Be explicit for each variable on the line
it's better to avoid activating / selecting.
you can avoid the VLookup loop, which be be a lot faster

Your code refactored to demonstrate
Sub manipulate()
    Dim wkb1 As Workbook, wkb2 As Workbook
    Dim ws1 As Worksheet, ws2 As Worksheet
    Set wkb1 = ThisWorkbook
    Set wkb2 = Workbooks.Open _
      ("F:\Flat Panel Engineering\09 MIT\Data\Yield-Symptom_Report_rev05.xlsx")

    Set ws2 = wbk2.Worksheets("Raw Data - MES Yield")
    ws2.Range("E1").EntireColumn.Insert

    Dim column As Range
    Set column = ws2.Range("E1:E416650")
    column = Application.VLookup(column.Offset(0, 1), _
      wkb1.Worksheets("PF").Range("A1:B80"), 2, False)

    Set ws1 = wbk1.Worksheets("NameOfWb1Sheet")
    ws1.Range("A3").End(xlToRight).Offset(0, 1).Value = _
      Application.WorksheetFunction.CountIfs( _
      ws2.Range("E:E"), ws1.Range("A3"), _
      ws2.Range("J:J"), ws1.Range("B3"), _
      ws2.Range("K:K"), ws1.Range("C2"), _
      ws2.Range("N:N"), ws1.Range("D1"))

    wkb2.Close savechanges:=False

End Sub

Coutnifs in Excel VBA is Not Working


Histograms with frequency density on the vertical axis

Question: In a histogram with frequency density on the vertical axis, could the actual frequencies for each bar of the histogram come out not as whole numbers?
Answer: That depends: if the Y-axis is relative frequency then yes, it will be a fraction. Otherwise it should be the number of points in a particular bin.