Conducting a subgroup analysis with regression modeling

Question: I'm conducting a survival analysis using Cox Proportional Hazards regression to identify prognostic factors for cancer patients. My covariates include information such as age, sex, tumor location etc. I hypothesize that there are sex differences when it comes to how tumor location affects survival, i.e. males with tumors in a certain region of the brain survival longer than females.
I have proposed using an interaction term between sex and tumor location (sex*location) to test for sex-location heterogeneity. This means there will be a $\beta$ with a corresponding p-value and confidence interval that we can use to assess whether sex heterogeneity exists.
My colleague has proposed an alternative solution. They suggest we stratify patients by sex into male and female cohorts and then fit separate Cox regression models (still including all other covariates). We'd then see if the hazard ratios for each covariate are different between models, and if so this would establish heterogeneity.
Which procedure is the proper method to conduct a subgroup analysis to investigate sex heterogeneity? I feel that creating separate male and female models is problematic as there's no way to evaluate whether the different hazard ratios from each model are "significant" (no way to address uncertainty about estimates). Is this reasoning correct? If so, are there any circumstances when creating separate male and female models would be appropriate?
Comment: Generally, single model is better than stratified models.
Answer: Your reasoning is correct - as already commented by @user158565, a single model is generally better, as you are able to obtain a proper CI for the heterogeneity term.
Another major difference is that the interaction model constrains the differences to that term, or the intercept, while the stratum-specific approach allows different effects for each of the terms. In other words, for a binary stratifying variable, a stratified model is similar to adding the interaction on every term, ~ 1 + sex + location + A + B + sex*location + sex*A + sex*B .... This is usually not the intent, and you might end up losing a large amount of precision for the effects where no interaction was needed.
Comment: Could you explain why adding an interaction on every term could lose a large amount of precision when there is no effect there? Would you say its bad practice to add an interaction on every term when one suspects there may be sex heterogeneity but doesn't know which other terms sex interacts with?
Comment: @TomasBencomo think of it like this: you're estimating each covariate's effect on twice smaller sample size now (only men or only women instead of the entire N). Frank Harrell and Andrew Gelman wrote a lot about this, e.g. https://www.fharrell.com/post/varyor/ https://statmodeling.stat.columbia.edu/2018/03/15/need-16-times-sample-size-estimate-interaction-estimate-main-effect/
Comment: Does this twice smaller sample size affect the estimates of all coefficients or just the interaction term coefficient? I would think the smaller sample size only affects the interaction term coefficients, not the main effects. Say I don't have any clue which terms could have interactions - why not include interactions with everything, not expecting to find anything, and then focus on the main effects? Are you saying that the main effects will suffer from a loss in precision?
Comment: @TomasBencomo say our model includes an interaction between a binary variable $B$ and any other variable $X$ as $Y = \beta_X X + \beta_{BX} BX$ + some intercepts. This is the same as $Y = \beta_0 X | b=0$, $Y= \beta_1 X | b=1$. In effect, you estimate each coefficient on part of your sample, and it's up to you whether this cost is acceptable.


Relations & modular artithmetic

Question: Given the following partition on the set N:{ n being natural : n = 7k+p} , where
p= 0,1,2,3,4,5,6.
1) Find an equivalence relation ~ on the set N that partitions N into the sets mentioned in
the partitions above
Answer :  mRn iff m ≅ n(mod 7)
I didn't recognize how the answer is obtained
Comment: Please elaborate on precisely what you'd like help with.
Comment: how we got the answer ? how to think of such problems
Answer: Hint $\ $ By definition, the equivalence class of $\,n\,$ is $\ (n\ {\rm mod}\ 7) + 7\,\Bbb Z\, =\, n + 7\,\Bbb Z,\,$ and
$$m+7\,\Bbb Z = n+7\,\Bbb Z\,\iff\,  m\equiv n\!\!\pmod 7\qquad $$
Answer: The sets $$\{n \in \mathbb{N}: n=7k+p \text{ for some } k \in \mathbb{Z} \}$$ for $p \in \{0,1,\ldots,6\}$ are the equivalence classes (congruence classes) under the equivalence relation defined by $$n R m \quad\text{ if and only if }\quad m \equiv n \pmod 7.$$
We could derive formally this as follows; the equivalence class containing $a \in \mathbb{N}$ is:
\begin{align*}
[a] &= \{n \in \mathbb{N}:n \equiv a \pmod 7\} \\
    &= \{n \in \mathbb{N}:7 \text{ divides } n-a\} \\
    &= \{n \in \mathbb{N}:n-a=7r \text{ for some } r \in \mathbb{Z}\} \\
    &= \{n \in \mathbb{N}:n=7r+a \text{ for some } r \in \mathbb{Z}\} \\
    &= \{n \in \mathbb{N}:n=7k+(a \text{ mod } 7) \text{ for some } k \in \mathbb{Z}\}
\end{align*}
where $(a \text{ mod } 7)$ denotes the least non-negative residue of $a$ modulo $7$.  The last step is just a change of variables.
The possible values of $(a \text{ mod } 7)$ belong to $\{0,1,\ldots,6\}$.

Relations & modular artithmetic


Fourth Proof of the infinitude of primes in "Proofs from THE BOOK"

