Assign User Points in existing website which already contains content

Question: Question specific to "User Points" module, backcopy of question from here due to no response: https://www.drupal.org/node/2492933
Drupal 7 -
I have a website which is already running for more than 2 years. Many users have been adding content to it and now I have a requirement where I need to assign points to the user. I came across this great module but this does not let me assign values to the user based on the content they have already contributed, revisions already worked on and also the comments provided already.
I have tried to google and also checked the module thoroughly but there is no way to do what I want to achieve. Is there a way to achieve this?
Answer: I think User Points Contributed modules is your best alternative available today. I. e. submodule userpoints_retroactive. Excerpt from that project page:

Award users points for their nodes, comments and votes that they have created so far, before userpoints was enabled on the site.

However, the port of this module to D7 still needs work. Maybe you can/want to somehow contriute to the finishing touch of that issue?
PS: there is also Berdir's Api documentation about this submodule ... (maybe that helps somehow).
Comment: Thank you, good find. Will wait and see if there are any other answers / possibilities, if not I will try the same.
Comment: Thank you for the guidance, I have ported the module and I provided enhancements to the contributed modules.
Answer: I used User Points Contributed modules and I provided a patch with which points are awarded for nodes and revisions in past and also the points transactions are stored across with the dates on which the node was created or revision was made.
Issue and patch: https://www.drupal.org/node/1187616#comment-10004999


Create instance of a class with dependencies using Autofac

Question: Problem:
Assume the class:
public class MyAwesomeClass
{
   private IDependCls _dependCls;
   public MyAwesomeClass(IDependCls dependCls)
   {
       _dependCls = dependCls;
   }

}

And somewhere else I need to get an instance of that class, like so:
public class SomewhereElse
{
    public void AwesomeMethod()
    {
        //...
        // AwesomeStuff
        //...

        var GetErDone = new MyAwesomeClass();  // PROBLEM! No constructor with 0 arguements
    }
}

Question is, do I
Proposed solution 1:
A) have to make an extra constuctor that resolves the dependency? For example:
   public MyAwesomeClass() // new constructor
   {
       _dependCls = DependencyResolver.Current.GetService<IDependCls>();
   }

public class SomewhereElse
{
    public void AwesomeMethod()
    {
        var GetErDone = new MyAwesomeClass();  // IT WORKS!!
    }
}

Proposed solution 2:
B) use the resolver inside AwesomeMethod right before  var GetErDone
public class SomewhereElse
{
    public void AwesomeMethod()
    {
        var depCls = _dependCls = DependencyResolver.Current.GetService<IDependCls>();
        var GetErDone = new MyAwesomeClass(depCls);  // IT WORKS!!
    }
}

