text:
Q: How to keep one layout over another layout in android This is my xml I want to keep one layout over another layout.
I have progress Bar and try again Textview in same place I am doing visible and invisible Textview and Progressbar programatically, so I want keep Progressbar over try again button, but I am unable to do this.
I have searched from google that we can do using Frame layout but its not working.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/tesco_blue"
    android:paddingBottom="@dimen/margin_18"
    android:paddingLeft="@dimen/margin_18"
    android:paddingRight="@dimen/margin_12"
    android:orientation="vertical"
    android:paddingTop="@dimen/margin_18">
    <LinearLayout
        android:id="@+id/securebarcode_error_layout_variant_a"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:orientation="vertical"
        android:layout_marginLeft="@dimen/margin_56"
        android:layout_marginRight="@dimen/margin_56"
        android:visibility="visible"
        tools:visibility="visible">

        <android.support.v4.widget.Space
            android:layout_width="match_parent"
            android:layout_height="@dimen/margin_40" />

        <TextView
            android:id="@+id/errortitle"
            style="@style/Typeface.Body.Bold.White"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:background="@android:color/transparent"
            android:gravity="center"
            android:lineSpacingExtra="4sp"
            tools:text="@string/pwp_network_error" />

        <TextView
            android:id="@+id/errordesc"
            style="@style/Typeface.Body.White"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:gravity="center"
            android:layout_marginTop="@dimen/margin_12"
            android:lineSpacingExtra="8sp"
            tools:text="@string/pwp_network_error_description" />
        <FrameLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_gravity="center"
            >
        <ProgressBar
            android:id="@+id/pwp_progressbarlayout_variant_a"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"

            android:visibility="visible"
            android:paddingLeft="@dimen/cl_48"
            android:paddingRight="@dimen/cl_48"
            android:paddingTop="@dimen/padding_12"
            android:paddingBottom="@dimen/padding_12"
            android:indeterminateDrawable="@drawable/custom_progress_bar"/>
        </FrameLayout>

        <TextView
            android:id="@+id/try_again"
            style="@style/Typeface.Body.Bold.HighlightBlue"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:background="@drawable/error_button_background"
            android:gravity="center"
            android:paddingLeft="@dimen/cl_48"
            android:paddingRight="@dimen/cl_48"
            android:paddingTop="@dimen/padding_12"
            android:paddingBottom="@dimen/padding_12"
            android:text="@string/Tryagain"
            android:textColor="@color/fdv_pending_state_color" />

        <android.support.v4.widget.Space
            android:layout_width="match_parent"
            android:layout_height="@dimen/margin_40" />

    </LinearLayout>
</LinearLayout>

A: *

*You can simply use constraint layout in your case as basically its
from the family of frame layout , you can implement the code below.just take your root layout as ConstraintLayout

<TextView
    android:id="@+id/try_again"
    style="@style/Typeface.Body.Bold.HighlightBlue"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    android:background="@drawable/error_button_background"
    android:gravity="center"
    android:paddingLeft="@dimen/cl_48"
    android:paddingRight="@dimen/cl_48"
    android:paddingTop="@dimen/padding_12"
    android:paddingBottom="@dimen/padding_12"
    android:text="@string/Tryagain"
    android:textColor="@color/fdv_pending_state_color" />

<ProgressBar
    android:id="@+id/pwp_progressbarlayout_variant_a"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintTop_toTopOf="@id/try_again"
    app:layout_constraintBottom_toBottomOf="@id/try_again"
    app:layout_constraintLeft_toLeftOf="@id/try_again"
    app:layout_constraintRight_toRightOf="@id/try_again"
    android:visibility="visible"
    android:paddingLeft="@dimen/cl_48"
    android:paddingRight="@dimen/cl_48"
    android:paddingTop="@dimen/padding_12"
    android:paddingBottom="@dimen/padding_12"
    android:indeterminateDrawable="@drawable/custom_progress_bar"/>

A: You have to move your try_again TextView to inside of FrameLayout so the your Progressbar will show on TextView
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/tesco_blue"
android:orientation="vertical"
android:paddingLeft="@dimen/margin_18"
android:paddingTop="@dimen/margin_18"
android:paddingRight="@dimen/margin_12"
android:paddingBottom="@dimen/margin_18">

<LinearLayout
    android:id="@+id/securebarcode_error_layout_variant_a"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginLeft="@dimen/margin_56"
    android:layout_marginRight="@dimen/margin_56"
    android:orientation="vertical"
    android:visibility="visible"
    tools:visibility="visible">

    <android.support.v4.widget.Space
        android:layout_width="match_parent"
        android:layout_height="@dimen/margin_40" />

    <TextView
        android:id="@+id/errortitle"
        style="@style/Typeface.Body.Bold.White"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:background="@android:color/transparent"
        android:gravity="center"
        android:lineSpacingExtra="4sp"
        tools:text="@string/pwp_network_error" />

    <TextView
        android:id="@+id/errordesc"
        style="@style/Typeface.Body.White"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="@dimen/margin_12"
        android:gravity="center"
        android:lineSpacingExtra="8sp"
        tools:text="@string/pwp_network_error_description" />

    <FrameLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center">

        <ProgressBar
            android:id="@+id/pwp_progressbarlayout_variant_a"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:indeterminateDrawable="@drawable/custom_progress_bar"
            android:paddingLeft="@dimen/cl_48"
            android:paddingTop="@dimen/padding_12"
            android:paddingRight="@dimen/cl_48"
            android:paddingBottom="@dimen/padding_12"
            android:visibility="visible" />

        <TextView
            android:id="@+id/try_again"
            style="@style/Typeface.Body.Bold.HighlightBlue"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:background="@drawable/error_button_background"
            android:gravity="center"
            android:paddingLeft="@dimen/cl_48"
            android:paddingTop="@dimen/padding_12"
            android:paddingRight="@dimen/cl_48"
            android:paddingBottom="@dimen/padding_12"
            android:text="@string/Tryagain"
            android:textColor="@color/fdv_pending_state_color" />
    </FrameLayout>

    <android.support.v4.widget.Space
        android:layout_width="match_parent"
        android:layout_height="@dimen/margin_40" />

Here it is the image what you want.

A: Update your Layout as below - Relative Layout can do the trick
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/tesco_blue"
    android:paddingBottom="@dimen/margin_18"
    android:paddingLeft="@dimen/margin_18"
    android:paddingRight="@dimen/margin_12"
    android:orientation="vertical"
    android:paddingTop="@dimen/margin_18">

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

        <LinearLayout
            android:id="@+id/securebarcode_error_layout_variant_a"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:orientation="vertical"
            android:layout_marginLeft="@dimen/margin_56"
            android:layout_marginRight="@dimen/margin_56"
            android:visibility="visible"
            tools:visibility="visible">

            <android.support.v4.widget.Space
                android:layout_width="match_parent"
                android:layout_height="@dimen/margin_40" />

            <TextView
                android:id="@+id/errortitle"
                style="@style/Typeface.Body.Bold.White"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:background="@android:color/transparent"
                android:gravity="center"
                android:lineSpacingExtra="4sp"
                tools:text="@string/pwp_network_error" />

            <TextView
                android:id="@+id/errordesc"
                style="@style/Typeface.Body.White"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:gravity="center"
                android:layout_marginTop="@dimen/margin_12"
                android:lineSpacingExtra="8sp"
                tools:text="@string/pwp_network_error_description" />

            <TextView
                android:id="@+id/try_again"
                style="@style/Typeface.Body.Bold.HighlightBlue"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:background="@drawable/error_button_background"
                android:gravity="center"
                android:paddingLeft="@dimen/cl_48"
                android:paddingRight="@dimen/cl_48"
                android:paddingTop="@dimen/padding_12"
                android:paddingBottom="@dimen/padding_12"
                android:text="@string/Tryagain"
                android:textColor="@color/fdv_pending_state_color" />

            <android.support.v4.widget.Space
                android:layout_width="match_parent"
                android:layout_height="@dimen/margin_40" />

        </LinearLayout>

            <ProgressBar
                android:id="@+id/pwp_progressbarlayout_variant_a"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_centerInParent="true"
                android:visibility="visible"
                android:indeterminateDrawable="@drawable/custom_progress_bar"/>

    </RelativeLayout>

</LinearLayout>


text:
Q: Add average line/plot line to area highchart R I know there are a few similar questions to this out there but they all seem to use javascript (?) or something besides the normal R coding so I don't know how to use it in my code... anyways all I want to do is add a plotline to my area chart that shows the average of the values, how do I do that? I know that highcharter itself can not calculate the average so I can do that myself but how do I create the plotline .... thank you so much. (i tried to make the code so that it is easily 'reproducible' ? hope it is ok). I attached a picture of the current chart if that helps.
library(tidyverse)
library(highcharter)
library(ggplot2)

data("diamonds", package = "ggplot2")

df <- diamonds %>%
  group_by(cut)%>%
  count()
head(df, 4)

# Create chart
hc <- df %>%
  hchart(
    'area', hcaes(x = cut, y = n),
    color = "lightblue"
  ) %>%
hc_yAxis(title = list(text = "cut"))

# Display chart
hc

A: Haha I got it. basically just this.
plotline <- list(
  color = "red", value = mean(diamonds$cut), width = 2, zIndex = 5
)

hc_yAxis(plotLines = list(plotline))

A: Below is a mini example of using the highcharts widget. You can add each series using hc_add_series. In this case, we have two series and two y-axes. Using two y-axes helps to differentiate between the series. I'm not sure what values you're trying to calculate the average so I chose price.
Hope this helps add some clarity to highcharter!
library(tidyverse)
library(highcharter)

df <- diamonds %>%
  group_by(cut)%>%
  summarise(
    n = n(),
    avg_price = round(mean(price),2)
  )

# create hc widget
highchart(type = "chart") %>%
  # add both series
  hc_add_series(df, hcaes(x = cut, y = n), color = "lightblue", yAxis = 0, type = "area", name = "N") %>%
  hc_add_series(df, hcaes(x = cut, y = avg_price), yAxis = 1, type = "line", name = "Avg Price") %>%
  # set type to categories since we're looking at categorical data
  hc_xAxis(type = "category", categories = df$cut) %>%
  hc_title(text = "Cut Freq vs Avg Price") %>%
  # add each y-axis which is linked above in 'hc_add_series'
  hc_yAxis_multiples(
    list(title = list(text = "Cut")), # yAxis = 0
    list(title = list(text = "Average Price"), opposite = TRUE) # yAxis = 1
  ) %>%
  hc_tooltip(shared = TRUE, split = FALSE)

Ex:

redpajama_set_name: RedPajamaStackExchange


text:
Q: Why does M2 place all CSS in inline
A: I believe this is for developer/debugging use only, once you are running with server-side compilation and in production mode you should no longer see them.
This is a screenshot from a production website we have:

A: Maybe you used custom js such as LeaVerou prefixfree, that convert link stylesheet tag to style tag. This was what happened to me.


text:
Q: I want to create a nested dictionary from a csv file with headers as keys This is my csv file:
Player Name,2022 Cap Number,Rating,Position
Poona Ford,"10,075,000",74,DT
Tyler Lockett,"10,050,000",90,WR
D.K. Metcalf,"8,838,827",89,WR
Gabe Jackson,"7,237,778",79,G
Uchenna Nwosu,"6,295,000",79,LB
Quandre Diggs,"5,800,000",85,FS

