How do I disable SID security check for folder redirection with Group Policy?

Question: How do I disable the SID security check for folder redirections with Group Policy? This isn't about weakening security, but rather about having Active Directory and Samba play nicely together.
I have a kerberized REALM-trusted Samba server. Users can read and write what they're supposed to be able to read and write to. Users can't read and write what they're not supposed to be able to read and write to. However, if I try to use it for Folder redirection I get errors like the following.
<code> EventData

  FromFolder RoamingAppData
  ToFolder \\samba.example.com\home\username\.AppData
  Options 0x9219
  Error Can't create folder "\\samba.example.com\home\username\.AppData"
  ErrorDetails This security ID may not be assigned as the owner of this object.
</code>
The roaming profile does not have the same problem, but I had to enable:
<code>Computuer Configuration \ Administrative Templates \ System \ User Profiles \ Do not check for user ownership of Roaming Profile Folders
</code>
Is there an equivelent setting for folder redirection that I have overlooked?
Answer: You need to clear the "grant exclusive rights" checkbox in the folder redirection settings.
http://technet.microsoft.com/en-us/library/cc785925(v=ws.10).aspx
"If you must create folders for users, make sure that you set the correct permissions. Then, clear the Grant exclusive rights to check box on the Settings tab of the Folder Redirection Properties page. If you do not clear this check box, Folder Redirection first checks preexisting folders to determine if the user is the owner. If the administrator previously created the folder, the check fails, and redirection is cancelled. Folder Redirection logs an event in the Application event log indicating that redirection failed and that the new directories for the redirected folder cannot be created due to not being able to assign a security ID as the owner of the folder (Event ID 101)."
Comment: Note: The target folder will not be created. If the target does not exist, the same error will be issued.
Answer: If i'm not wrong, the folder redirection must be set from User Configuration to the destination you wish.
Maybe this can help you: Folder Redirection


Jacobi iteration method

Question: I try to find solution for this ex. using Jacobi method

So i just write simple code for this case
 int main(int argc, char** argv)
 {
   int n = 100;
   double x[n], y[n], z[n], q[n];

   x[0]=0.0;
   y[0]=0.0;
   z[0]=0.0;
   q[0]=0.0;

   for(int i=0; i < n; i++){
     x[i+1] = 29.0/5.0 - (2.0*y[i])/5.0 - z[i]/5.0 - q[i]/5.0;
     y[i+1] = 31.0/6.0 - (2.0*x[i])/6.0 - (2.0*z[i])/6.0 - q[i]/6.0;
     z[i+1] = 26.0/7.0 - x[i]/7.0 - (2.0*y[i])/7.0 - q[i]/7.0;
     q[i+1] = 19.0/8.0 - x[i]/8.0 - y[i]/8.0 - (2*z[i])/8.0;

     cout<<"\tx="<<x[i+1]<<"\ty="<<y[i+1]<<"\tz="<<z[i+1]<<"\tq="<<q[i+1]<<"\n";

   }

   return 0;
 }

And it's not working! As you can see even after 10(20, 30) iterations it must look like solution

But here's what I got ($n = 20$)

Look at $z$ (which is $x_3$ value)
What's wrong?
Comment: Arguably it's better to develop your algorithms first in python + numpy or Matlab, and only later write them in C if you need more speed.
Comment: @littleO does it matter which language to use?
Answer: I wrote this Matlab code and got the same answer you got.  So I think your code is correct.
A = [5 2 1 1; 2 6 2 1; 1 2 7 1; 1 1 2 8];
b = [29 31 26 19]';

B = A - diag(diag(A));
D = diag(A);

xn = zeros(size(b));

for n = 1:20

    xn = (b - B*xn)./D;

end

Edit: The correct solution computed using Matlab's backslash operator agrees with the solution your code came up with.
EDU>> A\b

ans =

   3.992753623188405
   2.954106280193237
   2.161835748792270
   0.966183574879227

Whoever wrote this problem meant for the right hand side of the equation to be $\begin{bmatrix} 29 \\ 31 \\ 25 \\19 \end{bmatrix}$.
Comment: well, but why is there such big observational errors?
Comment: The "solution" is not correct.  Your code is working.
Comment: I edited my answer to show the solution given by Matlab's backslash operator.
Comment: Well, yes, code works but how to make it solve it right?
Is there some more codtitions which I should to check?
Comment: What I meant is that your answer key has an error, but your code is fine.
Comment: Damn, thanks! This problem is from one old soviet book about iteration methods :)

Jacobi iteration method


How to Delete Permissions from Linkedin App

Question: I am trying to find the answer of something stupid, but I can't. Does anybody know how to remove the "w_member_social" permission from linkedin App (if there is a way to do something like that)? I need this because the client does not want to see the message "- Post, comment and like posts on your behalf" when authorizing linkedin accounts on our application.

Any other suggestion on how to solve that is welcome.
Thanks in advance!
Answer: Quick Fix:

Search for w_member_social string in your backend code if you find it in the configurations just remove it.

Explanation:
You can't remove w_member_social permission directly from the LinkedIn app, but it can be modified by making changes in the backend code of your application.
You need to follow certain general steps irrespective of the backend you are using:

Find out the library you are using for social authentication/OAuth2 service
Check library documentation for Application scopes W.R.T LinkedIn
go to backend configurations/settings file remove the option w_member_social from your configuration.

My Case:
My application backend was created using the Django framework and for social authentication, we were using python-social-auth library. I just navigated to my setting file and commented out w_member_social scope/permission.
<code>SOCIAL_AUTH_LINKEDIN_OAUTH2_SCOPE = [
"r_basicprofile",
"r_emailaddress",
# "w_member_social",
</code>
]


call user control and pass custom property with allowed values

Question: i would like to call a user control(ascx) in one of my aspx page and pass a custom property with allowed predefined list of values, to it.
example:
<uc:MyCustomControl runat="server" CustomProperty="One|Two|Three" />

the {One, Two, Three} should come in Visual studio intellisence dropdown, similar to "Treu|False" values for IsVisible property.
Comment: define CustomProperty as enum !!
Answer: Use an enum on your control:
public enum CustomPropertyOptions
{
     One,
     Two,
     Three
}

public CustomPropertyOptions CustomProperty
{
     get; set;
}

Comment: Please consider marking this as the answer, if it solved your problem.
Comment: I tried, but i don't have 15 points, which is eligibility of marking responses as answers.


Not split-DNS, but close

Question: I have read this article on split-DNS: http://www.isaserver.org/tutorials/You_Need_to_Create_a_Split_DNS.html. I think I understand the concept, but to set up the optimal solution suggested in the article I need to control the DNS servers on "the outside" (which I cannot in my case).
My scenario is as follows: one internal domain called corp.local. One public domain called corp.com. I have a web site on the address www.corp.com, which actually points to a published server on the domain corp.local. I would like to publish this web server to internal clients as well (clients on the domain corp.local), without them going to the external IP and back. So I just setup a new zone on the DNS server the internal clients (corp.local) are using called corp.com, and add an entry for www.corp.com, this time pointing to a internal IP address.
To my problem: I have a lot of other entries on the external web server which should be left as they are. I know I could just copy and maintain two DNS servers, but ideally I would like this:
Case 1

Internal client asks for www.corp.com.
The Internal DNS server looks if it has an entry for www.corp.com.
It has, so it answers with the internal IP address for www.corp.com.

Case 2

Internal client asks for someother.corp.com.
The Internal DNS server looks if it has an entry for someother.corp.com, and it finds none.
It then forwards the request to the external DNS server, to see if that has an entry defined for someother.corp.com.
The external DNS server responds back to the Internal DNS server with the external IP for someother.corp.com.
The Internal DNS server responds back to the Internal client.

What happens in reality for Case 2 is that the Internal DNS server thinks it is authoritive for the zone corp.com (which it kind of is), and if it does not find a record for someother.corp.com it responds to the client with a negative answer.
Hope I made myself clear, looking forward to your input! Thanks in advance! Also, I'm running Windows domain with Windows DNS servers (Windows Server 2008).
Comment: Possible duplication of this question: http://serverfault.com/questions/188948/split-brain-dns-and-dns-forwarding
Comment: I need to clarify something here: for your internal users/DNS Server, do you want to forward requests for *.corp.com to your external DNS server, while www.corp.com and .corp.com resolve to your internal IP? Or are you trying to forward _any_ requests to *.corp.com that do not resolve locally to your external DNS server, i.e. you may have an A record for foo.corp.com that resolves internally by the internal DNS server, but if you asked for bar.corp.com, which doesn't resolve, it would get forwarded to the external DNS server?
Comment: ignore the italics... must've forgot to close the tag.
Comment: oh and it should read "do you want to forward requests for .corp.com to your external..." in the first line.  Having a rough go at it today.
Comment: I want to do exactly as you've written, "have an A record for foo.corp.com that resolves internally by the internal DNS server, but if you asked for bar.corp.com, which doesn't resolve, it would get forwarded to the external DNS server". I'm not sure I understand what you want clarified here.. what's the difference between the mentioned case and "do you want to forward requests for *.corp.com to your external DNS server, while www.corp.com and .corp.com resolve to your internal IP"? Thanks for your input!
Answer: This is a little bit of a hack - and i've only done it with bind, but it works.
Create a new zone called www.corp.com then create and @ record for the zone to be the internal IP address of your website.
This will make the DNS server think it is authoritative for the "zone" www.corp.com and return the @ record when people request www.corp.com. It will pass the rest of *.corp.com out to your normal public DNS servers for a recursive lookup and return the external IP.
Comment: The asker wants to forward any NXDOMAIN'ed request for *.corp.com to the external DNS server, so this won't work.  He doesn't want to maintain two zone configurations for corp.com.
Comment: @gravyface you've missed the point - this (very hacky) configuration makes the internal server _only_ authoritative for www.corp.com (and subdomains thereof).  Resolution for anything else in *.corp.com should follow the normal resolution path.
Comment: Right, and you can do that in Windows DNS too, but I think the asker wants to be selective, depending on whether there's an answer or not locally i.e. foo.corp.com resolves internally, bar.corp.com resolves internally, but foobar.corp.com does not resolve internally, so it gets forwarded to the external DNS server.
Comment: I think this solution might work actually. What do you mean the problem is here gravyface? foo.corp.com will resolve internally if there's an @ record on the internal DNS server, and so will bar.corp.com. These records would actually be individual zones, so the internal DNS server will not be authorative for the whole domain corp.com. When foobar.corp.com is requested, the internal DNS server will forward the request, as it is not authoritive for the zone corp.com (only bar.corp.com and foo.corp.com). Am I missing something?
Comment: @jos yep it will work, I've had to do it in a couple of places , for other reasons but same result.
Comment: @gravyface it's not taking action on NXDOMAIN it's just forwarding stuff it's not authoritative for to the authoritative servers. So same result as if you could somehow get the DNS server to not return NXDOMAIN but forward the request instead ...
Comment: I guess I was thinking that he needed a zone internally for corp.com as well.
Answer: If you use Unbound as a recursive server you can get it to reply for specific local data using the local-zone and local-data directives, and forward any unknown entries to an external server.
local-zone: corp.com. transparent
local-data: "www.corp.com. IN A www.xxx.yyy.zzz"

