text:
Q: Android WebView Rendering Issue after Android System Webview Update I am facing Webview Rendering issue on Android devices after Android System WebView Update. Webview is rendering outside the screen. For more information, please check screenshot.

Does anyone have a same issue?
Any help will be appreciated.Thanks in advance.
Please see the xml file as asked:
       <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<include
    android:id="@+id/toolbar"
    layout="@layout/toolbar" />

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/fragment_back_color">

    <ScrollView
        android:id="@+id/offerDetailScrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        android:layout_above="@+id/installTextView">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="10dp">

            <android.support.v7.widget.CardView
                android:id="@+id/card_offer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <LinearLayout
                        android:id="@+id/topViewDealDisplay"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@color/white"
                        android:gravity="center"
                        android:orientation="vertical"
                        android:paddingBottom="10dp"
                        android:paddingTop="10dp">

                        <ImageView
                            android:id="@+id/dealImageView"
                            android:layout_width="45dp"
                            android:layout_height="45dp"
                            android:layout_centerInParent="true"
                            android:layout_margin="5dp"></ImageView>

                        <com.spiceladdoo.views.LatoRegularTextView
                            android:id="@+id/dealNameTextView"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:padding="4dp"
                            android:text=""
                            android:textColor="@color/text_color"
                            android:textSize="18sp" />

                        <com.spiceladdoo.views.LatoRegularTextView
                            android:id="@+id/offerTitleTextView"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:padding="4dp"
                            android:text="deal titile"
                            android:textColor="@color/lower_text_color"
                            android:textSize="18sp"
                            android:visibility="gone" />

                        <com.spiceladdoo.views.LatoRegularTextView
                            android:id="@+id/offerTypeTextView"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="10dp"
                            android:layout_marginRight="10dp"
                            android:ellipsize="end"
                            android:gravity="center"
                            android:maxLines="2"
                            android:text=""
                            android:textColor="@color/lower_text_color"
                            android:textSize="14sp" />
                    </LinearLayout>

                    <FrameLayout
                        android:id="@+id/frameLayoutAmount"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"
                        android:layout_alignParentTop="true"
                        android:layout_marginTop="20dp"
                        android:clickable="true"
                        android:focusable="true"
                        android:gravity="right">

                        <ImageView
                            android:id="@+id/iv_rupee_bg"
                            android:layout_width="70dp"
                            android:layout_height="30dp"
                            android:layout_marginRight="-15dp"
                            android:background="@drawable/deals_image_background" />

                        <com.spiceladdoo.views.LatoRegularTextView
                            android:id="@+id/tv_amount"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"
                            android:gravity="center"
                            android:paddingLeft="4dp"
                            android:textAppearance="?android:attr/textAppearanceMedium"
                            android:textColor="#ffffff"
                            android:textSize="17sp" />
                    </FrameLayout>
                </RelativeLayout>
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:id="@+id/cardview_descImage"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/card_offer"
                android:layout_marginTop="10dp"
                android:paddingBottom="5dp"
                android:paddingTop="5dp">

                <ImageView
                    android:id="@+id/dealDescriptionImageView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:adjustViewBounds="true"
                    android:src="@null"
                    android:visibility="visible" />
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:id="@+id/cardview_shortDesc"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@id/cardview_descImage"
                android:layout_marginTop="10dp"
                android:padding="5dp">

                <WebView
                    android:id="@+id/shortDescWebView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:visibility="visible" />
            </android.support.v7.widget.CardView>

            <com.spiceladdoo.views.LatoBoldTextView
                android:id="@+id/related_offer_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/cardview_shortDesc"
                android:layout_gravity="center"
                android:layout_marginRight="10dp"

                android:text="SIMILAR OFFERS"
                android:textColor="@color/text_color"
                android:textSize="13sp" />

            <android.support.v7.widget.RecyclerView
                android:id="@+id/recyclerViewoffers"
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:layout_below="@id/related_offer_text"
                android:layout_marginTop="10dp"
                android:scrollbars="none" />

            <ProgressBar
                android:id="@+id/shortDescriptionProgress"
                style="?android:attr/android:progressBarStyle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:visibility="visible" />

        </RelativeLayout>
    </ScrollView>

    <com.spiceladdoo.views.LatoRegularTextView
        android:id="@+id/installTextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerInParent="true"
        android:layout_marginTop="5dp"
        android:background="@color/newFreeBColor"
        android:gravity="center"
        android:paddingBottom="15dp"
        android:paddingTop="15dp"
        android:text="INSTALL"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textColor="#FFFFFF"
        android:textSize="16sp"
        android:textStyle="bold"
        android:visibility="visible" />

    <FrameLayout
        android:id="@+id/hint"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_above="@+id/layoutInstallHint"
                android:background="#99000000"></RelativeLayout>

            <RelativeLayout
                android:id="@+id/layoutInstallHint"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_centerInParent="true"
                android:background="#99000000">

                <com.spiceladdoo.views.LatoRegularTextView
                    android:id="@+id/installTextHint"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:layout_marginBottom="15dp"
                    android:layout_marginTop="5dp"
                    android:background="@color/spice_laddooblue"
                    android:paddingBottom="10dp"
                    android:paddingLeft="80dp"
                    android:paddingRight="80dp"
                    android:paddingTop="10dp"
                    android:text="INSTALL"
                    android:textAppearance="?android:attr/textAppearanceSmall"
                    android:textColor="#FFFFFF"
                    android:textSize="15sp"
                    android:textStyle="bold"
                    android:visibility="visible" />
            </RelativeLayout>

            <com.spiceladdoo.views.LatoRegularTextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_above="@+id/imageViewHintPinIcon"
                android:layout_centerHorizontal="true"
                android:text="Click on Button"
                android:textColor="@color/white"
                android:textSize="18sp" />

            <ImageView
                android:id="@+id/imageViewHintPinIcon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="50dp"
                android:src="@drawable/hint_pin_down" />
        </RelativeLayout>
    </FrameLayout>

</RelativeLayout>

A: I think you have made mistake in giving webview's height you have given it as wrap_content instead try match_parent and give it try
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<include
    android:id="@+id/toolbar"
    layout="@layout/toolbar" />

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/fragment_back_color">

    <ScrollView
        android:id="@+id/offerDetailScrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        android:layout_above="@+id/installTextView">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="10dp">

            <android.support.v7.widget.CardView
                android:id="@+id/card_offer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <LinearLayout
                        android:id="@+id/topViewDealDisplay"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@color/white"
                        android:gravity="center"
                        android:orientation="vertical"
                        android:paddingBottom="10dp"
                        android:paddingTop="10dp">

                        <ImageView
                            android:id="@+id/dealImageView"
                            android:layout_width="45dp"
                            android:layout_height="45dp"
                            android:layout_centerInParent="true"
                            android:layout_margin="5dp"></ImageView>

                        <com.spiceladdoo.views.LatoRegularTextView
                            android:id="@+id/dealNameTextView"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:padding="4dp"
                            android:text=""
                            android:textColor="@color/text_color"
                            android:textSize="18sp" />

                        <com.spiceladdoo.views.LatoRegularTextView
                            android:id="@+id/offerTitleTextView"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:padding="4dp"
                            android:text="deal titile"
                            android:textColor="@color/lower_text_color"
                            android:textSize="18sp"
                            android:visibility="gone" />

                        <com.spiceladdoo.views.LatoRegularTextView
                            android:id="@+id/offerTypeTextView"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="10dp"
                            android:layout_marginRight="10dp"
                            android:ellipsize="end"
                            android:gravity="center"
                            android:maxLines="2"
                            android:text=""
                            android:textColor="@color/lower_text_color"
                            android:textSize="14sp" />
                    </LinearLayout>

                    <FrameLayout
                        android:id="@+id/frameLayoutAmount"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"
                        android:layout_alignParentTop="true"
                        android:layout_marginTop="20dp"
                        android:clickable="true"
                        android:focusable="true"
                        android:gravity="right">

                        <ImageView
                            android:id="@+id/iv_rupee_bg"
                            android:layout_width="70dp"
                            android:layout_height="30dp"
                            android:layout_marginRight="-15dp"
                            android:background="@drawable/deals_image_background" />

                        <com.spiceladdoo.views.LatoRegularTextView
                            android:id="@+id/tv_amount"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"
                            android:gravity="center"
                            android:paddingLeft="4dp"
                            android:textAppearance="?android:attr/textAppearanceMedium"
                            android:textColor="#ffffff"
                            android:textSize="17sp" />
                    </FrameLayout>
                </RelativeLayout>
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:id="@+id/cardview_descImage"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/card_offer"
                android:layout_marginTop="10dp"
                android:paddingBottom="5dp"
                android:paddingTop="5dp">

                <ImageView
                    android:id="@+id/dealDescriptionImageView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:adjustViewBounds="true"
                    android:src="@null"
                    android:visibility="visible" />
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:id="@+id/cardview_shortDesc"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@id/cardview_descImage"
                android:layout_marginTop="10dp"
                android:padding="5dp">

                <WebView
                    android:id="@+id/shortDescWebView"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:visibility="visible" />
            </android.support.v7.widget.CardView>

            <com.spiceladdoo.views.LatoBoldTextView
                android:id="@+id/related_offer_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/cardview_shortDesc"
                android:layout_gravity="center"
                android:layout_marginRight="10dp"

                android:text="SIMILAR OFFERS"
                android:textColor="@color/text_color"
                android:textSize="13sp" />

            <android.support.v7.widget.RecyclerView
                android:id="@+id/recyclerViewoffers"
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:layout_below="@id/related_offer_text"
                android:layout_marginTop="10dp"
                android:scrollbars="none" />

            <ProgressBar
                android:id="@+id/shortDescriptionProgress"
                style="?android:attr/android:progressBarStyle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:visibility="visible" />

        </RelativeLayout>
    </ScrollView>

    <com.spiceladdoo.views.LatoRegularTextView
        android:id="@+id/installTextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerInParent="true"
        android:layout_marginTop="5dp"
        android:background="@color/newFreeBColor"
        android:gravity="center"
        android:paddingBottom="15dp"
        android:paddingTop="15dp"
        android:text="INSTALL"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textColor="#FFFFFF"
        android:textSize="16sp"
        android:textStyle="bold"
        android:visibility="visible" />

    <FrameLayout
        android:id="@+id/hint"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_above="@+id/layoutInstallHint"
                android:background="#99000000"></RelativeLayout>

            <RelativeLayout
                android:id="@+id/layoutInstallHint"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_centerInParent="true"
                android:background="#99000000">

                <com.spiceladdoo.views.LatoRegularTextView
                    android:id="@+id/installTextHint"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:layout_marginBottom="15dp"
                    android:layout_marginTop="5dp"
                    android:background="@color/spice_laddooblue"
                    android:paddingBottom="10dp"
                    android:paddingLeft="80dp"
                    android:paddingRight="80dp"
                    android:paddingTop="10dp"
                    android:text="INSTALL"
                    android:textAppearance="?android:attr/textAppearanceSmall"
                    android:textColor="#FFFFFF"
                    android:textSize="15sp"
                    android:textStyle="bold"
                    android:visibility="visible" />
            </RelativeLayout>

            <com.spiceladdoo.views.LatoRegularTextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
               android:layout_above="@+id/imageViewHintPinIcon"
                android:layout_centerHorizontal="true"
                android:text="Click on Button"
                android:textColor="@color/white"
                android:textSize="18sp" />

            <ImageView
                android:id="@+id/imageViewHintPinIcon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="50dp"
                android:src="@drawable/hint_pin_down" />
        </RelativeLayout>
    </FrameLayout>

