text:
Q: Error class not found when starting app java.lang.ClassNotFoundException: javax.validation.ValidatorFactory I'm working on Web project based on Spring MVC framework on tomcat web server, recently I've added some dependencies  and I encountered a class not found exception and
It's been three day's which I couldn't resolve this problem in my we app
this my pom.xml file
    <modelVersion>4.0.0</modelVersion>
<groupId>com.mihanblog</groupId>
<artifactId>CloudGIS</artifactId>
<name>RegionalizationWebMVC</name>
<packaging>war</packaging>
<version>1.0.0-BUILD-SNAPSHOT</version>
<properties>
    <java-version>1.7</java-version>
    <org.springframework-version>4.3.6.RELEASE</org.springframework-version>
    <org.aspectj-version>1.6.10</org.aspectj-version>
    <org.slf4j-version>1.7.21</org.slf4j-version>
    <jackson.version>2.8.6</jackson.version>
    <hibernate.version>5.1.0.Final</hibernate.version>
    <geotools.version>2.5.5</geotools.version>
</properties>
<dependencies>
    <!-- Spring -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aspects</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>

    <!-- hibernate -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>${hibernate.version}</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>${hibernate.version}</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>${hibernate.version}</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-ehcache</artifactId>
        <version>${hibernate.version}</version>
    </dependency>
    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.4-1200-jdbc41</version>
    </dependency>
    <!-- AspectJ -->
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>1.8.9</version>
    </dependency>
    <dependency>
        <groupId>aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>1.5.4</version>
    </dependency>
    <dependency>
        <groupId>aopalliance</groupId>
        <artifactId>aopalliance</artifactId>
        <version>1.0</version>
    </dependency>
    <dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib</artifactId>
        <version>3.2.1</version>
    </dependency>
    <dependency>
        <groupId>asm</groupId>
        <artifactId>asm</artifactId>
        <version>3.3.1</version>
    </dependency>
    <dependency>
        <groupId>org.jboss.logging</groupId>
        <artifactId>jboss-logging</artifactId>
        <version>3.3.0.Final</version>
    </dependency>
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>11.0.2</version>
    </dependency>
    <!-- Geoserver -->
    <dependency>
        <groupId>it.geosolutions</groupId>
        <artifactId>geoserver-manager</artifactId>
        <version>1.7.0</version>
    </dependency>
    <dependency>
        <groupId>org.geoserver</groupId>
        <artifactId>data</artifactId>
        <version>1.7.0</version>
        <exclusions>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-beans</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.geoserver</groupId>
        <artifactId>main</artifactId>
        <version>1.7.0</version>
        <exclusions>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-beans</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-jdbc</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aop</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <!-- GeoTools -->
    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-shapefile</artifactId>
        <version>${geotools.version}</version>
    </dependency>
    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-api</artifactId>
        <version>${geotools.version}</version>
    </dependency>
    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-data</artifactId>
        <version>${geotools.version}</version>
    </dependency>
    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-epsg-hsql</artifactId>
        <version>${geotools.version}</version>
    </dependency>
    <!-- <dependency> <groupId>org.jdom</groupId> <artifactId>jdom</artifactId>
        <version>1.1</version> </dependency> -->
    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-epsg-hsql</artifactId>
        <version>${geotools.version}</version>
    </dependency>
    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-geometry</artifactId>
        <version>${geotools.version}</version>
        <exclusions>
            <exclusion>
                <groupId>org.geotools</groupId>
                <artifactId>gt-main</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-metadata</artifactId>
        <version>${geotools.version}</version>
    </dependency>
    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-process</artifactId>
        <version>${geotools.version}</version>
        <exclusions>
            <exclusion>
                <groupId>org.geotools</groupId>
                <artifactId>gt-main</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-cql</artifactId>
        <version>${geotools.version}</version>
        <exclusions>
            <exclusion>
                <groupId>org.geotools</groupId>
                <artifactId>gt-main</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>javassist</groupId>
        <artifactId>javassist</artifactId>
        <version>3.12.1.GA</version>
    </dependency>
    <dependency>
        <groupId>javax.vecmath</groupId>
        <artifactId>vecmath</artifactId>
        <version>1.5.2</version>
    </dependency>
    <dependency>
        <groupId>javax.media</groupId>
        <artifactId>jai_core</artifactId>
        <version>1.1.3</version>
    </dependency>
    <dependency>
        <groupId>com.vividsolutions</groupId>
        <artifactId>jts</artifactId>
        <version>1.13</version>
    </dependency>

    <!-- Logging -->

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${org.slf4j-version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>${org.slf4j-version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>${org.slf4j-version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.15</version>
        <exclusions>
            <exclusion>
                <groupId>javax.mail</groupId>
                <artifactId>mail</artifactId>
            </exclusion>
            <exclusion>
                <groupId>javax.jms</groupId>
                <artifactId>jms</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.sun.jdmk</groupId>
                <artifactId>jmxtools</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.sun.jmx</groupId>
                <artifactId>jmxri</artifactId>
            </exclusion>
        </exclusions>
        <scope>runtime</scope>
    </dependency>
    <!-- @Inject -->
    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>1</version>
    </dependency>
    <!-- Servlet -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>4.0.0-b01</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.1.0.Final</version>
    </dependency>
    <!-- Test -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.7</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-all</artifactId>
        <version>1.3</version>
    </dependency>
    <!-- End Test -->
    <dependency>
        <groupId>org.quartz-scheduler</groupId>
        <artifactId>quartz</artifactId>
        <version>2.2.3</version>
    </dependency>
    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>2.9.4</version>
    </dependency>

    <!-- Apache Commons -->
    <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
        <version>1.3.1</version>
    </dependency>

    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.4</version>
    </dependency>
    <dependency>
        <groupId>commons-validator</groupId>
        <artifactId>commons-validator</artifactId>
        <version>1.5.1</version>
    </dependency>
    <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        <version>1.4</version>
    </dependency>
    <dependency>
        <groupId>commons-httpclient</groupId>
        <artifactId>commons-httpclient</artifactId>
        <version>3.1</version>
    </dependency>
    <dependency>
        <groupId>commons-beanutils</groupId>
        <artifactId>commons-beanutils</artifactId>
        <version>1.6</version>
    </dependency>

    <!-- Jackson JSON Mapper -->
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>1.9.13</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>${jackson.version}</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-annotations</artifactId>
        <version>${jackson.version}</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.datatype</groupId>
        <artifactId>jackson-datatype-joda</artifactId>
        <version>${jackson.version}</version>
    </dependency>

    <dependency>
        <groupId>oro</groupId>
        <artifactId>oro</artifactId>
        <version>2.0.8</version>
    </dependency>

</dependencies>
<build>
    <plugins>
        <plugin>
            <artifactId>maven-eclipse-plugin</artifactId>
            <version>2.9</version>
            <configuration>
                <additionalProjectnatures>
                    <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                </additionalProjectnatures>
                <additionalBuildcommands>
                    <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                </additionalBuildcommands>
                <downloadSources>true</downloadSources>
                <downloadJavadocs>true</downloadJavadocs>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <compilerArgument>-Xlint:all</compilerArgument>
                <showWarnings>true</showWarnings>
                <showDeprecation>true</showDeprecation>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <configuration>
                <mainClass>org.test.int1.Main</mainClass>
            </configuration>
        </plugin>

    </plugins>
</build>
<repositories>
    <repository>
        <id>maven2-repository.dev.java.net</id>
        <name>Java.net repository</name>
        <url>http://download.java.net/maven/2</url>
    </repository>
    <repository>
        <id>osgeo</id>
        <name>Open Source Geospatial Foundation Repository</name>
        <url>http://download.osgeo.org/webdav/geotools/</url>
    </repository>
    <repository>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <id>boundless</id>
        <name>Boundless Maven Repository</name>
        <url>http://repo.boundlessgeo.com/main</url>
    </repository>
</repositories>

and this the error thrown when I start app in Eclipse Jee Neon
link to error log file

A: Your stacktrace says that a bean of class com.mihanblog.CloudGIS.Utilities.CustompostHandlelerInterceptor has been defined but the class isn't on the classpath.
I assume the package com.mihanblog is yours, so that should be one of your classes.
Does this class even exist ?
Or did you make a typo while defining the bean? Because the name "CustompostHandlelerInterceptor" looks like a typo to me.


text:
Q: Trying to write javascript to hide toggle side menu class until page is loaded. It currently shows for a split second until page loads EDIT- Got it figured out, answer is below, thanks everyone!
I'm back with another head scratcher that I've been working on all morning and can't seem to solve on my own and was hoping someone would help out this rookie.
I currently have a problem with my phpbb forum when in responsive mode on my phone (can't duplicate it on desktop using mobile view, but it is happening on my phone and I assume most other phones since mine isn't much different than any other android).
So my problem is that my toggle side menu is loading before I would like it to.  The easiest way to explain is with a picture I made (couldn't screenshot it because it doesn't stay long enough).

As you can see, for about a second (or fraction of a second, just long enough to bug me), the header expands and the menu items are visible.  It doesn't show exactly as it would if the toggle was activated, for some reason, only the text and border items are visible.  The background color does stay hidden.  The background of the header does expand with the text, which is shouldn't do with when the toggle is activated, so I'm not exactly sure what I need to do, hoping I can get some help.
I didn't just come here hoping someone could do this for me, I've tried many many options.
I saw a similar question where it was advised to use #selector within the .css, but I had no luck with that.
I've tried this script code:

The code does nothing for me.  I've also tried substituting .gf-menu-device-wrapper-sidemenu but nothing with that either.
Here's the html code for that menu, The javascript file is minified and nearly impossible for me to get anything out of, but if anyone would like to look at it, it's here:
https://raiderforums.com/styles/corvus/template/rt_js/mootools-core.js

A: You can use
display: none;

as it has been mentioned.
Though if you need to use calculations like height, etc before showing it, like contentHeight etc., this is not appropriate.
In this case you may use
opacity: 0.015;

or similar in CSS or even inline, and reset the opacity to 1 after hiding it via JavaScript.
This way it may not be that disturbing.
(Yes I know, inline CSS is ugly but blinking boxes are more that.)

A: Here's how I did it, thanks for the help guys. Changed the inline css to display:none, then this script got it working:

See anything wrong with what I did? It works, but perhaps I could have done it different?

redpajama_set_name: RedPajamaStackExchange


text:
Q: Switching panels and passing data in Swing I'm just starting out with Swing - I'm sorry if this question is hard to follow, but I feel like this is a very simple thing but it seems surprisingly hard in Swing.
I have a panel with two text fields and a submit button.
I've added a listener on the submit button, when it's clicked I validate the data and such.
Now, I want the frame to display a new panel - get rid of the current panel with the text fields and submit button, and instantiate a new one based on the data entered in the text fields.
How can I send this data back to the frame, so the frame can remove the current panel and replace it with a new, different panel, created with the data from the first panel.
Though it's not what I'm doing, it could be thought of like a login.
Display login panel
Panel gets username and password, validates (validation could be done higher up, too)
If validated, replace login panel with real content panel
This is surprisingly hard to figure out in Swing. Should I be defining my own event type and making the frame a listener for that event?

A: If I understood your question, you can use callback logic like this;
MyLoginPanel login = new MyLoginPanel(new IMyCallback(){

            public void processLogin(){
                //frame can remove the current panel and replace it with a new
            }

        });

*

*MyLoginPanel extended from Jpanel with Constructor public MyLoginPanel(IMyCallback callback)

*IMyCallback is an interface which has public void processLogin() method.

You could call callback.processLogin(); from LoginPanel
Does it work for you?

A: You should look at the java.awt.CardLayout. This Layout can handle multiple panels which are stacked on top of each other. And you can choose which panel should be the topmost and therefore visible.
The following code shows the relevent parts from the tutorial mentioned above:
//Where instance variables are declared:
final static String BUTTONPANEL = "Card with JButtons";
final static String TEXTPANEL = "Card with JTextField";

//Where the components controlled by the CardLayout are initialized:
//Create the "cards".
JPanel card1 = new JPanel();
JPanel card2 = new JPanel();

//Create the panel that contains the "cards".
JPanel cards = new JPanel(new CardLayout());
cards.add(card1, BUTTONPANEL);
cards.add(card2, TEXTPANEL);

and to switch the visible panel:
CardLayout cl = (CardLayout)(cards.getLayout());
cl.show(cards, TEXTPANEL);


text:
Q: $(1/r, 1/r)$ satisfying set system contains $r$ pairwise disjoint sets I am quite confused why $Pr(\mathcal E_i)>0$ means $\mathcal F$ contains an $i$-monochromatic set in the end of proof of lemma 1.6 of Improved bounds for the sunflower lemma. Don't we need $Pr(\mathcal E_i)=1$ to guarantee this?
Thanks in advance for explanation!

A: Consider an analogy: if a person is drawn randomly from the collection of all citizens of the world, what is the probability that they are a contributor on math.stackexchange? Having this probability be larger than $0$ is equivalent to the statement, "There exist MSE contributors," and having the probability be equal to $1$  is equivalent to, "Everyone in the world is an MSE contributor."


text:
Q: from _curses import * ModuleNotFoundError: No module named '_curses This is the error I am getting:
Traceback (most recent call last):
File "c:\Users\brook\python_practice\snake.py", line 1, in
import curses
File "C:\Users\brook\AppData\Local\Programs\Python\Python310\lib\curses_init_.py", line 13, in
from _curses import *
ModuleNotFoundError: No module named '_curses'
I tried pip install windows-curses and a few other things I found on stack overflow, nothing has worked.
I'm using VSCode.


text:
Q: Input changins in V-for does not make update placeholder and input I'm creating a passengers form,  In this form it gets adult and child counts and children ages. At the beginning childCount equals 0 and inputs of childAges are invisible. When i increase child count, they are visible one by one.  So far it is ok. However while increasing childAge, input and placeholder value do not change. By the way at the the background value is changing.
I want to be updated value in input while changing. I am sharing code via jsfiddle
Please, not only fix my code, please share how it works.
Thank you.
enter code here

A:
Due to limitations in JavaScript, Vue cannot detect the following
changes to an array:
When you directly set an item with the index, e.g.
vm.items[indexOfItem] = newValue. When you modify the length of the
array, e.g. vm.items.length = newLength.

Reference.
increaseChildAge: function(index) {
    this.$set(this.childAges, index, this.childAges[index] + 1);
},
decreaseChildAge: function(index) {
  if (this.childAges[index] > 0) {
    this.$set(this.childAges, index, this.childAges[index] - 1);
  }
}


text:
Q: Calculate mean median first third quartile from dataframe with distribution in with pandas I have an aggregate level dataframe as follow:
errors | class | num_students
  1    | A     | 5
  2    | A     | 8
  3    | A     | 2
...
  10   | A     | 1
  1    | B     | 9
  2    | B     | 12
  3    | B     | 5
  10   | B     | 2
...

The original data was at student ID level so in this dataframe, distribution of errors for each class is calculated. I want to get summary statistics per class from my dataframe that looks like below:
Class   | average error  | median error  | Q1 error  | Q3 error
    A   |       2.1      |   2           |  1        |  3
    B   |       3.4      |   3           |  2        |  5

What is the best way to accomplish this?


text:
Q: Program runs then says it stops working The program is required to calculate total cost of items and display back to user the quantity of product, product and the price of products as a bill. Keep in mind I am only a beginner in programming in C so basic functions are used.
 #include<stdio.h>
 #include<string.h>
typedef struct
{
    float price;
    int quantity;
    char product;
}Billing;
typedef struct
{
    int code;
    char product;
    float price;
}Stocks;
main()
{
    Stocks A;
    Billing B;
    FILE*s;
    FILE*c;
    printf(" Welcome to I.A.M Cash & Carry\n#8 New Trincity Industrial Estate\nTrincity\n");
    printf("=================================\n");
    void transfer(Billing,Stocks,FILE*,FILE*);
    transfer(B,A,s,c);
}
void transfer(Billing B,Stocks A,FILE*s,FILE*c)
{
    int count;
    s=fopen("C:\\stock.txt","r");
    int counter=0;
    while(fgetc(s)!=EOF)
    {
        counter++;
    }
    fclose(s);
    count=counter;
    Stocks D[count];
    int x;
    s=fopen("C:\\stock.txt","r");
    for(x=0;x<count;x++)
    {
        fscanf(s,"%d",&D[x].code);
        fscanf(s,"%s",D[x].product);
        fscanf(s,"%f",&D[x].price);
    }
    fclose(s);
    void menu(Billing,Stocks[],FILE*,FILE*,int);
    menu(B,D,s,c,count);
}
void menu(Billing B,Stocks D[],FILE*s,FILE*c,int count)
{
    printf("1)Enter items for billing\n");
    printf("2)Quit\n");
    void choice(Billing,Stocks[],FILE*,FILE*,int);
    choice(B,D,s,c,count);
}
void choice(Billing B,Stocks D[],FILE*s,FILE*c,int count)
{
    int x;
    printf("Enter choice:\n");
    scanf("%d",&x);
    if((x<1) || (x>2))
    {
        printf("Choice invalid\nPlease Re-enter\n");
        menu(B,D,s,c,count);
    }
    if(x==1)
    {
        void submenu(Billing,Stocks[],FILE*,FILE*,int);
        submenu(B,D,s,c,count);
    }
    if(x==2)
    {
        printf("Thank you, Have a great day\n");
    }
}
void submenu(Billing B,Stocks D[],FILE*s,FILE*c,int count)
{
    int x,z,quan,prod;
    float sum=0;
    float prices=D[x].price*quan;
    c=fopen("C:\\bill.txt","w");
    do{
    printf("Select choice:\n");
    printf("1)Enter items\n");
    printf("2)Quit");
    scanf("%d",&x);
    if(x==1)
    {
        printf("Enter product code:");
        scanf("%d",&prod);
        for(z=0;z<count;z++)
        {
          if(prod==D[x].code)
          {
            printf("Enter quantity:");
            scanf("%d",&quan);
            fprintf(c,"%d  ",quan);
            fprintf(c,"%s  ",prod);
            fprintf(c,"%5.2f\n",D[x].price*quan);
            sum= sum + prices;
          }
        }
    }
    if(x==2)
    {
        printf("Thank you, Have a great day\n");
    }
}while(x!=2);
fclose(c);
void countbill(Billing,FILE*,float);
countbill(B,c,sum);
}
void countbill(Billing B,FILE*c,float sum)
{
    int y;
    c=fopen("C:\\bill.txt","r");
    int x=0;
    while(fgetc(c)!=EOF)
    {
        x++;
    }
    fclose(c);
    y=x;
    Billing V[y];
    void displaybill(Billing[],FILE*,float,int);
    displaybill(V,c,sum,y);
}
void displaybill(Billing V[],FILE*c,float sum,int y)
{
    int x;
    c=fopen("C:\\bill.txt","r");
    for(x=0;x<y;x++)
    {
        fscanf(c,"%d",&V[x].quantity);
        fscanf(c,"%s",V[x].product);
        fscanf(c,"%f",&V[x].price);
        printf("%d  %s  %f\n",V[x].quantity,V[x].product,V[x].price);
    }
    printf("Total=%f",sum);
}

Debugger output

A: im sorry im making this as an answer, i just want you to really read it.
this code have tons of problems, ill just clarify most of them:
1) you are not declaring any of your functions
2) the way you call most of your functions is wrong
3) you are using tons of variable without initializing them, like x
4)you cant put a non constant variable in array declaration, it must be a constant number, or use dynamic allocation. (for example Stocks D[count])
and this is only what i saw from general look.
its look like you have some homework to do before you continue this code.
hope its helping somehow.


