Law of large numbers for non-stationary but independent process?

Question: This question is motivated by the following: Suppose we have a conditional distribution $p(Y|X)$, denoting a "channel" (in the information theory sense). Suppose we fix a particular sequence $x_1,...$, and think of it as some realization of a random sequence $X_1,...$. Then this induces a sequence of random variables $Y_1,...$, such that $Y_i$ is distributed independently by $p(Y|X=x_i)$. Note that this gives a different distribution for each $Y_i$, but nevertheless they are independent. Intuitively, $Y_1,...$ denotes a random output sequence, based on a fixed particular input sequence $x_1,...$ and where each output variable depends only on its particular input variable.
My sense is that even though the sequence is not iid, and therefore not stationary and not ergodic, there should still be a version of the law of large numbers that applies, so long as we make some not-very-restrictive assumptions on $p(Y|X)$ (maybe we need the domains to be finite?).
Is there a result analogous to the LLN for such a sequence?
Answer: The question is open-ended, but one resolution is via the notion of a conditional typical set, which is a pretty standard concept.  See, for example, Section 2.3 of these notes (which turned up as one of the top things with a google search, but the concept is standard):
https://web.stanford.edu/class/ee376a/files/2017-18/lecture_15.pdf
This is made more precise with the method of types, etc.  Assuming the alphabets of X,Y are finite.


How do I insert bar lines in mensural style in LilyPond?