</RelativeLayout>

or if this not work then you can put scrollview inside cardview and then webview in card view


text:
Q: Custom Font Won't Work I want to have a custom font (HP Simplified Light) for my webpage. I have the font file uploaded to Dropbox, and I have the link here.
But nothing happens. I get Times New Roman as the font. I've tried testing locally, both hosting the font locally, and the HTML document, but with the  same effect.

 Hello world!

A: Your CSS is only styling h1 elements with the font HP Simplified. The text "Hello world!" is not a h1. Either you can make it so:

Hello world!

Or you can have the CSS style everything with the font:
* {
    font-family: HP Simplified
}

A: This is the error I get in chrome:

Redirect at origin 'http://dl.dropboxusercontent.com' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'Null' is therefore not allowed access.

Download the file and host it locally. Also be sure to put the  tags around your text and include a ; at the end of your font-family css. I did all that and it works. Example: http://catsarecrits.com/test.html

A: When I checked your font, it looks like an ordinary font and not a webfont. Correct me if I am wrong.
The othher possible reason is that Drop box have blocked your font file from being accessed on random location.
I have uploaded your font and converted it to different webfont formats.
test link
http://files.coderinthebox.com/webfont/
zip files
http://files.coderinthebox.com/webfont/webfontkit-20150531-215129.zip

redpajama_set_name: RedPajamaStackExchange


text:
Q: Searching a name in a text file by ID I have a text file with 2 lines in it:
Voicu;Catalin;1234;2.32
Diana;Cadar;2345;1.01
I'm trying to make my program search in .txt file the ID (1234 or 2345) and match it to the name. Below is the code I've tried to make, but it won't find the ID in .txt after I write it in first scanf, the first thing that appears is the "else" line.
    void alegereStudent(struct student *stud)
{

    FILE *scStudenti = fopen("studenti.txt", "a");
    char *error;
    int i=0,n;
    if(scStudenti==NULL)
    {
            error = strerror(errno);
            printf("Fisierul nu poate fi creat: \n %s", error);
    }

    printf("\nIntroduceti Numele: ");
    scanf("%39s", stud->numeStudent);

    printf("Introduceti Prenumele: ");
    scanf("%39s", stud->prenumeStudent);

    printf("Introduceti ID-ul studentului: ");
    scanf("%d", &stud->idStudent);

    printf("Introduceti Media de admitere: ");
    scanf("%f", &stud->medieAdmitere);

    fprintf(scStudenti,"<%s>;", stud->numeStudent);
    fprintf(scStudenti,"<%s>;", stud->prenumeStudent);
    fprintf(scStudenti,"<%d>;", stud->idStudent);
    fprintf(scStudenti,"<%.2f>\n", stud->medieAdmitere);
    fclose(scStudenti);

}