Autofac solution?
C) Some other Autofac way?
Looking for best practices, as well as a good Autofac solution if possible. I think the first way is the worst as optional dependancies could lead to a lot of clutter.
Summary:
How do I get a new MyAwesomeClass() when MyAwesomeClass has dependencies?
Comment: Do you really mean _optional_ when you say it? If it really is optional, you may want to look into property injection. If not, and your ctor is cluttered because of too many dependencies, maybe your class is doing too much (see also [this answer](http://stackoverflow.com/a/2420245/1282778)).
Comment: I don't have a question about constructor clutter, rather than creating an instance of a class that needs constructor injection.
Comment: Thanks for not posting the solution answer. Not like any body else has this issue... /s
Answer: Have a look at the Composition Root pattern.
You are right, pulling up the dependency resolution only moves the problem to another place. If you continue to move it upwards in your object graph, though, you will reach the entry point of your application. There you will compose your object graph.
Compare that to the Service Locator anti-pattern (using DependencyResolver in client classes in your case) and you will see that Composition Root is a superior solution.
Comment: @Mihalis - Did you ever get a satisfactory solution using the Composition Root pattern or otherwise. You example code is easy to follow and I would like to see the code for the 3rd solution - thans
Comment: No Examples + dead link + OP never posted an answer = terrible question/answer.
Comment: Thanks for the reply. +1 because you actually have a grasp on the concept, and thanks for your article. So I guess this will happen inevitably? I am going to read on this approach more but I think that the actual composition root as you call it should be the declaration of the binding itself. Otherwise, you break both the single responsibility and the separation of concerns rule.
Comment: Yes, the Composition Root is defined abstractly as a "location", you can split it in several classes, but it is important that they are contained in the same assembly. Mark Seemann, the author of the articles, wrote [a great book](http://www.amazon.com/Dependency-Injection-NET-Mark-Seemann/dp/1935182501) about DI btw.
Comment: I think everyone would probably agree that using DI in the constructor as Seemann more or less explains seems to be the best solution.  However there are instances where you might need to dynamically get an instance of a controller at which point you would need a parameterless contstructor and then the Service Locator would seem to be our only option?
Comment: @MartinDawson Both links seem to be working from here. What example would you have liked to see?
Answer: First of all apart from constructor injection you can also use property injection and method injection. However constructor injection is most common and the fastest method so I suggest to stick to it.
The second thing you need to do is to register your MyAwesomeClassin the Autofac container along with its dependency, they have some nice examples right at their home page.
And the last thing - you should not create instances of MyAwesomeClass directly - use Autofac instead. Here is an updated example:
public void AwesomeMethod()
{
    //...
    // AwesomeStuff
    //...

    var GetErDone = DependencyResolver.Current.GetService<MyAwesomeClass>();
}

Comment: will this create a new instance or already registered service?
Answer: You can create a new instance of 'MyAwesomeClass' with reflection, resolving the constructor parameters with Autofac.
    public static T Instance<T>() where T : class
    {
        Type instanceType = typeof(T);
        ConstructorInfo constructorInfo = instanceType.GetConstructors()[0];
        ParameterInfo[] constructorParamsInfo = constructorInfo.GetParameters();
        object[] constructorParams = new object[constructorParamsInfo.Length];

        for (int i = 0; i < constructorParamsInfo.Length; i++)
        {
            var parameterInfo = constructorParamsInfo[i];
            var type = parameterInfo.ParameterType;
            constructorParams[i] = Container.Resolve(type);
        }

        object instance = Activator.CreateInstance(instanceType, constructorParams);

        return (T)instance;
    }

Answer: If you want to resolve instance automatically via Autofac, you can only choose from this

Inject in constructor of your class
Inject in property, by using
var builder = new ContainerBuilder();
builder.RegisterType<Foo>().PropertiesAutowired();
Use global access by DependencyResolver.Current.GetService<IFoo>();
Comment: I am using constructor injection but I am asking about the actual process of creating an instance of that class.
Comment: What do you mean process of creating an instance of that class ? What class do you want to instantiate ? And what exactly do you want to do ? Prodide more information
Comment: Please see the second gray block. If I use the code as is, I get a problem (of course). Then, I propose 2 solutions which I don't like, and ask for a third - or a confirmation that one of the 2 I propose is standard practice. I will update the answer to actually include my solutions for you to see
Comment: If you want instantiate MyAwesomeClass inside method, the best way is using DependencyResolver. But, I think it's bad practise to instantiate something in your method. You should create interface IMyAwesomeClass and use ctor injection in class using it. After that you can use class field in you method
Comment: Yes, DependencyResolver can be used in 2 different places (the solutions I am proposing). However, I would like a solution that doesnt involve DependencyResolver. About an interface, please see me comment on @Peter Lillevold answer. The problem stays the same, just one level higher. ( `SomewhereElse` class will NEED to get  `new SomewhereElse()` at some point, so same problem there)
Answer: In the class containing MyAwesomeMethod take MyAwesomeClass as a constructor dependency. Autofac will take care of the instantiation.
Comment: yes but this just move the problem one class higher up, this is the point I am actually. What if I want to make an instance of the class containing `MyAwesomeMethod` ?
Answer: I know that this question is old, but I found a quite useful link on the autofac documentation describing dynamic instantiation of classes.
Autofac Dynamic Instantiation
Perhaps it could be helpful for someone.


Bootstrap Tabs displaying stacked rather than inline

Question: Bootstrap Tabs displaying stacked rather than inline.
What I want (taken from Bootstrap Website):

What I get (notice the tabs 'Tenants' and 'Landlords' are stacked):

Bootstrap Code (taken from website):

My code:

Tenants

Landlords

...

Anyone know what's wrong?
Comment: it's `nav-tabs` not `nab-tabs`
Comment: What is your ".list-inline" class that you've added doing?
Comment: saw that somewhere online, was an attempt to fix but doesn't do anything. I'll take it out in the question.
Comment: wow, now i feel stupid. thanks Lars
Comment: don't worry bout it, we all feel like a bit of a [nab](http://www.urbandictionary.com/define.php?term=nab) sometimes.
Comment: Dang [nab-bit](http://www.urbandictionary.com/define.php?term=dang+nabbit) !
Answer: Typo pointed out by @Lars:
"it's nav-tabs not nab-tabs"


Limit of $\frac{e^{x}}{\ln(x)}$

Question: I don't know how to find the limit
$$\lim_{x\to\infty}\frac{e^x}{\log x}.$$
How can I do this ?
Thank you in advance.
Comment: This is highly dependent on what you can use.
Answer: For $x > 1$,
$$
\frac{e^x}{\ln x}
> \frac{1 + x + \frac{x^2}{2!}}{x} > \frac{x}{2} \to \infty.
$$
The relevant inequalities can be proved by elementary means;
see for example here and here.
Comment: @DanielFischer I see.  Thanks :)
Answer: You may also use the L'Hôpital's rule which, in this case, in view of the answer given by Goos, would be like killing a fly with a cannon...
I am giving you this information because L'Hôpital's rule is quite useful in some much more difficult problems involving limits (see the link for such examples), so it's good to know it.
Answer: $\frac{\exp(x)}{\ln(x)} > \frac{\exp(x)}{x} > x$
First part because $x > \ln(x)$
Second part because $\exp(x) > x^2$ as $x^2 = \exp(2 \cdot \ln(x))$ and $x > 2 \cdot \ln(x)$ for $x$ greater than 2. And exponential is an increasing function
Comment: Hi, you should use `\exp` for the exponential function, `\ln` for natural log, and `\cdot` for multiplication.
Comment: I see that you edited with the correct format, but I can't see the edited post for some reason. I'll make sure to remember this.
Answer: $$e^x>x\log x,\quad x\ge 1,$$
since $e=e^1<1\cdot\log 1=0$ and
$$e^x=\frac{d}{dx}e^x<\frac{d}{dx}(x\log x)=1+\log x.$$

Limit of $\frac{e^{x}}{\ln(x)}$


What is the best way to create pie graphs and other animated dynamic info graphics?

Question: What is the best way to create pie graphs and other animated dynamic info graphics?
Should I look into js libs like paper.js or should I create my own using minimal js and css3?
Examples are really what I'd like to see. Thanks!
Answer: In my opinion, Google Chart is a good option: http://code.google.com/apis/chart/
Comment: Do they update and animate in real-time? Are they fully customizable?
Comment: There is a chart gallery with many examples: http://code.google.com/apis/chart/interactive/docs/gallery.html, and the API is very easy
Answer: There are a number of javascript libraries out there which will do this for you. There certainly isn't any need to be rolling your own code.
If you do want to write your own, be aware that to get the kind of effects available with some of the libraries will take a lot more than minimal js code. Sure you could write a very basic script that draws pie segments in a fairly small amount of code, it won't have the animations or dynamic properties you'd get from using a library. And most libraries really aren't that big considering how much they do.
My favourite library for this sort of thing is Raphael, along with it's graphing sister library g.Raphael.
The beauty of Raphael is that it makes it very easy to produce quite complex graphics, including some very nice animated graphs. See the examples on the site above, which includes pie charts.
It's all Javascript-based so you can update it on the fly.
In addition, Raphael scores over other similar libraries in that it works flawlessly even in older versions of IE (as far back as IE6!), as it uses SVG on modern browsers, and falls back to VML for old versions of IE.
Hope that helps.
Comment: @Hal50000: In October 2015 when I wrote this answer, it was easily the best library of it's type, particularly because of it's compatibility with old IE versions. Five years on, that latter point is much less of an issue and other libraries have come along that can do similar things more elegantly. I still consider Raphael to be a very good piece of software though; it broke a lot of ground for others to follow, and it's still usable and respected today.
Answer: I have used and actually liked this library: http://www.highcharts.com/
There are quite a few other options though - I see no point in reinventing the wheel.


Which distributions are parameterization invariant when based on the Jeffreys prior?

Question: I understand that the Jeffreys prior provides a method for constructing a prior distribution over parameters for a given model (likelihood function) such that the prior distribution is "invariant under reparameterization." I understand this invariance to mean that the Jeffreys prior for a given set of parameters can be converted to a prior distribution over a second set of parameters (via the standard change of variables method for probability distributions), and the resulting prior will match the Jeffreys prior for the second set of parameters.
Does a similar kind of invariance exist for:

the posterior distribution based on the Jeffreys prior? (i.e. does the posterior derived from a Jeffreys prior possess the same invariance properties as the Jeffreys prior?)
the prior predictive distribution based on the Jeffreys prior? (i.e. does the prior predictive distribution derived from a set of parameters and the corresponding Jeffreys prior match the prior predictive distribution derived from a second set of parameters and the corresponding Jeffreys prior?)
the posterior predictive distribution based on the Jeffreys prior? (similar to #2)
the MAP (maximum a posteriori) parameter estimate based on the Jeffreys prior? (i.e. does the distribution over the data space based on one set of MAP parameters match the distribution based on the MAP parameters for a different parameterization, where both parameter posterior distributions are based on the corresponding Jeffreys priors)
Comment: It's worth noting that the Jeffrey's prior is only invariant under monotone transformations.
Comment: Also, I am not sure about all of the quantities you mentioned above, but I do believe that the posterior, under the Jeffrey's prior, will also be invariant to transformations.  See this paper as a reference: http://users.stat.umn.edu/~sudde001/personal_page/jeffreys.pdf
Answer:
Yes. And actually this is the interesting invariance property: it means that two Bayesians using a different parameterization of the model but both using the Jeffreys prior, obtain the same posterior distribution (up to change-of-variables) to draw inference.
Conceptually, there's no prior predictive distribution based on the Jeffreys prior. The goal of the Jeffreys prior is to provide a posterior distribution which reflects as best as possible the information brought by the data. There's no prior belief about the parameters, hence no prior predictive distribution of the data.
It is not clear what you mean by invariance for a (prior or posterior) predictive distribution. But note that from 1), two Bayesians using the Jeffreys prior but different parameterizations, obtain the same posterior predictive distribution.
The MAP is the mode of the posterior distribution. It is not invariant, in the sense that if you use $\theta$ as the model paramater on one hand, and $\psi=f(\theta)$ on the other hand, with $f$ one-to-one, then the mode of the posterior distribution of $\psi$ is not the image under $f$ of the mode of the posterior distribution of $\theta$. That means that our two Bayesians, both using the Jeffreys prior but using different parameterization, will get incoherent results if they consider the MAP as the parameter estimate.
Comment: @StéphaneLaurent: thanks for your helpful answer! I'm not sure I follow your argument for #2, for example: "There's no prior belief about the parameters"... isn't that what the parameter prior distribution represents? Is it not valid to treat the posterior predictive with no prior data as the prior predictive? In #3, yes, I wanted to know whether "two Bayesians using the Jeffreys prior but different parameterizations, obtain the same posterior predictive distribution," just as you said.
Comment: @TylerStreeter I only agree with Bernardo's definition of a noninformative prior: this is not a prior distribution, this is only a function which provides an appropriate posterior distribution via a formal application of Bayes' formula (as if it were a prior distribution, but it is not).
Comment: @StéphaneLaurent: Ok, now I see where you're coming from. I suppose I was focusing only on cases where the prior is proper and can be interpreted as a distribution.
Comment: @TylerStreeter Even when it is proper, it is not a dsitribution. Otherwise that would mean then you consider a prior predictive dietribution for the data. That makes no sense because you have no prior belief. Examine the famous case of the binomial model: the prior predictive distribution of the data would be U-shaped, why would we consider such a distribution is "noninformative" ? That makes no sense to say that a distribution is noninformative.
Comment: @StéphaneLaurent I assume you mean the prior distribution (not prior predictive) for the binomial parameter is U-shaped? Also, if the prior is proper, then I would assume the word "distribution" still applies... regardless of its interpretation. (In what way does it not match the technical definition of a distribution?)
Comment: @TylerStreeter The prior distribution of $\theta$ *and* the prior predictive are U-shaped. I prefer thinking in terms of predictive distribution because it is more concrete. Yes, saying that the prior is not a distribution this is just a matter of interpretation.
Comment: @StéphaneLaurent I see... I never noticed that the posterior predictive for the binomial model was also U-shaped. I too prefer thinking in terms of predictive distributions. (Actually that's why I created this question: to understand better how the Jeffreys prior influences predictive distributions.)


Is it enough to show that function is a valid kernel if it is an inner product?

Question: I've been studying kernel methods in my course and in a textbook came across an additional line (aside from the positive definiteness of the Gram/Kernel Matrix).
That it should be enough for a kernel to be a valid inner product.
Now for one of last years exercises I found that $\frac{1}{K(x,y)}$ for a valid Kernel $K(x,y)$ is not a valid kernel.
The proof is given by showing that the matrix is not necessarily positive definite (which is easy to follow).
That however confuses me, because if the rule stated above holds, then $K(x,y)$ is an inner product.
I can show that the reciprocal is also symmetric and linear with a little algebra. Positive semi-definitenes seems to also be guaranteed.
And thus I arrive at contradictory statements.
Do I overlook something major (probably)?
I am suspecting I am doing something wrong with my attempt at showing the reciprocal is an inner product.
thank you!
Comment: It's the opposite: inner products are kernels, but kernels are not necessarily inner products. The point of the [M-A theorem](https://en.wikipedia.org/wiki/Reproducing_kernel_Hilbert_space#Moore%E2%80%93Aronszajn_theorem) is that a kernel *corresponds to* an inner product (over a reproducing kernel Hilbert space), but the kernel is not technically (necessarily) an inner product.
Comment: What exactly do you mean by "positive semi-definiteness seems to also be guaranteed"? The example given in the proof you mention seems to show that it this is not necessarily the case
Comment: Also, note that it is not usually correct to say that a kernel $K(x,y)$ "is an inner product" even if that kernel is valid.
Comment: Note that the condition that $K(x,x) > 0$ for all $x$ is not enough to make $K$ a valid kernel. If (a symmetric function) $K$ satisfies $K(x,x) > 0$ **and** is linear in each argument, then $K$ must be a kernel because it is an inner product.
Comment: If $1/K(x,y)$ is **not** linear in each argument (which is usually true), then the fact that $1/K(x,x)  > 0$ for all non-zero $x$ is **not** enough to ensure that $1/K(x,y)$ is a kernel.
Comment: I'm glad I was helpful!
Comment: hi @BenGrossmann I meant that the inner product $\frac{1}{K(x,x)}$ is always > 0 because $K(x,x)$ is > 0.
Thanks! I think your second comment made me understand, so all kernels have to be inner products, but an inner product is not necessarily a kernel?
Comment: I see, that's how I originally understood it @BenGrossmann.

But then, if $K(x, y)$ is a valid kernel, how can $\frac{1}{K(x,y)}$ not be a valid kernel?
Because the reciprocal should also be linear and I can not see how it could be $<0$
Comment: @BenGrossmann Thank you!
I made a huge blunder, I think I can see now how it's not linear, I was pulling $\frac{1}{scalar}$ out of the fraction but made an algebraic mistake by using it as $scalar$ thank you so much!!!!
Answer: To summarize the discussion in the comments: the main misconception seems to have been that if $K(x,y)$ is linear in each of its arguments, then $1/K(x,y)$ must also be linear in each of its arguments. However, this is not the case. Thus, the condition that $1/K(x,x) > 0$ for all $x$ is not sufficient to ensure that $1/K(x,y)$ defines an inner product.
Comment: This is correct, thank you Ben for your patience and insight!


In mutual authentication, if a client certificate is known, does it need to be CA signed to prevent a MITM attack?

Question: Take an example: A povider has setup an API.  Both parties (provider and client) trust eachother. Mutual authentication is required by provider. Client generates a SSL certificate and sends it by SFTP over to the provider. Does that client certificate need to be CA signed to increase security (as in preventing a MITM attack ) ?
Answer: No, do not sign the certificate as it does not add security.
If anything, it slightly decreases security, because there is one more private key to guard (CA private key).
Both ways require the initial client contact to be authenticated with a separate mechanism, that doesn't change.
Both ways require to match CN field with client's identity, so that trusted client Bob cannot impersonate trusted client Alice.
Certificates expire with time. The main motivation behind CA-signing is to avoid re-distributing renewed certificate over multiple trustees and I assume you only have one trustee (i.e. one server for all the clients). Perhaps surprisingly, my reasoning holds all the same for the server certificate: if you have a single client, you don't gain all that much by CA-signing the server cert.


MSSQL question marks in php on windows with apache

Question: I have Microsoft SQL Server 2008 R2 on Windows Server 2008 R2.
And php 5.6 on Apache.
In SQL Server I have DB with COLLATE Cyrillic_General_CI_AI.
In SQL Server Management Studio I can see everything without any problems.
BUT
Then I do this:
<?php
$conn = sqlsrv_connect( $serverName, $connectionInfo);
$sql = "SELECT NAME FROM NAMES";
$stmt = sqlsrv_query( $conn, $sql );
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) ) {
    echo $row['NAME'];
}

I get ??????????????? question marks instead words.
Important condition: I can use only sqlsrv_connect().
Please help me.
Thank you!
Comment: you didn't tell your output environment that you're spitting out cyrillic text, so it'll render your text in whatever charset that environment is using, e.g. iso8859.
Comment: What you mean output environment? Where from iso8859 goes?
Answer: Set the correct charset in your browser:
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">

or via PHP with:
header("Content-Type: text/html; charset=windows-1251");

Comment: It's not a browser problem. sqlsrv_fetch_array get question marks.
Comment: @AlexanderMatrosov Doubtful. Whatever you're using to view the output likely doesn't know how to visually represent the data. If you're not seeing this in a browser then you need to fix the encoding issue in whatever it is you're viewing it with.
Comment: Anyway, this method didn't work. In Chrome with ANY enoding I see questions
Answer: So.
If Microsoft (burn in hell) do not have language pack for language you use in your SQL server, then you will see question marks.
To solve it - instal language pack to your server copy.
Thank you, microsoft again, for you stupidity and your utf-8 dislike.


What is the JavaFX equivalent of this CSS linear gradient?

Question: .Spectrum {
    background-color: linear-gradient(135deg, rgb( 23,240,245) 0.000%,
                                              rgb(  5,  5,250) 20.000%,
                                              rgb(253,  5,245) 39.990%,
                                              rgb(253, 10, 23) 60.010%,
                                              rgb(248,250, 23) 80.000%,
                                              rgb( 17,233, 17) 100.000% );
}
Answer: Assuming nodes with style class "Spectrum" are instances of Region (which includes all layout panes and controls), then
.Spectrum {
    -fx-background-color: linear-gradient(to top right,
         rgb( 23,240,245) 0.000%,
         rgb( 5, 5,250) 20.000%,
         rgb(253, 5,245) 39.990%,
         rgb(253, 10, 23) 60.010%,
         rgb(248,250, 23) 80.000%,
         rgb( 17,233, 17) 100.000% );
}

Comment: I think you meant to use "to bottom right" which is closer to what I want. But it doesn't seem that the 135deg part is valid JavaFX-CSS


Crontab - Sending StdErr to email and stdOut to log file

Question: In my crontab, I'm trying to send stdout to log file and stderr to email account using a custom subject title.
I've tried many solutions without achieving my initial goal, let me explain:
First method: using MAILTO
firstname.lastname@example.com
*/1 * * * * /my/script.sh > /my/file_stdout.log

This send stdout to log file and error to email, but the drawback is that I can't figure out how to update the email subject and what I have in consequence is Subject: Cron  /my/script.sh > /my/file_stdout.log.
Second method: using mail
I've playing arround with many ways of using mail but none of them works like I want:
*/1 * * * * /my/script.sh > /my/file_stdout.log 2>&1; [ $? != 0 ] && mail -s "Subject here" email@example.com < /my/file_stdout.log

another one :
*/1 * * * * /my/script.sh > /my/file_stdout.log 2>&1 || mail -s "Subject here" firstname.lastname@example.com < /my/file_stdout.log

another one :
*/1 * * * * /my/script.sh 2>&1 | tee /my/file_stdout.log | mail -s "Subject here" email@example.com < /my/file_stdout.log

another one:
*/1 * * * * OUTPUT=`/my/script.sh 2>&1` || echo "$OUTPUT" | mail -s "Subject here" firstname.lastname@example.com

Also I've noticed that or operator || doesn't work in my crontab, I even change the shell of crontab to /bin/bash ( by adding SHELL=/bin/bash variable).
I'm on Redhat entreprise server, and don't have Admin access so I can't install tools like chronic !
Answer: I finally get it to work, and found the issue with || operator, the script was always returning code 0, so now I've added explicitly a return statement at the end of the script, and now work as expected :
*/1 * * * * (/my/script.sh > /my/file_stdout.log 2>&1) || mail -s "Subject here" email@example.com < /my/file_stdout.log


O que significa duas chaves no JavaScript?

Question: Entendi o "===" que testa valor e tipo, diferente do "==" que testa apenas valor, porém não entendi a dupla chave, tipo: {{alguma_coisa}}, por exemplo em um JavaScript que possuo, tem algo assim:
mozL10n.get('page_of', {pageCount: pagesCount}, 'de {{pageCount}}');

Há mesmo a necessidade das duas chaves?
Comment: "l10n" significa *localization*, artigo relacionado: http://www.w3.org/International/questions/qa-i18n#l10n
Comment: Parece ser a notação de algum framework, talvez o angularjs
Answer: Isto é específico desta API não padrão. Evite usá-la.
É um placeholder. É usado para produzir uma interpolação de string, ainda que use uma forma mais simples. É muito parecido com o {0} usado em C#, mas um pouco melhor porque a expressão pode ser usada dentro da string, como na interpolação de string do C#. Esta expressão será avaliada e o seu resultado é que será impresso neste local.
As chaves duplas foram escolhidas para evitar alguma ambiguidade, poderia ser qualquer outra coisa. O importante é ter algum caractere que marque início e fim da expressão e que seja algo pouco usado em textos normais, para evitar ter que escapar e imprimir isto de forma normal.
Coloquei no GitHub para referência futura.
Comment: Vale a pena adicionar que no ECMA Script 6 haverá um recurso padrão semelhante, porém con sintaxe diferente. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/template_strings
Answer: Neste exemplo:
var a = {};
console.log(a);

Ele é utilizado apenas para inicializar um objeto sem nenhum valor no mesmo.
No seu Exemplo:
mozL10n.get('page_of', {pageCount: pagesCount}, 'de {{pageCount}}');

Ele é utilizado como um padrão de template para identificação de valores que serão modificados, isto não é do javascript e sim uma convenção da sua API.
Comment: Que é substituído por um valor ok, o que eu não estava entendendo é a utilização de duas chaves, achei que pudesse ser alguma novidade em versões mais recentes do javascript.
Comment: Entendi ambos, Gabriel e bigown. Um placeholder como disse o bigown.
Comment: @pnet é interessante você especificar qual framework você esta utilizando para que nos possamos responder de forma mais especifica, pelo menos no novo javascript ES6 não tem nada de novo sobre isto.
Comment: Vocês já responderam a razão da dupla chave.


Holomorphicity of $F(z)=\int_{-\infty}^{+\infty}\frac{f(t)}{t-z}dt$

Question:
Let $f:\Bbb{R} \to \Bbb{C}$ a continuous function and assume that $\int_{-\infty}^{+\infty}\frac{|f(t)|}{|t|+1}dt< +\infty$
Prove that  $F(z)=\int_{-\infty}^{+\infty}\frac{f(t)}{t-z}dt$ is holomorphic at every $z \in  \Bbb{C} \setminus \Bbb{R}$

From a theorem in complex  analysis i belive that the derivative of this function  is $G(z)=\int_{-\infty}^{+\infty}\frac{f(t)}{(t-z)^2}dt$
Let $z_0 \in \Bbb{C} \setminus \Bbb{R}$ ,so exists $>0$ such that $D(z_0,r)\subseteq \Bbb{C} \setminus \Bbb{R}$
If we take a smaller disk with center $z_0$ and radius $\frac{r}{2}$ we have that $|z-t| \geq \frac{r}{2}$ and $|t-w| \geq \frac{r}{2},\forall w \in D(z_0,\frac{r}{2}),\forall t \in \Bbb{R}$
So doing some algebraic manipulations i arrived at the inequality $$|\frac{F(w)-F(z_0)}{w-z_0}-G(z_0)| \leq  \int_{-\infty}^{+\infty}\frac{|f(t)|}{|t-z|}dt\frac{|w-z_0|}{\delta^2}$$
But i could not proceed any further and use my hypothesis.
Can someone help with this?
Thank you in advance.
Comment: Can "holomorphicity" be more simply called "holomorphy"?  As in: "Holomorphy of $F(z)$" ... MathSciNet has 260 reviews with "holomorphicity" and 2050 with "holomorphy".
Answer: Since $z_{0}\notin{\bf{R}}$, then $|t-z_{0}|\geq|\text{Im}(z_{0})|>0$ for all $t\in(-\infty,\infty)$.
Consider now $w\in B_{\delta}(z_{0})$ for a small $\delta>0$. We let $\delta<|\text{Im}(z_{0})|$.
We have $|t-w|\geq|t-z_{0}|-|z_{0}-w|\geq|t-z_{0}|-\delta\geq|\text{Im}(z_{0})|-\delta>0$ for any $t\in(-\infty,\infty)$.
the function $\dfrac{|f(t)|}{|t-z_{0}|}$ is continuous on the compact set $\{|t|\leq 2|z_{0}|+2\delta+1\}$, and hence $\displaystyle\int_{|t|\leq 2|z_{0}|+\delta+1}\dfrac{|f(t)|}{|t-z_{0}|}dt<\infty$.
Now we want to find that a dominated integrable function of
\begin{align*}
\left|\dfrac{f(t)}{(t-w)(t-z_{0})}\right|
\end{align*}
which the dominated integrable function must be independent of $w$, if we succeed to do that, then the rest is just by Lebesgue Dominated Convergence Theorem.
On $\{|t|\leq 2|z_{0}|+2\delta+1\}$, we have
\begin{align*}
\left|\dfrac{f(t)}{(t-w)(t-z_{0})}\right|\leq\dfrac{1}{|\text{Im}(z_{0})|-\delta}\dfrac{|f(t)|}{|t-z_{0}|},
\end{align*}
and it is already shown that the latter is integrable on the compact set.
On $\{|t|>2|z_{0}|+2\delta+1\}$, one sees that
\begin{align*}
|t|-|z_{0}|-\delta>\dfrac{1}{2}(|t|+1),
\end{align*}
so
\begin{align*}
|t-w||t-z_{0}|&\geq|\text{Im}(z_{0})|(|t-z_{0}|-|w-z_{0}|)\\
&\geq|\text{Im}(z_{0})|(|t|-|z_{0}|-\delta)\\
&\geq\dfrac{|\text{Im}(z_{0})|}{2}(|t|+1),
\end{align*}
but then
\begin{align*}
\left|\dfrac{f(t)}{(t-w)(t-z_{0})}\right|\leq\dfrac{2}{|\text{Im}(z_{0})|}\dfrac{|f(t)|}{|t|+1}
\end{align*}
which is integrable by assumption. So a dominated integrable function can be taken as
\begin{align*}
\dfrac{1}{|\text{Im}(z_{0})|-\delta}\dfrac{|f(t)|}{|t-z_{0}|}\chi_{|t|\leq 2|z_{0}|+2\delta+1}+\dfrac{2}{|\text{Im}(z_{0})|}\dfrac{|f(t)|}{|t|+1}\chi_{|t|>2|z_{0}|+2\delta+1},
\end{align*}
we are done.


Why isn't my overriden clean_password function not working?

Question: I a form that subclasses another form in Django:
class RegistrationForm(forms.Form):
    ...
    def clean_password(self):
            if not re.search('[a-zA-Z]', self.data['password']):
                raise forms.ValidationError('Must contain a letter.')
            return self.data['password']

class addNewFamilyMemberForm(RegistrationForm):
    ...
    def clean_password(self):
        if self.data["username"]:
            super.clean_password(self)
        return self.data["password"]

Why is Django producing this error?
type object 'super' has no attribute 'clean_password'

The superclass of addNewMemberForm clearly has a clean_password function.
Answer: In Python 2, you need to use super like this:
super(addNewFamilyMemberForm, self).clean_password()

You should probably be using the return value somehow, but I'm not sure how.
Also, class names should start with a capital letter, though that doesn't affect how it works.
Answer: super is not actually an object, and you can not do "super.method". Maybe you should change that line to something like
super(addNewFamilyMemberForm, self).clean_password()


Dictionaries, for loop, and python

Question: fhand = open('mail.txt')
days = dict()

for line in fhand:
    split = line.split()
    if line.startswith('From') and len(split) > 2:
        days[str(split[2])] = days.get(str([split[2]]), 0) + 1
    else:
        continue
print days

And this is the output:
{'Fri': 1, 'Thu': 1, 'Sat': 1}

I'm trying to record the number of times a word is used through a dictionary. But the dictionary doesn't update its values and only gives me the last line's dictionary.
Any help would be appreciated. If need be I can provide the text file.
If I change the location of the print days to be inside the for loop then this is what I get (shrunk down because it's too large):
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}
{'Fri': 1, 'Thu': 1, 'Sat': 1}

Comment: glad you got your problem solved.  That looks like a syntax error.  In the future always copy and paste the complete traceback with your question.  That will help others help you!
Comment: What do you mean by "the last line's dictionary?". Also, there is no need for an `else` clause with a `continue`
Comment: I will edit my question to include the output. Also, thanks, I've just started learning python.
Answer: is there a typo here? days.get(str([split[2]]), 0)
shouldn't it be days.get(str(split[2]), 0)?

Dictionaries, for loop, and python


Change point analysis using R's nls()

Question: I'm trying to implement a "change point" analysis, or a multiphase regression using nls() in R.
Here's some fake data I've made. The formula I want to use to fit the data is:
$y = \beta_0 + \beta_1x + \beta_2\max(0,x-\delta)$
What this is supposed to do is fit the data up to a certain point with a certain intercept and slope ($\beta_0$ and $\beta_1$), then, after a certain x value ($\delta$), augment the slope by $\beta_2$. That's what the whole max thing is about. Before the $\delta$ point, it'll equal 0, and $\beta_2$ will be zeroed out.
So, here's my function to do this:
changePoint <- function(x, b0, slope1, slope2, delta){
   b0 + (x*slope1) + (max(0, x-delta) * slope2)
}

And I try to fit the model this way
nls(y ~ changePoint(x, b0, slope1, slope2, delta),
    data = data,
    start = c(b0 = 50, slope1 = 0, slope2 = 2, delta = 48))

I chose those starting parameters, because I know those are the starting parameters, because I made the data up.
However, I get this error:
Error in nlsModel(formula, mf, start, wts) :
  singular gradient matrix at initial parameter estimates

Have I just made unfortunate data? I tried fitting this on real data first, and was getting the same error, and I just figured that my initial starting parameters weren't good enough.
Answer: (At first I thought it could be a problem resulting from the fact that max is not vectorized, but that's not true.  It does make it a pain to work with changePoint, wherefore the following modification:
changePoint <- function(x, b0, slope1, slope2, delta) {
   b0 + (x*slope1) + (sapply(x-delta, function (t) max(0, t)) * slope2)
}

This R-help mailing list post describes one way in which this error may result: the rhs of the formula is overparameterized, such that changing two parameters in tandem gives the same fit to the data.  I can't see how that is true of your model, but maybe it is.
In any case, you can write your own objective function and minimize it.  The following function gives the squared error for data points (x,y) and a certain value of the parameters (the weird argument structure of the function is to account for how optim works):
sqerror <- function (par, x, y) {
  sum((y - changePoint(x, par[1], par[2], par[3], par[4]))^2)
}

Then we say:
optim(par = c(50, 0, 2, 48), fn = sqerror, x = x, y = data)

And see:
$par
[1] 54.53436800 -0.09283594  2.07356459 48.00000006

Note that for my fake data (x <- 40:60; data <- changePoint(x, 50, 0, 2, 48) + rnorm(21, 0, 0.5)) there are lots of local maxima depending on the initial parameter values you give.  I suppose if you wanted to take this seriously you'd call the optimizer many times with random initial parameters and examine the distribution of results.
Comment: Instead of that (cumbersome) **sapply** call in your first code snippet, you can always just use **pmax**.
Comment: [This post](http://www.biostat.wustl.edu/archives/html/s-news/1999-07/msg00212.html) by Bill Venables explains well the issues involved in this kind of analysis.
Comment: The Bill Venables link do not work!
Answer:
Just wanted to add that you can do this with many other packages. If you want to get an estimate of uncertainty around the change point (something nls cannot do), try the mcp package.
# Simulate the data
df = data.frame(x = 1:100)
df$y = c(rnorm(20, 50, 5), rnorm(80, 50 + 1.5*(df$x[21:100] - 20), 5))

# Fit the model
model = list(
  y ~ 1,  # Intercept
  ~ 0 + x  # Joined slope
)
library(mcp)
fit = mcp(model, df)

Let's plot it with a prediction interval (green line). The blue density is the posterior distribution for the change point location:
# Plot it
plot(fit, q_predict = T)

You can inspect individual parameters in more detail using plot_pars(fit) and summary(fit).

Change point analysis using R's nls()


Union of finite union of finite intersection

Question: Let $A = \bigcup_{i=1}^n \bigcap_{j=1}^m A_{ij}$ and $B = \bigcup_{k=1}^p \bigcap_{l=1}^q B_{kl}$  two sets. I want to find $C_{rs}$ such that
\begin{align}
A \cup B = \bigcup_{r=1}^{n+p} \bigcap_{s=1}^{m+q} C_{rs}
\end{align}
I tried to rewrite the union in this way
\begin{align}
A \cup B = \bigcup_{k=1}^p \bigcap_{l=1}^q \bigcup_{i=1}^n \bigcap_{j=1}^m (A_{ij} \cup B_{kl})
\end{align}
but now I don't see how to get the result.
Any suggestion? Thanks in advance!
Answer: Perhaps you wanted a less trivial approach than this, but this satisfies your conditions: Take
$$
C_{rs}=
\begin{cases}
A_{rs}&1\le r\le n\land1\le s\le m\;,\\
B_{r-n,s}&n\lt r\le n+p\land1\le s\le q\;,\\
A\cup B&\text{otherwise}\;.
\end{cases}
$$
Then
$$
\bigcap_{s=1}^{m+q}C_{rs}=
\begin{cases}
\bigcap_{j=1}^mA_{rj}&1\le r\le n\;,\\
\bigcap_{l=1}^qB_{{r-n},l}&n\lt r\le n+p\;,
\end{cases}
$$
so
$$
\bigcup_{r=1}^{n+p}\bigcap_{s=1}^{m+q}C_{rs}=\left(\bigcup_{r=1}^n\bigcap_{j=1}^mA_{ij}\right)\cup\left(\bigcup_{r=n+1}^{n+p}\bigcap_{l=1}^qB_{{r-n},l}\right)=A\cup B\;.
$$
The last case $C_{rs}=A\cup B$ is just an arbitrary choice to keep the additional sets from reducing the intersection; if you don't like the fact that $A\cup B$ appears there, you can use suitable $A_{rj}$ and $B_{rl}$ instead. (Or you could do away with these seemingly unnecessary sets altogether.)
Comment: @MacRance: We certainly do. I meant more generally, since these sets aren't contributing anything and we're just adding them because the problem requires there to be $m+q$ of them, we could change the problem and just have $m$ of them for $1\le r\le n$ and $q$ of them for $n\lt r\le n+p$.
Comment: Ok yes, I'm totally with you. It really just is a technical requirement.
Comment: *(Or you could do away with these seemingly unnecessary sets altogether.)* I'm not sure about this; after all, any element in $A \cup B$ (after rewritten using sets $C_{ij}$) must be in the intersection of all such $C$. Picking suitable $A_{ij}$ or $B_{ij}$ certainly works, though.
Comment: @MacRance: But these elements are already in one of the other sets; we don't need further intersections with $A\cup B$ to get them.
Comment: I was thinking that for any fixed $r$ and an $x \in A$ witnessed by $r$ we must have that $x \in C_{rs}$ for *every* $s \leq m+q$. Maybe I just misunderstand what you meant by *do away*
Answer: An element $x$ is in $A$ if there is an $1 \leq i \leq n$ such that for for every $1 \leq j \leq m$ we have $x \in A_{ij}$, and similarly for $B$. Now assume you're given $x$. So you need to check whether $$ \exists 1 \leq i \leq n \; \forall 1 \leq j \leq m \; (x \in A_{ij}) $$ Suppose you've checked all such pairs $(i,j)$. Now, after checking these pairs, you need to check all pairs $(p,q)$ that range over the sets $B_{pq}$. Can you combine these two searches into one by fiddling with indices? What can you do with boundary cases?
SOLUTION:

 As suggested, do the search in stages: so define $$ C_{rs} = \begin{cases} A_{rs} & \text{if } 1 \leq r \leq n \text{ and } 1 \leq s \leq m\\ B_{r-n,s-m} & \text{if } n+1 \leq r \leq n+p \text{ and } m+1 \leq s \leq m+q\\ A_{11} & \text{if } 1 \leq r \leq n+p \text{ and } m+1 \leq s \leq q\\ B_{11} & \text{if } n+1 \leq r \leq p \text{ and } 1 \leq s \leq m+q \end{cases} $$ The $r$ value tells us whether we are searching over the $A$s or the $B$s, the $s$ coordinate ranges over the respective sets. What if $r$ tells us we search over the $A$s, but we have already checked all sets of the form $A_{ri}$ (ie the boundary case)? We can fill the remaining sets $C_{ri}$ with $i > m$ with any $A_{ij}$ we like. This holds because if $x \in A$ for this specific $r$ then $A$ is in the intersection of the $A_{ri}$ for any $1 \leq i \leq n$, so adding another copy doesn't make a difference. If $x$ isn't in there, we don't need to worry anyway.


How to add new module to running ejabberd node?

Question: I followed up this tutorial https://blog.process-one.net/elixir-sips-ejabberd-with-elixir-part-1/ how to write ejabberd module. And that works great, I put module to ejabberd/src and then compile everything.
But that seams as lot of work for me. Every time when I change one line of code during development I have to compile ejabberd again from scratch with new changed module. Is there any way that I can compile module and then just copy it to ejabberd modules path?
If yes, where is ejabberd modules path? And if yes what tutorial should I read?
Answer: Example usage: edit src/mod_echo.erl to add some relevant change. And now:
<code>$ make
Compiled src/mod_echo.erl
$ sudo make install
...
$ ejabberdctl update_list
mod_echo
$ ejabberdctl update mod_echo
</code>
Since now, the new code is running in ejabberd.
In your case, you copy your module source files into ejabberd source path, and compile them as if they were another ejabberd modules. Or you can compile them separately, and install the *.beam files toghether with all the other ejabberd beam files (the location depends on your system).


not able to complete the program

Question: I'm new to dart and having a hard time figuring out things. so, I just need some help completing the program below. I have no idea where I'm going wrong.
All I'm getting is an error related to null safety
question :-
Write a program to obtain a number N and increment its value by 1 if the number is divisible by 4 otherwise decrement its value by 1.
import 'dart:io';

void main(){
  String? input = stdin.readLineSync();
  int number = int.parse(input);
}

This is all that came to my mind, I know the logic, but I'm stuck at getting the user input and converting it.
Answer: As the comment suggest, in this answer is explained how Dart will handle if stdin.readLineSync does give a null value. So this should work, notice the ! at the end of stdin.readLineSync.
import 'dart:io';

void main() {
  var input = stdin.readLineSync()!;
  var number = int.parse(input);
}

not able to complete the program


CSV Upload & Parse it into HTML Table using JQUERY

Question: I'm developing a web application.My App is using Javascript, PHP, HTML. I already done apply code to upload xlsx , attach it on screen .
Here's my Code

            Load CSV file
            :
            <input type="file" id="fileInputCSV" />

Here's my UI

How do i supposed to do for hide/erase the null cell(Red Mark)?
Answer: It seems your CSV has an empty line at the bottom. Even if it is empty, as far as "sheet" is concerned, it will have one field as long as a carriage return is there.
I'd check to see if the content of the "el" contains anything before executing your el.forEach()
Comment: I already delete the last row in my csv file. it's always shown like that. so, do u have other solutions? thanks
Comment: One way or another, you are appending both a tr, and a td when you don't need to.  I'll rest on my suggestion that you should check the content of el, and perhaps verify that el has more than one column/element in it before you enter the forEach
Answer: Put some condition inside el.forEach
Like this
 el.forEach(function (el, i) {
                          if(el.value!="")
                          {
                              var cell = document.createElement('td');
                              cell.innerHTML = el.value;
                              row.appendChild(cell);
                          }
                         });

Comment: Really?  Gosh, how did you come up with that?
Comment: @slambeth Yeah. I just tried it all the time :D anyway thankyou :D


What is the proper condition to check for a select list value of none?

Question: I have a rule in drupal that populates an entity reference in a parent node with a child node.
Then I created a new rule that is applied "before content is saved" that will remove the child node from the old parent node if one wants to move it to a different parent node.
And it works as expected UNLESS one chooses -none- in the select list. How do I make it remove the child reference when none is selected. I tried Data value is empty and that doesn't work.
Here is an export of my current rule:
{ "rules_remove_job_from_client" : {
"LABEL" : "Remove Job From Client",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"ON" : { "node_presave--job" : { "bundle" : "job" } },
"IF" : [
  { "NOT data_is" : {
      "data" : [ "node-unchanged:field-client" ],
      "value" : [ "node:field-client" ]
    }
  },
  { "node_is_of_type" : {
      "node" : [ "node:field-client" ],
      "type" : { "value" : { "clients" : "clients" } }
    }
  }
],
"DO" : [
  { "list_remove" : {
      "list" : [ "node-unchanged:field-client:field-all-jobs" ],
      "item" : [ "node-unchanged" ]
    }
  },
  { "drupal_message" : { "message" : "Is this firing" } }
]
}
}

Answer: Make sure to add a Rules condition Entity has field (related to your field field-client as shown in your first Rules Condition). For a video tutorial that illustrates the importance of this Entity has field condition, refer to Data types and data selection, especially what is shown between about 13:30 and 17:30 in it.
If that doesn't help, you may want to do some Rules debugging, as explained in the answer to "How can I display the value of a variable inside a condition?".
Comment: Thank you @pierre-vriens for pointing me again in the right direction! I think I got it.
Comment: Ha! I get your point. :) Yes you did provide the answer to the question.
Answer: I split it into 2 rules, they may be able to be combined but I haven't tested it yet.
The first rule is as above and takes care of switching the job from one client to another. The second rule has a condition that checks if the unsaved field-client had a reference to a job and if the new saved field is now empty.
If this is true then it will remove the old job from the client job reference list.
Here is the export:
{ "rules_remove_job_from_client_if_empty" : {
"LABEL" : "Remove Job From Client If Empty",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"ON" : { "node_presave--job" : { "bundle" : "job" } },
"IF" : [
  { "entity_has_field" : {
      "entity" : [ "node-unchanged:field-client" ],
      "field" : "field_all_jobs"
    }
  },
  { "data_is_empty" : { "data" : [ "node:field-client" ] } }
],
"DO" : [
  { "drupal_message" : { "message" : "Data Value is empty!" } },
  { "list_remove" : {
      "list" : [ "node-unchanged:field-client:field-all-jobs" ],
      "item" : [ "node-unchanged" ]
    }
  }
]
}
}

Comment: So "Entity has field" (as in my answer) seems to be the proper ***Condition*** to check, right? With that, all that's needed is to verify if it is empty also.


Cox regression - Hazard and Survival Estimates?

Question: I have a couple questions about Cox survival regression:
1) Is it true that the hazard function h(t) is not available (even WITHOUT time dependent covariates)- and if not, is it because the baseline hazard is not defined (only the cumulative hazard is and you cant go from the cumulative hazard to the hazard)?
2) When you have time dependent covariates is it not possible to estimate the survival curve for a chosen set of covariate values (I'd like to plot prototypical values)? Can anyone explain why not?
Answer: 1) Yes that's correct. There is no intercept in the CoxPH - it is one of the reasons why it's usually complemented by Kaplan-Meier or cumulative incidence curves
2) I've had some efforts into looking into time dependant covariates and it seems to be a mine-field, I've summarised most of the things I've learned in my previous question. If you leave the cox regression then you could try poisson regression or the Laplace regression (quantile regression) that might be easier to work with. One important part is that even though the PH might be violated it might not be important unless there is a clear trend in your data. What you get is an average and that might be good enough - T. Thernaugh mentions in his book that it's not always that you have to address this issue.
Comment: Time-dependent covariates do not necessarily imply a time-dependent coefficient (and thus a non-proportional hazard ratio). @B_Miner: it's true that with time-dependent covariates the ability to predict survival curves from Cox model is usually lost. See for example the paragraph _Prediction and Time-Dependent Covariates_ from here http://www.bios.unc.edu/~lin/publications/1999/FisherLin99.pdf (Time-dependent covariates in proportional-hazards regression model; Fisher and Lin; Annu. Rev. Public Health. 1999. 20:145–57)
Comment: @andrea: Is your distinction between these that the latter (time-dependent coefficient) is an interaction with time? I was wondering if the answer to my second question was because of the first - that because the survival curve is cumulative, you'd need the hazard curve to know how to "accumulate" the survival as the covariates changed?
Comment: Regarding the link, the argument of forecasting the covariate values in time seems weak - it is of course hypothetical but that is the point of simulating the "what-if". I do think I apprciate the logic of the second argument however->
Comment: : Second, if we know the
future value of some covariates (e.g. blood pressure), the existence of the values
implies that the subject has not reached a death endpoint. This fact implies that
one cannot estimate the survival curve from the observed and future values of a
quantity such as blood pressure. The existence of a positive value would imply
that the subject was still alive. Knowing the covariate would imply knowledge
at each stage of the vital status.
Comment: @andrea Thank you for your clarification, time dependant coefficients and variables are truly two different things.
Comment: @B_Miner I've seen time dependent variables and I don't think it's that difficult to implement in the calculations, I know the cmprsk-package has it in it's crr function. I think that the logic isn't that knowledge of the future implies that the subject must be alive, I rather think of it as during the summer it's usually warmer - hence I know that it will occur in the future just as I know menopaus will occur in x years in 50 % of my subjects (of course if they stay alive that long).
Comment: @B_Miner: yes: a time-dependent coefficient is a consequence of an interaction between a covariate (which of course could be constant over time, i.e. time-_in_dependent) and (a function of) time.