The manual page is at http://www.unbound.net/documentation/unbound.conf.html
Comment: I'm currently using Windows DNS, but thanks anyway =)

Not split-DNS, but close


Where do you put your template override files?

Question: I am trying to get Drupal to recognize a template override that is a theme hook suggestion.
However, I don't know how to get Drupal 7 to recognize it.
Specifically, Drupal commerce allows for the override of a customer order using the template file
commerce-order--commerce-order--customer.tpl.php
I don't know where to put this.
I tried putting the file in my own theme directory, and clearing the cache. But it didn't recognize it.  Do I need to add something to the .info file of my theme?
I DID GET THIS TO WORK when I put the template in the main theme of the site, namely the omega_kickstart template directory. But this is not ideal for upgrading.
Finally, I tried making my theme a sub theme of omega_kickstart thinking it would override then, but that didn't work.
Comment: Out of curiosity, is this the only tpl file that your template isn't loading?
Answer: When creating new templates for your theme you need to name it to match your theme.
You'll want something like:
YOURTHEMENAME--commerce-order--customer.tpl.php

Comment: I am overriding the entity commerce-order and using the theme_hook_suggestions for commerce entities from commerce module. I am pretty sure this is the correct naming convention because it works in the omega_kickstart theme. I did try what you suggested though, and it didn't work.
Answer: What exactly this file is going to override? if it is a node then use this code in template.php
function MYTHEME_preprocess_page(&$variables) {
    if ($variables['node']->type == 'SomeThing') {
    // This will look for template named page--commerce.tpl.php in your theme.
        $variables['theme_hook_suggestions'][] = 'page__commerce';
    }
}

then create file page--commerce.tpl.php in your theme directory
and if it is a view you can do the same in hook_preprocess_views_view or there is another solution in here
Comment: What I am overriding is a commerce_order entity.  I am using the theme_hook_suggestions that are defined by commerce already so I don't think I need to define my own.  When I turn on theme debug, commerce-order--commerce-order--customer.tpl.php is one of the suggestions for overriding the page.  As I said, it works in the default theme, just not mine.
Answer: You can put the file in your theme directory, you need to clear the theme-registry cache to get the new template to register.
If you have drush: drush cc theme-registry
If you do not, use the Clear Cache button (Admin >> Configuration >> Development >> Performance) a few times. You should then have your new template registered.
Comment: I tried clearing the cache using drush, and it still doesn't show up. Thank you though for making me aware of how to clear the cache using drush. That will be useful in the future


Orthogonal sets and embedding between Hilbert spaces

Question: Let $V=(V,(\cdot , \cdot)_V)$ and $H=(H,(\cdot , \cdot)_H)$  be Hilbert spaces, such that $V \subset H$, $V$ is dense in $H$ and $V$ and the embedding $V \hookrightarrow H$ is compact.
Question. If $A:=\{w_n\}_{n \in \mathbb{N}}$ is a complete orthogonal set in $V$, then $A$ is also a complete orthogonal set in $H$?
I think that $A$ is complete in $H$. Because, $A$ is complete in $V$, so the closure
of the the set spanned by $A$ is equal to $V$, simbolically $\overline{[A]}=V$. But, $V$ is dense in $H$, that is, $\overline{V}=H$. Hence, $\overline{[A]}=\overline{\overline{[A]}}=\overline{V}=H$, which implies $A$ is complete in $H$. See more details here.
In order to prove that $A$ is a orthogonal set in $H$ I don't see how to prove that: $(w_m, w_n)_{V}=0$ implies $(w_m, w_n)_{H}=0$, for every $m,n \in \mathbb{N}, m\neq n.$ Here can I to use the compactness of the embedding? Or it's not possible to prove that?
References are welcome.
Answer: No, in general you can't conclude that two functions orthogonal in $V$ are so in $H$ (or vice versa for that matter). For instance consider $H=L^2(\mathbb{R})$ and $V=H^1(\mathbb{R})$ the Sobolev space of order one, i.e.
$$
V=\{ f\in L^2(\mathbb{R}): \hat{f}(\xi)(1+|\xi|^2)^{1/2}\in L^2(\mathbb{R})\},
$$
with inner product given by
$$
(f,g)_V:= \int_\mathbb{R} \hat f(\xi)\hat{g}(\xi)(1+|\xi|^2)\, d\xi.
$$
Now it's a matter of constructing two functions $f,g$ such that $h=\hat{f}\hat{g}$ satisfies
$$
\int_\mathbb{R} h(\xi)\, d\xi \neq 0, \qquad \int_\mathbb{R} h(\xi)(1+|\xi|^2)\, d\xi =0.
$$
You can always do this, for instance, by taking
$$
h(\xi)=
\begin{cases}
1, & \xi\in [1,2],\\
-1, & \xi\in [3,b],\\
0, & \text{otherwise},
\end{cases}
$$
for an appropriately chosen constant $b$.
Comment: Right, in general is not true. But, when $A$ is a complete orthogonal set? Moreover, by density, for every $v \in H$ there exists $(v_\nu)_{\nu \in \mathbb{N}}$ such that $v_{\nu} \to v$, where for each $\nu \in \mathbb{N}$ we can write $\displaystyle v_{\nu}=\sum_{n \in \mathbb{N}} (v_{\nu}, w_n)_V w_n$. So I can't go from $V$ orthogonality to $H$?
Comment: @Guilherme: No. By the Gram-Schmidt process you can extend these two functions in $V$ to a complete basis (after normalizing them). The density, as you note, will hold in $H$ but not the orthogonality.
Comment: I agree. The orthogonality is more complicated.  Thanks!


Fix loose bridge saddle screw

Question: One of the bridge height adjustment screws keeps coming loose on my Precision Bass (leftmost screw in the picture). The screw doesn't feel loose when the height is properly adjusted, but the E saddle works its way down to the deck on that side after just a few hours of play. The first time I noticed the problem, the screw had almost worked its way entirely out of the saddle.
My playing style doesn't bring my hand in contact with the bridge much, so I presume that vibrations are working the screw loose. This of course affects the action and tuning of my E string, and I'm concerned that it might fall out completely. Is there something I can do to fix this? Do I need a new screw or some kind of (anti) lubricant?
Answer: First thing I'd do is swap round - takeout the offending screw , and any other one, and see what happens. If the screw is worn, it will behave the same in its new home. Replace it ! If the problem is still in the same place on the saddle, it will be the female at that point.Full solution - new bridge, Temporary solution - which may become permanent - use Loctite, or PTFE tape (Plumbers' Tape For Everything), a white tape used on threads, which will tighten the screw by bulking the thread.
Another solution would be to re-tap the female with the next size up. Just poss., I guess, or buy a  re-threading system that makes a bigger thread and then puts a Helicoil in, bringing it back to original.There looks like just enough meat to do that.
Or - this might be the time to change it for a 5 string, as discussed previously...
I'd be surprised if one of these didn't do the job for you. Good luck.
Comment: Thanks for the excellent diagnostic tips! None of the other screws have this problem, so it's probably the screw or the saddle. I'll check it out.
Comment: I'd second the loctite solution. If you have the guitar set up as you like it, a dot of glue will keep that saddle screw exactly where it is...forever.
Comment: Forever's a long time when you want to tweak the action ! But it will come free with persuasion.
Comment: An unusual solution that has worked for me. Imagine screwing a damaged thread. Difficult ! Damage it gently, and it'll tighten up enough - if you know what you're doing. Don't try this at home...
Comment: Finally got a chance to try this and it worked like a charm. Turned out that the saddle is good and the screw is loose. Wrapped it very lightly with thread tape and (after a little trial and error) it's snug now.
Comment: Glad it worked. Mechanically it's a good arrangement in that the part that is easier to replace is an inferior metal. Or at least that's what should be the case. New grub screws are readily available, and I suggest you have a couple in your gigbag.
Answer: Loctite might help. You pour a little bit on the thread (having undone it a bit 1st so that when you do the screw up again, the loctite is pulled into the thread) and is prevents things vibrating loose. People use it on cars and models a lot.
Loctite Homepage
Thread locking section
It allows you to undo the thread if you need to though. You can feel that it's locked up, then as you undo the nut/screw etc you feel it ping as it lets go (normally quite easily)
I'd advise trying a snmall amount at first - just enough to get the thread a bit wet. You don't what it locked to thight that you can't adjust anything !
You can buy it in most DIY shops or motor spares shops.
Answer: If you choose to use some loctite, you'll need to know a trick or so.  Ordinary acetone (fingernail polish remover) will soften the loctite up and you should be able to back the screw out and clean it up.  I had some red loctite on some bolts for a tractor rear end I had to pull back off, and I used the acetone trick.  It did remove the paint on the parts in that area, but the loctite let loose in about 10 minutes.  Be careful on your guitar's finish if you use acetone/fingernail polish remover.

Fix loose bridge saddle screw


Spring boot 2 war repacking

Question: I have a multi project decomposed with the pattern <feature>/<subfeature>/api and <feature>/<subfeature>/implemntation
I'm using spring-boot-gradle-plugin, in the previous version when the executable war was built the subprojects name jar was updated to reflect the hierarchy. Inside the war libs I had a featureA-subfeatureB-api.jar for example but in the original war I got multiples api.jar.
In spring boot 2, I didn't have the original war and the final war doesn't rewrite the jar names.
For the time being I will rename the folder structure (seems best to me).
Am I missing something else using the new bootWar task and gradle plugin i order to repackage the war as previous version ?
Update 1 :
I was not really clear. Sorry
My structure for project 'scooby' is
root
- application
- featureA
-- api
-- implementation
- featureB
-- api
-- implementation

Application is a Spring boot application and depends on all the others projects.
With spring-boot-gadle-plugin 1.5, when building the application project, the result was 2 wars (application-0.0.0.war and application-0.0.0.war.original).
Inside the original/WEB-INF/lib I had 2 api-0.0.0.jar and 2 implementation-0.0.0.jar
Inside the repackagedWar/WEB-INF/lib I had scooby.featureA.api-0.0.0.jar, scooby.featureA.implementation-0.0.0.jar and the same for featureB. It was nice :) It was like the baseName was updated by the plugin.
With the same structure and spring boot 2, I only have one war built with multiple api-0.0.0.jar inside it.
Today I renamed all my source folders to make them more explicit and make the Jar task use a correct name. I like this better but I was searching the root cause explanation :)
Update 2 :
I added 2 github repositories.

The first one (scooby/ spring boot 1.5.x) : email@example.com:humeurvagabonde/scooby.git
and the second one (scooby2/2.0-Snapshot) : firstname.lastname@example.com:humeurvagabonde/scooby2.git