I want my output to be:
{'Poona Ford': {'2022 Cap Number': '"10075000"', 'Rating': '74', 'Position': 'DT'}, 'Tyler Lockett': {'2022 Cap Number': '"10050000"', 'Rating': '90', 'Position': 'WR'}, 'D.K. Metcalf': {'2022 Cap Number': '"8838827"', 'Rating': '89', 'Position': 'WR'}, 'Gabe Jackson': {'2022 Cap Number': '"7237778"', 'Rating': '79', 'Position': 'G'}, 'Uchenna Nwosu': {'2022 Cap Number': '"6295000"', 'Rating': '79', 'Position': 'LB'}, 'Quandre Diggs': {'2022 Cap Number': '"5800000"', 'Rating': '85', 'Position': 'FS'}

I've been able to produce this but the names are the only keys. I need the other header names to be keys within each name. '2002 Cap Number' , 'Rating', and 'Postion' need to be keys within Player Name.
csv_list = [['Player Name', '2022 Cap Number', 'Rating', 'Position'], ['Poona Ford', '"10075000"', '74', 'DT'], ['Tyler Lockett', '"10050000"', '90', 'WR'], ['D.K. Metcalf', '"8838827"', '89', 'WR'], ['Gabe Jackson', '"7237778"', '79', 'G'], ['Uchenna Nwosu', '"6295000"', '79', 'LB'], ['Quandre Diggs', '"5800000"', '85', 'FS']

(_, *header), *data = csv_list
csv_dict = {}
for row in data:
    key, *values = row
    csv_dict[key] = {key: value for key, value in zip(header, values)}

print(csv_dict)

I tried this but only the names are keys. The rest of the headers and data are all values.

A: Try this:
csv_list = [['Player Name', '2022 Cap Number', 'Rating', 'Position'], ['Poona Ford', '"10075000"', '74', 'DT'], ['Tyler Lockett', '"10050000"', '90', 'WR'], ['D.K. Metcalf', '"8838827"', '89', 'WR'], ['Gabe Jackson', '"7237778"', '79', 'G'], ['Uchenna Nwosu', '"6295000"', '79', 'LB'], ['Quandre Diggs', '"5800000"', '85', 'FS']]

csv_dict = {}
for i,*j in csv_list[1:]:
    csv_dict[i] = dict(zip(csv_list[0][1:], j))


text:
Q: use range with numeric value nest 1.7 I need to add a rangerfilter in nest 1.7 with numeric value,
but the class define GreaterThan with a string
namespace Nest
{
    public class RangeFilter : PlainFilter, IRangeFilter, IFieldNameFilter, IFilter
    {
        public RangeFilter();

        public RangeExecution? Execution { get; set; }
        public PropertyPathMarker Field { get; set; }
        public string Format { get; set; }
        public string GreaterThan { get; set; }
        public string GreaterThanOrEqualTo { get; set; }
        public string LowerThan { get; set; }
        public string LowerThanOrEqualTo { get; set; }
        public string TimeZone { get; set; }

        protected internal override void WrapInContainer(IFilterContainer container);
    }
}

so my query is
  {
                    "range": {
                      "NbAnnonce": {
                        "gt": "0"
                      }

and not
   {
                "range": {
                  "NbAnnonce": {
                    "gt": 0.0
                  }

how can i resolve this issue please?

A: You could try this
new NumericRangeQuery
{
  Name = "named_query",
  Boost = 1.1,
  Field = "description",
  GreaterThan = 1.0,
  GreaterThanOrEqualTo = 1.1,
  LessThan = 2.1,
  LessThanOrEqualTo = 2.0
}

Json Output
{
  "range": {
    "description": {
      "_name": "named_query",
      "boost": 1.1,
      "gt": 1.0,
      "gte": 1.1,
      "lt": 2.1,
      "lte": 2.0
    }
  }
}


text:
Q: Using ddrescue to recover hard drive - Don't know if image is being created I'm an Ubuntu newbie that has tinkered around with it just a tiny bit, but ultimately don't know much about it except how powerful it could be for super users! Also, if this is the wrong place to post this to, any ideas where it would be better suited? Anyway, I have a friend that needs help getting some data off a hard drive that has gone bad on him. Windows is pretty much a lost cause for this type of problem, so I went straight to Ubuntu. (Looks like Parted Magic is no longer open source?)
So I found a couple tutorials, and the one that seems to be working the best can be found here:
https://www.data-medics.com/forum/how-to-clone-a-hard-drive-with-bad-sectors-using-ddrescue-t133.html
I've also played around with this tutorial, but didn't have as much luck with it:
https://www.technibble.com/guide-using-ddrescue-recover-data/
Long story short, from the first tutorial, I determined that the command I should send in terminal would be as follows:
sudo ddrescue -f /dev/sdc /dev/sdb /media/ubuntu/ExtraSpace/Sailor/Sailor.log

When I executed that command, it was the first time that I got ddrescue to start doing its thing. It has now been running for a full day, and is reporting 22% recovered! So I think I'm making progress! (Of course I'll let it run until it's done...maybe 2 or 3 more days)
My question is this though. In the folder /ExtraSpace/Sailor I see a log file. So I believe my log file was created properly. But I'm curious where the data itself (or image file) is being saved? I don't see it anywhere, but I may just not know where to look! I thought a disk image should be created from what I read in that second tutorial...but maybe I executed the command wrong? And for what it's worth, I have made sure that /dev/sdc is the bad drive, and /dev/sdb is the drive, with sufficient space, that I am trying to get data over to.
Thanks for any help you can offer!

A: Execute
add-apt-repository ppa:hamishmb/myppa
apt-get update
apt-get install ddrescue-gui -y

It might make your life easier. /dev/sdX are block devices, you tried to copy disk-to-disk.
Also try
sudo apt install testdisk
testdisk /dev/sdX

And use the file recovery utilities in there.

A: If the drive you need to recover data from is dying (as indicated by increasing numbers of bad sectors) any read access will make things worse. In this case a last read with ddrescue may get you an image of the drive you can then safely use for data recovery software.

*

*See Recover files from NTFS drive with bad sectors on how to create such an image from an affected partition.

*See Mount an image created from ddrescue on how to use that image for data recovery.
In all other cases, and if the drive was healthy you can perform recovery directly from that drive. This would be much faster.

*

*See How do I recover my accidentally lost Windows partitions after installing Ubuntu? on a short guide on how to use data recovery software.


text:
Q: Google App Engine API Annotation - Using Environment Variables We are using App Engine and Firebase however we're having a slight issue. We want to use Environment Variables in our API annotations but we've hit a road block.
package com.myapp.services;

import com.google.api.server.spi.auth.EspAuthenticator;
import com.google.api.server.spi.auth.common.User;
import com.google.api.server.spi.config.*;

@Api(
    name = "contacts",
    version = "v1",
    authenticators = {EspAuthenticator.class},
    issuers = {@ApiIssuer(name = "firebase",
            issuer = "https://securetoken.google.com/<<PROJECT_NAME_GOES_HERE>>",
            jwksUri = "https://www.googleapis.com/service_accounts/v1/metadata/x509/securetoken@system.gserviceaccount.com")},
    issuerAudiences = {@ApiIssuerAudience(name = "firebase", audiences = "<<PROJECT_NAME_GOES_HERE>>")},
    authLevel = AuthLevel.REQUIRED
)
public class ContactService {

    @ApiMethod(path = "create", httpMethod = "post")
    public Long CreateContact(Contact contact, User user) {
        // Create the record
        return contact.id;
    }
}

How do we update the issuer and audiences values on an environment by environment basis? We can use Guice to pass in an environment into the methods however we can't inject into the annotations.
We just want a way to update <<<PROJECT_NAME_GOES_HERE>>> on deployment.


text:
Q: How do I parse a CSV list enclosed in brackets in Python? I'd like to parse the following raw string into an array:
(65.312321,89.314213214214)

Being Python, I'd bet there is a beautiful way to do this, I just don't know it!

A: Since it's syntactically equivalent to python's tuple of floats, you can use ast.literal_eval:
>>> import ast
>>> print ast.literal_eval("(65.312321,89.314213214214)")
(65.312321, 89.314213214214)

If you want, you can convert it to a list:
>>> print list(ast.literal_eval("(65.312321,89.314213214214)"))
[65.312321, 89.314213214214]

A: In Python you do not have array's. You either end up having data in an immutable tuple or a mutable List. Your best bet is to use ast for this purpose
>>> import ast
>>> st = "(65.312321,89.314213214214)"
>>> ast.literal_eval(st) # as a tuple
(65.312321, 89.314213214214)
>>> list(ast.literal_eval(st)) # as a list
[65.312321, 89.314213214214]

You may if you desire can also strip out the parenthesis and split by comma
>>> st.strip("() ").split(",")
['65.312321', '89.314213214214']


text:
Q: Spring MVC: PropertyEditor throwing exception, unable to set values I am new to Spring 3 MVC and was trying to implement PropertyEditor. Below is the code I tried:
Employee.java
private String name;
private String gender;
private Address address;
public Employee() {
    // TODO Auto-generated constructor stub
}
public Employee(String name,String gender,Address address) {
    this.name = name;
    this.gender = gender;
    this.address = address;
}
//Getters and Setters

Address.java
private String city;

public Address() {}

public Address(String city/*,String state*/) {
    this.city = city;
}

// Getters and Setters

AddressTypeEditor.java
public class AddressTypeEditor extends PropertyEditorSupport {

@Override
public void setAsText(String text) throws IllegalArgumentException {
    Address type = new Address(text.toUpperCase());
    setValue(type);
}
}

Context.xml
<mvc:annotation-driven />
<context:component-scan
    base-package="com.XXX" />

<bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
  <property name="customEditors">
   <map>
     <entry key="com.xxx.model.Address" value="com.xxx.editor.AddressTypeEditor"/>
   </map>
  </property>
</bean>

<bean id="viewResolver"
    class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass"
        value="org.springframework.web.servlet.view.JstlView" />
    <property name="prefix" value="/WEB-INF/pages/" />
    <property name="suffix" value=".jsp" />
</bean>

enter.jsp file
<form:form action="input" commandName="employee" method="post">

            Name:

                <form:input path="name"/>

            Gender:

                <form:input path="gender"/>

            City:

                <form:input path="employee.address"/>

                <input type="submit" value="Submit">

</form:form>

Controller.java
// Clicking the index.jsp , the above posted JSP file is displayed.
@RequestMapping(value="enter")
public String enterForm(ModelMap model){
    model.addAttribute("employee",new Employee());
    return "form";
}

@RequestMapping(value="input")
public String inputForm(Employee employee){
    System.out.println(employee.getName());
    System.out.println(employee.getGender());
    Address address = employee.getAddress();
    System.out.println(address.getCity());
    return "success";
}

Problem:
The form.jsp file is not getting rendered, I am getting an error:
org.springframework.beans.NotReadablePropertyException: Invalid property 'employee' of bean class [com.xxx.model.Employee]: Bean property 'employee' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?

The error is thrown in this line of the JSP file:

            City:

                <form:input path="employee.address"/>

Please let me know how to resolve this.

A: From the error message (emphasis mine):

org.springframework.beans.NotReadablePropertyException: Invalid property 'employee' of bean class [com.xxx.model.Employee]: Bean property 'employee' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?

The error seems very specific: there's no field employee in class Employee. You're trying to access to address  field by using employee.address:
<form:input path="employee.address"/>

Just access to address field directly. In fact, access to city field inside Address address field:
<form:input path="address.city"/>


text:
Q: Java HashMap to Matrix I am facing a problem. I used the following hashmap to store some values
HashMap<String, Object> hm = new HashMap<String, Object>();

The object is another HashMap (yeah, you can say HashMap of HashMap). String is to store book name, and Object is again another hashmap that is to store author name and number of authors. So it can look like ( Xyz book{authname,numberOfAuthors} ). Now I want to print this hashmap as NxN matrix. Is there any default function out there that i can use for this? If no, then anybody can tell me any hint to do it in easy way? Because I do not want to use so many loops and if conditions (it will kill system).
Thanks!

A: Looks like you underused the OO potential ... You can create your own Book class and override the toString() to print all the fields ...
public class Book{
    private String bookName;
    private String authorName;
    ...
    @Override
    public String toString() {
        return String.format("%s written by %s",bookName,authorName);
    }
}

by this way your library will be something like :
Map<String, Book> myLibrary = new HashMap<String, Book>(...);

and to print all your library you will need a simple loop :
    for(Book b : myLibrary.values()) {
        System.out.println(b);
    }

A: Definitely no built-in function to do this.
The first thing you need to do is to figure out the unique keys in your second-level map and assign them to columns. Maybe you already know them (if they are fixed), otherwise you have to loop over all of them once and collect them in a set.
If you do have fixed keys, you should consider eliminating the second-level map, and using a Java bean class for this (the books).
If you are really going to print the matrix, you need to think about formatting, mainly column widths. Again, this can also be fixed a priori, or you can look at the data (all or sample) to figure it out.
Ignoring formatting for a moment, you can output something like CSV by then looping over
the map (ideally in sorted key order), and output one line for each entry (book). In each line, you would then loop over the columns (the key list) and output each field.


text:
Q: Apipie for documentation not work for nested namespaces Using APipie for API docuemnation for rails app and it work perfect, but when try to use nested namespace its not showing up the doc for this controllers inside the namespace for example:
this one work ok:
scope 'api', module: :api, constraints: { format: :json } do
  namespace :v1 do
    resources :missions do
      resources :tasks
    end
  end
end

but this one not:
scope 'api', module: :api, constraints: { format: :json } do
  namespace :v1 do
    namespace :counselor do
      resources :students
    end
  end
end

any clue why Apipie not show docs for this nested namespace?

A: found the problem:
in my apipie.rb for APipie configuration api_controller_matcher was set like this:
config.api_controllers_matcher = "#{Rails.root}/app/controllers/api/v1/*.rb"

changed to be
config.api_controllers_matcher = File.join(Rails.root, "app", "controllers", "api", "v1", "**","*.rb")

now it can see all controllers and its routes.


text:
Q: How to maintain folder structure for html and other resources for golang webapp? In my web application, I am maintaining the following folder structure for the web resources,
/Users/Dinesh/go/src/github.com/dineshappavoo/test-proj/
                                                      main.go
                                                      README.md
                                                      app/
                                                          about.html
                                                          home.html
                                                          server.go
                                                          resources/
                                                                   css/
                                                                   js/
                                                                   fonts/
                                                      mypack/
                                                            abc/

In server.go under app folder I am starting the web server and rendering the html etc. In main.go [under top level folder] I am trying to call the server.go function. I am doing this because I can maintain the go dependencies and easily build the project.
Here is my main.go content,
package main

import (
    "github.com/dineshappavoo/test-proj/app"
)

func main() {
    app.Main()
}

and server.go code snippet is here,
package app

import (
    "html/template"
    "io/ioutil"
    "log"
    "net"
    "net/http"
    "regexp"
    "strconv"
    ....
    ....
)

//Home page handler
func homeHandler(
    w http.ResponseWriter,
    r *http.Request,
) {
    renderTemplate(w, "home", nil)
}

//About page handler
func aboutHandler(
    w http.ResponseWriter,
    r *http.Request,
) {

    renderTemplate(w, "about", nil)
}

var templates = template.Must(template.ParseFiles("about.html", "home.html"))

func renderTemplate(
    w http.ResponseWriter,
    tmpl string,
    p interface{},
) {
    //If you use variables other than the struct u r passing as p, then "multiple response.WriteHeader calls" error may occur. Make sure you pass
    //all variables in the struct even they are in the header.html embedded
    if err := templates.ExecuteTemplate(w, tmpl+".html", p); err != nil {
        http.Error(w, err.Error(), http.StatusInternalServerError)
    }
}

//URL validation for basic web services
var validPath = regexp.MustCompile("^/$|/(home|about)/(|[a-zA-Z0-9]+)$")

func validate(
    fn func(
        http.ResponseWriter,
        *http.Request,
    )) http.HandlerFunc {
    return func(
        w http.ResponseWriter,
        r *http.Request,
    ) {
        //log.Printf("Request URL Path %s ", r.URL.Path)
        m := validPath.FindStringSubmatch(r.URL.Path)
        if m == nil {
            http.NotFound(w, r)
            return
        }
        fn(w, r)
    }
}

//Main method to install
func Main() {
    log.Printf("TEST APP SERVER STARTED")

    http.HandleFunc("/", validate(homeHandler))
    http.HandleFunc("/home/", validate(homeHandler))
    http.HandleFunc("/about/", validate(aboutHandler))

    http.Handle("/resources/", http.StripPrefix("/resources/", http.FileServer(http.Dir("resources"))))
    //http.Handle("/templ/", http.StripPrefix("/templ/", http.FileServer(http.Dir("templ"))))
    if *addr {
        l, err := net.Listen("tcp", "127.0.0.1:0")
        if err != nil {
            log.Fatal(err)
        }
        err = ioutil.WriteFile("final-port.txt", []byte(l.Addr().String()), 0644)
        if err != nil {
            log.Fatal(err)
        }
        s := &http.Server{}
        s.Serve(l)
        return
    }

    http.ListenAndServe(":8080", nil)
}

When I start the server.go directly it works [by making Main() in server.go as main() and go run server.go]. But when I use the above structure it fails.
Error:
panic: open about.html: no such file or directory

goroutine 1 [running]:
html/template.Must(0x0, 0x81a568, 0x11980f20, 0x0)
    /usr/local/go/src/html/template/template.go:304 +0x40
github.com/dineshappavoo/test-proj/app.init()
    /Users/Dinesh/go/src/github.com/dineshappavoo/test-proj/app/server.go:625 +0x1ec
main.init()
    /Users/Dinesh/go/src/github.com/dineshappavoo/test-proj/main.go:9 +0x39

EDIT-I
I gave the absolute path for html templates. It worked. But css is not loading. I changed the following line.
http.Handle("/resources/", http.StripPrefix("/resources/", http.FileServer(http.Dir("/app/"))))

I am new to go language. Could anyone help me on this?


text:
Q: How do I simultaneously use two keyboards?
Possible Duplicate:
How to use two keyboards simultaneously on a single computer w/windows?

I prefer to type with one keyboard per hand. In my last job, I had a setup that worked using a macbook pro and the apple external keyboard plugged into a big apple monitor which then plugged into a special non-usb port on the macbook. Now I'm using a regular monitor and keyboard, but I can't use shift across the keyboards.
For example, I want to type a capital A. I hold down the shift key on one keyboard, and i press the 'a' key on the other. The result is a lower case a. It was by far the most comfortable typing I've ever done and I want to figure out how to continue to do it.

A: Simply connecting two keyboards should do it. On my notebook, I got a secondary usb keyboard connected - just tried and pressed 'shift' on the built-in keyboard and another literal on the usb keyboard - seems to work exactly as you described.
What does not work across keyboards is state changing keys - for example, pressing CapsLock on one keyboard will only affect that keyboard (this might vary by OS tho).


text:
Q: Can i run multiple instances of Android Monitor simultaneously? I have 2 android devices running 2 different versions of my app.
I want to monitor their memory usage etc. using Android Monitor.
The problem is that Android Monitor allows me to monitor only either one of them at a time.

I know i can run 2 instances of Android Studio and this way i get 2 instances of Android Monitor but i'm looking for a better solution.
So how can i monitor 2 devices simultaneously using the Android Monitor and only one instance of Android Studio?
Or maybe someone could point me to a third party software that can monitor android devices?
Cheers, Robert

A:
So how can i monitor 2 devices simultaneously using the Android Monitor and only one instance of Android Studio?

You can't. You can swap between the devices to see both, but there is no way to see both device's logs at the same time with only one AS instance


text:
Q: In a composite object, are almost identical functions in the parent and child objects common? Say I have a Timer object which has a TimerDisplay object as one of its properties. If I have a update(hours, minutes, seconds) method in the TimerDisplay object, which of the following (if any) are a good practice:

*

*have an updateDisplay(hours, minutes, seconds) method in the Timer, which calls the corresponding update method in the TimerDisplay

*allow a direct call to timer.timerDisplay.update(hours, minutes, seconds)

I'm just starting OO, by the way. The first seems to be more OO, but ends up with two almost identical methods. The second seems easier, but doesn't it go again encapsulation?
Thanks in advance

A: The direct access to timer.timerDisplay sounds like a bad idea (as public attributes are most of the time). If you don't want to have the timer class bother with comunicating with the timerDisplay, then why have timerDisplay be a property of a timer? Just have the same guy that is updating the timer own the display himself then.
On the other hand, if you want the Timer class to manage updating the display, then limiting it to managing only one display doesn't sound that good. Why not have it keep a list of displays to notify instead? If you choose to have the Timer do the communication like this, then hiding it behind the Timer.update method sounds best at least.
As an aside, if you don't like the TimerDisplay having methods too similar to the timer, perhaps you can use a simpler method like
TimerDisplay.updateFrom(timer)

using timer.getHours(), etc instead of passing tons of parameters everytime.

Lastly, depending on how complicated your problem is, you might get away with just fusing both classes into a single class. It is less modular, but simplicity also has its virtue.


text:
Q: Explanation about detecting end of line in C I'm reading/practicing with this book about C language: "C Programming - A Modern Approach 2" and I stumbled upon this piece of code whose explanation is odd to me:

Since scanf doesn't normally skip white spaces, it's easy to detect the end of an input line: check to see if the character just
  read is the new-line character. For example, the following loop
  will read and ignore all remaining characters in the current input
  line:

do {
    scanf("%c", &ch);
} while (ch != '\n');

When scanf is called the next time, it will read the first character on the next input line.

I understand the functioning of the code (it exits the loop when it detects enter or '\n') but not the lesson(?).
What is the purpose of this, since to store the input from the user into &ch you HAVE to press the enter key (quitting the loop)?
Also what does "the following loop will read and ignore all remaining characters in the current input line" mean actually?

A: ...What is the purpose of this...
For context in understanding what this code snippet can be used for, take a look at this link discussing stdio buffering.
In simplest logical terms, this technique consumes content placed in stdin until the newline character is seen. (From a user hitting the <enter> key.)  This is evidently the lesson.
This effectively clears the stdin buffer of content, also described in this more robust example.
Also what does

"the following loop will read and ignore all remaining characters in
  the current input line"

mean actually?
do {
    scanf("%c", &ch);
} while (ch != '\n');

It means that if the new char just read by scanf is not equal to the newline character, defined as \n, it will continue to overwrite c with the next read.  Once ch does equal \n, the loop will exit.


text:
Q: Possible to pass parameters to a skin? I have 2 skins, almost identical, but differ in 1 small way that can be accounted for if I could pass a Boolean to the skin while assigning it to the host component (a button).
<s:Button skinClass="MyBtnSkin" />

Is there a way while assigning the skin to the button, I could also pass a parameter to the skin somehow?

A: You have to create a Button subclass and add your custom boolean property in it.
<s:MyCustomButton skinClass"MyBtnSkin" customProperty="true" />

Updating your skin file when customProperty changes could be done with binding afterwards.
<Rect ... visible={hostComponent.customProperty}>


text:
Q: Converting UTC time to different time zone I want to convert UTC time to my desiered time zone, Im trying with the following code
        //inputDate - Timestamp (2016-10-15 12:30:00)
        //toZoneId -  Australia/Sydney

        ZonedDateTime utcDateTime = ZonedDateTime.ofInstant(inputDate.toInstant(), ZoneId.of("UTC"));
        Timestamp convertedTime = Timestamp.valueOf(utcDateTime.withZoneSameInstant(ZoneId.of(toZoneId)).toLocalDateTime());
        return convertedTime;

I get same "2016-10-15 12:30:00" as output not the UTC equivalent date time. What am I missing?


text:
Q: Jmeter: Requirement to Fetch aggregate response time of all the HTTP requests under a transaction controller for each iteration As per our project requirement , we have to write  response time of each transaction to a DB During our Load test.
For web services scripts , we are using prev.getTime() function in Beanshell  and write the response time of that transaction in a DB.
But for UI level scripts , we have to use transaction controller and under the transaction controller many HTTP requests are there. If we use prev.getTime() function it will fetch only the response time of last request .
If some one has solution for the  above requirement,  please share it...

A: If you're using Transaction Controller in Generate parent sample mode you can get the total duration of all nested samplers as prev.getParent().getTime()
See SampleResult.getParent() method JavaDoc for details.

I would recommend switching either to JSR223 Test Elements and Groovy language, since as when it comes to high loads Beanshell performance might be a big question mark. Groovy is Java-compliant (even more than Beanshell) so most likely you won't have to change a single line of code in order to migrate.
References:

*

*BeanShell Scripting

*JSR223 Elements

*Apache Groovy - Why and How You Should Use It


text:
Q: Error in creating a class header file I am attempting to create a simple class header file. I have done the following so far:
#ifndef RECORD_H
#define RECORD_H

class Records{
    int idNumber;
    int serialNumber;

public:
    Records();
};

#endif

However, I am getting the following error:

[Error] unknown type name 'class'

What am I doing wrong?

A: You're probably compiling it as C rather than C++. That is why you are getting that error..
Make sure your source file has a .cpp extension.

A: As lakesh said, you may to compiling as C rather than C++.  Most compiler use the file extension to determine how to compile the file (use .cpp instead of .c)
If that's not it, then the problem would probably be in the a different file loaaded before this.
    // Record.cpp
    #include "badfile.h"   // error in here
    #include "record.h"    // error showing up here.


text:
Q: Show that $n=(6k+1)(12k+1)(18k+1)$ is an absolute pseudoprime Prove that any integer of the form $n=(6k+1)(12k+1)(18k+1)$ is an absolute pseudoprime if all three factors are prime.
Proof: I am going to use this theorem to show that a number is a pseudoprime. Let n be a square-free number, say $n=p_1...p_r$ where $p_i$ are all distinct primes. If $p_i -1|n-1$ for $i= 1,2,....r$ then n is an absolute pseudoprime.
so by using this theorem I have $$ (6k+1)-1| n-1$$ $$(12k+1)-1|n-1$$ $$ (18k+1)-1|n-1$$. Now let's work on one equation at a time $$ (6k+1)-1= 6k| n-1$$
now i need to show that $$ 6k| n-1$$ this is where I am having difficulty. Any idea will be appreciated.

A: FACT 1 : If $p_1,...,p_m$ are $m$ distinct primes and $y\equiv 1 \pmod {p_j}$ for $ j\in \{1,...,m\}$ then $$y\equiv 1 \pmod {\prod_{j=1}^{j=m}p_j} .$$ FACT 2 :If $p$ is prime and $\gcd(p,x)=1$ then $$x^{p-1}\equiv 1 \pmod p, $$ $$\text {and so }  x^v\equiv 1 \pmod p $$ $$\text { whenever } (p-1)|v .$$ Now let $\{6k+1,12k+1,18k+1\}=\{p_1,p_2,p_3\} . $ Observe that  $(p_j-1) |(36k)$ for $j\in \{1,2,3\} ,$ and that $(36k)|(n-1). $ $$ $$ Therefore,  $\gcd(n,x)=1 \implies (\gcd (p_j,x)=1\text { for } j\in \{1,2,3\})$ $\implies (x^{36k}\equiv 1 \pmod {p_j}$ for $j\in \{1,2,3\}$ $\implies (x^{n-1}\equiv 1 \pmod {p_j}  \text{ for } j\in \{1,2,3\})$ $\implies x^{n-1}\equiv 1 \pmod {p_1 p_2 p_3}.$ $$. $$  In general $n$ is a pseudo-prime (a.k.a. Carmichael number) iff $n=\prod_{j=1}^{j=m}(p_j)$ where $\{p_1,...,p_m\}$ is a set of $m$ distinct odd primes with $m\geq 3$ and $LCM \{p_1-1,...,p_m-1\}$ is a divisor of $n-1$.

A: $$n=(6k+1)(12k+1)(18k+1)=6\cdot12\cdot13k^3+(6\cdot12+6\cdot18+12\cdot18)k^2+(6+12+18)k+1;$$
$$n-1=6\cdot12\cdot18k^3+(6\cdot12+6\cdot18+12\cdot18)k^2+(6+12+18)k;$$
$$\frac{n-1}{36k}=2\cdot18k^2+(2+3+6)k+1=36k^2+11k+1,\text{ an integer }.$$
So $n-1$ is divisible by $36k$, which is divisible by $6k$, by $12k$, and by $18k$.


text:
Q: конвертация flash в html 5 делаю по данной статье ссылка
const GOOGLE_API_URL = "https://www.googleapis.com/rpc?key=AIzaSyCC_WIu0oVvLtQGzv4-g7oaWNoc-u8JpEI";

header('Cache-Control: no-cache');
header('Content-Type: text/html; charset=UTF-8', true);
if($_FILES['f']['tmp_name']){
    $content =  file_get_contents($_FILES['f']['tmp_name']);
    print_r($content);
    $content = str_replace('+','-',base64_encode($content));
    $content = str_replace('/','_',$content);
}
else{
    return false;
}

$request_data = array(
    'apiVersion' => 'v1',
    'method ' => 'swiffy.convertToHtml',
    'params' => array(
        'client' => 'Swiffy Flash Extension',
        'input'  => $content
    )
);
$json = json_encode($request_data);
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, GOOGLE_API_URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
if (curl_errno($ch)) {
    print_r(curl_error($ch));
}
print_r($response);

мне постоянно возвращает такой ответ{"error":{"code":-32700,"message":"Parse Error","data":[{"domain":"global","reason":"parseError","message":"Parse Error"}]}}

A: 'method ' => 'swiffy.convertToHtml',

был лишний пробел, из-за которого все валилось,
нужно:
'method' => 'swiffy.convertToHtml',


text:
Q: Check if a directory contains only subdirectories and no files I have a directory which has subdirectories like this:
C:\FILES
C:\FILES\DONE

I want to check that FILES contains no files:
if not exist C:\FILES\*.* (
  echo No files to process.
  exit /b
)

But the test "not exist ..." is never true because of the subdirectory.
Any ideas on how to check if the directory has any files that are not directories?

A: Try to get the list of files and if it fails, there are no files
dir /a-d "c:\files\*" >nul 2>nul || (
    echo No files to process
    exit /b
)

If there are no files, the dir /a-d command (the switch means exclude directories) will fail. || is a conditional execution operator that will execute the following commands if the previous one has failed.

A: Only when there are files, the for execute the goto.
for %%a in (C:\FILES\*.*) do goto files
echo No files to process.
exit /b

A: Simple code:
for /f "delims=|" %%f in ('dir /b c:\FILES\') do goto :files
echo No files found
pause
goto:eof
:files
echo Files found
pause
goto:eof

A: If you want to check if exists sub-directories on this level:
(DIR /D "C:\FILES\" | findstr /i /p /r /c:"2 Directory" > nul 2> nul) && echo "No directories except current and parent."

This simple inline command could be easy adapted for any situation ;-)

A: Try
if not exist dir c:\FILES\*.* /a:-d (

You can find more on dir here
PS
I do not have DOS at my reach. So I can't test the above code snippet. But I think it is close to what you are looking for.If not something very close to that should work.


text:
Q: Change background based on different hovered element When hovering on each circle at the corner, background color in the main area should be changed so matches the color of the circle, and there is an adequate paragraph showing at the same time.
I have tried transition, opacity... but couldn't get it work.
Note, HTML has to be untouched.

* {
  margin: 0;
  padding: 0;
}

body {
  position: relative;
  height: 100vh;
  text-align: center;
}

p {
  font-family: Arial, Helvetica, sans-serif;
  color: white;
}

.bg {
  position: relative;
  height: 100vh;
  background-color: #333;
}

.circle {
  height: 10px;
  width: 10px;
  border-radius: 50%;
  border: white solid 2px;
  z-index: 1;
}

.red.circle {
  position: absolute;
  top: 10%;
  left: 10%;
  background-color: red;
}

.green.circle {
  position: absolute;
  top: 10%;
  right: 10%;
  background-color: green;
}

.blue.circle {
  position: absolute;
  bottom: 10%;
  left: 10%;
  background-color: blue;
}

.orange.circle {
  position: absolute;
  bottom: 10%;
  right: 10%;
  background-color: orange;
}

p.red {
  display: none;
  background-color: red;
  line-height: 100vh;
}

p.green {
  display: none;
  background-color: green;
  line-height: 100vh;
}

p.blue {
  display: none;
  background-color: blue;
  line-height: 100vh;
}

p.orange {
  display: none;
  background-color: orange;
  line-height: 100vh;
}

Czerwony

Zielony

Niebieski

Pomarańczowy

A: Since they are somewhat in the same hierarchy, you can take advantage of the ~ general sibling selector which matches the second element only if it follows the first element (though not necessarily immediately):

/* added */

.red.circle:hover ~ .bg  {
  background-color: red;
}
.green.circle:hover ~ .bg {
  background-color: green;
}
.blue.circle:hover ~ .bg {
  background-color: blue;
}
.orange.circle:hover ~ .bg {
  background-color: orange;
}
.red.circle:hover ~ .bg p.red { display: block; }
.green.circle:hover ~ .bg p.green { display: block; }
.blue.circle:hover ~ .bg p.blue { display: block; }
.orange.circle:hover ~ .bg p.orange { display: block; }
/* end of edit */

* {
  margin: 0;
  padding: 0;
}

body {
  position: relative;
  height: 100vh;
  text-align: center;
}

p {
  font-family: Arial, Helvetica, sans-serif;
  color: white;
}

.bg {
  position: relative;
  height: 100vh;
  background-color: #333;
  transition: background-color 0.5s ease-in;
}

.circle {
  height: 10px;
  width: 10px;
  border-radius: 50%;
  border: white solid 2px;
  z-index: 1;
}

.red.circle {
  position: absolute;
  top: 10%;
  left: 10%;
  background-color: red;
}

.green.circle {
  position: absolute;
  top: 10%;
  right: 10%;
  background-color: green;
}

.blue.circle {
  position: absolute;
  bottom: 10%;
  left: 10%;
  background-color: blue;
}

.orange.circle {
  position: absolute;
  bottom: 10%;
  right: 10%;
  background-color: orange;
}
p {
  transition: background-color 1s ease-in;
}
p.red {
  display: none;
  background-color: red;
  line-height: 100vh;
}

p.green {
  display: none;
  background-color: green;
  line-height: 100vh;
}

p.blue {
  display: none;
  background-color: blue;
  line-height: 100vh;
}

p.orange {
  display: none;
  background-color: orange;
  line-height: 100vh;
}

Czerwony

Zielony

Niebieski

Pomarańczowy

You can add transition on the .bg class for the desired effect.

A: I would simplify your code to rely on pseudo element and data-attribute for background and content. It will be then easier to control as you don't need any complex selector:

body {
  margin: 0;
  background: #333;
  min-height: 100vh;
}

.circle {
  position: absolute;
  height: 10px;
  width: 10px;
  border-radius: 50%;
  border: white solid 2px;
}

.circle::before {
  content: attr(data-text);
  font-family: Arial, Helvetica, sans-serif;
  text-align: center;
  color: white;
  line-height: 100vh;
  font-size: 80px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -2;
  background: inherit;
  opacity: 0;
  transition: 1s;
}

.circle:hover::before {
  opacity: 1;
}

.circle.red {
  top: 10%;
  left: 10%;
  background: red;
}

.circle.green {
  top: 10%;
  right: 10%;
  background: green;
}

.circle.blue {
  bottom: 10%;
  left: 10%;
  background: blue;
}

.circle.orange {
  bottom: 10%;
  right: 10%;
  background: orange;
}

A: The css only solution of @soulshined is great, but just in case anyone wants to use javascript - here's a hint:
const bg = document.querySelector(".bg");
const circles = document.querySelectorAll(".circle");

circles.forEach(circle => circle.addEventListener("mouseenter", (e) => {
  const style = getComputedStyle(e.target);
  const backgroundColor = style.backgroundColor;

  bg.style.backgroundColor = backgroundColor;
}))


text:
Q: How is possible to set up hibernate programmatically Sorry, I am curious if is possible (and if it is, how is possible) to set up the database on what is hibernate working from a running web application, well something like to modify properties.xml or hiberanete.xml from a page of the site.
Thank you,
Vlad.


text:
Q: Reconstruction Conjecture: Group theoretic formulation As we read from wiki, informally, the reconstruction conjecture in graph theory says that graphs are determined uniquely by their subgraphs.

*

*Is there a group-theoretic formulation of this conjecture?

*Has an analogous conjecture been made in group theory(in any sensible way)?

References such as books will do, thanks.

A: There are continuum 2-generated groups where all proper subgroups are cyclic of order $p$ (for the same prime $p\sim 10^{70}$), the Tarski monsters. All these groups have the same lists of proper subgroups, and the same lattice of subgroups. Also all cyclic groups of prime order have the same proper subgroups: the trivial group. So in general the answer is "no". But every finite non-cyclic abelian group is determined by the list of its proper subgroups, which follows easily from the description of finite abelian groups (note that I and, I think, the question, are not talking about the lattice of subgroups, but about the list of all proper subgroups). I suspect that at least for a large class of finite solvable groups, the list of proper subgroups determines the group. I would look first at A-groups, finite groups with all Sylow subgroups abelian (see the book of Huppert, "Endliche Gruppen") because the structure of subgroups of A-groups is more known, and one can use induction on the order of the group.


text:
Q: a six-sided die problem
Is this problem wrong? Because I think from ordinary die space we can get results like(5,5), but we can never get results like this from the given space in this problem.

A: As the comments have said, we already have an approach for solving the problem. Let me be a little more elaborate.
Let the numbers be $a,b,c,d,e,f$.
1) First of all, $12$ can only come on one occasion on an ordinary dice $(6+6)$, and no number greater than 12 appears. That tells you that $f=8$, so that $4+8=12$ is the only possibility.
2) Similarly, for $2$ coming only on one occasion, $a=1$.
3) For $3$ coming on two occasions, the two occasions are already covered, because $a=1$ and the first dice has two $2$s. Hence there is no $2$.
4) $4$ comes on three occasions. Now, two of these are covered, because $a=1$ and there are two threes in the first dice. The third case is covered by $b=3$ and the one on the first dice.
5) Five comes on four occasions. Two occasions are $b=3$ and the two $2$s. Another occasion is $a=1$ and the $4$ on the first dice. For one more occasion, let $c=4$, then we are done with the fourth situation, namely $c=4$ and the $1$ on the first dice.
6) Six comes on five occasions. Two of these are covered by $c=4$ and the two $2$s on the first dice. Two more are covered by $b=3$ and the two 3s on the first dice. To cover one more case, we must either have $d=5$ or $d=2$ (for 1 or 4 on the first dice respectively). We take $d=5$, because we ruled out $2$ being on the second dice, in the third step above.
7) Seven comes on six occasions. Two are covered by $d=5$ and the two 2s on the first dice. Two are covered by $c=4$ and the two 3s on the first dice. One case is covered by $b=3$ and the 4 on the first dice. Now, to cover the last case, set $e=6$, that gives you the last case, namely $e=6$ and $1$ on the first dice.
Now, the dice reads $1,3,4,5,6,8$.
Let us separate out the cases to make sure:
$2 \rightarrow 1+1$
$3 \rightarrow 2+1,2+1$
$4 \rightarrow 3+1,3+1,1+3$
$5 \rightarrow 4+1,2+3,2+3,1+4$
$6 \rightarrow 3+3,3+3,2+4,2+4,1+5$
$7 \rightarrow 4+3,3+4,3+4,2+5,2+5,1+6$
$8 \rightarrow 4+4,3+5,3+5,2+6,2+6$
$9 \rightarrow 4+5,3+6,3+6,1+8$
$10 \rightarrow 4+6,2+8,2+8$
$11 \rightarrow 3+8,3+8$
$12 \rightarrow 4+8$
That's the same distribution! Hence your second dice should have $1,3,4,5,6,8$.
Furthermore, by the above procedure, I have shown your answer is unique, so that answers a question in the comments as well.

A: Hint: We can assume $a \le b \le c \le d \le e \le f$ Start at the ends.  You need $\frac 1{36}$ chance to get $2$ and $12$, so $a=1, f=8$  Now think about the chances you need to get numbers like $3,4,10,11$ and see what that tells you about the numbers.


text:
Q: Не работают эмулятор для Android Не могу запустить эмуляторы: Genymotion после запуска вылетает, либо вообще не запускает, а эмулятор от Android Studio после прогрузки "Starting AVD" ничего не выдаёт.
Система: Ubuntu 16.04;

A: Проблема с libGL
Необходимо установить
sudo apt-get install lib64stdc++6:i386
sudo apt-get install mesa-utils

Найти путь к Android SDK и прилинковать файл
cd SDKPATH/Android/Sdk/emulator/lib64
mv libstdc++/ libstdc++.bak
ln -s /usr/lib64/libstdc++.so.6  libstdc++

Если не запустится, ещё есть вариант подгрузить библиотеку при запуске студии, для этого необходимо прописать первой строкой в studio.sh
export LD_PRELOAD='/usr/lib/x86_64-linux-gnu/libstdc++.so.6'

Если и это не поможет, то можно запустить эмулятор вручную с подгруженной библиотекой
LD_PRELOAD='/usr/lib/x86_64-linux-gnu/libstdc++.so.6' SDKPATH/tools/emulator -netdelay none -netspeed full -avd <avd_name>

где avd_name название эмулируемого устройства


text:
Q: Unresolved reference error when importing basic modules on Pycharm 4.0.1 and OS X Yosemite 10.10.1 After upgrading PyCharm to version 4.0.1 and OS X Yosemite to version 10.10.1, I encountered the following problem:
When trying to import basic modules, e.g: import time or import sys, PyCharm marks the import as an "Unresolved reference" (red underline) and does not recognise the module name.
When trying to figure it out, I noticed that while writing the module name the auto completion pop up is finding a match on the 'lib-dynload' folder within my virtualenv path (/Users/myname/Envs/envname/lib/python2.7/lib-dynload) rather than on the 'site-packages' folder.
There are also added to the PYTHOPATH in this order (lib-dynload before site-packages).
As a workaround I removed the lib-dynload path from the "project interpreter" setting window in PyCharm which made PyCharm recognise the basic modules again, but I am not sure what other impacts this change might have.
My Question is whether there is a way to reproduce the original behaviour PyCharm had so it would recognise the basic modules without tampering the paths of the virtualenv used as a project interpreter.
I am using a separate installation of Python (/usr/local/Cellar/python/2.7.6/bin/python) and virtualenv version 1.10.1.

A: I'm using pycharm 4.0.1 and virtualenv 1.11.6 and everything works fine to me, but i'm on Arch Linux not OSX.
You may try to recreate the virtualenv, and invalidate and restart the pycharm cache, then wait for pycharm to index again your virtualenv.
Don't know if this is too much of a hassle to you, maybe it is worth a try.
This is a django project tree i tried:

A: This is probably a bug, a recent youtrack issue seems to match your problem.


text:
Q: Region eu-west-2 not available for aws module boto.ec2 latest I'm running boto with python3 and I'm running an ansible playbook to setup some ec2 instances.
Everything is fine, creating instances, security groups, key pairs, everything in eu-west-2.
When the task for Elastic IPs runs it fails with this message:
Region eu-west-2 does not seem to be available for aws module boto.ec2. If the region definitely exists, you may need to upgrade boto or extend with endpoints_path
I'm running ansible with -e ansible_python_interpreter="/usr/bin/python3".
I have latest boto installed.
> python3 -m pip freeze | grep boto
 boto==2.44.0
 boto3==1.4.2
 botocore==1.16.19
> python3
 >>> import boto.ec2
 >>> for i in boto.ec2.regions():
 ...   print(i)
 ...
 RegionInfo:ap-northeast-1
 RegionInfo:ap-northeast-2
 RegionInfo:ap-south-1
 RegionInfo:ap-southeast-1
 RegionInfo:ap-southeast-2
 RegionInfo:ca-central-1
 RegionInfo:cn-north-1
 RegionInfo:eu-central-1
 RegionInfo:eu-west-1
 RegionInfo:sa-east-1
 RegionInfo:us-east-1
 RegionInfo:us-east-2
 RegionInfo:us-gov-west-1
 RegionInfo:us-west-1
 RegionInfo:us-west-2

You see that it's missing the eu-west-2 region ? It should be there. Any ideas ?
The ansible module I'm using is ec2_eip. If this is a limitation of boto how do I force boto3 for that module ?

A: I resorted to using the community module for elastic ip.
So community.aws.ec2_eip instead of ec2_eip.


text:
Q: Objective-C - Receiver type 'NSInteger' (aka 'long') is not an Objective-C class & Receiver type 'NSDecimal' is not an Objective-C class I am getting the errors in title and I have no idea why....
.h
@interface ItemData : NSObject

@property (nonatomic,assign) NSInteger tagId;
@property (nonatomic,strong) NSMutableString *deviceId;
@property (nonatomic,strong) NSDecimal *latitude;
@property (nonatomic,strong) NSDecimal *longitude;

@end

.m
#import <Foundation/Foundation.h>
#import "ItemData.h"

@implementation ItemData

-(id)init
{
    if(self = [super init])
    {
        //TODO: Fix Commented out items

        _tagId = [[NSInteger alloc] init];
        _deviceId = [[NSMutableString alloc] init];
        _latitude = [[NSDecimal alloc] init];
        _longitude = [[NSDecimal alloc] init];

    }
    return self;
}

@end

I dont understand what I am doing wrong...can someone help me out?

A: NSInteger and NSDecimal are no classes, but the type of scalars. You cannot sent messages to "objects" (in the sense of C, not in the sense of OOP) of this type. Therefore you do not construct them with +alloc and -init….
You have two possibilities:
A. Use (OOP) objects instead of scalars
@property (nonatomic,assign) NSNumber *tagId;
@property (nonatomic,strong) NSDecimalNumber *latitude;

Then you can assign references to objects as usual:
_tagId = @0; // Or whatever you want.
_latitude = [NSDecimalNumber zero];

B. Simply assign a value
_tagId = 0; // Or whatever you want. There is no nil for integers

This works good for integers, but bad for decimals, since they are a struct with private components and there is no function to create them. However, you can create an NSDecimalNumber instance object (as in A.) and get the decimal value with -decimalValue.
_latitude = [[NSDecimalNumber zero] decimalValue];

The usage of NSDecimal seems to be erroneous for me. Why do you want to use it? Usually longitude and latitude are double, another scalar type, which can be treated as integers with values. Decimal floating point objects are for use in finance software.

A: NSInteger is
typedef long NSInteger;

That should explain "NSInteger (aka 'long')" and it is equivalent
 64-bit long (long int) C data type. It is not an OC class, that's why you can't do (+)alloc and (-)init.


text:
Q: Sencha too slow I introduced Sencha grid in one of my JSPs. Locally sencha is quite fast but on an external server it is too slow.
I followed deploy instructions here
http://docs.sencha.com/ext-js/4-0/#!/guide/getting_started
using ext-debug.js and my app.js.
Then, in my JSP, I imported app-all.js (670KB) and ext.js

Where am I wrong ?
Thanks

A: app-all.js is 670KB, which is a very big file. You should refactor, optimize and minify the code so it will be smaller. You could even separate into multiple files per class or implementation and do a dynamic js load (but that would take more time). A good target would be as small as ext.js's.
Also if you have access to your webserver (i.e. Apache/Tomcat), you could turn on gz compression to compress files before sending to browsers. Also look out for other webserver optimizations.
(btw, your question sounds more like a webserver issue rather than a sencha related issue).

A: Another way to improve the load time of your application is making sure ext.js and app-all.js are cached by the browser. This way the first time your application loads it will be slow, but the following loads will be faster.
Look into the cache-control, expires and other HTTP cache controlling headers (this appears to be a nice explanation). Your server should generate this headers when sending the files you want to be cached.
The real problem, as it appears from the timeline, is the slow connection to the server (10 seconds loading 206/665 KB is slow for most connections), so you should see if there are no other server problems causing the slowness.


text:
Q: Sharepoint workflows show as rejected eventhough everyone has approved Two approvals via workflow show as rejected.  I don't know understand why as I believe everyone has provided their approval.
but  i could see one of the approver accidently deleted the doc and then again she added the doc and approved it under view workflow reports.
I believe that could be the reason for the rejection..AM not sure.. please clarify me.
Instead of recreating the workflow how make the workflow to be approved because we cant ask the people to approve it again.
Experts, please provide your inputs on this...
It would be nice if you update on this ASAP.

A: If you created this in SharePoint Designer, try setting the variable "IsItemApproved" to yes.

*

*Edit workflow

*Change behavior of single task

*Go to "When a Task Completes" step

*In the first section "If current task:Outcome equals Approved"

*Add a "Set Workflow Variable Action"

*Choose "IsItemApproved" from the variable dropdown.

*Set this variable to "Yes"

A: The OOTB Approval workflow stop (by showing either Rejected or Cancelled) the process as soon as someone changes the document (including Deletion). Also, while configuring the workflow you get the chance to change to specify this behavior via a check-box.


text:
Q: Is there some short formula for the "defect" of Hilbert function Let $X\subset\Bbb P^n_{\Bbb C}$ be a connected, Cohen Macaulay sub-scheme. (Possibly singular, reducible or non-reduced.) For $k\gg0$ the numbers $h^0(\mathcal{O}_X(k))$ depend polynomially on $k$. Denote this polynomial by $P(k):\stackrel{k\gg0}{=}h^0(\mathcal{O}_X(k))$ .
What is the geometric meaning of the "total defect" $\sum_{k\ge0}\Big(h^0(\mathcal{O}_X(k))-P(k)\Big)$?
e.g. if $X\subset\Bbb P^n_{\Bbb C}$ is a hypersurface of degree $d$ then this total defect is ${d\choose{n}}$, which can be interpreted in various ways. (Arithmetic genus, Euler characteristic etc.) Similarly for complete intersections. Is there some general statement? A reference?
I guess this defect is constant under flat deformations of $X$ in $\Bbb P^n$, and I'm interested in the smoothable case. So probably can assume $X$ smooth? (Does this help?)
upd. (I guess it helps.) In my case the embedding of $X$ is projectively normal. (Alternatively, $\mathcal{O}_X(k)$ is normally generated.)


text:
Q: Registering Serviceworker in Laravel I'm using pushpad (from pushpad.xyz) and followed the 3 initial steps to setup this SDK with my Laravel 5.5 Project.
But as soon as I visit a test view it just cannot find and register the Serviceworker.js
i tried placing it all over the place, almost in every folder now. So i know this is vaguely described but if you take a quick look at the Docs from pushpad you know what I mean.
Moreover, when i manually try to open it i get a 404.
also getting 404 when i try to import it via  from the https:// link where its located
when i copy its content and use it in a script tag i also get a 404.
im quite clueless as how to proceed
A bad HTTP response code (404) was received when fetching the script.
Failed to load resource: net::ERR_INVALID_RESPONSE
push-test:1 Uncaught (in promise) TypeError: Failed to register a
ServiceWorker: A bad HTTP response code (404) was received when fetching the
script.

A: You need to make sure that you have a service-worker.js file in the root directory of your website.
You can verify the installation by typing https://example.com/service-worker.js in your browser.


text:
Q: Show that an integral does not exists Consider the following integral :
$$\int_{-\infty}^{+\infty}\Big | \frac{e^{i(\omega+\omega_0)\frac{N\pi}{\omega_0}}e^{i\omega t}}{\omega+\omega_0}\Big |d\omega$$
I have to show that this integral does not exists. My attempt :
I have
$$\int_{-\infty}^{+\infty}\Big | \frac{e^{i(\omega+\omega_0)\frac{N\pi}{\omega_0}}e^{i\omega t}}{\omega+\omega_0}\Big |d\omega=\int_{-\infty}^{+\infty}\frac{1}{\mid \omega+\omega_0\mid}d\omega\geq \int_{-\infty}^{\infty}\frac{1}{\mid \omega\mid}d\omega$$
But then, I don't really know what to do with the last integral. Can I split it ? Like this :
$$\int_{-\infty}^{\infty}\frac{1}{\mid \omega\mid}d\omega=\int_{0}^{\infty}\frac{1}{ \omega}d\omega-\int_{-\infty}^{0}\frac{1}{ \omega}d\omega$$
Before splitting an integral, don't we have to show that it exists ? Here I am not sure if $\int_{-\infty}^{+\infty}1/(\mid \omega \mid)d\omega$ exists... Any help would be appreciated,

A: For complex $\omega_0$, it can be not trivial to get $\int_{-\infty}^{+\infty}\frac{1}{\mid \omega+\omega_0\mid}d\omega\geq \int_{-\infty}^{\infty}\frac{1}{\mid \omega\mid}d\omega$ directly.
However, you can definitely say $\int_{-\infty}^{+\infty}\frac{1}{\mid \omega+\omega_0\mid}d\omega\geq \int_{2|\omega_0|}^{\infty}\frac{1}{\mid \omega\mid}d\omega$ (we reduce integration area, and function is non-negative), then say  $\int_{2|\omega_0|}^{\infty}\frac{1}{\mid \omega\mid}d\omega \geqslant \int_{2|\omega_0|}^{+\infty} \frac{1}{2\omega}d\omega$ (replace function with strictly lower), and the last integral obviously diverges (we can explicitly find it).
In general, if your function is non-negative (or non-positive), you can split the integral - the original integral converges iff all parts converges. Equally - integral converges absolutely iff all parts converges absolutely
If function changes sign, then it's possible for integral to converge but parts to diverge - for example, $\int_0^\infty\frac{\sin x}{x}\, dx$ converges, but $\int_{\{x: \sin(x) > 0\}} \frac{\sin x}{x}\, dx$ and $\int_{\{x: \sin(x) \leq 0\}} \frac{\sin x}{x}\, dx$ both diverge.


text:
Q: C++ method overriding Is the Wikipedia example at this article about method overiding in C++ correct?
Please see the code below where I have mentioned a comment //INCORRECT
Slightly confused about overiding in C++ and run time polymorphism. What should this cast do?
#include <iostream>

class Rectangle {
public:
    explicit Rectangle(double l, double w) : length(l), width(w) {}
    virtual void print() const;

private:
    double length;
    double width;
};

void Rectangle::print() const { // print() method of base class
   std::cout << "Length = " << this->length << "; Width = " << this->width;
}

class Box : public Rectangle {
public:
    explicit Box(double l, double w, double h) : Rectangle(l, w), height(h) {}
    virtual void print() const; // virtual is optional here, but it is a good practice to remind it to the developer

private:
    double height;
};

void Box::print() const { // print() method of derived class
   Rectangle::print();  // Invoke parent print() method.
   std::cout << "; Height= " << this->height;
}

int main(int argc, char** argv) {
   Rectangle rectangle(5.0, 3.0);   rectangle.print();
   // outputs:
   // Length = 5.0; Width = 3.0

   Box box(6.0, 5.0, 4.0);
   // the pointer to the most overridden method in the vtable in on Box::print
   //box.print(); // but this call does not illustrate overriding

   static_cast<Rectangle&>(box).print(); // this one does

   // outputs:
   // Length = 5.0; Width = 3.0; Height= 4 // INCORRECT

   //But it actually outputs Length = 6; Width = 5; Height = 4

   getchar();
   return 0;

}

A: You're right - the output mentioned is incorrect.
The cast simply demonstrates that a box is a kind of rectangle (inheriting from it) and that even as a rectangle, the method override will still be effective and the Box version of the print method will be called.

A: Feel free to fix the comment in Wikipedia: the output should indeed be Length = 6; Width = 5; Height = 4.
The other part is correct, though: the code where a Box.print() is called even after the Box reference has been statically cast to a reference to its superclass is indeed a demonstration of how overriding of a virtual method works in C++.
Another way to demonstrate the same point is through use of a pointer instead of a reference:
Rectangle *boxPtr = &box;
boxPtr->print();

A: The comment in the article was indeed wrong (and has now been fixed); it should have printed 6,5, and 4 as you say.
The point of the cast is to demonstrate that, even if you call the virtual function via a reference to the base class (Rectangle), it will call the override associated with the actual type of the object (Box) - you still get the three values printed by Box::print(), rather than the two printed by Rectangle::print().

A: this line: static_cast<Rectangle&>(box).print(); has same effect as this code would have:
Rectangle & r = box;
r.print();

and also same effect as this code would have:
Rectangle * r = &box;
r->print();

It means that Box object was created (Box box(6.0, 5.0, 4.0); = in runtime you see Box) and it doesn't matter what is the type of pointer / reference where you store this object. The fact that you store box as a Rectangle* is what you see in compile time.
Most important fact about overriding virtual methods is that about "which method will be called?" is decided in runtime.
Hope this helps.


text:
Q: Why list can not act as function to get its indexed element in clojure? Vector and map can act as function to get its elements from key
([1 2 3] 2) ;=> 3
({:a 1 :b 2} :a) ;=> 1

but why I can not do this for list?
('(1 2 3) 2)
;clojure.lang.PersistentList cannot be cast to clojure.lang.IFn(java.lang.ClassCastException)

A: I think the error message is pretty descriptive in this case. Persistent list doesn't implement IFn, therefore cannot act as function. This is Clojure design choice and the reason may be that List datastructure is not designed for random access (getting element by index), because complexity of this operation is O(n), which is much worse than vector's O(log(n)).


text:
Q: OnLongKeyPress event on Android does not seem working I am trying to capture a long-key press in my application. I tried event tracking but does not seem working. Here is my code block:
public override bool OnKeyLongPress([GeneratedEnum] Android.Views.Keycode keyCode, KeyEvent e)
{

    if (e.KeyCode == Android.Views.Keycode.Num7)
    {
        return true;
    }
    return base.OnKeyLongPress(keyCode, e);
}

public override bool OnKeyUp([GeneratedEnum] Android.Views.Keycode keyCode, KeyEvent e)
{

    if (e.KeyCode == Android.Views.Keycode.Num7)
    {
        if (e.IsTracking && e.IsLongPress)
        {

        }

        return true;
     }
     return base.OnKeyUp(keyCode, e);
}

public override bool OnKeyDown([GeneratedEnum] Android.Views.Keycode keyCode, KeyEvent e)
{

    if (e.KeyCode == Android.Views.Keycode.Num7)
    {
        if (e.IsTracking && e.IsLongPress)
        {

        }

        return true;
     }
     return base.OnKeyUp(keyCode, e);
}

I do not receive IsLongpress as true at all even if I hold the key for more than 3 secs


text:
Q: How take date in class constructor? have json
{"id":1,"name":"123","dateoff":"2016-01-12T13:30:46.358+05:00","available":true}

and have class
export class Compaing {
    constructor(public id: number, public name: string,
                public dateoff: Date, public available:boolean) { }
}

But when i use in angular2
<Compaing>res.json()

It dont work. In compaing.dateoff not date, it's string.
How parse json string date to Date with constructor?

A: You could try something like this:
export class Compaing {
    dateoff:Date;
    constructor(public id: number, public name: string,
                public dateoffstr: string, public available:boolean)        {
       this.dateoff =new Date(dateoffstr);
    }
}


text:
Q: How to decide where the click area should be I am creating some thumbnails for my portfolio and wonder if someone can assist me in getting the whole dotted are clickable instead of the "view project" button. Same result for large,medium and small view ports.
I have attached an image and also the code that I am using
Thank you.
See final result here:

$(function(){$("#navi a").on("click",function(a){a.preventDefault,$("ul.grid").removeClass().addClass("grid").addClass($(this).attr("data-value"))})});
.grid figure {
    margin: 0;
    position: relative
}

.grid figure img {
    max-width: 100%;
    display: block;
    position: relative
}

.grid figcaption {
    position: absolute;
    top: 0;
    left: 0;
    padding: 20px;
    background: #2c3f52;
    color: #b2b2b2
}

.grid figcaption h4 {
    margin: 0;
    padding: 0;
    color: #fff
}

.grid figcaption a {
    text-align: center;
    font-weight: 500;
    padding: 10px 20px;
    border-radius: 2px;
    display: inline-block;
    background: #d5dee8;
    color: #000
}

.cs-style-1 figcaption {
    height: 100%;
    width: 100%;
    opacity: 0;
    text-align: center;
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transition: -webkit-transform .3s, opacity .3s;
    -moz-transition: -moz-transform .3s, opacity .3s;
    transition: transform .3s, opacity .3s
}

.cs-style-1 figure:hover figcaption,
.no-touch .cs-style-1 figure:hover figcaption {
    opacity: 1;
    -webkit-transform: translate(15px, 15px);
    -moz-transform: translate(15px, 15px);
    -ms-transform: translate(15px, 15px);
    transform: translate(15px, 15px)
}

.cs-style-1 figcaption h4 {
    margin-top: 12%
}

.cs-style-1 figcaption span {
    display: block
}

.cs-style-1 figcaption a {
    margin-top: 20px
}

@media screen and (max-width:31.5em) {
    .grid {
        padding: 10px 10px 100px
    }
    #navi,
    .grid li {
        width: 100%;
        min-width: 300px
    }
}

*,
:after,
:before {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box
}

Changi

Art Direction
View project

A:

Changi

                Art Direction

View project

And in your CSS, you would have to modify this selector .grid figcaption a with this:
.grid figcaption .button {
    text-align: center;
    font-weight: 500;
    padding: 10px 20px;
    border-radius: 2px;
    display: inline-block;
    background: #d5dee8;
    color: #000;
    border: none;
}


text:
Q: Fluent UI DetailsList - Is there a way to add filters to each column I am using Fluent UI DetailsList. My table looks like below:

I need filters below every column (text or drop-down) as shown below:

Please let me know if this is possible? Or maybe a way to display custom header (using html) ?

A: This actually turned out to be easier than I thought it'd be...
If you're ok with clicking the column header to reveal the choices (vs having the dropdown  directly under the title) then this can be achieved using the ContextualMenu component in conjunction with DetailsList. I got it working by tweaking from the variable row height example in the official docs: https://developer.microsoft.com/en-us/fluentui#/controls/web/detailslist/variablerowheights.
Add a ContextualMenu underneath your DetailsList:
<DetailsList
    items={items}
    columns={columns}
/>
{this.state.contextualMenuProps && <ContextualMenu {...this.state.contextualMenuProps} />}

Inside your column definition, set the hasDropdown action so the user gets a UI indicator that they can/should click the header, and call a contextMenu method (note I'm using onColumnContextMenu as well as onColumnClick so it doesn't matter if they left or right click the header:
{
    key: 'dept',
    name: 'Department',
    fieldName: 'dept',
    minWidth: 125,
    maxWidth: 200,
    onColumnContextMenu: (column, ev) => {
        this.onColumnContextMenu(column, ev);
    },
    onColumnClick: (ev, column) => {
        this.onColumnContextMenu(column, ev);
    },
    columnActionsMode: ColumnActionsMode.hasDropdown,
}

When the onColumnContextMenu method gets invoked, we need to build the context menu properties that will get consumed by the ContextualMenu component. Note the dismissal method as well, which clears out the state so the menu is hidden.
private onContextualMenuDismissed = (): void => {
    this.setState({
        contextualMenuProps: undefined,
    });
}

private onColumnContextMenu = (column: IColumn, ev: React.MouseEvent<HTMLElement>): void => {
    if (column.columnActionsMode !== ColumnActionsMode.disabled) {
        this.setState({
            contextualMenuProps: this.getContextualMenuProps(ev, column),
        });
    }
};

Finally, inside of getContextualMenuProps you need to determine what the options should be for the user to click. In this example, I'm simply giving sort options (you'll need to add an onClick handler to actually do something when the user clicks the item), but I'll use the column to determine what those items should actually be and paint the filters into the items collection so the user can select one to filter.
private getContextualMenuProps = (ev: React.MouseEvent<HTMLElement>, column: IColumn): IContextualMenuProps => {
    const items: IContextualMenuItem[] = [
        {
            key: 'aToZ',
            name: 'A to Z',
            iconProps: { iconName: 'SortUp' },
            canCheck: true,
            checked: column.isSorted && !column.isSortedDescending,
        },
        {
            key: 'zToA',
            name: 'Z to A',
            iconProps: { iconName: 'SortDown' },
            canCheck: true,
            checked: column.isSorted && column.isSortedDescending,
        }
    ];

    return {
        items: items,
        target: ev.currentTarget as HTMLElement,
        directionalHint: DirectionalHint.bottomLeftEdge,
        gapSpace: 10,
        isBeakVisible: true,
        onDismiss: this.onContextualMenuDismissed,
    }
}

Note the target on the ContextualMenuProps object, which is what tells the ContextualMenu where to lock itself onto (in this case, the column header that you clicked to instantiate the menu.

A: Detail list filter for each column without context menu -
https://codesandbox.io/s/rajesh-patil74-jzuiy?file=/src/DetailsList.CustomColumns.Example.tsx
For instance - Providing filter in text field associated with each column will apply filter on color column.


text:
Q: Binary radix sort not working with unsigned char for bigger amounds of numbers void Counting_Sort(vector<unsigned char>& A, unsigned int k)
{
    vector<unsigned char> C(2);
    for (int i = 0; i < A.size(); i++)
        C[(A[i]>>k)&1]++;

    C[1] += C[0];

    vector<unsigned char> B(A.size());
    for (int i = A.size() - 1; i >= 0; i--)
    {
        B[--C[(A[i] >> k) & 1]] = A[i];
    }

    swap(A, B);
}

 void Binary_Radix_Sort(vector<unsigned char>& A)
 {
     for (int k = 0; k < 8; k++)
     {
         Counting_Sort(A, k);
     }
 }

 int main(int argc, const char* argv[])
 {
     vector<int> vec;
     //Reading from file, filling vector
     Binary_Radix_Sort(vec);
     //Output A
 }

If the vector A is small enough the sorting works fine, if there are more elements (I tried with 257) the sorted vector contains a bunch of zeroes at random places. If I change vector types from unsigned char to int then it works. All numbers that I'm sorting are between 0 and 255. It seems to break at about 255 so perhaps it has to do something with it, printing the vector before sorting is fine, but during sorting something breaks.

A: It seems the maximum value for unsigned char in your environment is 255.
Use proper larger integer type for the elements of the vector C (counter).
size_t should be a good type to use.


text:
Q: hide button after third onclick i made buttons and when you click on them it change from green to red to yellow now i want to add that when you click the button after its color is yellow the button doesnt show anymore.
i tried doing this with:
if (color[change > 2]){
            button.style.display = "none";
     }

but this doesnt seem to work..is there a way to add this in the function without changing too much of the code?
var color = ["green", "red", "yellow"];
function page() {
    document.body.style.backgroundColor = "purple";
    //style page
    createButtons(10);
}
page();

function onbuttonclicked(a) {
    var Amount = document.getElementById("button" + a);
    var click = Amount.getAttribute('Color');
    var change = color.indexOf(click);
    Amount.setAttribute('style', 'background-color:' + color[change + 1]);
    Amount.setAttribute('Color', color[change + 1]);

    if (color[change > 2]){
        button.style.display = "none";
    }
}

function set_onclick(amount) {
    for (var a = 1; a < (amount + 1); a++) {
        document.getElementById("button" + a).setAttribute("onclick", "onbuttonclicked(" + a + ")");
    }
}

function createButtons(amount) {
    for (var a = 1; a <(amount + 1); a++) {

        var button = document.createElement("button");
        button.id = "button" + a;
        button.innerHTML = "button " + a;
        button.setAttribute('Color', color[0]);
        button.setAttribute('style', 'background-color:' + color[0]);
        container.appendChild(button);
    }
    set_onclick(amount);
}

A: you can declare a variable that increases everytime you click the button and then when the variable reaches a certain value you can delete the button
var count=0;
function onButtonClick(){
/your code here
if(count>2){
    /delete button
}
count++;
}

A:

let count = -1;
let color = ["green", "red", "yellow"];
document.querySelector('button').addEventListener('click', function() {
  if (color[++count]) {
    this.style.backgroundColor = color[count];
  } else {
    this.style.display = 'none';
  }
});
<button type="button">Click me</button>


text:
Q: python defining multiple classes with decorators I have the base class:
class BaseGameHandler(BaseRequestHandler):
    name = 'Base'
    def get(self):
        self.render(self.name + ".html")

Now, I need to define a few subclasses of this but the thing is, they have to have a decorator. Equivalent code would be:
@route('asteroid')
class AsteroidGameHandler(BaseGameHandler):
    name = 'asteroid'

@route('blah')
class BlahGameHandler(BaseGameHandler):
    name = 'blah'

and maybe a few more.
A little background here: This is a tornado web app and the @route decorator allows you to map /blah to BlahGameHandler. This code maps /blah to BlahGameHandler and /asteroid to AsteroidGameHandler.
So I thoughtI should use metaprogramming in python and define all these classes on the fly. I tried the following which doesn't work(and by doesn't work I mean the final web-app throws 404 on both /asteroid and /blah):
game_names = ['asteroid', 'blah']

games = list([game, type('%sGameHandler' % (game.title()), (BaseGameHandler,), {'name': game})] for game in game_names)

for i in xrange(len(games)):
    games[i][1] = route(games[i][0])(games[i][1])

What am I missing? Aren't these two codes equivalent when run?

A: The library that you use only looks for global class objects in your module.
Set each class as a global; the globals() function gives you access to your module namespace as a dictionary:
for i in xrange(len(games)):
    globals()[games[i][1].__name__] = route(games[i][0])(games[i][1])

The include() code does not look for your views in lists.
To be specific, include() uses the following loop to detect handlers:
for member in dir(module):
    member = getattr(module, member)
    if isinstance(member, type) and issubclass(member, web.RequestHandler) and hasattr(member, 'routes'):
        # ...
    elif isinstance(member, type) and issubclass(member, web.RequestHandler) and hasattr(member, 'route_path'):
        # ...
    elif isinstance(member, type) and issubclass(member, web.RequestHandler) and hasattr(member, 'rest_route_path'):
        # ...

dir(module) only considers top-level objects.


text:
Q: How to change the "shape" of pairplot in Seaborn? I plotted this pairplot correlating only one features with all the others, how can i visualize it in a better way? I need to visualize 4 columns. In the official documentation of pairplot i can't find the option.
This is the df:

This is the part of the code:
sns.pairplot(data=dftrain,
              y_vars=['medv'],
              x_vars=dftrain.columns[:-1])

This is the plot:

A: The shape of a pairplot can't be changed.  But, you can create a similar relplot if you convert the dataframe to long form.
Here is some simple example code, starting from dummy data:
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np

df = pd.DataFrame(np.random.rand(300, 14), columns=[*"abcdefghijklmn"])
df_long = df.melt(id_vars=df.columns[-1], value_vars=df.columns[:-1])

g = sns.relplot(df_long, x=df.columns[-1], y='value', col='variable', col_wrap=4, height=2)

A: You can use seaborn.FacetGrid and set a value of the parameter col_wrap.

col_wrap (int): "Wrap" the column variable at this width, so that the
column facets span multiple rows. Incompatible with a row facet.

Try this :
cols= dftrain.columns[:-1].tolist()

g = sns.FacetGrid(pd.DataFrame(cols), col=0, col_wrap=3, sharex=False)

for ax, varx in zip(g.axes, cols):
    sns.scatterplot(data=dftrain, x=varx, y="medv", ax=ax)

g.tight_layout()

# Output :


text:
Q: Disable aurelia-bundler just on dev machine? I've been working on an Aurelia app without gulp and it has gone well. Now I want to use gulp b/c the page loads are terrible with 100+ separate files being requested. I install aurelia-bundler from the skeleton and can get it working using gulp. But there are two problems:
1. I have to gulp bundle after EVERY change to refresh the page
2. The error messages make no sense b/c everything is minified now.
I can deal with #1 b/c of gulp-watch (even though that still takes time), but I can't handle the minified files and not being able to debug my code.
So, is there and easy way to switch back to the non-bundled files for development on my machine and only use the bundled files when I deploy to Heroku server? It seems like aurelia-bundle now points to the dist folder by default.
Oh yeah, I tried modifying config.js to point to "src" instead of "dist" but it still looks for the aurelia-xxx.js file instead of the non-bundled files.
Thanks.

A: If you are using the latest build files you can gulp watch in dev which should use the src files without bundling - of course, this is slower, but in conjunction with browser-sync you shouldn't have to do loads of refreshes.
Check your paths.js and other config files against the skeleton if gulp watch is also bundling.


text:
Q: What class/interface are Driver, PreparedStatement's implementation of java.sql.DriverManager , java.sql.PreparedStatement in Oracle's ojdbc11.jar? My development environment: Java / JDK 19, Oracle database 21c express edition. I am studying OCP 17 certificate, I read book where I seen

Source: Jeanne Boyarsky, Scott Selikoff .  https://www.wiley.com/en-us/OCP+Oracle+Certified+Professional+Java+SE+17+Developer+Study+Guide%3A+Exam+1Z0+829-p-9781119864585
I downloaded JDBC at https://www.oracle.com/database/technologies/appdev/jdbc-downloads.html and https://download.oracle.com/otn-pub/otn_software/jdbc/218/ojdbc11.jar?AuthParam=1675837769_3641dc4062ae318b752c22338c697ca4 , add to dependencie., Then, I practices by an example
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class VyUpdate {

    public static void main(String[] args) {
        try (Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "system", "12345678")) {
            if (connection != null) {
                System.out.println("Connected to the database.");
                String query = "update SYSTEM.CUSTOMER set email = ? where id = ?";
                PreparedStatement preparedStatement = connection.prepareStatement(query);
                preparedStatement.setString(1, "anhtrangmuathu222@gmail.com");
                preparedStatement.setInt(2, 3);
                preparedStatement.executeUpdate();
            } else {
                System.out.println("Failed to make connection.");
            }
        } catch (SQLException sqlException) {
            System.err.format("SQL State: %s\n%s", sqlException.getSQLState(), sqlException.getMessage());
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

}

but the idea I what seen still not clear. What class/interface are Driver, PreparedStatement's implementation of java.sql.DriverManager , java.sql.PreparedStatement in Oracle's ojdbc11.jar?

A: Use like this
System.out.println(preparedStatement.getClass().getName());
// Result: oracle.jdbc.driver.OraclePreparedStatementWrapper

DriverManager.getDriver("jdbc:oracle:thin:@localhost:1521:XE");
System.out.println(foo.getClass().getName());
// Result: oracle.jdbc.OracleDriver

Full working sample, with Oracle database 21c Express edition, Java/JDK 19:
SQL
CREATE TABLE CUSTOMER
(
    ID           NUMBER(10) NOT NULL,
    NAME         VARCHAR2(100) NOT NULL,
    EMAIL        VARCHAR2(100) NOT NULL,
    CREATED_DATE DATE NOT NULL,
    CONSTRAINT CUSTOMER_PK PRIMARY KEY (ID)
);

INSERT INTO "CUSTOMER" (ID, NAME, EMAIL, CREATED_DATE)
VALUES (1, 'Tran Phuong Ly', 'lylychancute@outlook.com', TO_DATE('2023-02-11', 'yyyy-mm-dd'));
INSERT INTO "CUSTOMER" (ID, NAME, EMAIL, CREATED_DATE)
VALUES (2, 'Nguyen Bich Van', 'bichvantt@yahoo.com', TO_DATE('2023-02-12', 'yyyy-mm-dd'));
INSERT INTO "CUSTOMER" (ID, NAME, EMAIL, CREATED_DATE)
VALUES (3, 'Dao Minh Thu', 'thudm@yahoo.com', TO_DATE('2023-02-13', 'yyyy-mm-dd'));
COMMIT;

import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.time.LocalDate;
import java.time.ZoneId;

public class VyInsert {

    public static void main(String[] args) {
        try (Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "system", "12345678")) {

            if (connection != null) {
                connection.setAutoCommit(false);
                System.out.println("Connected to the database.");
                String query = "insert into SYSTEM.CUSTOMER (ID, NAME, EMAIL, CREATED_DATE) values (?, ?, ?, ?)";
                PreparedStatement preparedStatement = connection.prepareStatement(query);
                Driver foo = DriverManager.getDriver("jdbc:oracle:thin:@localhost:1521:XE");
                System.out.println(foo.getClass().getName());
                // oracle.jdbc.OracleDriver
                preparedStatement.setInt(1, 17);
                preparedStatement.setString(2, "Nguyen Thu Hang23");
                preparedStatement.setString(3, "anhtrangmuathu32@gmail.com");
                preparedStatement.setObject(4, LocalDate.now(ZoneId.of("America/Montreal")));
                // preparedStatement.setObject(4, LocalDate.now(ZoneId.of("Asia/Ho_Chi_Minh")));
                preparedStatement.executeUpdate();
                // connection.commit();
                //connection.setAutoCommit(true);
            } else {
                System.out.println("Failed to make connection.");
            }

        } catch (SQLException sqlException) {
            System.err.format("SQL State: %s\n%s", sqlException.getSQLState(), sqlException.getMessage());
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

}