//

 void optiunea_2()
{
    printf("\n1.Despre studenti.\n");
    printf("2.Despre profesori.\n");
    printf("3.Revenire la meniu principal.\n");
    printf("\nAlegeti o optiune: ");
    scanf("%d",&alegere_opt2);

    switch(alegere_opt2)
    {
        case 1: while(&stud!=NULL)

        {

            FILE *scStudenti = fopen("studenti.txt", "r");
            char *error;
            int cautareID;

                if(scStudenti==NULL)
                {
                    error = strerror(errno);
                    printf("Fisierul nu poate fi creat: \n %s", error);
                }

            printf("\nIntroduceti ID-ul studentului: ");
            scanf("%d", &cautareID);
            fscanf(scStudenti,"%d",&stud->idStudent);
            if(cautareID==&stud->idStudent)
            {
            printf("Numele Studentului este %s %s",&stud->numeStudent, &stud->prenumeStudent);
            }
            else
                printf("\nAcest ID nu exista!\n");
                optiunea_2();

        }break;

A: #include <stdlib.h>
#include <stdio.h>

int main(void)
{
    char const *filename = "test.txt";
    FILE *input = fopen(filename, "r");
    if (!input) {
        fprintf(stderr, "Couldn't open \"%s\" for reading!\n\n", filename);
        return EXIT_FAILURE;
    }

    char name[101];
    char surname[101];
    int id;
    double value;
    while (fscanf(input, "%100[^;];%100[^;];%d;%lf%*[\n]", name, surname, &id, &value) == 4) {
        if (id == 2345) {
            printf("Found \"%s %s\" by id %d\n\n", name, surname, id);
            break;
        }
    }
}

A:
fprintf(scStudenti,"<%s>;", stud->numeStudent);
fprintf(scStudenti,"<%s>;", stud->prenumeStudent);
fprintf(scStudenti,"<%d>;", stud->idStudent);
fprintf(scStudenti,"<%.2f>\n", stud->medieAdmitere);
fclose(scStudenti);

This makes formatting much more difficult. The output file will contain:
<first>;<last>;<1234>;<0.5>

You want to start with a new file and simplify the output to write:
first;last;1234;0.5

Don't always put & in front of integer. Just use:
if(cautareID == stud->idStudent)
{
...
}

Example:
const char *filename = "studenti.txt";

void alegereStudent()
{
    struct student stud;
    FILE *scStudenti = fopen(filename, "a");
    if(scStudenti == NULL)
    {
        printf("error\n");
        return;
    }

    printf("\nIntroduceti Numele: ");
    scanf("%39s", stud.numeStudent);

    printf("Introduceti Prenumele: ");
    scanf("%39s", stud.prenumeStudent);

    printf("Introduceti ID-ul studentului: ");
    scanf("%d", &stud.idStudent);

    printf("Introduceti Media de admitere: ");
    scanf("%f", &stud.medieAdmitere);

    fprintf(scStudenti, "%s;", stud.numeStudent);
    fprintf(scStudenti, "%s;", stud.prenumeStudent);
    fprintf(scStudenti, "%d;", stud.idStudent);
    fprintf(scStudenti, "%.2f\n", stud.medieAdmitere);
    fclose(scStudenti);
}

void find_by_id(int id)
{
    FILE *fin = fopen(filename, "r");
    if(!fin)
        return;

    int count = 0;
    struct student stud;
    while(fscanf(fin, "%39[^;];%39[^;];%d;%f\n",
        stud.numeStudent, stud.prenumeStudent, &stud.idStudent, &stud.medieAdmitere) == 4)
    {
        if(id == stud.idStudent)
        {
            printf("found %s %s\n", stud.numeStudent, stud.prenumeStudent);
        }
        count++;
    }

    if(count == 0)
        printf("failed to read any record. Start with a new file.\n");
}

int main(void)
{
    alegereStudent();
    find_by_id(1234);
    return 0;
}

If <> characters are added, then read according to that format, you then have to remove the extra <> characters from the string.
void alegereStudent()
{
    struct student stud;
    ...
    fprintf(scStudenti, "<%s>;", stud.numeStudent);
    fprintf(scStudenti, "<%s>;", stud.prenumeStudent);
    fprintf(scStudenti, "<%d>;", stud.idStudent);
    fprintf(scStudenti, "<%.2f>\n", stud.medieAdmitere);
    fclose(scStudenti);
}

void find_by_id(int id)
{
    ...
    struct student stud;
    while(fscanf(fin, "%39[^;];%39[^;];<%d>;<%f>\n",
        stud.numeStudent, stud.prenumeStudent, &stud.idStudent, &stud.medieAdmitere) == 4)
    {
        if(id == stud.idStudent)
        {
            char *p;
            size_t i;

            //remove the extra <> characters
            p = stud.numeStudent;
            if (strlen(p) > 1)
            {
                for(i = 1; i < strlen(p) - 1; i++)
                    p[i - 1] = p[i];
                p[i - 1] = 0;
            }

            //remove the extra <> characters
            p = stud.prenumeStudent;
            if (strlen(p) > 1)
            {
                for(i = 1; i < strlen(p) - 1; i++)
                    p[i - 1] = p[i];
                p[i - 1] = 0;
            }

            printf("found %s %s\n", stud.numeStudent, stud.prenumeStudent);
        }
        count++;
    }

    if(count == 0)
        printf("failed to read any record. Start with a new file.\n");
}


text:
Q: Order by alphabet letters A-L and M-Z using lambda Good day,
In my sample scenario, I'm trying to fetching all users from my database and put then on my dto where it has lists of ordering by alphabet letters given the following: A-L, M-Z
Here's my sample code with common OrderBy by the user name:
var users = await users.Users().ToListAsync();

return users.Select(u=>new CategorizedByLetterUserDto{
    ...
}).OrderBy(u=>u.Name);

So my sample CategorizedByLetterUserDto looks like this.
public class CategorizedByLetterUserDto {
     public IEnumerable<AtoL> AtoL {get;set}
     public IEnumerable<MtoZ> MtoZ {get;set;}
     ...
}

public class AtoL{
     public int Id {get;set;}
     public string Name {get;set;}
}

public class MtoZ{
     public int Id {get;set;}
     public string Name {get;set;}
}

so on and so forth...

So the result will be (array)
 {
     categorizedByLetterUserDto: {
         atoL: [
         {
           ...
         }
         ],
         mtoZ: [
         {
           ...
         }
         ]
     }
 }

A: Use GroupBy, something like this:
 var grouped = users.GroupBy(u => u.Name.CompareTo("M") < 0).OrderBy(g => g.Key).ToArray();
 return new CategorizedByLetterUserDto
 {
    AtoL = grouped[1].Select(x => new UserDto { Id = x.Id, Name = x.Name }),
    MtoZ = grouped[0].Select(x => new UserDto { Id = x.Id, Name = x.Name }),
 };

And don't create identical classes, use:
public class UserDto
{
    public int Id {get;set;}
    public string Name {get;set;}
}

You could use ToLookup instead and in this case it would be equivalent but see https://stackoverflow.com/a/10215531/224370 for details as to when it's not.
And if you wanted to split on more than one split point you could do something like:
string splits = "EMT";
var grouped = users.GroupBy(u => splits.Count(c => u.Name[0] > c))
                     .OrderBy(g => g.Key).ToArray(); ...

Note: Purists would prefer a sorted list of split characters and a binary search method to find the index, but for most practical smaller sets of split characters this will be faster and it's less code and it doesn't care what order the splits points are specified in.

A: Better use the List<> Class instead of IEnumerable<> in your CategorizedByLetterUserDto class to access the .Add method.. Then try the ff code.
var users = await users.Users().ToListAsync();
char[] listOfAtoL = "ABCDEFGHIJKL".toCharArray();
CategorizedByLetterUserDto cat = new CategorizedByLetterUserDto();

foreach (User u in users.OrderBy(a => a.Name)) {
    listOfAtoL.Contains(char.ToUpper(u.Name.toCharArray()[0])) ? cat.AtoL.Add(new AtoL() {id = u.ID, Name = u.Name}) : cat.MtoZ.Add(new MtoZ() {id = u.ID, Name = u.Name});
}

return cat;

A: I don't think you need to get that involved, you can just use LINQs existing functionality tocreate lookups
List<User> list = ... .OrderBy(u=>u.Name); //from db

ILookup<int, User> lookup = list.ToLookup(
  u => (u.Name[0] - 63)/14,
  u => new Dto { Id = u.Id, Name = u.Name }
);

The numbers relate to treating a char as an int in the ascii table, A being 65. By subtracting 63, A becomes 2, L becomes 13, Z becomes 27. By then dividing by 14 we reduce this to 0 or 1. Your lookup will now be an enumerable of users indexed by either 0 or 1, the 0 being AtoL. If you want the users in a given list sorted you can call OrderBy on them. I did this with math rather than a bool compare so you can alter it to more columns in future just by altering the numbers, but you can use bool also:
var lookup = list.ToLookup(
  u => u.Name[0]<'M',
  u => new Dto { Id = u.Id, Name = u.Name }
);

In this the lookup returned, indexed by true would be A to L
Assign to your categorized Dto:
var x = new CatDto(){
  aToL=lookup[true],
  mToZ=lookup[false]
};

Note that this, in combination with every other answer here, relies on your names being properly formatted with an uppercase ASCII character as the first char.. If your names are messy, or don't always start thus, you should consider doing things like uppercasing them before compare etc


text:
Q: Where are all the `alternatives` stored? As far as I understand, /etc/alternatives stores only currently selected alternatives. Where are all the variants and all the metadata stored? I have accidentally removed an alternative with galternatives and want to add it back as it was manually (as galternatives functionality is very limited).

A: This data seems to be in /var/lib/dpkg/alternatives, also check man update-alternatives for more information.

A: The command-line update-alternatives tool should help you here.
This command should take you through all alternatives one at a time:
update-alternatives --all
There are some more examples at this wiki page which can show you all manually-set alternatives and even (use with caution!) reset all those to their defaults.
A more detailed description of how the alternatives system works, including where it stores all its configuration, is available in the update-alternatives manpage (note that this version for Debian and Ubuntu contains more functionality than the update-alternatives from redhat).


text:
Q: Prüfer domains: searching for an intuitive approach Prüfer domains are domains in which every finitely generated ideal is invertible. There are many definitions, like all localizations in prime ideals of a Prüfer domain is a valuation domain. But I'm searching for a more intuitive explanation for these domains in order to understand their structure better.

A: I like to think of them as non-Noetherian Dedekind domains.  A lot of the properties that hold for the category of modules over a Dedekind domains hold for the category of finitely generated modules over a Prüfer domain.
Lattice theoretically, they are integral domains whose lattice of ideals is distributive.
Homologically, all their finitely generated ideals are projective.
Kaplansky also characterized Prüfer domains as the domains in which the torsion submodule of every finitely generated module splits out.
Perhaps you should just go chase the extensive lists of equivalent conditions. Equivalences do more than anything to teach you what a particular condition is like, and Prüfer domains have a TON of characterizations.


text:
Q: Find minimum of nonlinear system of equations with nonlinear equality and inequality constraints in MATLAB I need to solve this problem better described at the title. The idea is that I have two nonlinear equations in four variables, together with two nonlinear inequality constraints. I have discovered that the function fmincon is probably the best approach, as you can set everything I require in this situation (please let me know otherwise). However, I'm having some doubts at the implementation stage. Below I'm exposing the complete case, I think it's simple enough to be in its real form.
The first thing I did was to define the objective function in a separate file.
function fcns=eqns(x,phi_b,theta_b,l_1,l_2)

fcns=[sin(theta_b)*(x(1)*x(4)-x(2)*x(3))+x(4)*sqrt(x(1)^2+x(2)^2-l_2^2)-x(2)*sqrt(x(3)^2+x(4)^2-l_1^2);
      cos(theta_b)*sin(phi_b)*(x(1)*x(4)-x(2)*x(3))+x(3)*sqrt(x(1)^2+x(2)^2-l_2^2)-x(1)*sqrt(x(3)^2+x(4)^2-l_1^2)];

Then the inequality constraints, also in another file.
function [c,ceq]=nlinconst(x,phi_b,theta_b,l_1,l_2)

c=[-x(1)^2-x(2)^2+l_2^2; -x(3)^2-x(4)^2+l_1^2];
ceq=[];

The next step was to actually run it in a script. Below, since the objective function requires extra variables, I defined an anonymous function f. In the next line, I did the same for the constraint (anonymous function). After that, it's pretty self explanatory.
f=@(x)norm(eqns(x,phi_b,theta_b,l_1,l_2));
f_c=@(x)nlinconst(x,phi_b,theta_b,l_1,l_2);

x_0=[15 14 16 18],
LB=0.5*[l_2 l_2 l_1 l_1];
UB=1.5*[l_2 l_2 l_1 l_1];

[res,fval]=fmincon(f,x_0,[],[],[],[],LB,UB,f_c),

The first thing to notice is that I had to transform my original objective function by the use of norm, otherwise I'd get a "User supplied objective function must return a scalar value." error message. So, is this the best approach or is there a better way to go around this?
This actually works, but according to my research (one question from stackoverflow actually!) you can guide the optimization procedure if you define an equality constraint from the objective function, which makes sense. I did that through the following code at the constraint file:
ceq=eqns(x,phi_b,theta_b,l_1,l_2);

After that, I found out I could use the deal function and define the constraints within the script.
c=@(x)[-x(1)^2-x(2)^2+l_2^2; -x(3)^2-x(4)^2+l_1^2];
f_c=@(x)deal(c(x),f(x));

So, which is the best method to do it? Through the constraint file or with this function?
Additionally, I found in MATLAB's documentation that it is suggested in these cases to set:
f=@(x)0;

Since the original objective function is already at the equality constraints. However, the optimization doesn't go beyond the initial guess obviously (the cost value is already 0 for every solution), which makes sense but leaves me wondering why is it suggested at the documentation (last section here: http://www.mathworks.com/help/optim/ug/nonlinear-systems-with-constraints.html).
Any input will be valued, and sorry for the long text, I like to go into detail if you didn't pick up on it yet... Thank you!

A: I believe fmincon is well suited for your problem. Naturally, as with most minimization problems, the objective function is a multivariate scalar function. Since you are dealing with a vector function, fmincon complained about that.
Is using the norm the "best" approach? The short answer is: it depends. The reason I say this is norm in MATLAB is, by default, the Euclidean (or L2) norm and is the most natural choice for most problems. Sometimes however, it may be easier to solve a problem (or more physically meaningful) to use an L1 or a more stringent infinity-norm. I defer a thorough discussion of norms to the following superb blog post: https://rorasa.wordpress.com/2012/05/13/l0-norm-l1-norm-l2-norm-l-infinity-norm/
As for why the example on Mathworks is formulated the way it is: they are solving a system of nonlinear equations - not minimizing a function. They first use the standard approach, using fsolve, but then they propose alternate methods of solving the same problem.
One such way is to reformulate solving the nonlinear equations as a minimization problem with an equality constraint. By using f=@(x)0 with fmincon, the objective function f is naturally already minimized, and the only thing that has to be satisfied in this case is the equality constraint - which would be the solution to the system of nonlinear equations. Clever indeed.


text:
Q: Android SQLiteDatabase table does not exists I am having a class named GameDb and it's extending SQLiteOpenHelper. I don't know why, but onCreate it's not called, the table is not created !
Having a singelton for all my activities and fragments:
public MyApp extends Application
{
   // .... Code

   private GameDb gameDb;

   public GameDb getGameDb()
   {
      if (gameDb == null)
         gameDb = new GameDb(this);

      return this.gameDb;
   }
}

Getting all games from database, calling from an activity
public class MyActivity extends FragmentActivity
{
   @Override
   protected void onCreate(Bundle bundle)
   {
      // Code....

      // Get all games
      ArrayList<Game> allGames = getMyApp().getGameDb().getAllGames();
   }
}

Class which contains all necessary methods for querying the database (writing and reading). This methods are not written below because it's not necessary.
public class GameDb
{
   private SQLiteDatabase db;
   private GameDbHelper dbHelper;

   public GameDb(Context context)
   {
      this.dbHelper = new GameDbHelper(context);
      this.db = dbHelper.getWritableDatabase();
   }

   public ArrayList<Games> getAllGames()
   {
       // return db.query(....);
   }

   public void insertNewGame(int id, String name)
   {
      // db.query(....);
   }

   // Static inner class which extends SQLiteOpenHelper
   private static class GameDbHelper extends SQLiteOpenHelper
   {
      public GameDbHelper(Context context)
      {
         super(context, "DB_NAME", null, 1);
      }

      // On create not called !
      @Override
      public void onCreate(SQLiteDatabase db)
      {
         db.execSQL("CREATE TABLE my_table(_id INTEGER AUTOINCREMENT, date TEXT);");
      }

      @Override
      public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
      {
         dropTable(db);
         onCreate(db);
      }

      public void dropTable(SQLiteDatabase db)
      {
         db.execSQL("DROP TABLE IF EXISTS my_table");
      }
   }
}

When I'm trying to get all games, or add a new game I'm getting a FATAL EXCEPTION, (1) no such table: my_table

A: You may have a old database present on your device and database doesn't always get deleted when you reinstall the app using IDE. Thus you must uninstall the app manually and the reinstall your app using IDE.

A: I don't believe onCreate() gets implicitly called when you instantiate your database object.  You need to explicitly call your Activity's openOrCreateDatabase() method.


text:
Q: Using RDFLIB to fetch elements for every class I have an OWL RDF data file that contains several data such as the following example:
<!-- http://purl.obolibrary.org/obo/OGMS_0000014 -->

    <owl:Class rdf:about="http://purl.obolibrary.org/obo/OGMS_0000014">
        <rdfs:subClassOf rdf:resource="http://purl.obolibrary.org/obo/OGMS_0000123"/>
        <obo:IAO_0000115 xml:lang="en">A representation that is either the output of a clinical history taking or a physical examination or an image finding, or some combination thereof.</obo:IAO_0000115>
        <obo:IAO_0000117>Albert Goldfain</obo:IAO_0000117>
        <obo:IAO_0000119>http://ontology.buffalo.edu/medo/Disease_and_Diagnosis.pdf</obo:IAO_0000119>
        <obo:IAO_0000232>creation date: 2010-07-19T10:18:02Z</obo:IAO_0000232>
        <rdfs:label>clinical finding</rdfs:label>
    </owl:Class>

and need to extract only the strings following the rdfs:label and the <obo:IAO_0000115 xml:lang="en"> tags for each class.
I am successfully reading the RDF file as follows:
from rdflib import Graph, URIRef
g = Graph()
g.parse("ogms_20210819.owl")

and then loop through it as usual:
# Loop through each triple in the graph (subj, pred, obj)
for subj, pred, obj in g:
    print(subj, pred, obj)

but I'm not understanding how to fetch only the text from the two tags I need for each class.
Thanks a lot for any help.


text:
Q: Why is `async` not a a reserved word? As far as I can tell, both the spec and the documentation have await as the only reserved keyword out of the async/await feature.
This is further demonstrated by the fact that we can name a variable async:
For example:

var async = 5;
console.log(async) // this is fine

Node (6.10) (also on Repl.it)

Chrome (59)

Firefox (54)

Is it because of backwards compatibility? I'd guess many codebases would use the name async for certain features.
This allows for some strange looking code examples:

async function async() {
  var async = 5;
  await async;
  return async;
}
async().then(console.log)

Infinite recursive promise chain? (Not really important since any function name would allow this, however this code looks additionally confusing)

async function async() {
  await async();
}
// stackoverflow (might need to open your console to see the output)

A: async does not need to be a reserved word, because it can be uniquely identified. The contexts in which it can occur are those such as
async function() { }
async () => { }
obj = { async foo() { } };

All of these could not be parsed in any way other than seeing async as indicating an async function.
On the other hand, await can in theory be used in a statement such as
async function foo() {
  await(1);
}

which is ambiguous; is await awaiting the value 1, or is it a function being called with the parameter 1? Therefore, await needs to be a reserved word (inside async functions; outside, feel free to use it as a variable).
Remember that JavaScript has evolved greatly since its origin. Many words were designated as reserved, and then never used, or designated as reserved when technically they might not need to have been. The designation of await as a reserved word (within modules), and the non-designation of async as a reserved word, are the product of a more mature understanding of the language on the part of its designers.


text:
Q: How to show an exception message if the user doesn't check a radio button in Xamarin Android? Hi I need to display a error message on the screen if the user doesn't check a radio button. In this code there are 13 radio buttons separeted on 4 radio groups.
I tried to use try/catch and if/else but the screen stills not showing the Toast error message.
Another doubt: I know that radio groups doesn't allow a person to choose more than 1 option, but how can I do an excepeiton that allows the user just to pick 1 button of one single radio group? For example: now I have to choose at least 4 buttons (1 of each radio group) but I want to do it in a way that just one of any group will be good enough
Here is the code
    using Android.App;
using Android.Content.PM;
using Android.Content.Res;
using Android.OS;
using Android.Support.V4.Widget;
using Android.Views;
using Android.Widget;
using System.Collections;
using Android.Support.V7.App;
using Android.Support.V4.View;
using Android.Support.Design.Widget;
using Auth0.OidcClient;
using Android.Content;
using IdentityModel.OidcClient;
using Android.Graphics;
using System.Net;
using System;
using Android.Runtime;
using Android.Text.Method;
using System.Text;
namespace whirlpoolapp
{
    [Activity(Label = "whirlpoolapp", MainLauncher = true)]
    [IntentFilter(
    new[] { Intent.ActionView },
    Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
    DataScheme = "whirlpoolapp.whirlpoolapp",
    DataHost = "lucasmoreira.auth0.com",
    DataPathPrefix = "/android/whirlpoolapp.whirlpoolapp/callback")]
    public class MainActivity : Activity
    {
        private ArrayList enderecos;
        TextView queroreconhecer;
        TextView crie;
        TextView conquiste;
        TextView entregue;
        TextView viva;
        TextView comentar;
        EditText comentário;
        Spinner spinner;
        ArrayAdapter adapter;
        RadioGroup rdgcrie;
        RadioGroup rdgconquiste;
        RadioGroup rdgentregue;
        RadioGroup rdgviva;
        Button enviar;
        private Auth0Client client;
        private AuthorizeState authorizeState;
        ProgressDialog progress;

        protected override void OnResume()
        {
            base.OnResume();

            if (progress != null)
            {
                progress.Dismiss();

                progress.Dispose();
                progress = null;
            }
        }

        protected override async void OnNewIntent(Intent intent)
        {
            base.OnNewIntent(intent);

            var loginResult = await client.ProcessResponseAsync(intent.DataString, authorizeState);

            var sb = new StringBuilder();
            if (loginResult.IsError)
            {
                sb.AppendLine($"An error occurred during login: {loginResult.Error}");
            }
            else
            {
                sb.AppendLine($"ID Token: {loginResult.IdentityToken}");
                sb.AppendLine($"Access Token: {loginResult.AccessToken}");
                sb.AppendLine($"Refresh Token: {loginResult.RefreshToken}");

                sb.AppendLine();

                sb.AppendLine("-- Claims --");
                foreach (var claim in loginResult.User.Claims)
                {
                    sb.AppendLine($"{claim.Type} = {claim.Value}");
                }
            }

        }

        private async void LoginButtonOnClick(object sender, EventArgs eventArgs)
        {

            progress = new ProgressDialog(this);
            progress.SetTitle("Log In");
            progress.SetMessage("Please wait while redirecting to login screen...");
            progress.SetCancelable(false); // disable dismiss by tapping outside of the dialog
            progress.Show();

            // Prepare for the login
            authorizeState = await client.PrepareLoginAsync();

            // Send the user off to the authorization endpoint
            var uri = Android.Net.Uri.Parse(authorizeState.StartUrl);
            var intent = new Intent(Intent.ActionView, uri);
            intent.AddFlags(ActivityFlags.NoHistory);
            StartActivity(intent);
        }

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);
            client = new Auth0Client(new Auth0ClientOptions
            {
                Domain = Resources.GetString(Resource.String.auth0_domain),
                ClientId = Resources.GetString(Resource.String.auth0_client_id),
                Activity = this
            });
            //preenche o arraylist com os dados
            GetEmails();
            //cria a instância do spinner declarado no arquivo Main
            spinner = FindViewById<Spinner>(Resource.Id.spnDados);
            //cria textview
            queroreconhecer = FindViewById<TextView>(Resource.Id.txtReconhecer);
            crie = FindViewById<TextView>(Resource.Id.txtCrie);
            conquiste = FindViewById<TextView>(Resource.Id.txtConquiste);
            entregue = FindViewById<TextView>(Resource.Id.txtEntregue);
            viva = FindViewById<TextView>(Resource.Id.txtViva);
            comentar = FindViewById<TextView>(Resource.Id.txtComentário);
            comentário = FindViewById<EditText>(Resource.Id.edtComentario);
            rdgcrie = FindViewById<RadioGroup>(Resource.Id.rdgCrie);
            rdgconquiste = FindViewById<RadioGroup>(Resource.Id.rdgConquiste);
            rdgentregue = FindViewById<RadioGroup>(Resource.Id.rdgEntregue);
            rdgviva = FindViewById<RadioGroup>(Resource.Id.rdgViva);
            adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, enderecos);
            spinner.Adapter = adapter;
            spinner.ItemSelected += Spinner_ItemSelected;
            enviar = FindViewById<Button>(Resource.Id.button1);
            enviar.Click += enviar_Click;
            void GetEmails()
            {
                enderecos = new ArrayList();
                enderecos.Add("Escolha um colaborador abaixo");
                enderecos.Add("alexandre_bonfim@whirlpool.com");
                enderecos.Add("alexandre_t_pires@whirlpool.com");
                enderecos.Add("ana_carolina_simoes @whirlpool.com");
                enderecos.Add("ana_claudia_s_belarmino@whirlpool.com");
                enderecos.Add("andre_costa@whirlpool.com");
                enderecos.Add("andre_l_teixeira@whirlpool.com");
                enderecos.Add("andreza_a_valle@whirlpool.com");
                enderecos.Add("anna_carolina_b_ferreira@whirlpool.com");
                enderecos.Add("bruno_b_souza@whirlpool.com");
                enderecos.Add("bruno_c_castanho@whirlpool.com");
                enderecos.Add("bruno_s_lombardero@whirlpool.com");
                enderecos.Add("caio_c_sacoman@whirlpool.com");
                enderecos.Add("carla_sedin@whirlpool.com");
                enderecos.Add("cassia_r_nascimento@whirlpool.com");
                enderecos.Add("celia_r_araujo@whirlpool.com");
                enderecos.Add("cesar_leandro_de_oliveira@whirlpool.com");
                enderecos.Add("daniel_b_szortyka@whirlpool.com");
                enderecos.Add("denis_caciatori@whirlpool.com");
                enderecos.Add("elisabete_c_ferreira@whirlpool.com");
                enderecos.Add("erick_c_senzaki@whirlpool.com");
                enderecos.Add("erika_g_souza@whirlpool.com");
                enderecos.Add("fabiana_monteiro@whirlpool.com");
                enderecos.Add("fernando_v_santos@whirlpool.com");
                enderecos.Add("gabriel_roveda@whirlpool.com");
                enderecos.Add("herivelto_alves_jr@whirlpool.com");
                enderecos.Add("jefferson_s_pecanha@whirlpool.com");
                enderecos.Add("josiane_a_teles@whirlpool.com");
                enderecos.Add("juliana_g_saito@whirlpool.com");
                enderecos.Add("juliano_ventola@whirlpool.com");
                enderecos.Add("leonardo_l_costa@whirlpool.com");
                enderecos.Add("leonardo_r_silva@whirlpool.com");
                enderecos.Add("lucas_m_santos@whirlpool.com");
                enderecos.Add("luiz_perea@whirlpool.com");
                enderecos.Add("norma_raphaeli@whirlpool.com");
                enderecos.Add("patricia_f_prates@whirlpool.com");
                enderecos.Add("priscila_l_dattilo@whirlpool.com");
                enderecos.Add("priscila_m_konte@whirlpool.com");
                enderecos.Add("reider_a_bernucio@whirlpool.com");
                enderecos.Add("renato_occhiuto@whirlpool.com");
                enderecos.Add("ricardo_a_fernandes@whirlpool.com");
                enderecos.Add("ricardo_matos_campaneruti @whirlpool.com");
                enderecos.Add("rogerio_pagotto@whirlpool.com");
                enderecos.Add("ruben_c_anacleto@whirlpool.com");
                enderecos.Add("taise_azevedo@whirlpool.com");
                enderecos.Add("vinicius_marques_assis@whirlpool.com");
                enderecos.Add("wanderly_t_limeira@whirlpool.com");
            }// fim getEmails

            void Spinner_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
            {
                Spinner spinner = (Spinner)sender;
                string toast = string.Format("Colaborador selecionado: {0}", spinner.GetItemAtPosition(e.Position));
                Toast.MakeText(this, toast, ToastLength.Long).Show();
                string texto = toast;

            }

        }
        void enviar_Click(object sender, EventArgs e)
        {   try {
            RadioButton rdbgrupo1 = FindViewById<RadioButton>(rdgconquiste.CheckedRadioButtonId);
            RadioButton rdbgrupo2 = FindViewById<RadioButton>(rdgcrie.CheckedRadioButtonId);
            RadioButton rdbgrupo3 = FindViewById<RadioButton>(rdgviva.CheckedRadioButtonId);
            RadioButton rdbgrupo4 = FindViewById<RadioButton>(rdgentregue.CheckedRadioButtonId);
            if (rdbgrupo1.Selected == false || rdbgrupo2.Selected == false || rdbgrupo3.Selected == false || rdbgrupo4.Selected == false)
                {
                 string excecao = "Ao menos um botão de cada campo deve ser selecionado e o comentário deve ser preenchido";
                 Toast.MakeText(this, excecao, ToastLength.Long).Show();
                }
            else
                {
                    String emailescolhido = spinner.SelectedItem.ToString();
                    String campocomentario = comentário.Text;
                    string message = "Ao menos um botão de cada campo deve ser selecionado";
                    Toast.MakeText(ApplicationContext, message, ToastLength.Long).Show();
                    var email = new Intent(Android.Content.Intent.ActionSend);
                    //send to
                    email.PutExtra(Android.Content.Intent.ExtraEmail,
                    new string[] { "" + emailescolhido });
                    //cc to
                    email.PutExtra(Android.Content.Intent.ExtraCc,
                    new string[] { "comite_clima_ti@whirlpool.com" });
                    //subject
                    email.PutExtra(Android.Content.Intent.ExtraSubject, "SABIA QUE VOCÊ FOI RECONHECIDO?");
                    //content
                    email.PutExtra(Android.Content.Intent.ExtraText,
                    "Você foi reconhecido pelo(s) valor(es) de: " + rdbgrupo1.Text + " , " + rdbgrupo2.Text + " , " + rdbgrupo3.Text + " e " + rdbgrupo4.Text);
                    email.PutExtra(Android.Content.Intent.ExtraText, "" + campocomentario);
                    email.SetType("message/rfc822");
                    StartActivity(email);
                }

            }
            catch (Java.Lang.Exception ex)
            {
                string excecao = "Ao menos um botão de cada campo deve ser selecionado e o comentário deve ser preenchido";
                Toast.MakeText(this, excecao, ToastLength.Long).Show();

            }

        }

    }
}