Como salvar um CSV em memória utilizando Python?

Question: Olá! Preciso ler um grande CSV, quebrá-lo em CSVs de 1000 linhas, armazená-los em memória e então zerar um zip com estes arquivos menores.
Este é o código até o momento:
import pandas as pd
from io import BytesIO, StringIO
import gzip

csvfile = pd.read_csv('file.csv')
buffer = BytesIO()
f = StringIO()

with gzip.open(buffer, 'wb') as zf:
    for i in range(len(csvfile)):
        if i % 1000 == 0:
            data = csvfile[i:i+1000]
            arq = data.to_csv(f, index=False)
            zf.write(arq)

E este é o retorno do erro:
TypeError: memoryview: a bytes-like object is required, not 'NoneType'

Por favor, alguém poderia me auxiliar?
Comment: Use chunks: https://pt.stackoverflow.com/questions/392787/manipulando-dataset-de-3-gb-com-pandas-usando-chunks
Comment: o que é "quebrar em 1000 linhas"? O arquivo tem milhares de linhas e vc quer salvar de 1000 em 1000?
Comment: Exatamente, Lucas.
Answer: "Criar um CSV em memória" não faz muito sentido - Uma estrutura DataFrame do Pandas é uma tabela de dados em memória, mas já com muito mais facilidades que um CSV. Um CSV é um tipo de arquivo conveniente para portar dados de um lado para outro no disco - mas que tem um mínimo de praticidade direta.
Pela sua pergunta, você quer gerar um arquivo .zip dentro do qual estejam CSVs com seus dados. É possível sim, em Python, serializar os dados como se fossem um CSV em memória, e adicionar cada um a um arqivo zip - mas se os arquivos CSV fossem criados como arquivos temporários no disco, daria o mesmo trabalho - ou seja: podemos criar "em memória" - mas isso não tem importância para o seu problema.
O erro específico que você está tendo é por que a chamada to_csv  do Pandas não retorna "o arquivo em memória". Ela retorna anda (None)  - daí quando você tenta adicionar "arq" ao seu arquivo "gzip" acontece o erro que você postou.
Os dados do arquivo CSV vão ficar no próprio objeto StringIO - esse que está na sau variável "f". Há alguns erros de lógica no seu código: você cira um único objeto StringIO e nunca apaga seu conteúdo - se tudo o mais estivesse funcionando, você estaria repetindo todos os dados dos primeiros arquivos também nos últimos.
Isso é fácil arrumar.
Um outro problema é que  arquivos do tipo "gzip" não tem uma estrutura interna, como um arquivo ZIP - eles são uma única sequência de dados comprimida - e são descomprimidos como um único arquivo. Tanto que é ácil ver que arquivos distruibuidos na internet como "gzip" em geral terminam em ".tar.gz" - indicando que dentro do gzip há um arquivo "tar" - esse sim, tem informações sobre arquivos contidos dentro dele.
Se quiser ter um arquivo ZIP que possa ser listado em qualquer programa que trabalhe com esse tipo de arquivo, e lá dentro ver os CSV's de linha 0 a 999, de 1000 a 1999, etc... tem reamente que usar o módulo zipfile da biblioteca padrão, e não o gzip;
o objeto "StringIO" não tem um nome de arquivo - não deve dar pra passar ele direto para o gzip.write - temos que ver a documentação dessa chamada ver um objeto gzip file aceita dados direto,e metadados como nome de arquivo - senão será necessária a criação de um arquivo temporário em disco, como mencionei acima.
Bom, na prática, vamos tentar algo assim:

import pandas as pd
from io import StringIO
import zipfile

csvfile = pd.read_csv('file.csv')

f = StringIO()

with zipfile.ZipFile('arquivos_csv_agrupados.zip',
                     'w', compression=zipfile.ZIP_DEFLATED,
                      compresslevel=9) as zf:
    for starting_line in range(0, len(csvfile) , 1000):  # a funçao range já permite especificiar o passo de 1000 em 1000 linhas
        data = csvfile[starting_line: starting_line + 1000]
        f = StringIO()
        data.to_csv(f, index=False)
        # Inserir dados no arquivo ZIP, criando o nome do arquivo e recuperando os dados escritos em 'f':
        zf.writestr(f"file_{linha_inicio:04d}_{linha_inicio + 1000:04d}.csv", f.getvalue())

A maior diferença é realmente o uso do zipfile, em vez de gzip - mas o que estava errado mesmo eram (1) o conteúdo do CSV parcial gerado dentro do StringIO é recuperado com o método .getvalue, e não o valor retornado pelo write_csv.
Com o zipfile, temos o direito de criar os nomes dos arquivos que vão dentro do zip, com o método .writestr usado acima.
Você estava tentando criar um arquivo zippado em memória com o "bytesIO"

isso não faz muito sentido - o arquivo é gerado direto no disco com o nome de exemplo "arquivos_csv_agrupados.zip" - mas se realmente quiser criar o zip só em memória, usar o bytesIO poderia funcionar.