Question: I was gifted Proofs from THE BOOK and recently started flipping through some of the proofs.The fourth proof of the infinitude of primes (Euler's proof) has raised some questions on my end.
First Question
The proof starts by stating that for $n \leq x \leq n+1$,
$$ \log(x) \leq 1 + \dfrac{1}{2} + \cdots + \dfrac{1}{n-1} + \dfrac{1}{n} $$
And then claims
$$ \log(x) \leq \sum \dfrac{1}{m} $$
quote "where the sum extends over all $m \in \mathbb{N}$ which have only prime divisors $p\leq x$".  Why is this true?  Since 1 is not prime, isn't $\sum 1/m$ actually less than the partial sum of the harmonic series?
The proof continues...
Second Question
By the fundamental theorem of arithmetic, every such $m$ can be written as
$$ m = \prod_{p \leq x} p^{k_p} $$
and so
$$ \sum \dfrac{1}{m} = \prod_{\underset{p \leq x}{p \in \mathbb{P}}} \left( \sum_{0 \leq k} \dfrac{1}{p^k} \right) $$
Where $\mathbb{P}$ are the set of primes.  Are the product and sums commutable like that, or have I just missed some key property of primes?
Answer: First question: 1 has no prime factors, and so all of its prime factors are less than $x$ -- You can't name any counterexample, can you?
Second question: It's unrelated to commutativity. That's just plain distributivity: $a(b+c)=ab+ac$, dressed up in all those sigma's and pi's. Write a few intermediate steps and you should be able to see that.
Comment: That's a good point about 1.


Printing simple data from controller to view

Question: Currently I am learning Laravel by doing some basic tasks.
I am wanting to print data from a controller to the view for a profile page.
Current code I have for my Controller:
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;

class AccountController extends Controller
{
     $userInfo = array(
          'accountType' => 'Developer',
          'username' => 'Sys',
          'email' => 'firstname.lastname@example.com',
          'firstName' => 'Greatest',
          'lastName' => 'Forever',
          'gender' => 'M'
      );

      $posts = array(
        'fromUser' => 'Bob',
        'msg' => 'Hello World!',
        'sentTime' => '2016-07-07 18:01:00'
      );

      $friends = array(
        'Bob', 'Jim', 'Speed'
      );
}

My view currently has nothing in as things I have tried haven't worked.
Comment: Please show what you have tried.
Answer: Please read documentation:
https://laravel.com/docs/5.2/views#passing-data-to-views
You need to pass data to a view like this:
return view('your.view', ['userInfo' => $userInfo, 'posts' => $posts, 'friends' => $friends]);

Or:
return view('your.view', compact('userInfo', 'posts', 'friends'));

Then you can use these variables in a blade view:
@foreach ($friends as $friend)
    {{ $friend }}
@endforeach

Comment: The line     return view('your.view', ['userInfo' => $userInfo, 'posts' => $posts, 'friends' => $friends]);    goes inside the "class AccountController" section?
Comment: You should create action inside this class, put your logic there and add `return view` part. Please read here: https://laravel.com/docs/5.2/controllers#basic-controllers  Also, I'd really recommend you to read some Laravel book or some introduction tutorial at least.


Time varying Cox regression, adding in a mixed effect for patient

Question: I've been reading a lot of vignettes and literature on how to approach repeated-measures longitudinal data with time varying components for the purpose of time-to-event or survival analysis.
The consensus seems to be that modelling methods that allow for right and left censoring should be used (such as the $\tt{survival}$ package in R), and each 'patient' should be split up into long form, with a different row for each interval, with disjointed intervals for each row (see Fox & Weisburg or Thomas & Reyes, for example). This seems to structure the data in way that allows for row independence, since the time intervals are disjoint.
This is where my problem lies: I have a hard time understanding how (or why) these rows from the same patient are considered 'independent'. Why wouldn't we be including a random effect (or a 'frailty') for each patient, as surely the variances of these rows are possibly related somehow?
Answer: Therneau et al explain this in a vignette about time-dependent covariates and time-varying coefficients in survival analysis:

One common question with this data setup is whether we need to worry about correlated data, since a given subject has multiple observations. The answer is no, we do not. The reason is that this representation is simply a programming trick. The likelihood equations at any time point use only one copy of any subject, the program picks out the correct row of data at each time. There two exceptions to this rule:
When subjects have multiple events, then the rows for the events are correlated within subject and a cluster variance is needed.
When a subject appears in overlapping intervals. This however is almost always a data error, since it corresponds to two copies of the subject being present in the same strata at the same time, e.g., she could meet herself at a party.

Thinking about how Cox regressions work might help make this logic clearer. The analysis is done at each event time. The covariate values for the case having that event are compared against the current covariate values of all cases still at risk at that time.
If there is at most one event per individual, nothing can be done to take into account inter-individual differences in risk except insofar as they are represented in the event times and covariate values themselves. Any inter-individual differences beyond what's in the covariate values and times are necessarily confounded with those values and times.
So if there is at most one event per individual possible, breaking out separate rows for each time period for each individual is just a way of keeping track of which covariate values apply at which times during the analysis. The event times and covariate values over time are still independent among the individuals in the study.
The need for incorporating random effects or "frailties" in some designs is explained for example in this review on multilevel survival analysis:

Conventional regression models assume that subjects are independent of one another.[*] However, subjects who are nested within the same higher level unit are likely to have outcomes that are correlated with one another, thus violating the assumption of independent observations.

The article goes on to explain how groupings of subjects by hospital, geographic locations, and so forth can lead to a need to incorporate frailties into the model, to account for the lack of independence. But those aren't frailties per individual.
Individual frailties do need to be considered when the same person can have more than one event. Then the distributions of event times aren't all independent, as is required by standard Cox regression. Some way of accounting for the intra-individual correlations are required, with frailty terms a way to do that.
So if multiple events per individual are possible, or if there is some higher-level structure that should be taken into account in any analysis, your concerns are warranted. Otherwise, there is no need to worry about that particular problem as there is still independence among event times and individuals. As the vignette demonstrates, there are more than enough other things to worry about in survival analyses with time dependencies.

*If more than one event per individual is possible, then there needs to be a stronger assumption that the event times are independent, even within a subject.
Comment: @bandwagoner I've expanded the answer in an attempt to provide more intuition. With at most 1 event per individual, there is no way to account for inter-individual difference in risk except insofar as that information is contained in the event times and covariate values. That is true whether the covariate values happen to be constant over time or are time-varying. Multiple events per individual or higher-order structure to the data (e.g., patients within hospitals) lead to potential non-independence that needs to be addressed with approaches like frailty.
Comment: Yes, I saw this vignette also, thank you. I understand that it's probably the case that this is true, as it's been reiterated in many explanations. I haven't really found anything concrete as to why, though. It just doesn't make intuitive sense to me.


Add event listener to modal close

Question: In Drupal we can open a modal is two ways, either with HTML:
Open Modal

Or with JS:
let ajaxSettings = {
  url: 'node/1',
  dialogType: 'modal',
  dialog: { width: 800 },
};
let ajaxObject = Drupal.ajax(ajaxSettings);
ajaxObject.execute();

Once the modal is open I would like to attach an event to the close button so I can drop a cookie on the close event to show the visitor has seen the modal and not show it to them again.
The close button has the class ui-dialog-titlebar-close but this is added after the initial page load so to attach an event we would need a dynamic click handler such as:
$('body').on('click', '.ui-dialog-titlebar-close', function() {
    alert('close button was clicked 2');
});

However this event never fires. This ctools issue mentions the same thing and has a solution involving binding to the CToolsCloseModalBehaviors event, however that was 6 years ago and I'm using D9 with no ctools so need to find a new solution.
When I inspect the attached events on the close button I can see jquery.ui/ui/widget-min.js r() and an anonymous function in jquery.min.js. Using non minified vs would help but not sure how to do that?
Answer: In core dialog.js code I've found a following lines of code.
$(window).trigger('dialog:afterclose', [dialog, $element]);

and
$(window).trigger('dialog:beforeclose', [dialog, $element]);

Means that it is possible to assign event listener to these events using the following code sample:
$(window).on('dialog:afterclose', (e) => {
  console.log(e);
});

P.S. Just don't forget to put it into Drupal behaviors and use .once to ensure that event listeners won't attach multiple times.
Answer: The clue was seeing the Drupal's modal just uses jquery widgets. So a simple Google for "jquery widget close event" lead me to this SO answer.
So the solution is:
$('#drupal-modal').on('dialogclose', function(event) {
    alert('closed');
});

Add event listener to modal close


Prove that a prime $p$ can be represented as the difference of two cubes if and only if it is of the form $p = 3k(k+1) + 1$ for some $k$.

Question: This is a question from David Burton's Elementary Number Theory,  p. 280, under "Representation of Integers as Sums of Squares."

Prove that a prime $p$ can be represented as the difference of two cubes if and only if it is of the form $p = 3k(k+1) + 1$ for some $k$.
Comment: One observation that may be useful: The difference of two cubes is : $a^3 - b^3 = (a-b)(a^2+ab+b^2)$ which is always a composite number unless a=b+1.
Answer: As already pointed out by mathreadler, we have $a=b+1$, then:
$$p=a^2+ab+b^2=b^2+1+2b+b^2+b+b^2=3b(b+1)+1$$
So $p$ should be of the form $3k(k+1)+1$.
For the other direction, let $p = 3k(k+1)+1$. Then clearly $p=(k+1)^3-k^3$.
Comment: what about the other direction. this is an if and only proof
Comment: Thanks @user146269 for pointing out. It has been added.
Answer: Let $p$ be a positive prime $p=x^3-y^3=(x-y)(x^2+xy+y^2)\Rightarrow x-y=1$ or $x^2+xy+y^2=1$.
If $x^2+xy+y^2=1$ then the prime is $2$ with the representation $2=(1)^3-(-1)^3$ and this prime has not a such form $3k(k+1)+1$ so the prime $2$ is an exception. When $x-y=1$ the asked form is get inmediately.
Reciprocally, all integer $n$ of the forme $3k^2+3k+1$ is obviously representable as a difference of two cubes because $(k+1)^3-k^3=n$ and so is  all prime $p$ of the same form.


Installing the Media Module + WYSIWYG Module on Acquia Cloud

Question: I'm trying to get the Media module (and it's dependent WYSIWYG module) working on an Acquia Cloud environment. Normally, this isn't too bad locally but Acquia has a strange file structure that is giving me some headaches.
I have installed and activated both WYSIWYG along with Media but neither are working correctly. WYSIWYG needs CKEditor to work and wants it to be included in sites/all/libraries (outside of the normal modules folder). Acquia doesnt give you access to add in libraries like that.
Media isn't showing the library when a user accesses a content-type with an image field that use's Media's 'Media file selector' widget.
Im guessing a lot of this is due to path problems, but the only documentation Acquia has about their file structure is here (and this mostly pertains to the files folder - not core + contrib paths):
https://docs.acquia.com/cloud/files
So my question is two fold:

How do you get CKEditor into an Acquia Cloud instance with the WYSIWYG module?
Why wouldnt media show its library? Am I leaving another module out maybe? Path issue?
Answer: Short answer: turn off livedev in your Acquia Cloud dev environment.
Longer Answer: I was trying to drush my modules and do basic site building in their environment using the livedev option. But they don't let you run mkdir and scp live in their environment via CLI.
Their recommended workflow will have you add your modules/libraries locally, commit via git and then push up to their environment.


What if nid reaches the maximum ?

