How to get rid of the white background of Choropleth?

Question: I am building a dashboard using Potly Dashboard. I am using a dark bootstrap theme therefore I don't want a white background.
However, my map now looks like this:

And the code that produced it is shown below:
trace_map = html.Div(
    [
        dcc.Graph(
            id = "map",
            figure = go.Figure(
                data=go.Choropleth(
                locations=code, # Spatial coordinates
                z = df.groupby(['month']).sum()['Sales'].astype(int),
                locationmode = 'USA-states',
                colorscale = 'Reds',
                colorbar_title = "USD",
            ), layout = go.Layout(title = 'The Cities Sold the Most Product',
                                  font = {"size": 9, "color":"White"},
                                  titlefont = {"size": 15, "color":"White"},
                                  geo_scope='usa',
                                  margin={"r":0,"t":40,"l":0,"b":0},
                                  paper_bgcolor='#4E5D6C',
                                  plot_bgcolor='#4E5D6C',
                                  )
            )
        )
    ]
)

I have tried paper_bgcolor, and plot_bgcolor but couldn't make it work.
Ideally I would like to achieve how this image looks (please ignore the red dots):
Answer: Generally:
fig.update_layout(geo=dict(bgcolor= 'rgba(0,0,0,0)'))

And in your specific example:
go.Layout(geo=dict(bgcolor= 'rgba(0,0,0,0)')

Plot:

Code:
import plotly.graph_objects as go

fig  = go.Figure(
                data=go.Choropleth(
                #locations=code, # Spatial coordinates
                #z = df.groupby(['month']).sum()['Sales'].astype(int),
                locationmode = 'USA-states',
                colorscale = 'Reds',
                colorbar_title = "USD",
            ), layout = go.Layout(geo=dict(bgcolor= 'rgba(0,0,0,0)'),
                                  title = 'The Cities Sold the Most Product',
                                  font = {"size": 9, "color":"White"},
                                  titlefont = {"size": 15, "color":"White"},
                                  geo_scope='usa',
                                  margin={"r":0,"t":40,"l":0,"b":0},
                                  paper_bgcolor='#4E5D6C',
                                  plot_bgcolor='#4E5D6C',
                                  )
            )

fig.show()

And you might want to change the color of the lakes too. But do note that setting lakecolor =  'rgba(0,0,0,0)' will give the lakes the same color as the states and not the bakground. So I'd go with lakecolor='#4E5D6C'. You could of course do the same thing with bgcolor, but setting it to 'rgba(0,0,0,0)' gets rid of the white color which you specifically asked for.
Lake color plot:

Lake color code:
import plotly.graph_objects as go

fig  = go.Figure(
                data=go.Choropleth(
                #locations=code, # Spatial coordinates
                #z = df.groupby(['month']).sum()['Sales'].astype(int),
                locationmode = 'USA-states',
                colorscale = 'Reds',
                colorbar_title = "USD",
            ), layout = go.Layout(geo=dict(bgcolor= 'rgba(0,0,0,0)', lakecolor='#4E5D6C'),
                                  title = 'The Cities Sold the Most Product',
                                  font = {"size": 9, "color":"White"},
                                  titlefont = {"size": 15, "color":"White"},
                                  geo_scope='usa',
                                  margin={"r":0,"t":40,"l":0,"b":0},
                                  paper_bgcolor='#4E5D6C',
                                  plot_bgcolor='#4E5D6C',
                                  )
            )

fig.show()

And we could just as well change the state border colors, or what is more cryptically known as subunitcolor in this context. And to better match your desired endresult we could spice up the landcolor as well:
State border and state colors, plot:

State border and state colors, code:
import plotly.graph_objects as go

fig  = go.Figure(
                data=go.Choropleth(
                #locations=code, # Spatial coordinates
                #z = df.groupby(['month']).sum()['Sales'].astype(int),
                locationmode = 'USA-states',
                colorscale = 'Reds',
                colorbar_title = "USD",
            ), layout = go.Layout(geo=dict(bgcolor= 'rgba(0,0,0,0)', lakecolor='#4E5D6C',
                                          landcolor='rgba(51,17,0,0.2)',
                                          subunitcolor='grey'),
                                  title = 'The Cities Sold the Most Product',
                                  font = {"size": 9, "color":"White"},
                                  titlefont = {"size": 15, "color":"White"},
                                  geo_scope='usa',
                                  margin={"r":0,"t":40,"l":0,"b":0},
                                  paper_bgcolor='#4E5D6C',
                                  plot_bgcolor='#4E5D6C',
                                  )
            )

fig.show()

Comment: @yts61 I haven't used `dcc.Graph` much myself. But it should work just fine if you put `geo=dict(bgcolor= 'rgba(0,0,0,0)')` into your `go.Layout` definition.
Comment: Great! thank you, but I have no idea where i should put this snippet in. would you please tell? Because i tried putting geo in go.Layout, but it shows error.
Answer: I found my way here because I wanted to change the theme of my Choroplethmapbox.  The accepted solution helped, but ultimately I found the code below worked for my situation:
instantiate figure
fig = go.Figure()

add some traces
fig.add_trace(go.Choroplethmapbox(geojson=data_for_choropleth_geojson,
                                  locations=data_for_choropleth['fips'],
                                  z=data_for_choropleth['total_population'],
                                  featureidkey='properties.fips'
                              ))

finally, change the theme using update_layout
fig.update_layout(
    hovermode='closest',
    mapbox=dict(
                # style options: "basic", "streets", "outdoors",
                # "dark", "satellite", or "satellite-streets","light"
                # "open-street-map", "carto-positron",
                # "carto-darkmatter", "stamen-terrain",
                # "stamen-toner" or "stamen-watercolor"
                style='light',
                bearing=0,
                pitch=0,
                accesstoken=TOKEN,
                zoom=5,
                center=dict(
                    lat=29.4652568,
                    lon=-98.613121
        )
)


What is a non-interactive service account?

Question: Trying to get a clear understanding of what makes a AD domain service account non-interactive and how this is done?
I require a service e account with "logon as a service" and "logon as a batch" for a service account on a IIS box.
Comment: I Googled your title and found: https://docs.microsoft.com/en-us/windows/desktop/secauthn/noninteractive-authentication and
Answer: Wha is an interactive logon ?

An interactive logon to a computer can be performed either locally,
  when the user has direct physical access, or remotely, through
  Terminal Services, in which case the logon is further qualified as
  remote interactive. After an interactive logon, Windows runs
  applications on the user's behalf and the user can interact with those
  applications.
Users can perform an interactive logon by logging on to a computer
  using a local user account or by using their domain account.

Please read that blog about Managed service account. https://blogs.technet.microsoft.com/askds/2009/09/10/managed-service-accounts-understanding-implementing-best-practices-and-troubleshooting/

The Windows Server 2008 R2 AD Schema introduces a new object class
  called msDS-ManagedServiceAccount. Create an MSA, examine its
  objectClass attribute, and notice the object has an interesting object
  class inheritance structure:
Computer
msDS-ManagedServiceAccount
organizationalPerson
Top
User
The object is a user and a computer at the same time, just like a
  computer account. But it does not have an object class of person like
  a computer account typically would; instead it has
  msDS-ManagedServiceAccount. MSA's inherit from a parent object class
  of "Computer", but they are also users. MSA objects do not contain new
  attributes from the Win2008 R2 schema update.

If you ask as you wish to make a service account, please see:
For your question, if a managed account is not what you look for, you can create a non-interactive account by creating a GPO that set that; Computer Configuration/Windows settings/Local Policies/User Right Assignement, and you deny the user account the Log On right. (https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/deny-log-on-locally). That way that account will only be able to be used for services


How do I implement access checks based on referring nodes in the grants system?

Question: Following a suggestion in another thread here I'm trying to rewrite the access restrictions that I developed using hook_node_access (and that are working well, so far) in Drupal's grant system (i.e. using hook_node_access_records and hook_node_grants). I would like to do that for two reasons:

I'm worried that the current access checks might become a performance bottleneck, when the number of users grows.
I need to use the results of access checks as a filter in views.

Here's a truncated version of my current access checks:
function mymodule_node_access(\Drupal\node\NodeInterface $node, $op, \Drupal\Core\Session\AccountInterface $account){
  $type = $node->bundle();
  $user = $account->getAccount();
  $uid = $user->id();

  // only handle the lesson content type
  if ($type === 'lesson') {

    // ...

    // check the user's access to the referring courses
    $courseaccess = FALSE;
    if ($node->hasField('reverse_entity_reference')) {
      $parentcourses = $node->get('reverse_entity_reference')->getValue();
      foreach ($parentcourses as $course) {
        $coursenode = \Drupal\node\Entity\Node::load($course['target_id']);
        // perform access checks for the referring course
        $courseaccess = $courseaccess || ...
      }
    }

    // ...

    // return the result
    if ($courseaccess) {
      return AccessResult::allowed();
    } else {
      return AccessResult::forbidden();
    }
  }

  // ...

}

Note that, in essence, I need to check, whether the current user has access to any of the nodes (courses) that are referring to the viewed node (lessons): That determines, whether the user may access the lesson. I'm using reverse entity references for that.
As I see it (I'm open to suggestions), there are fundamentally two ways for approaching this. Unfortunately, so far, I have been unable to solve the problems involved. So, in my understanding, I could...

Put (more or less) the full access logic into hook_node_grants: That would mean, I need to have access to the currently viewed node (lesson) in hook_node_grants to be able to follow its reverse references to check, whether the user has access to any of the referring nodes. Is that possible? There's no $node variable...
Put (more or less) the full access logic into hook_node_access_records: In that case, the problem is that the hook only gets called (and thus the lesson gets updated), whenever the node is saved. So, the access restrictions will be out of date, as soon as a lesson is included in another course.

I'm unsure how to proceed at this point. Is it even possible to rewrite this in the grant system? Any other ideas?
Answer: Given that we don't have an exhaustive list of requirements & Q&A isn't suited well for long discussions, it will be impossible to definitely say yes.
The grant system isn't designed around any sort idea of hierarchy. Is it possible to rewrite? It depends if you can refactor your existing logic around what the grant system supplies.
You've framed your question as a dilemma, but you really need both hooks to use the grant system:

hook_node_grants need to assign realm/gid grants that correspond to the $user and the available lesson nid they can access.
hook_node_access_records needs to fire against a lesson $node

So if you can:

Map the realm/gid grant keys to match to courses the user has access to (e.g. mymodule_course_realm/123 where 123 some group identifier that maps to a group of users that have course access, thus lesson nid access)
Trigger lesson save events upon course updates (e.g. using hook_node_update, hook_node_insert, etc. to look for update courses, then doing dummy saves on the lesson nodes) so that hook_node_access_records can fire against lesson nodes that have a changed relationship. (or build custom logic where you insert grants directly via NodeGrantDatabaseStorage::write())

You can probably refactor around the hooks the grant system provides.
Comment: Thank you very much for the detailed answer. I was afraid this might be the bottom line. I had already thought of triggering _lesson_ save events, but am worried that this might cause inefficiencies and inconsistencies down the road. Which is why I was hoping for a way to get access to the `$node` variable in `hook_node_grants`. Sadly, refactoring the system seems unrealistic, as the flexibility is important: I.e., if a _lesson_ is part of two _courses_, only one of which the user may access, the _lesson_ should be accessible in **both** _courses_! Thanks anyway, much appreciated!


nested exception is java.lang.NumberFormatException: For input string/ Multipart file and json data to spring boot

Question: I have the POST request API call to accept the JSON body request parameters and multipart file from the client side. This is my method:
@PostMapping("/saveCategory")
    @ResponseStatus(HttpStatus.OK)
    public void createCategory( @RequestParam("file") MultipartFile file,@RequestParam("cateogry") CategoryModel category) {
        String fileName = fileStorageService.storeFile(file);

        String fileDownloadUri = ServletUriComponentsBuilder.fromCurrentContextPath().path("/downloadFile/")
                .path(fileName).toUriString();
        //category.setImage_path(fileName);

        //this.categoryRepository.save(category);

        // return new UploadFileResponse(fileName, fileDownloadUri,
        // file.getContentType(), file.getSize());

    }

I have this exception:
 "category_name": "ziska111"

    }'; nested exception is java.lang.NumberFormatException: For input string: "{"category_name":"ziska111"}"]

This is my Postman request:

I think I have a problem with my CategoryModel  but I do not know why:
This is my CategoryModel:
   @Entity
   @Table(name = "Category")
   @JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
public class CategoryModel {
    @Id
    @Column(name = "id")
//@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

private String category_name;
private String category_description;
private String image_path;

@JsonIgnore
@OneToMany( mappedBy = "category")
private Set<ProductModel> category;
+Geterrs and Setters

Answer: You try to convert string to integer but,  input string contains alphabetical characters and it's impossible to convert to integer
Comment: Hmm, how I can to send an object from my postman, not String?
Comment: As I can see from your screen shot, you have selected category as text but you're passing data as Json. That might be the issue. Please check In the meantime, you can check the difference between two here : https://stackoverflow.com/questions/4350753/advantages-of-using-application-json-over-text-plain


Python Tkinter: Cant configure button from another class

Question: I am just learning MVC and im using Tkinter to do so, but while i am trying to configure a button from a class within a class i keep getting this error
Traceback (most recent call last):
  File "Controller.py", line 22, in <module>
    controller = Controller(root)
  File "Controller.py", line 10, in __init__
    self.view.addWidgets.btn.config(command=self.addShow)
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1205, in configure
    return self._configure('configure', cnf, kw)
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1196, in _configure
    self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: invalid command name ".35986680.35987112.35991848"

If you cant determine the problem from the error i can post my code, but they are in two separate files, although the files are only 40 lines long.
Details:
Button is in Frame class
Frame class is in View class
View class is in Controller class
function being called by Button command is in Controller class
    error happens when i configure button from Controller class
    self.view.addWidgets.btn.config(command=self.addShow)

Edit
I striped the code.
Controller.py
from View import *
from Model import *
from Tkinter import *

class Controller:
    def __init__(self,root):
        self.model = Model()
        self.view = View(root)

        self.view.addWidgets.btn.config(command=self.addShow)

    def addShow(self):
        print 'Working'

root=Tk()
root.withdraw()
controller = Controller(root)
root.mainloop()

View.py
from Tkinter import *
from MultiListbox import *
from AddFrame import *

class View(Toplevel):
    def __init__(self, master):
        Toplevel.__init__(self, master)
        self.title('Show Preserver')

        self.protocol(self.protocol('WM_DELETE_WINDOW', master.destroy))#When i delete this i dont get the error but it still dosent work

        self.addFrame=Frame(self,bg='black')
        self.addWidgets=AddFrame(self.addFrame)

        self.addFrame.grid(row=0)

        self.mainloop()

AddFrame.py
#Add Frame
from Tkinter import *

class AddFrame(Frame):

    def __init__(self,master):

        self.frame = Frame(master,bg='black')
        self.frame.grid(row=0,column=0,sticky=W+E)

        self.btn = Button(self.frame,text='Add',bg='black',fg='yellow',activebackground='yellow',activeforeground='black', width=2,command=None)
        self.btn.grid(row=0,column=6,sticky=E)

Comment: one obvious problem without looking any deeper is that you're calling `mainloop` twice. Tkinter is designed such that `mainloop` must only be called once to work properly.
Comment: lol. Your a genius! my problem has been solved
Answer: The error invalid command name ".35986680.35987112.35991848" comes from the underlying Tcl interpreter which powers Tkinter. .35986680.35987112.35991848 is the low-level identifier for the widget, and it also represents a proxy command which is used to interact with that widget. Since Tcl is saying "invalid command name", that almost always means that the low level widget has been destroyed since the command goes away when the widget is destroyed.
Looking at your code, it appears that .35986680.35987112.35991848 represents self.view.AddWidgets.btn. Are you certain that widget still exists at the time you try to configure it?
[time passes, and now the question has some code...]
You are calling mainloop twice, which is not how Tkinter is designed to be used. You need to remove one of those.
Comment: I am pretty sure that the button is not being destroyed. I just put my code up, if your willing to take a look.


LDAP slapd server not starting -> Modify ldap when server is offline

Question: so im trying to get a LDAP server with ssl certificate running. I need to change the config by changing cn=config with ldapmodify and therefore cannot use a slapd.conf. It was quite hard finding proper guides on how to set it up with this... im relative new to linux...
Currently the slapd server is not starting and neither a systemctl status nor a journalctl had any information.
I think the problem is that for the ssl certificate I generated a key, so 2 .pem files one as the cert and one as key and then I ran
sudo ldapmodify -Y EXTERNAL -H ldapi:/// -f ldap.ldif

to load the config.
Content of ldap.ldif:

dn: cn=config
changetype: modify

add: olcTLSCertificateFile
olcTLSCertificateFile: /etc/ldap/ssl/ldapcert.pem
-
add: olcTLSCertificateKeyFile
olcTLSCertificateKeyFile: /etc/ldap/ssl/keys/ldapkey.pem
-
add: olcTLSCipherSuite
olcTLSCipherSuite: TLSv1+RSA:!NULL
-
add: olcTLSVerifyClient
olcTLSVerifyClient: never

I had a typo in this file when I loaded it and then the problem arised.
My question is: How can I load the new (without typo) ldap.ldif file to the slapd server, when its shut down. When trying to run ldapmodify it says that he cannot make a connection to the ldap server which makes sense when it's offline.
To get more information when I try to start the server I ran the following command
/usr/sbin/slapd -h "ldapi:/// ldap://:7389/ ldaps://:7636/" -d -1

and got some more information: (part of the output)

daemon: bind(8) failed errno=98 (Address already in use)
lap_open_listener: failed on ldapi:///
lapd stopped.
onnections_destroy: nothing to destroy.

But I don't know what to do with this information and I didn't found similar problems in the internet.
I hope someone can help me!
Greeting Jonas
Answer: The last output is actually telling you something is using the port so the slapd service is probably in limbo.
Kill the slapd process manually, you can use suggestions in this answer
or just plain pgrep slapd will give you pid of the process which you gonna kill.
Command lsof +L1 or lsof -c slapd may show you slapd is touching some file (means  it's in limbo).
And I'm gonna pretend there isn't tlsv1 in your config ;)


Sqlite compartilhado entre flavors android

Question: Olá, estou querendo fazer uma versão paga sem anúncios do meu app que já está publicado na play store. Eu queria que se uma pessoa comprar a versão paga ela não perca todos os dados já cadastrados na versão gratuita, onde armazeno tudo no SQLite. Qual a maneira de compartilhar os dados do SQLite entre diferentes flavors no android?
Answer: Você precisa que as duas aplicações usem o mesmo id.
Adicione essa linha à ambos os manifesto:
<code>android:sharedUserId="com.android.xyz"
</code>
Outra opção é através do Custom Content Provider.
Comment: Mas no android studio tem apenas um manifest. Devo criar uma pasta para cada flavor e em cada pasta usar um manifest diferente? Como fica a configuração do gradle? Cada flavor fica com o mesmo id e a mesma versão? E na hora de publicar a versão paga, na play store vai ficar como um app diferente?
Comment: Tem a opção paga e a free. Isso deve ser colocado no Manifest da versão paga e da versão free.


Making sticky results in Search API Solr

Question: We want to be able to promote some nodes on the search results.
I thought about using the "Sticky" option, so if a node is sticky, it should be on top of the results.
I've tried using the "Boost" option in the index field settings but it doesn't work.
Is there any way of achieving that?
(Using Drupal 7, Apache Solr 4.6.1 and Search API)
Answer: Could you perhaps?:

Put a boolean field on your content (or make use of the 'promote to front page' field)
Make a view to arrange your search results
Group by that boolean (or 'promoted')

I don't know if 'promoted' is indexed by default, you might need to set that.


Jquery Layout Plugin How to determine whether a pane is open or closed

Question: I am using jquery.layout-1.2.0 by Fabrizio Balliano
i want to know in my java script whether a Layout Pane is in open state or closed state.
As per documentation i tried the following.
var lout = $('body').layout();
// get layout 'state'
var is_west_open = lout.state.west.isOpen;
alert(is_west_open);
if (!is_west_open)
  outerLayout.toggle('west');

Alert is returning 'Undefined'
What did i miss?
Answer: That's right. There's no duplicate property isOpen. Use NOT isClosed instead:
var is_west_open = ( ! lout.state.west.isClosed);

I am not ready to answer why is there no property isOpen (I dont watch on this js-library), but I'd like to give you 2 advices:
1) Use console.log(<variable>) instead of alert(<variable>).

First of all, it doesn't stop execution of the script, so you can see few log-messages at a time rather than clicking "OK" any time an alert happens;
You can back to the previous message;
Alert accepts a String, so any element provided is converted automatically with toString() method, so it is not exactly the same object that browser operate with;

2) Try to use Developer Tools in Google Chrome or Firebug (in Firefox) or, in Opera and IE their native inspectors - it can enshort the time you debug your application - they show you all the properties and methods available for an object
Just Click F12 and you'll can see something like this:
https://i.stack.imgur.com/JlSga.png


Integration solving problem

Question: A integration is given $$x-x_0 = \pm \int_{0}^{\phi(x)}\frac{d\Phi}{\sqrt\frac{\lambda}{2}(\Phi^2-\frac{m^2}{\lambda})} \tag{1}$$
The author said that, equation (2) can be written from equation (1) by inverting;
$$\Phi(x)= \pm \left(\frac{m}{\sqrt\lambda }\right)\tanh\left[\left(\frac{m}{\sqrt2}\right)(x-x_0)\right] \tag{2} $$
How to solve this integration easily?
Anyone can help?
Answer: Partial fractions:
$$
\frac{d\Phi}{\Phi^2-\frac{m^2}{\lambda}} = \left(\frac{A}{\Phi-\frac{m}{\sqrt{\lambda}}}+\frac{B}{\Phi+\frac{m}{\sqrt{\lambda}}}\right)\,d\Phi.
$$
Use some algebra to figure out what numbers $A$ and $B$ are.  When you integrate, you get
$$
A\log_e\left(\Phi-\frac{m}{\sqrt{\lambda}}\right) + B\log_e\left(\Phi+\frac{m}{\sqrt{\lambda}}\right).
$$
Then use identities involving logarithms to write it as just one logarithm.
Answer: Hint: Use
$$\int \frac{1}{a^2 -b^2} da  = - \frac{\tanh^{-1}(a/b)}{b} + \text{constant}.$$
Comment: Actually I have little problem in Hyperbolic tanh, so if you elaborate, it will be helpful for me, and I will follow that in future.

Integration solving problem


"Cascade induction"? [telescopy]

Question: I refer to this answer.
The answer is based on several simplification steps, all of them proven by induction.

$S_n = 2903^n - 803^n - 464^n + 261^n$
$T_n = 2642\cdot2903^n - 542\cdot803^n - 203\cdot464^n$
$U_n = 6443838\cdot2903^n - 183738\cdot803^n$

are all proven to be divisible by 1897.

First statement is the original statement from the question.
Second statement is the induction step for the first statement.
Third statement is the induction step for the second statement.

Is there a name for the method applied there? "Cascade induction", let's say?
Comment: Again, consider $\varphi(n)=(1897| S_n\land 1897| T_n\land 1897|U_n)$. Then you can prove $\varphi(n)$ by standard induction.
Comment: If you told me about "cascade induction" without saying what you mean specifically, I would assume you meant something like induction with respect to two (or more) natural numbers, which is really just a special case of transfinite induction. This is just your run-of-the-mill induction: we prove inductively that for each $n$, all the numbers $U_n,T_n,S_n$ are divisible by $1897$. Or three inductions, depending on how you think about it: first, you inductively prove that each $U_n$ is divisible by $1897$, then for $T_n,S_n$. Either way, nothing nonstandard to warrant a special name.
Comment: but each proof relies on the proof one level bellow, they are not independent, except the last one which is 'plain' induction @tomasz but ok, it could be just an insignificant idea
Answer: What is being cascaded is not induction but, rather, telescopy (essentially to construct the difference operator / recurrence that annihilates $\,f_n = S_n).\ $  The telescopic step is this:
Theorem $\ \ m\mid f_n= a^n\! + g_n\,$ for all $\,n\iff m\mid g_{n+1}\!-ag_n\,$ for all $\,n,\,$ and $\,m\mid f_0$
Proof $\ (\Rightarrow)\ \ f_{n+1}\!-af_n = g_{n+1}\!-ag_m\,$ so $\,m\mid f_{n+1},f_n\Rightarrow\, m\mid{\rm\small LHS}\Rightarrow m\mid\rm\small RHS$.
$\ (\Leftarrow)\ $ Induction Base: $\,m\mid f_0\,$ by hypothesis. Step: $\,m\mid f_n,{\rm\small RHS}$ $\,\Rightarrow\, m\mid{\rm\small RHS}+ a f_n = f_{n+1}$
Remark $\, $ Let $S\,$ be the linear  $\,n$-shift $\,S f_n = f_{n+1}.\,$ Then $\,(S\!-\!a) a^n = a^{n+1}\!-a a^n = 0.\,$ Thus $\, (S-a)(S-b)(S-c)(S-d)\,$ kills $\,f_n = a^n + b^n + c^n + d^n.\,$ This yields an order $4$ constant coef recurrence for $\,f_n,\,$ say $\,f_{n+4} = c_3 f_{n+3} + c_2 f_{n+2} + c_1 f_{n+1} + c_0 f_n.\,$ So by (strong) induction we deduce that $\,\forall n\!: m\mid f_n$ $\iff m\mid f_0,f_1,f_2,f_3,\,$ thus $\,\gcd(f_0,f_1,\ldots) = \gcd(f_0,f_1,f_2,f_3).\,$ The linked proof amounts to constructing this recurrence in $4$ steps, using the above Theorem for each step, which amounts to applying $\,S\!-\!a\,$ to kill $\,a^n,\,$ then applying $\,S\!-\!b\,$ to kill $\,b^n,\,\ldots$
Thus the linked proof can be greatly simplified once one observes that the form of $\,f_n\,$ implies that it satisfies an order $4$ recurrence, so we need only check the first $4$ values. But we can simplify the proof even further. As I mention in my answer there, by symmetry, it suffices to check that $\{2903,\, 261\}\ \equiv\ \{803,\, 464\}\,\ {\rm mod}\,\ 271 \ \,\&\,\ 7.\,$ Then the induction is encapsulated in the well-known Congruence Power Rule $\, A\equiv a\,\Rightarrow\, A^n\equiv a^n.\,$ This is a prototypical example of how exploiting innate symmetry leads to great simplification.
Comment: Thanks for amazing insights!

"Cascade induction"? [telescopy]


Proof that $3^n > 2^n$ for all natural numbers greater than or equal to $1$

Question: Claim: $\forall n \in \mathbb{N} \geq 1,\,3^n > 2^n$
Proof: Proceed by induction on $n$.
Base Case (n=1): $3^1 > 2^1$ true.
Inductive Hypothesis: Assume for $n=k\geq 1$ that $3^k > 2^k$
Inductive Step:
$\begin{align}
3^{k+1} > 2^{k+1} \\
3 \cdot 3^k > 2 \cdot 2^k
\end{align}$
By the inductive hypothesis we know that $3^k > 2^k$. After this I'm stuck as to how to prove the seemingly obvious $3 \cdot 3^k > 2 \cdot 2^k$ - do I even need to prove it? The only thing I can think of is splitting the multiplication into addition, but then what?
Comment: $3^{k+1}=3\cdot 3^k>3\cdot 2^k>2\cdot 2^k=2^{k+1}$ (using that all involved are $>0$)
Comment: Use the inductive hypothesis?
Comment: @SahibaArora I'm already using it.
Comment: @HagenvonEitzen do you mind elaborating on this more? I'm having trouble following those inequalities
Comment: If $a>b$ and $c>0$ then $ac>bc$.
Comment: Alternatively, $3^{k+1}=3^k+3^k+3^k>2^k+2^k+2^k>2^k+2^k=2^{k+1}$
Comment: $3/2>1$, then $(3/2)^n>1$(why?).$\Rightarrow 3^n>2^n$. This process holds for any real number greater than $1$.
Comment: $3 > 2$ so of course $3^n > 2^n$. Right...?
Answer: Under the inductive step you start with what you are attempting to prove.  You should say assume $3^k \gt 2^k$.  Then $3^{k+1}=3 \cdot 3^k \gt 3 \cdot 2^k \gt 2 \cdot 2^k=2^{k+1}$  In each of the $\gt$ signs we replace a term on the left with a smaller term on the right.
Comment: Where was the inductive hypothesis used here?
Comment: It was use in the first inequality where we replace $3^k$ by $2^k$


How can I forward sound as well as X windows with ssh -X?

Question: I use ssh lots, often doing long-running builds on other machines.
I'd like to know when a compile or other long-running process fails on a remote machine, and my preference for feedback would be audio.
Is there a way I can get remote audio forwarded to my local machine? I'd prefer something that integrates with ssh -X if possible, but I'd like to know about any options that exist.
Comment: My use case is more broad than yours. I've got a LOT of machines and am usually at ONE system and I'd SURE like to be able to get the audio over x-Windows - and, in particular, X11. I have so many reasons I could list why this would help me, I don't have room here or time to share them all here; simply, it would save me having to move to local consoles to get that, and it would empower features and capabilities many have likely never considered. ... Further, I've never understood why someone didn't add this to x11 decades ago, but as PulseAudio is open source, it would surely make sense now.
Answer: The system bell works through ssh; or you can tunnel ESD, NAS, or whatever audio system works for your system. On my systems I have a tiny program called beep installed that rings the system bell.
Comment: There is pulseaudio as well: http://wiki.archlinux.org/index.php/PulseAudio#PulseAudio_over_network
Answer: There are multiple sound servers that can forward sound over TCP: esd, JACK, NAS, Pulseaudio... If you decide to use one, your main problem will be to make sure that you have the same on all machines, or else to arrange for forwarding multiple systems and translating them locally.
For your use case, I think it would be simpler to send only text through the ssh channel, and locally play a sound when you receive a notification from the remote end. For example (nc is OpenBSD netcat):
while true; do
  ret=$(nc -l localhost 12345);
  if [ "$ret" -eq 0 ]; then play ok.wav; else play failed.wav; fi
done &
ssh remote -R12345:localhost:12345 'make; echo $? | nc localhost 12345'


Is there a way to test if a React component is within another component of a particular type?

Question: Let's for a second assume we have 3 components.
export class ComponentA extends React.Component<IComponentAProps, IComponentAState>{
    constructor(props: Readonly<IComponentAProps>) {
        super(props)
    }

    render() {
        return(
            <ComponentB />
        );
    }
}

export class ComponentB extends React.Component<IComponentBProps, IComponentBState>{
    constructor(props: Readonly<IComponentBProps>) {
        super(props)
    }

    render() {
        return(
            <ComponentC />
        );
    }
}

export class ComponentC extends React.Component<IComponentBProps, IComponentBState>{
    constructor(props: Readonly<IComponentBProps>) {
        super(props)
    }

    render() {
        return(
            <ComponentA />
        );
    }
}

Now obviously this is going to cause an infinite loop. Is there a way for me to check in ComponentC to see whether or not it is ultimately contained within an instance of ComponentA?
Comment: @Matt That's what a context would provide: a way of understanding, relatively unobtrusively, that something already exists.
Comment: Looks like bad design, what goal are you trying to achieve?
Comment: Yeah it's bad design here and not actually indicative of what I'm building, it just easily demonstrated the issue. Essentially I have an auditing component, and it needs to set a global context. But I need to be careful that there isn't another auditing component inside another, and if there is I want the parent to be the auditing context. The concern is that some dev might come along and unknowingly nest them which would cause issues for the audit.
Comment: At runtime, or compile time? The thing is that a recursive component hierarchy isn't intrinsically bad--it's only bad if there's no end condition, like anything recursive.
Comment: Wouldn't such scenario automatically throws `RangeError` at runtime even during development? Why do you need to manually check?
Comment: Either runtime or compile time would be fine honestly. Compile time would be nice to prevent devs from doing it, runtime is fine in that I could write some logic to handle it.
Comment: @Matt My point was that determining "bad" vs "good" recursive hierarchies depends on understanding what "bad" and "good" mean, which depends on context and (possible) run-time behavior. One trivial way to solve for a simple case would be to stick a context wrapper around the problematic component and do something like increment a counter in that context each time the component is used. If > n there's a potential problem.
Comment: @Dave Newton Yeah perhaps my example is a bit too simplistic for what I'm looking for. Essentially I just want to be able to write some code that can check to see if one component is the child of another particular type of component, but the nature of React has barriers preventing me from going up the chain. I might have to think outside the box and implement some sort of locking feature for what I want if I can't just do a check and ignore.
Comment: Yeah contexts seem like what I need to work on. I can simply check the context on componentDidMount and handle what I need to do there. Thanks for the help.
Answer: I'm not sure this is what you need, but you can achieve this using a React context.
import React, { createContext, FunctionComponent, useContext, useEffect } from 'react';

export const TopDogContext = createContext<string>('');

// The top dog can never be nested!
export const TopDog: FunctionComponent = ({ children }) => {
  const aboveMe = useContext(TopDogContext);

  useEffect(() => {
    if (aboveMe) {
      setTimeout(() => alert('Yo, you can\'t nest me!'));
      throw new Error('Yo, you can\'t nest me!');
    }
  }, [aboveMe]);

  return (
    <TopDogContext.Provider value={'I\'m the top dog!'}>
      { children }
    </TopDogContext.Provider>
  )
};

// -------
import { TopDog } from './top-dog';

function App() {
  <TopDog>

      [... YOUR APP HERE ...]
      {/* Will create an error if uncommented */}
      {/* <TopDog /> */}

  </TopDog>
}

Note that you can still have multiple <TopDog>, but they will never have one being the ancestor of another.
Comment: Note: you can also just pass down the same value as the parent context instead of throwing an error. This way, only one value is created.
Comment: This is exactly what I need. Thank you.


WriteFile to SD card (physical hard disk) fails with ERROR_ACCESS_DENIED (0x5)

Question: I'm trying to write to physical Hard Disk (SD Card/FAT32) directly using Windows API: WriteFile() but it always fails with ERROR_ACCESS_DENIED (0x5). I've tried many options suggested by some other posts such as unmount/lock but nothing seems to be working.
Does anyone have a better idea what is the root cause of this and how can we access to the physical drive directly from Windows API?
This is the sample code I'm using:
<code>#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <windows.h>

DWORD lastError;

int main (void) {
  uint16_t x, y;
  uint8_t  buffer[512];
  DWORD    bytesWritten, status;

  HANDLE sdCardHandle = CreateFile("\\\\.\\PhysicalDrive2", GENERIC_READ    | GENERIC_WRITE,
                                                            FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

  if(sdCardHandle == INVALID_HANDLE_VALUE) {
    CloseHandle(sdCardHandle);
    return -1;
  }

  for (y = 1; y < 10001; y++) {
    memset(buffer, y, sizeof(buffer));
    if (WriteFile(sdCardHandle, buffer, sizeof(buffer), &bytesWritten, NULL) == 0) {
      lastError = GetLastError();
      printf("WriteFile error: 0x%X\n", lastError);
      CloseHandle(sdCardHandle);
      return -2;
    }
    printf("%d\n", y);
  }

  CloseHandle(sdCardHandle);
  return 0;
}
</code>
Thanks!
Comment: Are you running your process elevated (with admin privileges)?
Comment: I doubt that `FILE_SHARE_READ | FILE_SHARE_WRITE` is valid when requesting access to the physical drive.
Comment: I did try running .exe of this code with admin but it didn't work
Comment: Maybe this helps: https://stackoverflow.com/questions/6608466/how-to-writefile-to-a-physicaldrive-windows-7-without-getting-error-access-den, or this: https://www.codeproject.com/Questions/245762/WriteFile-to-physicaldrive-on-Win7
Comment: Try `FSCTL_LOCK_VOLUME`, `FSCTL_DISMOUNT_VOLUME`. It should work without `FILE_FLAG_NO_BUFFERING`, but who knows. Also buffer should be aligned on 512 or 4096 byte boundary
Answer: Thanks all for the comments.
So I figured out a way to work around this problem (in Windows 10). The workaround is to lock, dismount and create disk as GPT to make Windows think it's unallocated disk. For whatever reason if it was formatted as FAT/FAT32, I just wouldn't be able to WriteFile to the card.
The following is the example code that is working for me:
<code>#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <windows.h>

static CREATE_DISK   raw; // dummy raw to create disk as GPT to trick Windows to see it as unallocated
static DWORD         lastError;
static HANDLE        sd_handle;

int main (void) {
  uint16_t x, y;
  uint8_t  i, buffer[512];
  DWORD    bytes;

  if ((sd_handle = CreateFile("\\\\.\\PhysicalDrive2",
                              GENERIC_READ|GENERIC_WRITE,
                              FILE_SHARE_READ|FILE_SHARE_WRITE,
                              NULL,
                              OPEN_EXISTING,
                              FILE_FLAG_NO_BUFFERING,
                              NULL)) == INVALID_HANDLE_VALUE) {
    printf("Error 0x%X openning Physical Drive\n", GetLastError());
    return -1;
  }

  // Workaround to lock, dismount, and create disk as GPT to trick Windows to see drive as unallocated
  if (!DeviceIoControl(sd_handle, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, &bytes, NULL)) {
    puts("Error: Cannot lock volume");
    CloseHandle(sd_handle);
    return -2;
  }

  if (!DeviceIoControl(sd_handle, FSCTL_DISMOUNT_VOLUME , NULL, 0, NULL, 0, &bytes, NULL)) {
    puts("Error: Cannot dismount volume");
    CloseHandle(sd_handle);
    return -3;
  }

  raw.PartitionStyle = PARTITION_STYLE_GPT;
  if (!DeviceIoControl(sd_handle, IOCTL_DISK_CREATE_DISK, &raw, sizeof(raw), NULL, 0, &bytes, NULL)) {
    puts("Error: Cannot create disk");
    CloseHandle(sd_handle);
    return -4;
  }

  // unlock, close, and reopen again to allow Windows to see it as newly unallocated drive
  if (!DeviceIoControl(sd_handle, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0, &bytes, NULL)) {
    puts("Error: Cannot unlock volume");
    CloseHandle(sd_handle);
    return -5;
  }

  CloseHandle(sd_handle);

  if ((sd_handle = CreateFile("\\\\.\\PhysicalDrive2",
                              GENERIC_READ|GENERIC_WRITE,
                              FILE_SHARE_READ|FILE_SHARE_WRITE,
                              NULL,
                              OPEN_EXISTING,
                              FILE_FLAG_NO_BUFFERING,
                              NULL)) == INVALID_HANDLE_VALUE) {
    printf("Error 0x%X openning Physical Drive\n", GetLastError());
    return -6;
  }

  // Note for WriteFile:
  // The GetLastError code ERROR_IO_PENDING is not a failure;
  // it designates the write operation is pending completion asynchronously.
  for (i = 1; i < 100; i++) {
    memset(buffer, i, sizeof(buffer));
    if (!WriteFile(sd_handle, buffer, sizeof(buffer), &bytes, NULL)
     &&((lastError = GetLastError()) != ERROR_IO_PENDING)) {
      printf("WriteFile error: 0x%X\n", lastError);
      CloseHandle(sd_handle);
      return -7;
    }
  }
}
</code>
Again, this is just a workaround that I found out to be working for me, but I don't know what was the exact cause yet. If anyone knows the root cause and is willing to share that would be great.


How do we track web traffic on a Windows 2003 Server running IIS?

Question: Our management would like to know how people are using our website, which we host on our Windows 2003 Server using IIS.  Since none of us are really system administrators, we don't know how to go about getting the information out of wherever IIS, or the system, logs it.  Is it kept just in the event logs, or is it some where else?
Answer: In order to use server logs for analytics then first you have to have logging enabled in IIS and that is done in IIS Mgr on the properties of the web site.  Right-click on the web site, choose Properties and it's on the General tab.
The data is kept in log files usually (and by default), but it's also possible to log to a database.  If you log to files then by default they're in c:\windows\system32\inetsrv, but your configuration will tell you where they are located on a site by site basis.
You'll need to get a web analytics package to efficiently analyze your log data.  Wikipedia lists some decent ones.  If your site is public facing then go with Google Analytics.  Webtrends has powerful packages and is not listed on that Wikipedia page.
Comment: If we choose to log to a database, does it set the database up?  Or do we have to?  And if we have to, what's the database schema?
Comment: @rod you have to set the database up. It's a single table with columns that are the log fields. You might limit yourself with analytic package choices if you log to a Dhaka, though. Make sure the one you want to use supports SB logs or else you'll have to export the data to flat files.
Answer: Easiest way is to just sign up for google analytics.


Why is $a=e$ the smallest number such that $a^x\ge 1+x$ for all $x$?

Question: Calculus book:

Find all numbers $a$ such that $\forall x, a^x \ge 1+x$

I immediately thought of the inequality $e^x\ge 1+x$ and guessed that the answer was any number $a$ in $[e,\infty)$. After playing around with a graphing app I can see this is definitely true, although I can't explain why.
Why is $e$ specifically the smallest number such that the inequality holds? To my untrained eye, a quick scan of the equation does not give rise to anything involving the constant $e$. Maybe because $1+x$ is only a tangent to the equation $a^x$ when $a=e$? Thanks.
Comment: $e^x$ is not the smallest number $\ge 1+x$.
Comment: Have you worded your question right? Are you looking for smallest $a$ such that $a^x \geq 1+x , \, \forall x$?
Comment: @baharampuri Actually, I'm looking for all numbers $a$ that satisfy that constraint for all $x$. The answer is probably in the form of an interval.
Comment: @LordSharktheUnknown Judging from your five upvotes on that comment, I've made a mistake in my question. But the two answers I have (including yours) confirm $e$ is the smallest number. Have I made a mathematical typo? You seem to be understanding my question.
Comment: @LugGian: I've now fixed the title so it actually fits your question.
Comment: @celtschk Thanks. What was wrong with it? In particular, why did Lord Shark say $e^x$ is not the smallest number (if you don't mind me asking)?
Comment: As originally formulated, you asked about the number $e^x$. But the number $e^x$ is not for all $x$ the smallest number $\ge 1+x$; for example, for $x=1$, $e^x=e>1+x=2$, but obviously the smallest number $\ge 2$ is $2$. With the reformulated title, the question asks no longer about the size of $e^x$, but about the size of the base $a$ of the exponential $a^x$, which must be at least $e$ so that the inequality is fulfilled for all $x$.
Comment: See this answer https://math.stackexchange.com/a/2383082/72031
Answer: Note that $e^x$ has taylor series:
$$e^x = 1+x+x^2/2!+\dots$$
We can rewrite $a^x = e^{x\ln a}$, then this has taylor series:
$$a^x = e^{x\ln a} = 1+x\ln a+ x^2(\ln a)^2/2!+\dots$$
Now, if we want $a^x\geq 1+x$, this means:
$$1+x\ln a+x^2(\ln a)^2/2!+\dots \geq 1+x\implies x(\ln a-1)+x^2(\ln a)^2/2!+\dots\geq 0$$
All of the coefficients of the taylor polynomial on the left are positive if and only if $\ln a-1\geq 0\implies \ln a \geq 1$, so if $a\geq e$.
If $a<e$, then for $x>0$ the inequality won't hold.  I'm guessing it wouldn't be too bad to compute specific intervals where the inequality fails, but I'll omit this for now.
Answer: Suppose that $0<a<e$. The derivative of $f(x)=a^x$ is $f'(x)=(\ln a )a^x$.
In particular $f'(0)=\ln a<1$. Since $\ln a<(1+\ln a)/2<1$,
there is a $\delta>0$ such that
$$f(x)<f(0)+\frac{1+\ln a}2x<1+x$$
when $1<x<1+\delta$.
Comment: OP speaking: You said $f'(1)=\ln a$, but I think you mean $f'(0)$?


Arpeggiated chords: which order to play, and does it matter if it's right or left hand?

Question: In an answer here Carl Witthoft says the default is that arpeggiated chords are played from lowest to highest. Does this convention apply to both hands? E.g. in Measure 8 of the 2nd movement of this Beethoven sonatina, the arpeggiated chord is on the left hand, in which order should it be played?
Answer: Chords, by default, are arpeggiated from the lowest pitch to the highest, unless otherwise indicated, regardless which hand is playing them. This is the case with the Beethoven example in the question.
There is a symbol for downward-arpeggiated chords. It looks like the same "squiggly line", but has an arrow at the bottom, pointing downwards.

(Image source: Steinberg help)
Comment: Regardless left or right hand? (p.s. That chord with 6 notes has to be played by two hands?)
Comment: @GrandAdagio It's just illustrating the symbol. And yes, handedness doesn't matter, even if the arpeggio spans both hands.
Comment: Worth noting (!) that in a piece with arps that go up in some places, down in others, both may have arrowheads, to save confusion. Particularly in guitar music, where arps abound.
Comment: @Tim I'm hunting around for an example score, but I don't know the literature. Any suggestions?
Comment: Arpeggiated chord is the same as rolled chord? Same notation?
Comment: @GrandAdagio arpeggiation is a more general term that includes rolling. Rolled chords are typically denoted by a vertical, squiggly line.
Comment: @Aaron So I should have better titled this question "Rolled chords..."?
Comment: @GrandAdagio I think that's your call. But if you change it, I would still keep the word "arpeggiated" somewhere in the post in case that's the search term someone chooses.


Logistic regression: my main effects lose significance when I add my interaction effects. Why?

Question: I have a dichotomous dependent variable for a 2x3 experiment.  There are about 30 observations in each cell, for a total sample size of about 180.  Each person was only in one cell.  The dependent variable is 0 if they did not display a behavior and 1 if they did display a behavior.  The first independent variable has a control group and a treatment group, and the second independent variable has a control group and two treatment groups.  So Var1 is 0 for control and 1 for treatment, and Var2 is 0 for control, 1 for the first type of treatment, and 2 for the second type of treatment.
I ran a logistic regression in SPSS for just the main effect and got significant results for Var2(2) (which is the second treatment for Var2--the reference group is the control group).
I also ran a logistic regression for the main effects AND the interaction of Var1 and Var2, and the main effects go away (the interactions are not significant).
Here are my results (I changed actual variable names to this general notation for ease of use).

Why would my main effect go away if the interaction is not significant?  Does anyone have any idea on what is going on?  Do I not have a main effect, or am I interpreting the second logistic regression incorrectly?  Any help would be appreciated!
Comment: possibly related: http://stats.stackexchange.com/questions/5450/what-if-interaction-wipes-out-my-direct-effects-in-regression/5455#5455
Answer: The interpretation of your coefficient for Var2(2) in the presence of an interaction is that, that is the effect on the DV when all variables it interacts with are 0. So what you are looking at is not a main effect, but the simple effect of Var2(2) when the person is in the control condition of Var1. To get the main effects, you need to contrast code your predictors (sum to zero codes, rather than dummy codes). In SPSS Helmert coding and polynomial coding are both sum to zero codes. There may be others, but I don't have SPSS in front of me to check.
Additionally, these individual effects (Var2(1) and Var2(2)) are not main effects. They are contrast effects or simple main effects (different nomenclature, same thing). For categorical variables with more than 2 levels, the main effect is the joint effect of all contrasts (for Var2 the joint effect of both Var2(1) and Var2(2)). If you really want the main effect (you may truly only be interested in the contrasts) you need to compare your model
$$y=\beta_0+\beta_1*VAR1_1+\beta_2*VAR2_1+\beta_3*VAR2_2+\beta_4*VAR1_1*VAR2_1+\beta_5*VAR1_1*VAR2_2+\epsilon$$
against a model that removes both VAR2 variables (but leaves the interactions):
$$y=\beta_0+\beta_1*VAR1_1+\beta_4*VAR1_1*VAR2_1+\beta_5*VAR1_1*VAR2_2+\epsilon$$
The easiest way to do this is to not use categorical variables. You will need to create new numeric variables based on the categorical variables. For VAR1 the value should be -1 if control and 1 if not control. For VAR2 you will need two variables. The contrast depends on what's if interest to you, but probably you'd want the following. For VAR2(1) the value would be -2 if control and 1 if either of the treatments. For VAR2(2) the value should be 0 if control and -1 for one treatment and 1 for the other. Next, you need to create the interactions. Again there are 2. Multiply VAR1 by VAR2(1) to create one interaction, and VAR1 by VAR2(2) for the second interaction. As an aside, these are the same as the sum-to-zero contrasts I mentioned. Specifically, these are Helmert contrasts.
Then go back to the logistic regression dialogue box and use all of those variables as continuous predictors. Get your model. Then do another logistic regression that only has VAR1, Interaction1 and Interaction2. Get your model. Both results should tell what the deviance is for the model. Subtract the deviance from the first model from deviance from the second model. This a Chi-squared value. You can do a Chi-squared test with one degree of freedom and that value as your test statistic (here's an online calculator for it).
As you can see its a little complicated. There may be an easier way in SPSS. I'm not a regular user. Again, though, you may not be interested in the main effect. The main effect just tells you that VAR2 accounts for significant variance in the model. However, it doesn't tell you anything about the effect of VAR2 (does it increase your DV or decrease it). The contrasts tell you that. Since you seem to not be familiar with contrasts, I suggest you read up a bit on them. You can't interpret regression results without knowing what is going on. Here is a place to start. Here's some more. Finally, here's some reading on what a main effect is, and here's some reading on interpreting coefficients when interactions are in your model.
Also, while it is not of focal interest, your intuition about the interaction not affecting the main effect because it is not significant isn't correct. Not significantly different from 0 does not mean the interaction equals 0. Not being significant just means you don't have enough evidence to say the size of the interaction isn't 0. The interaction still picks up a chunk of variance in addition to changing how you interpret lower order coefficients.
Comment: Thank you for the fast reply (as well as the additional insight about non-significant interactions).  Is coding to sum to zero often called "Deviation Coding"--I tried that in SPSS and the main effect comes back, but I want to make sure I'm using the right thing.
Comment: I edited the original answer to get at some of your other questions. If my answer suffices, please mark it as an answer.
Comment: Thank you so much for all of the help!  I very much appreciate it!


Describing Specialization

Question: I am trying to formalize an observed trend. To simplify what I am trying to do, suppose a dataset of salesmen selling items A, B, C, D. In the year 1950, the proportion of each sold is (0.2, 0.2, 0.1, 0.5), however this shifts to (0.4, 0.1, 0.1, 0.4) in 2000 (or some other statistically significant shift) - now this can be shown with a chi-square test. Important to note, the group of salesmen in 1950 is not the same as in 2000.
Now what I would like to show is that taking into account the shift in product sales, we witness a specialization in certain products, ie whereas in 1950 salesmen would sell all products fairly equally, in 2000, salesmen increasingly focus on certain products (for example, whereas in 1950 an average salesperson may have a distribution of sales more or less representative of the sales overall - 0.2, 0.2, 0.1, 0.5; a 2000 salesperson may have 0.9 of A and 0.03 of each of the others).
I was wondering how one would go about this? Would it be appropriate to compare the top 10% of sales people in each product and show increasing discrepency in how they sell when compared to a normalized supposed salesperson? Is there a more standard way of doing this?
Any help would be very much appreciated.
Answer: Perhaps you might want to read up on diversity indices. Perhaps you've heard of the Gini index, which quantifies income inequality, or what economists know as the Hirschman-Herfindahl index to quantify market concentration (the concept appears to have been discovered first by Edward Simpson, and it's called the Simpson index in ecology). A higher Herfindahl index means more market concentration, i.e. you have one firm with most of the market share.
Or, for those of us who are familiar with latent class analysis, many of us have heard of (Shannon) entropy, which we use to describe how well-separated are the latent classes.
Example for individuals as the unit of observation
I'll give an example using normalized Shannon entropy (note: link to free article at the American Psychological Association) because I'm most familiar with it. Entropy (not normalized!) for each unit of analysis (e.g. each salesperson, or each metropolitan area, etc) is given by the formula:
$E = -\sum^C_{i=1}p_i \ln p_i$
Above, $C$ indexes the number of categories of items (or latent classes, racial groups, etc). Assume that $\ln 0 = 0$.
Imagine Mrs. Chen, a very specialized salesperson, sells only item D, i.e. (0, 0, 0, 1). Her entropy is 0 under this calculation.
Now, imagine Mrs. Huang, who sells all items in equal proportion, i.e. (0.25, 0.25, 0.25, 0.25). Her value of entropy is $-4 \times 0.25 \times \ln 0.25 = 1.3863\ $, i.e. she has the maximum possible value of entropy given that you have 4 types of items to sell. You might want to normalize entropy by dividing by the maximum possible value of entropy, which is $\ln C$. Here, $\ln C = \ln 4 = 1.3863$, so Mrs. Huang's normalized entropy is 1.
Example for groups of observations or samples
In latent class analysis, we would normally calculate the normalized entropy over all observations,
$E = 1 + \frac{1}{N \ln C}\sum^N\sum^C_{i=1}p_i \ln p_i$
(Note: this is from the first formula in the link above, with notation modified to be consistent with the rest of the answer)
So, the above formula should tell you how much the entire salesforce is specialized in each year. Remember, if all individual salespeople have the exact 1950 proportion of sales, then you have one value of entropy, but you could have a situation where 50% of the salesforce was selling only product D, 20% were selling only A, etc. That would still be a pretty specialized salesforce, and you'd see that in the entropy value.
As illustrated in Budescu and Budescu (first link), the Simpson/Herfindahl index, which they call generalized variance (GV), should perform equivalently to entropy. The calculation is a bit simpler, but either should be easy enough to do. If you're in Stata, install the entropyetc package from SSC (Nick Cox, who contributes here frequently, is the author). There have to be R packages that do this also, but I can't be bothered to search for a specific one.
Comment: @Izy I have no idea. Entropy and its relatives seem to be used as a descriptive statistic, and I have yet to see an article describing the variance of entropy or its relative. I would imagine that bootstrapping could be one way to estimate the difference in entropy between the two datasets. Any others have comments?
Comment: Not to entropy per se, but to cross entropy, but I'm not sure if that could be used for this particular case.
Comment: Thanks for the mention. Sum of squared probabilities is one of many indexes associated with Corrado Gini whose work predates Simpson's. Gini is named in work on classification and regression trees. In calculating $0 \ln 0$ you aren't assuming that $\ln 0 = 0$ but rather using a convention that the first factor $0$ annihilates the entire product.  Another way of thinking about it: whatever categories don't occur in the data don't contribute to the diversity of those that do, so that if a zoo contains some cats, some dogs and no elephants, we don't include the elephants in the calculation.
Comment: Interesting approach, makes a lot of sense. So what statistical test can you then use to compare the normalised entropy for 1950 and 2000?
Comment: Maybe [this](https://en.wikipedia.org/wiki/Wilks%27_theorem) is useful for this?
Comment: @Mindcraft unfortunately, I can't quite see the connection. Wilks theorem is about the sampling distribution of the test statistic of likelihood ratio tests ($\chi^2, df =$ the difference in dimensionality). Can you relate this to entropy?
Comment: Gini index calculated as sum of squared probabilities is not the same as Gini index used in income inequality!
Answer: You are working under the assumption that every salesperson should sell every item uniformly, so what you want to find out is how discrepant those observations are under your assumption or what was the probability of seeing such discrepant observations.
If you want to know is how discrepant those observations are with the prior you have, then I would measure the Kullback-Leibler Divergence from those 2 distributions.
If you want to know how likely a distribution so discrepant with your observation was, then I would do a Multinomial Test.
There are other statistical tests that do the two things at once, like Kolmogorov-Smirnov Test, but they work under the assumption that the distribution is continuous, I don't think this works for your case.
Answer: Interesting question.
Taking only the top 10% of sales people in each product would mean you could only draw inferences about a particular subset of your population, so I don't think that would be a good idea unless you're mostly interested in that subset of salespeople.
As a really simple approach to test if sales have become more specialised: for each salesperson in your dataset, you could work out the proportion of sales from their best-selling product (e.g. in 2000, salesperson 1 sells mostly product A, at proportion 0.9 of their sales). Then compare these proportions between 1950 and 2000, e.g. using a t-test with a logit transformation on your proportions before you carry out the t-test (assuming that you just have data from these two years - otherwise using regression with time as your explanatory variable).

Describing Specialization


Does there always exist a prime ideal that contains $x$ but not $y$?

Question: Let $A$ be a commutative ring with unity. Say $x, y$ are two distinct elements of $A$, neither of which are nilpotent. I was wondering can we always find a  prime ideal $P$ of $A$ such that $x \in P$ and $y \not \in P$? Thank you.
Comment: Consider $A=\mathbb Z$, $x=21$, and $y=7$
Answer: No; if $x$ and $y$ differ by a unit, then they generate the same ideal, and so any prime ideal containing $x$ contains $y$, and vice-versa.
Suppose, though, that all prime ideals containing $x$ contained $y$, and vice-versa. Then $y$ is contained in all prime ideals of $A/(x)$, since the prime ideals of $A/(x)$ are the prime ideals of $A$ containing $x$. Since the intersection of all prime ideals of a ring is its nilradical, we have that $y$ is contained in the nilradical of $A/(x)$, i.e. $y \in \sqrt{(x)}$, the ideal of $A$ which is the radical of the ideal generated by $x$. If we swap $x$ and $y$, we can say that that $\sqrt{(x)} = \sqrt{(y)}$.
Comment: I should have thought about that more carefully. thank you. If $D(x) = D(y)$ what can we say about $x$ and $y$ in general? Would you happen to know? $D(x)$ is all the primes that does not contain $x$... I wanted to deduce $x = y$ somehow..
Comment: I have edited my answer to explain a condition which we can deduce from this; does this help?
Comment: Yes, it does. Thank you!
Comment: Thank you for your help, in case you are interested this is the question I was trying to deduce by asking this question..  https://math.stackexchange.com/questions/3430217/two-projections-of-a-ring-which-define-the-same-set-theoretic-map-of-the-the-spe


Drupal blocks not showing up

Question: I am editing a site someone else built for my small nonprofit organization, and as you will see, I know very little about working with drupal (or anything beyond basic HTML, really.) I apologize in advance for that and will be so appreciative if anyone can help me.
I am trying to fix a problem. I am trying to add a listed page to a block, and the block is now not showing up on any pages it was previously associated with. When I went into a different block and tried to add a page, that block also stopped showing up. (You can see an example here: http://africaid.com/upcomingevents -- the left hand side block has disappeared.)
I am wondering if the problem is related to two warning messages. The first, on the "Administer" home page, says "One or more problems were detected with your Drupal installation. Check the status report for more information."
When I go to list content, I get the following message:
strict warning: Non-static method view::load() should not be called statically in /home/africaid/public_html/sites/all/modules/views/views.module on line 843.
strict warning: Declaration of views_plugin_display::options_validate() should be compatible with views_plugin::options_validate(&$form, &$form_state) in /home/africaid/public_html/sites/all/modules/views/plugins/views_plugin_display.inc on line 1877.
strict warning: Declaration of views_plugin_display_page::options_submit() should be compatible with views_plugin_display::options_submit(&$form, &$form_state) in /home/africaid/public_html/sites/all/modules/views/plugins/views_plugin_display_page.inc on line 481.
strict warning: Declaration of views_handler_field_broken::ui_name() should be compatible with views_handler::ui_name($short = false) in /home/africaid/public_html/sites/all/modules/views/handlers/views_handler_field.inc on line 641.
strict warning: Declaration of views_handler_field_user::init() should be compatible with views_handler_field::init(&$view, $options) in /home/africaid/public_html/sites/all/modules/views/modules/user/views_handler_field_user.inc on line 48.
strict warning: Declaration of views_handler_sort_broken::ui_name() should be compatible with views_handler::ui_name($short = false) in /home/africaid/public_html/sites/all/modules/views/handlers/views_handler_sort.inc on line 82.
strict warning: Declaration of views_handler_filter::options_validate() should be compatible with views_handler::options_validate($form, &$form_state) in /home/africaid/public_html/sites/all/modules/views/handlers/views_handler_filter.inc on line 585.
strict warning: Declaration of views_handler_filter::options_submit() should be compatible with views_handler::options_submit($form, &$form_state) in /home/africaid/public_html/sites/all/modules/views/handlers/views_handler_filter.inc on line 585.
strict warning: Declaration of views_handler_filter_broken::ui_name() should be compatible with views_handler::ui_name($short = false) in /home/africaid/public_html/sites/all/modules/views/handlers/views_handler_filter.inc on line 609.
strict warning: Declaration of views_handler_filter_boolean_operator::value_validate() should be compatible with views_handler_filter::value_validate($form, &$form_state) in /home/africaid/public_html/sites/all/modules/views/handlers/views_handler_filter_boolean_operator.inc on line 128.
strict warning: Declaration of views_bulk_operations_plugin_style::options() should be compatible with views_object::options() in /home/africaid/public_html/sites/all/modules/views_bulk_operations/views_bulk_operations_plugin_style.inc on line 280.

If anybody can help me with this, I will be grateful for eternity.
Thank you,
Ashley
Answer: I'm making a few assumptions, the main one being that you're using Drupal 6...
Basically your PHP error reporting settings include E_STRICT compliance, and the code in the version of Views you've got installed isn't compatible with it. D6, and subsequently the associated version of Views, was written for PHP4 and PHP5, and as such isn't compatible with E_STRICT.
You can either

Disable E_STRICT error reporting in your php.ini/other php conf file (if you're not sure how to do this, get whoever administers your server to do it - it'll make sense to them). Or
Apply the patch in this issue (comment #11) which will remove the problems for PHP5.3. If you have PHP5.4 installed, there's another patch in #26 to apply too.
Comment: it not related to cron, you can run cron manually at anytime.
Comment: Hi Clive, thank you so much for this answer and for trying to help. I'm the only one left to help with the site -- our original drupal programmer is gone. Is what you suggest above something an amateur (i.e. me) can do? It looks like it is Drupal 6.20. I check the "status report" and it said I haven't run a cron job in awhile. Might that be the problem? Is there a risk in manually running a cron job?
Comment: No risk in running cron, no...as for fixing it, you're probably going to need at least a bit of technical knowledge to use either of those methods. Unless you're confident of being able to back yourself out of anything that may go wrong I wouldn't attempt it. Patching would be the easier choice if you're unfamiliar with either I think
Comment: Thank you so much, Clive and Bala. Do you have any recommendations about where to find individuals familiar with Drupal who might be willing/able to help execute what you recommend above?

Drupal blocks not showing up


Applications of Positive Operator Valued Measures (POVMs)

Question: I am wondering what some applications of POVMs are in mathematics (or mathematical physics)? I am going through Berberian's 'Notes on Spectral Theory', which shows how we can write a normal operator as an integral over a spectral measure. Because it is not that much extra work, he treats operator valued integrals in generality, allowing for integration over a POVM. As it is however, I can't find any examples or motivations for integrating over POVMs.
In quantum mechanics I have come across using POVMs to represent the most general form of measurement, but in that case a POVM is defined as a series of positive operators which sum to the identity. I suppose if you allow for a continuous range of results then this sum would become an integral, but is there anything else to it?
Comment: See quantum chromatic numbers for one application
Answer: If $A$ is a bounded linear operator on a complex Hilbert space $H$ such that $\|A\| \le 1$, then there exists a positive operator measure $P$ on the unit circle $T$ such that
$$
           A^n = \int_{T} z^n dP(z),\;\;\; n=1,2,3,\cdots.
$$
Note that $P(T)=I$. This becomes an abstract moment problem.
If $A : \mathcal{D}(A)\subseteq H\rightarrow H$ is the generator of a contractive $C_0$ semigroup $T(t)$ iff there is a positive operator measure on $[0,\infty)$ such that
$$
              T(t)f = \int_{0}^{\infty}e^{-ts}dP(s)f.
$$
Note that $P[0,\infty)=I$.
A positive Borel operator measure on $\mathbb{C}$ dilates to a spectral measure. More precisely, if $P$ is a positive operator measure on $\mathbb{C}$ with $P(\mathbb{C})=I$, then there exists an auxiliary Hilbert space $K$ and an isometry $V:H\rightarrow K$ and a spectral measure $E$ with values in $\mathcal{L}(K)$ such that
$$
                     P(S) = V^*E(S)V.
$$
If $P(\mathbb{C}) \ne I$, you can renormalize to use the above result.
If $F$ is a positive operator harmonic function on the open unit disk $D$, then there is a positive operator measure $P$ on the unit circle $T$ such that
$$
              F(re^{i\theta})=\frac{1}{2\pi}\int_{0}^{2\pi}\frac{1-r^2}{1-2r\cos(\theta-\theta')+r^2}dP(\theta'), \\
   \mbox{ or } F(z) = \int_{T}\Re\left(\frac{z+w}{z-w}\right)dP(w)
$$
Using the dilation theorem, you can write $F$ as an operator expression involving the unitary operator $U=\int zdE(z)$, where $V^*EV=P$ and $E$ is a spectral measure. You find that $F$ is a positive operator function on the open unit disk $D$ iff there exists a unitary operator $U$ and $V : H \rightarrow K$ such that
$$
         F(z)  = \Re V^* \frac{zI+U}{zI-U}V
$$
That includes all scalar positive harmonic functions on the unit disk, $D$. Operator theory offers an interesting way to study harmonic functions, and these are equivalent to integral representations with respect to positive operator measures.


PhoneGap Hello World change orientation

Question: This is silly, but if I run phonegap create someApp, and then edit the config.xml file from:
<preference name="orientation" value="default" />

to
<preference name="orientation" value="landscape" />

and run on ios, nothing changes.  In fact, its locked in portrait mode.  Whats up with this?  This is a fresh app, no modifications.  Documentation says that this is all there is to it, but it does nothing.  Not finding any help anywhere else online...  Thanks in advance.
Comment: I am having exactly same issue - both cordova and phonegap 'hello world apps' with a single line of modification (as mentioned above) fail on iOS Emulator :(
Comment: just checked - works like charm in Android Emulator :(
Comment: I'm actually trying it on an iPhone 5s, so that means emulator AND real hardware both ignore this setting... I would love it if someone who has figured this out could enlighten us.
Comment: actually you can set orientation in xcode when open your ios project that can be very easy.
Answer: Check this http://plugins.cordova.io/#/package/net.yoik.cordova.plugins.screenorientation for possible solution.
I have updated the js/index.js file from the default app:
onDeviceReady: function() {
    app.receivedEvent('deviceready');
    screen.lockOrientation('landscape'); //this is the new line
},

This is just a workaround as now the app works differently on Android and iOS :(
Comment: getting rid of some meta tags (as advised for iOS7) fixed the different layout issue on Android/iOS with the use of above plugin.

PhoneGap Hello World change orientation


How to display the images stored in a list

Question: I have stored images in a list but these images cannot be displayed by using the display()
I have unzipped the images in a folder and stored these images in a list. I'm trying to see the image so I used the display() method. The system shows me there is an attribute error.
def unzip(path):
    """ return list of filenames inside of the zip folder"""
    global imglist
    imglist= []
    global namelist
    namelist= []
    with ZipFile(path, 'r') as imgzip:
        namelist = imgzip.namelist()
        for im in imgzip.infolist():
            with imgzip.open(im) as image:
                opened_image = Image.open(image)
                #display(opened_image)
                #saved_image  = opened_image.save("readonly/"+im.filename)
                imglist.append(opened_image)
        return imglist,namelist

small = 'readonly/small_img.zip'

Imlist,Nmlist=unzip(small)
display(Imlist[1])

the expected result is an RGB image but now the output is :

AttributeError: 'NoneType' object has no attribute 'seek'
Comment: What is `display()`? Does your `Imlist` contain images?
Comment: I'm using jupyternotebook and Display() is used to show the image in the output. The Imlist does contain the information about the image
Comment: if I use print(Imlist), the output is:
 [, , , ]
Answer: Data is not actually read with Image.open:

Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but the
  file remains open and the actual image data is not read from the file
  until you try to process the data (or call the load() method).

When your script leaves context manager scope (with imgzip.open(im) as image:) the zip file is closed.


Does the Bootstrap 3 Theme for Drupal meet WCAG 2.0 and ATAG 2.0 standards?

Question: I'm currently creating a new website for work and I would like our drupal website to be accessible to users with disabilities, and I wanted to know if the Bootstrap 3 Theme meets web accessibility standards like the themes Zen and Adaptive.
I wanted to confirm that the Bootstrap 3 theme is accessible before moving forward with adding content.  I did not find any information on the Bootstrap 3 page on the drupal website specifying the accessibility aspect of the theme.
Comment: Given that [this](http://www.w3.org/WAI/WCAG20/quickref/) is shortened and simplified "quick reference", and it's still damn long, I don't think it is possible to reliably answer your question. Also, you haven't specified how much A you need.
Answer: As you can see in this bugreport: https://github.com/twbs/bootstrap/pull/11757 Bootstrap aims to be WCAG compatible. But it does not claim it already is. Also, there are a lot of WCAG guidelines that are not theme-only. The very first one:

Guideline 1.1 Provide text alternatives for any non-text content so that it can be changed into other forms people need, such as large print, braille, speech, symbols or simpler language.

Obviously, theme cannot force you to comply with it.
Audit
WCAG is now, effectively, a part of law in European Union. This means that no one will claim to be WCAG compliant lightly, and specialized law / audit companies charge big bucks to give you a "WCAG compatible" document with their signature on it. From my experience, we talk about 4, 5 digits sums, if you need it for government cooperation purposes (like, you want to sell website to a city). Possibly more. Open Source projects hardly have funding for that, that's why you "did not find any information on the Bootstrap 3 page", and you will not in predictable future.
Pay from your own pocket, or use at your own risk.


How should I run a directory of CGI scripts which need PATH_INFO on Apache 2.4?

Question: With Apache 2.2 I was running Mailman's CGI web interface in a VirtualHost which had:
    <Directory "/usr/lib/cgi-bin/mailman/">
               AssignUserId www-data www-data
               AllowOverride None
               Options ExecCGI
               AddHandler cgi-script .cgi
               Order allow,deny
               Allow from all

    </Directory>
    <Directory "/var/lib/mailman/archives/public/">
               AssignUserId www-data www-data
               Options FollowSymlinks
               AllowOverride None
               Order allow,deny
               Allow from all
    </Directory>
    <Directory "/usr/share/images/mailman/">
               AssignUserId www-data www-data
               AllowOverride None
               Order allow,deny
               Allow from all
    </Directory>

    ScriptAlias "/mailman/"  "/usr/lib/cgi-bin/mailman/"

This worked fine. Recently, perhaps after an update to Apache 2.4 in Jessie (2.4.10-10+deb8u7) I am finding that I get no content from Apache. After a lot of head scratching and after debugging mailman (1:2.1.18-2+deb8u1) I find what works is to replace the ScriptAlias with a bunch of ScriptAliasMatch statements and modify Mailman to use REQUEST_URI rather than PATH_INFO since PATH_INFO is undefined. Perhaps that's because I'm ScriptAliasMatch, but if ScriptAliasMatch swallows the trailing path components that would seem to limit its usefulness.
Specifically, I hacked the site to work with the rather inelegant:
    <Directory "/usr/lib/cgi-bin/mailman/">
               AssignUserId www-data www-data
               AllowOverride None
               Options ExecCGI
               AddHandler cgi-script .cgi
               Order allow,deny
               Allow from all

    </Directory>
    <Directory "/var/lib/mailman/archives/public/">
               AssignUserId www-data www-data
               Options FollowSymlinks
               AllowOverride None
               Order allow,deny
               Allow from all
    </Directory>
    <Directory "/usr/share/images/mailman/">
               AssignUserId www-data www-data
               AllowOverride None
               Order allow,deny
               Allow from all
    </Directory>

    Alias "/mailman/images/" "/usr/share/images/mailman/"
    #       ScriptAlias "/mailman/"  "/usr/lib/cgi-bin/mailman/"
    ScriptAliasMatch "/mailman/admin/(.*)"  "/usr/lib/cgi-bin/mailman/admin"
    ScriptAliasMatch "/mailman/admindb/(.*)"  "/usr/lib/cgi-bin/mailman/admindb"
    ScriptAliasMatch "/mailman/confirm/(.*)"  "/usr/lib/cgi-bin/mailman/confirm"
    ScriptAliasMatch "/mailman/create/(.*)"  "/usr/lib/cgi-bin/mailman/create"
    ScriptAliasMatch "/mailman/edithtml/(.*)"  "/usr/lib/cgi-bin/mailman/edithtml"
    ScriptAliasMatch "/mailman/listinfo/(.*)"  "/usr/lib/cgi-bin/mailman/listinfo"
    ScriptAliasMatch "/mailman/options/(.*)"  "/usr/lib/cgi-bin/mailman/options"
    ScriptAliasMatch "/mailman/private/(.*)"  "/usr/lib/cgi-bin/mailman/private"
    ScriptAliasMatch "/mailman/rmlist/(.*)"  "/usr/lib/cgi-bin/mailman/rmlist"
    ScriptAliasMatch "/mailman/roster/(.*)"  "/usr/lib/cgi-bin/mailman/roster"
    ScriptAliasMatch "/mailman/subscribe/(.*)"  "/usr/lib/cgi-bin/mailman/subscribe"

I then patched Mailman's function that uses PATH_INFO to fall back to REQUEST_URI:
def GetPathPieces(envar='PATH_INFO'):
    path = os.environ.get(envar)
    if path is None:
        path = '/'.join(os.environ.get('REQUEST_URI').split('/')[3:]).split('?')[0]
    if path:
        if CRNLpat.search(path):
            path = CRNLpat.split(path)[0]
            syslog('error', 'Warning: Possible malformed path attack.')
        return [p for p in path.split('/') if p]
    return None

I've read the docs on ScriptAlias and mod_cgi, and tried to be sure by adding to my VirtualHost:
    AcceptPathInfo on

which didn't help. I've also looked through the extensive apache configuration for this server and didn't find anything that looked relevant.
Also seemingly not relevant but close by is a wordpress .htaccess in the DocumentRoot of the VirtualHost
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

My question is: how do I run an unmodified copy of Debian Jessie Mailman againgst Apache 2.4. Or, have I hit a bug in Apache? The Mailman behavior seems reasonable.
Comment: This is likely unrelated, but you need to update your config syntax for 2.4, especially for the `Order` and `Allow` statements. https://httpd.apache.org/docs/2.4/upgrading.html
Comment: Indeed; however I already tried to work through those.
Answer: For a Perl CGI script I use, the following configuration works with Apache 2.4.51 from SLES12, but it triggers some AH01630 ("client denied by server configuration") errors while it works:
...
<VirtualHost FQHN:443>
    DocumentRoot "/srv/www/HN"
    ...
    ScriptAlias /alias /srv/www/cgi-bin/CGI.pl
    <Location /alias>
        SetHandler perl-script
        PerlResponsehandler ModPerl::Registry
        ...
    </Location>
...
</VirtualHost>

Maybe that helps for Python, too.


Representing inner products on $\mathbb{R^n}$ using matrices

Question: I would like to ask two basic questions about inner products on $\mathbb{R^n}$:
Given an inner product $\langle u, v\rangle$ on $\mathbb{R^n}$,
1) Am I correct in thinking that the matrix $A$ with $a_{ij}=\langle e_j,e_i\rangle$ satisfies $\langle u, v\rangle=\big(Au\big)\cdot v$
$\;\;$for all $u,v\in \mathbb{R^n}$ where $e_1,\cdots, e_n$ are the standard basis vectors?
2) When is it possible to find an invertible matrix $C$ with $\langle u,v\rangle=\big(Cu\big)\cdot\big(Cv)$ for all $u,v\in \mathbb{R^n}$?
Answer: 1) Yes, see the example below (equation (1)). An inner product is always associated with a positive definite (p.d.) matrix $A$.
2) The existence of such a matrix $C$ is well known; one can even give it an upper triangular form ; it is called the Cholesky matrix, and the decomposition $A=C^TC$ is called the Cholesky decomposition of matrix $A$:  https://en.wikipedia.org/wiki/Cholesky_decomposition
Edit : Here is an example of a p.d. matrix $A$ and its Cholesky decomposition
$$A=\begin{bmatrix}1&1&1\\1&2&3\\1&3&6\end{bmatrix}=
\begin{bmatrix}1&0&0\\1&1&0\\1&2&1\end{bmatrix}\begin{bmatrix}1&1&1\\0&1&2\\0&0&1\end{bmatrix}$$
An important point, not always underlined, is that Cholesky decomposition is equivalent to the (Gauss) decomposition of a p.d. quadratic form into the sum of squares of independant linear forms. In the case of the quadratic form associated with matrix $A$, i.e.,
$$Q(x,y,z)=x^2+2y^2+6z^2+2xy+2xz+6yz=\begin{bmatrix}x&y&z\end{bmatrix}\begin{bmatrix}1&1&1\\1&2&3\\1&3&6\end{bmatrix}\begin{bmatrix}x\\y\\z\end{bmatrix} \ \ \ (1)$$
The algorithm is as follows: rank the variables (here, there is a natural order x, y z). Consider the first variable $x$ and put the polynomial in canonical form with respect to this variable, i.e., here:
$$Q(x,y,z)=(x+(y+z))^2+R(x,y)$$
where $R(x,y)$ is a polynomial in the remaining variables, and begin back the same operation on this new polynomial, this time with variable $y$, etc., ending with the final decomposition
$$Q(x,y,z)=(x+y+z)^2+(y+2z)^2+z^2$$
which can be written under the matrix form:
$$\begin{bmatrix}(x+y+z)&(y+2z)&z\end{bmatrix}
\begin{bmatrix}(x+y+z)\\(y+2z)\\z\end{bmatrix}=\begin{bmatrix}x&y&z\end{bmatrix}\begin{bmatrix}1&0&0\\1&1&0\\1&2&1\end{bmatrix}\begin{bmatrix}1&1&1\\0&1&2\\0&0&1\end{bmatrix}\begin{bmatrix}x\\y\\z\end{bmatrix} \ (2)$$
Comparison between (1) and (2) does not need commentaries.


Updated >= Drupal 8.0.5+: Rendering forms/entities programmatically on theming level

Question: There are several attempts and questions already asked about near to that topic in combination with the new Drupal core (8), but non of them came down to the bottom of the basic question. And non of them are up-to-date enough (2015) since many late changes in core arrived afterwards (2016). Answering the basic question will hopefully lead to answers for many depending questions and open HOWTO topics and could be a good basis for updated docs on drupal.org.
The basic question is:
How to programmatically render path/page based forms or any other entity bundles on the theming level to display them path independently, e.g. in blocks or other pages other than the given pages/paths of itself? And how can I find the right routing for the correct system calls or class paths for the needed preprocess functions in the new D8 core logic if I am new to D8?
The question arises from 2 points of view:

Why should a form be hard binded to a page view or fixed path? It's a page element, not a page. It should be available easely in any
other places without complicated coding struggles in a website
building CMF like Drupal on the theming level. It's part of theme
design to decide to have a form on frontpage, for example. (ok, this is arguable, I know, but in some cases it is)
From the basic structure how Drupal is build and what it tries to achieve in these times (the goal to rather build web applications
instead of classic and static websites), it should be easily
reachable to maintain such task like a form on the bottom of a
one-page site or to build a survey or render entities on unexpected
pages.

To keep with the form example:
here are some links to questions regarding this topic and I've tried already to interfere there and suggest to inform about changes in core here and there to update the posts or to link to sources:

How to programmatically render a contact form in a theme in D8
Rendering contact_form
Embed a contact form

The basic structure
.. how it works is common, mostly clear, and not so far from how it worked in D7:
You will use a preprocess_xxx() function in your D8 twig YOURTHEMENAME.theme file to call and pipe the form or entity array into the region variable array, to be able to render it via {{ var }} twig-tags in your xxx.twig file: e.g. block.html.twig or page.html.twig, since the form or entity is maybe not known in this layer (enviroment variable) by default.
Just an example (needs update and correction) of your THEMENAME.theme file:
preprocess_page(){
  $form = Drupal::routeMatch()->getParameter('contact_form'); // ???
  $message = \Drupal::entityTypeManager() // ???
  ->getStorage('contact_message')
  ->create(array(
      'contact_form' => $form->id(),
  ));
  /// ???
  $form = Drupal::service('entity.form_builder')->getForm($message);
  $variables['contact_form'] = $form;
}

Just an example page.html.twig file:

  {{ header_region }}

 ...

  {{ contact_form }}

But now comes the tricky part:
The docs are not up-to-date enough to make clear how to build the preprocess_xxx() function correctly, demonstrated with \\ ??? here. Using the demo example here as-is (atm) will cause an almost empty frontpage, only rendering html.html.twig but without the nested page.html.twig, obviously caused by a wrong coding in the preprocess function.
Somebody who tries to find updated docs or QA for that will have a hard time ...
Comment: I'm not exactly sure what you are asking in that very long question. As I've answered in multiple of the questions you mention, the entityform_block (and some others too) module does exactly this. A block that allows to display *any* entity form as a block. Currently add only, but editing existing entities would absolutely be possible too. Use it or learn from it. It has exactly the those pieces of code that you're missing.
Comment: @Berdir, well I can't disagree more. If you are not sure about what nilsun is asking about you definitely doesn't read it. He took the time to explain very clearly and in detail that he tries to collect some infos here for further documentation. And to recommend looking in some specific module-code representing some corner cases, while he tries to get a basis, is the absolutely wrong answer. Then, we can close Drupal Answers, since most of the questions can be reviewed via some other module code. And even the title says **theming level**. Not module development. Not even hard to read...
Comment: Despite of that, we agree in the community of many missing documentation @ D8 ATM and we shouldn't discourage people who try to collect informations to build docs. It takes time to write docs or detailed intro questions like this and I don't like the way you slap it, TBH. BTW: most of the mentioned questions and answers are outdated.
Comment: Let's stay nice ;) You're welcome to explain me the difference between theming level and module development. It's both PHP. You're certainly not going to be able to this just with twig without any PHP. And the way to build something with Drupal (specifically with 8), is with *blocks*. Theming is there to control how something is displayed, not what. 2 of the 3 questions are a bit older yes. But there's also http://drupal.stackexchange.com/questions/197084/how-to-place-contact-form-in-block from *today* which has a reference to two different modules that allow you to place contact/entity forms.
Comment: Oh great! For me it isn't hard to stay nice ;-) I like nice people. & I like facts. And missing docs is one. The Q was very good readable seperated by a paragraph and headline IMHO is another one. 2nd, there are many approaches how to build web apps with Drupal, that's the good thing and should not be changed by howto-religions and should not effect docs at all. 3rd, I'd never try to explain you the diff between theme & module level since you obv. can learn from reading module code ;-). But it's about users here who feel unconfident. 4th: There're scenarios where blocks doesn't make it. Then?
Comment: And I use example code from modules all the time. That doesn't make drupal answers useless. I happen to know tons of modules and maintain many myself, not everyone else does. So it's still a good place to connect the questions with those modules. Last, very long questions often have it hard because nobody bothers to read through them. Which is why I asekd what *exactly* is being asked after. Seems to be multiple things and it also implies bad practices like hardcoded, fixed page templates. That's just not how you should do things (Use blocks, use controllers, use page manager/panels, ... ).
Comment: @Berdir I understand your worries but most of the *felt* length comes from paragraphs, outlining and structured formatting for readability. The second link provides a similar long question to this topic. http://drupal.stackexchange.com/questions/187117/rendering-contact-form#comment237906_187117  I'm not sure why we discuss the length of a question which tries to sum up a topic? I'm not interested in answers of users rushing over it since this is an attempt to collect experiences for further documentation. You are welcome, feel free to provide a code example which works in a theme. Regards.
Comment: Minor part of the problem here is like often (also stated in connection with Drupal) that dev communities are friendly, invite to contribute, but some stall when it comes to documenting for understanding code structure. Because it is their daily income. Especially ascending coders stall a lot while the sobersides are smarter. Documentation is part of a movement. I have a grasp for that behaviour & I know that it is hard to balance the way how an Open Source community works. But the question here is clear, there is nothing to claim. The answer would be code or detailed explanations like below.
Answer: I'm still new to drupal but here is what i did to render a form in node.html.twig:
//file themename.theme
function themename_preprocess_node(&$variables) {
  if(isset($variables['node'])){
    $node = $variables['node'];
    if($node->getType() == 'application') {
        $message = \Drupal::entityTypeManager()
            ->getStorage('contact_message')
            ->create(array(
            'contact_form' => 'webentwickler_job', //ID(Machine name) of form
        ));
        $form = \Drupal::service('entity.form_builder')->getForm($message);
        $variables['application_form'] = $form;
    }
  }
}

//file node--application.html.twig
{{ application_form }}

Answer: The question is a feature request. Providing this feature "entity/form as a block" can be done in the core module, but usually this kind of features are first provided in contrib and later they may become part of core. There are projects to address this:
https://www.drupal.org/project/entityblock
https://www.drupal.org/project/contact_block
https://www.drupal.org/project/entityform_block
In my opinion putting the code in theming is only a short time solution, until this is solved in contrib/core. As the OP has experienced, you don't know how long it works, because this code doesn't get updated.
Comment: @nilsun I agree, there are always cases where you need to do something apart from the mainstream, which is in in D8 that every element on a page without it's own path is a block. Compare the page templates from D7 and D8.
Comment: thanks for your effort, time and links for this. You are partly right but in some cases in can become the only option to render entity bundles directly in a dedicated type-of-something.html.twig. It depends also on how the build project tries to seperate things. Lucky enough Drupal tries to keep being flexible for such decisions, which is part of its strength.
Answer:
How to programmatically render path/page based forms or any other entity bundles on the theming level to display them path independently, […]

Because in Drupal 8/7/6/…, forms do not have dedicated routes/controllers (D8) or page callbacks/paths (D7/6…). Hence they are path-dependent.
Once that is solved, then yes, you would be able to do that. For now, it's literally impossible.
See https://www.drupal.org/node/2503429
The only way you could perhaps make this work, but even then only for forms you define (and not for every form), is by defining a route where your form always POSTs to, and then setting it as the form action ($form['#action'] = 'foo'; is mapped to <form action="foo").

For now, the recommended approach to be able to put a form anywhere, is to expose it as a block. For an example, see \Drupal\search\Plugin\Block\SearchBlock and how it uses \Drupal\search\Form\SearchBlockForm.
Comment: I'm not sure I follow that argument :) Of course, the way form submission has to be implemented internally right now is *awkward*, but form *placement* is path-independant. As long as the form is somehow rendered again when doing the POST request, then it can be submitted. Can be the same page or it can be a different page.
Comment: @Wim Leers Thanks a million for the detailed explanation and the link to the issue. This gives a lot of inside to dip deeper into it.