A outra correção é que você não precisa fazer o "i" avançar de 1 em 1 e usar um if para detectar as linhas múltiplas de 1000 - a função range faz isso sozinha.
Comment: Funcionou perfeitamente! Agradeço imensamente! Porém, preciso salvar em memória o zip, e não em disco, pois irei transmitir para um storage posteriormente. Como eu poderia usar o bytesIO nesse caso?
Comment: em memória voce nao "salva" - mas é só fazer quase como você estava fazendo - crie  objeto "bytesIO" numa variável antes do `with`,  e passe ele como primeiro parâmetro para a chamada do `ZipFile` - deve funcionar. Aí você usa o `.getvalue()` desse objeto para obter os bytes do zip - se o objetivo for, por exemplo, enviar o conteúdo do zip para uma API ou colocar num corpo de mensagem HTTP.
Comment: Se entendi, faria algo assim: memory_zip = BytesIO() \n with zipfile.ZipFile(memory_zip, ...) \n zip_to_bucket = memory_zip.getvalue() \n upload()? Tentei aqui, e informou "File b'PK\x03\x04\x14\x00\x00\x00\x0...' uploaded to file.zip". Porém, ao consultar o Storage (estou tentando subir para o Google Cloud), o arquivo não consta.
Comment: ai precisa ver como você está chamando o update - não está no código dessa questão. De repente, abra uma outra.