Question: What if my nid reaches the maximum allowed value of MySql int type
I have made a drupal.org site search that ends up Here. And also i found Integer Types (Exact Value). In an app that i am about to build is a contact manager for students. Which is supposed to pull gmail, fb contacts in future. My plan is to make each contact a node. Is it a good idea to keep each contact as separate node? Can you suggest any other brilliant mechanism to handle this?
I am worried about the overflow of nid as i made a test run using may own gmail id, which ends up in a 1025 new nodes.
I am using typical Drupal 7.14 installation.
Comment: See [here](http://dev.mysql.com/doc/refman/5.5/en/integer-types.html) : max unsigned int is 4,294,967,295. No need for complicated maths : just RTFM :D.
Comment: @NikhilMohan : look for my comment above :-)
Actually for normal `int` type, you'll have values from 0 to 2^32 − 1 or 4294967295 that is something above 4 billion. I'm doubtful that your database would go beyond that.
Comment: I checked to see that `nid` in `node` table is of type `int(10)`. That means we can have `10!` number of nodes. I don't think that your requirement might extend that value...
Comment: According to my Mac's calculator `10! = 3,628,800`
Comment: @indrock `10! number of nodes` means ? 10K ?
Comment: refer [this](http://www.mathsisfun.com/numbers/factorial.html). I'm not that good at math but I think there should at least be `10!` (or may be `10*10!`) different numbers.
Comment: @Clive, does my question make any sense? or its foolish?. Anyway what if a 1000 users provided with a screen like this? http://drupal.org/files/images/Screen%20shot%202010-09-09%20at%2010.15.44%20AM.png
Comment: @indrock, suppose i have covered `10!` whats then ?
Comment: I think it's a perfectly valid question...a site with 4 million nodes doesn't sound beyond the realms of possibility. Plus, you can't just change the int length to, say, `11` in the node table, as many other tables relate the `nid` and will still have a max int length of `10`. I'm interested to see how this one pans out
Comment: @NikhilMohan then I suppose I would change the value of `nid` to hold more values by the query `ALTER TABLE  'node' CHANGE  'nid'  'nid' INT( 15 ) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT  'The primary identifier for a node.'`

It would increase your number of values to `(15 !) - (10 !) = 1 307 670 739 200`
Comment: @indrock, have you seen Cliv's comment? I agree with him +1. you can't just change the int length to, say, 11 in the node table, as many other tables relate the nid
Comment: @Clive : I found the answer to this. Actually I was wrong considering the length of the integer as the capacity which would be stored in the column. `int(10)` means it will display width of the integers. there is an interesting [article there](http://dev.mysql.com/doc/refman/5.5/en/numeric-type-attributes.html). So, even changing the value will  not affect the existing site (i checked on my installation to confirm).
Comment: @indrock Thanks I'll have a read through that, sounds interesting
Answer: If nid reaches the maximum your site will no longer be able to create new nodes as there will be SQL errors whenever Drupal tries to insert a new nid.
Chances are though, that drupal.org will hit this limit before you do, regardless of what you're doing to your site in any useful real-world application.
If drupal.org gets anywhere close to 4 billion nodes, there definitely will be a workaround readily available for you.
Comment: Upvote for creativity in the answer.
Comment: @NikhilM would you consider marking my answer as correct?

What if nid reaches the maximum ?


Using Reflection to create a Mock of an interface that is unknown during buildtime

Question: For my ned to end testing it is important that my testassembly does not preload a shadowcopy of a dependent assembly.
Assembly T is the Testframework that loads and tests Assembly A.
Assembly A depends on interfaces defined in B.
For testing purposes i have to replace some static members in A without having them available during buildtime.
Here is some pseudo code that illustrates the dilemma i am in:
        A_assembly = Assembly.LoadFrom("A.dll");
        A_type = A_assembly.GetType("TheSingleton.Master", true);
        MethodInfo Master_Init_Info = type.GetMethod("Init", BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance);
        //before init is called some things need to be replaced
        FieldInfo semiknown = A_type.GetField("needsmocking", BindingFlags.Public | BindingFlags.Static));
        ??? mock_semiknown = MockRepository.GenerateMock<???>();
        semiknown.SetValue((???)mock_semiknown, mock_semiknown);
        //testing makes only sense if that static is replaced.
        Master_Init_Info.Invoke(null, null);

I can access the type via semiknown.FieldType but what good does
that do me? Can i use that information somehow to create the mock
and replace the static member with it?
Suppose i get the type and am able to replace the static member -
how can i build my expectancies in the mock?
Answer: You can call it by reflection
var method = typeof(MockRepository).GetMethod("GenerateMock").MakeGenericMethod(semiknown.FieldType);
var mock_semiknown = method.Invoke(null, null);


E F# G# Am Chord Progression

Question: So I have a chord progression in the key of G like
E7 D7/F# E7/G# Am
I know there's an element of tonicization here but explain the F# in between please? What am I missing? Thanks
Answer: This is simply an A minor progression. The A Melodic Minor scale is:

A B C D E F# G# A

So, seeing a progression of:

E  G# B D - E7
F# A  C D - D7/F#
G# B  D E - E7/G#
A  C  E A - Am

or whatever the exact voicings may be, is very understandable and common. Whether or not the piece modulated from G Major to A Minor, I could not say.
Comment: Don't think so though. Seeing as secondary dominants apply here, it is an A major progression:

A B C# D E F# G#

I do know that the norm is, if your target is Am, you can choose either of these:

E to Am
E7 to Am
E/G# to Am
E7/G# to Am

Just don't get the theory why the F# in between.
Comment: @tjvg1991 I am not sure why you are saying that it is an A Major progression when the defining note of the A Major triad is missing (C#) and the A Major chord is missing. Either way, the F# is the 6th degree of the A Melodic Minor scale, as noted here: https://www.basicmusictheory.com/a-melodic-minor-scale
Answer: If this is in the Key of G the D7 chord is the V (fifth) chord.
D7/F# means that you are playing F# in the bass of the D7 chord.
F# is the 3rd of the chord, and the 7th in the key of G (i.e. it is diatonic to the key).
hope that helps.
Comment: There are two things going on here. The chords and the bass line. The chords are E7 D7 E7 Am. The bass line is just an ascending line - E F# G# A. The composer could have just given the chords but wanted to specify the ascending bass line so it is given with the chords. The F# is the 3rd of the D7 chord and the composer wants that chord played with the 3rd in the base to get the ascending bass line. This will give a very different feel than having all roots in the bass. Hope that helps.
Comment: I get that. Why I don't get is why the F# when transitioning from E to Am.

E F# G# Am Chord Progression


Nested list comprehension - python

Question: Probably there is quite an easy solution for this, but I just can't seem to find it.
I have multiple names which I'm trying to join together:
dir_name = ['bseg', 'ekpo']
sys_name = ['a3p065', 'a3p100']
paths = [os.path.join(a, b) for a in (os.path.join(os.getcwd(), name) for name in sys_name) for b in dir_name]

paths gives me:
['C:path\\a3p065\\bseg', 'C:path\\a3p065\\ekpo', 'C:path\\a3p100\\bseg', 'C:path\\a3p100\\ekpo']

However I need such a format:
[['C:path\\a3p065\\bseg', 'C:path\\a3p065\\ekpo'], ['C:path\\a3p100\\bseg', 'C:path\\a3p100\\ekpo']]

Answer: Something like this? (I'm using "." for the root path, but feel free to use os.getcwd().)
import os

dir_names = ["bseg", "ekpo"]
sys_names = ["a3p065", "a3p100"]
localized_sys_names = [os.path.join(".", name) for name in sys_names]
paths = [
    [os.path.join(sys_name, dir_name) for sys_name in sys_names]
    for dir_name in dir_names
]

print(paths)

Output:
[['a3p065/bseg', 'a3p100/bseg'], ['a3p065/ekpo', 'a3p100/ekpo']]

Answer: A nesting of lists requires nested list comprehensions. One to iterate over the dir_names, and another for the sys_names. Try this:
dir_name = ['bseg', 'ekpo']
sys_name = ['a3p065', 'a3p100']
paths = [[os.path.join(a, b) for a in (os.path.join(os.getcwd(), name) for name in sys_name)] for b in dir_name]

Answer: You don't actually have a nested list comprehension; you have a single comprehension with two iterators.
Compare
[x for y in z for x in y]  # One comprehension, two iterators

with
[[x for x in y] for y in z]  # Two comprehensions, each with a single iterator

For your case, you want something modeled on the latter:
dir_name = ['bseg', 'ekpo']
sys_name = ['a3p065', 'a3p100']

paths = [[os.path.join(os.getcwd(), s, d) for d in dir_name] for s in sys_name]

Nested list comprehension - python


Always the same error : HTML2PDF

Question: (I'm french so I try to write in english)
Hello,
I just have do this little code :

<page>
<?php
include "top.php";
include "open_security.php";
?>

  <form method="post" action="genPDF.php">

Texte à l'intérieur du formulaire

      <button type="submit">Générer</button>
  </form>

</page>

The page genPDF is the basicaly code for a PDF generator :
<?php
ob_start();
    include( "test.php" );
    $content = ob_get_clean();
   require_once( __DIR__ . "/assets/html2pdf/html2pdf.class.php");
    try
    {
        $html2pdf = new HTML2PDF("P", "A4", "fr");
        //$html2pdf->setModeDebug();
        $html2pdf->setDefaultFont("Arial");
        $html2pdf->writeHTML($content);
        $html2pdf->Output("votre_pdf.pdf");
    }
    catch(HTML2PDF_exception $e) {
        echo $e;
        exit;
    }
?>

SO, when i click on the button, I have always the same error :
ERREUR n°4
Fichier : /var/www/html/assets/html2pdf/_class/parsingHtml.class.php
Ligne : 119

Code HTML non valide, les balises ne sont pas fermées dans le bon ordre.
Etat :
Array
(
    [0] => page
    [1] => section
    [2] => section
    [3] => section
)

HTML : ...Générer</button> </form> </page>  </page>...

Can you help me ? I realy don't understand why it doesn't work :/
Thanks for your help
Answer: The error occurs because your tags are not closed properly.  If you can look at the raw html output, you will find the third
 tag has no closing tag
 or, more likely, there is a child element directly below this
 tag which is not closed, perhaps around <button></button>.  Do some digging.  Look at Line 119 and see if there is an open, not closed or poorly formatted html structure present, or missing.  The smallest thing can mess it up.  I have even had errors using  segments ( still works though).  If you get really frustrated, break down the content output, starting blank and adding properly closed html blocks back in until html2pdf spits out an error.  Voila! You will find the problem code.
html2pdf requires properly formatted html or it gives this error.

Always the same error : HTML2PDF


No results returned when using IN(SELECT....) mySQL query

Question: Further to an earlier question related to fetching all child category id's, I used this query to pull in a list of all valid categories_id.
SELECT categories_id
FROM (SELECT * FROM categories ORDER BY categories_id)
products_sorted, (SELECT @pv := '151') initialisation
WHERE find_in_set(parent_id, @pv)
AND length(@pv := concat(@pv, ',', categories_id))

This query alone works fine.
I then took a simple query to check if a product had been added to the database today
SELECT * FROM products
WHERE DATE(products_date_added) = DATE(NOW())

The final piece of the puzzle is to check if the master_categories_id of any of the returned products matched the categories_id's returned in the first query. So I tried
SELECT * FROM products
WHERE DATE(products_date_added) = DATE(NOW())
AND master_categories_id
IN(SELECT categories_id AS master_categories_id
FROM (SELECT * FROM categories ORDER BY categories_id)
products_sorted, (SELECT @pv := '151') initialisation
WHERE find_in_set(parent_id, @pv)
AND length(@pv := concat(@pv, ',', categories_id)))

I don't get an error, I just get zero results even though I know some products have a master_categories_id that exists in the other query.
What have I done wrong?
Comment: That kind of use is why @/session variables get a bad reputation.
Comment: You're missing a `)` after `DATE(NOW()`
Comment: You really don't like JOINs do you? See https://meta.stackoverflow.com/questions/333952/why-should-i-provide-an-mcve-for-what-seems-to-me-to-be-a-very-simple-sql-query
Comment: Are you sure the products that have one of those master categories were added today?
Comment: If you're using a recent version of MySQL, you might want to look into CTEs for your recursive querying needs, instead of session variable abuse.Your session variable use assumes WHERE processes rows in an order that is no way guaranteed or implied.
Comment: @Barmar. Sorry, Missed the ) when copy/pasting into the question. And yes, products were added today. It displays several without limiting master_categories_id
Comment: @strawberry. MySQL is not my field at all which is why I came here asking for help. Joins confuse the heck out of me. I usually deal with php, but was asked to look at this as a favour. Thankfully I made no promises!
Comment: @uueerdo, that comment needs to be directed to the person who's answer has got 186 upvotes and led me to use that sql command in the first place.
Comment: @Steph3071 I just looked up the answer that I believe you are referencing; the poster who supplied it also cautioned on it's reliability and mentioned the lack of any documented guarantee.
Answer: You should write it as a join rather than WHERE ... IN, as the order of reassignment of the @pv variable is probably wrong when it's used in the WHERE clause repeatedly.
SELECT DISTINCT p.* FROM products AS p
JOIN (
    SELECT categories_id AS master_categories_id
    FROM (SELECT * FROM categories ORDER BY categories_id)
    products_sorted, (SELECT @pv := '151') initialisation
    WHERE find_in_set(parent_id, @pv)
    AND length(@pv := concat(@pv, ',', categories_id))
) AS c
ON c.master_categories_id = p.master_categories_id
WHERE DATE(p.products_date_added) = DATE(NOW())

Joining with the subquery should just execute it once, just as when you use the query by itself.
Comment: Works perfectly. I'll try to use JOIN on similar queries in future to see if it's increased my understanding of ho they work
Comment: It will also often improve performance. MySQL is notorious for poor optimization of `WHERE column IN (SELECT ...)`


Proving the intersection of two partially ordered sets is a partially ordered set - transitivity

Question: I need to prove that if $R,S$ are both partially ordered sets (POsets)
then $R \cap S$ is a POsets as well.
I got stuck while proving it is transitive:
let $<a,b>,<b,c> \in R\cap S$  then, WLOG, $<a,b>,<b,c> \in R$
and thus $<a,c> \in R$ because R is a POSet.
Similarly $<a,c> \in S$ and thus $<a,c> \in R \cap S$
Is it considered a proof of transitivity? Are there any mistakes along the way?
Comment: Only mistake: Please strike out WLOG
Answer: I think you mean that $R$ and $S$ are both partial orders on some set $X$, so that $X$ is the partially ordered set, not $R$ and $S$ themselves.
It's fine, apart from one slight misuse of language. You don't actually mean 'without loss of generality', since you're not picking just one of the alternatives and saying that it doesn't matter which one is picked: you're picking both and observing that $\langle a,b\rangle$ and $\langle b,c\rangle$ are both in both $R$ and $S$. Thus, you can apply transitivity of both $R$ and $S$ to conclude, as you did, that $\langle a,c\rangle$ is in both $R$ and $S$ and hence in their intersection. Drop the WLOG, and you're fine.


Conditional Forwarding to an external doman causes Email Sending to that domain to fail

Question: My company (@abc.com) is in the process of merging its operation with another one (@xyz.com) and both are Microsoft shops with Exchange 2010 SP3.
The 2 networks are linked by an IPSEC tunnel.
We set up DNS conditional forwarding on each side.
In @abc.com network, we conditionally forward all DNS @xyz.com hostname request to @xyz.com internal DNS Server
In @xyz.com network, we conditionally forward all DNS @abc.com hostname request to @abc.com internal DNS Server
We then allow TCP/UDP 53 to flow through the IPSEC tunnel.
After that, we found out that in @abc.com, when we try to send email to email@example.com, the emails are all stuck in the queue viewer of the Edge server with no error code.
1) In @abc.com, I went to the Edge server, in EMC / Edge Transport / Properties / External DNS Lookups, the DNS servers are all valid external DNS servers.  I did NSLOOKUP on the Edge server and was able to resolve external @xyz.com nicely.
2) I turned on verbose for Protocol Logging of the Send Connectors but the SMTPSend file does not record anything stuck in the queue.
3) I have a feeling that the Edge Server disregards the External DNS lookups and go straight to the conditional forwarder to get this the internal MX record of @xyz.com instead.  Because internally @xyz does not have any MX record and so it was therefore stuck in the queue.
Any thoughts?
Comment: Is the relevant Send Connector configured to use the DNS lookup settings on the transport server?
Comment: @joeqwerty, let me check when I get back to the office.  BTW, what is the difference between the two options: 1) use domain name system DNS MX records to route mail automatically 2) Use the External DNS lookup settings on the transport server?
Comment: @joeqwerty, I checked the send connector called "EdgeSync - Default-First-Site-Name to Internet", the first option is checked which says "use domain name system DNS MX records to route mail automatically (Enable Domain Security Mutual Auth TLS) which I don't really understand what it means.
Answer: Hi,
To satisfy your requirement, I suggest you that create a forest trust between xyz.com and abc.com and then create cross-forest send connectors.
More details about how to configure forest trust and cross-forest send connectors: Create a one-way,outgoing,forest trust & Configure a cross-forest Send connector
Best regards,
Ivan Wang
Answer: Please refer to the link below for the solution
https://social.technet.microsoft.com/Forums/exchange/en-US/2b34183b-5069-4959-8bac-4e5ef05d32f6/dns-conditional-forwarding-and-email-stuck-in-queue-viewer?forum=exchange2010#e26d774d-7343-4fb2-92f1-37db3ecc4bf6