Question: I'm playing with LilyPond and was attempting to typeset some of Fux's Gradus Ad Parnassum. As far as I can tell, Fux uses what LilyPond calls mensural style for note heads, clefs, time signatures, etc.; he also uses bar lines. LilyPond, conversely, does not display bar lines within the context MensuralStaff. (I realise that Fux is considerably later than the period associated with this notational style; I'm just going by the look of his scores.) Any tips? Here is my code:
lowerStaff = \new MensuralStaff = "lowerStaff" <<
  \context MensuralVoice <<
    \set Staff.forceClef = ##t
    \clef "mensural-c1"
    \time 2/2
    \relative{ a'1 a g a b c c b d cis d\breve}
  >>
>>

\paper {
  line-thickness = #(/ staff-space 5.0)
}

\score {
  <<
    \lowerStaff
  >>
  \layout {
    indent = 0.0
    line-width = 17.25\cm
    \context {
      \Score
      timing = ##f
    }
    \context {
      \MensuralVoice
      \override NoteHead.style = #'mensural
      \override Rest.style = #'mensural
      \override Flag.style = #'mensural
      \override Stem.thickness = #1.0
    }
    \context {
      \MensuralStaff
      \override KeySignature.glyph-name-alist = #alteration-mensural-glyph-name-alist
      % \override BarLine.transparent = #f
    }
  }
}

Answer: If you mean by "mensural bars" the bar lines only appearing between the systems, this snippet was taken from lilypond documentation:
global = {
  \hide Staff.BarLine % suppress barlines within the systems
   s1 s
  % the final bar line is not interrupted
  \undo \hide Staff.BarLine
   \bar "|."
}

I'm not sure, how one would integrate that into your code.
Comment: Thanks, but that's not it, I'm afraid. I'm just referring to standard bar lines, as found within the stave in modern notation.
Answer: Well, one way would be to manually add them.  You almost had the start of it:
\context {
  \MensuralStaff
  \override KeySignature.glyph-name-alist = #alteration-mensural-glyph-name-alist
  \override BarLine.transparent = ##f % Notice two pound signs
}

Then you can add the bar lines:
\relative{ a'1 \bar "|" a g a b c c b d cis d\breve}

You still have to make the bar lines thinner, and it's a pain inserting all those bar lines, but maybe it's what you have to do.
Comment: Ah, thanks very much, didn't realise the thing about the two pound signs. In the meantime I had fudged it by using the standard settings with no fancy contexts, and overriding just the styles of note head, rest, time signature, etc. But this is better.


aws_launch_configuration: timeout - last error: dial tcp :22: connectex: No connection could be made because the target machine actively refused it

Question: I have the following launch config for an auto-scaling group:
resource "aws_launch_configuration" "ASG-launch-config" {
  #name = "ASG-launch-config"  # see: https://github.com/hashicorp/terraform/issues/3665
  name_prefix = "ASG-launch-config-"
  image_id = "ami-a4dc46db" #Ubuntu 16.04 LTS
  #image_id = "ami-b70554c8" #Amazon Linux 2
  instance_type = "t2.micro"
  security_groups = ["${aws_security_group.WEB-DMZ.id}"]
  key_name = "MyEC2KeyPair"
  #user_data = <<-EOF
  #            #!/bin/bash
  #            echo "Hello, World" > index.html
  #            nohup busybox httpd -f -p "${var.server_port}" &
  #          EOF

  provisioner "file" {
  source="script.sh"
  destination="/tmp/script.sh"
  }
  provisioner "remote-exec" {
  inline=[
  "chmod +x /tmp/script.sh",
  "sudo /tmp/script.sh"
  ]
  }
  connection {
  user="ubuntu"
  private_key="${file("MyEC2KeyPair.pem")}"
  }

  lifecycle {
    create_before_destroy = true
  }
}

Error: Error applying plan:
1 error(s) occurred:

aws_launch_configuration.ASG-launch-config: timeout - last error: dial tcp :22: connectex: No connection could be made because the target machine actively refused it.

I want to run a bash script to basically install WordPress on the instances created.
the script runs fine in a resource type "aws_instance" "example"
how to troubleshoot this?
Answer: Sounds like the instance is denying your traffic. Start up an instance without the provisioning script and see if you can SSH to it using the key you provided. You may want to add verbose logging to the SSH command with -v.


Use Webform as Module Config Page?

Question: I am building a module that will create webforms for use with the Commerce Webform Order module. These must be somewhat constrained in their structure, so I have developed a form (using FAPI) to configure them.
Well, the form has become rather complex, with several "add another" fields and the like.  The Webform module handles these rather elegantly, and I'd love to use its capabilities for my module's config page, but feel that a traditional webform would be subject to error and fiddling.
The config page must look at a given webform (if specified) and use its content to pre-load values, or create fields, to allow for further settings adjustment (e.g. prices of items, additional fields, etc)
So, is it feasible to somehow invoke the webform module to create something that works like a webform but is under the control of my module?
Thanks in advance.
Comment: Building on @jrockowitz' great answer, I am finding this to be a great solution. Some elements require one to add "webform_" to the field type.

One issue: in using webform_custom_composite, I am having trouble.  The '#element" items, which render as a "" on a webform, instead render as a "" on my custom form. Adding works great, but I'd love these to be inline td's in the table row.  Any thoughts?
Answer: The Webform module just extends Drupal's Form API. Most of the elements available to a webform can be used in custom-built forms. For example, you can use the WebformMultiple element in any FAPI form.
@see https://git.drupalcode.org/project/webform/blob/8.x-5.x/src/Element/WebformMultiple.php
Comment: Yep, almost all of them are reusable. One immediate exception is computed elements that rely on a webform submission. Select other, entity references, multiple, and composites are reusable.
Comment: Btw, this deserves a post on your personal blog ;-)
Comment: To make the YAML Source editor easier, I remove the 'webform_*' suffix from all Webform specific elements.
Comment: Hold on a minute: Dou you mean I can  use every form element of Webforms for my own, custom `class FooForm extends FormBase`? (At least for the `buildForm()` part)
Comment: Wow, that's awesome, didn't know this was possible. This basically is a super-charger for core forms API, this will be very useful for my future work :-)
Comment: Trying this out with "select_other", the element is not appearing. Discovered I need to call it "webform_select_other".  I was misdirected by the YAML code!  This is a great feature

Use Webform as Module Config Page?


Central limit theorem - num random variables vs. sample size?

Question: Does the Central Limit Theorem require the number of random variables to increase to a sufficiently large number or the number of samples of each random variable to increase to a sufficiently large number?
If the number of random variables is 1 for the chi-square statistic (as an example), then the degrees of freedom is 1, and the distribution would not represent a normal distribution, no matter how many samples. However, if the number of random variables is large, it seems we would still require more than a few samples for the chi-square distribution to resemble a normal distribution.
Note: I am starting to self learn statistics, and may need some contextual info in answers.
Comment: Of possible interest: https://stats.stackexchange.com/questions/473455/debunking-wrong-clt-statement
Comment: Do you mean a situation where you write something like $X_1, X_2,X_3,...\overset{iid}{\sim} f(x)$?
Comment: Yes, that's correct
Answer: Your question shows some confusion! A sample is usually represented by a sequence of random variables iid $X_1, X_2, \dotsc, X_n, \dotsc$, where each random variable is a function from some sample space $\omega \mapsto X(\omega)$, the argument $\omega$ often omitted from the notation. So a realization is only one value, always. So $n$ in the CLT refers to the number of observations, each observation represented with one random variable.
So in your chisquare example, $n$ has nothing to do with the number of degrees of freedom $\nu$. For the iid CLT, the only assumption is that expectation and variance exists as finite numbers. Since that is the case for the chisquare distribution, the CLT applies and when the number of observations $n \to\infty$, the standardized mean converges to a normal distribution.


LINQ query to select all that don't match

Question: I have the following LINQ query that selects all the pages that have a menu associated with them. I now want to pull out all the pages that don't have a menu associated with them I.e.. all the pages in Pages that don't exist in "AssociatedPages".
var AssociatedPages = (from mm in db.MainMenus
                            join p in db.Pages on mm.MainMenuPageFK equals p.PageID
                        select p);

var unAssociatedPages = (from p in db.Pages
                            where ???
                            select p);
return View(unAssociatedPages);

I've done this before in SQL but I'm not sure on the LINQ syntax.
The setup is one MainMenu can have one too many Pages associated with it
Any help would be greatly appreciated.
Answer: Try this:
var unAssociatedPages =
    from p in db.Pages
    join mm in db.MainMenus on p.PageID equals mm.MainMenuPageFK into mms
    where !mms.Any()
    select p;

You may find that you need to pop in a couple of .ToArray() calls to improve performance.
Comment: Still a bit to learn about LINQ here! Any() was not in my vocabulary until just now. It works perfectly, thanks


Could not load file or assembly... An attempt was made to load a program with an incorrect format

Question: I am having issues with a dll that I made reference to in a visual studio website project. It works fine on my local machine. The file is in the bin folder of the project, but when I uploaded it to my web server, I get the following error.
<code>Could not load file or assembly 'phdapinet' or one of its dependencies. An attempt was made to load a program with an incorrect format.
</code>
It is almost like it can't see the file in the bin. I looked through the code VS exported when I published it, and I don't even see a reference to the file anywhere. is it just supposed to automatically check the bin folder? Or is there something I am missing.
Here is the stack trace as well.
<code>    [BadImageFormatException: Could not load file or assembly 'phdapinet' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +210
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +242
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +17
   System.Reflection.Assembly.Load(String assemblyString) +35
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +122

[ConfigurationErrorsException: Could not load file or assembly 'phdapinet' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +12761078
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +503
   System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +142
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +334
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +203
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +152
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1151

[HttpException (0x80004005): Could not load file or assembly 'phdapinet' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12881540
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12722601
</code>
Sorry I am new to asp.net and web programming, and still am trying to figure alot out.
Comment: Likely, you've uploaded the x64 version of the library to an x86 app or vice versa.
Comment: @AllanElder Both my local machine and the server are x64 though. Would that make a difference?
Comment: If you're running under IIS, then it depends on the application pool that your running under; see here http://stackoverflow.com/questions/6728339/iis-7-5-fixing-an-attempt-was-made-to-load-a-program-with-an-incorrect-format-pr
Comment: check it out https://msdn.microsoft.com/en-us/library/system.badimageformatexception(v=vs.110).aspx.it might help.check the reason for exception
Answer: Allan was correct.
It was a 32 bit file. I enabled 32 bit applications and it fixed that issue.
Answer: change publish settings:
configuration - Test(/debug/release) Any CPU


Object method is not a function

Question: TL;DR What's wrong with for (car in carList) {...} where carList is an array?
I have a class Car with a method reset(). On instantiation, a Car object adds itself to a list of cars. I want to use a method, reset() in a for loop. Here is my (cut down) code:
$(document).ready(function() {
    var carList = [];

    function Car(speed) {
        carList.push($(this));
        console.log(carList);
        ...
        this.reset = function() {
            // Does some resetting stuff
        };
    }

    car1 = new Car(0.4);
    car2 = new Car(0.1);

    for (car in carList) {
        car.reset();
    }
});

This produces an Uncaught TypeError. The console log is
> [m.fn.init[1]]
> [m.fn.init[1], m.fn.init[1]]
> Uncaught TypeError: car.reset is not a function

But if I type car1.reset() in the console, it works. Why is this?
Comment: You probably also should define the variable, `for ( var car in carList ) {`
Comment: I would be very reluctant to have the reference to `carList` in the constructor as it sets up a specific dependancy for the constructor. IMO it would be better to do this: `carList.push(new Car(0.4));`.
Answer: function Car(speed) {
    carList.push($(this));

You're jQuery-ifying the Car object for some reason, but it's not a DOM element so it doesn't make any sense.
Change it to:
function Car(speed) {
    carList.push(this);

Comment: I tried the non-jQuery-ified `push(this)` but this in itself only changes `[m.fn.init[1], m.fn.init[1]]` to `> [Car, Car]`. The error still happens unless I change my `for` syntax as Gothdo answered. But it is still necessary to use the non-jQuery-ified version, so thank you
Answer: Your loop is done wrong. It should be:
for (var i in carList) {
    carList[i].reset();
}

or, if you are using ES6:
for (var car of carList) {
    car.reset();
}

See documentation for for...in loop and for...of loops.
Also, when you push an instance of Car, you should use this instead of $(this), as @JamesMcLaughlin pointed.
Comment: Note: the latter method using ES6 is not supported by IE11 https://developer.mozilla.org/pl/docs/Web/JavaScript/Reference/Statements/for...of#Browser_compatibility
Comment: @BinaryFunt For ES6 compatibility check [kangax's compatibility table](https://kangax.github.io/compat-table/es6/).

Object method is not a function


Factoring ideal into prime ideals in $\mathbb{Z}[\sqrt{-5}]$

Question: I would like to write the ideal $(9)$ as a product of prime ideals in $\mathbb{Z}[\sqrt{-5}]$, which is a Dedekind domain. We have
$$9=3 \cdot 3=(2+\sqrt{-5})\cdot (2-\sqrt{-5}) $$
and I have shown that $3,2+\sqrt{-5},2-\sqrt{-5}$ are irreducible and not prime.
I can see that $(3)$ is not a prime ideal because $(2+\sqrt{-5}) (2-\sqrt{-5})=9 \in (3)$, but $2+\sqrt{-5},2-\sqrt{-5}\notin (3)$.
I am not sure what to do next.
Answer: This is exactly the situation that the Dedekind-Kummer theorem treats. This is given in the following two theorems from Keith Conrad's Factoring after Dedekind.
Theorem 1 (Dedekind). Let $K$ be a number field and $\alpha \in O_K$ such  that $K= \mathbb{Q}(\alpha)$. Let $f(T)$ be the minimal polynomial of $\alpha$ in $\mathbb{Z}[T]$. For any prime $p$ not dividing $[O_K:\mathbb{Z}[\alpha]]$, write
$$
f(T) \equiv \pi_1(T)^{e_1}\cdots \pi_g(T)^{e_g} \pmod{p}
$$
where the $\pi_i(T)$ are distinct monic irreducibles in $\mathbb{F}_p[T]$. Then $ (p) = p O_K$ factors into prime ideals as
$$
\newcommand{\p}{\mathfrak{p}}
(p) = \p_1^{e_1} \cdots \p_g^{e_g}
$$
where there is a bijection between the $\p_i$ and $\pi_i(T)$ such that $N(\p_i) = p^{\deg(\pi_i)}$. In particular, this applies for all $p$ if $O_K=\mathbb{Z}[\alpha]$.
He further describes how to obtain generators for the $\p_i$ in Theorem 8.
Theorem 8. In the notation of Theorem 1, when $\p_i$ is the prime ideal corresponding to $\pi_i(T)$ we have the formula $\p_i = (p,\Pi_i(\alpha))$ where $\Pi_i(T)$ is any polynomial in $\mathbb{Z}[T]$ that reduces mod $p$ to $\pi_i(T)$ mod $p$.
Returning to your problem, the minimal polynomial of $\sqrt{-5}$ is $T^2 + 5$. How does this factor mod $3$? What does this tell you about the primes ideals in the factorization of $(3)$ and their generators?


Differences in sample size when calculating weighted correlations (Pearson, Kendall-tau) in SPSS

Question: Please consider the following dataset in SPSS:
v1  v2  weight
1   3   0,50
2   2   0,50
3   4   1,00
4   5   1,00
5   3   1,00
1   3   2,00
2   2   2,00
3   .   3,00
.   5   1,00
5   4   0,50

When I calculate correlations between v1 and v2 (pairwise missing deletion) with unweighted in SPSS, I get the following results:
Pearsons r: n=8; r=0.525
Kendalls tau: n=8, t=0,334
Suppose now, I'll apply case weights to the data, provided in the "weight" column. I now get the following results:
Pearsons r: n=8,5 (due to weighting); r=0.496
Kendalls tau: n=10 (weighted), t=0,274
My question/problem is that I don't understand why there are different weighted sample sizes for the two correlations.
I understand SPSS weights as case weights, so for both correlations I was expecting a weighted sample size of 8,5, as it is indeed for Pearsons r.
Can anyone help me out here, why there is a different sample size for kendalls tau? If there is some scientific paper/website/whatsoever about that topic, I'm ready to read it on my own, but I didn't find anything useful on my own.
[Edit] Could it be that for Kendall's tau, SPSS is rounding the case weights to natural/whole numbers? In this case, we would indeed end up with n=10. But this then brings me to the question, why SPSS is doing so.
[Edit2] As suggested by Joel W., here's the SPSS syntax to reproduce what I'm doing.
Code for unweighted correlations:
CORRELATIONS
  /VARIABLES=v1 v2
  /PRINT=TWOTAIL NOSIG
  /MISSING=PAIRWISE.
NONPAR CORR
  /VARIABLES=v1 v2
  /PRINT=KENDALL TWOTAIL NOSIG
  /MISSING=PAIRWISE.

Code for weighted correlations:
WEIGHT BY weight.
CORRELATIONS
  /VARIABLES=v1 v2
  /PRINT=TWOTAIL NOSIG
  /MISSING=PAIRWISE.
NONPAR CORR
  /VARIABLES=v1 v2
  /PRINT=KENDALL TWOTAIL NOSIG
  /MISSING=PAIRWISE.

Thx,
deschen2
Comment: Perhaps it would help if we were able to see your SPSS commands.
Comment: I could provide some syntax code, of course. But I'm not sure what's the point of doing so, because calculating correlations in SPSS is straightforward and relatively unambiguous. Nevertheless, I'll update my question.
Comment: It appears that 8.5 is correct. I don't think you can have a partial weight in a Kendall's tau calculation (because it's a ratio of counts, but maybe I'm wrong). Test it with some different weights. Change a weight from 0.5 to 0.01, and another from 1.0 to 1.1, and see what happens.
Comment: You can also look at the SPSS algorithms.
Comment: Finally, SPSS is unusual (unique?) in that it allows non-integer frequency weights. I don't know of another package that allows this.
Comment: JUST sit and read the documentation (Command Syntax Reference and SPSS Algorithms) for the procedures.
Answer: I just found an answer in a SPSS forum, just to let you know: http://www-01.ibm.com/support/knowledgecenter/SSLVMB_22.0.0/com.ibm.spss.statistics.algorithms/alg_nonpar_corr.htm


How do I call an AngularJS service function inside a Redux Reducer?

Question: I need to call a angularjs function inside a Redux Reducer.
How should I do that?
The Reducer is written in node fasion:
module.exports = ...
But the Angular Js factories or services are only accessible with Angularjs Injection.
How should I access those within the Redux reducer?
Answer: There are two ways to get an AngularJS injector:
var injector = angular.injector(['ng']);

OR
var injector = angular.element(element);

For more inforation, see

AngularJS angular.injector Function API Reference
AngularJS angular.element Function API Reference - jqLite Extras


What would have to happen to break LaDanian Tomlinson's 2006 season, 31 touchdown record?

Question: In 2006, LaDanian Tomlinson set the record for total touchdowns scored (rushing and receiving) at 31.
What would need to happen to eclipse this mark?  I'm wondering about the attributes of the player.
I am assuming that it would be a running back, and not a receiving skill player.  I am assuming also that there is something about LaDanian's size, frame, and running style that made this record possible.  The other names at the top of this list are Shaun Alexander, Priest Holmes, Marshall Faulk, and Emmitt Smith.  Is it that they are all, for lack of a better descriptor, 'bowling-ball' runners - strong and hard to tackle?
Another way to answer this would be that this mark won't be eclipsed again, due to injury and the runningback-by-committee approach.
Answer: There are no attributes for a player.   There needs to be a dominant offense, a dominant defense, and an offensive coordinator that likes to run near the goal line.  And the coach can't have too much trust in their QB because RBs scoring receiving TDs is more "luck" than skill.  And then add on a bit of luck on a player lasting close to 16 games... maybe on the health concerns you can discriminate against the smallest and biggest 10-15% as they are more likely to get hurt.
So four of the guys heavily benefited from Norv Turner/Marty Schottenheimer/Dick Vermeil/Sauners or their direct disciples LT, Holmes, Faulk and Emmitt.  These guys would run the ball every play if the defense didn't blitz.   They for sure hated throwing the ball near goal line.   And to make it the perfect situation(s) in Dallas and San Diego, both teams had good QBs but not great and definitely not trusted around the goal line as a stud.   If you were playing fantasy football 20 years ago, you drafted the RBs these coaches were coaching early.
Shaun's was about the same.   Holmgren has always been a run in the redzone guy.  Him and Favre got in fights because Favre loved stat padding on 1 yard TD throws (stat check but Favre has to be on the all-time list for 3 yard and less TD throws).   So Holmgren plus Hasselbeck means big numbers for Shaun.   Let's not forget that during Shaun's three big years the Seahawks had THE BEST offensive line in football with two future HOFers (at least two).
Faulk's big season is easier.   It was a top 5 offensive line and maybe the best offense ever in the NFL (adjusted for year).   Faulk just had a ton of chances and didn't get hurt.   Martz/Vermeil did throw it a ton around the goal line, so it made the runs even easier for Faulk.
Going back to LT he was on a run first team that had a great offensive line and two pro-bowl skill players that were known for blocking - O'Neal/Gates.   But LT was arguably the best goal line runner ever.   He set records at TCU before coming to the NFL.
So to break the record you need a lot of help from coaches and teammates and probably need to be one of the best ever at RB.   LT in the list you had was the best all around back, Faulk may have been a better receiver but wasn't close as a runner... and maybe Emmitt is equal as a runner but no way at receiver.   Also didn't LT throw 2 TDs that year (I had him on my fantasy teams - draft Marty backs- so yea I know he did).
Note: This record could be broke again.   You are exactly missing it with the reasoning that it can't.   It might be harder now.   The issue is that the NFL has made passing easier.   This means more passing TDs so less running ones.   But the biggest issue is the offensive line.   If you are a road grating OL you aren't as valuable in today's NFL.   Passing is easier so GMs are more likely to draft a two-point stance 6-8" guy with super long arms than a 6-4" guy that will bowl people over.   The 49ers are a good example this year.   They run the ball really well and if they had a HOF back maybe he gets 20-25 TDs total... they purposely went out and got all of the smaller leftovers that can run block that other GMs didn't want.
Comment: Thank you for these insights.  As a favor to you I will furnish those <= 3yd TD pass stats in a bit.


how to set spark.sql.pivotMaxValues in scala?

Question: this may be a dumb question but how do i set spark.sql.pivotMaxValues when trying to pivit in databricks ? im getting this huge error  'org.apache.spark.sql.AnalysisException: The pivot column census_block_group has more than 10000 distinct values, this could indicate an error. If this was intended, set spark.sql.pivotMaxValues to at least the number of distinct values of the pivot column.;  so anybody know  how do i fix this issue ?
import org.apache.spark.sql.SQLContext

 val df = censusBlocks.toDF
df.groupBy("B08007e1").pivot("census_block_group").sum("B08008e4")
df.show()

Answer: You can set it with
spark.conf.set("spark.sql.pivotMaxValues", 10000)

Comment: But I have pivot column more than 10000.
Comment: @Salm change the 10000 to the max value you need


Slave VMs can't ping 184.108.40.206 after router VM reboot

Question: So im on the cloud and i have a vm (master) that i turned to a router for my others vms (slaves) so they can get access to the internet. For the purpose of this question we will call the master script mr.sh and the script that runs on the slaves sr.sh . After i run both scripts for the first time i can ping 126.96.36.199 from the slave vms fine. But when i reboot the master vm and then rerun the scripts i cant ping 220.127.116.11 from the slave vms. i used the traceroute command to a slave vm and this is the output:
 1  master (192.168.0.1)  0.521 ms  0.388 ms  0.364 ms
 2  * * *
 3  * * *
 4  * * *
 5  * * *
 6  * * *
 7  * * *
 8  * * *

i tried to: restart networking on all the machines, flash the ip tables and rerun the scripts, reboot the vms again and retry but with no avail any ideas why is this happening? and how to fix this?
mr.sh:
#!/bin/bash
echo "Enabling ipv4 forwarding (cleaning old rules)"
# flushing old rules -- USE WITH CARE
iptables --flush
iptables --table nat --flush
# MASQUERADE each request form the inside to the outer world
iptables -t nat -A POSTROUTING -j MASQUERADE
# enable IPv4 packet forwarding in the kernel
echo 1 > /proc/sys/net/ipv4/ip_forward
echo "Master is now operating as router"

and sr.sh:
#!/bin/bash
ENDPOINT_INTERFACE=$(cat /etc/hosts | grep master | awk '{print $1}')
route add default gw $ENDPOINT_INTERFACE
echo "Gateway now points to $ENDPOINT_INTERFACE"

Answer: Your MASQUERADE rule is wrong. It needs to specify the outbound interface, otherwise it will try to NAT all traffic in both directions, causing a total failure in connectivity. You need to specify the outbound interface:
iptables -t nat -A POSTROUTING -o enp4s0 -j MASQUERADE

Comment: Thanks for the quick reply! I have a problem finding my outbound interface since i'm a beginner to all of that stuff . My provider says that that eth0 is my public network card and eth1 is my private one . After searching on the internet about finding which is the outbound interface i found the command `ip route get an_ip` which returns my public ip and dev eth1 . Is it safe to assume that eth1 is the outbound interface?
Comment: @DeStC3 It probably is today. You may want to try to find out why your interfaces have the names eth0 and eth1 and get that fixed though, before you try to put this in production. This ancient style of naming network interfaces is not a good idea because it cannot be guaranteed they will be the same when you reboot. Look up consistent network device naming for your Linux distribution.
Comment: it seems that i get the exact same problem after i restart the master vm, i checked `ip route get an_ip` and eth1 stills comes up after the reboot but slave can't ping 220.127.116.11 after masters reboot.
Answer: It seems like you're missing the allow FORWARD rules
Instead of running separate iptable commands, I suggest you use something like iptables-restore /etc/firewall.conf. It flushes the tables that you specify and loads all rules at once.
With contents of firewall.conf being:
*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]

-A POSTROUTING -o eth0 -j MASQUERADE

# Port forward
-A PREROUTING -p tcp -i eth0 --dport 80 -j DNAT --to-destination 126.96.36.199:80

COMMIT

*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state INVALID -j DROP
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

# Local server filter rule
-A INPUT -p tcp -m tcp -s 184.108.40.206 --dport 22 -m state --state NEW -j ACCEPT

# Allow traffic forwarding
-A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i eth1 -o eth0 -j ACCEPT

-A INPUT -p icmp -j ACCEPT
-A OUTPUT -j ACCEPT

COMMIT

Answer: First of all i want to thank both Michael Hampton and Marco for taking the time to answer my question. The problem was something completely different that what i was expecting, Docker was blocking the forwarding of packages on my router-pc. So i followed this article https://docs.docker.com/network/iptables/#docker-on-a-router and this article https://discuss.linuxcontainers.org/t/lxd-and-docker-firewall-redux-how-to-deal-with-forward-policy-set-to-drop/9953/3 to fix my problem.

Slave VMs can't ping 8.8.8.8 after router VM reboot


jquery data() vs cookies

Question: Both jQuery .data() and browser cookies seem to do the same job saving information for later use. Is there any advantage to using one over the other? .data() seems to be quick and easy.
Answer: jQuery.data() and cookies are quite different:

cookies survive across requests, jQuery.data() only has the lifetime of the document it's issued in
jQuery.data() can store arbitrary objects, while you can only store objects serializable as text in cookies (for example, you can't directly store a DOM element in a cookie)
jQuery.data() is attached to a DOM element, while a cookie is attached to a domain, or a sub path of a domain

So in general jQuery.data() is used to store data used by different parts of your jQuery code (e.g. settings, cached values, etc...), and cookies are used to store persistent user information (e.g. session informations).
Comment: So what is the advantage of using data() compared to using a global variable.
Comment: You don't pollute the global namespace and avoid conflicts when mixing javascript from different sources. You should namespace your jQuery.data() usage too when you write a plugin, see [these guidelines](http://docs.jquery.com/Plugins/Authoring#Data) for details.
Comment: While I would emphasize on the domain v dom, I would not emphasize persistence; that's why we have session-only cookies.
Answer: Data is not persistent between requests. So if you save something with .data() and then the user clicks on a link you wont have the saved data anymore (unlike cookies, which do persist).
Answer: .data() is - as Jakub already said - not persistent between requests while cookies are (you can even give them an expire time!).
However, there's another big difference: .data() is set on an element and cannot be easily retrieved without having the element (or a jQuery object containing it) while cookies are document-wide simple key=>value mappings.
Oh, and you cannot store complex data (arrays, objects) in cookies without serializing them somehow (JSON would do the job).

jquery data() vs cookies


Inspect WCF Messages in the Callback direction?

Question: I can inspect WCF messsages on both Client side and server side using IClientMessageInspector, IDispatchMessageInspector respectively. But in a Duplex comunications it is not clear how to do it in a callback from server to client (Nor much documentation on that topic).
Any ideas about how to implement this feature?
Comment: I am also facing the same issue.
Answer: Finally I get the solution.
In a Duplex comunication scenario when a callback is made the server becomes the client and vice versa.
So on server side when implementing IServiceBehavior inject the message inspector using the CallbackClientRuntime property of the DispatchRuntime foreach EndpointDispatcher.
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase)
{
    foreach (ChannelDispatcher item in serviceHostBase.ChannelDispatchers)
    {
        foreach (EndpointDispatcher epd in item.Endpoints)
        {
            //injecting an inspector in normal call
            epd.DispatchRuntime.MessageInspectors.Add(new MessageSizerInspector());

            //injecting an inspector in callback
            epd.DispatchRuntime.CallbackClientRuntime.MessageInspectors.Add(new MessageSizerInspector());
        }
    }
}

On client side when implementing IEndpointBehavior inject the message inspector using the CallbackDispatchRuntime.
public void ApplyClientBehavior(ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.ClientRuntime clientRuntime)
{
    //injecting an inspector in normal call
    clientRuntime.MessageInspectors.Add(new MessageSizerInspector());

    //injecting an inspector in callback
    clientRuntime.CallbackDispatchRuntime.MessageInspectors.Add(new MessageSizerInspector());
}

Then apply the extension as always.
In my case I created a class like the following pseudo code
public class MessageSizer : Attribute, IServiceBehavior, IEndpointBehavior
{
    .....
}

then I applied this attribute to service implementation for the server side inspection
and added a behaviorExtensions inside the app.config to setup the endpoint for message inspection on client side.
<system.serviceModel>
    ...........
    <client>
      <endpoint address="net.tcp://localhost/MinerDual.svc"
            binding="netTcpBinding" bindingConfiguration="wsDualMinerNetTcp"
            contract="WebApplication.IMinerDual" name="NetTcpMinerDual"
            behaviorConfiguration="Default" />
    </client>
  <behaviors>
    <endpointBehaviors >
      <behavior name="Default">
        <messageSizer/>
      </behavior>
    </endpointBehaviors>
  </behaviors>
  <extensions>
    <behaviorExtensions>
      <add name="messageSizer"
           type="WCFExtensions.MessageSizerElement, WCFExtensions,
           Version=22.214.171.124, Culture=neutral, PublicKeyToken=null"/>
    </behaviorExtensions>
  </extensions>
</system.serviceModel>


Proving this subgroup/cyclic property?

Question: Wondering how to do the later parts and if my attempts are correct so far.
Question

Show that if $G$ is a group, and $a \in G$, then $H = \{a^k |k\in \mathbb{Z}\}$ is a subgroup of $G$.
Show that if the subgroup $H$ in part $1$ is finite, then there exists positive integer $m$ such that $$a^m = e \quad \text{and} \quad H = \{e,a,a^2,\ldots,a^{m-1}\}.$$
If $G$ is a finite group and $|G|$ is prime, then is $G$ cyclic. Prove it.
Let $p$ be prime and suppose $|G| = |H| = p$. Prove that $G$ and $H$ are isomorphic.

My attempts

Since $H$ is clearly a non-empty subset of $G$ then we check closure and inverse axiom. Let $\star$ be the operation of $G$.
Let $x,y\in H$ then $x=a^k$ and $y =a^l$ for some $k,l \in \mathbb{Z}$.
$x\star y = a^k \star a^l$...... Does this simplify to $a^{k\star l}$ or $a^{k+l}$?
Since $H$ is finite, then since $H$ is a subgroup, it contains an inverse element $e$. Let $e = a^n$ for some integer $n$. Then let $a \in H \implies e\star a = a^{n\star 1}$.
I'm not sure how to really continue because "logically" I feel since it's finite, it should cycle over again I just can't put this down as a mathematical proof.
I have no clue. I feel like it's a yes, because we prove that $H$ is cyclic, and we didn't even restrict the prime condition on $H$. But again, I'm not sure how to mathematically prove.
Unsure how to do this.

Any help is appreciated.
Comment: Next time, ask a new question for your each question.
Comment: There is a simple rule for proving that a non-empty set $H\subseteq G$ is a subgroup. For that it is enough to show that $a,b\in H\implies ab^{-1}\in H$. If $a\in H$ (note that $H$ is demanded to be non-empty) then $e=aa^{-1}\in H$. Then $a^{-1}=ea^{-1}\in H$. Finally if $a,b\in H$ then $ab=a(b^{-1})^{-1}\in H$.
Answer: In your first attempt, $k, l$ are just integers, so $k \star l$ is meaningless because the operation is defined on $G$, not on integers.Plus, to show that it is a subgroup, you have to state also that $a^0 = e \in H$ before saying that it is nonempty.
Addition to that, by definition, $a^k \star a^l = a^{k+l}$ for any multiplicative operation $\star$.
For the second question:
Let $|H| = m$.If we can show that all the elements in the set $S = \{e, a,...,a^{m-1}\}$ are distinct, we can say that $ S = H $.
For the third question;
Hint: Let $a \in G$. Is the cyclic set generated by $a$ a subgroup of G ? If so, by Lagrange Theorem, what can you concluded that considering the order of G is prime ?
For the forth question;
Hint: Let $f : G \to H$ defined by $g \to h$, where $<g> = G$ and $<h> = H$.
Answer: Question 2, you have the right intuition, but:

$e$ is not 'an inverse element' but 'the neutral element'.
You need to find $e=a^n$ for $n>0$, since obviouly $e=a^0$ and that doesn't require the group to be finite.
Once you have $e=a^n$, you can take any $x=a^p \in H$ and show that $x=a^r$ for some $r, 0<=r<n$. (Hint: euclidean division...)

Question 3, take an element $a\neq e$ in H, and consider $A=\{a^n, n\in \mathbb{N}\}$ If there is $b\in H-A$, what can you say about $ba$. About $ba^2$ ?
Question 4, use question 3 to write both groups as cyclic groups...

Proving this subgroup/cyclic property?


Does this inequality hold? And can it be shown?

Question: If $x>1$ and $y$ is some positive integer greater than 1, then is it always true that,
$\frac{x}{x+1} \prod_{i=1}^y \left( 1 + \frac{1}{xy+2i-2} \right) < 1$?
Graphing the expression seems to suggest that it is. But can this be shown?
Answer: I believe your inequality holds.
Let's define
$$
f_n(x) = \frac{x}{x+1} \prod_{k=1}^n
\biggl( 1 + \frac{1}{nx + 2k - 2} \biggr),
$$
and phrase your question as asking whether $f_n(x) < 1$ for all $x > 1$.
Now, I don't like the term in the product, so I'm going to try to estimate it by something nicer. We all know that $k-1 \leq 2k-2$ holds when $k \geq 1$, so $nx + 2k - 2 \geq nx + k -1$ for $k \geq 1$. Note also that
$$
1 + \frac{1}{nx +k - 1} = \frac{nx + k}{nx + k - 1}.
$$
Then we get the upper bound
$$
f_n(x) \leq
\frac{x}{x+1} \prod_{k=1}^n
\biggl( 1 + \frac{1}{nx + k - 1} \biggr)
=
\frac{x}{x+1} \frac{\prod_{k=1}^n nx + k}{\prod_{k=1}^n nx + k - 1}.
$$
Now, the product there telescopes - the $k$-th term on the bottom cancels out against the $(k+1)$-th term on the top - so we're left with the estimate
$$
f_n(x) \leq \frac{x}{x+1} \frac{nx + n}{nx} = 1.
$$
Looking back at the statement of the problem, we notice that $n \geq 2$, so there's always a $k$ for which we get a strict inequality in our first estimate, so we have proved the strict inequality $f_n(x) < 1$ for all $x > 1$ (actually $x > 0$, by staring at this for a bit).


Testing graph isomorphism with powers of the adjacency matrix

Question: Suppose $A$ and $B$ are two square, symmetric, binary matrices with null diagonal representing the adjacency matrices of undirected graphs.  If the multisets of the column-sums of $A$ and $B$ differ, then they are definitely not isomorphic.  If the column-sum multisets are the same, then $A$ and $B$ might be isomorphic.  Now I am wondering how the effectiveness of this test is improved by running it on $A^s$ and $B^s$ with a large integer $s$.  Are there any two non-isomorphic graphs that "look" the same in this sense for all $s$ or even for an infinite number of values of $s$?
Comment: The condition should imply that the two graphs are isospectral (http://en.wikipedia.org/wiki/Spectral_graph_theory#Isospectral_graphs), so I would look at known examples of isospectral but non-isomorphic graphs for counterexamples.
Comment: Yes, I didn't say that the two conditions are equivalent, but I am still pretty sure any counterexample has to be isospectral.
Comment: Dan's example of $C_3 \cup C_3$ and $C_6$ is not isospectral.
Comment: @Qiaochu, the article gives the examples $K_{1,4}$ and  $C_4 \cup K_1$ but I don't think this is the same.  $K_{1,4}$ has column-sum multiset $\{1,1,1,1,4\}$ and $C_4 \cup K_1$ has column-sum multiset $\{0,2,2,2,2\}$ so the test would correctly decide them to be non-isomorphic with $s=1$.
Answer: Slightly more generally than Dan's example, if a graph is $r$-regular, the column-sum multiset of $A^s$ is
$(r^s,\ldots,r^s)$.  So any two nonisomorphic $r$-regular graphs on $n$ vertices provide an example.
Answer: If $A = C_3 \cup C_3$ and $B = C_6$, then it seems like the column-sum multiset is always $\{2^s,2^s,2^s,2^s,2^s,2^s\}$.  I'm still interested in references and broader explanations.
Comment: Oh, interesting. I guess only the spectral radii need to be the same; extra structure may make the other eigenvalues of the graph irrelevant...
Answer: Testing graph isomorphism by multiset of column sums of adjacency with any power is the same as what first order Weisfeiler-Lehman (1-WL test known as vertex coloring) test does. So that approach is definitely not powerful than 1-WL test and you cannot distinguish not just isospectral graphs but also the graphs whose just maximum eigenvalues are the same.
1-WL test starts checking column-sum (actually not necessarily sum but any injective function) of Adjacency matrix. Let's think all vertices are the same, If $a_0=b_0={\bf1}$ is a vector of enough 1s, 1-WL test checks if multiset of  $Aa_0$ and  $Bb_0$ are equal or not. To do that generally, we can use the sort function, so we can check if $sort(Aa_0)=sort(Bb_0)$. If they are the same, then 1-WL relabel the result after concatenating of the current color of the vertex and the previous step ($a_1=[a_0,~Aa_0]$ and $b_1=[b_0,~Bb_0]$), relabel $a_1$ and $b_1$ and repeat the process. Relabbellin process can be seen as assigning a unique identifier for each unique row of the concatenated colors of both graphs ($[a_1;b_1]$).
In the second turn, it checks if $sort(Aa_1)=sort(Bb_1)$. If they are the same, again relabelling and again checking. If they are not equal in any step it concludes that the graphs are not isomorphic at all, or if the relabelling process cannot change the color of vertices ($a_{t+1}=a_{t}$) then the algorithm stops and supposed they are isomorphic (still they might not be isomorphic). So, what you describe is a simplified version of 1-WL test which performs $S$ number of iteration. Because if we enroll the update and change the relabelling process by just assign new color of vertex (neglect the old color of vertex by $a_1=Aa_0$), after $S$ iteration, it checks $sort(A^S{\bf1})=sort(B^S{\bf1})$ which is exactly what you asked!
This algorithm definitely not powerful and be able to just find very very easy cases. Check higher-order Weisfeiler-Lehman test procedures.


Aseprite Script Lua "attempt to index a nil value (global 'dlg')

Question: I'm writing my own Aseprite script from scratch to generate color palettes for me and want to use a drop down list (combobox) to set a flag I can later use when generating the colors. (For right now, writing into the console would be good enough)
I'm having a hard time trying to figure out how comboboxes are being used, referencing the documentation:
https://github.com/aseprite/api/blob/main/api/dialog.md#dialogcombobox
My function "is not callable (a nil value)" if written after the drop down list and if the function is written before it, I'm getting a "attempt to index a nil value (global 'dlg') error.
The function in question:
local function amountOfColorsChanged()
    if dlg.data.amountOfColors == "7" then
        print("Changed Amount of Colors to 7")
    elseif dlg.data.amountOfColors == "9" then
        print("Changed Amount of Colors to 9")
    elseif dlg.data.amountOfColors == "11" then
        print("Changed Amount of Colors to 11")
    elseif dlg.data.amountOfColors == "13" then
        print("Changed Amount of Colors to 13")
    elseif dlg.data.amountOfColors == "15" then
        print("Changed Amount of Colors to 15")
    end
end

The "combobox" in question:
:combobox
{
    id = "amountOfColors",
    option = "15",
    options =
    {
        "7",
        "9",
        "11",
        "13",
        "15"
    },
    onchange = amountOfColorsChanged()
}

If I try to initialize the variable to set a default value
local dlg.data.amountOfColors = "15"

The following "unexpected symbol near '.'"-error comes probably because I can't write dots into variables.
Because I couldn't figure out how to read/modify the data of comboboxes from the documentation, I went and looked for an extension that is using them in a similar way I'm trying to and found this, which is how I got to my approach:
https://github.com/not-surt/Limit-Colour-Component-Levels/blob/main/Limit%20Colour%20Component%20Levels.lua
(It's license permits me to copy and distribute the code freely, if that's in question. However, it should be obvious that I am not)
Here is the entire script for reference.
-- Chaonic's Palette Helper

-- INITIALIZE!!!!

local dlg = Dialog
    {
        title = "Chaonic's Palette Helper"
    }

-- Standard values when opening
if hasvalues ~= nil
then
    hasvalues = true
    local vmhueslider = 160
    local vmsatslider = 40
    local vmvalueslider = 35
    local vmalphaslider = 255
end

function easeInQuad(self, x)
    return x * x
end

function easeInSine(self, x)
    return 1 - cos(nil, x * PI / 2)
end

function lerp()
end

-- TEST DELETE LATER
  local C = app.fgColor
  if(shadingColor ~= nil) then
    C = shadingColor
  end

-- COLOR AMOUNT CHANGED

local function amountOfColorsChanged()
    if dlg.data.amountOfColors == "7" then
        print("Changed Amount of Colors to 7")
    elseif dlg.data.amountOfColors == "9" then
        print("Changed Amount of Colors to 9")
    elseif dlg.data.amountOfColors == "11" then
        print("Changed Amount of Colors to 11")
    elseif dlg.data.amountOfColors == "13" then
        print("Changed Amount of Colors to 13")
    elseif dlg.data.amountOfColors == "15" then
        print("Changed Amount of Colors to 15")
    end
end

-- COLOR VARIABLE STORAGE

local SH1 = colorShift(C, 0, 0.4, -0.6, -0.6)
local SH2 = colorShift(C, 0, 0.333, -0.5, -0.5)
local SH3 = colorShift(C, 0, 0.266, -0.4, -0.4)
local SH4 = colorShift(C, 0, 0.2, -0.3, -0.3)
local SH5 = colorShift(C, 0, 0.133, -0.2, -0.2)
local SH6 = colorShift(C, 0, 0.066, -0.1, -0.1)
local SH5 = colorShift(C, 0, 0, 0, 0)
local SH8 = colorShift(C, 0, 0.066, 0.1, 0.1)
local SH9 = colorShift(C, 0, 0.133, 0.2, 0.2)
local SH10 = colorShift(C, 0, 0.2, 0.3, 0.3)
local SH11 = colorShift(C, 0, 0.266, 0.4, 0.4)
local SH12 = colorShift(C, 0, 0.333, 0.5, 0.5)
local SH13 = colorShift(C, 0, 0.4, 0.6, 0.6)

-- DIALOG

dlg
:label
{
    id=labelColorsLeft,
    label = "Base Colors",
    text= "Left"
}
:label
{
    id=labelColorsMain,
    text= "Main"
}
:label
{
    id=labelColorsRight,
    text= "Right"
}
:label
{
    id=labelColorsClipboard,
    text= "Clipboard"
}
:shades
{
    id = "mainColors",
    colors = {C, C, C, C}
}
:button
{
    id = "buttonSetLeft",
    text = "Set",
    onclick = function()
    end
}
:button
{
    id = "buttonSetMain",
    text = "Set",
    onclick = function()
    end
}
:button
{
    id = "buttonSetRight",
    text = "Set",
    onclick = function()
    end
}
:button
{
    id = "buttonSetClipboard",
    text = "Set",
    onclick = function()
    end
}
:label
{
    id=labelColorsLeft,
    label = "Amount of:",
    text= "Colors"
}
:label
{
    id=labelColorsLeft,
    text= "Hues"
}
:combobox
{
    id = "amountOfColors",
    option = "15",
    options =
    {
        "7",
        "9",
        "11",
        "13",
        "15"
    },
    onchange = amountOfColorsChanged()
}
:combobox
{
    id = "amountOfHues",
    option = "12",
    options =
    {
        "4",
        "6",
        "8",
        "12",
        "18"
    }
}
-- COLOR CONTROL
-- :separator
-- {
    -- id = "separator",
-- }
-- :slider
-- {
    -- id = "hueslider",
    -- label = "Hue: ",
    -- min = 0,
    -- max = 360,
    -- value = vmhueslider,
    -- onchange = function()
    -- end,
    -- onrelease = function()
    -- end
-- }
-- :slider
-- {
    -- id = "satslider",
    -- label = "Sat/Val: ",
    -- min = 0,
    -- max = 100,
    -- value = vmsatslider,
    -- onchange = function()
    -- end,
    -- onrelease = function()
    -- end
-- }
-- :slider
-- {
    -- id = "valueslider",
    -- min = 0,
    -- max = 100,
    -- value = vmvalueslider,
    -- onchange = function()
    -- end,
    -- onrelease = function()
    -- end
-- }
-- :slider
-- {
    -- id = "alphaeslider",
    -- label = "Alpha: ",
    -- min = 0,
    -- max = 255,
    -- value = vmalphaslider,
    -- onchange = function()
    -- end,
    -- onrelease = function()
    -- end
-- }
:label
{
    id=huelabel,
    label = "Interpolations: ",
    text= "Hue"
}
:label
{
    id=satlabel,
    text= "Saturation"
}
:label
{
    id=vallabel,
    text= "Value"
}
:label
{
    id=alphalabel,
    text= "Alpha"
}
:combobox
{
    id = "hueinterpolation",
    option = "RGB",
    options =
    {
        "Sine",
        "Quad",
        "Cubic",
        "Circ",
        "Linear",
        "RGB"
    }
}
:combobox
{
    id = "satinterpolation",
    option = "Quad",
    options =
    {
        "Sine",
        "Quad",
        "Cubic",
        "Circ",
        "Linear",
        "RGB"
    }
}
:combobox
{
    id = "valinterpolation",
    option = "Quad",
    options =
    {
        "Sine",
        "Quad",
        "Cubic",
        "Circ",
        "Linear",
        "RGB"
    }
}
:combobox
{
    id = "alphainterpolation",
    option = "Quad",
    options =
    {
        "Sine",
        "Quad",
        "Cubic",
        "Circ",
        "Linear",
        "RGB"
    }
}
-- COLOR CONTROL END
:separator
{
    id = "separator",
}
-- SHADE
:shades
{
    id = "paletteShade",
    label = "Shade",
    colors = {C, C, C, C, C, C, C, C, C, C, C, C, C, C, C}
}
:button
{
    id = "buttonShadeLine",
    text = "Copy Line to Palette",
    onclick = function()
    end
}
:button
{
    id = "buttonShadePalette",
    text = "Generate whole Palette",
    onclick = function()
    end
}
-- SHADE END
-- SOFT SHADE
:shades
{
    id = "paletteSoftShade",
    label = "Soft Shade",
    colors = {C, C, C, C, C, C, C, C, C, C, C, C, C, C, C}
}
:button
{
    id = "buttonShadeLine",
    text = "Copy Line to Palette",
    onclick = function()
    end
}
:button
{
    id = "buttonShadePalette",
    text = "Generate whole Palette",
    onclick = function()
    end
}
-- SOFT SHADE END
-- LIGHT
:shades
{
    id = "paletteLight",
    label = "Light",
    colors = {C, C, C, C, C, C, C, C, C, C, C, C, C, C, C}
}
:button
{
    id = "buttonShadeLine",
    text = "Copy Line to Palette",
    onclick = function()
    end
}
:button
{
    id = "buttonShadePalette",
    text = "Generate whole Palette",
    onclick = function()
    end
}
-- LIGHT END
-- SOFT LIGHT
:shades
{
    id = "paletteSoftLight",
    label = "Soft Light",
    colors = {C, C, C, C, C, C, C, C, C, C, C, C, C, C, C}
}
:button
{
    id = "buttonShadeLine",
    text = "Copy Line to Palette",
    onclick = function()
    end
}
:button
{
    id = "buttonShadePalette",
    text = "Generate whole Palette",
    onclick = function()
    end
}
-- SOFT LIGHT END
-- SATURATION
:shades
{
    id = "paletteSaturation",
    label = "Saturation",
    colors = {C, C, C, C, C, C, C, C, C, C, C, C, C, C, C}
}
:button
{
    id = "buttonShadeLine",
    text = "Copy Line to Palette",
    onclick = function()
    end
}
:button
{
    id = "buttonShadePalette",
    text = "Generate whole Palette",
    onclick = function()
    end
}
-- SATURATION END
-- SOFT SATURATION
:shades
{
    id = "paletteSoftSaturation",
    label = "Soft Sat.",
    colors = {C, C, C, C, C, C, C, C, C, C, C, C, C, C, C}
}
:button
{
    id = "buttonShadeLine",
    text = "Copy Line to Palette",
    onclick = function()
    end
}
:button
{
    id = "buttonShadePalette",
    text = "Generate whole Palette",
    onclick = function()
    end
}
-- SOFT SATURATION END
-- SOFT HUE
:shades
{
    id = "paletteSoftHue",
    label = "Soft Hue",
    colors = {C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C}
}
:button
{
    id = "buttonShadeLine",
    text = "Copy Line to Palette",
    onclick = function()
    end
}
-- SOFT HUE END
-- HARD HUE
:shades
{
    id = "paletteHardHue",
    label = "Hard Hue",
    colors = {C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C}
}
:button
{
    id = "buttonShadeLine",
    text = "Copy Line to Palette",
    onclick = function()
    end
}
-- HARD HUE END
:separator
{
    id = "separator",
}
-- :button
-- {
    -- id = "buttonPreset1",
    -- label = "Presets: ",
    -- text = "1",
    -- onclick = function()
        -- vmhueslider = 160
        -- vmsatslider = 40
        -- vmvalueslider = 35
        -- vmalphaslider = 255
        -- reload()
    -- end
-- }
-- :button
-- {
    -- id = "buttonPreset2",
    -- text = "2",
    -- onclick = function()
        -- vmhueslider = 210
        -- vmsatslider = 80
        -- vmvalueslider = 80
        -- vmalphaslider = 255
        -- reload()
    -- end
-- }
-- :button
-- {
    -- id = "buttonPreset3",
    -- text = "3",
    -- onclick = function()
    -- end
-- }
-- :button
-- {
    -- id = "buttonPreset4",
    -- text = "4",
    -- onclick = function()
    -- end
-- }
-- :button
-- {
    -- id = "buttonPreset5",
    -- text = "5",
    -- onclick = function()
    -- end
-- }
-- :button
-- {
    -- id = "buttonPreset6",
    -- text = "6",
    -- onclick = function()
    -- end
-- }
-- :newrow()
:button
{
    id = "buttonGenerate",
    text = "Generate",
    onclick = function()
    end
}
:button
{
    id = "buttonReload",
    text = "Reload",
    onclick = function()
    end
}
:button
{
    id = "buttonCancel",
    text = "Cancel",
    onclick = function()
    end
}
:show
{
wait = false
}

This is my first post to stack overflow, so I hope I'm doing this right.
Thank you very much for your help!!!
Answer: While going through the documentation again to check if I have forgotten to mention something, I've seen under https://github.com/aseprite/api/blob/main/api/dialog.md#dialogdata that I need to initialize the use first.
Simply adding these lines to the script make it work:
local data = dlg.data
dlg.data = data

Comment: The function isn't actually getting executed, but the script loads up!
Comment: What do you think the second line you added does?
Comment: I don't really know what it does, I've copied that part from the API documentation as I've said. From my limited understanding, these lines create a new variable, copy stuff from dlg.data to data and on the second line it copies it back. Logic tells me this is unnecessary, but it works now.
Comment: It works without the second line. I'm very sorry. I can't downvote my own post, otherwise I would do that now.
Comment: I regret now posting any of this.


How do i specify a style for a single exposed filter?

Question: I have a View where i show some exposed filters; i would like to apply a particular CSS class only to a specific exposed filter.
I have seen that if i copy the views-exposed-form.tpl.php inside my theme directory and call it views-exposed-form--MYFORMNAME.tpl.php i can control the html code; i don't think it s a good thing to put code with
<code> if($widget->id==MYID) {}
</code>
inside the template ... which is the correct way to assign a style to an exposed filter?
Answer: Not sure if you need the template for other reasons, but you can style it directly with CSS, using the ID.  See screenshot.  I happen to be using Better Exposed Filters module, which provides some nice extras controls.


Trying to understand an expansion/limit from geometric sum to exponentials, what kind of rule is at play?

Question: Can someone help me understand what's going on here?

This is for a problem involving moment generating functions, which is related to statistics and probability, but I figured it was more of a math questions. The whole expansion is below:
Comment: Do you just want to prove that the two sides are equal?
Answer: Rewrite the right-hand side using the Taylor expansion for $\exp$.
Answer: Hint
$$A=1+\sum_{n=1}^\infty \frac{t^n}{n!}\big(\frac 19+3^{n-1}\big)=1+\frac 19\sum_{n=1}^\infty \frac{t^n}{n!}+\frac 13\sum_{n=1}^\infty \frac{(3t)^n}{n!}$$ $$A=1+\frac 19 \Big(\sum_{n=0}^\infty \frac{t^n}{n!}-1\Big)+\frac 13\Big(\sum_{n=0}^\infty \frac{(3t)^n}{n!}-1\Big)$$ Now, remember that $$e^x=\sum_{n=0}^\infty \frac{x^n}{n!}$$
Comment: Got it. Thanks for the help!


Drupal gives error while add content or edit node

Question: Hi all i am facing this error when try to edit node or add content
Additional uncaught exception thrown while handling exception.
Original
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: INSERT INTO {watchdog} (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => node [:db_insert_placeholder_2] => %type: !message in %function (line %line of %file). [:db_insert_placeholder_3] => a:6:{s:5:"%type";s:12:"PDOException";s:8:"!message";s:238:"SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT 1 AS expression FROM {variable} variable WHERE ( (name = :db_condition_placeholder_0) ); Array ( [:db_condition_placeholder_0] =&gt; drupal_http_request_fails ) ";s:9:"%function";s:14:"variable_set()";s:5:"%file";s:74:"/home/apetrdo6/public_html/Development/InfinityPups/includes/bootstrap.inc";s:5:"%line";i:991;s:14:"severity_level";i:3;} [:db_insert_placeholder_4] => 3 [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => http://apetrailportfolio.com/Development/InfinityPups/node/add/dogs [:db_insert_placeholder_7] => http://apetrailportfolio.com/Development/InfinityPups/node/add/dogs [:db_insert_placeholder_8] => 22.214.171.124 [:db_insert_placeholder_9] => 1473159652 ) in dblog_watchdog() (line 160 of /home/apetrdo6/public_html/Development/InfinityPups/modules/dblog/dblog.module).

Additional

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT 1 AS expression FROM {variable} variable WHERE ( (name = :db_condition_placeholder_0) ); Array ( [:db_condition_placeholder_0] => drupal_css_cache_files ) in variable_set() (line 991 of /home/apetrdo6/public_html/Development/InfinityPups/includes/bootstrap.inc).

Uncaught exception thrown in session handler.

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: UPDATE {users} SET access=:db_update_placeholder_0 WHERE (uid = :db_condition_placeholder_0) ; Array ( [:db_update_placeholder_0] => 1473159609 [:db_condition_placeholder_0] => 1 ) in _drupal_session_write() (line 219 of /home/apetrdo6/public_html/Development/InfinityPups/includes/session.inc).

Uncaught exception thrown in shutdown function.

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: DELETE FROM {semaphore} WHERE (value = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] => 80080962057cea1b962fce6.76953018 ) in lock_release_all() (line 269 of /home/apetrdo6/public_html/Development/InfinityPups/includes/lock.inc).

Comment: Check your error log tail -f /var/log/apache2/error.log. You may find a hint.
Comment: Check whether the mysql server works fine. The server might be killed by mistake. http://dev.mysql.com/doc/refman/5.7/en/gone-away.html
Answer: One possibility to solve is to increase "max_allowed_packet" .

    Go to xampp\mysql\bin
    Open my.ini
    Change "max_allowed_packet" from "1m" to "16m"
    Save my.ini
    Now restart MySql through the XAMPP control panel.

Or
settings.php
ini_set('max_allowed_packet', '1024M');

Comment: Well currently i am working on live server where i set value
Comment: current  my
PHP memory limit 128M
Comment: memory_limit is separate from max_allowed_packet.
Comment: You need to change on server my.ini file or you can make the changes on setting.php file of drupal.
Comment: still same error


How to measure marginal effect of interdependent variables on a binary outcome?

Question: My data represents observations on a possible sequences of events that may lead to a positive outcome (y).
Each event (A, B, C, D) is dependent on the previous event; for D to occur C must occur, for C to occur B must occur, for B to occur A must occur.
Some example rows to illustrate:

A
B
C
D
y

0
0
0
0
0

1
0
0
0
1

1
1
1
0
0

1
1
0
0
1

1
1
1
1
1

I'd like to measure the relative impact of each event on the probability of y. For example, I'd like to be able to make statements such as "Event B increase the probability by 10% compared to if only Event A occurs. However Event C only increases the probability by a further 1%".
I've considered using logistic regression. However, I have a concern that due to the inherent collinearity in the data the regression coefficients will not be reliable to infer from.
What possible methods could I use/explore?
Answer: You can create a variable that just contains the last event each participant went through. Then run a logistic regression (or another kind of regression) of the outcome on that variable.
To ease interpretation, you can also employ successive difference contrast coding. This makes it so that the coefficient on the second level is equal to the difference between the second and first levels, and the coefficient on the third level is equal to the difference between the third and second level. The intercept is the average of the probabilities for all the events. In R, this can be done using MASS::contr.sdif().
I also urge you to consider not using logistic regression if you want to interpret your estimates as changes in probability and you have no other variables in the model. Using a linear probability model makes the resulting effects much easier to interpret and doesn't make any additional assumptions on the model. You just have to use a robust standard error.
Putting this all together, R code to implement this would look like the following:
#List of column names in original dataset correspond to events
events <- c("A", "B", "C", "D")

#Create new `last_event` variable; could also do this manually
data$last_event <- factor(events[rowSums(data[events])], levels = events)

#Fit the linear model with the contrasts
fit <- lm(y ~ last_event, data = data,
          contrasts = list(last_event = MASS::contr.sdif))

#Get coefficients with robust SEs
lmtest::coeftest(fit, vcov. = sandwich::vcovHC)

Answer: It looks like a Bayesian problem. The probabilities of each event are not independent of one another, so logistic regression is unlikely to work since its underlying assumption is violated.
You can build a Bayesian network where each event A, B, C, D and y are nodes and use Expectation Maximization algorithm to estimate the probabilities of each event given the other ones.
Have a look to this blog post for a nice introduction of Bayesian Belief Network


Object converted to xts but an error appears when I apply dailyReturn

Question: I have already converted my data to an xts object and this error persists. I think it is related to my date format but, I have used the function as.Date to make sure my date format is right. Here is my code so far:
    library(quantmod)
    library(ggplot2)
    library(PerformanceAnalytics)
    library(GetTDData)
    library(openair)
    library(dplyr)
    library(devtools)

    ntnb <- download.TD.data('NTN-B')
    ntnb35 <- read.TD.files(dl.folder = 'TD Files',
     maturity = '150535')

    new35<-ntnb35%>%select(ref.date,yield.bid,price.bid,asset.code,matur.date)%>%filter(ref.date>=as.Date("2016-01-01"))

    new35$ref.date<-as.Date(new35$ref.date,format="%Y-%m-%d")

    new35_xts<-xts(new35,order.by=new35$ref.date)
dailyReturn(new35_xts)

Error in to_period(xx, period = on.opts[[period]], ...) :
  unsupported type
A sample of my data which class is data.frame:
ref.date yield.bid price.bid
1 2016-01-04    0.0737   2425.21
2 2016-01-05    0.0735   2431.68
3 2016-01-06    0.0727   2453.29
4 2016-01-07    0.0724   2462.39
5 2016-01-08    0.0732   2443.98

When I convert to xts, my index is strange, that is, my first column, which has an X before the date:
             ref.date    yield.bid price.bid
X2016.01.04 "2016-01-04" "0.0737"  "2425.21"
X2016.01.05 "2016-01-05" "0.0735"  "2431.68"
X2016.01.06 "2016-01-06" "0.0727"  "2453.29"
X2016.01.07 "2016-01-07" "0.0724"  "2462.39"
X2016.01.08 "2016-01-08" "0.0732"  "2443.98"
X2016.01.11 "2016-01-11" "0.0737"  "2432.90"
X2016.01.12 "2016-01-12" "0.0735"  "2439.33"
X2016.01.13 "2016-01-13" "0.0734"  "2443.28"

My current version of R is '3.6.3'. Thank you guys!
Answer: You need to remove the date from your timeseries when creating an xts object. If you don't the date will appear in the matrix and will turn the matrix into a character matrix.
Using the data.frame new35 as a starting point:
library(quantmod)

# Make sure you don't have the data in the data for the xts matrix.
# The index is defined in the order.by
new35_xts <- xts(new35[, -1], order.by = new35$ref.date)

dailyReturn(new35_xts)

           daily.returns
2016-01-04   0.000000000
2016-01-05  -0.002713704
2016-01-06  -0.010884354
2016-01-07  -0.004126547
2016-01-08   0.011049724

data:
new35 <- structure(list(ref.date = structure(c(16804, 16805, 16806, 16807,
16808), class = "Date"), yield.bid = c(0.0737, 0.0735, 0.0727,
0.0724, 0.0732), price.bid = c(2425.21, 2431.68, 2453.29, 2462.39,
2443.98)), row.names = c("1", "2", "3", "4", "5"), class = "data.frame")


Create hourly time slots from start and finish time

Question: Hoping you can help me with something I've been stuck on for ages.
I have two tables.  One has employee records with fields cost, start time and finish time.  Other table has revenue with actual time.  I want to generate a report which groups revenue and cost by hourly time slots.  What's the best approach for doing this?
I am using mysql.
Code used:
<code>SELECT
    `Employee Number`,
    `Shift Start`,
    `Shift Finish`,
    `Shift Length`,
    STR_TO_DATE(`Shift Start`, '%m/%d/%Y %h:%i:%s %p') AS ShiftStart,
    STR_TO_DATE(`Shift Finish`, '%m/%d/%Y %h:%i:%s %p') AS ShiftFinish,
    timestampdiff(
        MINUTE, STR_TO_DATE(`Shift Start`, '%m/%d/%Y %h:%i:%s %p'),
        STR_TO_DATE(`Shift Finish`, '%m/%d/%Y %h:%i:%s %p')) / 60 AS Diff
FROM table_name;
</code>
Table structure (last column is what I've added in the query): http://ge.tt/9yzYx39?c
Answer: By stack exchange rules, we want to see the structure of your table, and some piece of code that says you know what you are doing and you tried your best already.
Comment: By SO rules, we don't want to see this type of comments posted as an answer either
Comment: @Icarus: lfewater has no rep for comments, though.
Comment: Sorry mate, I've added it now.
Comment: :D, @lcarus, judging by his auto-generated ID, he's new here (as i am). someone had to tell him or he won't get answers.


Suppose $X \subseteq \mathbb R$ and $f : X \to X$ is a bijection (that is, one to one and onto) satisfying $f(x) > x$ for all $x \in X$

Question: Suppose $X$ is a subset of real numbers and $f: X \to X$ is a bijection  satisfying  $f(x) > x$ for all $x$ belonging to $X$.  Then $X$ cannot be:
(A) the set of integers
(B) the set of positive integers
(C) the set of positive real numbers
(D) the set of real numbers
Comment: What are your thoughts on the problem? Have you tried constructing such a function $f$ for the various sets $X$?
Comment: $(B)$ the set of positive integers.
Answer: The answer is B). $f(n)>n\geq 1$ for all $n$ so $1$ is not the image of any number.
To rule out other options consider $f(x)=x+1$ for A) and D) and $f(x)=2x$ for C).


Question about the location of regularization constant C in SVM

Question: I've encountered very similiar but different functions in SVM optimization problem, the diffrence is in the location of regularization constant C.
$\sum_{i=1}^n(1-(y_i(w^tx))_+ +\frac{1}{2C} \left\lVert w\right\rVert^2 \rightarrow min_w$
$C\sum_{i=1}^n(1-(y_i(w^tx))_+ +\frac{1}{2} \left\lVert w\right\rVert^2 \rightarrow min_w$

Is it right that technically they are diffrent functions, and if we graph them we will see the difference, but the location of minimum is the same for both of them?
Also I would like to check whether my intuition about regularization is right.
In the first function small values of $С$ makes second term of the summation large, that means with large $C$ we want $\left\lVert w\right\rVert$ to be small and thus miximize the separating margin.
In the second equation with large values of $C$ we want to reduce the number of misclassifiactions and also penalise more those errors with lesser value
of $y_i(w^tx)$, since $y_i(w^tx)$ is negative for misclassified examples. These are two different ways to arive at the same optimal solution. Is it the right logic?
Answer:
Yes, they're different loss functions, where $Cf_1=f_2$, if we call them as $f_1,f_2$ respectively. Since they're related by a constant chosen by you, i.e. we're not optimizing with respect to $C$, their optimum values are the same.
You're correct in your logic for the second function. Large $C$ penalizes the errors more than weights. Similarly, for the first one, large $C$ means small $1/2C$ and penalizing weights less than errors. So, we're again penalizing errors more. The two objective functions behave the same with same $C$ because they're multiples of each other as described in (1).


Fixed point of a cone over an $n$-point space

Question: I'm trying to answer the following question:
Let $CX$ denote the cone over an $n$-point space $X=\{1,\dots,n\}$. Show that every continuous map $f:CX\to CX$ has a fixed point.
Any help is appreciated. The only fixed point theorem I've come across for this course is the Brouwer fixed point theorem for the disk, i.e., if $f:B^2\to B^2$ is continuous, then there exists a point $x\in B^2$ such that $f(x)=x$.
Comment: Are you able to describe a cone geometrically? Do you know that union of two spaces $X, Y$ with fixed point property and $|X\cap Y| = 1$ also as a fixed point property?
Comment: Are we in $\mathbb R ^2$, in $\mathbb R^3$, or other space? $X$ is not really the set of integers from $1$ to $n$? What do you mean by "the cone over" $X$ ?
Comment: @Jean-ArmandMoroni Cone of a topological space
Comment: @Jakobian I would describe it as lines from a common point to the $n$ points. It's possible that that property was mentioned but I cannot recall it honestly. How would you show such a thing?
Comment: Sorry I'd write it sooner but my keyboard is malfunctioning
Answer: We can embed $X$ as a subset of $S^1$ by identifying $k$ with $\zeta_k = e^{\frac{2k\pi i}{n}}$. Let $Z = \{ \zeta_1, \ldots, \zeta_n\}$ and $Z^* = \{t \zeta \mid t \in [0,1], \zeta \in Z\}$. Clearly $Z^*$ is a homeomorphic copy of $CX$. It therefore suffices to show that each $f : Z^* \to Z^*$ has  afixed point.
It is easy to see that there is a retraction $r : B^2 \to Z^*$ (drawing a picture helps, to derive an explicit formula is somewhat tedious).
Given $f : Z^* \to Z^*$, define
$$F : B^2 \to B^2, F(z) = f(r(z)) .$$
This map has a fixed point $z_0 \in B^2$. We have
$$z_0 = F(z_0) = f(r(z_0)) \in f(Z^*) \subset Z^*$$
and therefore $r(z_0) = z_0$. Hence
$$f(z_0) = f(r(z_0)) = F(z_0) = z_0 .$$
Comment: I think there is a typo: Is $f'=F$?
Comment: @Gerd Thank you! I corrected the typo.
Answer: Theorem. If $X, Y$ have fixed point property (in some ambient space $Z$), be closed, and $X\cap Y = \{x_0\}$, then $X\cup Y$ has fixed point property.
Proof: Let $f:X\cup Y\to X\cup Y$ be continuous, and $$g_Y(x) = \begin{cases} x_0, & x\in X \\ x,& x\in Y\end{cases},\ g_X(x) = \begin{cases} x,& x\in X\\ x_0, & x\in Y\end{cases}$$
Then $f_Y = g_Y\circ f\restriction_Y$ and $f_X = g_X\circ f\restriction_X$ have fixed points, so that there are $x\in X, y\in Y$ with $f_X(x) = x$ and $f_Y(y) = y$. If $f(x)\in X$ or $f(y)\in Y$ then we are done. Suppose on the other hand that $f(x)\in Y$ and $f(y)\in X$, then $f_X(x) = x = x_0$ and $f_Y(y) = y = x_0$ so that $f(x) = f(y) = f(x_0)\in X\cap Y = \{x_0\}$ so finally $f(x_0) = x_0$. $\square$
Corollary. Let $X_1, ..., X_n$ have fixed point property, be closed (in some space $Z$), and $X_i\cap X_j = \{x_0\}$ for $i \neq j$. Then $X_1\cup ... \cup X_n$ has fixed point property.
Proof: Induction. $\square$
In your case, $CX$ is a union of spaces $I_i$ homeomorphic to compact intervals such that the vertex $x_0$ is the common intersection of each two disjoint intervals. Hence $CX$ has fixed point property.


DOMcollection.js failed to compile in React Environment

Question: I am new to react and there is a problem while solving the error.
May I ask please what is missing in my project environment please?
The following message appears:
**Failed to compile**

./node_modules/@testing-library/dom/node_modules/pretty-format/build/plugins/DOMCollection.js
Module parse failed: Unexpected token (53:15)
You may need an appropriate loader to handle this file type.
|                 return props;
|               }, {})
|             : {...collection},
|           config,
|           indentation,

webpack.config.dev.js file:
This file is being generated after the npm run eject command.

'use strict';

const autoprefixer = require('autoprefixer');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
const eslintFormatter = require('react-dev-utils/eslintFormatter');
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
const getClientEnvironment = require('./env');
const paths = require('./paths');

Comment: I'm also getting this same error... was this ever resolved?
Comment: can you provide the code from your webpack.config,js file?
Comment: @Ran marciano, thank you for your reply. May I ask please where to find the webpack.config.js file?
Comment: how did you create the project? using create-react-app?
Comment: yes, I created the project using create-react-app. Then uploded my public and src folders on GitHub. Now cloned it on my laptop and installed npm package again and then run ti with npm start command.
Comment: To get webpack.config.js file you can run "npm run eject".
It should be inside the config folder.
Now before you cloned it, did it worked?
Comment: It says, Remove untracked files, stash or commit any changes, and try again.
Comment: Makes sense, its just asking you to commit the last changes you've mad
Comment: @RanMarciano, unfortunately, problem still persists. May i ask please what is the issue? Are you also facing the same issue?
Comment: The code you've provided is the whole webpack.config file?
Basically, there are some problems that I know that can cause this issue and they are originated in the webpack.config.js file
Comment: I reinstalled ```npm install --save-dev @testing-library/react``` and it gives some warning about dependencies.
Comment: No, I just put few lines from ```webpack.config.dev.js```file.
Answer: I don't know if it is a good long term solution but I was having this issue and changed react-scripts to version 4.0.1 with npm install email@example.com and my dev environment is up again.
Comment: Could you explain why you did this?
Comment: [New React app failed to compile immediatly following install](https://stackoverflow.com/q/66127456/16203449) In this post a user mentions  very vaguely a problem with react scripts and changing the version as a solution to a very similar issue, so I thought it would be worth a try.
Answer: Okay, so the first step is having the DOMCollection.js file opened and then resolving the {...collection} to collection,
Save the file and reload the page.DOMCollection
so from  : {...collection}
config,
indentation,
depth,
refs,
printer
to :
collection,
config,
indentation,
depth,
refs,
printer


Como colocar um CSS dentro da tag html com URL?

Question: Eu tenho esse CSS que gostaria de colocar no meu form
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">

Porém, quando coloco no  o CSS de toda página é alterada (obviamente iria acontecer isso).
Como faço para importar esse CSS somente para a tag <form>?
Comment: Por quê não cria o seu CSS próprio e estiliza o `form` da maneira que deseja?
Comment: Basta vc abrir o link e copiar as partes do css que você deseja usar no seu form. Por ex: as formatações de button,input,select,textarea e etc.
Comment: não tem como colocar este css só na tag form. Ele é o css completo do w3. Se você optar por usar deste link, vai ter que usar todos os estilos aplicados pelo w3. Agora, uma forma de manter o seu próprio estilo utilizando o css do w3 é adicionar o !important dentro do seu próprio estilo. exemplo: .elemento1{background-color: #f0f !important}
Comment: Esse link é toda a biblioteca de css do w3. quando você coloca na tag head é normal a alteração. Uma coisa que você pode fazer é criar uma página somente para o form! sem precisar das tags html, body, head.. Apenas o form. E ai sim na página do body passar o CSS do w3
Comment: Eu criei, porém, continua _alterando_ coisas como o **menu**. Queria colocar esse css só na **tag** `form`, como faço? @BrunoCastro
Comment: tem como mostrar seu código? E a pagina do w3 que usa esse css
Comment: @AndersonCarlosWoss porque achei bonito o **CSS** do _W3 Schools_, e queria fazer algo simples porque é uma página de exemplo.
Comment: De repente se vc colocar o seu css depois desse do w3 pode ser que dê certo devido a prioridade em css. PODE SER e não VAI SER.
Comment: @LeoCaracciolo funcionou cara! Obrigado
Comment: Vai virar resposta então
Comment: Veja a resposta que publiquei e aprenda um pouco sobre prioridade em css e aproveita e leia esse post https://pt.meta.stackoverflow.com/questions/1078/como-e-por-que-aceitar-uma-resposta/1079#1079
Answer:
De repente se vc colocar o seu css depois desse do w3 pode ser que dê certo devido a prioridade em css. PODE SER e não obrigatoriamente VAI SER.
   "têm prioridade aquelas declaradas por último"

Prioridade de Estilos (cascata)
Em alguns casos você pode especificar diferentes estilos para a mesma página por meio da combinação de um arquivo ".css" referenciado em link ou com a inserção de uma tag de style, e também com atributos de estilo inline. Se estas diferentes especificações entrarem em conflito entre si, o browser tem que decidir qual dos valores deve usar. Essa escolha é feita com base numa ordem de prioridade (cascading style sheets - "folhas de estilo em cascata").
Esta ordem de prioridade segue assim:

default
do Browser
CSS externo (arquivo ".css")
CSS interno (dentro da tag )
Estilos inline (dentro do elemento HTML )

Então, um estilo inline tem a maior prioridade dentro da "cascata", o que significa que ele irá fazer um override sobre todo estilo declarado dentro da tag , em um arquivo externo ".css", e em um browser (valor default).
FONTE

O ideal seria você incorporar na sua folha de estilos somente as partes do css que você deseja usar no seu form como bem disse o nosso amigo alan no comentário e que lhe trará somente benefícios.

Quando uma pessoa entra no site pela primeira vez, os primeiros segundos são críticos para captar a atenção e convencê-la a ficar mais um pouco ou a voltar no futuro. Se o seu site demora muito tempo a carregar, a maioria das pessoas desiste e abandona-o, mesmo antes de ter tido oportunidade de lhes mostrar o valor do seu serviço. "Um atraso de um segundo pode resultar em 7% menos conversões, 11% menos visualizações de páginas, ou mesmo uma diminuição de 16 por cento na satisfação do cliente" BRYAN EISENBERG.
Código limpo significa carregamento mais rápido e visitantes contentes.
É importante manter o tempo de carregamento baixo escrevendo código semanticamente adequado, usando as melhores práticas de otimização de performance e, rotineiramente, a limpeza de CSS, HTML e imagens.
Geralmente, o tempo de carregamento do site irá aumentar com sua evolução e isso, de certo modo, é algo já esperado. Por isso é importante fazer essa rotina de limpeza de HTML, CSS e imagens uma parte natural do fluxo de trabalho para garantir uma experiência positiva ao usuário.
Comment: E tem a outra metade da cascata, que determina a precedência conforme o seletor.
Comment: Existe também o !important que da prioridade máxima para o estilo
Comment: se você constrói suas regras ........
Comment: PODE SER e não obrigatoriamente VAI SER. Mas o autor ficou satisfeito e deu certo.


saltstack equivalent of puppet last_run_summary.yaml

Question: Does Salt have the equivalent of Puppet's last_run_summary.yaml? If not, what's the suggested way to monitor the success or failure of executions on individual salt minions?
Answer: I think I found a reasonable way to get this information written to the file system.
We can modify the minion config (on Linux I believe the default location is /etc/salt/minion) to add:
returners: rawfile_json
This will result in one JSON object per line being logged. Documented here. The default output file location for this is /var/log/salt/events.
The JSON object has fields which we can use:
retcode, success, and fun (the function name). In my case I want to filter for fun = "state.apply".
Answer: I think you can use the jobs.exit_success command to do so
The only thing is you need to retrieve the job_id first
salt-run jobs.list_jobs
salt-run jobs.exit_success <jobid>


Trying to programmatically add UIScrollView to my App and I keep getting a blank View

Question: Trying to create a UIScrollView and I cant seem to get my labels to appear as I would like them dead center.
lazy var label : UILabel = {
        let label = UILabel()
        label.text = "center of container view.center of container view"
        label.font = UIFont(name: "Bebas Neue", size: 23)!
        label.textColor = .black
        return label
    }()
  // Mark: Properties

    lazy var contentViewSize = CGSize(width: self.view.frame.width + 1200, height: self.view.frame.height)

    // Mark: Views
    fileprivate lazy var parentScrollView : UIView = {
        var newView = UIView()

        newView.translatesAutoresizingMaskIntoConstraints = false
        newView.backgroundColor = .black
        newView.frame = self.scrollView.bounds
        newView.frame.size = contentViewSize

        return newView
    }()
    fileprivate lazy var scrollView : UIScrollView = {
        var uiScrollView = UIScrollView(frame: .zero)
        uiScrollView.translatesAutoresizingMaskIntoConstraints = false
        uiScrollView.frame = view.bounds
        uiScrollView.backgroundColor = .gray
        uiScrollView.addViewBorder(borderColor: UIColor.gray.cgColor, borderWith: 10, borderCornerRadius: 0)
//        uiScrollView.alpha =
        uiScrollView.contentSize = contentViewSize
//        uiScrollView.autoresizingMask = .flexibleHeight
        uiScrollView.showsVerticalScrollIndicator = true
        uiScrollView.bounces = true

        return uiScrollView
    }()
    fileprivate lazy var tutorialView : UIStackView = {

        var tutView = UIStackView(arrangedSubviews: [label,label,label])
        tutView.axis = .horizontal
        tutView.backgroundColor = .white
        tutView.distribution = .fillEqually
        tutView.spacing = 0

        return tutView
    }()
    override func viewDidLoad() {

        view.backgroundColor = .white

        view.addSubview(scrollView)
        scrollView.addSubview(parentScrollView)
        parentScrollView.addSubview(tutorialView)

        scrollView.widthAnchor.constraint(equalTo:self.view.widthAnchor,multiplier: 0.9).isActive = true
        scrollView.heightAnchor.constraint(equalTo:self.view.heightAnchor,multiplier: 0.7).isActive = true
        scrollView.centerXAnchor.constraint(equalTo: self.view.centerXAnchor).isActive = true
        scrollView.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 75).isActive = true

        tutorialView.topAnchor.constraint(equalTo: parentScrollView.topAnchor,constant: +10).isActive = true}

It seems that when I add that last constraight with the topAnchor I get a blank screen. When I take that off I actually get the borders between the two views and I am able to do some scrolling.
Any help would be appreciated. Thank you
Comment: Any answer is working for you or not?
Comment: @KishanBhatiya I actually solved it. I forgot to `translatesAutoresizingMaskIntoConstraints = false` for my Label
Answer: Did you give a value to the scrollView?
 uiScrollView.contentSize.width = 1200

Then give the tutorialView the same width constraint with the other constraints.
 NSLayoutConstraint.activate([
     tutorialView.widthAnchor.constraint(equalToConstant: 1200),
     tutorialView.heightAnchor.constraint(equalTo: uiScrollView.heightAnchor)
       ])

Comment: So the strange thing that keeps happening when I add a constraint to my tutorialView is that the whole view would just go gray
Answer: You have to add tutView.translatesAutoresizingMaskIntoConstraints = false when giving layout constraints in closure of tutorialView and also there are some mistakes in your code. So included some changes in your code and check updated code:
    lazy var label : UILabel = {
            let label = UILabel()
            label.text = "center of container view.center of container view"
            label.font = UIFont(name: "Bebas Neue", size: 23)!
            label.textColor = .green
            return label
        }()
        // Mark: Properties

        lazy var contentViewSize = CGSize(width: self.view.frame.width + 1200, height: self.view.frame.height)

        // Mark: Views
        fileprivate lazy var parentScrollView : UIView = {
            var newView = UIView()

            newView.translatesAutoresizingMaskIntoConstraints = false
            newView.backgroundColor = UIColor.clear

    //        newView.layer.borderWidth = 2
    //        newView.layer.borderColor = UIColor.yellow.cgColor

            return newView
        }()
        fileprivate lazy var scrollView : UIScrollView = {
            var uiScrollView = UIScrollView()
            uiScrollView.translatesAutoresizingMaskIntoConstraints = false
    //        uiScrollView.frame = view.bounds
            uiScrollView.backgroundColor = .orange
            uiScrollView.layer.borderColor = UIColor.blue.cgColor
            uiScrollView.layer.borderWidth = 2
            uiScrollView.layer.cornerRadius = 0

            //        uiScrollView.alpha =
            uiScrollView.contentSize = contentViewSize
            //        uiScrollView.autoresizingMask = .flexibleHeight
            uiScrollView.showsVerticalScrollIndicator = true
            uiScrollView.bounces = true

            return uiScrollView
        }()
        fileprivate lazy var tutorialView : UIStackView = {

            var tutView = UIStackView(arrangedSubviews: [label,label,label])
            tutView.axis = .horizontal
            tutView.backgroundColor = .red
            tutView.distribution = .fill
            tutView.translatesAutoresizingMaskIntoConstraints = false

            return tutView
        }()

    override func viewDidLoad() {
        super.viewDidLoad()

        view.backgroundColor = .white

        view.addSubview(scrollView)
        scrollView.addSubview(parentScrollView)
        parentScrollView.addSubview(tutorialView)

        scrollView.widthAnchor.constraint(equalTo:self.view.widthAnchor,multiplier: 0.9).isActive = true
        scrollView.heightAnchor.constraint(equalTo:self.view.heightAnchor,multiplier: 0.7).isActive = true
        scrollView.centerXAnchor.constraint(equalTo: self.view.centerXAnchor).isActive = true
        scrollView.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor, constant: 25).isActive = true

        parentScrollView.centerXAnchor.constraint(equalTo: scrollView.centerXAnchor).isActive = true
        parentScrollView.topAnchor.constraint(equalTo: scrollView.topAnchor, constant: 10).isActive = true
        parentScrollView.heightAnchor.constraint(equalToConstant: 200).isActive = true
        parentScrollView.widthAnchor.constraint(equalToConstant: 200).isActive = true
//        scrollView.layer.borderWidth = 2
//        scrollView.layer.borderColor = UIColor.blue.cgColor

        tutorialView.heightAnchor.constraint(equalTo: parentScrollView.heightAnchor).isActive = true
        tutorialView.widthAnchor.constraint(equalToConstant: 1200).isActive = true

    }


Sum of two indpendent Poisson Distribution graph

Question: Let $X$ and $Y$ be independent. I know that if $X$ ~ $Poisson (a)$ and $Y$ ~ $Poisson (b)$ then $X + Y$ ~ $Poisson (a+b)$, but I don't fully understand why. I know how to develop the equation for it, but i'm lacking an intuitive sense of how this changes from a graphic perspective. Does anyone know of any visual source that can help explain this?
Comment: Not sure if this is what you're after, but this is the proof of the statement you referenced: https://math.stackexchange.com/questions/221078/poisson-distribution-of-sum-of-two-random-independent-variables-x-y
Comment: I looking for more of a "visual" proof. Just something that can Poisson distribution for 2 independent sets and then shows the combined one.
Comment: What does that mean? Poisson distribution of 2 sets? Poisson distribution is a measure!
Answer: You can think of $X$ as the number of times an event occurs, in a period where on average it happens $a$ times, if the occurrence of such events is memoryless, i.e. no knowledge of events' histories affects the distribution of the number of events in any subsequent period. You can think of $Y$ as the number of times another such kind of event occurs, this time with average frequency $b$. So the interpretation is that defining "one event type or the other" events, if they're independent, retains the memorylessness property. This is the point @StashuKozlowski was making.
Answer: I'm not sure what you mean by 'visual', and the link @scoopfaze gave has a pretty comprehensive list of solutions. I'll try nevertheless to give a combinatorial, so to say, argument for the support of $X+Y$. Since both rvs have a non-negative support $X\geq 0$, their sum can take only non-negative integer values $n$.
At the same time, any positive integer $n$ is expressed as a sum of two non-negative integers (i.e. incl. $0$) in exactly $n+1$ number of ways: $n = k + (n-k), \ 0 \leq k \leq n$.
This determines the number of convolutions for each outcome of $X+Y$.


Windows 2003 Active Directory: Log failed login attempts with the password used?

Question: Windows 2003 Active Directory: Log failed login attempts with the password used?
I want to log not only the username but the password used also for debugging purpose. Is there a way to do that? One of the application is not able to connect with passwords of less than 9 characters, so I want to see what is the username and password received by the Windows 2003 system.
Comment: something sounds fishy about this, if an app needs 9+ characters (strange) then just set it to 9+ characters...
Answer: No. You can't do this. It would be horrible security practice to do anyway since you'd be collecting a very long list of usernames and passwords that your user likely use for other services.
What you can do is enforce a minimum password length of 9 characters in Group Policy, which seems like a sensible thing to do, given the problem at hand.
Comment: @Priyank He answered your questions in the first part.  It's not possible to log the password used for Windows login.
Comment: This is not what I asked. I am not talking about security practice. I have to debug some issue, and I will be using my own username/password. Also the password length policy is already there for 8 characters and above, but that particular application is not able to login with 9 characters passwords, so I want to check what is the password being send.
Comment: I did answer you, as @squillman points out. The passwords are salted and hashed before they're sent across the wire.
Answer: Logging the plaintext password is even technically impossible, because the server does not receive it at all — all authentication protocols currently used by Windows use the so called "NT hash" (MD4 hash of the UTF-16LE password representation) instead of the password, and even the NT hash is not passed directly to the server (even in encrypted form), but is used either as HMAC key (in NTLMv2), or as an encryption key for the Kerberos TGT. Therefore the server can only check whether the password is correct, but is unable to determine even whether several successive incorrect password attempts were using the same password.
Answer: Since it's not possible to log plaintext password failures, can you debug the issue from the other side, and look at your app to determine why it won't work with passwords <9 characters?  Sounds like the application itself might have some password requirements that one would think should be configurable.
Though, for what it's worth, I think MDMarra's suggestion of forcing users to have passwords of >= 9 is a good one.  With the computing power available in even a desktop (or desktop GPU), it's no longer safe to assume that 8 characters and 3 of 4 character sets is enough to keep brute force and rainbow tables attacks at bay.


Bing maps with VB

Question: Hi I have written a piece of code which allows the program to take a postcode from a text box then type it into Bing for the user. This works perfectly fine when I use www.bing.com but if I was to use http://www.bing.com/maps/?mkt=en-gb so that the postcode is type directly into Bing maps then it crashes. I have included a copy of my code which works with the standard Bing search but would like some advice on allowing the program to search directly into Bing maps without the program crashing.
Thank you
Public Class Form1
<code>Dim Automate As Boolean

Private Sub BTNMAPP_Click(sender As Object, e As EventArgs) Handles BTNMAPP.Click
    Automate = True
    BingBrowserWindow.Navigate("https://www.bing.com")
End Sub

Private Sub BingBrowserWindow_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles BingBrowserWindow.DocumentCompleted
    If Automate = True Then Automate = False Else Exit Sub
    Dim txt As HtmlElement = BingBrowserWindow.Document.GetElementById("q")
    Dim btn As HtmlElement = BingBrowserWindow.Document.GetElementById("go")

    txt.SetAttribute("value", PostcodeTextBox.Text)
    btn.InvokeMember("click")

End Sub
</code>
Answer: You can find documentation on how to create a custom URL to the Bing Maps consumer site here: https://msdn.microsoft.com/en-us/library/dn217138.aspx
That said, you really should be using the Bing Maps WPF control inside of your app. It makes for a much better user experience and would make your align with the terms of use of Bing Maps. Similarly you should be using the Bing search API's instead of loading the Bing search page in your app.

Bing maps with VB