A:
How to show an exception message if the user doesn't check a radio button in Xamarin Android?

You could use radioGroup.CheckedRadioButtonId to get the result whether a RadioGroup is check, upon empty selection, the returned value is -1.
public int RadioGroupIsChecked(RadioGroup radioGroup)
{
     //-1 means empty selection
     return radioGroup.CheckedRadioButtonId;
}

//When user doesn't check a radio button, show a Toast
if (RadioGroupIsChecked(group) == -1 || RadioGroupIsChecked(group2) == -1 || RadioGroupIsChecked(group3) == -1 || RadioGroupIsChecked(group4) == -1)
{
     string excecao = "Ao menos um botão de cada campo deve ser selecionado e o comentário deve ser preenchido";
     Toast.MakeText(this, excecao, ToastLength.Long).Show();
}


text:
Q: Ordenar un array de forma descendente en PHP Necesito mostrar eso por pantalla con un array con PHP, alguna sugerencia?
<?php
$number= array("1","2","3","4","5","6","7","8","9","10");
arsort($number);
for($x = 0; $x < count($number); $x++) {
    echo $number[$x];
    echo "
";
}
?>

A: Creo que la función que buscas se llama rsort que orderna los valores en sentido descendente, arsort ordena y mantiene los índices asignados
$a=array(1,2,3,4);
rsort($a);
print_r($a);