MVC3 ASP.NET Can I reload my view when validating a form nested within a partial view?

Question: I have a partial view that I'm using on my index page to display a form. When an item is selected from a dropdown menu on the index page, the partial view is loaded with corresponding form data. I need to validate the form when submitted, but I'm not sure what to return from my controller that will load the page correctly when displaying errors. My submit button is currently on my partial view. (I tried moving the submit to the Index page, but it did not return anything from the form.) If there are validation errors, the partial view loads, but the dropdown menu from the Index view does not. I've seen a few solutions to this issue but none have worked in this situation, probably due to the dropdown. Any help is greatly appreciated. Please let me know if the HTML would be helpful, I was having issues formatting it for this post.
Controller:
public class PrinterSettingsController : Controller
{
    public ActionResult Index()
    {
        ViewBag.Areas = db.Areas.ToList();
        PopulateDocumentTypeViewBag();
        return View();
    }

    public ActionResult AreaDocumentSettingsList(int areaId = 0)
    {
        PopulateDocumentTypeViewBag();

        //get area, contains list of document settings
        }

        return PartialView("_AreaDocumentSettingsList", selectedArea);
    }

    [HttpPost]
    public ActionResult AreaDocumentSettingsList(Area selectedArea)
    {

        if (IsPrinterValid(selectedArea.PrinterName) == false)
        {
            ModelState.AddModelError(string.Empty, "Incorrect printer path entered.");
        }

        if (ModelState.IsValid)
        {

            //do some stuff, save the new records to the database

            db.Entry(originalAreaRecord).CurrentValues.SetValues(selectedArea);
            db.SaveChanges();

            //if everything saves fine, go to a different page
        return RedirectToAction("Index", "Workorder");

        }
        //if there are errors -- this part needs to be changed -- show errors in partial view, but also display view it's nested inside of

        return View("_AreaDocumentSettingsList", selectedArea);

    }

Comment: So what you are asking is how to get Index to refresh when you submit the partial view (your form)?
Comment: @cshemby Yes, right now when the page loads with validation errors, anything on the index page does not appear
Comment: Take a look at this walkthrough. Its a little more complicated that what you need but should explain well enough how to pass the partial views around. http://geekswithblogs.net/blachniet/archive/2011/08/03/walkthrough-updating-partial-views-with-unobtrusive-ajax-in-mvc-3.aspx
Answer: @cshemby's link was helpful: Updating Partial Views with Unobtrusive AJAX in MVC 3
But my problem ended up being that I was loading my partial view into a
 tag with a javascript .changed event. In order to fix this, I added a @Html.RenderPartial to the Index page for the partial view and passed the value of the dropdown back to my controller instead. That way I could reload the entire page, including the validation.


How would you show if a formula is valid in first order logic?

Question: I'm trying to understand how I can solve two particular tasks.
I need to show if the following formulas are valid:

$Pa \lor Pb \rightarrow \exists xPx$
and this one

$\forall xPx \rightarrow Pa \land Pb$

The book I'm reading from tells me that

a closed formula $\varphi$ is valid if it is true in all models $M$, otherwise it is falsifiable