With first one : gw clean build produces 2 wars and the jar are renamed but 1 api.jar is still present so I can have duplicate classes (oooh :'( ) ; the second one only 1 war and no renaming
Comment: Sorry, I don't understand your description of the behaviour that you were seeing or that you're seeing now. Can you provide a minimal example that illustrates both the old and new behaviour?
Comment: Thank you. I added 2 github repositories. The first one (scooby/ spring boot 1.5.x) : firstname.lastname@example.com:humeurvagabonde/scooby.git and the second one (scooby2/2.0-Snapshot) : email@example.com:humeurvagabonde/scooby2.git With first one : gw clean build produces 2 wars and the jar are renamed but 1 api.jar is still present so I can have duplicate classes (oooh :'( ) ; the second one only 1 war and no renaming.
Answer: no connect: git clone email@example.com:humeurvagabonde/scooby2.git
Cloning into 'scooby2'...
The authenticity of host 'github.com (220.127.116.11)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,18.104.22.168' (RSA) to the list of known hosts.
firstname.lastname@example.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

Spring boot 2 war repacking


How to make an abstract Haystack SearchIndex class

Question: How do you make an abstract SearchIndex class, similar to how Django lets you make abstract base models?
I have several SearchIndexes that I'd like to give the same basic fields (object_id, timestamp, importance, etc). Currently, I'm duplicating all this code, so I'm trying to create a "BaseIndex" and simply have all the real index classes inherit from this.
I'm tried:
class BaseIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    object_id = indexes.IntegerField()
    timestamp = indexes.DateTimeField()

    class Meta:
        abstract = True

class PersonIndex(BaseIndex):
    ...other fields...

but this gives me the error:
NotImplementedError: You must provide a 'model' method for the '<myapp.search_indexes.BaseIndex object at 0x18a7328>' index.

so I then tried:
class BaseIndex(object):
    text = indexes.CharField(document=True, use_template=True)
    object_id = indexes.IntegerField()
    timestamp = indexes.DateTimeField()

class PersonIndex(BaseIndex, indexes.SearchIndex, indexes.Indexable):
    first_name = indexes.CharField()
    middle_name = indexes.CharField()
    last_name = indexes.CharField()

but these gives me error:
SearchFieldError: The index 'PersonIndex' must have one (and only one) SearchField with document=True.

How do I inherit from a custom SearchIndex subclass?
Comment: A [search indexes `Meta` class](http://django-haystack.readthedocs.org/en/latest/searchindex_api.html#modelsearchindex) doesn't have an attribute `abstract`... Don't know where you got that from?
Answer: Just don't include indexes.Indexable as a parent on anything you don't want indexing.
So modifying your first example.
class BaseIndex(indexes.SearchIndex):
    text = indexes.CharField(document=True, use_template=True)
    object_id = indexes.IntegerField()
    timestamp = indexes.DateTimeField()

    class Meta:
        abstract = True

class PersonIndex(BaseIndex, indexes.Indexable):
    ...other fields...

Comment: actually, that's for django models, for Indexes it doesn't seem to work, I probably just copied it from the question.
Comment: This worked for me. I do not believe you need the `class Meta: abstract = True` bit for it to work.
Comment: `abstract = True` is useful if you want to stop other developers trying to use your class directly.
Comment: Sorry, I should have included that in my comment that it's not necessary for haystack indexes. But the answer helped me regardless. Thanks!
Answer: class BaseIndex(indexes.SearchIndex):
    model=None

    text = indexes.CharField(document=True, use_template=True)
    object_id = indexes.IntegerField()
    timestamp = indexes.DateTimeField()

    def get_model(self):
        return self.model

class PersonIndex(BaseIndex, indexes.Indexable):
    first_name = indexes.CharField()
    middle_name = indexes.CharField()
    last_name = indexes.CharField()

    def get_model(self):
        return Person


SVN configuration problem

Question: Configured the SVN with httpd service including below modules but it gives an error as below:
LoadModule dav_svn_module     /usr/lib/httpd/modules/mod_dav_svn.so
LoadModule authz_svn_module   /usr/lib/httpd/modules/mod_authz_svn.so

error:
Starting httpd: httpd: Syntax error on line 206 of /etc/httpd/conf/httpd.conf:
Cannot load /usr/lib/httpd/modules/mod_dav_svn.so into server:
/usr/lib/httpd/modules/mod_dav_svn.so: undefined symbol:
svn_mergeinfo__remove_prefix_from_catalog

Server version:
Apache/2.2.3 Server built: Nov 12 2008 07:09:27 RHEL 5.4 - 32 bit

How would you troubleshoot this error message?
Comment: change your apache version to 2.0
Answer: This is usually associated with older versions of the libsvn present on your server: see this thread.

Could it be that you still have an older version of the Subversion libraries somewhere?
  If so, remove them. mod_dav_svn may be trying to link with the wrong version.
This is assuming that you did update /usr/local/apache/modules/mod_dav_svn.so with the new one.
  Otherwise, it could be that mod_dav_svn is the old part and it's having trouble linking with the newer Subversion libraries.

You find the same upgrade advice in this bug report.

SVN configuration problem


How did John Lennon tune his guitar

Question: From the Wikipedia page on the quarrymen: The Quarrymen.

Lennon's mother, Julia Lennon, taught her son to play the banjo and then showed Lennon and Eric Griffiths how to tune their guitars in a similar way to the banjo, and taught them simple chords and songs.

My question is how did he tune and did he do so with the Beatles as well?
Comment: It's more common to tune a banjo like the top strings of a guitar!
Comment: Unverified sources on the internet suggest that he initially used only 5 strings on his guitar and tuned it like a banjo (probably open-G), but that all but a handful of Beatles songs (such as Dear Prudence) were recorded using standard tuning.
Answer: "tuning the guitars a similar way to the banjo" is a reference to open tuning, usually open G.
This was relatively common in Blues and American old time music (from which skiffle was largely derived), and it's easy to play some basic chords for beginners on it too (easier to "get going", so to speak, whereas with standard tuning it's much easier to make some quite cacophonous sounds if your left hand isn't yet up to scratch)
Answer: I've heard that Julia was the first to teach a few chords to John, but I've also read the when George joined the band, John stood onstage with his guitar, only faking his playing, and that George was the person who really taught John to play. The only person still living that might be able to set the record straight is probably Paul.
Comment: The question surely is more about the actual tuning notes rather than who taught whom.
Comment: @Tim- I suppose I should have been a little more precise in my answer. Perhaps Julia taught John to tune like a banjo, and then George came along and taught him standard tuning and open tunings since that was Georges area of expertise. That's the point I was trying to get across, I hope I have a little better success this time.
Comment: Speaking of faking the playing, the first audible playing by John appears on 'All my Loving'. Before that I really cannot hear a note he plays.
Comment: @user207421- That's what I call pulling something apart to look at it!  I've listened to a lot of Beatles, but I never pulled any of it apart like that. I'll have to try it sometime to see if I like it.
Answer: Lennon's mom taught him a few banjo chords ..He tuned his gtr like a banjo..When G. Harrison saw him play..he said "What are you doing w 5 strings" from that point George came to the rescue and straightened his ass out..The advantage of JL's position as ryth gtr player shows on "All My Loving" and "Dear Prudence" George and Paul envied JLs finger picking techniques..And
"Revolution" is another example how JL killed no matter how he tuned..Yeah The Beatles taught each other no doubt..and Paul was a workaholic..They were great together..and just regular apart.
Comment: Please use full words. Do you have any citations for this?
Answer: What's interesting, John Lennon purposely tuned the D string low on his guitar making it "slightly out of tune" in order to make it recognizable on mono recordings from the other Beatles. He did the same on a few occasions when he played live on his 1961 Hofner bass.
You can hear it on the video below:
John Lennon Out Of Tune

How did John Lennon tune his guitar


Why does a Cm13 chord use A instead of A♭?

Question: Why is the 13th (or the 6th) of a Cm chord A, not Ab?
Comment: The 6th note of of Cm scale is Ab rather than G#, but see my answer below.I bet you're a guitarist !!
Comment: Apart from anything else, C minor with an Ab doesn't usually sound that great in some voicings, due to the semitone between the G and Ab.
Comment: If you don't like either the sound or the concept, use Ab, omit the G, emphasize the Bb and support the Ab with Db. Gives you an interesting sound.
Answer: When a 13th is written in a chord name, this always refers to the major 13th, which is the same as a major 6th - in this case an A natural. This is one of the conventions of how chords symbols are written. It may seem a little odd that the 6th or 13th of a minor chord is major, but there are a number of situations like this. For instance, 7ths are always flattened (minor) sevenths, when only a "7" is written, whether this is on a major or minor chord; if you want a major 7th, you have to write "maj7". (You're probably familiar with this, and wouldn't even think twice about it.)
This is simply the way these chords are written.
But, this has advantages; it means that we always know what interval a 13th (or 7th or 9th or anything else) is going to add to a chord, no matter what the other notes of the chord are. In particular, we know what interval to add even if the tonality or modality of surrounding chords, other parts of the chord itself, or written parts (eg. bass line or melody), might suggest a different interval.
I can see two reasons why you might think a Cm13 chord has an Ab; let me deal with both:

The key signature of C minor and the C Natural Minor Scale (Aeolian) have a flattened sixth degree (Ab). Yes, but there are minor modes/scales on C (with a minor triad on the root note, i.e. chord I is Cm) which have MAJOR sixths: C Dorian and C Melodic Minor Ascending are two obvious ones. Tim mentioned these already.
It might also be possible that you were reading C…m13 rather than Cm…13, in other words, a C chord with a minor 13th. This would be a completely different chord, and, although we do talk about minor 13th intervals, these would be notated in a chord symbol as b13 (i.e. a flattened 13th - Ab).

Lastly, it is worth mentioning where this misunderstanding arises; through trying to work out what intervals are in a chord by using a supposed mode/scale containing these notes, rather than choosing a mode to use which fits the chords (the harmony). The second way is how we actually play. The chord symbols tell us exactly which notes the composer wants in the harmony at any particular point in a piece/song, we then choose a mode for improvisation or creating a melody, bass or harmony line to fit the chord, not the other way around. For instance, Cm13 suggests the notes C Eb G Bb D (F) A (as a 13th chord is built using tertian harmony - sorry if you don't know anything about that yet!), this in turn would suggest that C Dorian would be a good scale to use with it.
To sum up. When reading a chord, don't worry about the key the piece/song is in, and which mode or scale this might suggest, or the character of the surrounding harmony. The chord you are reading might not relate closely to these anyway! Instead, follow some simple conventions for working out what the intervals in that chord are. The following intervals are presumed to be major unless adjusted with a flat or sharp: 2, 6, 9, 13. (Be aware, though, that the flat or sharp adjustment is relative to the major interval - eg. a 6 on E is G#, so a b6 is G natural!) Thirds are notated in the first bit of the chord itself: so C something-or-other is major, with a major third; Cm something-or-other is minor, with a minor third. Fourths, fifths and 11ths are presumed to be perfect unless adjusted. 7ths are the weird ones; they are presumed to be flattened (minor) unless marked as major - this is because the most common use of 7th chords traditionally is on dominant chords, and 7ths on dominant chords are minor - again, this is a whole other area of discussion and probably merits some study too (this post is useful, but there is also loads on the web…)
You should probably read up on how tertian harmony works, to fully understand which notes you usually put in 9th, 11th and 13th chords, and which ones can be safely left out (very important for guitarists!)
Answer: This is one of the weird bits with chords. With a maj.6 on C, it's C E G A. With a min.6 on C it's C Eb G A. It's the chord that's minor, not the 6th interval.The minor 6th interval is Ab rather than G# anyway. So for 6th or 13th, which is effectively and in reality the same note - possibly different octave - seems to depend on one's persuasion - its going to be A natural.It would never have been G in any case, as G is the 5th or 12th , and that is in the original triad.
On the subject of notes in scales, in the melodic minor,(classical) ascending, the 6th note IS A natural.
Comment: I still dont get it, why we´re using A rather than Ab? The 6th of C minor is Ab, not A. – What does mean "classical" btw?
Comment: Sorry about that ! Guitarists ( I play as well) tend to use # rather than b for naming notes.The guitar is what I call a 'sharp' instrument, as opposed to something like saxes, which I call 'flat'. Trouble is, notes need to be named from their roots - as in, the note we discuss was A, moved to Ab, rather than G, moved to G#.
Comment: It's also a practical thing. The notes C Eb G Ab don't sound like any kind of minor chord, because they would most simply be interpreted as a Major 7th chord in first inversion (Ab C Eb G, with the C at the bottom).
Comment: How did you know I play the guitar!? (=   Does it mean we dont use the diatonic minor scale when it comes to a Cm13?
Comment: Nope, we all use the same scales (ish), but us guitarists just think a bit differently…!
Comment: @Bob - I play guitar as well, but sometimes, when a note is written on a stave, it needs to be in the correct place for non guitarists ,as well, to understand it!
Comment: Hey, Tim, don't misunderstand me - I'm completely with you on everything in your answer, hence the +1...
Comment: It's more down to how it sounds than the technicality, try playing C Eb G Ab, or if you're talking Cm13, POSSIBLY using C Eb G Bb D (F) Ab. It just doesn't sound good - even to a jazzer.I've already said that the 6th (13th) of Cm is A if we consider C melodic ascending, which contains A natural, so this is the 6th (13th) note anyway.     The old melodic minor notes use slightly different ones from the newer jazz melodic. It's readily available in 'Google'.
Comment: Ok... but, there is no Bb in the C melodic ascending... I have to investigate about the C melodic "ascending" (and descending) thats new for me.
Comment: I'm writing you an answer to clear all this stuff up - you don't need to consider the mode or scale you are using when reading a chord symbol...
Comment: Now I'm befuddled ! Simple thing is, a min. 6th chord will always have 1, b3, 5 and maj.6 in it.13th chords , as discussed in an earlier thread, will be a basic triad plus b7 plus maj6. I hope !!
Comment: Well, almost, but the 13th implies a 9th and 11th too (tertian harmony) - but 11ths can generally be missed out in 13th chords. So, R b3 5 b7 9 13 (C Eb G Bb D A). Cm6 is C Eb G A; Cm6/7 is C Eb G Bb A.
Comment: Whatever else, the A natural is there, not the Ab/G#.
Comment: YES! Boy could this page have been shorter!
Comment: "The notes C Eb G Ab don't sound like any kind of minor chord" It might sound like Cm(b6). Not necessarily, sure, but that's true for a lot of other kinds of chords. The X-files theme is basically an arpeggiated Am(b6). Does it sound like Fmaj7 to you?
Answer: This is not an exception or something illogical. There are many scales whose 1, 3, and 5 form a minor triad. Some of these have a major 6, some a minor 6. A C minor chord could, for example, appear in the key of B flat, where an A natural occurs in the key signature. People reading chord symbols want to be able to connect the symbol with a specific chord, so we use specific rules about what the symbols mean. The rule is that in a 13th chord, the 13 (6) is major.
There's the closely related notation Cm6. Note that if you interpreted Cm6 as having an Ab in it, you'd get C Eb G Ab, which would sound to most people like an Ab maj7 chord, not a C minor triad.
Answer: Let me add that the predetermined values of the numbers in chord notation (i.e. the qualifications of the intervals when the numbers appear alone) come from the interval qualifications that result from the dominant chord of the major scale, which is the first chord to which tensions are added if we follow the logic of tonal music. In the key of C major, the chord G13 would diatonically be G-B-D-F-A-C-E, which corresponds to: Root-Major 3rd-Perfect 5th-Minor 7th-Major 9th-Perfect 11th-Major 13th.
Answer: Because, in our system of triad-based chord naming, 7ths are minor but other  added intervals are major except when stated otherwise.   The 'm' in 'Cm13' refers to the basic triad, not to the 13th. And 'Borough' is pronounced 'burrer'.  Live with it.
And that's really all there is to say about it.  When chord-naming developed, no-one was thinking in terms of what scales might be played over them.
Answer: Just use the circle of fifths (i.e. even if you don't understand it.) and you wont go wrong; here's the formula.
For triads, 7th, 9th, 11th and 13th minor chords: choose your minor root note and then move 3 spaces counter clockwise to get the 3rd note then from that, move 4 more spaces but clockwise to get the 5th note, move 3 counter clockwise again to get the 7th, move 4 clockwise to get the 9th repeat this pattern for the 11th and 13th as well. I call it the 3 back 4 forward formula. Of course it differs slightly for major chords.
Comment: Goodness!  What a HARD way to do it!   Just know your major scales.
Comment: I don't know my major scales by head and counting TTSTTTS may take more time for me; yet with this formula I just need a circle of fifths diagram and count my way to any minor chord and its extensions whenever I want. This makes things way more easier and straightforward unless selling piano lessons is your business of course.
Comment: Don't get me wrong; knowing your music theory thoroughly is good, but to get things done so you can find time and earn money for learning later on; then this is one way to go about it.
Answer: You might think that Cm13 has an Ab. If you want to use a m13 with a flattened 13th it would be a mb13. Cmb13 or Cmm13 Will be C, Eb, G, Bb, D, F, Ab
Comment: May I ask why you copied the first paragraph of Laurence's answer?


Administrator verification for user role type

Question: Is it possible to add admin verification for specific user roles.  For instance, my site has three user roles, one of which would should get verified before gaining access to the content.  I realise there is an option " Visitors, but administrator approval is required" in the
people > administration tab, but this would be for all users.
I'm managing roles directly through Drupal 7 and not using any modules such as profile2.
Thank in advance,
Cheers,
Answer: For the record, the option you refer to ("Visitors, but administrator approval is required") is not for all users.  It only applies to the Anonymous user role, and means that the Anonymous user is allowed to register at the site (gaining the Authenticated user role), but only after the administrator has approved the registration.
The "standard" way of doing this in Drupal is to set up the site so that the "Anonymous" user role does not get access to the content you want to reserve for verified users.
Then, to gain access the anonymous user must 1) register; and 2) the administrator must approve the registration (using the option you refer to).
How would this model work for your site?
Answer: http://drupal.org/project/apply_for_role
The Apply for Role module allows users to apply for roles and allows role administrators to approve the role applications.
Maybe this module can help you
https://www.drupal.org/project/autoassignrole
Answer: An alternative would be the Registration Role With Approval, which sounds like it does exactly what you need it to. I've used it before with success.

This module lets administrator to select roles that will be available
  for selection on registration form. It also allows to select which
  roles needs admin approval.
During registration user will be presented with optional checkboxes
  where he can select a one or more of available roles. If role needs
  admin approval, user account will be blocked until approved by admin.
  Email will be sent to administrator (configurable) with roles that are
  requested and username of user who request it.

https://www.drupal.org/project/registration_role_with_approval


How can I make the coupon code field in commerce mandatory?

Question: Using D7 commerce coupon/discount modules. I need to make the coupon field mandatory. Every order needs a coupon code entered.
There is no standard "required" checkbox on the field and I tried using conditional fields module to no avail.
Comment: I'm not sure I understand. Does every order need to be accompanied by a Coupon code? As in, you can't order without a coupon code?

Or do you just want to make sure the coupon code field isn't blank when people hit the "Add coupon" button?
Comment: They always need to use a coupon code for every order.
Comment: Why use the coupon module at all? Could you not simply add a required field to the order type? Or are there all kinds of coupons with all kinds of discounts?
Comment: There are multiple affiliates that sell a product through their own systems that issue a user with a coupon code with varying levels of discounts. The coupons and amounts vary too much to go the route you mention. However a coupon code is required for all purchases.
Comment: I understand. I'll see if I can come up with something.
Comment: Sounds great. Thank you.
Comment: Can this be done with a hook_form_alter and marking that field required?
Answer: You must do this in a hook_form_FORM_ID_alter().
You wouldn't use hook_form_alter() unless you are checking on a dynamic form ID. In this case it's better to use hook_form_FORM_ID_alter().
The reason for this, is that hook_form_alter() is called on every form render and hook_form_FORM_ID_alter() is only called when that specific form is being rendered.
Add this code to your .module file to make the field required:
/**
 * Implements hook_form_FORM_ID_alter().
 */
function MY_MODULE_form_commerce_checkout_form_checkout_alter(&$form, &$form_state, $form_id) {
  if (!empty($form['commerce_coupon']['coupon_code'])) {
    $form['commerce_coupon']['coupon_code']['#required'] = TRUE;
  }
}

Comment: This is the better answer, due to the - justified - use of `hook_form_FORM_ID_alter`
Answer: You can do that by Implements hook_form_BASE_FORM_ID_alter but that would allow passing the step if the user enters any random string inside the coupon field.
To avoid this confusion you need to use the form alter to make coupon field required and also add custom validation to check if the coupon is valid.
if the coupon is not valid, then the user will stay in the step and will get the same error message provided by the commerce coupon module.
I assume your custom module name is 'CUSTOM'
/**
 * Implements hook_form_BASE_FORM_ID_alter().
 */
function CUSTOM_form_commerce_checkout_form_checkout_alter(&$form, &$form_state, $form_id) {
  if (!empty($form['commerce_coupon']['coupon_code'])) {
    // Set code as required.
    $form['commerce_coupon']['coupon_code']['#required'] = TRUE;
    $form['buttons']['continue']['#validate'][] = 'my_custom_coupon_validate';
  }
}

/**
 * Custom coupon validate.
 */
function my_custom_coupon_validate(&$form, &$form_state) {
  $code = $form_state['input']['commerce_coupon']['coupon_code'];
  $order = $form_state['order'];

    $coupon = commerce_coupon_redeem_coupon_code($code, $order, $error);
    if ($coupon) {
      // Reload the order so it is not out of date.
      $order = commerce_order_load($order->order_id);
      // Recalculate discounts.
      commerce_cart_order_refresh($order);
    }
    else {
      form_set_error('coupon_code',$error);
    }
}

Comment: Hook form alter isn't the preferred solution unless you are checking for dynamic form ID.
Comment: @Jdrupal thanks for suggesting that, I change the implementation.


Is there an input filter to add the class clearfix to all  tags?

Question: I have a lot of inline images in my content. Most of the time I want to have some sentences and an image grouped together. To get a nice layout I have to mannually add class="clearfix" to all
 tags. This is especially anoying because the class often gets lost when I edit the text in the wysiwyg editor.
Is there an input format, or some other easy way to do that automatically?
Answer: If you are trying to add the "clearfix" class to all of your paragraph tags, sitewide, it would probably be more simple to apply the "clearfix" properties to your "p" tag in your CSS files.
So you'd find:
.clearfix { ... }

and add in your paragraph tag like so:
.clearfix, p { ... }

Or copy the properties to your custom CSS file if you are worried about overwriting your changes.


Commerce Paypal Order for Goods and Services

Question: I'm helping a non-profit set up an order page on their website that would allow users to order physical products. I have commerce integrated with their paypal account and I can successfully collect order information with a webform and process their payment with paypal.
The client, however, wants to be able to print a shipping label for that order directly from paypal. As far as I can tell, the only way the "Buy Shipping Label" option appears on paypal transactions is if the order's payment type is marked as "Goods and Services."
Is there a way to specify the payment type within the commerce module? The payments that I'm collecting now all show up in paypal with "Checkout" as the payment type.
The modules I'm using for this setup include, webform_product (3.0.4), commerce_paypal (8.x-1.4), and commerce (8.x-2.36) along with its related modules (cart, checkout, number pattern, order, payment, price, product, and store).
Answer: For anyone else who runs into this issue, I found a few lines in the commerce_paypal module code that reference the shipping module. Apparently, the presence of this module affects how a payment is sent to paypal. The code is in: commerce_paypal/src/Plugin/Commerce/PaymentGateway/ExpressCheckout.php starting on line 509.
After enabling this module, all the payments I sent to paypal were marked as goods and services and I was able to print a shipping label directly from paypal.  I don't ~think~ I did any other configuration to make this happen althought I was testing with the checkout flow the module added titled "shipping" but I didn't end up using that flow.  Regardless, hope this helps someone.


Test whether each function is continuous at the given point. If the function is not continuous, state the type of discontinuity.

Question: Just need a little help with this assignment I'm working on.
Thank you! =)
Just a couple of examples of the questions:
$f(x) = \frac{x+3}{x^2 - 6x + 8 } $ At X = 2
$f(x) = \frac{2x^2 + 7x - 15}{x^2 + 6x + 5} $ At X = -5
Comment: What did you try?
Answer: $x^2 - 6x + 8 =(x-2)(x-4)=0$ so
$f(x) = \frac{x+3}{x^2 - 6x + 8 } $ in $\mathbb{R}-\{2,4\}$ is continuous.
$x^2 + 6x + 5=(x+2)(x+3)=0$ so
$f(x) = \frac{2x^2 + 7x - 15}{x^2 + 6x + 5} $ in $\mathbb{R}-\{-3,-5\}$ is continuous.
Comment: welcome dear :)


Is Cross Validation Used More in Machine Learning Models Compared to Regression Models?

Question: Something I have been noticing lately, is that Machine Learning practitioners appear to be talking more about Cross Validation a lot more than those working with traditional statistical models (e.g. Regression).
For example, in almost any Machine Learning paper, the results section usually contains an extensive Cross Validation section where the Machine Learning models (e.g. Random Forest, Gradient Boosting, Neural Networks) are evaluated against testing and validation sets. As a matter of fact, emerging and key concepts in Machine Learning such as "Double Descent" (e.g. https://openai.com/blog/deep-double-descent/) are rooted in the milieu of Cross Validation.
On the other hand, I don't see Cross Validation being used as extensively in Statistics papers (e.g. within Epidemiology). In many papers, I see that the researchers might fit a Regression model to their data - and then report on the quality of the "model fit" and the statistical significance of the regression coefficients; but they do not seem to be engaging in Cross Validation as such (i.e. building their model on a random subset of the data).
I have researchers make arguments that modern Cross Validation has its roots purely in Statistics. The theoretical framework of Cross Validation is largely borrowed from concepts such as Bootstrap Sampling in which we assert that statistics calculated on multiple random samples from a population can converge to the true value of this statistics.
However, I am still not sure as to why Cross Validation appears to be more popular in Machine Learning compared to Statistics. How exactly would Cross Validation be used to test if the "statistical significance and impact of covariate predictors on the response variable are similar on the training data vs. the test data?
Can someone please comment on this?
Comment: What is statistics, what is machine learning, and what is the border between the two? I do not see how to answer this question without first answering those.
Comment: The answer is No. Cross-validation is extensively used in Statistics and statistical literature. See for a review [A survey of cross-validation procedures for model selection](https://hal.archives-ouvertes.fr/hal-00407906/document).
Comment: Your last edit raised an interesting question but really belongs as a separate question. I have rolled back the edit. The history is there, however, if you want to copy and paste your verbatim phrasing into a new question.
Comment: @ Dave: thank you! how do I view the history?
Comment: Click the "edited" above the username of the last member to edit the post. For other administrative details like this, you might want to take the site tour or ask on [Meta](https://stats.meta.stackexchange.com).
Comment: Thank you for this suggestion!
Comment: @ Dave: I just posted it here: https://stats.stackexchange.com/questions/597895/cross-validating-inference-models
Comment: @ Dave: thank you for your comment! I guess the distinction I was making was between specifically "Regression Models" (Statistics) vs models such as Random Forest, Gradient Boosting, Neural Networks. I agree - the border between statistics and machine learning is often described as blurry (e.g. we could argue that a regression model is trying to "learn" optimal parameters based on a dataset - and that in machine learning we want a model that we "statistically believe" will generalize well to unseen data).
Answer: Cross-validation is a tool for assessing prediction performance. It applies equally well to any type of model, but perhaps is even more obviously needed for models with hyperparameters that need tuning (e.g. RF, GBDT, NNs etc.), while fitting a statistical model via maximum likelihood may seem to not have tunable hyperparameters (but you can of course apply penalization etc.).
If you do inference such as answering a question on whether a treatment compared with placebo improves blood pressure based on a randomized trial using a pre-specified regression analysis model, there's usually no point in doing cross-validation. There's no hyperparameters to choose and the predictive capability of the model is not really per-se of interest.
There's of course areas that lie between these two cases, where the answer is not so clear and where mixtures of approaches may be appropriate.
Note: As an aside, by most definitions of "machine learning" any regression model is a form of machine learning.


Multiple testing correction on non-normal data with dependent tests

Question: I have 8 continuous variables in a small sample (n=10)
with mostly a non-normal distribution.
I perform 4 Wilcoxon signed-rank tests on the 4 variable pairs.
The variables are strongly dependent across pairs.
I was wandering which correction of multiple comparison I should apply as the Bonferroni & Dunn procedures seem to be too conservative taking the dependence of variables into account.
Thanks a lot for your ideas!
Answer: First of all, Bonferroni correction is just one of the many methods (perhaps the most famous and conservative one) proposed for controlling family-wise error rate (FWER). Be sure to read more about other methods in the Wikipedia page for FWER
If you are fine with the Wilcoxon singed-rank test (given its assumptions and what it looks for) - read the Wikipedia page for singed-rank test, you could perform permutation given the small sample size that you have. You can perform as many permutations as you want to get a good sense of your null distribution.


Docker e Nodejs

Question: Tenho uma aplicação em NodeJs e preciso configurar a arquitetura dessa aplicação, sou novo com Docker e preciso criar alguns containers para essa aplicação, a aplicação deve ter a seguinte configuração:

-- Container 1 - Funciona como um balanceador de carga;
-- Containers 2,3,4  - Instâncias da Aplicação;
-- Container 5 - Banco de dados (Mysql);

OBS: Possivelmente essa arquitetura irá receber mais um container para funcionar como um proxy reverso;
Gostaria de saber se isso é possível e se sim como fazer o deploy desta aplicação depois ?
Answer: Dê uma olhada no Docker Compose!
O Docker Compose é a ferramenta nativa do Docker para lidar com aplicativos que usam múltiplos containers.
Basicamente, você especifica um arquivo 'docker-compose.yml', que identifica quais são os serviços disponibilizados e como eles se relacionam.
Depois é só rodar um comando docker-compose up e ele se encarrega de subir os containers necessários.
Comment: Uma arquitetura em microserviços implica em outros desafios. O docker compose pode ser usado, mas seria necessário usar tecnologias complementares. Por exemplo, o [Docker Swarm](https://docs.docker.com/swarm/overview/) para controle de cluster, [Consul](https://www.consul.io/) para descobrimento e health checking dos serviços. Em suma: é viável, mas é um desafio bem maior.
Comment: Embora este link possa responder à pergunta, é melhor incluir as partes essenciais da resposta aqui e fornecer o link para referência.  As respostas apenas por link podem ser invalidadas se a página com o link for alterada. - [From Review](/review/low-quality-posts/86379)
Comment: @KennyRafael faz sentido, obrigado pelo correção!
Comment: Eu dei uma olha no docker composer e parece satisfatório no entanto me surgiu uma dúvida, futuramente essa arquitetura vai crescer e se tornar  microserviços que possivelmente estarão em hosts diferentes ainda sim o dokcer composer atenderá minhas necessidades ?

Docker e Nodejs


Moderation analysis with non-significant main effects but significant interaction

Question: I am doing a simple moderation analysis with one independent variable (IV), one moderator (M) and one dependent variable (DV).
Results indicate that a regression model containing both main effects (of IV and M) is non-significant.
After adding the interaction term of IVxM to the previous model, the new model remains non-significant.
However, the R-squared change IS significant, so the second model accounts for a significantly higher amount of the DV than model 1.
My question is:
Under these conditions, can we speak of having a moderation here?
After all, the main effects are non-significant and I believe to remember that my statistic prof told me a moderation only occurs if the model in general and both main effects are significant...
By the way, it seems as if my main effects are non-significant due to a cross-over interaction.
However, I am not sure how to find out if this cross-over interaction is significant (in SPSS). Does this also have to do with the R-squared change value?
Answer: Unless you have a large number of subjects AND the estimate effect sizes are meaningful for your domain AND you have a solid theory that would explain why this could happen (preferably not one made up after seeing data), I would not read to much into such result.
Remember, that The Difference Between "Significant" and "Not Significant" is not Itself Statistically Significant http://www.stat.columbia.edu/~gelman/research/published/signif4.pdf
Also, as an approximation, if you $N$ subjects to estimate main effect reliably, you need roughly $16 \times N$ subjects to estimate interactions reliably.


How to modify default login page using theme?

Question: Version: Drupal 8.7.x
Currently, I am using a subtheme of the Bootstrap theme and I want to override the default login page because the interface doesn't look good. I was hoping to override the template file in Bootstrap theme responsible for login but there was no file with familiar name in the theme folder. Maybe Bootstrap inherited the login file as well? Then I created a file named page--user--login.html.twig and put that in my subtheme folder but there was no change in the login page. Maybe the file name is supposed to be different or it is something else entirely.
Comment: Yes, I was using the same file name but as Stanley pointed out, you can check the filename by setting debug: true in services.yml. In my case the file I needed to create was page--login.html.twig
Comment: page--user--login.html.twig should work. The file should be located in `my_theme/templates/page--user--login.html.twig` - and make sure you clear the cache too.
Answer: Go to

web/sites/default/services.yml

and change the debug value from false to true
<code>debug: true
</code>

You will get file name suggestions like shown in the image, u should use the same names.
Also, was your sub-theme succesfully installed?
Is the sub-theme under this path ? `

themes/custom/myproject_bootstrap_subtheme

`
Comment: Thank you so much.Yes my theme was working but the file name was wrong. In my case it was page--login.html.twig instead of page--user-login.html.twig. I checked the source code after doing debug: true as you instructed. Then I changed to appropriate filename


Paper.js Mouseup Event Inhibited by Tool

Question: I'm using Paper.js and I need to do something on mouseup on a raster. However the event does not seem to fire when I use the global tool space.
Note this sketch, where clicking and dragging yields a log something like this:

raster mousedown
raster mousedrag
... [more "raster mousedrag"] ...
raster mousedrag
raster mouseup

indicating the raster.on('mouseup' function() {...}); was hit properly, as expected.
However, in this sketch, which contains functionality for displaying the dragged area, the raster.on('mouseup' function() {...}); is not hit properly. Note that the log does not contain "raster mouseup", only "raster mousedown" and "raster mousedrag".
Why in the second instance does mouseup not fire on the raster? How can I adjust the code in the second sketch so that it does fire?
Comment: I ended up opening an issue on github because of a problem I saw when playing with this - if you use view.on('drag', ...) then the rectangle's .removeOn function is not called. Mouse handling in paper could probably use a bit of an overhaul. I typically use only two types of handlers - a global tool handler and then, if needed, specific handlers for path.removeOn(...) if needed.
Comment: This is going to be fixed in paperjs but Júrg provided a clean workaround: set the red rectangle to be a guide. See the sketch in his comment here: https://github.com/paperjs/paper.js/issues/842#issuecomment-166155595
Answer: Well, the simple answer is that the problem is that the on('mouseup', ...) handler is never called. The paper code gets the most recent hit, i.e., the red rectangle you're drawing, and checks to see if that responds to the 'mouseup' event. It doesn't. Then it checks the parent chain and the parent of the red rectangle is the layer, so it doesn't pass the .responds test either. Because the raster is at the same level as the red rectangle handlers associated with the raster are never called.
The simplest answer is to install the handlers on the view, not the raster, by using the global tool, e.g.,
function onMouseUp(event) {
    console.log('vup');
}

See the paperjs code (in CanvasView.js):
function callEvent(view, type, event, point, target, lastPoint) {
    var item = target,
        mouseEvent;

    function call(obj) {
        if (obj.responds(type)) {
            if (!mouseEvent) {
                mouseEvent = new MouseEvent(type, event, point, target,
                        lastPoint ? point.subtract(lastPoint) : null);
            }
            if (obj.emit(type, mouseEvent) && mouseEvent.isStopped) {
                event.preventDefault();
                return true;
            }
        }
    }

    while (item) {
        if (call(item))
            return true;
        item = item.getParent();
    }
    if (call(view))
        return true;
    return false;
}


How to force a cron run after a Rules component is scheduled?

Question: This question is a sequel on Why is the database not updated before a next Rule is launched?. I have a Rule that schedules a Rules component 5 seconds after the current time (this number is arbitrarily chosen). Since this component uses information from a frequently changing View, it should be executed as soon as possible. However, in my current configuration, that only happens when cron is run; which takes place once in an hour.
Can I somehow force a cron run (eventually with Rules) when the Rules component is scheduled?
Comment: The best I can think of for implementing a Rules Action to for cron to run, is to create your own custom Rules Action, in which you invoke [drupal_cron_run](https://api.drupal.org/api/drupal/includes!common.inc/function/drupal_cron_run/7.x)
Comment: @Pierre.Vriens: That sounds like a great idea to me if that is easier/better for performance than using another module like Elysia Cron or Ultimate Cron.
Comment: Now you make me doubt if I should write that down as an actual answer ...
Comment: @Pierre.Vriens: Haha, you are the expert here, so the decision is yours. I am new to cron and stuff, so I don't really know what the best practices are or what the drawbacks of a frequently running cron are.
Comment: I'd be interested in an answer that doesn't involve a custom Rules Action, I can't imagine nobody ever had a similar requirement. Maybe somebody like @NiallMurphy might come up with an interesting solution ...
Comment: Or otherwise @rooby ??? PS: If you're in a hurry and want to give such custom Rules Action a try, you may want to look at [this answer](http://drupal.stackexchange.com/questions/166023/how-to-adjust-prices-depending-on-quantity-and-attributes-using-drupal-commerce/166026#166026) for a basic getting started with custom Rules Events / Conditions / Actions ...
Answer: you can give this module a try , it makes it possible to run cron via configurable rules
Ultimate cron
Comment: I'd be interested how to "configure" those "rules", using this module, so that cron is triggered "when the Rules component is scheduled" (as in the question.


Pontuação de boliche em C;

Question: Sou iniciante em C e estou tendo problemas em um exercício, não consigo ver uma forma de solucioná-lo.
Seguinte:
Em cada etapa o jogador dispõe de 2 bolas com as quais deve derrubar 10 pinos. A etapa termina quando: o jogador derrubar os 10 pinos ou o jogador usar as 2 bolas.
i = bola1;
j = bola2;

pontuação
    1 – STRIKE   se i = 10 (a 2a bola não é usada);
    2 – SPARE    se i < 10, mas  i + j = 10;
    3 – MISS       se i + j < 10;
Valor pontuação
STRIKE - 10 + números de pinos que o jogador derrubar com as duas bolas  seguintes.
SPARE - 10 + número de pinos derrubados com a próxima bola
MISS - i + j

a) Leia uma seqüência de números inteiros que descreve  um jogo completo. O i-ésimo termo da sequência é o número de pinos derrubados pela i-ésima bola. Qual será o tamanho máximo da seqüência?
b) Identifique a quantidade de pinos derrubados por cada etapa e classifique como STRIKE, SPARE ou MISS.
c) Calcule o número de pontos por etapa
d) Calcule o total de pontos no jogo
e) Imprima os resultados

Numero de exemplo;
    1o jogo: 10, 9, 1, 6, 3, 7, 0, 8, 2, 0, 8, 2, 0, 8, 2, 0, 8, 1, 0, 9, 1;
    2o jogo: 9, 1, 0, 10, 10, 10, 6, 2, 7, 3, 8, 2, 10, 9, 0, 9, 1, 2;
    3o jogo: 10, 9, 0, 8, 2, 10, 10, 7, 3, 4, 6, 10, 9, 1, 10, 7, 3;

Bom, tentei usar um for pra verificar o valor de cada posição do vetor, até aí tudo bem, meu problema é para comparar os dois próximos valores caso o primeiro não seja um Strike.
main() {
    int game1[20] = {10, 9, 1, 6, 3, 7, 0, 8, 2, 0, 8, 2, 0, 8, 2, 0, 8, 10, 9, 1};
    int game2[18] = {9, 1, 0, 10, 10, 10, 6, 2, 7, 3, 8, 2, 10, 9, 0, 9, 1, 2};
    int game3[17] = {10, 9, 0, 8, 2, 10, 10, 7, 3, 4, 6, 10, 9, 1, 10, 7, 3};
    int i, j;

    for(i=0; i<20; i++) {
        for(j=0; j<20; j++) {
            if(game1[i] == 10) {
                printf("Strike");
            }
        }
    }
}

Esse é o código que comecei a fazer, porém minha duvida é mais na parte logica, como comparar o valor de i e j para saber se é um Strike, Spare ou Miss;
Comment: Edite sua pergunta e poste o código que você já tentou para o pessoal poder te ajudar, ;)
Comment: editado, valeu ^^
Comment: Não vejo para que usar 2 for, basta 1 e seguir sua lógica: se game1[i] = 10 então é strike, senão se game1[i] + game1[i+1] = 10 então é spare, e assim vai. Só tem de se atentar ao game1[i + 1], pois este vai estourar o vetor quando tiver no final, então tens de veriricar.
Comment: tentei do jeito que voce disse luiz henrique, ate funcionou, porem, por exemplo, depois de comparar o primeiro 10, ele passa pra comparar o 9 com o 1, e depois o 1 com o 6. Sendo que apos comparar o 9 com o 1 ele compare o 6 com o 3 respectivamente. Nao sei se deu pra entender. Mas sua resposta ja me deu uma boa luz aqui. Obrigado ^^
Answer: Para que ele ande mais que uma casa basta incrementar o i quando não for "STRIKE".
#include <stdio.h>
#define JOGADAS 20

int main(void) {
    int game1[JOGADAS] = {10, 9, 1, 6, 3, 7, 0, 8, 2, 0, 8, 2, 0, 8, 2, 0, 8, 10, 9, 1};
    //int game2[18] = {9, 1, 0, 10, 10, 10, 6, 2, 7, 3, 8, 2, 10, 9, 0, 9, 1, 2};
    //int game3[17] = {10, 9, 0, 8, 2, 10, 10, 7, 3, 4, 6, 10, 9, 1, 10, 7, 3};
    int i;

    for(i=0; i<JOGADAS; i++) {
        if(game1[i] == 10) {
            printf("STRIKE\n");
        }
        else if (game1[i]+game1[i+1] == 10) {
            printf("SPARE\n");
            i++; //avança mais uma casa para o próximo jogo.
        }
        else {
            printf("MISS\n");
            i++; //avança mais uma casa para o próximo jogo.
        }

    }
    return 0;
}

Veja aqui a funcionar.
Comment: Cara, muito obrigado, alias, muito origado a todo mundo que ajudou. Deu certo aqui tambem, agora o restante do exercicio consigo fazer numa boa. ^^
Comment: @YutoSan Pelo que você está dizendo, parece ser o caso de [marcar uma resposta como aceita](http://meta.pt.stackoverflow.com/questions/1078/). Se tem uma resposta que realmente te ajudou, marque-a como aceita. Assim o conteúdo fica mais organizado e fácil de ser encontrado futuramente por outras pessoas com problemas parecidos.
Answer: Cara, você deveria rever a estrutura que você utilizou para guardar os dados de cada jogada. Da forma que os dados estão sendo guardados, você não consegue saber a que rodada a pontuação se refere a menos que você faça uma execução completa do algoritmo, o que o torna extremamente ineficiente (afinal guardar o resultado das jogadas serve exatamente para você não precisar fazer tudo de novo).
Recomendo que você crie uma estrutura personalizada, por exemplo:
struct rodada{
    int jogada1;
    int jogada2;
};

struct rodada game1[20];

Dessa forma a informação sobre o resultado da i-ésima jogada estará a apenas uma instrução de distância. Quer dizer, basta você fazer um resultado = game1[10].jogada1; para saber se foi um strike ou não. Não há necessidade de ler TODAS AS JOGADAS até a décima para obter uma informação tão simples.
Recomendo também definir algum valor inválido (como um "x" ou uma variável booleana) na segunda jogada para sinalizar que houve um strike na rodada.

Obs: Desculpe se houver algum erro no código, tem alguns anos que não programo em C.

Obs2: Você também poderia adicionar uma outra variável na struct para manter a pontuação parcial de cada rodada.

Pontuação de boliche em C;


How to provide /etc/aliases / .forward functionality in the current anti-spam environment?

Question: The actual problem I'm having:
My email server (exim, but it hardly matters for this), which I've been running for years, forwards email via /etc/aliases (i.e. email@example.com points to ~5 people) and individual user's .forward files (i.e. my .forward has "email@example.com").  This has been problematic off and on for years, with various services refusing to accept mail for various periods, but recently gmail has gotten very serious about just refusing these mails.
I have DKIM, SPF and DMARC setup, but DMARC doesn't apply for these forwarded emails.  The only thing I'm doing against best practices is that my IP's reverse DNS points to 50-250-232-19-static.hfc.comcastbusiness.net., which is certainly not great.  I'm skeptical that just fixing that would solve this, though.
I've started passing the mail from the actual domains I control though a service (smtp2go, but again I don't think it matters), but they will only accept mail that is actually from my domains.
I think at this point, forwarding in the traditional MTA sense just isn't really workable in the modern anti-spam landscape.
I could try moving all my mail handling to an external service (a friend uses purelyemail, for example), but the disruption to my users, some of whom use local maildir with like alpine and mutt, would be substantial, and I think I'd just be kicking the can down the road: maybe MTA-style forwarding via such a service would work for now, but some day it'd fail, I bet.
What I'm trying to figure out is what is the minimum I can do to get mail flowing without having to make huge changes to my entire setup.
These are the options I can think of:

Use a mail syncing tool (there seem to be several of them; OfflineIMAP, isync, imapsync, others; if anyone has one they prefer that would be extremely helpful) to just shove the mails from a local maildir directly into the user's IMAP account.  This is what I plan to do instead of my own .forward file, but that's not going to work for random board members, especially since as far as I know IMAP creds are all-or-nothing.

Have the MTA forward the mail but rewrite the sender to an address in my domain, so that DMARC works and so on.  In other words, forward like an MUA instead of an MTA, but at the MTA level.  Weirdly, I'm not seeing much info online on how to do this; I'm sure I could roll my own with procmail and formail, but I kind of expected this to be well solved.  There's some definite detail work there, like making the Reply-To correct and so on.  I know that mailman will do the correct kind of rewriting here, as I've configured it to do that for a mailing list, but that's about all I've found.

I would love to here about other possible solutions.  Failing that, I'm looking for specific advice on how to do either #1 or #2, as I expect to do a mixture of both.
Answer: The "solution" to deal with how traditional e-mail forwarding breaks SPF is SRS ; the Sender Rewriting Scheme.

SRS can be used to modify sender addresses when forwarding so that SPF verification does not object to them. It operates by encoding the original envelope sender in a new sender local part and using a domain run by the forwarding site as the new domain for the sender. Any DSN message should be returned to this new sender at the forwarding site, which can extract the original sender from the coded local part and forward the DSN to the originator.
This is a way of avoiding the breakage that SPF does to forwarding.

It is supported by exim: https://www.exim.org/exim-html-current/doc/html/spec_html/ch-dkim_spf_srs_and_dmarc.html and several other MTA's.
Comment: Ugh, gonna have to compile it myself.  :sadpanda:  You're right that that looks like the correct thing to do, though, I'll try it out.
Comment: No, standard SRS does not appear to help.  smtp2go (which is who I'm using to route outbound mail since gmail doesn't like my IP anymore) will only send stuff if it likes the *header* From address, which SRS doesn't appear to rewrite, and with SRS on *not* routed through smtp2go, gmail continues to just reject them.
Comment: However!, SRS rewriting the envelope *and* header From addresses seems to work fine, and gmail accepts it without forwarding it through smtp2go; possibly confusing for the end user, but replies *do* work so meh.
Answer: Comments break formatting, so here's how to rewrite the From header (as well as the envelope From) with SRS using Exim.
The docs at https://www.exim.org/exim-html-current/doc/html/spec_html/ch-dkim_spf_srs_and_dmarc.html have this:
  return_path =         ${srs_encode {SRS_SECRET} {$return_path} {$original_domain}}

Add this as the next line:
  headers_rewrite = *@* "$return_path" f

For better recipient experience what I actually ended up doing was:
  headers_add = X-Forwarded-For: $reply_address
  headers_add = Reply-To: $reply_address
  return_path =         ${srs_encode {SRS_SECRET} {$return_path} {$original_domain}}
  headers_rewrite = *@* "$return_path" f

That way, reply actually works without having to route back through my server, although if it does route back through my server it does work.


Prevent API Call During Rails Create in Seeds File

Question: I have a rails model that uses geokit that includes the line acts_as_mappable :auto_geocode=>true which calls something like before_validation :geocode_address, :on => :create. However, my issue is that I have a seeds file for my development database that calls th Rails model and then calls this on create, which calls an external API and fails when I'm not connected to the internet. What approaches are available to me?
It would be nice if the approach covered both this case and when I run my tests as well, but I already have a work around for the tests that isn't very pretty.
Answer: You could try something like this:
# /db/seeds.rb

ModelName.class_eval { acts_as_mappable(:auto_geocode => false) }

# Create seed models...

ModelName.class_eval { acts_as_mappable(:auto_geocode => true) }

This might even work,
ModelName.acts_as_mappable(:auto_geocode => false)

EDIT:
Another solution would be the skip_callback method:
ModelName.skip_callback(:validation, :before, :auto_geocode_address)

Comment: so I would put the first line at the top of my development.rb file and the last line at the bottom if that's what is called when I create the seed models? If so that didn't work. The problem, I believe, is that it hits the Model and is using the default value of true.
Comment: Put those lines of code at the top and bottom of your `seeds.rb` file, around the code that creates the models that you don't want to auto-geocode. I'll add the filename to the top of the code example.
Comment: It's still not working. I'll play around with this general idea.
Comment: Tried calling `acts_as_mappable` on agency like so: `agency.acts_as_mappable(:auto_geocode => false)` where agency is a local variable already setup. I get `undefined method `acts_as_mappable' for #`. I think opening up the class and modifying it is a good approach, not sure how to execute it though.
Comment: Try `Agency.acts_as_mappable(:auto_geocode => false)`. You would need to call `acts_as_mappable` on the model class, not an instance of the model.


Why is ln[E(x)] > E[ln(x)]?

Question: We're dealing with the lognormal distribution in a finance course and my textbook just states that this is true, which I find sort of frustrating as my maths background isn't very strong but I want the intuition. Can anyone show me why this is the case?
Comment: $\ln $ is a concave function. Look up Jensen inequality:  https://en.wikipedia.org/wiki/Jensen%27s_inequality
Comment: Already answered here:
https://math.stackexchange.com/questions/21063/difference-between-logarithm-of-an-expectation-value-and-expectation-value-of-a
Comment: Inathan: Oh sorry I didn't find that when I was looking.
Answer: Recall that $e^x\geq 1+x$
$E\left[e^{Y}\right]=e^{ E(Y)} E\left[e^{Y- E(Y)}\right]\geq  e^{E(Y)} E\left[1+{Y- E(Y)}\right] = e^{E(Y)}$
So $e^{E(Y)}\leq E\left[e^{Y}\right] $
Now letting $Y=\ln X$, we have:
$e^{E(\ln X)}\leq E\left[e^{\ln X}\right]=E(X)$
now take logs of both sides
$E[\ln (X)]\leq\ln[E(X)]$

Alternatively:
$\ln X = \ln X - \ln \mu+\ln\mu \qquad$   (where $\mu=E(X)$)
$\qquad= \ln(X/\mu)+\ln \mu $
$\qquad= \ln[ \frac{X-\mu}{\mu} + 1]+\ln \mu$
$\qquad \leq \frac{X-\mu}{\mu} + \ln \mu\qquad$ (since $\ln(t+1)\leq t$)
Now take expectations of both sides:
$E[\ln(X)] \leq \ln\mu$

An illustration (showing the connection to Jensen's inequality):
(Here the roles of X and Y are interchanged so that they match the plot axes; better planning would have swapped their roles above so the plot more directly matched the algebra.)

The solid coloured lines represent means on each axis.
As we see because the relationship "bends toward" $X$ in the middle  (and "away from" $Y$), the mean of $Y$ (orange horizontal line) goes along a little further before hitting the curve (giving the small gap (marked in blue) between log(mean(y)) and mean(log(y)) that we see).

Why is ln[E(x)] > E[ln(x)]?


S3 policy to allow by IP can't be changed

Question: We have an S3 bucket with website content in it that's served to the public through a proxy cache.  The access to the bucket is limited to the IPs used by the proxy.  This is all working fine.
New IPs were recently added to the proxy, but we're not able to add those to the policy.  Directly editing the policy gives a "permission denied" no matter what permissions the user has.  We discovered that we could work around this by temporarily unblocking public access to the bucket.  However, if we add new IPs, after re-blocking public access we discover that all requests are blocked.  If we revert the changes to the policy back to the original list of IPs then it goes back to working.
The policy is fairly basic and looks like this (edited for privacy):
{
    "Version": "2012-10-17",
    "Id": "my-bucket",
    "Statement": [
        {
            "Sid": "IPAllow",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:*",
            "Resource": "arn:aws:s3:::my-bucket/*",
            "Condition": {
                "IpAddress": {
                    "aws:SourceIp": [
                        "220.127.116.11/20",
                        "188.8.131.52/22",
                        "188.8.131.52/24",
                        "126.96.36.199/23",
                        "18.104.22.168/24",
                        "126.96.36.199/20",
                        "188.8.131.52/18",
                        "220.127.116.11/17",
                        "18.104.22.168/17",
                        "18.104.22.168/16",
                        "188.8.131.52/18",
                        "220.127.116.11/17",
                        "184.108.40.206/20",
                        "188.8.131.52/20",
                        "184.108.40.206/20",
                        "188.8.131.52/18",
                        "220.127.116.11/22",
                        "184.108.40.206/21",
                        "220.127.116.11/16",
                        "2a04:4e40::/32",
                        "2a04:4e42::/32"
                    ]
                }
            }
        }
    ]
}

Comment: After a lot of trial-and-error, it seems like things fail when we have 2 IPv6 ranges at the end of the list.
Comment: That sounds like an escaping error or bug to me!
Comment: What netmask did the IPv6 ranges have?
Comment: @shearn89 - I've updated the question with the actual IPs used.  It's taken from Fastly's list of public IP addresses.
Answer: I think you might be bumping into this.
I believe if you have a large list of IPs, and you have block public access turned on at the account level, then you run into this edge case.
With BPA turned on, S3 checks policies to prevent people allowing 0/0 or similar. For large enough IP ranges or lists, the checks that S3 uses behind the scenes to determine 'public' will have too wide a range to check, and will time out or error.
If you can narrow down some of your ranges, or find another way to protect the data, you should be okay.
Comment: I've updated the question.  We have 21 ranges.  We found dropping the last one allowed it to work so thought perhaps 2 IPv6 caused a problem, but maybe the problem is you can't have more than 20?  This all seems like some really terrible design choices on AWS's side if you get no syntax issues when saving the policy.
Comment: Actually, I we had around 17-18 before and adding a single IPv6 in one test seemed to cause it to fail.
Comment: I think a `/32` IPv6 is the limit for IPv6, so having multiple IPv6 ranges is the problem. I would suggest reaching out to AWS support if you have it to raise a ticket - potentially additional feedback that could help make it clearer.
Comment: I suspect if you just had the 2 IPv6 ranges and no IPv4 you'd still hit the problem, it's not a list-length issue but a size-of-range allowed issue!


Calculus: Local/Global Minima/Maxima

Question:
Let $f$ be continuous on $[a,b]$ where $a<b$ such that $f(x)\ne0$ for all $x\in[a,b]$. Prove that there is a $c>0$ where either $f(x)>c$ for all $x\in[a,b]$ or $f(x)<-c$ for all $x\in[a,b]$.

Is this about local/absolute minimum and maximum? I do not know how to approach this question and any guidance to at least start the approach would be very much appreciated. Thank you!
Comment: Do you know the properties of a function continous over an interval?
Comment: 1) $f$ is bounded 2) $f$ has a minimum and maximum on $[a,b]$
Comment: @Ra You may want to google "Weierstrass Theorem on continuous functions" ...
Answer: Since $f$ is continuous, by the extreme value theorem there exists a lower bound $m$ and an upper bound $M$ on $[a,b]$. Let $q,Q\in[a,b]$ be such that $f(q)=m$ and $f(Q)=M$.
We have that both $m$ and $M$ are non-zero from the definition of $f$, so they are either positive or negative each. Suppose they are of opposite signs, then by the intermediate value theorem there exists some $r$ between $q$ and $Q$ with $f(r)=0$, but the definition of $f$ precludes this.
Hence $m$ and $M$ have the same signs. If they are both positive, we choose $c$ such that $0<c<m$; if they are both negative, we choose $c$ such that $M<-c<0$. Then $c$ or $-c$ is a lower or upper bound on $f$, respectively. This completes the proof.