text:
Q: C# LINQ subquery (On entities) I am trying to use LINQ to query a list of objects wherever appropriate. Currently I am stuck on the syntax of a nested query which I hope you can help me with.
Classes:
public class FooType
{
    public int Id { get; set; }

    public IList<Foo> Foos { get; set; }

}

public class Foo
{
    public int FooTypeId { get; set; }

    public string CorrelationId { get; set; }
}

public class Bar
{
    public string FooCorrelationId { get; set; }
}

Usage:
IList < FooType > fooTypes = new List < FooType >();
// ... add a lot of FooTypes, each enriched with some Foos
Bar bar = new Bar(){FooCorrelationId = "abcdef"};
Foo foo = fooTypes.Where( ft => ft.Foos.Where( f => f.CorrelationId == bar.FooCorrelationId ) ).First<Foo>();

This fails because the outer WHERE-expression is fed with something that does not provide a boolean return value. As you might guess, I intend to something like the following in LINQ:
 foreach (FooType fooType in fooTypes)
 {
     Foo foo = fooType.Foos
                      .Where(f => f.CorrelationId == bar.FooCorrelationId)
                      .First();
 }

Do you have any idea how to get that Foo I'm looking for, the one with CorrelationId "abcdef"?
And one more question for the benchmarkers : What about performance? Does LINQ optimize it's queries? Or is the result the same as an iteration over the objects like I did in my "something like" block?
Thanks a lot in advance!

