text:
Q: Accessing nested JSON data in React Component Hi i am just starting to learn react as a side project.
Im using an express backend to call an api that returns some JSON to my component. I cant seem to access the nested array to iterate over and display.
import React, { Component } from 'react';
import '../../app.css';

export class Table extends Component {
constructor(props) {
    super(props);
    this.state = {
        jsonItems: [],
        isLoaded: false
    }
}

componentWillMount() {
    this.renderMyData();
}

renderMyData() {
    fetch('/api/nfl')
        .then(res => res.json())
        .then(json => {
            this.setState({
                jsonItems: JSON.parse(json),
                isLoaded: true
            })
        })
}

render() {
    console.log(this.state.jsonItems.fullgameschedule);
    return (

                    Test 1
                    Test 2

    )
}
}

Json output:
{
"fullgameschedule": {
    "lastUpdatedOn": "2018-08-24 2:55:41 PM",
    "gameentry": [
     {
    "id": "43306",
    "week": "1",
    "scheduleStatus": "Normal",
    "originalDate": null,
    "originalTime": null,
    "delayedOrPostponedReason": null,
    "date": "2017-09-07",
    "time": "8:30PM",
    "awayTeam": {
      "ID": "73",
      "City": "Kansas City",
      "Name": "Chiefs",
      "Abbreviation": "KC"
    },
    "homeTeam": {
      "ID": "50",
      "City": "New England",
      "Name": "Patriots",
      "Abbreviation": "NE"
    },
    "location": "Gillette Stadium"
      }
    ]
  }
}

jsonItems gets populated (as shown in my react dev tools). but i cant seem to iterate over the json array "gameentry"
I can print out {this.state.jsonItems.fullgameschedule} , but i cant access it any further for example {this.state.jsonItems.fullgameschedule.gameentry} or gameentry[0] without the error message:

Cannot read property 'gameentry' of undefined

Which at first i thought was because of js being asynchronous that it was loading the component before it rendered, so i changed componentDidMount() to componentWillMount() and that should handle that. How can i access the array list and iterate over to display it to the component? or just a general point in the right direction.
EDIT: How im getting the data.
    var options = {
        url: url,
        auth: {
            user : 'xxx',
            password : 'xxx',
        }
    }
    app.get('/api/nfl', function (req, res) {
        request(options, function (err, response, body){
            if (err) {
                console.log(err);
            }
            res.send(JSON.stringify(response.body));
        })
    });

A: As you thought since data is coming in an asynchronous way, you need to handle it somehow. When you try to get a property from an undefined object, you get an error like yours. So, you should use conditional rendering.
Before that, using componentWillMount instead of componentDidMount does not work since render does not wait for any of these two methods to finish its jobs. Actually, componentWillMount will be deprecated, so go with componentDidMount for the asynchronous operations.
Since you haven't shared the code how have you tried to get the data I'm giving a blind suggestion here.
render() {
    console.log(this.state.jsonItems.fullgameschedule);
    return this.state.jsonItems.fullgameschedule && (

                    Test 1
                    Test 2

              {this.state.jsonItems.fullgameschedule.lastUpdatedOn}

    )
}

This is just an example. You can change it according to your needs.


text:
Q: Django Detailview Error Handling I have a scenario where I am trying to send different messages to the user in the event that they are not authorized to see a record or if the record does not exist.  I have been able to get the interface to send a message to the user if a 404 occurs, but can't quite figure out the logic based on criteria of the record.  I've been playing with get, get_object, or get_object_or_404 and nothing quite works.
Here is my DetailView..
class BookSearchDetailView(LoginRequiredMixin,DetailView):

    model = Book
    context_object_name = 'book_detail'
    template_name = 'book/book_search_detail.html'

    def get_object(self, queryset=None):
        return get_object_or_404(Book, book_number=self.request.GET.get("q"))

    def get(self, request, *args, **kwargs):
        book_number=self.request.GET.get("q")
        try:
            self.object = self.get_object()
        except Http404:
            messages.add_message(self.request, messages.INFO, 'Book Number %s Not Found' % book_number )
            return HttpResponseRedirect(reverse('Book:book_number_search'))
        context = self.get_context_data(object=self.object)
        return self.render_to_response(context)
        except Not a Preference:
            Book_number exists but is not self.request.user.preferences.all()

I realize the except Not a Preference doesn't work, but I am illustrating what I am trying to do.
Here is my model.
class Book(models.Model):

    book_name = models.CharField(max_length=80,null=True,unique=False)
    book_number = models.IntegerField(editable=True,null=True)

Note I do not have a  slug defined to my model.  In the current code above, this doesn't cause any problems.  When I have played with different code variations, one of the error messages I get is that DetailView must be called with a pk or a slug.
I am ultimately trying to filter the book so that if the user doesn't have attributes to allow them to see the book it would essentially return none.
I have also tried to override get_queryset, but when I use the code below,
def get_queryset(self):
    queryset = super(BookSearchDetailView, self).get_queryset()
    return queryset.filter(book_number__in=self.request.user.preferences.all())

However, when I define the code above, my DetailView does not seem to honor it or have any effect.
What I've read is that the get_object either gets the object or 404.  I've got that piece work working fine.  Just can't figure out how to incorporate a third variation of error message.
Thanks in advance for any thoughts.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Rabbitmq connections management in Pyramid web app? How can I manage my rabbit-mq connection in Pyramid app?
I would like to re-use a connection to the queue throughout the web application's lifetime. Currently I am opening/closing connection to the queue for every publish call.
But I can't find any "global" services definition in Pyramid. Any help appreciated.

A: Pyramid does not need a "global services definition" because you can trivially do that in plain Python:
db.py:
connection = None

def connect(url):
    global connection
    connection = FooBarBaz(url)

your startup file (__init__.py)
from db import connect
if __name__ == '__main__':
    connect(DB_CONNSTRING)

elsewhere:
from db import connection
...
connection.do_stuff(foo, bar, baz)

Having a global (any global) is going to cause problems if you ever run your app in a multi-threaded environment, but is perfectly fine if you run multiple processes, so it's not a huge restriction. If you need to work with threads the recipe can be extended to use thread-local variables. Here's another example which also connects lazily, when the connection is needed the first time.
db.py:
import threading

connections = threading.local()

def get_connection():
    if not hasattr(connections, 'this_thread_connection'):
        connections.this_thread_connection = FooBarBaz(DB_STRING)
    return connections.this_thread_connection

elsewhere:
from db import get_connection

get_connection().do_stuff(foo, bar, baz)

Another common problem with long-living connections is that the application won't auto-recover if, say, you restart RabbitMQ while your application is running. You'll need to somehow detect dead connections and reconnect.

A: It looks like you can attach objects to the request with add_request_method.
Here's a little example app using that method to make one and only one connection to a socket on startup, then make the connection available to each request:
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response

def index(request):
    return Response('I have a persistent connection: {} with id {}'.format(
        repr(request.conn).replace("<", "<"),
        id(request.conn),
    ))

def add_connection():
    import socket
    s = socket.socket()
    s.connect(("google.com", 80))
    print("I should run only once")
    def inner(request):
        return s
    return inner

if __name__ == '__main__':
    config = Configurator()
    config.add_route('index', '/')
    config.add_view(index, route_name='index')
    config.add_request_method(add_connection(), 'conn', reify=True)
    app = config.make_wsgi_app()
    server = make_server('0.0.0.0', 8080, app)
    server.serve_forever()

You'll need to be careful about threading / forking in this case though (each thread / process will need its own connection). Also, note that I am not very familiar with pyramid, there may be a better way to do this.


text:
Q: Ubuntu 20.04 with QGIS 3.14 (pi) SAGA is missing After updating to QGIS 3.14 in Ubuntu 20.04, SAGA is not available. The Log Panel (View->Panels->Log Messages) said SAGA didn't load. In the Processing Toolbox, the SAGA category is missing.

A: In order to solve the problem I had to:

*

*Verify if SAGA is actually installed in the system with:

saga_cmd
It said SAGA was not installed.

*Install SAGA with:

sudo apt-get install saga

*Check it's version with:

saga_cmd
Answer was: "SAGA Version: 7.3.0"

*Edit the SagaAlgorithmProvider.py file:

sudo nano /usr/share/qgis/python/plugins/processing/algs/saga/SagaAlgorithmProvider.py

*Replaced REQUIRED_VERSION = '2.3.' with REQUIRED_VERSION = '7.3.'

*Save file (Ctrl-O) and quit nano (Ctrl-X).

*Run QGIS 3.14

Now SAGA is available in the Processing Toolbox!!! When running and algorithm it says "SAGA version 7.3.0 is not officially supported - algorithms may encounter issues", yet I have not found any issues.


text:
Q: How to source environment variables from a script on a remote host when using remote mode in clion? At my company we use a number of linux servers dedicated to compilation of our codebase. I would like to use CLion's remote working capabilities, but so far I am unable to find a way for CLion to source my ~/.bashrc file, which sources other files that set the env and toolchain.
Is there a way to make clion source a file, .bashrc to be specific, after making the ssh connection to the remote server?

A: I did find a workaround:
I created a bash script that looks like this:
export PATH=/home/user/Qt/5.15.1/gcc_64/bin/:$PATH
/home/user/Documents/cmake-3.19.0-rc3-Linux-x86_64/bin/cmake $@