But, still I didn't understand that so well.
I would appreciate if someone could show me how I can solve the two formulas above so they are valid.
Thank you.
Comment: Try negating each expression and see if you get a contradiction. If you do, they're tautologous, and tautologies are true in every model.
Comment: Type \$\varphi\$ to get $\varphi$.
Comment: @GitGud Thanks! Edited now.
Comment: (Or, if you're supposed to use model theoretic methods, think about the model with underlying set $\{a,b\}$ and about the definitions of truth for $\varphi\wedge\psi$, $\exists\alpha\varphi$, etc.)
Answer: $$\fbox{Syntactically}~^{\dagger}$$
For (1), assume $Pa \lor Pb$. Suppose $Pa$, then $\exists xPx$ (by $\exists$-introduction). Similarly for $Pb$. Since $\exists xPx$ follows from both cases, conclude $\exists xPx$ (by $\lor$-elimination based on the first assumption and the two cases). This shows that $Pa \lor Pb \vdash \exists x Px$.
For (2), assume $\forall x Px$. Then, in particular you have $Pa$ (by $\forall$-elimination). Similarly for $Pb$. Conjoin $Pa$ and $Pb$ to get the desired conclusion. This shows that $\forall x Px \vdash Pa \land Pb$.
Assuming the proof system is sound, these will imply $Pa \lor Pb \models \exists x Px$ and $\forall x Px \models Pa \land Pb$.
$$\fbox{Semantically}~^{\dagger}$$
For (1), assume some model satisfies $Pa \lor Pb$. This means that either the object denoted by 'a' is in the interpretation of the predicate 'P' or the object denoted by 'b' is. In either case, we know that the interpretation of 'P' is non-empty, therefore the model also satisfies $\exists xPx$.
For (2), assume some model satisfies $\forall x Px \equiv \lnot \exists x \lnot Px$. Suppose, for contradiction, that this model also satisfies $\lnot Pa \lor \lnot Pb$. Suppose it satisfies $\lnot Pa$, then it satisfies $\exists x \lnot Px$, but this contradicts the first assumption. Supposing that it satisfies $\lnot Pb$ similarly leads to a contradiction. Since both cases of the hypothesis lead to a contradiction, it follows that the model actually satisfies $\lnot(\lnot Pa \lor \lnot Pb)$, which is equivalent to $Pa \land Pb$.
$\dagger$ Meaning proof-theoretically and model-theoretically, respectively.
Comment: thanks alot for a great answer! I would appreciate if you also could give an helping on on my previous question which i posted here.http://math.stackexchange.com/questions/550239/help-needed-with-first-order-logic-semantics-true-or-false

Thanks again!
Comment: I'm glad you found it helpful! I have answered your other question, so let me know _there_ if you're having trouble following it or finding the relations.


How do I expand the root's volume size?

Question: I have Ubuntu Server 18.04 LTS running off a 16GB SanDisk USB pendrive in my server. From what I can remember, when I installed Ubuntu on there I had enabled LVM support. For some reason, when I ssh into my server, it says / is using 99.6% of 3.87GB, but doing sudo fdisk -l /dev/sdm says:
Disk /dev/sdm: 14.6 GiB, 15664676864 bytes, 30595072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 7DF91AEG-9DE1-43B2-A7C7-EB564B51FEB2

Device       Start      End  Sectors  Size Type
/dev/sdm1     2048     4095     2048    1M BIOS boot
/dev/sdm2     4096  2101247  2097152    1G Linux filesystem
/dev/sdm3  2101248 30593023 28491776 13.6G Linux filesystem

And output from (parted) print with /dev/sdm selected gives me:
Model: SanDisk Cruzer Glide (scsi)
Disk /dev/sdm: 15.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  2097kB  1049kB                     bios_grub
 2      2097kB  1076MB  1074MB  ext4
 3      1076MB  15.7GB  14.6GB

Running sudo df -h gives me:
Filesystem                         Size  Used Avail Use% Mounted on
udev                                12G     0   12G   0% /dev
tmpfs                              2.4G  241M  2.2G  10% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  3.9G  3.9G     0 100% /
tmpfs                               12G     0   12G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
tmpfs                               12G     0   12G   0% /sys/fs/cgroup
/dev/loop0                          90M   90M     0 100% /snap/core/6034
/dev/loop1                          90M   90M     0 100% /snap/core/6130
/dev/sdm2                          976M  155M  755M  17% /boot
tmpfs                              2.4G     0  2.4G   0% /run/user/1000
/dev/loop3                          92M   92M     0 100% /snap/core/6259

I have left out my ZFS volume above, as it's unnecessary to include it.
Running sudo vgs gives me:
  VG        #PV #LV #SN Attr   VSize  VFree
  ubuntu-vg   1   1   0 wz--n- 13.58g 9.58g

And, lastly, running sudo lvs gives me:
  LV        VG        Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  ubuntu-lv ubuntu-vg -wi-ao---- 4.00g

/dev/sdm is my root drive by the way. Any insight to this would be helpful. I do have ZFS installed managing other disks, but / is ext3 or 4.
One other thing to note is that I have LVM enabled because if my USB drive were to ever go bad I wanted to be able to restore the data to a new drive, whether it is smaller or larger than 16GB, and utilize the whole disk.
Comment: Found out that the journal logs were taking up about ~290MB. purging them using `sudo journalctl --vacuum-time=2d` gave me enough free space to perform the actions Michael suggested.
Answer: As you can see, there's about 9.58 GiB free in your volume group, so that's how much space you can add to the logical volume.
First, you can use lvextend to extend the size of the logical volume, to fill up the remaining space:
sudo lvextend --extents +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv

Now, you can resize the filesystem in that logical volume.
sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

Finally, you can see the end result:
sudo df -h /

Comment: Thank you, but I tried `sudo lvextend --extents +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv` and it says: `/etc/lvm/archive/.lvm_ubuntu-server_21283_417376161: write error failed: No space left on device`
Comment: @leetbacoon Yes, you do need at least a tiny bit of free space available to complete this. You should delete some files you don't need, such as old logs or whatever.

How do I expand the root's volume size?


Jaccard similarity of sets with approximate element matching

Question: Consider two sets like this:
A = {'hello', 'world'} and B = {'Hello', 'helo', 'goodbye'}.
I want to measure the similarity between these two sets.  There are two levels to this problem:

Comparing set elements:  How similar are "hello" and "Hello"?  This is not the subject of my question; let's assume that we have a satisfactory function $ElementSim()$ that returns a similarity between any two strings.
Comparing sets:  How similar are A and B?  The Jaccard similarity provides one solution to this problem.  Implicitly, the Jaccard similarity uses a binary $ElementSim()$; two elements $a \in A, b \in B$ are in the intersection $A \cap B$ iff $a$ and $b$ are exactly the same.

The basic Jaccard similarity of A and B is 0, but obviously you could be unhappy with this if your preferred element similarity is very not binary, like $1 >>ElementSim(hello, Hello) >> 0$.
I'm looking for a generalization $SetSim()$ of Jaccard similarity that accepts an arbitrary $ElementSim()$ function for comparing elements.  Requirements for such a similarity include, for any sets A,B,

$SetSim(A, B) \leq 1$ with equality holding iff A = B
$SetSim(A, B) \geq Jaccard(A, B)$ with equality if $ElementSim(a,b) = I(a == b)$, the indicator of exact equality.
Comment: I don't think the question is about "a variant of Jaccard similarity". It actually is about how to measure partial match between words, a totally idependent theme.
Comment: @ttnphns, you are correct that there are two independent components here.  One is the set-level similarity.  The other is the element-level similarity.  A partial match between words is an element-level similarity in my application above.  My question is about the set-level similarity, not the word-level part.  It's easy enough to normalize Levenshtein distance into a word-level similarity.
Comment: I'll edit the question to clarify this distinction.
Comment: Sides 28-32 present a soft set similarity that gives intuitive results, although it does not readily scale well to large sets, and it lacks peer review or other formal validation: https://www.first.org/resources/papers/conf2017/Measuring-Similarity-Between-Cyber-Security-Incident-Reports.pdf
Comment: As I know, extension of Jaccard similarity from binary data to quantitative data case is called Ruzicka similarity (which is also = 1-Soergel distance). If you are interested you can find formulas in "Various proximities" docx on my web page.
Comment: This includes a "Ruzicka" similarity, but it seems to assume binary equality of underlying set elements (i.e. being in the same bin; bins don't overlap halfway, unlike two words, which may match just partially): http://users.uom.gr/~kouiruki/sung.pdf
Answer: You may want to try to represent your items as a bag (or set) of N-Grams on the character level. For example, "hello" could be represented as {"hel", "ell", "llo"}. And you may apply this transformation to all the elements of your original set.
Once you've done it, you can compute the Jaccard similarity on this representaion.
Even though this is not exactly what you ask (and the other answer points you in the right direction), I still believe it can solve your problem in a computationally cheaper way.
Answer: Jaccard works with a label system, so if you want that make happen you need to do use a distance measure, like Levenshtein distance.
If you want to use Jaccard anyway, try to normalize to lowercase letters and atleast you would have a match in cases like the example.


store line in linked list (c)

Question: I think that I am having some issues with how linked lists work, please bear in mind that I am not an expert with C and that I have not worked with linked lists before.
I'm trying to take a text file with a list of things and store it in a linked list. I have the following code right now:
typedef struct linked_list {
    struct linked_list *next_ptr;
    char name;
    float price1;
    float price2;
}linked_list;

struct linked_list *first_ptr;
char name_temp;

int writeList(void) {
    // read input files
    FILE *sh_list;
    sh_list=fopen("case1/shoppingList.dat", "rw");
    if (sh_list == NULL) {
        perror("Cannot open file, you seem to have something mixed up...");
        exit(8);
    }

    struct linked_list *current_ptr;
    current_ptr = first_ptr;

    while ((fscanf(sh_list, "%s", &name_temp)) !=EOF) {
        next_ptr = malloc(sizeof(linked_list));
        strcpy(name, name_temp);
        //move to next node and complete the same task
    }
};

I stopped at the //move... because I am struggling to get the code correct - my IDE is giving me errors. Similarly, I can't get it to read the variable "name" which I need to do in order to copy the string to the node.
Comment: Always specify what errors you're getting.
Comment: Don't put semi-colons after the brace at the end of a function definition.
Comment: The error I'm looking to fix is that it says "next_ptr" is an unidentified variable in the function writeList. Beyond that, I was looking for some advice for the right direction to move to get this thing stored in a linked list.
Comment: You probably need an array for the name: `char name[36];` or thereabouts (choose your size).  This needs to be in the structure; you also reference a variable `name` in the function but provide no definition of it; you also have `char name_temp;` which should (a) be inside the function and (b) should also be an array.  You should specify the size of the array minus one in the format (`"%35s"` for example).
Answer: You are getting next_ptr as undeclared because you have not delcared it.
Your code should look something like this ...
linked_list   *next_ptr;
char          name_temp[MAX_SIZE];

while ((fscanf(sh_list, "%s", &name_temp)) !=EOF) {
         next_ptr = malloc(sizeof(linked_list));
         strcpy(next_ptr->name, name_temp);
         next_ptr->next_ptr = first_ptr;
         first_ptr = next_ptr;
}

You should also make the declaration of name in linked list to be:
char      name[MAX_SIZE];

Comment: this helped a lot, that took care of all of the errors I was getting - thanks :). I'm going to keep plugging away, but in theory this will store each line in the linked list?

also, where is the best place to actually read about linked lists and their inner workings, clearly I'm not quite understanding them as well as I should be (I'm aware of this)
Answer: In your fscanf statement you specify that you're inputting a string, %s, but name_temp has type char. You're going to have to change it to a char array, like so:
char name_temp[100];