A: Just replace the outer where with a SelectMany and get the first
Foo foo = fooTypes
    .SelectMany(ft => ft.Foos.Where(f => f.CorrelationId == bar.FooCorrelationId))
    .First();

If you an to get the first Foo across all FooType, what has CorrelationId == FooCorrelationId.


text:
Q: Behavior of starred section in beamer In a LaTeX article, \section* behaves like this:
\documentclass[12pt]{article} \begin{document}
\section*{Not numbered} \thesection % --> 0
\section{Numbered} \thesection % --> 1
\end{document}

However, with beamer the following happens:
\documentclass[12pt]{beamer} \begin{document}
\section*{Not numbered} \frame{\thesection}  % --> 1
\section{Numbered} \frame{\thesection} % --> 2
\end{document}

Why is this? Could I correct this behaviour?
Now, what I actually need is a command \secnr for beamer that will print nothing when in a starred section and the correct -viz. documentclass article- numbering in unstarred sections. So that would require:

*

*Fixing the numbering misbehavious in beamer

*An if to test "if current section is starred ..."

A solution to either (or both) of these problems would be very welcome.

A: beamer implements \section* in a different way. The actual section number is kept in the (TeX) counter \beamer@tocsectionnumber, which is not advanced when \section* is found.
A possible solution to your problems is
\usepackage{etoolbox}
\newif\ifstarred
\def\secnr{}
\makeatletter
\pretocmd\beamer@@ssection{\gdef\secnr{}\global\starredtrue}{}{}
\patchcmd\beamer@section{by 1\relax}
  {by 1\relax\xdef\secnr{\the\beamer@tocsectionnumber}\global\starredfalse}{}{}
\makeatother

This defines \secnr as you want: in a \section* it expands to nothing, while in a \section it expands to the section's number. The \ifstarred conditional is true after a \section* and false after a \section.


text:
Q: PHP Printing $_POST['something'] without refresh I got this code..

        <form method="get" target="speechs">
            <input type="text" id="speech_input_welcome" name="speech_input_welcome" placeholder="Click here to speak..">
            <input type="submit" id="speech_welcome" name="speech_welcome" value="Say">
        </form>

and then this:

        <?php
        if(isset($_POST['speech_welcome']))
        {
            if($_POST['speech_input_welcome'] == 'registrated')
            { ?>

            <?php }
            else if($_POST['speech_input_welcome'] == 'new')
            { ?>

            <?php }
            else
            { ?>

                <img src="http://www.habborator.org/exec/speech/bubble.php?name=You&text=<?php echo $_POST['speech_input_welcome']; ?>&format=say">

            <?php }
        }
        ?>

What I'm trying to do:
Just like echo the $_POST['speech_input_welcome'] without refreshing the side, As I got an iframe that disabled the refreshment.
I tried to use echo $center2 = 'lalal'; But it wont load the $_POST without refresh, And I really can't use MySQL or something similar for this proccess.

A: This will probably prove helpful :)
http://api.jquery.com/load/
Regards,


text:
Q: Insert comment and still use moderation I have a custom comment form that inserts a comment outside of the loop and applies it to a post. I'm trying to get it to still use the moderation check before it marks as "approve". Is there a way to leverage the moderation tools with a wp_insert_comment? I'm needing to prevent comments with inappropriate words from showing up in the comment feed.
Here's my code:
add_action( 'wp_ajax_create_comment', 'create_comment' );
    function create_comment(){

        $postID = $_POST['postID'];
        $commentAuthName = $_POST['authorName'];
        $commentAuth = $_POST['authorID'];
        $commentContent = $_POST['commentContent'];
        $commentParent = $_POST['commentParent'];
        if(empty($commentParent)){
            $commentParent = 0;
        }

        $time = current_time('mysql');

        $data = array(
            'comment_post_ID' => $postID,
            'comment_content' => $commentContent,
            'comment_parent' => $commentParent,
            'comment_date' => $time,
            'comment_approved' => 1,
            'user_id' => $commentAuth,
            'comment_author' => $commentAuthName,
            'comment_author_IP' => $_SERVER['REMOTE_ADDR'],
            'comment_agent' => $_SERVER['HTTP_USER_AGENT'],
        );

        $commentID = wp_insert_comment($data);
        print_r($commentID);
        die();
    }

**Adding additional clarification:
I want to automatically publish and display contents that are not flagged based on the moderation keys. The ones that are flagged, need to be sent to the moderation que.

A: Just to close this out, the answer is very easy in that, yes it is possible and here's the function that does the check to see if the comment passes the moderation verification or not. Then you can add a conditional and either add the comment or not based on that.
check_comment();
Function reference: http://codex.wordpress.org/Function_Reference/check_comment


text:
Q: How many bitstrings of length n are there with c adjacent 1s somewhere? I am self-studying Kolmogorov complexity, and for its purposes, (Sipser exercise 6.26) I am trying to prove that for constant c, as n approaches infinity, the ratio of bitstrings of length n that contain $(1)^{c}$, to the ratio of bitstrings of length n approaches 1. (More than c consecutive 1s are acceptable as well, and not all 1s of the string need to be consecutive.) It's hard to do without counting good strings more than once.
https://math.stackexchange.com/q/1530139 Seems to answer the question for specific n and c, but it doesn't seem easy to calculate as n tends to infinity and for general c.