Pela mensagem, parece tudo ok - a questão é ver onde está sendo feito o upload e por que não aparece como você espera.
Comment: Outra: se esse update puder aceitar um arquivo aberto, talvez não seja preciso o `.getvalue()` - aí é o caso de chamar o método `seek(0)` para resetar o pontiero do objeto `BytesIO` - mas isso seria só cosmético - pela mensagem que você colocou acima, o upload já está funcionando.
Comment: Pelo que sei, o update aceita apenas arquivos fechados. Segue:

def upload_to_storage(bucket_name, source_file_name, destination_blob_name):\n
    """Uploads a file to the bucket."""\n

    storage_client = storage.Client()\n
    bucket = storage_client.bucket(bucket_name)\n
    blob = bucket.blob(destination_blob_name)\n

    blob.upload_from_string(source_file_name)\n

    print(
        "File {} uploaded to {}.".format(
            source_file_name, destination_blob_name
        )
    )\n
, onde este método é chamado após as tratativas dos arquivos, antes aqui mencionadas.


Adonisjs filtrar as tabelas no .preload

Question: sou novo com o adonisjs , no meu controller tenho o seguinte codigo:
export default class StudentsController {
public async show({ params }: HttpContextContract) {
    const student = await Student.query().preload('rooms').where('id', params.id)

    return student
  }
}