Para tu caso podrías hacer
$number= array("1","2","3","4","5","6","7","8","9","10");
rsort($number);
for($x = 0; $x < count($number); $x++) {
    echo ($x+1) ."°-".$number[$x];
    echo "
";
}

A: Efectivamente, la función que mejor haría lo que quieres sería rsort.
Según el Manual de PHP esta función:

*

*Ordena un array en orden inverso (mayor a menor)

Y hay otra cosa interesante que dice:

*

*Esta función asigna nuevas claves a los elemenos del array.

Visto esto, una vez ordenado el array de mayor a menor, puedes trabajar solamente con el array para presentar los datos también. Dado que la función asigna nuevas claves, puedes leer en un foreach cada clave/valor del array para presentar el valor y el orden en que ha quedado. Dado que las claves empiezan por 0, tendrías que sumar 1 a la clave en cada paso del bucle.
De este modo el código queda más limpio, y usas menos variables. Trabajarás únicamente con tu dato, por lo que ganarás en rendimiento.
Veamos:
▸ Código:
VER DEMO EN REXTESTER
$arrNumbers= array("1","2","9","4","8","10","7","5","3","6");
rsort($arrNumbers);

foreach ($arrNumbers as $k=>$v){
    print ($k+1)."°- ".$v.PHP_EOL;
}

▸ Resultado:
1°- 10
2°- 9
3°- 8
4°- 7
5°- 6
6°- 5
7°- 4
8°- 3
9°- 2
10°- 1

Nota adicional:
Dado que al parecer necesitarás hacer esta operación varias veces, puedes crear una función que haga el trabajo con sólo pasarle en parámetro el array.
La función sería más o menos así (la presento en una versión simple, sabiendo que se podría mejorar, haciendo que controle por ejemplo si el valor recibido es un array, etc):
function ordenDescendente($arrNumbers){
    rsort($arrNumbers);
    foreach ($arrNumbers as $k=>$v){
        print ($k+1)."°- ".$v.PHP_EOL;
    }
}

Y para usarla con varios arrays:
$arrNumbers= array("7","3","1","5");
ordenDescendente($arrNumbers);

Obtienes:
1°- 7
2°- 5
3°- 3
4°- 1

Uso con otro array distinto:
$arrNumbers= array("9","3","7","1","5");
ordenDescendente($arrNumbers);

Obtienes:
1°- 9
2°- 7
3°- 5
4°- 3
5°- 1

Este es el tipo de funciones cadidatas para una Clase utilitaria en cualquier aplicación.
Espero te sirva.


text:
Q: Why cant I pass parameter into an anonymous function inside addEventListener, how to fix it? I made a function name edit(index). index is the id number of  h1 tag elements. Whenever i click the edit button (which is has id index) then the input text appear for me to adding some text therefor i can submit another button.
function saveChange(index) {
    if(editName.value != "") {
        productList[index] = editName.value;
    }
    spoiler.style.display = 'none';
}

//and here i call the event
function edit(index) {
    spoiler.style.display = "block";
    document.getElementById('save').addEventListener('click',saveChange(index));
}

how can i pass the index parameter?

A: You need to use an anonymous function if you want to pass parameters in addEventListener. Use this code instead:
document.getElementById('save').addEventListener('click', () => saveChange(index));

This is because if you add the saveChange(index) into addEventListener by itself, it will actually execute the function rather than saving it for use in the event listener. This is the same reason you have to use function references/anonymous functions inside setInterval and setTimeout (see my answer for some more information on this).

A: You can call the function inside of an anonymous function.
Change
document.getElementById('save').addEventListener('click',saveChange(index));

To
document.getElementById('save').addEventListener('click', function(){saveChange(index)});

Demo:

function saveChange(index) {
  console.log("save: "+index);
  //if(editName.value != "") {
    //productList[index] = editName.value;
  //}
  //spoiler.style.display = 'none';
}

//and here i call the event
function edit(index) {
  //spoiler.style.display = "block";
  document.getElementById('save').addEventListener('click', function(){saveChange(index)});
}

edit(10)
<button type="button" id="save">Save</button>


text:
Q: c++ abstract class implementation in another base class Question
Why not to try virtual inheritance if it seems to solve my diamond inheritance problem below?
Briefing:
While learning C++, I came with some compiler errors for the following code:
#include <stdlib.h>
#include <iostream>

class IFoo{
    public:
    virtual void Hello() = 0;
};

class Foo : public IFoo{
    public:
    void Hello()
    {
        printf("Hello");
    }
};

class IBar : public IFoo{
    public:
    virtual void HelloWorld() = 0;
};

class Bar : public IBar, public Foo{
    public:
    void HelloWorld()
    {
        Hello();
        printf("World");
    }
};

int main()
{
    Bar b;
    b.HelloWorld();

    system("pause");
    return 0;
}