A: Here is a probabilistic way. Fix $c \geq 1$ and consider $n$ large enough. Consider choosing a bitstring $\mathbf{x}$ of length $n$ uniformly at random; or equivalently, each bit $x_i$ is independently $0$ or $1$ with probability $1/2$. Now the aim is to show that
$$
\mathbb{P}(\mathbf{x} \not\ni (1)^c) = o(1) \quad(*)
$$
(where the notation on the left-handside means the random bitstring contains a sequence of $c$ consecutive $1$'s somewhere). If we show this, then this implies that $\mathbb{P}(\mathbf{x} \ni (1)^c) \to 1$ as $n \to \infty$, or equivalently that the ratio of bitstrings with the desired property to all bitstrings tends to one.
To show $(*)$: Consider chopping up the $n$ bits into $n / c$ consecutive blocks of $c$ bits (we will assume that $n/c \in \mathbb{Z}$ for simplicity, but the general argument only requires an easy modification). Then if the event on the left-hand side happens, it must be that each of these $n/c$ blocks must all be different from a sequence of $c$ 1's. For each block, this happens with probability $1 - 2^{-c}$. Thus, by independence, we have that
$$
\mathbb{P}(\mathbf{x} \not\ni (1)^c) \leq (1 - 2^{-c})^{n/c}.
$$
Since $c$ is fixed, it follows that the upper bound tends to 0 as $n \to \infty$.


text:
Q: Injecting an Interface implementation in Swing objects I have defined a class InfoAction implements java.swing.Action that needs to retrieve some information from its calling context in order to execute itself. For this I have defined an interface for providing those information:
public interface InfoProvider {
    Info getInfo();
}

The actionPerformed in the InfoAction class looks like
public void actionPerformed(ActionEvent e) {
    Info info=e.getSource().getInfo();
    // ... treat Info ...
}

Then I want to create various Swing objects using these actions, every Swing object providing its own context to the action.
InfoAction infoAction = MyApp.getInstance().getAction(MyApp.RENAME_ACTION); // Retrieving one action
JButton button = new JButton(infoAction); // TODO: inject the InfoProvider interface
JMenuItem menuItem = new JMenuItem(infoAction); // TODO: inject the InfoProvider interface

I'm stuck at how to add to those swing objects the InfoProvider interface.
Naively I tried to write
InfoAction infoAction = MyApp.getInstance().getAction(MyApp.RENAME_ACTION);
JButton button = new JButton(infoAction) implements InfoProvider {
    Info getInfo() {
        return MyGui.this.getInfo();
        }
    };
JMenuItem menuItem = new JMenuItem(infoAction)  implements InfoProvider {
    Info getInfo() {
        return MyGui.this.getInfo();
        }
    };

But this is not a valid code.
I'd like to avoid creating sub-classes of all the Swing pieces such as
private class InfoButton extends JButton implements InfoProvider {...}, private class InfoMenuItem extends JMenuItem implements InfoProvider {...}.
So I wonder what are the other options to do this while keeping a clean code ?
Would working with reflection a good option ? Getting rid of the interface and testing if the actionEvent.getSource() has a getInfo() method ?
PS: I'm working with Java8

A: You don't need to specialize every component supporting actions (or timer or other sources of action events). Instead, create one specialized Action implementation to mediate between the component/event source and the actual action. E.g.
public class InfoProviderAction implements Action, InfoProvider {
    final PropertyChangeSupport listeners = new PropertyChangeSupport(this);
    final PropertyChangeListener relay = ev -> listeners.firePropertyChange(
                        ev.getPropertyName(), ev.getOldValue(), ev.getNewValue());
    final Action target;
    final InfoProvider actualProvider;

    public InfoProviderAction(Action target, InfoProvider actualProvider) {
        this.target = target;
        this.actualProvider = actualProvider;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        target.actionPerformed(new ActionEvent(
            this, e.getID(), e.getActionCommand(), e.getWhen(), e.getModifiers()));
    }

    @Override
    public Info getInfo() {
        return actualProvider.getInfo();
    }

    @Override
    public void addPropertyChangeListener(PropertyChangeListener listener) {
        boolean hadListeners = listeners.hasListeners(null);
        listeners.addPropertyChangeListener(listener);
        if(!hadListeners) target.addPropertyChangeListener(relay);
    }

    @Override
    public void removePropertyChangeListener(PropertyChangeListener listener) {
        boolean hadListeners = listeners.hasListeners(null);
        listeners.removePropertyChangeListener(listener);
        if(hadListeners && !listeners.hasListeners(null))
            target.removePropertyChangeListener(relay);
    }

    @Override
    public boolean isEnabled() {
        return target.isEnabled();
    }

    @Override
    public void setEnabled(boolean b) {
        target.setEnabled(b);
    }

    @Override
    public Object getValue(String key) {
        return target.getValue(key);
    }

    @Override
    public void putValue(String key, Object value) {
        target.putValue(key, value);
    }
}

Then, your MyGui class can use it like
InfoAction infoAction = MyApp.getInstance().getAction(MyApp.RENAME_ACTION);
infoAction = new InfoProviderAction(infoAction, this::getInfo);// inject the InfoProvider
JButton button = new JButton(infoAction);
JMenuItem menuItem = new JMenuItem(infoAction);

The component will see the InfoProviderAction as its action, which will exhibit the same properties and behavior as the wrapped action. Whereas the actual action will see the InfoProviderAction as the even source, implementing the InfoProvider interface as expected.
Problems could arise if the action expects the source to be a component. But actions should not assume this, as it would cause problems with Timer or global key bindings as event sources.

A: There is something you can use with Swing:

*

*JComponent.putClientProperty

*JComponent.getClientProperty
When you build your object, you can configure it:
class ComponentFactory {
  public static <T extends JComponent> T configure(T component) {
    // the MyGui.this won't compile here, but it is only to explain
    // what you can do with your current code.
    component.putClientProperty(InfoProvider.class, MyGui.this);
  }
}

And build object as in:
ComponentFactory.configure(new JButton(infoAction));

Or create a static method for it in ComponentFactory:
ComponentFactory.createButton(infoAction);

In your action, you can then read the property:
public void actionPerformed(ActionEvent e) {
  Object src = e.getSource();
  if (src instanceof JComponent) {
    JComponent c = (JComponent) src;

    Info info = (Info) c.getClientProperty(InfoProvider.class);
    ...
  }

}

Notes:
Since it is Swing, there is a some chance it requires to be Serializable - which I don't think is a problem in 2022.
And that the doc for putClientProperty says:

The clientProperty dictionary is not intended to support large scale extensions to JComponent nor should be it considered an alternative to subclassing when designing a new component.

It should be fine for one property, otherwise you would have to use subclassing and implements InfoProvider for each such component.


text:
Q: Redeployment of Azure Function does not happen I am experimenting with an Azure Function in PowerShell to answer a simple HTTP request.
I am editing directly in the Azure Portal.
I do not understand how deployment works. I assume it should directly redeploy after "save".
When I change my code and test it within Azure Portal I get debug results in the console/log and expected results in the HTTP-Output.
However: When I call the function from a browser, it returns different results. I think these are old results, so either the function is not redeployed or some cache / proxy is fooling my browser.
How can I see if redeployment took place after "save" in the AzurePortal?
How can I check debug / console output of a real invocation?

A: First, I run with the default Code from the Http Trigger Function (PowerShell Runtime) - i.e., created in the Azure Portal and edited the Function Code from the Portal itself > Saved > Clicked on Run again.
If we save the function, it will just save the changes in the code. We have to run again the Function for changes made in the Code Logic for new response.

You can see how many times your function in the Azure Function App is executed, in Monitor > Invocations with more information such as Response Code for every invocation (Function Run), Execution Time,
And I have updated the Function Code two times after 1st run of the default Code. Here in the Activity Logs, you can see number of times updated the run.ps1 function code updates registered:

Updated Answer:
I have run the Azure Function App PowerShell Http Trigger in the browser tab with its function URL for 4 times and the invocations are display after 4 minutes of time because my function app is hosted in Consumption plan:

A: Seems the function was "disabled" - after enabling it again all works as expected!


text:
Q: Why conditional breakpoints don't work in VScode with the hit count condition? I put a conditional breakpoint in this code on the line std::cout << i << ", "; :
(I use gdb)
#include <iostream>

int main() {

    for (int i = 0; i < 10; ++i) {
        std::cout << i << ", ";
    }

    std::cout << std::endl;
}

I set the hit count on 4. But I see VScode break on the breakpoint the very first time it gets to the breakpoint.
Anyone knows how to fix this ?
Oddly enough, if I enter the expression i == 4 it works tho.
Thx!


text:
Q: jpa criteriabuilder for @ElementCollection What's the equivalent CriteriaBuilder for this simple jpl?
TypedQuery<Sample> query = em.createQuery("from Sample s, In(s.friends) f where f = :friend", Sample.class).setParameter("friend", friend);
// query yields: select sample0_.id as id39_ from Sample sample0_ inner join Sample_friends friends1_ on sample0_.id=friends1_.Sample_id where friends1_.friends=?
return query.getResultList();

I've tried dozens of formulations using .in() .join() and .member() to no avail. .in only works as a where clause not as part of the from. .join seems to require a dereference to an attribute when using in the where. and .member only works on non-elemental types (full entities as the contained reference). [I can post my vain attempts. I've used the join() mechanism for other collections where the joined object is an entity, but I can't figure out how to use for an element.]


text:
Q: Can you get the Minecraft seed on xbox? I was wondering if/how to get the world seed to create a parallel-world for testing.

A: You can't get a seed unless you manually enter it.
It is, by default, not an observable aspect of the world generation.  The seed that is generated by the game is hidden, whether on purpose or not is unclear.


text:
Q: HUGO IN function not accepting variable as ITEM I am using the IN function of Hugo that can be used as in SET ITEM as defined at Hugo Documentation for IN
I am trying to filter out posts of a particular category by the below code
{{ range where .Site.Pages "Section" "products"}}
   {{ if in .Params.categories "New Arrival" }}

{{ .Title }}

   {{end}}
{{end}}

the above code works completely fine.
But if I use a variable instead of a string for the ITEM. It always returns False.
{{ $display_product_cat := "New Arrival" }}

{{ range where .Site.Pages "Section" "products"}}
      {{ if in .Params.categories $display_product_cat }}

{{ .Title }}

      {{end}}
{{end}}

The above code does not work as expected.
Wondering if I am missing something here. Appreciate your time and help.

A: You can test what the boolean is by something like:
{{ $i := in .Params.categories "New Arrival" }}
{{ $i }} ## will output true|false

{{ $var := "New Arrival" }}
{{ $j := in .Params.categories $var }}
{{ $j }} ## will output true|false

If it's giving false outcomes, you might need to inspect how your .Params are actually constructed (what pattern are they in, etc.).
Providing more info will allow a better debug for you (like the snippet of your Params).


text:
Q: website.com/index.php/page works but website.com/page doesn't Here is the website I'm specifically talking about: http://anomet.com.
The home page loads fine, but navigating to another page doesn't, unless it's prefixed with index.php. For example: http://anomet.com/index.php/lighting works, but http://anomet.com/lighting doesn't. The website was created using Laravel 5.4.15. The website is hosted on Bell's server, and when I called them, they said mod_rewrites should be enabled. I have proper permissions set on my storage folder as well (755), since I've read that not having proper permissions on the Laravel folder can cause this problem. Here is my .htaccess file below:
<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>
    RewriteEngine On
    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]
    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

AddHandler phpCGI .xml .php
Action phpCGI /cgi-bin/php5.6fcgi
# for php5 and securewebexchange
<IfDefine SSL>
    AddHandler phpCGI .xml .php
    Action phpCGI https://secure9.securewebexchange.com/anomet.com/cgi-bin/php5.6fcgi
</IfDefine>