And set my toolchain's cmake to that file. Now whenever there is a configuration or building operation the script would pick up the arguments, setup the environment and then call cmake with passed parameters.

A: Unfortunately, as of 13.11.2020 there is no way to source a script from the remote machine while working in CLion remotely via ssh.
There is a ticket for this functionality to be added so if you are reading this in the future, check the web, maybe the situation has changed.


text:
Q: Family of Sets Proof for Set Theory Let $A$ be a nonempty set. A ring of subsets of $A$ is a nonempty family $F$ of subsets of $A$ such that for all $S,T, \in F,$
(i) $S \cup T \in F$
(ii) $S \setminus T \in F$ (difference between the sets).
Prove that if $F$ is a ring of subsets of $A$, then for all $S, T \in F, S \cap T \in F.$
My attempt so far:
From the first condition about the union, we have that
$$S \cup T = \{ x: x \in S \; \textbf{or} \; x \in T \} \in F.$$
And from the second condition,
$$S \setminus T  = \{ x: x \in S \; \textbf{and} \; x \not\in T \} \in F.$$
So then we have two cases:
I:
$$\{ x : x \in S \} \in F$$
$$\{ x: x \in S \; \textbf{or} \; x \in T \} \in F.$$
II:
$$\{ x: x \in T \} \in F$$
$$\{ x: x \in S \; \textbf{and} \; x \not\in T \} \in F.$$
What i'm not sure about is how to transform these resulting facts into something about the intersection of arbitrary subsets of $F$.

A: Hint. Show that $S \cap T = S \setminus (S \setminus T)$.


text:
Q: Google colab no muestra markdown Si import markdown de la clase Ipython del a siguiente forma y creo un objeto de tipo Markdown
from IPython.display import display, Markdown
display(Markdown("**hello**"))

me regresa esto:
<IPython.core.display.Markdown object>

pero lo que espero ver seria esto:
Hello
Necesito crear celdas de markdown automaticamente, he probado hacerlo de forma local con jupyter, pero en google colab no.

A: do:
In [903]: from IPython.display import display

In [904]: markdown_string = '''\
     ...: hello world
     ...: '''

In [905]: display({'text/plain': markdown_string,'text/markdown': markdown_string},raw=True)
hello world

as in:
https://stackoverflow.com/questions/53377801/jupyter-notebook-vs-jupyter-console-display-of-markdown-and-latex-html-etc


text:
Q: Pyomo (PySP) is changing "\" into " /" When I use the runef command (PySP) in Anaconda Prompt (Windows operating system)
(base) D:\Downloads\Documents\models_Opt_estocastica> runef --solve --solver=gurobi

I'm getting the error:
"runef: IO ERROR:
path does not exist: D:/Downloads/Documents/models_Opt_estocastica/ReferenceModel.py

The problem is that Pyomo is changing the "\" symbol to the "/" symbol so it doesn't recognize the path I'm giving. Do you have any idea how I can fix this problem?
Thank you very much for your help.


text:
Q: android application connecting to 'sparklr' J2EE application using OAuth2 I'm trying to make an OAuth 2.0 Provider and an Android application that is able to connect to the provider using OAuth 2.0. I have the following setup:
A tomcat server with the J2EE example OAuth 2.0 provider named 'sparklr' from springsource. When I test it with the example 'Tonr' it works perfectly.
Now I want an Android application that does more or less the same as the example Tonr application. Accessing the photo resources from the sparklr application using OAuth 2.0
But I'm stuck. I'm using the leeloo libraries which have been moved to apache amber. To be exact I'm using the following tutorial: http://simpleprogrammer.com/2011/05/25/oauth-and-rest-in-android-part-1/
The first fase of the application works. The browser starts and I get the sparklr page to login and authorize the request.
But when I try to get the access token the application crashes. I didn't get any wiser from the logcat so I used debug to get the request. The following code builds the request:
request = OAuthClientRequest.tokenLocation("http://10.106.0.16:8084/sparklr/oauth/token")
                .setGrantType(GrantType.AUTHORIZATION_CODE)
               .setClientId("tonr")
                .setClientSecret("secret")
                .setRedirectURI("MyOAuth2POC://oauthresponse")
                .setCode(code)
                .setScope("trust")
                            .buildBodyMessage();

And I get my url: http://10.106.0.16:8084/sparklr/oauth/token?scope=read&code=iCMZPE&client_secret=secret&client_id=tonr&grant_type=authorization_code&redirect_uri=MyOAuth2POC%3A%2F%2Foauthresponse
All the parameters are there and it looks correct to me.  But I get the following output:

{   "error": "invalid_grant",   "error_description": "Invalid
  authorization code: MASCID" }

So obviously something goes wrong with the scope parameter. I tried to set it to 'trust' instead of 'read' but no different result. Do I need to change something in the sparklr application? Or am I doing something wrong with the Android application, and what?
Hope someone can help.
thx!

A: the problem wasn't in my url to get the access token but in the url of my request token.
I didn't specify the scope there.
I added the parameters to my url for authorization like this: http://.../sparklr/oauth/authorize?scope=read&response_type=code
and now it does work.
I was looking at the wrong place..


text:
Q: Align image view with other Linear Layout elements in Android I am designing a static week calendar as per the snapshot below. As you can see the dot image is not getting aligned with other items in the Linear layout. This is a Static calendar that displays days in the current week. I had to set button width and height to 40dp else instead of circular background I was getting bit of oval shape for button background when selected. Any pointers on the change required to align the dot icon with other items vertically.
The rounded button style is as below.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="false">
        <shape android:shape="oval">
            <solid android:color="#FFFFFF"/>
        </shape>
    </item>
    <item android:state_pressed="true">
        <shape android:shape="oval">
            <solid android:color="#000000"/>
        </shape>
    </item>
</selector>

My xml UI layout is as below.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="7">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_marginEnd="10dp"
        android:layout_weight="1"
        android:orientation="vertical">

        <TextView
            android:id="@+id/dayLabel1"
            android:layout_width="40dp"
            android:layout_height="wrap_content"
            android:layout_gravity="fill"
            android:gravity="center"
            android:text="M"
            android:textAlignment="center" />

        <Button
            android:id="@+id/dateBtn1"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:background="@drawable/round_button"
            android:text="13" />

        <ImageView
            android:id="@+id/dotIcon1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="5dp"
            app:srcCompat="@drawable/dotindicatoricon" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="vertical"
        android:layout_marginTop="10dp"
        android:layout_marginEnd="10dp">

        <TextView
            android:id="@+id/dayLabel2"
            android:layout_width="40dp"
            android:layout_height="wrap_content"
            android:layout_gravity="fill"
            android:gravity="center"
            android:text="M"
            android:textAlignment="center" />

        <Button
            android:id="@+id/dateBtn2"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:background="@drawable/round_button"
            android:text="13" />

        <ImageView
            android:id="@+id/dotIcon2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp"
            android:layout_gravity="center_horizontal"
            app:srcCompat="@drawable/dotindicatoricon" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="vertical"
        android:layout_marginTop="10dp"
        android:layout_marginEnd="10dp">

        <TextView
            android:id="@+id/dayLabel3"
            android:layout_width="40dp"
            android:layout_height="wrap_content"
            android:layout_gravity="fill"
            android:gravity="center"
            android:text="M"
            android:textAlignment="center" />

        <Button
            android:id="@+id/dateBtn3"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:background="@drawable/round_button"

            android:text="13" />

        <ImageView
            android:id="@+id/dotIcon3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="5dp"
            app:srcCompat="@drawable/dotindicatoricon" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="vertical"
        android:layout_marginTop="10dp"
        android:layout_marginEnd="10dp">

        <TextView
            android:id="@+id/dayLabel4"
            android:layout_width="40dp"
            android:layout_height="wrap_content"
            android:layout_gravity="fill"
            android:gravity="center"
            android:text="M"
            android:textAlignment="center" />

        <Button
            android:id="@+id/dateBtn4"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:background="@drawable/round_button"

            android:text="13" />

        <ImageView
            android:id="@+id/dotIcon4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="5dp"
            app:srcCompat="@drawable/dotindicatoricon" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="vertical"
        android:layout_marginTop="10dp"
        android:layout_marginEnd="10dp">

        <TextView
            android:id="@+id/dayLabel5"
            android:layout_width="40dp"
            android:layout_height="wrap_content"
            android:layout_gravity="fill"
            android:gravity="center"
            android:text="M"
            android:textAlignment="center" />

        <Button
            android:id="@+id/dateBtn5"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:background="@drawable/round_button"

            android:text="13" />

        <ImageView
            android:id="@+id/dotIcon5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="5dp"
            app:srcCompat="@drawable/dotindicatoricon" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="vertical"
        android:layout_marginTop="10dp"
        android:layout_marginEnd="10dp">

        <TextView
            android:id="@+id/dayLabel6"
            android:layout_width="40dp"
            android:layout_height="wrap_content"
            android:layout_gravity="fill"
            android:gravity="center"
            android:text="M"
            android:textAlignment="center" />

        <Button
            android:id="@+id/dateBtn6"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:background="@drawable/round_button"

            android:text="13" />

        <ImageView
            android:id="@+id/dotIcon6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="5dp"
            app:srcCompat="@drawable/dotindicatoricon" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="vertical"
        android:layout_marginTop="10dp"
        android:layout_marginEnd="10dp">

        <TextView
            android:id="@+id/dayLabel7"
            android:layout_width="40dp"
            android:layout_height="wrap_content"
            android:layout_gravity="fill"
            android:gravity="center"
            android:text="M"
            android:textAlignment="center" />

        <Button
            android:id="@+id/dateBtn7"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:background="@drawable/round_button"
            android:text="13" />

        <ImageView
            android:id="@+id/dotIcon7"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="5dp"
            app:srcCompat="@drawable/dotindicatoricon" />
    </LinearLayout>
</LinearLayout>

A: gravity="center" should be appropriate, there seems to be an issue withdotindicatoricon maybe you set some margins in the xml? or is there a padding somewhere?


text:
Q: Threejs shader implementation Past weeks I have been experimenting with the three.js library & shaders and I'm stuck with implementing a shader on my model. I found this interesting example on pixelshaders.com that I want to implement on a threejs model.
http://pixelshaders.com/examples/noise.html
It's the last example at the bottom of the page and I'm trying to implement.
I'm trying to add it to the 3D model that can be found in the link below:
http://martinr.nl/lab/Speeltuin/webgl_shader2.html
The hard thing is when I add the code of the example the 3D model disappears. This makes it really hard to debug and find the error.
This is the shader code that works, but not with the right shader:

When I try to implement the shader of the above example the 3D model disappears.
Does anyone know how to implement the shader of the pixelshader.com example onto the model in my example?
Or does anyone have any tips what I could try to make it work?

A: I replaced your fragment shader with the code from pixelshaders.com.  Console reported the following error:
> THREE.WebGLProgram: shader error: 0 gl.VALIDATE_STATUS false
> gl.getPRogramInfoLog Varyings with the same name but different type,
> or statically used varyings in fragment shader are not declared in
> vertex shader: position

A varying variable is essentially an interface between the vertex shader and the fragment shader.  This error is telling us that position is declared in the fragment shader, but not in the vertex shader.
You actually had the required variable in your vertex shader...except it was named vUv.  All I had to do was make the variable names consistent.

Full source (i took the scaling off the time in the render() function too):
<!DOCTYPE html>

        <title>three.js webgl - materials - shaders [custom]</title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">

three.js - shader material demo. featuring Monjori by Mic

    <link rel="stylesheet" href="css/skeleton.css">
    <link rel="stylesheet" href="css/normalize.css">
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/codemirror.css">


text:
Q: Github Actions badge shows no status I have run many times github actions on my repo without problem and with the same script on one of my repo it is displaying "no status".
The repo is: https://github.com/aurelpere/python-planif
I dont understand why it is not displaying a status as the workflow runs correctly…
Any help would be great
thank you
Notice my svg badge also shows "no status" at https://github.com/aurelpere/python-planif/workflows/CI/badge.svg and at https://github.com/aurelpere/python-planif/workflows/Unittests/badge.svg .
(following what is in this post : https://github.community/t/badge-shows-no-status-and-no-status-mismatch-between-the-filepath-vs-name-usage/16907 or in this post Github Actions badge shows "No status")
I also tried to duplicate the code in another fresh repo (https://github.com/aurelpere/python-geothermal---power-to-gas/
) and it is the same, the badge shows no status, so it has nothing to do with the fast forward merge issue from here https://github.community/t/workflow-badge-no-status/17280/2
Edit : solved with the answer below, but i deleted the initial repo and kept only the fresh one if you try to follow the links

A: For some reason you have to use the workflow name instead of the yaml file name. This worked for me


text:
Q: Unit group of power series ring Is there any way to calculate the multiplicative group of the units of power series ring $k[[x]]$, where $k$ is a field ?

A: Hint $\rm\displaystyle\quad 1\: =\: (a-xf)(b-xg)\ \Rightarrow\ \color{#c00}{ab=\bf 1}\ $ so scaling top & bottom below by $\rm \,b\,$ yields
$$\Rightarrow\ \ \displaystyle\rm\ \ \frac{1}{a-xf}\ =\ \frac{b}{\color{#c00}{\bf 1}-bxf}\ =\ b\:(1+bxf+(bxf)^2+(bxf)^3+\:\cdots\:)$$

A: $\bf Hint:$ $\sum_{n=0}^\infty a_nx^n$ is a unit iff $a_0\ne 0$.

A: The multiplicative group is $k[[x]]\backslash (x)$.
Certainly those elements divisible by $x$ are not units. If an element is not divisble by $x$ (in other words, has nonzero constant term), you can construct the inverse term by term.

A: It's possible to be much more specific about the structure of the unit group than has been done so far, as follows. So far we know that the units in $k[[x]]$ are those formal power series with nonzero constant term. Dividing by the constant term shows that this group is isomorphic to $k^{\times}$ (the constant term part) times the group of formal power series $1 + a_1 x + a_2 x^2 + \dots$ with constant term $1$.

Claim: If $k$ has characteristic $0$, then this group is isomorphic to $(k[[x]], +)$. In particular, it is a $\mathbb{Q}$-vector space.

(Note that this can't be true in characteristic $p$ since the group of units is not $p$-torsion: we have, for example, $(1 + x)^p = 1 + x^p \neq 1$.)
The isomorphism is given by the "exponential" map
$$k[[x]] \ni f \mapsto (1 + x)^f \in k[[x]]^{\times}.$$
This is defined using the identity
$$1 + x = \exp \log (1 + x) = \exp \sum_{n \ge 1} (-1)^{n-1} \frac{x^n}{n}$$
(which is where we need that $k$ has characteristic $0$), which allows us to define
$$(1 + x)^f = \exp f \log (1 + x)$$
as a formal power series. This has all of the standard properties of the exponential, and is in particular a homomorphism. The inverse of this isomorphism is the "logarithm" map
$$\log_{1 + x}(g) = \frac{\log g}{\log (1 + x)}$$
where $g$ has constant term $1$. It's formal to verify that these two operations are inverse to each other.
The answer is more interesting in positive characteristic: we get the underlying abelian group of the ring of Witt vectors $W(k)$. For example, when $k = \mathbb{F}_p$ this group is related to the group of $p$-adic integers $\mathbb{Z}_p$, and in fact there is a natural exponential $(1 + x)^f \in \mathbb{F}_p[[x]]$ where $f \in \mathbb{Z}_p$. Edit: See the comments!


text:
Q: How to get claims from Azure AD B2C I have followed the following tutorial
Azure AD B2C: Call an ASP.NET Web API from an ASP.NET Web App
I am able to run the app.
When the authorisation code is received I put a break point on line var code = notification.Code;and I am able to see all the claims received.
But when I try to print the claims nothing is displayed and the app exits. It shows a null object reference on the following line
string a = notification.AuthenticationTicket.Identity.FindFirst(ClaimTypes.Country).Value;
Any idea how I can print all the claims. Any help will be appreciated. Thank you
private async Task OnAuthorizationCodeReceived(AuthorizationCodeReceivedNotification notification)
{
    // Extract the code from the response notification
    var code = notification.Code;

    string signedInUserID = notification.AuthenticationTicket.Identity.FindFirst(ClaimTypes.NameIdentifier).Value;
    string a = notification.AuthenticationTicket.Identity.FindFirst(ClaimTypes.Country).Value;
    TokenCache userTokenCache = new MSALSessionCache(signedInUserID, notification.OwinContext.Environment["System.Web.HttpContextBase"] as HttpContextBase).GetMsalCacheInstance();
    ConfidentialClientApplication cca = new ConfidentialClientApplication(ClientId, Authority, RedirectUri, new ClientCredential(ClientSecret), userTokenCache, null);
    try
    {
        AuthenticationResult result = await cca.AcquireTokenByAuthorizationCodeAsync(code, Scopes);
    }
    catch (Exception ex)
    {
        //TODO: Handle
        throw;
    }
}


text:
Q: How to insert many-to-many entities without having tracking issues (already being tracked)? I have the following models/tables:
CV:
   int ID
   string Title
   List<SkillCV> SkillsCVs // many-to-many junction/associative model/table to link the 2 tables

SkillCV:
   int CvID
   int SkillID
   bool IsCore

Skill:
   int ID
   string Title

Then I have the following method:
public async Task<int> UpdateAsync(CV cv, List<SkillsCVs> skillsCVs)
{
   var cvDB = await context.Set<CV>()
               .Include(CV => CV.SkillsCVs)
                  .ThenInclude(skillCV => skillCV.Skill)
               .Include(CV => CV.User)
               .FirstOrDefaultAsync(CV => CV.Id == cv.Id);
   cvDB.Title = cv.Title;
   cvDB.SkillsCVs.Clear();
   cvDB.SkillsCVs.AddRange(skillsCVs);
   context.Set<CV>().Update(cvDB); // EXCEPTION
   return await context.SaveChangesAsync();
}

The problem is that I have CVSkill entity with CV id 8, Skill id 1, so the composite key is (1, 8). Then I use this method to add (1, 14) - the same skill with ID 1 to CV with ID 14 and it says that CV with id 8 is already being tracked or that the (1, 8) can't be duplicated. I suppose that Skill 1 is still tracked to CV 8, because I join CV -> SkillCV -> Skill. How can I update the CV with ID 14 to insert (1, 14) into its SkillsCVs collection, without having tracking/duplicating issues? I suppose that it's not a problem to have both (1, 8) and (1, 14) entities, because the composite keys as a whole are unique even though the Skill IDs are the same?

EDIT:
Now I have the following code:
public async Task<int> UpdateAsync(CV cv, List<SkillsCVs> skillsCVs)
{
   var cvDB = await context.Set<CV>()
               .AsNoTracking()
               .Include(CV => CV.SkillsCVs)
                  .ThenInclude(skillCV => skillCV.Skill)
               .Include(CV => CV.User)
               .FirstOrDefaultAsync(CV => CV.Id == cv.Id);
   cvDB.Title = cv.Title;

   foreach (var skillCV in cvDB.SkillsCVs)
      context.Entry(skillCV).State = EntityState.Detached;

   cvDB.SkillsCVs.Clear();

   foreach (var skillCV in skillsCVs)
      cvDB.SkillsCVs.Add(skillCV);

   context.Set<CV>().Update(cvDB); // EXCEPTION
   return await context.SaveChangesAsync();
}

When I try to add a single entity skillCV (skillsCVs collection with 1 entity) it throws: Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException: Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded.
When I try to add a bunch of entities through the skillsCVs in CV with ID 14 it throws: System.InvalidOperationException: The instance of entity type 'CV' cannot be tracked because another instance with the key value '{Id: 8}' is already being tracked. When attaching existing entities, ensure that only one entity instance with a given key value is attached.

A: Try using AsNoTracking() like await context.Set<CV>().AsNoTracking(), It should not throw exception as it won't be track entities anymore.
public async Task<int> UpdateAsync(CV cv, List<SkillsCVs> skillsCVs)
{
   var cvDB = await context.Set<CV>()
               .AsNoTracking()
               .Include(CV => CV.SkillsCVs)
                  .ThenInclude(skillCV => skillCV.Skill)
               .Include(CV => CV.User)
               .FirstOrDefaultAsync(CV => CV.Id == cv.Id);
   cvDB.Title = cv.Title;
   cvDB.SkillsCVs.Clear();
   cvDB.SkillsCVs.AddRange(skillsCVs);
   context.Set<CV>().Update(cvDB); // EXCEPTION
   return await context.SaveChangesAsync();
}

Edit 1 Or your cvDB is already being track, so try with removing context.Set<CV>().Update(cvDB);. It will explicitly track the entity so it might be causing the issue.
public async Task<int> UpdateAsync(CV cv, List<SkillsCVs> skillsCVs)
{
   var cvDB = await context.Set<CV>()
               .Include(CV => CV.SkillsCVs)
                  .ThenInclude(skillCV => skillCV.Skill)
               .Include(CV => CV.User)
               .FirstOrDefaultAsync(CV => CV.Id == cv.Id);
   cvDB.Title = cv.Title;
   cvDB.SkillsCVs.Clear();
   cvDB.SkillsCVs.AddRange(skillsCVs);
   // context.Set<CV>().Update(cvDB); // comment this line
   return await context.SaveChangesAsync();
}

Edit 2 Did not use AsNoTracking() here. Updated code to get existing SkillsCVs, then clear cvDB.SkillsCVsand while adding new SkillsCV check if the same is already exists or not. If exists then mark existing one as Detached & newly added as Modified. Also comment line context.Set<CV>().Update(cvDB);.
public async Task<int> UpdateAsync(CV cv, List<SkillsCVs> skillsCVs)
{
    var cvDB = await context.Set<CV>()
                .Include(CV => CV.SkillsCVs)
                    .ThenInclude(skillCV => skillCV.Skill)
                .Include(CV => CV.User)
                .FirstOrDefaultAsync(CV => CV.Id == cv.Id);
    cvDB.Title = cv.Title;

    // Retrieve list of existingSkillsCVs so later we can mark it as Detached and newly added skillCV as Modified.
    var existingSkillsCVs = cvDB.SkillsCVs.ToList();

    cvDB.SkillsCVs.Clear();

    foreach(var skillsCV in skillsCVs)
    {
        cvDB.SkillsCVs.Add(skillsCV);

        // Find SkillsCV if already exists. If exists then Detach it & set newly added skillsCV as Modified.
        var existingSkillsCV = existingSkillsCVs.FirstOrDefault(x => x.CvID == skillsCV.CvID && x.SkillID == skillsCV.SkillID);
        if (existingSkillsCV != null)
        {
            context.Entry(existingSkillsCV).State = EntityState.Detached;
            context.Entry(existingSkillsCV.Skill).State = EntityState.Detached;
            context.Entry(skillsCV).State = EntityState.Modified;
        }
    }

    // context.Set<CV>().Update(cvDB); // comment this line
    return await context.SaveChangesAsync();
}

A: Try using the Detach to detach current CVSkills
like :
  var cvDB = await context.Set<CV>()
               .AsNoTracking()
               .Include(CV => CV.SkillsCVs)
                  .ThenInclude(skillCV => skillCV.Skill)
               .Include(CV => CV.User)
               .FirstOrDefaultAsync(CV => CV.Id == cv.Id);
   cvDB.Title = cv.Title;
   foreach( var skillsCV in cvDB.SkillsCVs)
   {
      context.Entry(skillsCV).State = EntityState.Detached;
   }
   cvDB.SkillsCVs.Clear();
   cvDB.SkillsCVs.AddRange(skillsCVs);
   context.Set<CV>().Update(cvDB); // EXCEPTION
   return await context.SaveChangesAsync();


text:
Q: SQL trying to generate random int 64 bit and I tried FLOOR(RAND()*( POW(2,64) -1)the numbers I get  numbers look like 432443.0 32424.0 but I need int without trailing zero.
How it can be solved?

A: Try converting your result to an int like this:
CONVERT(int, FLOOR(RAND()*( POW(2,64) -1))


text:
Q: What is the meaning of contemporary history in this sentence? I read a sentence in The Hindu which was:

The forthcoming Lok Sabha elections, widely seen as a watershed event in our contemporary history, are expected to redraw the Nation's political landscape with implications for the future of Indian democracy.

First, the writer is saying the elections are forthcoming but what then does he mean by contemporary history?

A: The adjective "contemporary" means occurring or happening in the present as opposed to the distant past or distant future. The expression "our contemporary history" would then mean the history of India that has to do with the present (political events that are talking place presently), near future (because the elections are inevitably going to happen and for that reason the author already thinks of them as part of India's history) and more specifically the very recent past of the country because the recent past of a country is closely connect with its present. That's why you can talk about the forthcoming Lok Sabha elections as part of India's contemporary history.
Of course, when you say "the history of a country", it implies that we are going to talk about events that happened in the past. In this case, the expression "contemporary history", if taken literally, makes zero sense because "contemporary" means related to the present. But that's only true if you think of this expression literally. In general, "contemporary history" is understood to mean "the history of something closely connected to its recent past, present and near future". How recent is recent and how near is near depends on the history of the political region you're talking about. For the countries that once comprised the USSR, the recent past and near future would be from the collapse of the Soviet Union up to the present moment plus all major political changes such as presidential elections that are going to happen in the near future.


text:
Q: C# Datagridview does not sort Checkbox column When I bind a Linq-to-sql query to a datagridview (using a BindingSource in between), the columns are sortable by default. However, this does not seem to be the case for boolean types. For these the datagridview uses Checkbox columns, but when I click on the header nothing happens. Solution anyone?

A: will this help?
dgv1.Columns["Colname"].SortMode = DataGridViewColumnSortMode.Automatic;

A: In VS2012 in the designer you can also set the SortMode.
Right-click on the DataGridView and go to "Edit Columns".
There's a drop-down for SortMode with a choice of NotSortable, Automatic, and Programmatic.
It appears that the default for most columns is Automatic, but for checkboxes (boolean) columns the default is NotSortable.


text:
Q: Updating several records in a database with increasing value I need to update several records in a table, and am hoping to accomplish it in one query.
I have a php array of id's for a few of the records in my table. The array is in a specific order, and I need to update a value for each id with the position/key that the id is in the array. I could easily loop through each value in the array and run a query for each record that needs to be updated, but I am looking for a way to possibly update each record in one query.
The following will give me the desired result, but I am looking for a one query solution.
$ID = array('3','2','6','5','9');
for($i = 0; $i <= 4; $i++){
    $q = "UPDATE table SET blah = ".$i." WHERE id = ".$ID[$i];
    mysql_query($q) or die();
}

Thanks.

A: A big long ugly if or case statement would do the trick:
UPDATE ...
SET blah = IF(id=3,1,IF(id=2, 2, IF(id=6,3, IF....))))
WHERE id IN (3,2,6,....)

it'd quickly become unmanageable, but it would accomplish things in a single query. A slightly cleaner, more portable alternative:
UPDATE
SET blah = CASE id WHEN 3 THEN 1 WHEN 2 THEN 2 WHEN 6 THEN 3 .... END CASE
WHERE id in (3,2,6,...)

A: 2 queries:
First only needed in case you have used @var already.
SET @var := -1;

And then (note FIND_IN_SET wants a comma-separated string):
UPDATE tablename
SET blah = @var := @var +1
WHERE id IN (3,2,6,5,9)
ORDER BY FIND_IN_SET(id,'3,2,6,5,9');

If you have an array with key=>postition pairs, this could be used:
$array = array(2 => 40,3 => 12,5 => 8,6 => 9,9 =>13129);
mysql_query("
   UPDATE bla
   SET blah = ELT(
     FIELD(id,".implode(',',array_keys($array))."),
      ".implode(',',$array).")
   WHERE id IN (".implode(',',array_keys($array)).")");

A: Try this:
INSERT INTO tbl_name (idCol, valCol) VALUES (id1, value1),(id2, value2)
ON DUPLICATE KEY UPDATE
  idCol = VALUE(idCol),
  valCol = VALUE(valCol)

You could also use a stored procedure, passing it a string of the ID's:
CREATE PROCEDURE updateItems( firstNum INT NOT NULL, ids TEXT NOT NULL) BEGIN
   @id := ... #  Some expression to get the first ID.
   WHILE id != "" DO
      SET ids := ... #  Some expression to get the rest of the string.
      UPDATE table SET blah = firstNum WHERE id = @id;
      SET firstNum = firstNum +1;
      @id := ... ;
   END;
END $$

Also, there was one trick with LAST_INSERT_ID() - if you call it with a param, like LAST_INSERT_ID( 123 ), successive call to LAST_INSERT_ID() will give you 123.
Could be used together with @variables to achieve that goal.
You might get some inspiration here: http://ondra.zizka.cz/stranky/programovani/sql/mysql_stored_procedures.texy

A: It's impossible in this way ...Well, it's possible but I'd suggest you not to do it, 5 queries aren't horrors

A: $q = "UPDATE table SET blah = ".$i." WHERE id in ('3','2','6','5','9')";

A: If you are concerned about performance, you should take a look at using prepared statements and transactions.
There is most likely a solution to doing this in one single query, but it would most likely get really messy.

A: your better of using foreach then you don't have to set a $i limit.
i think its quick to do it this way
$id = array('3','2','6','5','9');
$i=0;

 foreach ($id as $v){

    $q = "UPDATE table SET blah = ".$i++." WHERE id = '$v'";
    mysql_query($q) or die();

 }


text:
Q: An embedding of $\mathbb{RP}^2$ into $\mathbb{R}^4$ I am trying to prove that the map $$F:(x,y,z)\in S^2\mapsto (x^2-y^2,xy,xz,yz)\in\mathbb{R}^4$$
induces a $C^\infty$ map $G:\mathbb{RP}^2\rightarrow\mathbb{R}^4$ which is an embedding.
What I would do is:

*

*Define $G: [x,y,z]\in\mathbb{RP}^2\mapsto F(x,y,x)\in\mathbb{R}^4$. This is well defined beacuse $F$ is both adequate to the antipodal quotient relation and is homogeneous of deegre two component-wise.

*To show that it is $C^\infty$ I would observe that the projection on the quotient $\pi$ is a local diffeomorphism for the usual structures on the sphere and on $\mathbb{RP}^2$, so is $F$, being the restriction of a $C^\infty(\mathbb{R}^3,\mathbb{R}^4)$ map to a subvariety, and hence so is $G$ since it holds $G\circ\pi=F$.

*To show $G$ is an immersion I would show that the differential $F_*:T_p\mathbb{R}^3\rightarrow T_p\mathbb{R^4}$ has full rank on the points of $S^2$: then being $S^2$ a subvariety its restriction to $T_pS^2$ this will coincide with the differential of $F|_{S^2}$, which is what we search for. Then one observes $G_*=F_*(\pi^{-1})^*$ and again uses the fact $\pi$ is a local diffeomorphism. This is the point I am more uncertain of.

*Finally to show $G$ is an homeomorphism onto its image one exploits usual results about quotient topology plus the fact that $S^1$ and hence $\mathbb{RP}^2$ is compact and $G(\mathbb{RP}^2)\subset\mathbb{R}^4$ is Hausdorff.

Is the outline of the solution correct?
Thanks in advance

A: About point 1. : proving that it is antipode-invariant is actually enough, since $S^2$ mod the antipodal map is $\mathbb{RP}^2$
About point 2. : using that it's a local diffeomorphism is essentially reproving the defining property of the quotient; so you don't actually need to do it (although of course, you can!)
About point 3. : This is correct; the fact that it's a local diffeomorphism implies that $d_p\pi$ is an isomorphism on tangent spaces, so you get full rank for $d_pG$ as well.
About point 4. : everything is correct, except that you probably meant $S^2$ and not $S^1$.


text:
Q: Where was it established that Super Goof's goobers were irradiated by a meteor? In old comics from the 1960s and later, Goofy used to have a superhero alter ego, Super Goof. Toonopedia explains that Disney made a trial run in Donald Duck #102 (October, 1965) where Gyro Gearloose invented a super cape that Goofy used. The character was well received and

That same month, he got his own title, and Super Goof #1 (also by Connell and Murry) provided yet another origin story. This one involved a goober patch in Goofy's back yard, which, irradiated by a nearby meteorite, yielded super goobers which powered him up when ingested.

I am a bit confused about the line about the goobers connection to a meteor. It has been referenced in many places, it even showed up in an episode of Disney's House of Mouse. It is well known that Goofy got  his powers from peanuts, or goobers as he calls them, but there does not seem to be any  reliable source that show where in comic they attribute it to a meteor?
The first number of the comic Super Goof #1 (1965) says nothing about it, it only mention that Goofy managed to grow the goobers in his garden, but no mention about why they were so special.

Much later, in Super Goof #31(1974) the goobers were destroyed by the Beagle Boys which forced Goofy to get replacements. His research of the origin of the peanuts leads him to a Mexican superhero called Super Señor who had "superior goobers" on his ranch and who provided Goofy with new ones.

That is all the origin there seems to be for the goobers, so where does the meteor come in?
Could anyone bring clarity to this?

A: I do not recall encountering an references to radiation from a meteor being responsible for Goofy's Super Goobers.  However, in Super Goof issue seven, Gyro Gearloose demonstrates that he can create new Super Goobers using just his "atomic greenhouse," so nuclear radiation does appear to be the culprit.  (Goofy does not provide Gyro with a Super Goober to work from; he just tells him what is needed in a letter.)


text:
Q: Optimize two lists with shared objects I have the following two lists:
List<Animal> AllAnimals;
List<Animal> AnimalsWithEyes;

Since there are a lot of animals in the world and there are a lot of the same animals, objects, in both lists, as many have eyes, it would be kind of cool if there were a way to optimize the memory efficiency by not having duplicate objects cluttering up the RAM.
As an additional problem, the Animals in AllAnimals are ordered alphabetically, meaning that we can't just say that the first block of indexes is animals with eyes.
Any ideas on how Java can support such behavior?

A: Perhaps you should consider using java.util.Set and java.util.TreeSet for natural ordering(if needed be). The Set interface specification ensures, that no two equal objects exist in a Set.
Override Animal#equals, Animal#hashcode and implements Comparable interface. For example:-
public class Animal implements Comparable<Animal>{

    private final String name;
    private final boolean hasEyes;

    public Animal(String name, boolean eyes){
        this.name = name;
        this.hasEyes = eyes;
    }

    public String getName() {
        return name;
    }

    public boolean isHasEyes() {
        return hasEyes;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 29 * hash + Objects.hashCode(this.name);
        hash = 29 * hash + (this.hasEyes ? 1 : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Animal other = (Animal) obj;
        if (this.hasEyes != other.hasEyes) {
            return false;
        }
        if (!Objects.equals(this.name, other.name)) {
            return false;
        }
        return true;
    }

    @Override
    public int compareTo(Animal o) {
        //....compareTo implementation.
    }
}

Finally "intersections" between 2 List<Animal> consolidated into a Set<Animal>.
Set<Animal> s = new TreeSet<>();
s.addAll(allAnimals);
s.addAll(animalWithEyes);

The Set#addAll implementation ensure no duplicate Animal exist.
*** Or you could use project Lombok annotations to generate equals, hashcode and Comparable implementations.


text:
Q: Array in ngFor not saving I have a button Add Educational Background that takes me to the awards input form.

    <button *ngIf="authService.permission('edit_user') || authService.user().employee_number == routes.parent.snapshot.params.employee_number"
    [hidden]="editProfileForm" class="btn btn-primary btn-sm float-right" (click)="isView=false; userEducationBackGround=resetUserEducationBackGround(); isEdit=false; awards=[]">
        Add Educational Background

    </button>

Here are my awards input form which is displayed by ngFor.

 0">

                        Input Award Title

                    <input type="text" [ngModelOptions]="{standalone: true}" [(ngModel)]="item.award"
                    class="form-control">

                        File

                    <input #file type="file" accept='image/*' class="form-control" (change)="onPictureSelected($event.target.files, i)"
                    />

                    <button class="btn btn-primary btn-xs" (click)="$event.preventDefault(); saveAward(i);"
                    *ngIf="isEdit">

                    </button>

                    <button class="btn btn-secondary btn-xs" (click)="$event.preventDefault(); removeAward(i); awardsErrorMessage=''">

                    </button>

Here's my button on that same page to add multiple awards field.

        <button class="btn btn-primary btn-sm" (click)="addAward()">
            Awards

        </button>

Here's the method for addAward
addAward() {
    this.awards.push({
        id: null,
        award: '',
        photo: null
    });
}

Here's what I've done. I added the addAward() to pass on the initial value. This works it saves data the problem is, I'm unable to saves multiple awards and only one gets save.

    <button *ngIf="authService.permission('edit_user') || authService.user().employee_number == routes.parent.snapshot.params.employee_number"
    [hidden]="editProfileForm" class="btn btn-primary btn-sm float-right" (click)="addAward(); isView=false; userEducationBackGround=resetUserEducationBackGround(); isEdit=false;">
        Add Educational Background

    </button>

UPDATE
Here's the save awards method.
saveEducationalAward(id) {
    let counter = 0;
    for (let item of this.awards) {
        counter++;
        let formData = new FormData();
        formData.append('photo', item.photo);
        formData.append('award', item.award);
        this.apiService.postData('users/educational-award/' + id, formData).subscribe(response = >{
            if (this.awards.length === counter) {
                this.finishSave();
            };
        });
    }
    if (this.awards.length === 0) {
        this.finishSave();
    };
}

onPictureSelected(files, index) {
    this.awards[index].photo = files[0];
}

Not sure if this information will suffice to solve this problem. Please let me know.


text:
Q: Generator vs Sequence object I know the difference between range and xrange.
But I was surprised to see that xrange wasn't agenerator but a sequence object.
What's the difference then, how to create a sequence object and when used it over a generator?

A: A sequence object is a special, C-provided type.  A generator can be written by user code.
This is a Python 2 thing -- in Python 3:
>>> print(type(range(1)))
<class 'range'>
>>> print(type(xrange(1)))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'xrange' is not defined

Python2:
Python 2.7.5+ (default, Feb 27 2014, 19:37:08)
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print type(xrange(1))
<type 'xrange'>

A: The reason that xrange is a sequence object is because it supports the sequence methods interface.  For example you can index it (which is something you can't do with a vanilla generator):
print xrange(30)[5]  # No Error

In other words,

*

*something is a sequence if it supports all of the methods defined in that link.

*If it's a generator, it probably only supports a couple methods (.next or .__next__ are the most important)1.

*there's also an in-between land which is "iterable" -- "iterables" have a typically2 defined __iter__ method which returns "generator" (something with a well defined .next or .__next__3 method)

*just to be complete, you'll often see people say "iterators" which are very similar to generators (implement __iter__ which returns the object itself and has a well defined next and/or __next__ method).

More formal definitions can be found in the documentation glossary
1generators also support __iter__ and simply return themselves. so techincally, all generators are also iterables (and iterators!), but not all iterables (iterators) are generators.
2__len__ + __getitem__ is enough to create an iterable as pointed out in the comments.
3__next__ is the method name for python3.x


text:
Q: Android draw on zoomed image I'm trying to draw some points on an ImageView which also features DRAG and ZOOM capabilities.
My implementation works fine if the image is not modified ( zoomed or dragged ), but if I apply these types of transformations, it won't draw correctly anymore.
Instead it will hold the initial frame as reference and will draw the dots as if it weren't modified.
This is what the image looks like right after choosing it from the gallery and drawing a green dot by tapping on it.

This is what the image looks like after zooming it in and dragging it to the side. As you can see, if I tap inside the initial frame, it will draw the dot inside the image as if it were unscaled.

Bellow is the code (select image from gallery, onTouch method and the actual drawing).
public void onClick(View v) {

    if (v.getId()==R.id.putPoint){
        drawPath=true;
    }
    else
    if (v == choosePicture) {
        Intent choosePictureIntent = new Intent(
                Intent.ACTION_PICK,
                android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        startActivityForResult(choosePictureIntent, 0);
    }
}

protected void onActivityResult(int requestCode, int resultCode,
                                Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);

    if (resultCode == RESULT_OK) {
        Uri imageFileUri = intent.getData();
        try {
            BitmapFactory.Options bmpFactoryOptions = new BitmapFactory.Options();
            bmpFactoryOptions.inJustDecodeBounds = true;
            bmp = BitmapFactory.decodeStream(getContentResolver().openInputStream(
                    imageFileUri), null, bmpFactoryOptions);

            bmpFactoryOptions.inJustDecodeBounds = false;
            bmp = BitmapFactory.decodeStream(getContentResolver().openInputStream(
                    imageFileUri), null, bmpFactoryOptions);

            alteredBitmap = Bitmap.createBitmap(bmp.getWidth(), bmp
                    .getHeight(), bmp.getConfig());

            canvas = new Canvas(alteredBitmap);
            paint = new Paint();
            paint.setColor(Color.GREEN);
            paint.setStrokeWidth(5);
            matrix = new Matrix();
            canvas.drawBitmap(bmp, matrix, paint);

            choosenImageView.setImageBitmap(alteredBitmap);
            choosenImageView.setOnTouchListener(this);
        } catch (Exception e) {
            Log.v("ERROR", e.toString());
        }
    }
}
public boolean onTouch(View v, MotionEvent event) {
    int action = event.getAction();
    ImageView view = (ImageView) v;
    if(drawPath) {
    //I use this flag to enable drawing mode

        switch (action) {
            case MotionEvent.ACTION_DOWN:
                downx = event.getX();
                downy = event.getY();
                canvas.drawCircle(downx, downy, radius,paint);
                choosenImageView.invalidate();
                drawPath=false;
                break;

        }
        return true;
    }
    else{
        //if the drawing mode is not enable I can zoom and drag the image
        switch (event.getAction() & MotionEvent.ACTION_MASK) {
            case MotionEvent.ACTION_DOWN:
                savedMatrix.set(matrix);
                start.set(event.getX(), event.getY());
                mode = DRAG;
                lastEvent = null;
                break;
            case MotionEvent.ACTION_POINTER_DOWN:
                oldDist = spacing(event);
                if (oldDist > 10f) {
                    savedMatrix.set(matrix);
                    midPoint(mid, event);
                    mode = ZOOM;
                }
                lastEvent = new float[4];
                lastEvent[0] = event.getX(0);
                lastEvent[1] = event.getX(1);
                lastEvent[2] = event.getY(0);
                lastEvent[3] = event.getY(1);
                d = rotation(event);
                break;
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_POINTER_UP:
                mode = NONE;
                lastEvent = null;

                break;
            case MotionEvent.ACTION_MOVE:
                if (mode == DRAG) {
                    matrix.set(savedMatrix);
                    float dx = event.getX() - start.x;
                    float dy = event.getY() - start.y;
                    matrix.postTranslate(dx, dy);

                } else if (mode == ZOOM) {
                    float newDist = spacing(event);
                    if (newDist > 10f) {
                        matrix.set(savedMatrix);
                        float scale = (newDist / oldDist);
                        matrix.postScale(scale, scale, mid.x, mid.y);
                    }
                }
                break;
        }

        view.setImageMatrix(matrix);
        return true;

    }
}

}
My goal is to be able to tap on the image(zommed or dragged) and see the points drawn correctly.

A: See: How do I get touch coordinates with respect to canvas after scaling and translating?
The easiest and most consistent way to do this is to apply the inverse matrix you used to modify the view modify the MotionEvent. There's two commands you need to know:
event.transform(invertMatrix);

and:
invertMatrix = new Matrix(viewMatrix);
invertMatrix.invert(invertMatrix);

Basically you do the opposite of what you did to the view to the touches. So the touches go to the scene space.


text:
Q: Multiple Controllers in .net core How do you route with multiple controllers? I am confused... I have it working for logins but when I try to do with another task it cant find the page, though the URL is correct.. I had this folder under the main views but moved it to an area to see if that was my issue. I generated the CompanyInformationsController from scaffolding, and it works if I just make it a standard link off the same home controller, but as soon as I try to do CRUD operations and it creates the controller and folders I cant get it to route...

Controller
public class CompanyInformationsController : Controller
{
    private readonly ApplicationDbContext _context;

    public CompanyInformationsController(ApplicationDbContext context)
    {
        _context = context;
    }

    // GET: CompanyInformations

    public async Task<IActionResult> Index()
    {
        return View(await _context.CompanyInformations.ToListAsync());
    }

CSHTML

                         Dashboard

                         Clients

Program
    app.UseEndpoints(endpoints =>
{
//    endpoints.MapAreaControllerRoute(
//    name: "Onboarding",
//    areaName: "Onboarding",
//    pattern: "Onboarding/{controller=Onboarding}/{action=Index}"
//);

    endpoints.MapControllerRoute(
        name: "areaRoute",
        pattern: "{area:exists}/{controller}/{action}"
    );

    endpoints.MapControllerRoute(
        name: "default",
        pattern: "{controller=Home}/{action=Index}/{id?}"
    );

});

A: By default, your routing will be generated from your controller name excluding the 'Controller' text from the controller name.
You can provide custom routing using Attribute routing on the Controller level. You can add any text on the routing. Like below:
[Route("CompanyInformations")]
public class CompanyInformationsController : Controller
{
}

A: I deleted and regenerated the scaffolding and its working..... Not sure why since I have done this already....

A: Below is my suggestion: Add {id} to your route
In Startup.cs:
app.UseEndpoints(endpoints =>
            {
                endpoints.MapAreaControllerRoute(
                     name: "Onboarding",
                     areaName: "Onboarding",
                     pattern: "Onboarding/{controller=CompanyInformations}/{action=Index}/{id?}"
               );
                endpoints.MapControllerRoute(
                      name: "areaRoute",
                      pattern: "{area:exists}/{controller}/{action}/{id}"

               );
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });

In controller: Add  [Area("Onboarding")]
    [Area("Onboarding")]
    public class CompanyInformationsController : Controller
    {
        private readonly Mul1Context _context;

        public CompanyInformationsController(Mul1Context context)
        {
            _context = context;
        }

        // GET: CompanyInformations
        public async Task<IActionResult> Index()
        {
            return View(await _context.CompanyInformation.ToListAsync());
        }
}

result:


text:
Q: How do I use an imagestream from another namespace in openshift? I have been breaking my head over the following:
I have a set of buildconfigs that build images and create imagestreams for it in the "openshift" namespace. This gives me for example the netclient-userspace imagestream.
krist@MacBook-Pro netmaker % oc get is netclient-userspace
NAME                  IMAGE REPOSITORY                                                                 TAGS     UPDATED
netclient-userspace   image-registry.openshift-image-registry.svc:5000/openshift/netclient-userspace   latest   About an hour ago

What I have however not been able to figure out is how to use this imagestream in a deployment in a different namespace.
Take for example this:
kind: Pod
apiVersion: v1
metadata:
  name: netclient-test
  namespace: "kvb-netclient-test"
spec:
  containers:
    - name: netclient
      image: netclient-userspace:latest

When I deploy this I get errors...
Failed to pull image "netclient-userspace:latest": rpc error: code =
Unknown desc = reading manifest latest in
docker.io/library/netclient-userspace: errors: denied: requested
access to the resource is denied unauthorized: authentication required

So openshift goest and looks for the image on dockerhub. It shouldn't. How do I tell openshift to use the imagestream here?

A: When using an ImageStreamTag for a Deployment image source, you need to use the image.openshift.io/triggers annotation. It instructs OpenShift to replace the image: attribute in a Deployment with the value of an ImageStreamTag (and to redeploy it when the ImageStreamTag changes in the future).
Importantly, note the annotation and the image: ' ' with the explicit space character in the yaml string.
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    image.openshift.io/triggers: '[{"from":{"kind":"ImageStreamTag","name":"content-netclient-userspace:latest","namespace":"openshift"},"fieldPath":"spec.template.spec.containers[?(@.name==\"netclient\")].image"}]'
  name: netclient-test
  namespace: "kvb-netclient-test"
spec:
  ...
  template:
    ...
    spec:
      containers:
      - command:
        - ...
        image: ' '
        name: netclient
...

I will also mention that, in order to pull images from different namespaces, it may be required to authorize the Deployment's service account to do so: OpenShift Docs.


text:
Q: Is there a way to completely disable copy/paste functionality in Visual Studio? I'm looking for a way to completely disable the copy/paste functionality in Visual Studio (2005 if it matters). The reason behind this request is that I want to prevent myself from doing too much copy/paste while coding.
Thanks to all for your answers!

A: Yes, there is a way.
Download AutoHotKey. Save this as GoAwayN00b.ahk and double click it.
#ifWinActive, ahk_class wndclass_desked_gsk

^c::
^v:: MsgBox Go away n00b !

Additionally, you may want to provide visualisation for xtra stimulation. Save this picture and display it on hotkey press (left for exercise):
alt text http://images.paraorkut.com/img/funnypics/images/g/go_away_noob-12269.jpg
BTW, copy/paste + CLCL = FTW. I don't use VS without it.
EDIT:
Alternativelly, you can Customize Keyboard (right click toolbar -> Customize->Keyboard) and delete Edit.Copy and Edit.Paste hotkies.
However, above script works with any VS and on any computer while this solution needs to be setup individually.

A: The other day my daughter asked if I had a duller saw so she wouldn't cut herself as easily while pruning some bushes. Of course now it takes longer to prune the bushes...

A: As asked: The other day my daughter asked if I had a duller saw so she wouldn't cut herself as easily while pruning some bushes. Of course now it takes longer to prune the bushes...  Refactored.
For dull saw she asked
No injury while pruning
Free time now all gone

A: I think you missed the point of the article but in you really want to, here are some resources for battle copypasta.

A: As Jeff lines out in his current blog entry, copy&paste itself is not the problem, but how you use it. As copy&paste can also be used to speed up "typing"/editing, you shouldn't disable it.

A: Prise your C button out of the keyboard.

A: No.  Use self-discipline instead.

A: Copy and paste is a valuable tool. You should be careful about what you copy and paste, but you don't need to disable it. Just watch what you're doing.

A: Don't forget to disable CTRL-drag as well!

A: Maybe you can find some sort of util that allows you to global remap key combinations. Then all you have to do is re-map the copy/paste combinations do to something else. Just an idea.
Although I think you are crazy for wanting to do it. :)

A: Write a small service program that will monitor clipboard changes and upon notification replace the clipboard text with "Content protection from lazy asses".


text:
Q: How do I merge multiple txt files with different file names in to one txt file, successfully? Scenario:
During the day, several txt files are created in a specific folder on the network.  These txt files are all different names.  A batch file will then run which combines all the txt files in to one master txt file.
What I've done so far:
The closest I've gotten to accomplishing this is by running a batch file in the same network folder which contains the following script
copy /b *.txt IMPORT.txt

The Problem:
The "IMPORT.txt" file will not successfully add the contents of each file directly beneath the previous data.  It will sometimes just add it to the last word in the previous data set.
Example:
File 1 is named "n5z.txt"
The contents of that file are
John, Doe

File 2 is named "po6.txt"
The contents of that file are
Jane, Doe
George, Washington

File 3 is named "xyz.txt"
The contents of that file are
John, Adams
Betty, White
Tom, Petty
Chris, White

Then I open the Windows Batch file (.bat) located in the same folder which runs the following script
copy /b *.txt IMPORT.txt

The ending result is a file named "IMPORT.txt"
The contents of this file looks like this
John, DoeJane, Doe
George, WashingtonJohn, Adams
Betty, White
Tom, Petty
Chris, White

I need it to look like this
John, Doe
Jane, Doe
George, Washington
John, Adams
Betty, White
Tom, Petty
Chris, White

A: @ECHO OFF
SETLOCAL
SET "sourcedir=."
SET "destdir=U:\destdir"
SET "filename1=q45178448*.txt"
SET "outfile=%destdir%\outfile.txt"
(
FOR /f "delims=" %%a IN (
 'dir /b /a-d "%sourcedir%\%filename1%" '
 ) DO (
 TYPE "%sourcedir%\%%a"
 ECHO.
)
)>"%outfile%"

GOTO :EOF

You would need to change the settings of sourcedir and destdir to suit your circumstances.
I used some files named q45178448*.txt containing some dummy data for my testing. You would need to enter your required filemask to replace this value.
Produces the file defined as %outfile%
The problem appears to be that the .txt files generated do not have a terminal newline, so this procedure simply generates a list of the required files in memory, serially types then to the destination with a newline inserted after each by the echo.
--edit 201708041820
sourcedir should not be in filename1 - only worked because I'd used . for sourcedir.

A: Try the Bash-for-Windows stuff
This is a really straightforward problem for anyone on Linux, where you would just write,
ls *.txt | xargs awk 1 >IMPORT.txt

Fortunately, those tools are now available on the Windows 10 command line, so just try that and see if it works?


text:
Q: how can I make my app not break on certain screen sizes due to scaling I'm building an app and I can't figure out how can I make my app not break on certain screen sizes.
I want the app to have a standard look on all devices.
how it should look here
how it looks on the pixel 3
how it looks on a tablet
<ImageView
    android:scaleType="fitXY"
    android:id="@+id/imageView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:srcCompat="@drawable/hub_background" />

<androidx.constraintlayout.widget.Guideline
    android:id="@+id/guideline2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    app:layout_constraintGuide_begin="19dp" />

<androidx.constraintlayout.widget.Guideline
    android:id="@+id/guideline3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    app:layout_constraintGuide_end="19dp" />

<ImageView
    android:translationZ="3dp"
    android:id="@+id/background2"
    android:layout_width="409dp"
    android:layout_height="1200dp"
    android:adjustViewBounds="true"
    android:maxWidth="302dp"
    android:maxHeight="722dp"
    android:scaleType="fitXY"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent"
    app:srcCompat="@drawable/start_anim_background_color"
    tools:visibility="gone" />

<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/monthProgress"
    android:layout_width="327dp"
    android:layout_height="159dp"
    android:layout_marginTop="40dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.494"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="@+id/imageView"
    app:layout_constraintVertical_bias="0.0"
    tools:ignore="=">

    <TextView

        android:id="@+id/topPanel"
        android:layout_width="320dp"
        android:layout_height="70dp"
        android:layout_marginBottom="35dp"
        android:background="@drawable/btn_shape_capsule_empty"
        android:gravity="center_vertical"
        android:textAlignment="center"
        android:textSize="16dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="@+id/time"
        app:layout_constraintStart_toStartOf="@+id/money"
        tools:ignore="RtlCompat" />

    <TextView
        android:id="@+id/money"
        android:layout_width="160dp"
        android:layout_height="70dp"
        android:layout_marginBottom="35dp"
        android:gravity="center_vertical"
        android:text="1500$"
        android:textAlignment="center"
        android:textSize="20dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        tools:ignore="RtlCompat" />

    <TextView
        android:id="@+id/time"
        android:layout_width="160dp"
        android:layout_height="70dp"
        android:layout_marginBottom="35dp"
        android:gravity="center_vertical"
        android:text="150hrs"
        android:textAlignment="center"
        android:textSize="20dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        tools:ignore="RtlCompat" />

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="28dp"
        android:text="Your month's progress:"
        android:textColor="@color/white"
        android:textSize="20dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/line"
        android:layout_width="1dp"
        android:layout_height="30dp"
        android:background="#757575"
        app:layout_constraintBottom_toBottomOf="@+id/topPanel"
        app:layout_constraintEnd_toEndOf="@+id/topPanel"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/topPanel" />

</androidx.constraintlayout.widget.ConstraintLayout>

<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/layout1"
    android:layout_width="150dp"
    android:layout_height="280dp"
    android:layout_marginStart="47dp"
    android:layout_marginLeft="47dp"
    android:layout_marginBottom="250dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent">

    <android.widget.Button
        android:id="@+id/button1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/btn_shape_lightedge4"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintStart_toStartOf="parent" />

    <TextView
        android:id="@+id/text1"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginBottom="200dp"
        android:backgroundTint="@color/white"
        android:gravity="center"
        android:text="start a new\nshift"
        android:textSize="18dp"
        android:translationZ="3dp"
        app:layout_constraintBottom_toBottomOf="@+id/button1"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        tools:ignore="MissingConstraints" />

</androidx.constraintlayout.widget.ConstraintLayout>

<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/layout2"
    android:layout_width="150dp"
    android:layout_height="170dp"
    android:layout_marginEnd="47dp"
    android:layout_marginRight="47dp"
    android:layout_marginBottom="360dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent">

    <android.widget.Button
        android:id="@+id/button2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/btn_shape_lightedge2"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginBottom="90dp"
        android:backgroundTint="@color/white"
        android:gravity="center"
        android:text="see all of\nyour shifts"
        android:textSize="18dp"
        android:translationZ="3dp"
        app:layout_constraintBottom_toBottomOf="@+id/button2"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        tools:ignore="MissingConstraints" />

</androidx.constraintlayout.widget.ConstraintLayout>

<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/layout3"
    android:layout_width="150dp"
    android:layout_height="280dp"
    android:layout_marginEnd="47dp"
    android:layout_marginRight="47dp"
    android:layout_marginBottom="70dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent">

    <android.widget.Button
        android:id="@+id/button3"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/btn_shape_lightedge3"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginBottom="200dp"
        android:backgroundTint="@color/white"
        android:gravity="center"
        android:text="settings"
        android:textSize="18dp"
        android:translationZ="3dp"
        app:layout_constraintBottom_toBottomOf="@+id/button3"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        tools:ignore="MissingConstraints" />

</androidx.constraintlayout.widget.ConstraintLayout>

<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/layout4"
    android:layout_width="150dp"
    android:layout_height="170dp"
    android:layout_marginStart="47dp"
    android:layout_marginLeft="47dp"
    android:layout_marginBottom="70dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent">

    <android.widget.Button
        android:id="@+id/button4"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/btn_shape_lightedge1"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintStart_toStartOf="parent" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginBottom="90dp"
        android:backgroundTint="@color/white"
        android:gravity="center"
        android:text="about"
        android:textSize="18dp"
        android:translationZ="3dp"
        app:layout_constraintBottom_toBottomOf="@+id/button4"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        tools:ignore="MissingConstraints" />

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
I'm using up as my measurement unit for everything.

A: It's impossible for it to look the same on all different screens as they have different ratios. But what is possible is to make it look very similar on different screens with the same ratio.
Generally the best is going with dp since the user can then rescale your app via Android settings if he/she has sight difficulties (to e.g. make it bigger). But if you prefer your app to always use the same design ratios you can for example use GridLayouts and weights. You can then specify how much percentage of your screen should be covered by a view. Additionally, you could of course also always go by manually implementing stuff like
desiredRatio = 0.4f;
viewHeight = desiredRatio * getMeasuredHeight();

and then applying the height to your view by changing the LayoutParams or implementing your own ViewGroup and do the whole onLayout stuff yourself (sure possible and necessary in rare occasions)
Generally, I'd try to get it done with GridLayouts or LinearLayouts using weights and in rare cases implement your own ViewGroup.
So in your case that could be something like
<androidx.gridlayout.widget.GridLayout
android:layout_width="match_parent"
android:layout_height=match_parent"
app:orientation="horizontal"
app:columnCount="2">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/monthProgress"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_rowWeight="1"
app:layout_columnWeight="1"
//...The rest of your stuff here
/>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_1"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_rowWeight="1"
app:layout_columnWeight="1"
//...The rest of your stuff here
/>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_3"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_rowWeight="1"
app:layout_columnWeight="1"
//...The rest of your stuff here
/>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_4"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_rowWeight="1"
app:layout_columnWeight="1"
//...The rest of your stuff here
/>

</androidx.gridlayout.widget.GridLayout>

Sorry for the missing indentations, the StackOverFlow code "editor" is just horrible.
Anyhow, that's how you'll get some parts done. Make sure to set the height in your ConstraintLayouts to "0dp", likewise with the width. Otherwise, GridLayout won't be able to do what you want.
Additionally, you used android:scaleType="fitXY" in your ImageView. That will look weird. Instead, I'd recommend centerCrop instead.


text:
Q: What is config.properties in Spring and what is the use of it I'm trying to build a simple CRUD operation on task management.
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="WebApp_ID" version="2.5">
    <display-name>SampleApplication</display-name>

      <welcome-file-list>
        <welcome-file>html/homepage.html</welcome-file>

    </welcome-file-list>

    <servlet>
        <servlet-name>spring</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>spring</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <context-param>
         <param-name>contextConfigLocation</param-name>
         <param-value>/WEB-INF/spring-servlet.xml</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>

</web-app>

Spring-servlet.xml
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <context:property-placeholder location="classpath:/config.properties"/>

    <!-- Spring will search in the bellow paths controller an services annotations-->
    <context:component-scan base-package="org.itc" />
    <mvc:resources mapping="/html/**" location="/html/" />
    <mvc:resources mapping="/js/**" location="/js/" />
    <mvc:annotation-driven />

    <bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url" value="jdbc:mysql://localhost:3306/task" />
        <property name="username" value="root" />
        <property name="password" value="root" />
    </bean>
</beans>

Im getting the below error.
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [config.properties] cannot be opened because it does not exist
    at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:151)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:265)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:162)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:609)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4842)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: class path resource [config.properties] cannot be opened because it does not exist
    at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)
    at org.springframework.core.io.support.EncodedResource.getInputStream(EncodedResource.java:143)
    at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:98)
    at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:175)
    at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:156)
    at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:142)
    ... 16 more