You'll have to make the array sufficiently big for your purposes. You'll also have to change the type of name:
char name[100];

The error you are getting is because name and next_ptr are part of the struct linked_list but you you have to create an instantiation of linked_list to access name. In your case, you have the current_ptr so you should change it to:
current_ptr->next_ptr = malloc(sizeof(linked_list));
strcpy(current_ptr->name, name_tmp);

Comment: do you have any idea why it's telling me that next_ptr is undeclared?
Comment: @SoFly For the same reason as why `name` was undeclared. `next_ptr` is part of a struct and you have to create an instantiation of the struct to access a copy of `next_ptr`.
Comment: they're still undeclared, so I need to create some kind of reference inside of the function to access the struct's variables?
Comment: Because `next_ptr` is not declared as a variable.  If you want to reference an element of the structure, you have to have a structure to reference:  `linked_list item; item.next_ptr = malloc(...);`.  Even with that fixed, you probably have some chicken-and-egg issues to resolve.
Answer: it should be strcpy(current_ptr->name, name_temp);
You are trying to refer to the name variable in the structure, which needs to be accessed through the current_ptr.
so similarly it should be current_ptr->next_ptr = malloc(sizeof(linked_list));
To access variable in a structure, you need to use the . operator. When you are using a pointer to a structure, then you access its variables using the ->operator.

store line in linked list (c)


How to place search query in the URL?

Question: With a lot of search engines, you can find the string you are searching in the URL.
However, http://drugcompare.destinationrx.com/Home.aspx does not let me do this. When I search something, the resulting URL is http://drugcompare.destinationrx.com/DrugCompare.aspx no matter what.
Is there any way I can find out whether I can search the website by adding something to the end of the URL, like "?query=searchstring" instead of using the form provided on the page? Basically I need a unique URL.
Comment: Does http://drugcompare.destinationrx.com/Home.aspx and  http://drugcompare.destinationrx.com/DrugCompare.aspx are your websites?? If not then how do you expect you can change their functionalities
Answer: that website you pointed at uses POST to send data for its search query which means you wont be able to see or append it on the URL bar. The reason for that is either for security or the search query it generates is a complex object or too long and does not fit in a url. websites such as search engines uses GET, with that you can append your search query in the url by following the syntax it generates.

How to place search query in the URL?


Inconsistent theory with uniformly long refutation?

Question: I understand that there are theorems in PA that necessarily require "very long" proofs; cmp. [1]. On the other hand it seems interesting to think about Life in an inconsistent world.
So is it conceivable that a (non-paraconsistent) deductive system $S$ be inconsistent, yet any proof of the statement $A\wedge\neg A$ necessarily "very long"?
(If so, then define the girth of $S$ as the minimum length of such a proof — which by explosion must be independent of $A$.)
Answer: Yes, of course it's conceivable.  Suppose we have a consistent system $S$ that has a short theorem $T$ whose shortest proof is very long.  Consider the inconsistent system $S'$ obtained from $S$ by adjoining the axiom $\neg T$.  From any proof of $A \wedge \neg A$ in $S'$ you can produce (without much increase in length) a proof of $T \implies (A \wedge \neg A)$ in $S$, and then a proof of $\neg T$ in $S$, so the original proof must have been very long.
Answer: If you add to Peano arithmetic the negation of a theorem whose shortest proof is very long, then you've got it.
There can be no finite upper bound on the ratio of the length of the shortest proof of a theorem to the length of the theorem.  Suppose there were such a bound $B$.  Then, since only finitely many sequences of characters have length less than $B$ times the length of the proposed theorem, one could search through all of them, checking each to see whether it's a proof.  Then one would have an algorithm for checking theoremhood --- a known impossibility.  The set of theorems is recursively enumerable, but not recursive.


Why doesn't netbeans 7.3 see that I've installed Java 1.7.0_21?

Question: I've recently installed netbeans 7.3 on my Mac (Lion 10.7.5, up-to-date).
At the command line, I would get:
<code>[129]$java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06-451-11M4406)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01-451, mixed mode)
</code>
Today I went to the netbeans plugin window and found 18 updates to install.  When I attempted to do this, I received a message that some of them require > Java 1.7, and I only have 1.6 (as indicated above). So I dutifully ran out to java.com and downloaded Java 1.7 Update 21 successfully.
When I run a Java version checker in various browsers I see a report that Java 1.7.0_21 is the installed version.  In addition, the Mac's Java Control Panel also indicates that 1.7.0_21-b12 is the current version.
However, upon restarting netbeans, it still has the same complaint that Java 1.6 is in use.  I've rebooted the machine and get the same result.  And, the result of 'java -version' at the command line also still shows the same result as above (1.6.0_45).
And, finally, even if I try something like:
<code>/usr/libexec/java_home -v 1.7.0_21 --exec java -version
</code>
I get:
<code>Unable to find any JVMs matching version "1.7.0_21"
</code>
I'm baffled. Does anybody have any advice on this?
Thanks.
Doug
Answer: netbeans will be using it's own version of the the JDK try this
where-can-i-set-the-jre-jdk-which-is-used-to-run-netbeans-besides-the-command-line
Comment: So, I called AppleCare and was told, "1.7.0_21 is still a high security risk, and Apple disables it.  It can be enabled, but only via the command line via 3rd party instructions.  We won't tell you how, but you can find it by searching around."  Anyway, I suspected that I didn't have a complete installation. So, after getting rid of my current installation of netbeans 7.3, I headed out to http://www.oracle.com/technetwork/java/javase/downloads/index.html and downloaded both the jdk and the jre+netbeans7.3.  Upgrades now work (except for aproxy/server error on deadlock.netbeans.org).
Comment: It appears that the thread you indicated is for somebody running on a Windows system.  I found the netbeans.conf file and that the netbeans_jdkhome is a Windows environment variable. I could be wrong, but don't think it applies.
Comment: Having upgraded to Java 1.7 after installing netbeans, I don't have to uninstall netbeans and reinstall it, do I?
Comment: You should not need to reinstall does this site help http://wiki.netbeans.org/JDKVersionAndMacOS


How can I call RestFull webservice Java use ajax html

Question: How call restfull webservice java use ajax html, I create simple webservice in java, I want to POST data into database use html ajax with call webservice java eclipse, but show error in my java program, how can I fix it my code?
This is My Entity PayrollModel
@Entity
@Table(name="payroll")
public class PayrollModel implements Serializable {

private static final long SerialVersionUID = 1L;

@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
private long idPayroll;

@Column(name="name_file")
private String nameFile;

@Column(name="status")
private String status;

@Column(name="creationdate")
private Date creationDate;

@Column(name="company_id")
private String companyId;

public long getIdPayroll() {
    return idPayroll;
}

public void setIdPayroll(long idPayroll) {
    this.idPayroll = idPayroll;
}

public String getNameFile() {
    return nameFile;
}

public void setNameFile(String nameFile) {
    this.nameFile = nameFile;
}

public String getStatus() {
    return status;
}

public void setStatus(String status) {
    this.status = status;
}

public Date getCreationDate() {
    return creationDate;
}

public void setCreationDate(Date creationDate) {
    this.creationDate = creationDate;
}

public String getCompanyId() {
    return companyId;
}

public void setCompanyId(String companyId) {
    this.companyId = companyId;
}

public static long getSerialversionuid() {
    return SerialVersionUID;
}

@Override
public String toString() {
    return "PayrollModel [idPayroll=" + idPayroll + ", nameFile=" + nameFile + ", status=" + status
            + ", creationDate=" + creationDate + ", companyId=" + companyId + "]";
}

 }

This is my Controller
@PostMapping(path="/save")
@Produces(MediaType.APPLICATION_JSON)
PayrollModel savepayroll(@RequestBody PayrollModel body) {

    body.setStatus("0");
    body.setCreationDate(new Date());
    return payrollRepoSitory.save(body);
}

This is My Html and Ajax code
<!DOCTYPE html>

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Belajar Dasar Ajax</title>

Kirim Data dengan Ajax

<form method="POST" onsubmit="return sendData()">

        Nama File
        <input type="text" id="name_file" placeholder="name file">

        Company Id

        <input type="text" id="company_id" placeholder="isi company id"></textarea>

    <input type="submit" value="Kirim" />
</form>