Is Bell wrong in saying that mod_rewrites is enabled? The tech support person didn't sound confident on the phone, and they didn't actually check the configuration files (i.e. httpd.conf or apache.conf) to see if it had anything like AllowOverride All or Require all granted inside of it.
Lastly, I have the exact same files uploaded to a Namecheap server (https://kdev.solutions/) and everything works on there, which further leads me to believe that the problem is with Bell's server configuration.


text:
Q: overriding paint method in JApplet I am working on a project to make a JApplet's contents automatically scale to the size specified in the html. I realize this is the kind of thing that layout managers were made for, however as I am not permitted to rewrite the entire applets structure, i decided i would try to override paint and simply set the AffineTransform of the Graphics object to an appropriately scaled version, then capture mouse Events in the top container and scale them back with an appropriate scaling transform. Im getting stuck on the drawing part at the moment. When viewed in a web browser, it renders the scaled version correctly once, then the image is shrunk back to its original size. In addition, it seems that the paint method in JApplet is only ever called once. Here is a cropped version of my code which focuses on the problem. Any help would be appreciated. Thanks in advance.
import javax.swing.JApplet;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;

public class Test extends JApplet
{
        public static final int ORIGINAL_APPLET_WIDTH = 1024;
        public static final int ORIGINAL_APPLET_HEIGHT = 800;
        private AffineTransform scalingTransform;
        private AffineTransform inverseScalingTransform;
 @Override
 public void init()
 {
            double xFactor = ((double)(this.getWidth()))/((double)(Test.ORIGINAL_APPLET_WIDTH));
            double yFactor = ((double)(this.getHeight()))/((double)(Test.ORIGINAL_APPLET_HEIGHT));
            this.scalingTransform = new AffineTransform();
            this.inverseScalingTransform = new AffineTransform();
            this.scalingTransform.scale(xFactor,yFactor);
            this.inverseScalingTransform.scale(1D/xFactor,1D/yFactor);
 }
    @Override
    public void paint(Graphics g)
    {
        ((Graphics2D)g).setTransform(Test.this.scalingTransform);
        super.paint(g);
    }
}

A: I figured out, after much research, that the problem was that JApplet's paint method doesn't get called very often. The instead the content pane has its own drawing surface, so i simply had to replace the content pane to get it to upload. heres the way i did it:
@Override
    public void init()
    {
            double xFactor = ((double)(this.getWidth()))/((double)(qt.ORIGINAL_APPLET_WIDTH));
            double yFactor = ((double)(this.getHeight()))/((double)(qt.ORIGINAL_APPLET_HEIGHT));
            this.scalingTransform = new AffineTransform();
            this.inverseScalingTransform = new AffineTransform();
            this.scalingTransform.scale(xFactor,yFactor);
            this.inverseScalingTransform.scale(1D/xFactor,1D/yFactor);
            JPanel drawScale = new JPanel()
            {
                @Override
                public void paint(Graphics g)
                {
                    ((Graphics2D)g).setTransform(Test.this.scalingTransform);
                    super.paint(g);
                }
                @Override
                public void paintAll(Graphics g)
                {
                    ((Graphics2D)g).setTransform(Test.this.scalingTransform);
                    super.paintAll(g);
                }
                @Override
                public void paintComponents(Graphics g)
                {
                    ((Graphics2D)g).setTransform(Test.this.scalingTransform);
                    super.paintComponents(g);
                }
                @Override
                public void paintComponent(Graphics g)
                {
                    ((Graphics2D)g).setTransform(Test.this.scalingTransform);
                    super.paintComponents(g);
                }
            };
            Container oldPane = this.getContentPane();
            drawScale.setLayout(oldPane.getLayout());

            this.setContentPane(drawScale);
}

these paint methods were of course in addition to the ones in the applet.


text:
Q: Losing documents in my collection I'm looking for suggestions on how to debug this one.
When one of my documents gets too large in a collection, the entire document is removed from the collection. I'm using heroku with mongoid 2.2.6 and rails 3.0.20 with MongoHQ. I'm unable to reproduce the problem locally.
We started writing this code two years ago and it's been slowly maintained by some of my students. The site is similar to a basic blogging site where a "post" will have "comments." The initial design had the post versioned and each post contains all of the comments. Because of versioning, the size of the document can grow very quickly. We tried to limit the size of the versions with max_versions 5, but we can still reproduce the problem with extremely large comments. It may be the case that the site is fully useable, but since we loose the entire document (and not just the comment), I'd like to find a solution. Had I noticed that the comments were being versioned within the document, I'd have change the design to store comments outside of the post.

A: As a comment said, it is likely that your document simply grows too large. Since a while, all the MongoDB drivers default to Acknowledged Writes, which in most cases will give you an exception if a document can't be stored or updated. Please check whether you use a recent driver version and/or have Acknowledged Writes turned on (sometimes also called "safe").
I still think your best bet is to change your schema. If you have an unbound amount of comments then you will run into this problem, even without versioning at some point. Alternatively, you can store older comments and/or posts in a separate collection.

A: A few pieces of info that may help:

*

*The server will not delete the document if it grows past the 16MB limit; instead it will raise an error (e.g. Invalid size).

*To the best of my knowledge, there's nothing in Mongoid nor the MongoDB Ruby driver that would delete the document if an update operation fails.

*If the application removes a document and then inserts a new document for every update, I would suggest modifying the application to leverage updates and simply ensure any errors are handled appropriately.


text:
Q: To add hh/mm/ss to date in sql In the below query i want to add hh/mm/ss in date.I want to add 00:00:00 and 23:59:59 to my date .pls help me to do this.
@i_StartDate VARCHAR(50)

    SELECT Distinct p.ProductID,
       p.ProductName,
       ISNULL((SELECT top 1 ISNULL( CurrentStock,0.00)
        FROM   Productstatus PS
        WHERE  PS.ProductID =p.ProductID
               AND PS.LocationID = 1
               AND  PS.StatusDateTime>= @i_StartDate+'00:00:00' AND  PS.StatusDateTime<= @i_StartDate+'23:59:59'
               and PS.productid=p.productid),0) OpeningStockQuantity
     from Product p

A: Convert to Datetime should help you..
SELECT Distinct p.ProductID,
       p.ProductName,
       ISNULL((SELECT top 1 ISNULL( CurrentStock,0.00)
        FROM   Productstatus PS
        WHERE  PS.ProductID =p.ProductID
               AND PS.LocationID = 1
               AND  PS.StatusDateTime>= convert(datetime,@i_StartDate+' 00:00:00') AND  PS.StatusDateTime<= convert(datetime,@i_StartDate+' 23:59:59')
               and PS.productid=p.productid),0) OpeningStockQuantity
     from Product p

A: Add Time in the Date and Cast to Datetime
SELECT Distinct p.ProductID,
   p.ProductName,
   ISNULL((SELECT top 1 ISNULL( CurrentStock,0.00)
    FROM   Productstatus PS
    WHERE  PS.ProductID =p.ProductID
           AND PS.LocationID = 1
           AND
CAST(PS.StatusDateTime as DATETIME)>=
CAST(DATEADD(day, DATEDIFF(day, 0,@i_StartDate), '00:00:00') as DATETIME) AND
CAST(PS.StatusDateTime as DATETIME)<=
CAST(DATEADD(day, DATEDIFF(day, 0,@i_StartDate), '23:59:59') as DATETIME) AND
PS.productid=p.productid),0) OpeningStockQuantity
 from Product p

A: AND  PS.StatusDateTime>= CONCAT(@i_StartDate,' 00:00:00')

 AND

 PS.StatusDateTime<= CONCAT(@i_StartDate,' 23:59:59')

-->

A: Assuming you are on SQL 2008+ just cast the StatusDateTime as Date and compare to your @i_StartDate.
DECLARE @i_StartDate date = '2014-11-01'

    SELECT DISTINCT
        p.ProductID,
        p.ProductName,
        ISNULL((SELECT top 1 ISNULL(CurrentStock,0.00)
        FROM   Productstatus PS
        WHERE  PS.ProductID =p.ProductID
            AND PS.LocationID = 1
            AND  CAST(PS.StatusDateTime AS DATE) = @i_StartDate
            AND PS.productid=p.productid),0) OpeningStockQuantity
        FROM Product p


text:
Q: If I can't use return to exit a for...in loop, what can I use? What's the rule with return in for...in loops? Checked MDN MDN for any references and found none. It looks to me like it isn't allowed in for...in loops and the loop won't run:

o = {
    color: "red",
    shape: "circle"
};

console.log(o)

for (key in o) {
    o[key] = "square";
    return
};

console.log(o);

What's a better way to stop executing the loop (exit the loop) like return and break seem to do in long-form for loops?

A: This has nothing to do with the for loop.
You can't return outside of a function.
You can use break to break a for..of loop.

o = {
  color: "red",
  shape: "circle"
};

console.log(o)

for (key in o) {
  o[key] = "square";
  break;
};

console.log(o);


text:
Q: Looks like javascript doesn't recognize new elements after ajax call I got an element which loads data in it according to a block that was clicked.
Using Ajax I load an entire phpfile inside my index after a variable is sent to it.
For example:
Block 1 is clicked, $block (containing string: block1) is sent to my php script where I place $block in my query to retrieve the correct data. After that I load the result on my index.
This works as it should but all javascript functionalities are broken. When I add the php script in my index and don't retrieve it using ajax but add the word manually (where $block would normally be) all javascript works fine.
So it seems when the result is loaded, the javascript is already finished or doesn't recognize it. How can I fix that?
My code where I retrieve it:
$('.handmouse').on('click', function(e){
        var alias = $(this).attr("data-attribute");
        var clicked = true;
        $.post("ajax/blokken.php", {
          dienstnaam : alias
        }, function(data) {
            $(".tabwrapper").html(data);
        });
        $('.tabwrapper').slideToggle();
        if(clicked != true){
          $('html, body').animate({
              scrollTop: $(".tabwrapper").offset().top
          }, 2000);
        }
    });

A: You need to put all your code into success method of your ajax call and not after your ajax call, because ajax call is async.
$('.handmouse').on('click', function(e){
    var alias = $(this).attr("data-attribute");
    var clicked = true;

    $.post("ajax/blokken.php", {
        dienstnaam : alias
    }, function(data) {
        $(".tabwrapper").html(data);
        $('.tabwrapper').slideToggle();
        if(clicked != true){
            $('html, body').animate({
                scrollTop: $(".tabwrapper").offset().top
            }, 2000);
        }
    });
});


text:
Q: Getting text from an element with the same class name using jQuery I've got a little drag and drop app which i've built. It's working OK, but there is a slight issue where I drag on the item to the droppable location.
It should get the text from the HTML (which is does) and update another div to show the user what they've dragged in.
Unfortunately, it always returns the same name, no matter which list item you drag. This is the first in the list, so the first instance of that class.
Anyway we can get the correct label for the item dragged?
Here is my jQuery
$(function() {
    $( ".drag_me" ).draggable({ revert: "invalid" });
    $( ".choc2_bowl" ).droppable({
      drop: function( event, ui ) {
        $( this )

            var htmlString = $('.choc_label').html();
            $('.choc2_flavour').text( htmlString );

            ui.draggable.fadeOut(500);
      }
    });
  });

An here is the list in my HTML (this is shortened for this demo, but the list is dynamic from a DB.

Raspberries

Strawberries

Blueberries

Cranberries

Any help would be greatly appreciated!
Simon

A: You need to target the choc_label inside the dragged element so use
$(".choc2_bowl").droppable({
    drop: function (event, ui) {
        var htmlString = ui.draggable.find('.choc_label').html();
        $('.choc2_flavour').text(htmlString);
        ui.draggable.fadeOut(500);
    }
});


text:
Q: Measuring Variance of 2D Data Points I have a list of weighted data points on a 2D plane in the form $(x, y)$.  I believe the mean can calculated as $\left(\frac{\sum{x_i\times w_i}}{\sum w_i}, \frac{\sum{y_i\times w_i}}{\sum w_i}\right)$.
What is the best way to calculate a single value which will accurately describe the spread of the data points?

A: You have computed the weighted mean $$\mathbf{\bar x}_* = \sum w_i\mathbf{x}_i$$ (assume $\sum w_i = 1$ for ease of notation). Then why not use weighted variance
$$\sum w_i|\mathbf{x}_i -\mathbf{\bar x}_*|^2$$
or, for an unbiased version, use the unbiased weighted variance
$$\frac{1}{1-\sum w_i^2}\sum w_i|\mathbf{x}_i -\mathbf{\bar x}_*|^2$$
Here, $|\cdot|$ denotes the ordinary Euclidean norm $|\mathbf u| = \sqrt{u_1^2+u_2^2}$, so $|\mathbf{ u }|^2 = u_1^2+u_2^2$.


text:
Q: Publisher - Subscriber communication between un-related components in Angular4 I am using Angular4 app with typescript. I have a left menu (component 1), clicking on one of the items loads a screen (component 2).
On the action of button click in component2 I want component 1 to load menu items.
I tried Observable.Subscribe() & Subject.next() with a shared service. However this does not work.
I also tried this http://jasonwatmore.com/post/2016/12/01/angular-2-communicating-between-components-with-observable-subject with no help at all.
Can someone please help me understand/direct me in the right direction for me to achieve this.


text:
Q: Unable to recompile package in Oracle 9i I have a need to recompile a package in oracle 9i. But the session gets hung forever. When I checked in V$SESSION_WAIT, got to know that it is waiting on an event 'library cache pin'. Couldn't get a possible solution for 9i version. Is there anyway to find the session, that is executing my package and kill it?

A: Sure.
To find what sessions run a code which contains a name:
select s.*,sa.*
FROM v$session s
left join v$sqlarea sa
   on s.sql_address=sa.address AND s.sql_hash_value=sa.hash_value
where sql_text like '%your_package_name_here%';

After this, you have the pid and serial so you can kill the session you need to kill. (The code above may return sessions that you do not need to kill, for example, it is finding itself :)  )

A: Oracle offers no built-in easy path to do this.
If your application uses the DBMS_APPLICATION_INFO routines to register module usage you're in luck: you can simply query V$SESSION filtering on MODULE and/or ACTION.  Alternatively, perhaps you have trace messages in your PL/SQL which you use?
Otherwise, you need to start trawling V$SQLTEXT (or another of the several views which show SQL) for calls containing the package name.  Remember to make the search case-insensitive.  This will give you a SQL_ID you can link to records in V$SESSION.
This will only work if your package is the primary object; that is, if it is the top of the call stack.  That is one explanation for why the package is locked for so long. But perhaps your package is called from some other package: in that case you might not get a hit in V$SQLTEXT.  So you will need to find the programs which call it, through ALL_DEPENDENCIES, and sift V$SQL_TEXT for them.
Yes, that does sound like a tedious job.  And that is why it is a good idea to include some form of trace in long-running PL/SQL calls.


text:
Q: Blend's Assets list is empty Blend to Visual Studio 2012 have an empty assets list. Instead of items it shows a sendwatch coursor.
I don't found any way to fix or restore it.
I have tried to google but no result.
UP: It seems to be project related because all working correct while another project are editing.

A: Try to separate Windows Store and Windows Phone project in a different solution. Have you tried this? I have tried this and it works well on my machine.
The sad fact is, can be that Expression Blend 5 for Visual Studio was having trouble of separating assets for Windows Store and Windows Phone application within the same solution.


text:
Q: Getting a directory path using project directory I have a project whose name is Myproject.Application.DataExporter. I'm saving a file to a directory whose name is Export. I'm using this code :
workbook.Save(@"D:\workspace\MyApp\Myproject.Application.DataExporter\Export\Calc.xlsx");

I see how to get current project directory in Stackoverflow. There is this code :
Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;

I want to save file under Export directory, using a generic path like the code above. It gives current project directory. I want to use it for adding a file to Export directory. How can I use it in my project for adding a file to Export? Thanks.

A: As per the other previous comments you need to clarify your question.  I'm assuming you want to get the current directory and then save a file to it so the path is relative to where you host your application?
You could just do this:
workbook.Save(Path.Combine(Environment.CurrentDirectory, "Calc.xlsx");

To get path relative to the your current working directory see here:
Getting path relative to the current working directory?
EDIT:
Can't comment as not enough reputation.
When you do a Directory.GetCurrentDirectory() what is the value that is returned?
If Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName returns the "Export" folder path you could just do this:
string fileName = "Calc.xlsx";
workbook.Save(Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName, fileName );

A: string dir = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
string path = Path.Combine(dir, "Myproject.Application.DataExporter", "Export");
string file = "Calc.xlsx";
workbook.Save(Path.Combine(path, file));

or if you want to skip Myproject.Application.DataExporter
string dir = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
string path = Path.Combine(dir, "Export");
string file = "Calc.xlsx";
workbook.Save(Path.Combine(path, file));


text:
Q: Tricky sticky footer with sidebar I'm looking to place a sticky footer inside of the content area of a page with a full-height sidebar.
Here is a copy of the page I'm working on:
http://www.lavenderstone.co.uk/stackoverflow/

I've worked with http://ryanfait.com/sticky-footer/ many times successfully in the past, and a method using %'s instead. The twist to the problem I'm having is there is a 100% height sidebar (green) and I need the footer (orange) at the bottom of the content div (grey).
I can't place the footer div at the bottom of its parent div, nor can I force its sibling to have 100% height minus the hight of the footer. I've tried both to no avail.
I could place the footer right at the bottom of the page, but this would disrupt the design of the side bar. Can anyone help? I'm almost wanting to resort to javascript!

A: add this style to content-wrap element
#content-wrap{
    height:100%;
}

put your footer element in your content element and add this style;
#footer{
    position:absolute;
    bottom:0;
}