What does config.properties file missing mean? Im new to spring and trying to configure Spring MVC.

A: You have defined
<context:property-placeholder location="classpath:/config.properties"/>

That is, you want the application to load properties from the file config.properties found in the application's classpath.
The error means that it cannot find this file.
Without knowing your exact layout, build-chain or how you start the application I can't say exactly where you should put this file in order to have it available to the application. Somewhere like /src/main/resources/ perhaps.
If instead you don't need this file or externalised properties in general, you can stop telling the application that you do: Remove its definition from spring-servlet.xml.

A: If you don't have properties file in your application, remove this line from the Spring-servlet.xml file:
<context:property-placeholder location="classpath:/config.properties"/>

You are telling spring to search for a properties file named config.properties which does not exists.
If you need a properties file, then create the config.properties and put it in your classpath.

A: config.properties used to save application variables (properties). I find it very useful because:

*

*This file as mentioned can store some initial application cofig data,
like db connection.

*You can create your own properties and inject their values within Spring application. Also this properties can be preset with application run command (command line arguments)

*You can compile your application with config.properties inside, but on deployment create config.properties outside of compiled app and Spring will use properties from it instead of compiled file.

*You can preset profiles, and they will help on development, test, and deployment stage, because each bean can be marked with profile and will be injected depending on your application run mode.

These are features I use, and could be much more. Actually I not find any description how-to about config.properties. All this stuff mentioned in different places in Spring manual.
Update
Try Spring Boot - it contains Spring MVC, Hibernate and I found many good examples for starters. It was build to reduce initial config efforts.

A: ensure that you have config.properties and the file is placed in the /WEB-INF/classes folder and use classpath:/config.properties.

A: If you are going to use properties file you will have to declare bean org.springframework.beans.factory.config.PropertyPlaceholderConfigurer in your Spring-servlet.xml file.
Your Spring-servlet.xml:
<bean
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

    <property name="location">
        <value>classpath:config.properties</value>
    </property>
</bean>

your datasource bean will look like the following.
<bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="db.url.property" />
    <property name="username" value="db.user" />
    <property name="password" value="db.password" />
</bean>

You should have config.properties in your class path containing following properties.
Your config.properties
 db.url.property=jdbc:mysql://localhost:3306/task
 db.user=root
 db.password=root