I want Bar to implement abstract class IBar which has IFoo as a base class but then I want all the implementation of IFoo provided by Bar's second base class Foo.
I get 2 compiler errors (GCC 4.9.2): One related to ambiguities and another one about missing implementations for abstract class IFoo.
Then I found this question and got to meet the concept of virtual inheritance, which lead me to this page. Following the tutorial, I added virtual inheritance and all problems were gone:
class Foo : public virtual IFoo{...
class IBar : public virtual IFoo{...

But a user in the question suggest not to try virtual inheritance. Hence my question.

A: Your Hello() call in Bar::HelloWorld() is ambiguous. The compiler can't tell if you are trying to call Hello() from IBar or Foo.  You can call Foo::Hello() or IBar::Hello() in it's place.  That being said, your inheritance structure doesn't really make sense.
Your Bar class also needs to override Hello that it inherits from IBar.
If you have c++11, it would be a good idea to mark the virtual functions you are overriding with the override keyword:
#include <stdlib.h>
#include <iostream>

class IFoo{
    public:
    virtual void Hello() = 0;
};

class Foo : public IFoo{
    public:
    virtual void Hello() override
    {
        printf("Hello");
    }
};

class IBar : public IFoo{
    public:
    virtual void HelloWorld() = 0;
};

class Bar : public IBar, public Foo{
    public:
    virtual void HelloWorld() override
    {
        Foo::Hello();
        printf("World");
    }

     void Hello() override {}
};

int main()
{
    Bar b;
    b.HelloWorld();

    system("pause");
    return 0;
}

To answer your question on virtual inheritance, you could easily change your inheritance structure to something that still works that avoids a diamond pattern.  The diamond pattern is rarely needed and is usually avoidable:
#include <stdlib.h>
#include <iostream>

class IFoo{
public:
    virtual void Hello() = 0;
};

class Foo : public IFoo{
public:
    virtual void Hello() override
    {
        printf("Hello");
    }
};

class IBar {
public:
    virtual void World() = 0;
};

class Bar : public IBar{
public:
    virtual void World() override
    {
        printf("World");
    }
};

class FooBar : public Foo, public Bar
{
public:
    virtual void HelloWorld()
    {
        Hello();
        World();
    }
};

int main()
{
    FooBar b;
    b.HelloWorld();

    system("pause");
    return 0;
}

A: Your class
Bar

must override
Hello

otherwise class Bar also becomes purely abstract, because
Hello

is inherited all the way from
IFoo.

Whenever a class inherits an abtract base class it must implement all of the base class' pure virtual functions, otherwise the derived class itself also becomes abstract.
class Base{
public:
    virtual void foo() = 0;
};

// this class is abstract, it doesn't implement Base::foo
class Derived1 : public Base{
public:
    void fooDerived() {}
};

// this class is not abstract, it implements Base::foo
class Derived2 : public Base{
public:
    void foo() {}
};

As suggested in another answer, in C++11 you can declare the function using the override keyword, which ensures that the function overrides a virtual function. Like this:
   // this class is not abstract, it implements Base::foo
class Derived2 : public Base{
public:
    void foo() override {}
};

Virtual inheritance solves another problem, the problem of ambiguity when inheriting from more than one base class which declares identical functions or members.


text:
Q: Is there a formula for the size of Symplectic group defined over a ring $Z/p^k Z$? Is there a formula for the size of Symplectic group defined over a finite ring $Z/p^k Z$?

A: From L. C. Grove's Classical Groups and Geometric Algebra, page 27:
$$|\operatorname{SP}(2n,\mathbb{F}_q)|=q^{n^2}\prod_{i=1}^n(q^{2i}-1),$$
for some $q=p^k$. This works in the case of $\mathbb{F}_p\cong\mathbb{Z}/p\mathbb{Z}$, but I don't think it's helpful for the general case $\mathbb{Z}/q\mathbb{Z}$.

A: Hi.
EDIT: As Joe Silverman pointed out, this approach doesn't work as simple as I imagined it. Sorry for that. I leave the attempted proof here in case someone has an idea how to fix it.
Yes, there is such a formula. It works for in a similar fashion all of the classical algebraic group. Consider the projection $\mathbb{Z}/p^k\to\mathbb{Z}/p$. It induces a surjection $Sp_{2n}(\mathbb{Z}/p^k)\to Sp_{2n}(\mathbb{Z}/p)$ because every transvection has a preimage and the transvections generate $Sp_{2n}(F)$ for every field $F$. The kernel of the homomorphism consists obviously of those matrices $M$ with $M-I \in (p\mathbb{Z}/p^k\mathbb{Z})^{n\times n}$. There are $p^{(k-1)n^2}$ such matrices.
Therefore $|Sp_{2n}(\mathbb{Z}/p^k)| = p^{(k-1)n^2} |Sp_{2n}(\mathbb{Z}/p)|$. The order of the symplectic group over $\mathbb{Z}/p$ is known.

A: From Christopher Perez's answer, we have $|Sp_{2n}(\mathbb{Z}/p\mathbb{Z})| = p^{n^2} \prod_{i=1}^n (p^{2i}-1)$.  Following Johannes Hahn, we wish to determine the size of the kernel of the homomorphism  $Sp_{2n}(\mathbb{Z}/p^k\mathbb{Z}) \to Sp_{2n}(\mathbb{Z}/p\mathbb{Z})$.
To compute this, we may induct on $k$: For $k \geq 1$, elements in the kernel of the homomorphism $Sp_{2n}(\mathbb{Z}/p^{k+1}\mathbb{Z}) \to Sp_{2n}(\mathbb{Z}/p^k\mathbb{Z})$ have the form $I + p^k A$ for a matrix $A = \left( \begin{smallmatrix} E & F \\ G & H \end{smallmatrix} \right)$ with values in $\mathbb{Z}/p\mathbb{Z}$.  The symplectic condition (given in Wikipedia) is equivalent to the conditions that $F^t = F$, $G^t = G$, and $E^t + H = 0$.  $F$ and $G$ are therefore symmetric matrices, while $H$ and $E$ determine each other, with no further conditions.  The kernel of one-step reduction therefore has size $p^{n(n+1)/2} \cdot p^{n(n+1)/2} \cdot p^{n^2}$, or $p^{2n^2 + n}$.
The final answer is therefore: $|Sp_{2n}(\mathbb{Z}/p^k\mathbb{Z})| = p^{(2k-1)n^2 + (k-1)n} \prod_{i=1}^n (p^{2i}-1)$
Edit: To address kassabov's complaint, I'll explain the calculation in a bit more detail.  The symplectic condition on $I + p^k A$ is that $(I + p^k A)^t \Omega (I + p^k A) \equiv \Omega \pmod {p^{k+1}}$, where $\Omega = \left( \begin{smallmatrix} 0 & I_n \\ -I_n & 0 \end{smallmatrix} \right)$.  Because $k \geq 1$, we may eliminate the $p^{2k} A^t \Omega A$ term when expanding, to get
$$ \Omega + p^k A^t \Omega + p^k \Omega A \equiv \Omega \pmod {p^{k+1}}$$
By subtracting $\Omega$ from both sides, we get the conditions I mentioned on the blocks in $A$.  As you mentioned, this coincides with the symplectic Lie algebra condition.  George McNinch gave an elegant explanation in the comments, but a possibly more pedestrian reason is that $(p^k)$ is a square zero ideal in $\mathbb{Z}/p^{k+1}\mathbb{Z}$, so one has a canonical isomorphism between the kernel of reduction and the Lie algebra tensored with the quotient ring.


text:
Q: Jquery - Change content styles iframe I want to change styles css inside at a iframe, using:
$("#box_close").click(function(){
("#iframe").contents().find("#scrolling_box").removeClass("scrollingBox");
$("#iframe").contents().find("#scrolling_box").addClass("scrollingBoxCustom");
});

Not working ok because the attribute src is in different host that index file, so it gives a classic browser policy error when trying to access a resource that is not on the same host.
Is there some another way I can change styles from the html content of an iframe from a page hosted on another server?
Thanks,


text:
Q: Why do i get the error "Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first"? I am trying to play the sound of the apposite color when I open the page. The problem is that it appears this error about the sound and I don't know why.. Especially because all the rest of the code is working just fine. Any suggest please ?
This is the code:
var gamePattern = []
var buttonCoulors = ["red", "blue", "green", "yellow"]

nextSequence()

function nextSequence() {

  var randomNumber = Math.floor(Math.random() * 4)
  var randomChosenColour = buttonCoulors[randomNumber]
  var randomSound = "sounds/" + randomChosenColour + ".mp3"
  var Sound = new Audio(randomSound)
  gamePattern.push(randomChosenColour)
  $("#" + randomChosenColour).addClass("pressed")
setTimeout(function(){
$("#"+randomChosenColour).removeClass("pressed")
},100)
Sound.play()

}


text:
Q: TinyMCE does not apply font-size and text-color while project is on the web I've used TinyMCE in my projects. It works well when I run the web application locally. But when I put the files on the internet, text-color and font-size don't apply in the formatting.
What's the problem ?

A: I think you've got an another rule that overrides your font style.
The fact that the development and production version diverge is a little weird, have you try to clean your cache (CTRL + F5) ?
Like @Aiden Ewen said, you should view the rule being applied to an element by inspect it using the developers tools, and easily target the file and line where is located this rule.

Here you can see the color black is applied to #question-header a in the all.css file.
You can also try, if it is not already, to add the keyword important next to the CSS rules you want to apply at the TinyMCE.

A: Finally I've found the problem when I saw the source of page.
This is what is stored in databae for one of that items:
<span style=\"font-size: 24pt; color: #ff0000;\">

When I removed \ from stored data, problem got solved. I'm using PDO to connect PHP with MySQL. So I think it is escaping double quotes.
So the solution is about preventing PDO to escape double quotes.
Thank you all to getting participate in this question.


text:
Q: Get text from QPushButton in PyQt I'm trying to create a simple keyboard from list of QtGui.QPushButton objects.
class XKeyboard(QtGui.QWidget):
  '''Special virtual keyboard for any language.'''
  def __init__(self, parent=None):
    QtGui.QWidget.__init__(self, parent)
    self.MainLayout = QtGui.QVBoxLayout()
    self.TextEntry = QtGui.QTextEdit()
    self.Keyboard = QtGui.QVBoxLayout()
    self.MainLayout.addWidget(self.TextEntry)
    self.MainLayout.addLayout(self.Keyboard)
    self.setLayout(self.MainLayout)

  def addRow(self, keys):
    layout = QtGui.QHBoxLayout()
    buttons = [QtGui.QPushButton(unicode(key)) for key in keys]
    for button in buttons:
      key = keys[buttons.index(button)]
      layout.addWidget(button)
      button.clicked.connect(
          lambda key: self.keyClick(key))
      self.keyClick(key)
    self.Keyboard.addLayout(layout)