text:
Q: How can you find the probability that an element is part of a sampled set? Let's say I have a set of scalar values $V$ that I sampled from a set $S$.  I want to test whether a given value $X$ could be a member of $S$ or not.
I understand that if the values in $V$ are distributed normally, then we can find the mean and standard deviation, after which you can determine the probability of occurrence for any particular value based on how many standard deviations your value differs from the mean.
However, what happens if the values are not distributed normally?  For example, what if you have 2 peaks in your data?
Example: If you sample the ratio of pelvis width to femur length over a large number of adults, you will have 2 peaks, one for men and one for women.  Now, my question is, given a particular ratio, how can we determine the probability that the subject was human? (i.e. probability that the ratio is part of our set $S$.)

A: If you think your data consists of multiple peaks or components, each of which might be normally distributed, you could try a Gaussian mixture model, see this video.
For your example with the femur lengths, you would have one Gaussian component corresponding to the male ratios and one Gaussian component corresponding to the female ratios and the distribution over all humans is an equal mixture of these two.


text:
Q: Cannot Create Any Account on Windows 7 - User Profile Service failed the logon. User profile cannot be loaded I have run this weird problem of not being able to create any users. It began with the idea of creating new user for gaming. Before that I had 2 Admin accounts, 1 normal password protected account, 1 guest accout (not protected for frieds) - and some several hidden services for Xampp Services. And never had such a problem anymore.
I have created a new user and put a password from my normal user (with UAC asking for an admin-password). Tried to switch to newly created user and had this error (in german on my pc):
User Profile Service failed the logon. User profile cannot be loaded.
I have done some research and found out there is a solution for this but mostly people experienced it with an existing already-in-use account, where they could delete the entry in the registry/transfer files etc.
This does not work in my case as there NO registry entries in profilelist and there is NO folder for the user. The only trace of this newly created account is that it appears in the login screen of windows.
So I had the idea to see what particular error message there is, which is timely overlapping with logging into that account and I have found these 2 errors (translation found on the net):
"Windows cannot find the local profile and is logging you on with a temporary profile. Changes you make to this profile will be lost when you log off."
"Windows cannot log you on because your profile cannot be loaded. Check that you are connected to the network, and that your network is functioning correctly." (I think this is because it tries to login with TEMP account but does not succeed that too!)
I also get several warnings:
"The Winlogon notification subscriber Profiles failed a critical notification event."
"Die Datei \?\C:\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\desktop.ini konnte nicht nach \?\C:\Users\Gamer\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\desktop.ini kopiert werden. Mögliche Fehlerursachen sind Netzwerkprobleme oder nicht ausreichende Sicherheitsrechte.
Details - Zugriff verweigert" (did not find any exact translation but it says that the file cannot be copied and access denies)
So therefore I was wondering what the problem was and looking for answers. Finally I have found this about security rights of the folders. (sorry it is in german)
So I have started to investigate the security rights of all those files, which could not be copied. All of them were inaccessible by the Administrators!
So I have changed the ownership of those files to administrators and gave the permission to them and everyone. After this step I could log in and both the folders and registry keys were created.
When I have started with this text I didn't know the solution so I have decided to keep writing and share. I did not know why suddenly the problem occured so I cannot trace it back to prevent it happening again.
PS: Windows 7 Home Premium, all updates installed.