Calculus: Local/Global Minima/Maxima


Finding the order of a group and isomorphism class from the presentation

Question: Let a group be given by $G = \{<a,b> | ab = ba^2, a^3=b^2 = e\}$ where e is the identity.
How do I show that the order of G is 6 and determine the isomorphism class.
Answer: At the time of writing, there was another answer simply stating that this is the dihedral group on $6$ elements.
Observe that $G$ has at most $6$ elements, since any product of the symbols $a$ and $b$ can be simplified into one of the following six forms by repeatedly applying the rules of the group presentation:
$$
e,a,a^2,b,ab,a^2b.
$$
On the other hand, there are at least six elements, since $a$ has order $3$ the number of elements is a multiple of $3$, and similarly since $b$ has order $2$ the number of elements is a multiple of $2$. Thus there are exactly $6$ elements.
Finally, observe that the group is non-abelian, since $ab^2$ and $ab$ are distinct means that $ab^2\not=b^2a$. There is only one non-abelian group of order $6$, the symmetric group on $3$ elements.
An explicit bijection is given by sending $a$ to any $3$-cycle and $b$ to any $2$-cycle.

Regarding the drive-by downvote(s), I assume it is due to confusion regarding the dual answers involving the symmetric group on the one hand, and the dihedral group on the other - which appear (on the surface) to be two different groups. In fact, both answers are correct: the unique non-abelian group of order $6$ is isomorphic to both the symmetric group $S_3$, and the dihedral group with six elements.
Let me explain what is going on here in more detail, since it is actually quite nice. For any natural number $n\in\mathbb N$, we have the following concrete representation of the dihedral group. Take $n$ points equally spaced around the unit circle in the plane. Then the dihedral group of order $2n$ is the group of rigid symmetries of these $n$ points. It consists of rotations (by multiples of $2\pi/n$) and reflections. On the other hand, the symmetric group $S_n$ consists of all ways of permuting these $n$ points - and in particular, includes the rigid symmetries as a special case. When $n=4$ and higher we can find permutations that don't come from rigid symmetries: for instance, the permutation leaving one side of a square fixed and interchanging the corners of the side does not arise from a rigid symmetry, since it does not preserve distances between the pairs of corners. But when $n=3$, a magical thing happens: all permutations arise from rigid symmetries! Thus the symmetric and dihedral groups coincide in the special case we are considering.
Comment: Your argument is a bit flawed. The first part shows that $G$ has order at most $6$, but then $a^3=1$ only implies the order of $a$ divides $3$. So, to finish the argument, it is better to simply point out that $S_3$ satisfies the presentation, therefore the group must be $S_3$. (I didn't downvote.)
Comment: Even your latest comment is a bit unclear. If we take the cyclic group of order $2$, generated by $b$, and $a$ the identity in that group, then that DOES satisfy the presentation. (In the sense that all the relations hold.) Now of course that doesn't mean that this is the group defined by the presentation, just that it's a quotient of it.

Of course, you are right that the presentation defines $S_3$, but a minimal argument goes as follow: first argue that the group has order at most $6$ (as you did), then show that $S_3$ does satisfy the presentation. That's it.
Comment: Consider for example the group $\langle a,b\mid a^3=1,ba^2b^{-1}=1\rangle$. Note that $a$ does not have order $3$ in this group, in spite of the $a^3=1$ relation. What is the difference between this example and the one in the question that allows you to conclude directly from the presentation that $a$ has order $3$?
Comment: To be perfectly clear. I am not saying that $a$ does not have order $3$ in the current question, it does. I am just saying that (1) this cannot be read off directly from the presentation, as you somehow do in your answer, and (2) it does not matter anyway, it is not necessary in a proof.
Comment: In other words, I think it's preferable to say that $a$ has order $3$ because the group is $S_3$, and not the other way around! (And of course, at this point, there's actually no point in bringing up the order of $a$ at all.) Here's a challenge: try to fill in the missing details in your claim that $a$ has order $3$ in your answer. I think you'll find that you essentially have to prove that the group is $S_3$ (or at least has order $6$) along the way, which shows that your proof is circular.
Comment: Would be great if downvoters explained why they downvoted, as this has happened twice now on a perfectly complete and comprehensive answer!
Comment: @verret actually, $a^3=e$ *does* imply that the order of $a$ is $3$, since the only other option $a=e$ leads to a group that does not have the given presentation (cyclic group on two elements, specifically generated by $b$ in this case).
Comment: @verret I get your point regarding shortening the argument, however I don't believe my argument is flawed. Notice my comment 3 says "... leads to a group that does not *have* the given presentation", which is different than how you interpreted as if I wrote "... leads to a group that does not **satisfy** the given presentation". It amounts to the difference between saying two groups are equal vs one is a subgroup of the other. Your example illustrates both of our points - and perhaps could be made more explicit by invoking the definition of a presentation as a quotient of a free group.
Comment: I still think the way you wrote your argument is more or less circular. You claim very early on that $a$ has order $3$. Why is that true? Through discussion in the comments, you argue that, otherwise, $a$ would be the identity, and then the group would be cyclic of order $2$. Why is the group not cyclic of order $2$, given that that group DOES satisfy the presentation? Well, because the presentation actually defines $S_3$. Right, and why is that true? Well because $a$ has order $3$, so $3$ divides the order of the group, as in your original answer!
Comment: @verret the proof is not circular, although I do agree with your assessment that my proof can be more direct