This is My Messages error
   org.postgresql.util.PSQLException: ERROR: null value in column "name_file" violates not-null constraint
   Detail: Failing row contains (null, 0, 2019-11-21 15:50:15.569+07, null, 32).
   at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2497) ~[postgresql-42.2.8.jar:42.2.8]
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2233) ~[postgresql-42.2.8.jar:42.2.8]
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:310) ~[postgresql-42.2.8.jar:42.2.8]
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:446) ~[postgresql-42.2.8.jar:42.2.8]
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:370) ~[postgresql-42.2.8.jar:42.2.8]
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:149) ~[postgresql-42.2.8.jar:42.2.8]
at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:124) ~[postgresql-42.2.8.jar:42.2.8]
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61) ~[HikariCP-3.4.1.jar:na]
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java) ~[HikariCP-3.4.1.jar:na]
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:197) ~[hibernate-core-5.4.8.Final.jar:5.4.8.Final]
at org.hibernate.dialect.identity.GetGeneratedKeysDelegate.executeAndExtract(GetGeneratedKeysDelegate.java:57) ~[hibernate-core-5.4.8.Final.jar:5.4.8.Final]
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:43) ~[hibernate-core-5.4.8.Final.jar:5.4.8.Final]
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3106) ~[hibernate-core-5.4.8.Final.jar:5.4.8.Final]
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3699) ~[hibernate-core-5.4.8.Final.jar:5.4.8.Final]
at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:84) ~[hibernate-core-5.4.8.Final.jar:5.4.8.Final]
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:645) ~[hibernate-core-5.4.8.Final.jar:5.4.8.Final]
at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:282) ~[hibernate-core-5.4.8.Final.jar:5.4.8.Final]
at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:263) ~[hibernate-core-5.4.8.Final.jar:5.4.8.Final]
at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:317) ~[hibernate-core-5.4.8.Final.jar:5.4.8.Final]
at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:335) ~[hibernate-core-5.4.8.Final.jar:5.4.8.Final]
at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:292) ~[hibernate-core-5.4.8.Final.jar:5.4.8.Final]
at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:198) ~[hibernate-core-5.4.8.Final.jar:5.4.8.Final]
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:128) ~[hibernate-core-5.4.8.Final.jar:5.4.8.Final]
at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:192) ~[hibernate-core-5.4.8.Final.jar:5.4.8.Final]
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:135) ~[hibernate-core-5.4.8.Final.jar:5.4.8.Final]
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:62) ~[hibernate-core-5.4.8.Final.jar:5.4.8.Final]
at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:108) ~[hibernate-core-5.4.8.Final.jar:5.4.8.Final]
at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:702) ~[hibernate-core-5.4.8.Final.jar:5.4.8.Final]
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:688) ~[hibernate-core-5.4.8.Final.jar:5.4.8.Final]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_211]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_211]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_211]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_211]
at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:368) ~[spring-orm-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at com.sun.proxy.$Proxy97.persist(Unknown Source) ~[na:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_211]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_211]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_211]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_211]
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:314) ~[spring-orm-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at com.sun.proxy.$Proxy97.persist(Unknown Source) ~[na:na]
at org.springframework.data.jpa.repository.support.SimpleJpaRepository.save(SimpleJpaRepository.java:554) ~[spring-data-jpa-2.2.1.RELEASE.jar:2.2.1.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_211]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_211]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_211]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_211]
at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:371) ~[spring-data-commons-2.2.1.RELEASE.jar:2.2.1.RELEASE]
at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:204) ~[spring-data-commons-2.2.1.RELEASE.jar:2.2.1.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:657) ~[spring-data-commons-2.2.1.RELEASE.jar:2.2.1.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:621) ~[spring-data-commons-2.2.1.RELEASE.jar:2.2.1.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:605) ~[spring-data-commons-2.2.1.RELEASE.jar:2.2.1.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) ~[spring-data-commons-2.2.1.RELEASE.jar:2.2.1.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:366) ~[spring-tx-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:99) ~[spring-tx-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) ~[spring-tx-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:178) ~[spring-data-jpa-2.2.1.RELEASE.jar:2.2.1.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93) ~[spring-aop-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at com.sun.proxy.$Proxy106.save(Unknown Source) ~[na:na]
at com.bsm.payroll.controller.PayrollController.savepayroll(PayrollController.java:64) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_211]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_211]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_211]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_211]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:888) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.27.jar:9.0.27]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-9.0.27.jar:9.0.27]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526) [tomcat-embed-core-9.0.27.jar:9.0.27]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) [tomcat-embed-core-9.0.27.jar:9.0.27]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.27.jar:9.0.27]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) [tomcat-embed-core-9.0.27.jar:9.0.27]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) [tomcat-embed-core-9.0.27.jar:9.0.27]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408) [tomcat-embed-core-9.0.27.jar:9.0.27]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-9.0.27.jar:9.0.27]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861) [tomcat-embed-core-9.0.27.jar:9.0.27]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1579) [tomcat-embed-core-9.0.27.jar:9.0.27]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.27.jar:9.0.27]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_211]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_211]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.27.jar:9.0.27]
at java.lang.Thread.run(Unknown Source) [na:1.8.0_211]

Answer: Add name attribute for your both input. And replace the following line
title to  nameFile and companyid to companyId
Comment: @UlfaHartina can post your `PayrollModel` class ?
Comment: i have do post my PayrollModel @sudhir Ojha


auth, user and other logs are empty

Question: I've a problem since the ssh logins and other info are not logged under /var/log/* (especially auth.log)
I've been reading all the questions here and there, but the configuration seems to be fine, the permission is set correctly, and I'm cross cheking with other servers of mine and conf are identical.
Note: in order to access the machine where i've to ssh the main machine than does the forwarding based on the port: e.g. ssh root@myserver -p 221 . the myserver has the conf to fowrard the 221 to the serverwithproblem:22. for the other server i still see the logs, so it couldn't be that.
Basically, I can't figure out what's going on.
here is the rsync.conf:
#  /etc/rsyslog.conf    Configuration file for rsyslog.
#
#           For more information see
#           /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html

#################
#### MODULES ####
#################

$ModLoad imuxsock # provides support for local system logging
$ModLoad imklog   # provides kernel logging support
#$ModLoad immark  # provides --MARK-- message capability

# provides UDP syslog reception
#$ModLoad imudp
#$UDPServerRun 514

# provides TCP syslog reception
#$ModLoad imtcp
#$InputTCPServerRun 514

###########################
#### GLOBAL DIRECTIVES ####
###########################

#
# Use traditional timestamp format.
# To enable high precision timestamps, comment out the following line.
#
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat

#
# Set the default permissions for all log files.
#
$FileOwner root
$FileGroup adm
$FileCreateMode 0640
$DirCreateMode 0755
$Umask 0022

#
# Where to place spool and state files
#
$WorkDirectory /var/spool/rsyslog