A: I have started to investigate the security rights of all those files, which could not be copied. All of them were inaccessible by the Administrators!
So I have changed the ownership of those files to administrators and gave the permission to them and everyone. After this step I could log in and both the folders and registry keys were created.
When I have started with this text I didn't know the solution so I have decided to keep writing and share. I did not know why suddenly the problem occured so I cannot trace it back to prevent it happening again.

A: Have you tried restoring to an earlier time through safemode? "The User Profile Service Failed The Logon"

A: I had exactly the same problem. In the logs I saw it trying to copy something from default profile's local temporary Internet files. Why would default profile have temporary Internet files, I would think it should only have an empty directory? Checked my other Win7Pro 64 bit computer. Nothing there. I removed those files and that fixed the problem. They were directories called SQM and Content.IE5.


text:
Q: Writing DataFrame as parquet creates empty files I am trying to do some performance optimization for Spark job using bucketing technique. I am reading .parquet and .csv files and do some transformations. After I am doing bucketing and join two DataFrames. Then I am writing joined DF to parquet but I have an empty file of ~500B instead of 500Mb.

*

*Cloudera (cdh5.15.1)

*Spark 2.3.0

*Blob
val readParquet = spark.read.parquet(inputP)
readParquet
    .write
    .format("parquet")
    .bucketBy(23, "column")
    .sortBy("column")
    .mode(SaveMode.Overwrite)
    .saveAsTable("bucketedTable1")

val firstTableDF = spark.table("bucketedTable1")

val readCSV = spark.read.csv(inputCSV)
readCSV
    .filter(..)
    .ordrerBy(someColumn)

    .write
    .format("parquet")
    .bucketBy(23, "column")
    .sortBy("column")
    .mode(SaveMode.Overwrite)
    .saveAsTable("bucketedTable2")

val secondTableDF = spark.table("bucketedTable2")

val resultDF = secondTableDF
    .join(firstTableDF, Seq("column"), "fullouter")
    .
    .
resultDF
    .coalesce(1)
    .write
    .mode(SaveMode.Overwrite)
    .parquet(output)

When I launch Spark job in command line using ssh I have correct result, ~500Mb parquet file which I can see using Hive. If I run the same job using oozie workflow I have an empty file (~500 Bytes).
When I do .show() on my resultDF I can see the data but I have empty parquet file.
+-----------+---------------+----------+
|       col1|          col2 |      col3|
+-----------+---------------+----------+
|33601234567|208012345678910|       LOL|
|33601234567|208012345678910|       LOL|
|33601234567|208012345678910|       LOL|

There is no problem writing to parquet when I am not saving data as a table. It occurs only with DF created from table.
Any suggestions ?
Thanks in advance for any thoughts!

A: I figured it out for my case I just added an option .option("path", "/sources/tmp_files_path"). Now I can use bucketing and I have a data in my output files.
readParquet
  .write
  .option("path", "/sources/tmp_files_path")
  .mode(SaveMode.Overwrite)
  .bucketBy(23, "column")
  .sortBy("column")
  .saveAsTable("bucketedTable1")


text:
Q: Dar formato de moneda, Laravel chats 6 por mucho que busque no encuentro como darle el formato de moneda a los importes laterales que salen de la gráfica. Todo lo que encuentro está en JavaScript y no se como hacerlo en el controlador de Laravel.
Esto lo tengo en el controlador de Laravel.
$chart->dataset('Ventas:', 'bar', array_values($result))
      ->color("#3d3d3d")
      ->backgroundcolor("rgba(111, 216, 205, 0.54)")
      ->options([
            'borderWidth' => 1,

      ]);

Y lo que encuentro que se puede hacer es así:
 scales: {
    yAxes: [{
      ticks: {
        beginAtZero: true,
        callback: function(value, index, values) {
          if(parseInt(value) >= 1000){
            return '$' + value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
          } else {
            return '$' + value;
          }
        }
      }
    }]
  }

Pero no se como incorporar esto en laravel, como veis aquí está en $ pero siria ponerlo en €.


text:
Q: Bayesian inference on a sum of iid random variables with known distribution Let $X_1$, $X_2$, ..., $X_n$ be iid RV's following a mixture distribution of two lognormals such that the pdf of each $X_i$ is $f_{mix}(x)=pf_1(x) + (1-p)f_2(x)$ where $f_1(x)$ and $f_2(x)$ are lognormal pdfs with parameters $\mu_1,\sigma$ and $\mu_2,\sigma$, respectively.
Define $S_i$ as a sum of 10 $X$s, e.g. $S_1 = X_1 +..+ X_{10}, \ \ S_2 = X_{11} +..+X_{20},...$
I am given only $S_1,S_2,\dots,S_{n/10}$.
How can I infer the mixing proportion parameter $p$ here?
That means, I want to know what the proportion of the two lognormals in my mixture is among the 10 samples is (but I only have the sum measurement).
Note that the sum of lognormals is not lognormally distributed.
My problem could be related to this one, but I am not sure:
Bayesian inference on a sum of iid real-valued random variables
update:
assume that I have many samples of $S_i$. If that helps we can assume that the $\mu$s are well separated, making the mixture nicely bimodal.
Generally in mixtures it is that the mixing proportions sum to 1.
This is also why I thought about the Dirichlet process. I have no restrictions on the values of $p$ otherwise.

A: Each $X_i$ comes from either one of the two lognormals with probabilities $p$ and $1-p$.  Let $Z_j$ be the number of $X_i$'s in the sum $S_j=\sum_{i=10j-9}^{10j}X_i$ that comes from the first lognormal.  Clearly $Z_j \sim \mbox{bin}(10,p)$.  Conditional on $Z_j$, each $S_j$ is a sum of $Z_j$ lognormals with parameters $\mu_1,\sigma^2$ and $10-Z_j$ lognormals with parameters $\mu_2,\sigma^2$, with pdf
$$
f_{S|Z=z}(s;\mu_1,\mu_2,\sigma^2), \tag{1}
$$
given by a complicated convolution integral.  The unconditional distribution of each $S_j$ is the 11-component mixture
$$
f_S(s;\mu_1,\mu_2,\sigma^2,p)=\sum_{z=0}^{10}{10 \choose z}p^z(1-p)^{10-z}f_{S|Z=z}(s;\mu_1,\mu_2,\sigma^2). \tag{2}
$$
If $\sigma^2$ is sufficiently small or $\mu_1$ and $\mu_2$ sufficiently different this is going to be a 11-modal distribution with modes located near $10e^{\mu_1+\sigma^2},9e^{\mu_1+\sigma^2}+e^{\mu_2+\sigma^2},\dots,10e^{\mu_2+\sigma^2}$.  This suggest that all five parameters in principle are identifiable given enough data.
Perhaps you can approximate the convolution in (1) by a single moment-matched lognormal as discussed here, use (2) to compute the likelihood and then compute approximate maximum likelihood estimates by maximising the resulting log likelihood numerically.  Or you could do approximate Bayesian inference using this approximate likelihood function.  This option would allow using informative priors on some of the parameters which might be necessary in practice if there is too much overlap between each component of (2).

A: A simulation based answer is to treat the $X_i$'s as latent variables and include these in a global MCMC sampler. At iteration $t$, it could proceed as follows

*

*Simulate the $X_i^t$'s given the $S_j$'s and the current value of the parameters ${\theta}^t$

*Given the $X_i^t$'s and their log-Normal mixture distribution, simulate the next value of the parameters, $\theta^{t+1}$

Step 2 is straightforward in that this is equivalent to simulate the posterior of a Normal sample. Step 1 can be decomposed in a sequence of Gibbs steps where each $X_i$ is generated conditional on the $8$ other $X_k$'s and the corresponding $S_j$. Meaning any MCMC move targeting the distribution
$$\{pf_1(x_i;\mu_1,\sigma_1)+(1-p)f_2(x_i;\mu_2,\sigma_2)\}\times
\{pf_1(s_j-x_{10(j-1)+1}-\ldots-x_{10j};\mu_1,\sigma_1)+(1-p)f_2(s_j-x_{10(j-1)+1}-\ldots-x_{10j};\mu_2,\sigma_2)\}$$

A: The parameter $p$ is not identifiable. This can be seen by writing
$f_{mix}=p\cdot \mathcal{LN}(\mu_1,\sigma) + (1-p)\cdot \mathcal{LN}(\mu_2,\sigma)$
as
$f_{mix}=\mathcal{LN}(\nu_1,\sigma) +\mathcal{LN}(\nu_2,\sigma)$
with $\nu_1=\log p + \mu_1$ and $\nu_2=\log (1-p) + \mu_2$
Then we can always choose $\mu_1=\nu_1-\log p$ and $\mu_2=\nu_2-\log (1-p)$. Then
$$p(f_{mix}|\mu_1,\mu_2,\sigma,p)=p(f_{mix}|\nu_1,\nu_2,\sigma,p)=p(f_{mix}|\nu_1,\nu_2,\sigma)$$
 and hence
$$p(S_n|\nu_1,\nu_2,\sigma,p)=p(S_n|\nu_1,\nu_2,\sigma)$$
In other words the data likelihood is independent of $p$ given $\mu_1$ and $\mu_2$.


text:
Q: Making recaptcha work with a reverse proxy I am trying to include a recaptcha verification on a 'forgot password' screen for users that are trying to connect to a mobile hotspot.  Prior to logging in, they have very limited access through the firewall, and therefore the forgot password screen can't download the js file from the standard script generated by Recaptcha.createRecaptchaHtml:
<script type="text/javascript" src="https://www.google.com/recaptcha/api/challenge?k=...."></script>