What is the best way to quantify the goodness of fit between the data and my model?

Question: I am modeling the total fluid rate at the bottom of an oil well using a roughly exponential model (mixed with other terms representing an input signal). Here is one example (blue circles are the observed data and black solid line is my model):

In order to determine the goodness of this fit, I plotted the observed data vs the modeled data and calculated the coefficient of determination, $R^2$; however, this does not seem to do justice to my model because very small or negative $R^2$ values occur a lot ($R^2 = -0.37$ for the above example). BTW, because the data is extremely noisy, it is sufficient that my model is able to track the observed data. Please help me fix this problem or find a better way to quantify the quality of my fit.
Comment: How are you getting $R^2<0$?
Answer: You should try fitting a Quadric Equation to your data which is quite flexible to get the perfect trend of any data and then calculate R square value which won't be negative or even less.
Comment: I am not sure we are on the same page. I have already fit the data with my model. I need a measure of the goodness of the fit.


Interaction term renders all terms non-significant

Question: In a random effects logistic model, I have two variables of interest:  Call and Visit.  When I run the model, Call and Visit both have a p-value near 0.10.  When I add an interaction term between Call and Visit, all three terms are now much larger than p = 0.10 and don't approach conventional significance.  Why might this be?
Comment: Do you expect the p values to stay the same when new variables enter the model?
Comment: A good question.  I wouldn't expect the p-values to remain the same.  However, if Call and Visit are both independently significant, I wouldn't expect adding a Call * Visit interaction term to render them all insignificant.  At the very least, the interaction term might show significance while the individual terms might fall out of significance.
Answer: The individual terms or "main" effects in a model have a completely different interpretation in the presence of an interaction that they do without the interaction. So comparing their p-values with and without the interaction is inappropriate. In the presence of an interaction, the coefficient on one of the predictors is the effect of that predictor on the outcome when the other predictor is fixed at zero. Zero may not even be a meaningful value for the other predictor, rendering the coefficient on the main effect nonsensical. This phenomenon is observed here, for example.
Two get an honest p-value for whether the main effect matters in the presence of an interaction, use an ANOVA test. You can also get a more interpretable coefficient by centering both predictors at their means, in which case the main effect of each predictor is the effect of that predictor when the other predictor is fixed at its mean. You can also compute marginal effects to get the average effect of each predictor, collapsing across the other predictor.
Comment: I should have mentioned that the predictors are dummy variables.  I understand how interactions work and how to interpret main effects.  I'm more curious about real world reasons for why two main effects would show significance, but when an interaction term is added, both the main effects AND the interaction term all become non-significant.  It is probably something to do with my data and who is placed in what groups.  I'll probably start there.
Comment: That doesn't change anything. The interpretations of the coefficients changes from ones with potentially high precision (the overall effects of the predictors) to one with potentially low precision (the effect of each predictor at the reference level of the other predictor). It also requires a lot of precision to estimate interaction effects, which may be why it is nonsignificant. Without access to the results of your tests or the alternatives I mentioned it is impossible to say what the reason for the phenomenon you observed is.