  def keyClick(self, key):
    self.TextEntry.insertPlainText(key)

The problem is that lambda returns False instead of key. What am I doing wrong?

A: That lambda :
lambda key: self.keyClick(key)

is equivalent to this:
def dummy(key):
    self.keyClick(key)

So, basically you are accepting a parameter from clicked signal, which returns checked state of the button and it is False since you don't have a check-able button, and passing it to the keyClick method. keyClick method does not receive the key parameter in the for loop.
Possible solution would be writing your lambda accepting two parameters one with the default value of your intended value:
lambda checked, key=key: self.keyClick(key)

Why you need to do key=key is a whole different subject. This particular answer (along with the other answers) from a related subject might shed some light on it.

A: The right way to do this is to use a QButtonGroup, which is designed for precisely this situation.
Here's one way to re-write your example to use it:
class XKeyboard(QtGui.QWidget):
  '''Special virtual keyboard for any language.'''
  def __init__(self, parent=None):
    QtGui.QWidget.__init__(self, parent)
    self.MainLayout = QtGui.QVBoxLayout()
    self.TextEntry = QtGui.QTextEdit()
    self.Keyboard = QtGui.QVBoxLayout()
    self.MainLayout.addWidget(self.TextEntry)
    self.MainLayout.addLayout(self.Keyboard)
    self.setLayout(self.MainLayout)
    self.buttonGroup = QtGui.QButtonGroup(self)
    self.buttonGroup.buttonClicked[int].connect(self.keyClick)

  def addRow(self, keys):
    layout = QtGui.QHBoxLayout()
    for key in keys:
        key = unicode(key)
        button = QtGui.QPushButton(key)
        self.buttonGroup.addButton(button, ord(key))
        layout.addWidget(button)
    self.Keyboard.addLayout(layout)

  def keyClick(self, key):
    self.TextEntry.insertPlainText(unichr(key))


text:
Q: How to Create Such Transition Effect on Android Rotation I wanna to create this transition effect on View in Activity or Fragment like below in this Image... Please anyone give me some idea regarding this....

A: See this answer. You can't do such fancy animations on orientation change.


text:
Q: Rolling two dice alternatively. What is probability of winning? Tom and Paul roll 2 dice alternatively starting with Tom. Consider they use two fair 6-faced dice. The player who rolls 6 first wins. They continue to roll until one of them wins. Find probability that Tom wins.
I have listed out the total possible outcomes below:
{(1,1), (1,2), (1,3), (1,4), (1,5), (1,6), (2,1), (2,2), (2,3), (2,4), (2,5), (2,6), (3,1), (3,2), (3,3), (3,4), (3,5), (3,6), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6), (5,1), (5,2), (5,3), (5,4), (5,5), (5,6), (6,1), (6,2), (6,3), (6,4), (6,5), (6,6)}
Here are all the possible outcomes of two dice rolls. And as one can see, only 5 of these comes out with a 6 first; so, I think the probability of Tom winning should be 5/36.
However, when I looked at the solution (This is a question from one midterm in one of previous semesters given at my school) says:
p is 5/36
$$P(Tom\, Wins)=\sum_{k=0}^{\infty }p(1-p)^{2k}=p\sum_{k=0}^{\infty }(1-p)^{2k}=$$
$$\frac{\frac{5}{36}}{1-\frac{31}{36}}=\frac{5}{5}$$
As one can see this answer is really rediculus! (Tom will win no matter what??)
I think that the key here is probably on the word "alternatively", but cannot figureout what has gone wrong here.

A: The probability that Tom wins on the first roll is $\frac16$. He wins on the third roll if and only if he first rolls something other than a $6$, then Paul rolls something other than a $6$, and then Tom rolls a $6$; the probability of this is $\frac56\cdot\frac56\cdot\frac16$. In general, Tom wins on the $(2k+1)$-st roll if and only if the first none of the first $2k$ rolls is a $6$, and Tom rolls a $6$ on roll $2k+1$; this occurs with probability $\frac16\left(\frac56\right)^{2k}$. Thus, the probability that Tom wins is
$$\begin{align*}
\sum_{k\ge 0}\frac16\left(\frac56\right)^{2k}&=\frac16\sum_{k\ge 0}\left(\frac56\right)^{2k}\\
&=\frac16\sum_{k\ge 0}\left(\frac{25}{36}\right)^k\\
&=\frac16\cdot\frac1{1-\frac{25}{36}}\\
&=\frac6{11}\;.
\end{align*}$$
This is the formula in the solution that you read, with $p=\frac16$.
It should not be surprising that this is slightly more than $\frac12$: the fact that Tom goes first gives him an advantage, but it's a small one, since the game is otherwise very symmetric.
One can also compute the desired probability without resort to infinite series. Let $p$ be the probability that Tom wins, so that Paul wins with probability $1-p$. On the other hand, the probability that Paul when Tom first rolls something other than a $6$ must be $p$, because at that point the game is effectively starting over with Paul as the first player. Thus, Paul wins with probability $\frac56p$, the probability that Tom rolls something other than a $6$ initially and Paul then rolls a $6$ before Tom does. In short, $1-p=\frac56p$, and solving for $p$ again yields $p=\frac6{11}$.


text:
Q: Why does my Tkinter toplevel freeze after a while? I have stopwatch running on both my main window and my top level. The watch starts as soon as the program is launched and is stopped by closing the program. The toplevel is launched by using a button. The toplevel is supposed to display a copy of the stopwatch. But, when I keep the toplevel open for over an hour, it freezes. The main window runs fine. The toplevel works fine for another hour or so when I manually close and reopen it. Does anyone know what could be the problem? I'm running the code on Windows OS.
Here's the relevant code:
import datetime
import time
import tkinter as tk

time_elapse_flag = False
start_time = datetime.datetime.now()
diff = 0

def time_elapse():
    global time_elapse_flag
    global diff

    if(not time_elapse_flag):
            time_elapse_flag = True
            time_elapse_count = tk.Label(window, text='', relief='sunken', bg='white', font='Helvetica 16 bold')
            time_elapse_count.place(x=10, y=150, width=200, height=50)
            start_time = datetime.datetime.now().replace(microsecond=0)

            time_elapse_label = tk.Label(window, text='Recording data since:', font='Helvetica 12 bold')
            time_elapse_label.place(x=10, y=120, width=200, height=30)

            def update_time():
                global start_time
                global diff
                current_time = datetime.datetime.now().replace(microsecond=0)
                diff = current_time - start_time
                time_elapse_count.config(text=diff)
                time_elapse_label.after(1000,update_time)

            update_time()

    else:
        time_elapse_flag = False
        time_elapse_count = tk.Label(window, text='')
        time_elapse_count.place(x=10, y=150, width=200, height=50)

        time_elapse_label = tk.Label(window, text='')
        time_elapse_label.place(x=10, y=120, width=200, height=30)

def Param_Window():
    global time_elapse_flag
    global diff

    pw = tk.Toplevel()
    pw.geometry('1200x550')

    def update_values():
        global diff

        if(time_elapse_flag):
                time_elapse_label = tk.Label(pw, text='Recording data since:', font='Helvetica 20 bold')
                time_elapse_count = tk.Label(pw, text=diff, relief='sunken', bg='white', font='Helvetica 16 bold')
                time_elapse_label.place(x=640, y=350, width=300, height=50)
                time_elapse_count.place(x=640, y=400, width=200, height=50)
        else:
                time_elapse_label = tk.Label(pw, text='')
                time_elapse_count = tk.Label(pw, text='')
                time_elapse_label.place(x=640, y=350, width=300, height=50)
                time_elapse_count.place(x=640, y=400, width=200, height=50)

        pw.after(800,update_values)

    update_values()

if __name__ == "__main__":
    window = tk.Tk()
    window.geometry('550x250')

    disp_param_button = tk.Button(window, text='Display Parameters', command=Param_Window, bg='sky blue', font='Helvetica 12 bold', width=20, state='normal', relief='raised')
    disp_param_button.place(x=300, y=150)
    print('Automatically starting in')

    for cd in range(5):
        print(5-cd)
        time.sleep(1)

    time_elapse()

    window.mainloop( )

A: The problem is that you're creating two new label widgets every 800 milliseconds in Param_Window. When you run for an hour, that means you will have created 4,500 label widgets. At some point you're going to hit a hard limit, because you can't create an infinite number of widgets.
You need to restructure your code so that you create the labels once and then reconfigure them instead of creating new widgets on every iteration.

A: To add to Bryan's answer you should also move the code for sleep to be outside of the tk instance and fix your indention.
Here is a corrected version of your code that will fix all the problems I can see.

*

*Indention fix

*Sleep moved outside of tk instance (not related to your main problem but is wrong just the same)

*changed the Param_Window function to update labels instead of recreating them ever 0.8 seconds.
Code:
import tkinter as tk
import datetime
import time

time_elapse_flag = False
start_time = datetime.datetime.now().replace(microsecond=0)

def time_elapse():
    global time_elapse_flag
    global diff

    if(not time_elapse_flag):
        time_elapse_flag = True
        time_elapse_count = tk.Label(window, text='', relief='sunken', bg='white', font='Helvetica 16 bold')
        time_elapse_count.place(x=10, y=150, width=200, height=50)
        start_time = datetime.datetime.now().replace(microsecond=0)

        time_elapse_label = tk.Label(window, text='Recording data since:', font='Helvetica 12 bold')
        time_elapse_label.place(x=10, y=120, width=200, height=30)

        def update_time():
            global start_time
            global diff
            current_time = datetime.datetime.now().replace(microsecond=0)
            diff = current_time - start_time
            time_elapse_count.config(text=diff)
            time_elapse_label.after(1000, update_time)

        update_time()

    else:
        time_elapse_flag = False
        time_elapse_count = tk.Label(window, text='')
        time_elapse_count.place(x=10, y=150, width=200, height=50)

        time_elapse_label = tk.Label(window, text='')
        time_elapse_label.place(x=10, y=120, width=200, height=30)

def Param_Window():
    global time_elapse_flag
    global diff

    pw = tk.Toplevel()
    pw.geometry('1200x550')
    time_elapse_label = tk.Label(pw, text='Recording data since:', font='Helvetica 20 bold')
    time_elapse_count = tk.Label(pw, text=diff, relief='sunken', bg='white', font='Helvetica 16 bold')
    time_elapse_label.place(x=640, y=350, width=300, height=50)
    time_elapse_count.place(x=640, y=400, width=200, height=50)