I can get around this by changing the src above to point to a local address, and setting up a reverse proxy to forward it to google.
However, this call downloads an additional javascript (https://www.google.com/recaptcha/api/js/recaptcha.js) file that contains more references to google (and I believe other sites as well) that the page cannot reach.
Question:  Has anyone tried to do something like this, and is there an elegant solution?  If not, I will resort to a simpler captcha solution that requires fewer firewall changes.

A: For anyone still wondering, I ended up using a lighter-weight captcha solution that did not require additional calls.


text:
Q: Hibernate 4.3 transactions in CMT EJB with Glassfish v4 I'm using Java EE 7 and latest Hibernate 4.3 on Glassfish 4. According to Hibernate documentation (http://docs.jboss.org/hibernate/orm/4.3/manual/en-US/html/ch01.html#tutorial-firstapp-helpers, http://docs.jboss.org/hibernate/orm/4.3/manual/en-US/html/ch13.html#transactions-demarcation-jta) I created:
pom.xml dependencies
<dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.3.4.Final</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.6</version>
    </dependency>
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>11.2.0</version>
    </dependency>
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.6</version>
    </dependency>
</dependencies>

hibernate.cfg.xml in src/main/resources:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
        <property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property>
        <property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:XE</property>
        <property name="hibernate.connection.username">xxx</property>
        <property name="hibernate.connection.password">xxx</property>
        <property name="hibernate.default_schema">xxx</property>

        <property name="hibernate.current_session_context_class">jta</property>
        <property name="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>
        <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.SunONETransactionManagerLookup</property>

        <mapping class="xxx" />
    </session-factory>
</hibernate-configuration>

HibernateUtil helper class
public class HibernateUtil {

    private static final SessionFactory sessionFactory = buildSessionFactory();

    private static SessionFactory buildSessionFactory() {
        try {
            // Create the SessionFactory from hibernate.cfg.xml
            Configuration configuration = new Configuration().configure();
            StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();
            return configuration.buildSessionFactory(serviceRegistry);
        } catch (HibernateException ex) {
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }

    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }

}

and EJB Stateless bean
@Stateless
public class AccountBean {
    SessionFactory sessionFactory = HibernateUtil.getSessionFactory();

    @Transactional
    public List findAll() {
        Session session = sessionFactory.getCurrentSession();
        List accounts = session.createQuery("from Account").list();

        return accounts;
    }
}

But I'm getting exception:

org.hibernate.HibernateException: No TransactionManagerLookup
  specified     at
  org.hibernate.context.internal.JTASessionContext.currentSession(JTASessionContext.java:85)
    at
  org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:1014)

Only working way is manually starting transactions each time like this:
public List findAll() {
    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();
    List accounts = session.createQuery("from Account").list();
    session.getTransaction().commit();

    return accounts;
}

but I don't want to write it all the time since I don't have to, according to documentation.

A: Do not use
     <property name="hibernate.transaction.manager_lookup_class">...</property>

in Hibernate 4. Use something like
<property name="connection.datasource">jdbc/MyDB</property>
<property name="current_session_context_class">jta</property>
<property name="hibernate.transaction.factory_class">org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory</property>
<property name="hibernate.transaction.jta.platform">org.hibernate.service.jta.platform.internal.SunOneJtaPlatform</property>

A: dont forget above your EJB:
   @TransactionManagement(TransactionManagementType.CONTAINER)
   @TransactionAttribute(TransactionAttributeType.REQUIRED)


text:
Q: unknown output in snakemake I'm working on implementing a very simple pipeline in snakemake in hopes of replacing a chain of annoying bash scripts with one cohesive Snakefile.
I'm having trouble writing a rule that splits a file into smaller pieces (using GNU split), and then leads to a second rule where the output is concatenated together.
I don't know what to write for the input in the concat step, since I don't know how to define all the files fitting the pattern bam_files/test*. I tried with glob, but that decidedly doesn't seem to work (it seems like it's actually skipping split altogether with the glob included). Is there any better way that I could be doing this?
# test snakemake pipeline
import glob

SAMPLE_IDS = ["test"]

rule all:
    input:
        expand("bam_files/{FASTQ}.out", FASTQ=SAMPLE_IDS)

rule split:
    input:
        expand("{FASTQ}.txt", FASTQ=SAMPLE_IDS)
    output:
        "bam_files/{FASTQ}."
    shell:
        "cat {input} | split -l 1000 -d - {output}."

rule concat:
    input:
        split_files = glob.glob("bam_files/{FASTQ}.*")
    output:
        "bam_files/{FASTQ}.out"
    shell:
        "cat {input} > {output}"

A: I think this should work:
SAMPLE_IDS = ["test"]

rule all:
    input:
        expand("bam_files/{FASTQ}.out", FASTQ=SAMPLE_IDS)

rule split:
    input:
        "{FASTQ}.txt"
    output:
        dynamic("bam_files/{FASTQ}.{PART}")
    params:
        length=1000
    shell:
        "cat {input} | split -l {params.length} -d - bam_files/{FASTQ}."

rule concat:
    input:
        split_files = dynamic("bam_files/{FASTQ}.{PART}")
    output:
        "bam_files/{FASTQ}.out"
    shell:
        "cat {input} > {output}"

It looks like the split rule should be taking one file {FASTQ}.txt at a time and producing {FASTQ}.1, {FASTQ}.2, ... or something similar. Because you don't know ahead of time how many files it will produce, you need to use dynamic() for both split.output and concat.input.


text:
Q: Application stopped to find shared library wkhtmltopdf is used to create pdf files in Debian Linux.
wkhtmltopdf suddenly stopped working. Running it from shell throws library not found error:
root@x:/usr/local/bin# ./wkhtmltopdf
./wkhtmltopdf: error while loading shared libraries: libQt5Core.so.5: cannot open shared object file: No such file or directory

Symlink of library exists in /usr/lib/x86_64-linux-gnu :
root@x:/usr/lib/x86_64-linux-gnu# ls -l libQt5Core.so.5*
lrwxrwxrwx 1 root root      20 jaan  30  2020 libQt5Core.so.5 ->
 libQt5Core.so.5.11.3
lrwxrwxrwx 1 root root      20 jaan  30  2020
libQt5Core.so.5.11 -> libQt5Core.so.5.11.3
-rw-r--r-- 1 root root 5200168 jaan  30  2020 libQt5Core.so.5.11.3

How to allow wkhtmltopdf to find library in Debian Linux ?
I tried to copy library to the same directory where whhtmltopdf exists (/usr/local/bin ) but problem persists.
It has worked for years but suddenly stopped working. Debian VPS server was re-booted unexpectedly, maybe this caused it.

A: Try to update your system..
if it does not help ; try ( as root or sudo it yourself )
strip --remove-section=.note.ABI-tag /usr/lib/x86_64-linux-gnu/libQt5Core.so

source : https://github.com/wkhtmltopdf/wkhtmltopdf/issues/4497
You should backup the file before alter it.


text:
Q: Loading html file from href into div won't work with jquery .load I cant seem to load any of my files in the href part of the dropdown menu. I am trying to load the files dynamically in the .where-you-tune class. I don't know what I am doing wrong because I keep getting

(index):81 Uncaught TypeError: $(...).load is not a function

I have excluded some of the bootstrap code because it is not necessary

    Scooters Tuner
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">

    </button>

        <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          Tuning Type
        </button>

          Guitar(Standard)
          Guitar(Drop D)
          Bass Standard
          Mandolin

          About
            (current)

The jQuery slim distribution is an alternative, not something to be used as well as the main distro.
Remove one of them, and your code works fine - I've verified this locally.


text:
Q: sql vba query expression syntax error I'm trying to run the following through vba sq in access but get an error "Extra ) in query expression '0)'". Following is the query expression:
mnthfld = "SELECT IIf([issuedate] <= #" & useDateUpper & "#," & _
    "IIf([expirydate] <= #" & useDateUpper & "#, 0, IIf([expirydate <=#" & useDateUpper & "#," & _
    "([expirydate]-#" & useDateUpper & "#+1)/([expirydate]-[effectivedate]+1),[grosspremium]),0),0) as 'EP M" & _
    Format(useDateLower, "mm yyyy") & "' FROM tblEpData"

Any help is appreciated. My hunch is that I'm using brackets wrongly in the subtraction and division parts.

UPDATE:
Snapshot of the mnthfield string on one iteration:
IIf([issuedate] <= #11/30/2015#,IIf([expirydate] <= #11/30/2015#, 0, IIf([expirydate <=#11/30/2015#,([expirydate]-#11/30/2015#+1)/([expirydate]-[effectivedate]+1),[grosspremium]),0,0)) as [EP M11 2015]

A: Each instance of IIf requires 3 parameters (bool_test, value_if_true, value_if_false)
I've converted the below string to be syntactically correct; you'll need to review it to make sure it's what you expected it to be doing though!
IIf([issuedate]<= #11/30/2015#,IIf([expirydate] <= #11/30/2015#, 0, IIf([expirydate] <=#11/30/2015#,(([expirydate]-#11/30/2015#+1)/([expirydate]-[effectivedate]+1)),[grosspremium])),0) as [EP M11 2015]

A: Add a ] in statement [expirydate <=#" & useDateUpper and remove the ,0 from [grosspremium]),0 should work. Final query looks like :
SELECT
IIf
(
    [issuedate] <= #11/30/2015#,
    IIf
    (
        [expirydate] <= #11/30/2015#,
        0,
        IIf
        (
            [expirydate] <=#11/30/2015#,
            ([expirydate]-#"11/30/2015"#+1)/([expirydate]-[effectivedate]+1),
            [grosspremium]
        )
    ),
    0
) as [EP M11 2015]