#
# Include all config files in /etc/rsyslog.d/
#
$IncludeConfig /etc/rsyslog.d/*.conf

###############
#### RULES ####
###############

#
# First some standard log files.  Log by facility.
#
auth,authpriv.*         /var/log/auth.log
*.*;auth,authpriv.none      -/var/log/syslog
#cron.*             /var/log/cron.log
daemon.*            -/var/log/daemon.log
kern.*              -/var/log/kern.log
lpr.*               -/var/log/lpr.log
mail.*              -/var/log/mail.log
user.*              -/var/log/user.log

#
# Logging for the mail system.  Split it up so that
# it is easy to write scripts to parse these files.
#
mail.info           -/var/log/mail.info
mail.warn           -/var/log/mail.warn
mail.err            /var/log/mail.err

#
# Logging for INN news system.
#
news.crit           /var/log/news/news.crit
news.err            /var/log/news/news.err
news.notice         -/var/log/news/news.notice

#
# Some "catch-all" log files.
#
*.=debug;\
    auth,authpriv.none;\
    news.none;mail.none -/var/log/debug
*.=info;*.=notice;*.=warn;\
    auth,authpriv.none;\
    cron,daemon.none;\
    mail,news.none      -/var/log/messages

#
# Emergencies are sent to everybody logged in.
#
*.emerg             :omusrmsg:*

#
# I like to have messages displayed on the console, but only on a virtual
# console I usually leave idle.
#
#daemon,mail.*;\
#   news.=crit;news.=err;news.=notice;\
#   *.=debug;*.=info;\
#   *.=notice;*.=warn   /dev/tty8

# The named pipe /dev/xconsole is for the `xconsole' utility.  To use it,
# you must invoke `xconsole' with the `-file' option:
#
#    $ xconsole -file /dev/xconsole [...]
#
# NOTE: adjust the list below, or you'll go crazy if you have a reasonably
#      busy site..
#
daemon.*;mail.*;\
    news.err;\
    *.=debug;*.=info;\
    *.=notice;*.=warn   |/dev/xconsole

/etc/rsyslog.d/*.conf is empty.
sshd_config is set to this:
# Logging
SyslogFacility AUTH
LogLevel INFO

the ownership of the /var/log/auth is set to root:adm . any idea where the problem is?
Comment: if i start it by using debug mode rsyslogd -dn >~/tmp/rsys.log it works. i can add messages. that's strange.
Comment: What happens if you try `logger -p auth.err test message`? Does that get logged correctly? Have you tried restarting/reloading the syslog service?
Comment: edit: the string is not in the log file
Comment: That suggests there's a problem with rsyslogd. At a glance the config looks OK. Is the rsyslogd process running? Have you tried restarting the rsyslogd service? What Linux distribution is this? Have a look at the rsyslog site for troubleshooting suggestions.
Comment: rsyslog is running (checked with service rsyslog status). version is debian jessy. i just updated it. i tried also to do a service rsyslog rotate (and deleting the auth.log file before doin so) and no file is added.
Answer: After some diggin i found that the init script checks for a file under /etc/default/rsyslog
mine was set as this
# Options for rsyslogd
# -x disables DNS lookups for remote messages
# See rsyslogd(8) for more details
RSYSLOGD_OPTIONS=""

by commenting the RSYSLOGD_OPTIONS="" (add a # at the beginning) it started working properly again!
Answer: I gave up debugging it, actually in my case rsyslogd works fine when started from command line but doesn't work properly (skips logs, doesn't log auth and user logs ever, etc)  .
I made sure permissions are ok, debugged it for 2 hours without noticing any problem except less activity than it should show (when not started from command line).
apt-get remove rsyslog
apt-get install syslog-ng

This switches out the buggy rsyslog with syslog-ng, it's a very close drop-in replacement

auth, user and other logs are empty


Many to Many WTForms Flask SQLAlchemy

Question: Boa noite!
Estou fazendo a implementação de um sistema com wtforms flask, e parei na seguinte situação: tenho CRUD produtos e um CRUD Orçamento, logo, terei items de produtos no orçamento (n:n). Nas pesquisas que realizei somente encontro exemplo de "SelectField" (combo), mas preciso de uma grid para adicionar itens de produto nesse orçamento.
Alguém teria uma orientação, exemplo ou dicas de como realizar essa implementação?
Estou com a idéia de cria uma 3 classe (ItemOrcamento), apontar as FKs (Produto e Orçamento) e tratar na codificação o CRUD de items.
Fico no aguardo, um abraço!!!
Answer: Vi que a pergunta foi feita há um tempo mas vou deixar aqui algumas sugestões.
A experiência que tive com WTForms é que ele funciona muito bem para formulários simples. Já com formulário complexos (com tabelas, conteúdo dinâmico, operações client-side - com Angular, por exemplo), eu percebi que ele se torna um limitador. As vezes você gasta muito tempo tentando sincronizar o formulário HTML com o formulário do WTForms.
Quando tenho que utilizar esses tipos de formulários mais robustos, eu utilizo alguma biblioteca client-side (Angular, por exemplo), crio o JSON no lado cliente e trato ele no server-side.
Uma outra alternativa é utilizar o conceito de Dynamic Form Composition (link) que tenta prever esse tipo de construção. Mas, ao meu ver, é bem chatinho de usar =X
Espero ter ajudado!
Comment: No fim acabei desistindo de fazer nesse formato, e passei para o Django com REST Framework. Com o Rest do Flask ficou mais fácil também!

Many to Many WTForms Flask SQLAlchemy


Get Safari to use different autocompletion on different URLs on same hostname

Question: I have a webserver publishing different services over the same SSL VirtualHost, the two most commonly used being PhpMyAdmin and Cacti. These (and others) use 'cookie' style authentication, asking user and password in an HTML form (thus not using HTTP Authentication).
Being on the same hostname, the Safari browser didn't manage too well stored passwords: if I login to one app with user foo, and then go to app two it would propose me user foo and its password in the login form. Changing just the username to bar used to be sufficient to let Safari autocomplete the correct password in its form field. Annoying, but I could live with it - usernames are short and easy to remember when compared to the passwords we use.
After the update to safari5 this seems to be no longer true: if I store in safari (actually user keychain on OSX) credentials for https://www.foobarbaz.com/app1 AND credentials for https://www.foobarbaz.com/app2 there seem to be no way for it to autocomplete both based on the url. Even editing the keychain to add the path (it will store only the hostname by default) does not help.
Is there anything I can do to let it work the way I want while still keeping everything on one hostname? Modifying anything server side is of course possible, but I can't switch apps to HTTP Auth (and not every one will support it anyway) to use different 'realms'.
Comment: Do you get the behavior you want with other browsers?
Comment: This sounds like a Superuser.com question.  The behavior you're discussing is entirely client-side, not server-side.
Comment: @tomjedrz, I'm trying to fix the issue server side if I can, before going out asking customers to change browser.

@Andy, I was in doubt too. But I can modify the server side to play nice with clients like S5, the opposite being impossible, and that made me decide for SF. But I could be wrong nonetheless..
Answer: As I understand things, in an HTTP request URI, the host is everything between the scheme (i.e. http://) and the end of the top level domain (i.e. .com/), and everything to the right of the host is the request for the host to process.
The best solution to your problem is to use sub-domains .. https://app1.foobarbaz.com/ and https://app2.foobarbaz.com. You will need to put the sub-domains in the DNS zone for the foobarbaz.com domain, and configure virtual hosts on the web server to process the requests using /app1 and /app2. Apache and IIS can both do exactly what you need without having to reconfigure the applications. You will probably have to obtain (or create) new certificates for SSL to work without the browser security errors.

Apparently this is not allowed, per a (IMHO silly) organizational policy. The OP should work to get this policy changed, because it conflicts with how the internet works.
That said, another alternative is to modify each app to deploy a specific cookie for itself, and then to look through all returned cookies to find the one for itself. How that is done depends on the platform, and is a StackOverflow question.
Comment: having different domains would have been an obvious fix, unfortunately it's not an option (per policy)
Answer: If you mean authentication using HTTP auth (as opposed to an HTML form), this works: You can make it work by setting different authentication realms along with the URL. Like this:
    <Location /abc/>
        AuthType Basic
        AuthName "Realm for ABC"
        AuthUserFile /var/www/html/domain.org/abc/.htpasswd
        require valid-user
    </Location>

    <Location /xxx/>
        AuthType Basic
        AuthName "Realm for XXX"
        AuthUserFile /var/www/html/domain.org/xxx/.htpasswd
        require valid-user
    </Location>

The interesting part is the AuthName. Safari then remembers/autocompletes the HTTP auth dialog per Realm and not only per Domain.


MongoDB convert group object to key:value (_id:count) object

Question: I have an aggregation pipeline with result like that.
[
   {
      "_id":"1621",
      "count":567
   },
   {
      "_id":"1658",
      "count":1089
   }
   ...
]

How i can convert this result into key:value pair ("_idValue": "countValue"), like this?
   {
      "1621": 567,
      "1658": 1089
      ...
   }

My pipeline is:
pipeline = [
    {'$match': {
        'date': {'$gte': start_date, '$lt': end_date}
    }},
    {
        '$group': {
            '_id': '$networkId',
            'count': {'$sum': 1}
        }
    },
    {
        '$sort': {'_id': 1}
    },

]

Comment: What happens if the id is not unique?
Comment: @WernfriedDomscheit they are unique
Answer: Add below stages after your pipeline stages,

$group by null and construct the array of key-value pair
$arrayToObject convert above formatted array to object
$repalceRoot to replace above converted object to root

pipeline = [
  // .. add your pipeline stages here
  {
    $group: {
      _id: null,
      object: {
        $push: { k: "$_id", v: "$count" }
      }
    }
  },
  {
    $replaceRoot: { newRoot: { $arrayToObject: "$object" } }
  }
]

Playground


Filter on boolean with NULL (unset) value

Question: Client wants to hide some published content from specific Views displays.
Unpublishing the content is not an option: it needs to remain accessible.
I added a boolean exclude_from_view field to several content types.
I planned to add a boolean filter to exclude content from the necessary displays if this field's value was TRUE, but I was surprised to find that when I did so, Views returned no results at all. Setting the boolean filter to NOT FALSE had the same result.
This is happening because the field has been added to the existing content without a default value, so the field returns NULL, which is neither TRUE nor FALSE. (In PHP, NULL is a "falsy" value, but apparently not to Views.)
A little research reveals that a lot of other people have complained about this problem.
Some of them think that boolean fields not set on entities should be considered FALSE, not NULL.
Others wish that NULL fields could be treated as TRUE.
Still others think that Views UI should offer filtering options for "Treat NULL as FALSE" or "Treat NULL as TRUE." (This is a cool idea but it requires patching core, which I'm not necessarily opposed to if it is the best way forward.)
What should I do?
UPDATE 2019-11-13:
Kudos to @no-sssweat for coming up with a viable workaround, which I upvoted below.
I'm still hoping for a better answer because I'm not satisfied with the user experience of the "checkboxes/radio buttons" field widget.
If I just use one value, it shows up as two radio buttons, for N/A and Yes. Adding a No option doesn't make it much better:

I think the client would really prefer a boolean checkbox, so I'm holding out for an answer that will give me that.
Answer: Just for posterity, here's the approach I ended up using:
The Field Defaults contrib module allowed me to set all null values for the new field in pre-existing content, so I was able to use the boolean checkbox I wanted.

There's no need to patch core to deal with this, because it won't happen again with newly-created content. As soon as the node is saved, the field has a sensible default value.
Answer: Interesting problem, I was able to replicate the issue.

Some of them think that Boolean fields not set on entities should be
  considered FALSE, not NULL.
Others wish that NULL fields could be treated as TRUE.

Seems like patching core catered towards your needs would make some people unhappy. Unless you add, a new option, an Is Empty (NULL) to it.

A work around solution is to use List (text) OR List (integer)
I set mine to 1 | yea
You could make it a select box by switching the field widget from list to checkboxes
Then in Views filter you just set to is none of and it will return all nodes that are not set to "yea".

OR better yet you can select Is Empty (Null)
Comment: Interesting workaround. Can't filter on NULL because after nodes are edited, the field has a value, but "Is none of" might work.
Comment: Thanks for looking at this. I found another approach (https://drupal.stackexchange.com/a/288289/80164), but your insights were worth an upvote.