    def update_values():
        global diff

        if(time_elapse_flag):
            time_elapse_label.config(text='Recording data since:')
            time_elapse_count.config(text=diff)

        else:
            time_elapse_label.config(text='')
            time_elapse_count.config(text='')

        pw.after(800, update_values)

        update_values()

if __name__ == "__main__":

    print('Automatically starting in')

    for cd in range(5):
        print(5-cd)
        time.sleep(1)

    window = tk.Tk()
    window.geometry('550x250')

    disp_param_button = tk.Button(window, text='Display Parameters', command=Param_Window, bg='sky blue', font='Helvetica 12 bold', width=20, state='normal', relief='raised')
    disp_param_button.place(x=300, y=150)

    time_elapse()
    window.mainloop()


text:
Q: When X is r.v with exponential distribution then X-a is r.v with Exponential distribution too? (a is a constant) When r.v. $X$ ~ Expo($\lambda$) then r.v. $(X-a)$ ~ Expo($\lambda$) ?
Let $Y = X-a$.
CDF of $Y$ : $P(Y < y) = P(X-a < y) = P(X < a+y) = 1-e^{\lambda(a+y)}$
It doesn't seem like $Y$ is not r.v with Expo$(\lambda)$ but i want to make sure whether my logic is correct.
And i wanna know why given $X$ ~ Expo($\lambda$), $E(X|X>a) = a + E(X-a|X>a) = a + E(X)$
I really would be appreciated if you enlighten me, Thanks!

A: The exponential distribution's support is $[0,\infty)$, whereas $Y$ has support $[-a,\infty)$. Thus, if $a\ne0$ $Y$ cannot be an exponential distribution. It does have the same shape as one, though.
We calculate $E(X\mid X>a)$ as
$$\frac{\int_a^\infty x\lambda e^{-\lambda x}\,dx}{\int_a^\infty \lambda e^{-\lambda x}\,dx}=\frac{(1+a\lambda)e^{-a\lambda}}{\lambda e^{-a\lambda}}=a+\frac1\lambda=a+E(X)$$


text:
Q: Auto Convert to GoogleDocs format doesnt work for automatic upload I am trying to upload my folder system using "gsutil"  command line, which i am able to do it succesfully.
I have made a setting on my google docs that convert each of document to google doc format.
When i do manual upload it auto converts each document to google doc format but when am doing automatic upload it does not format any of the documents.
Please let me know what i am doing wrong or is it possible to do it?
Thanks


text:
Q: Getting RavenDB Client API to work in Silverlight I just learned that RavenHQ is an easy-to-use database for .NET and especially Silverlight. I'm trying to insert some Test Data (see Code) but it won't work. I think I am missing something big because I'm new to RavenDB.
I added the references to the project and created clientaccesspolicy.xml and crossdomain.xml. I get (Firebug) an HTTP 200 Response to "GET clientaccesspolicy.xml" from 1.ravenhq.com but nothing else happens and no data is inserted. Any Ideas would be much appreciated.
Private Sub TestRavenDB()
    Try
        Dim ds = New DocumentStore()
        ds.Url = "https://1.ravenhq.com/databases/AppHarbor_60e82bd1-234f-4178-a59a-b527a1d391bb"
        ds.ApiKey = "1f827c44-3e38-4e66-8801-83ba03b01f67"
        ds.Initialize()

        Dim p As New Person("Donald")
        Dim session As IAsyncDocumentSession = ds.OpenAsyncSession()
        session.Store(p)

        session.SaveChangesAsync()
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
End Sub

A: Note that you have SaveChangesAsync there. Before your test return, you need to wait for that to complete.


text:
Q: How to pass multi method from a component to other component by React-navigater? I am facing this problem in React native.
How to pass multi methods from a component to other component by react-navigater.
Actually, I know Redux or Mobx is better way to solve this problem but I can't do that in some reason from my boss...
So, Please let me know this.
example code is this.
method1() {
  this.setState({ checked: true });
}
method2() {
  this.setState({ marked: false });
}

navigation={this.props.navigation.navigate('Home',
           { method1: this.method1.bind(this);},
           { method2: this.method2.bind(this);},
)}

I wanna do above one but I can't.

A: Try passing your data as a single second argument prop:
navigation={
   this.props.navigation.navigate('Home',
       { method1: this.method1.bind(this),
         method2: this.method2.bind(this)}
       )}


text:
Q: Data matches even though program puts resukt FALSE in excel - Selenium web driver I have created program which match console output with excel cell data and prints "TRUE" - "FALSE" based on data matching. Issue is my data is matching here 100% then also it is printing "FALSE" in excel , WHY?
Code is given below :
     //CODE TO REMOVE UNNECESSARY WARNING
    System.setProperty("org.apache.commons.logging.Log",
    "org.apache.commons.logging.impl.Jdk14Logger");

    //CALL FIREFOX DRIVER TO OPEN IT
    WebDriver driver = new FirefoxDriver();

    //GETTING PAGE , OPEN IT IN BROWSER AND GET PAGE TITLE TO PRINT IT
    driver.get("http://en.wikipedia.org/wiki/Software_testing");
    String title = driver.getTitle();
    System.out.println(title);

    //EXCEL FILE READING
    FileInputStream input = new FileInputStream("D:\\sel.xls");

    int count=0;

    HSSFWorkbook wb = new HSSFWorkbook(input);
    HSSFSheet sh = wb.getSheet("sheet1");
    HSSFRow row = sh.getRow(count);
    String data = row.getCell(1).toString();
    System.out.println(data);

    //CONDITION TO MATCH CONSOLE OUTPUT WITH EXCEL CELL DATA VALUE
    if(title==data)

    {
        FileOutputStream webdata = new FileOutputStream ("D:\\sel.xls");
        row.createCell(10).setCellValue("TRUE");
        wb.write(webdata);

    }
    else
    {
        FileOutputStream webdata = new FileOutputStream ("D:\\sel.xls");
        row.createCell(11).setCellValue("FALSE");
        wb.write(webdata);

    }

    driver.close();
    wb.close();
    input.close();

  }

  }

A: title and data are two different objects, means holding two different references. Your == symbol will match references and not exact value. Use equals() instead.
Use
if(title.equals(data))

instead of
if(title==data)


text:
Q: What IP address would I check if my email is blacklisted? I have a server hosting a website with an ISP. That server's IP address is X. I can also see MX records for my domain, they resolve to the IP address Y.
People have been telling me "your email is ending up in my spam folder", so I think some IP address ended up on a blacklist somewhere.
Do I check the IP address of my server? The IP address of the MX records of my domain? Or some possibly third IP address, and if so, how do I determine that third IP address?


text:
Q: Setting up a class with a specific parameter Can anybody explain to me why this doesn't work and how I go about setting this class up to run with a specified parameter? (the intial balance) I wanted to run this class from my main program with a specific parameter passed as the initial balance. Do I need to setup start balance as a class variable?
public class LoanAccount
{
static float interestRate = 0.006F;
private float balance;

public LoanAccount(float StartBalance)
{
    balance = StartBalance;
}

public float getBalance(){
    return balance;
}

public void addInterest(){
    float interest = balance * interestRate;
    balance = balance + interest;
}

public void makePayment(float LPaid){
    balance = balance - LPaid;
}

public static void main(){
    LoanAccount BankLoan = new LoanAccount(StartBalance);

}

}

A: On this row:
LoanAccount BankLoan = new LoanAccount(StartBalance);

StartBalance is not defined. You need to supply an actual value to the constructor, or a float variable that has been initialized with a value.

A: Here
LoanAccount BankLoan = new LoanAccount(StartBalance);

you just need
LoanAccount BankLoan = new LoanAccount(1500.0f);

or whatever balance you want to start out with.

A: You can pass the StartBalance as a command line argument :
public static void main(String[] args)
{
    float StartBalance = 0.0;
    try {
        if (args.length > 0) {
            StartBalance = Float.parseFloat(args[0]);
            LoanAccount BankLoan = new LoanAccount(StartBalance);
        }
    }
    catch (NumberFormatException exc) {
        System.out.println("invalid input : " + args[0]);
    }
}

A: You havent initialised StartBalance, that you are meant to pass on to constructor while creating LoanAccount. You could do it in two ways like:
 LoanAccount BankLoan = new LoanAccount(10.0f);

Or you could define a local variable in the main method like:
float initialBalance = 10.0f;
LoanAccount BankLoan = new LoanAccount(initialBalance);
LoanAccount BankLoan2 = new LoanAccount(initialBalance);


text:
Q: React select set value in select As I understood, in react-select (latest) you need to send an object to the value props, to select/preselect an option. I am also using react-hook-form for my form management.
Is it possible to set the value through react-select or do I need to use react-hook-form's setValue()
As I click on an Item, I send this to my states:
const handleSectionOnClick = (id) => {
    setTravelRoute({
        'LocationEnd': { value: +travelRoutes[id].LocationIdEnd, label: travelRoutes[id].LocationCityEnd },
        'LocationStart': { value: +travelRoutes[id].LocationIdStart, label: travelRoutes[id].LocationCityStart },
        'startDate': new Date(),
        'endDate': new Date()
    })
}

My Demo object looks like this:
    {
        'LocationCityEnd': "Berlin, Ger",
        'LocationCityStart': "Hattingen, Ger",
        'LocationIdEnd': 2,
        'LocationIdStart': 1,
        'startDate': new Date(),
        'endDate': new Date()
    }

My (LocationStart) select component looks like this:
<Controller
render={({ onChange }) => (
    <Select
        styles={customStyles}
        onChange={handleOnChangeStartLocation}
        name="startLocation"
        value={travelRoute?.LocationStart}
        options={selectOptions}
        placeholder="Choose..."

    />
)}
name="startLocation"
className={`${errors.startLocation ? 'inputSelectError' : ''}`}
control={control}
rules={{ required: true }}
/>

Nothing gets selected, not even the value/label.
What Am I missing? Thank you!
EDIT:
I added the handleOnChangeStartLocation function:
const handleOnChangeStartLocation = e => {
    const { value, label } = e;
    setTravelRoute(prevState => ({
        ...prevState,
        LocationIdStart: value,
        LocationCityStart: label
    }))
}

A: The problem seems to be that you are not updating LocationStart with the new value/label. You should do something like:
const handleOnChangeStartLocation = e => {
    const { value, label } = e;
    setTravelRoute(prevState => ({
        ...prevState,
        LocationStart: e, // add this line of code
        LocationIdStart: value,
        LocationCityStart: label
    }))
}