um exemplo do retorno no insomnia:
{
        "id": 1001,
        "name": "Leonardo",
        "email": "email@example.com",
        "birthdate": "04/01/1995",
        "rooms": [
            {
                "id": 10,
                "teacher_id": 5001,
                "capacity": 4,
                "available": true
            }
        ]
    }

até aqui tudo ok, está retornando o preload('rooms)
oque eu preciso é que o .preload "rooms" retorne somente o "id" e o
"teacher_id"
Answer: Para buscar apenas algumas das colunas presentes na tabela é necessário informa-las através do SELECT conforme as documentações a seguir:
https://docs.adonisjs.com/guides/database/query-builder#select-queries
https://legacy.adonisjs.com/docs/4.0/query-builder#_selects
Segue um exemplo de código de como ficaria no seu caso:
export default class StudentsController {
public async show({ params }: HttpContextContract) {
    const student = await Student.query().preload('rooms').select('id', 'teacher_id').where('id', params.id)
    return student
  }
}

Adonisjs filtrar as tabelas no .preload


What is the purpose of the FileTransfer class?

Question: What is the purpose of the FileTransfer?
I read its documentation page, but it's not clear when a module should deal with that class or one of its child classes.
Answer: FileTransfer is an abstract class for transfering files that specific implementations should extend. The available implementations are FTPFileTransfer, SSHFileTransder and LocalFileTransfer, which are used to transfer files using different methods.
What separates it from the "traditional" file transfer is that it is designed to operate on directories that are not writable by the web-server.
An obvious example is the update manager, which, by using these classes, is able to dowload and install module and theme updates automatically.
A module might interact with one of these classes in order to transfer files via FTP or SSH.


Informação de um User Control até o Window pai

Question: Estou tentando enviar umas informações de meu User Control até a barra de titulo da tela principal que seria o janela pai.
A informação que estou tentando enviar, é a empresa selecionada de um DataGrid.
Como posso fazer isso? não estou conseguindo..
Espero qualquer ajuda...
Class onde eu armazeno a informação capturado;
public class EmpresaSelecionada
    {
        public int Codigo { get; set; }
    }

    public int Codigo
    {
        get { return es.Codigo; }
        set { es.Codigo = value; }
    }

Onde eu gravo:
es = new EmpresaSelecionada();

Object item = dataGridEmpresa.SelectedItem;

string codigo = (dataGridEmpresa.SelectedCells[0].Column.GetCellContent(item) as TextBlock).Text;

es.Codigo = Convert.ToInt32(codigo);

Onde eu tento recuperar para jogar em minha TextBlock da tela principal:
Telas.EscolherEmpresa.EmpresaSelecionada es = new Telas.EscolherEmpresa.EmpresaSelecionada();

    public int Codigo = 0;

    public MainWindow()
    {
        InitializeComponent();

        es = new Telas.EscolherEmpresa.EmpresaSelecionada();
        Codigo = es.Codigo;
    }

    private string _titulo;// = Convert.ToString(Codigo);
    public string Titulo
    {
        get
        {
            return _titulo;
        }
        set
        {
            _titulo = Convert.ToString(Codigo);
        }
    }

XAML
<TextBlock Text="{Binding Titulo,RelativeSource={RelativeSource FindAncestor,AncestorType=Window}}" HorizontalAlignment="Center"  />

Answer: Para fazer isto de forma elegante, eu montei um exemplo para você. Vou descrever por partes:
Primeiramente no seu projeto você deve ter um modelo para Empresa, abaixo está o modelo básico que eu criei para exemplificar:
public class Empresa
{
    public int Codigo { get; set; }
    public string RazaoSocial { get; set; }
    public string Fantasia { get; set; }

    public override string ToString()
    {
        return String.Format("{0} - {1}",Codigo,Fantasia);
    }
}

Após isso criei um UserControl de exemplo chamado MeuUserControl. Abaixo o código XAML do MeuUserControl.xaml:
<UserControl x:Class="WpfApplication1.MeuUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d" >
    <Grid>
        <DataGrid x:Name="dg_empresas" AutoGenerateColumns="False"
                  SelectedItem="{Binding EmpresaSelecionada,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl},Mode=TwoWay}"
                  ItemsSource="{Binding Empresas, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}">
            <DataGrid.Columns>
                <DataGridTextColumn Header="Codigo" Binding="{Binding Codigo}"/>
                <DataGridTextColumn Header="Razão social" Binding="{Binding RazaoSocial}"/>
                <DataGridTextColumn Header="Fantasia" Binding="{Binding Fantasia}"/>
            </DataGrid.Columns>
        </DataGrid>

    </Grid>
</UserControl>

A seguir o CodeBehind do MeuUserControl.cs (criei uma lista com empresas hipotéticas):
  public partial class MeuUserControl : UserControl
    {
        public static readonly DependencyProperty EmpresaSelecionadaProperty =
                               DependencyProperty.Register("EmpresaSelecionada", typeof(Empresa), typeof(MeuUserControl), new PropertyMetadata(null));

        public Empresa EmpresaSelecionada
        {
            get{ return this.GetValue(EmpresaSelecionadaProperty) as Empresa; }
            set{ this.SetValue(EmpresaSelecionadaProperty, value); }
        }

        public List<Empresa> Empresas
        {
            get
            {
                return new List<Empresa>()
                {
                    new Empresa(){Codigo=1, RazaoSocial= "Razao Social 1", Fantasia="Fantasia 1"},
                    new Empresa(){Codigo=2, RazaoSocial= "Razao Social 2", Fantasia="Fantasia 2"},
                    new Empresa(){Codigo=3, RazaoSocial= "Razao Social 3", Fantasia="Fantasia 3"},
                    new Empresa(){Codigo=4, RazaoSocial= "Razao Social 4", Fantasia="Fantasia 4"},
                };
            }
        }

        public MeuUserControl()
        {
            InitializeComponent();
        }
    }

E por último o XAML da tela que utiliza o UserControl, cujo titulo é a empresa selecionada no DataGrid:
<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:controls="clr-namespace:WpfApplication1"
        Title="{Binding EmpresaSelecionada,ElementName=userControl,Mode=OneWay}">
    <Grid>
        <controls:MeuUserControl x:Name="userControl"/>
    </Grid>
</Window>

A solução basicamente se resume em criar uma DependencyProperty no UserControl que esteja ligada com a Empresa selecionada no DataGrid, e ligar esta propriedade ao titulo da janela que utiliza o UserControl.
Comment: Esta solução foi útil para você?
Comment: Nicolas, mas como eu posso chamar esta empresa e jogar para o titulo? tentei com dois cliques sobre o item do DataGrid.. Mas não sei como chamá-lo
Comment: Como você pode notar o titulo da tela esta ligado com o item do datagrid selecionado, então com esta solução, sempre quanto o item selecionado no DataGrid mudar, automaticamente o titulo muda..Tente reproduzir o exemplo acima em um novo projeto, que consiguirás entender a solução.


get path of an uploaded file

Question: This is my form to upload a photo
 $form['Background_image'] = array(
 '#type' => 'managed_file',
 '#title' => t('Choose a background image'),
 '#description' => t('Click "Browse..." to select an image to upload.'),
 '#required' => TRUE,
 '#upload_validators' => array('file_validate_extensions' => array('jpeg jpg png gif')),
'#upload_location' => 'public://backgroundimage/',
 '#default_value' => $this->options['Background_image'],

);

I tried this function that get the current uploaded image and return its path, but still not working: what is missing:
function image_path()
  {
   $f = file_load($this->options['Background_image']);
  //this too is not working:
  //$f = file_load($form_state['values']['Background_image']);
   $url_image = file_create_url($f->uri);
   print_r($url_image);
   return ($url_image);
  }

Comment: can you check if you are getting the value of `$f->uri`, if not than can you try $f = $form_state['values']['Background_image'];
Comment: Whats `$this` in your current context?
Answer: In your submit handler of your form, you should be able to retrieve the fid of the uploaded file / image. By using this fid, you can load the file and work with that object.
function YOUR_MODULE_FORM_NAME_submit($form, &$form_state)
{
    $fid = $form_state['values']['Background_image'];

    if ($fid !== 0) {
        // Retrieve image URL
        $image_url = YOUR_MODULE_get_file_url(file_load($fid));
    }
}

function YOUR_MODULE_get_file_url($file)
{
    if (!$file) {
        // File not found
        return false;
    }

    // Return URL from a give file URI
    return file_create_url($file->uri);
}

Answer: $this is surprising in your form! I am not sure but do not consider $this as reference  of current uploaded file,if the code you have shared is complete code then if you try to look inside dpm($this) , you will get your answer why file is not loading.
check this link, it explains how to create custom upload form.
the use of file_create_url() is appropriate to get file url from uri,so I am sharing the submit handler changed codes from reference link the submit handler showing use of
function import_form_submit(&$form, &$form_state) {
  // Load the file.
  $file = file_load($form_state['values']['file_fid']);
  // Change status to permanent.
  $file->status = FILE_STATUS_PERMANENT;
  // Save.
  $uploaded = file_save($file);
  if ($uploaded == TRUE) {
    drupal_set_message(t('The file has been uploaded.'));
    dpm(file_create_url($file->uri));
  }
  else {
    drupal_set_message(t('The file could not be uploaded. Please contact the site administrator.'), 'error');
  }

}

Comment: when I tried  drupal_set_message(t( dpm(file_create_url($file->uri))));to see the file path but drupal dispays:http://localhost:8080/TestD3/  (link of my site)
Comment: please do debugging and use dpm() without drupal_set_messgage() and t(), it looks like you are able to upload the file properly , check the upload location you are providing in the form field.

get path of an uploaded file


PostgreSQL Select WHERE column = [Array]

Question: I have a table1 with column 1 and 2
1        2
Banana   x
Apple    y
Orange   z

I want to call a SELECT on this table with an array as parameter: ['Banana', 'Apple']
I want to get the rows where column 1 contains Banana or Apple (elements of the array)
SELECT * FROM table1 WHERE column1 = 'Banana OR column1 = 'Apple'

But how is this working dynamically? Like where column1 = elemt in array....?
Answer: Use the ANY operator:
select *
from the_table
where the_column = any( array['Banana', 'Apple'] );

Answer: Use the keyword IN:
SELECT * FROM table1 WHERE column1 IN ('Banana', 'Apple');

(reference doc.: https://www.postgresql.org/docs/current/functions-subquery.html#AEN16806)


Busca linear recursiva c++

Question: Queria fazer uma busca linear recursiva usando vector e iteradores, aqui vai o código:
long int busca_sr(std::vector<long int> &amostra, const long int &key){
    auto first = amostra.begin();
    auto last = amostra.end();
    if (last == first-1){
        return -1;
    }
    else if(*last == key){
        return 1;
    }
    else{
        --last;
        std::vector <long int> auxi1 (first, last);
        return busca_sr(auxi1, key);

    }

O problema é que quando eu executo essa função o meu pc trava, eu suspeito que o erro esta na condição de parada da minha recursão, pois quando o last for igual ao first o vector auxiliar la em baixo não será alocado, queria uma forma de inserir uma condição de parada sem ter que mudar a assinatura da função!
Comment: Você não deve desreferenciar o valor de end(), o que ocorre em *last == key. fonte: http://www.cplusplus.com/reference/vector/vector/end/
Answer: Como é uma busca linear, acho que é mais natural você começar a verificação a partir do primeiro elemento e ir avançando o iterador do inicio em 1 em vez de começar pelo último elemento.
Outro ponto que estava errado era o critério de parada: a condição if(last == first-1) sempre dá exceção, pois você está tentando ler um índice antes do primeira posição. Para averiguar se o iterador chegou no fim do vector, basta fazer a verificação v.begin() == v.end().
long int busca_sr(std::vector<long int> &amostra, const long int &key) {
    std::vector<long int>::iterator first = amostra.begin();
    std::vector<long int>::iterator last = amostra.end();

    if (last == first) {
        return -1;
    }
    else if (*first == key) {
        return 1;
    }
    else {
        std::vector <long int> auxi1(++first, last);
        return busca_sr(auxi1, key);
    }
}

Busca linear recursiva c++