text:
Q: Request to api works fine in component but not when using provider with react When making a request to my API from a component and using react-data-table-component everything works perfectly but if I try to make the request from my Product Provider the pagination is incorrect and no longer works as expected.
With this code I make the request, datatable and pagination from my component working perfectly:
import React, { useState, useEffect, useCallback, useMemo } from "react";
import axiosClient from "../config/axiosClient";
import DataTable from 'react-data-table-component-with-filter'
import { CSVLink } from "react-csv"
import { Link } from 'react-router-dom'
import useProducts from "../hooks/useProducts";

const removeItem = (array, item) => {
  const newArray = array.slice();
  newArray.splice(newArray.findIndex(a => a === item), 1);

  return newArray;
};

const ProductsTest = () => {

  const [data, setData] = useState([]);
  const [loading, setLoading] = useState(false);
  const [totalRows, setTotalRows] = useState(0);
  const [perPage, setPerPage] = useState(10);
  const [currentPage, setCurrentPage] = useState(1);
  const [searchBox, setSearchBox] = useState('')

  const STRING_TRADUCTIONS = { "KILOGRAM" : "KILOGRAMOS", "GRAMS" : "GRAMOS", "BOX" : "CAJA", "PACKAGE" : "PAQUETE", "BOTTLE" : "BOTE", "PIECES" : "PIEZAS", "BAG" : "BOLSA", "LITER" : "LITRO" }

  const fetchUsers = async (page, limit = perPage, search = searchBox) => {
    setLoading(true)
    const dataOnLs = localStorage.getItem('cmtjs')

    const config = {
      headers: {
          "Content-Type": "application/json",
          apiKey: dataOnLs
      } ,
      params: {
          limit,
          page,
          search
        }
  }
    const response = await axiosClient(`/products`, config)
    const data = response.data.products.docs.map( doc => (
      {
          _id: doc._id,
          idProduct: doc.idProduct,
          barCode: doc.barCode,
          name: doc.name,
          presentation: STRING_TRADUCTIONS[doc.presentation],
          salePrice: doc.salePrice,
          purchasePrice: doc.purchasePrice,
          stock: doc.stock,
          user: doc.user.username,
          category: doc.category.name,
          provider: doc.provider.name
      }
  ))
      setData(data);
      setTotalRows(response.data.products.totalDocs);
      setLoading(false);
  };

  useEffect(() => {
    fetchUsers(1)
  }, []);

  const columns = useMemo(
    () => [
      {
        name: "ID",
        selector: "idProduct",
        sortable: true
      },
      {
        name: "Código de Barras",
        selector: "barCode",
        sortable: true
      },
      {
        name: "Nombre",
        selector: "name",
        sortable: true
      },
      {
        name: "Presentación",
        selector: "presentation",
        sortable: true
      },
      {
        name: "Precio",
        selector: "salePrice",
        sortable: true
      },
      {
        name: "Stock",
        selector: "stock",
        sortable: true
      },
     { cell: row =>
      <Link to={ `/dashboard/product/${row._id}`}>
        <button className='btn btn-ghost text-xs'>
            Mas
        </button>
      </Link>}
    ]
  );

  const handlePageChange = page => {
    fetchUsers(page);
    setCurrentPage(page);
  };

  const handlePerRowsChange = async (newPerPage, page) => {
    fetchUsers(page, newPerPage);
    setPerPage(newPerPage);
  }

  const headers = [
    { label: "ID", key: "idProduct" },
    { label: "Código de Barras", key: "barCode" },
    { label: "Nombre", key: "name" },
    { label: "Presentación", key: "presentation" },
    { label: "Precio Venta", key: "salePrice" },
    { label: "Precio Compra", key: "purchasePrice" },
    { label: "Stock", key: "stock" },
    { label: "Creador", key: "user" },
    { label: "Categoría", key: "category" },
    { label: "Proveedor", key: "provider" }
  ]

  const paginationComponentOptions = {
    rowsPerPageText: 'Mostrar',
    rangeSeparatorText: 'de',
    selectAllRowsItem: true,
    selectAllRowsItemText: 'Todos',
};

const clear = () => {
  setPerPage(10)
  setSearchBox('')
  fetchUsers(1, 10, '')
}

  return (

      <input type="text" onChange={(e)=> setSearchBox(e.target.value)}/>
      <button onClick={ ()=> fetchUsers()}>Buscar</button>

      <CSVLink data={data} headers={headers} filename={"productos.cdtmx.csv"} className="cursor-pointer">
        <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABmJLR0QA/wD/AP+gvaeTAAACnUlEQVRoge2YXUhUQRiGn7HVRVddc8k0QawQw6hQohKSlsp+oDulQBGCbuxGQ1itDIx+IIWINKK86S4o6ibFEG9ywQzCEJLVSCylorYf1CJaXXe6SPvZ1ePZs3tczfNcfsP3zfvOzHc4M2BgYGAQSYTWxJSrReUg6oHEYHNtuRu1TDkupKx27Tp38+9glJZKv9AmPgQSpYiq9w+GYGBBxU8jrf6RUAwsCgwDkcYwEGlM/gFLVf4JkBcEWJQSvw+/Ua4cJYixWjElxoemcB4CDKgRrwqfZGJ0lImpqYChFe53IZefIeAIhUX8DDJsleZkyffA8jBgNkXTe+ouXy93U2Ev+R3PSE7jU70T96VHZNrSdROphCoDHu8kZ1quAVC1u4x4cxwAdQfLMZuiaei4xevPb/VTqYDqI9Ta56Rj4Ak2SxLHCw6zaU0Wxbl7Gfw4QlPnbT01KjLLZ3RuTj9oxJ61lQp7CYUbdiAQVN5rwOOd1EvfvATVxAMfXtHcdZ+k2ATy127hzrN2nIM9emlTRVA7AJAwff4BhJj/QmfpDuwNT0pCsNPOSVA7ULA+j7Jth3g63EfXUC9H8vazJ3t72MRoQbUBsymaK0UOhBCcbbtBbUsTUkoai2uIi4nVU6Miqg2c3HeM7NWZtPc/xjnYQ8+Ii9Y+JxnJadQUHtVToyKqDOSkrqPSXopP+jj/8M+jQF3bdby+KSrspWxOz9JNpBKqmtj1fojk6oKA+Ev3CCsdO8MuKhiWx7/QYmY2A9/CVt2n/4Vgth6oBS4Cod0FfVKa3Z4fgMd/yPb8i+ay/pma30ZTD+RoXl5rxiqtqbxo7vxH83/ZA0sKw0CkWdYGxsOmQj1j/gHNBoQQDhABBXVkTEocCzifgYGBgQp+AlpMnf09Cu/RAAAAAElFTkSuQmCC"/>
      </CSVLink>
      <DataTable
        columns={columns}
        data={data}
        progressPending={loading}
        pagination
        paginationServer
        paginationTotalRows={totalRows}
        paginationDefaultPage={currentPage}
        onChangeRowsPerPage={handlePerRowsChange}
        onChangePage={handlePageChange}
        selectableRows
        //onSelectedRowsChange={({ selectedRows }) => console.log(selectedRows)}
        paginationComponentOptions={paginationComponentOptions}
        noDataComponent="No hay resultados"
      />
      {
        searchBox && searchBox !== ''  &&  <button onClick={ () => clear() }>Limpiar</button>
      }

  )
}

But I have my product provider where I make a get request to all my products, avoiding making the requests from my component and having the data globally, but if I use "getProducts" from my provider, the first view of the datatable is correct however , when clicking on a page or next, the pager advances but the data displayed does not, for example: it shows me the first 10 records but I ask for the next 10 and the pager advances correctly but the data is still the first 10 records, No I know how to use my provider and make the pager show the following data depending on what the user needs.
This is the code of my provider to obtain the product data

    const getProducts = async(page, limit, search) => {

        const dataOnLs = localStorage.getItem('cmtjs')

        const config = {
            headers: {
                "Content-Type": "application/json",
                apiKey: dataOnLs
            } ,
            params: {
                page,
                limit,
                search
              }
        }
        try {
            const { data } = await axiosClient(`/products`, config)
            setProducts(data)
        } catch (error) {

So in my component I call "getProducts" from my provider to have the products data in "products" using the useEffect hook
  useEffect(() => {
    getProducts()
    setData(products.products?.docs)
    setTotalRows(products.products?.totalDocs)
    setLoading(false)
  }, []);

In my paginator to obtain the following 10 product records, I click and the text changes that indicates which page is being shown, but the data remains the same as the first page
  const handlePageChange = page => {
    getProducts(page); // it does not show the next 10 records as it happened in the fetch of my component
    setCurrentPage(page); // OK
  };

In the same way, my browser no longer works using it in this way, I only changed the function to call my provider now, but it does not work
      <input type="text" onChange={(e)=> setSearchBox(e.target.value)}/>
      <button onClick={ ()=> getProducts()}>Buscar</button>

I would like to know if you can help me to make my datatable and browser work using my provider. Thanks.

A: In this code
 useEffect(() => {
    getProducts()
    setData(products.products?.docs)
    setTotalRows(products.products?.totalDocs)
    setLoading(false)
  }, []);

You are calling getProducts(), which is asynchronous. Then you try setData(products...), but the asynchronous call did not finish yet, so products was not updated yet. When eventually the asynchronous code terminates, the useEffect statement is not triggered again, because the dependency array states that the effect is only executed when the component mounts.
Split up your effect in two parts instead, so the second effect gets triggered when new products are available:
 useEffect(() => {
    getProducts()
  }, []);

 useEffect(() => {
    setData(products.products?.docs)
    setTotalRows(products.products?.totalDocs)
    setLoading(false)
  }, [products]);


text:
Q: how to use OpenCV with VB.NET 2008 I have heard about EmguCv, OpenCV wrapper for VS.NET
I dindn't understand how to use it on VB.NET 2008.
is it different with OpenCV usage?
anyone can help me, may you have ebook, tutorial etc.
thank you so much..

A: There are naturally some slight differences when using EMGU. You best port of call are the examples I know that the downloaded examples with EMGU are lacking in VB examples. With thanks to giusdisa on the EMGU forums who has provided a web site with more examples
http://www.motoreitaliano.net/emgu/default.htm
There are no books but I would recommend going over these examples and get them running if you get any errors take a look at this article http://www.codeproject.com/KB/cs/EMGU_Image_Processing.aspx. While it is for C# it has details on errors that can occur and trouble shooting problems. If you encounter any other errors then please let me know. I am in the process of re-writing the article for VB so it would be useful to account for alternative errors.
Hope this helps,
Cheers,
Chris

redpajama_set_name: RedPajamaStackExchange


text:
Q: Error inflating xml layout ArrayIndexOutOfBoundsException on TextView I ran into a weird crash problem. I can't quite seem to figure out the problem.
Here is the crash report.
                  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bigappcompany.grocery/com.bigappcompany.grocery.activity.OrderDetailsActivity}: android.view.InflateException: Binary XML file line #125: Binary XML file line #125: Error inflating class <unknown>
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2560)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626)
                  at android.app.ActivityThread.-wrap11(ActivityThread.java)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475)
                  at android.os.Handler.dispatchMessage(Handler.java:111)
                  at android.os.Looper.loop(Looper.java:207)
                  at android.app.ActivityThread.main(ActivityThread.java:5740)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766)
               Caused by: android.view.InflateException: Binary XML file line #125: Binary XML file line #125: Error inflating class <unknown>
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
                  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
                  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                  at com.bigappcompany.grocery.activity.OrderDetailsActivity.onCreate(OrderDetailsActivity.java:11)
                  at android.app.Activity.performCreate(Activity.java:6543)
                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2513)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626)
                  at android.app.ActivityThread.-wrap11(ActivityThread.java)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475)
                  at android.os.Handler.dispatchMessage(Handler.java:111)
                  at android.os.Looper.loop(Looper.java:207)
                  at android.app.ActivityThread.main(ActivityThread.java:5740)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766)
               Caused by: android.view.InflateException: Binary XML file line #125: Error inflating class <unknown>
                  at android.view.LayoutInflater.createView(LayoutInflater.java:645)
                  at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
                  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694)
                  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)
                  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
                  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
                  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
                  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
                  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
                  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                  at com.bigappcompany.grocery.activity.OrderDetailsActivity.onCreate(OrderDetailsActivity.java:11)
                  at android.app.Activity.performCreate(Activity.java:6543)
                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2513)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626)
                  at android.app.ActivityThread.-wrap11(ActivityThread.java)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475)
                  at android.os.Handler.dispatchMessage(Handler.java:111)
                  at android.os.Looper.loop(Looper.java:207)
                  at android.app.ActivityThread.main(ActivityThread.java:5740)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766)
               Caused by: java.lang.reflect.InvocationTargetException
                  at java.lang.reflect.Constructor.newInstance(Native Method)
                  at android.view.LayoutInflater.createView(LayoutInflater.java:619)
                  at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
                  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694)
                  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)
                  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
                  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
                  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
                  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
                  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
                  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                  at com.bigappcompany.grocery.activity.OrderDetailsActivity.onCreate(OrderDetailsActivity.java:11)
                  at android.app.Activity.performCreate(Activity.java:6543)
                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2513)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626)
                  at android.app.ActivityThread.-wrap11(ActivityThread.java)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475)
                  at android.os.Handler.dispatchMessage(Handler.java:111)
                  at android.os.Looper.loop(Looper.java:207)
                  at android.app.ActivityThread.main(ActivityThread.java:5740)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766)
               Caused by: java.lang.ArrayIndexOutOfBoundsException: length=38; index=384
                  at android.content.res.StringBlock.get(StringBlock.java:65)
                  at android.content.res.XmlBlock$Parser.getPooledString(XmlBlock.java:458)
                  at android.content.res.TypedArray.loadStringValueAt(TypedArray.java:1151)
                  at android.content.res.TypedArray.getString(TypedArray.java:195)
                  at android.widget.TextView.<init>(TextView.java:1091)
                  at android.widget.TextView.<init>(TextView.java:696)
                  at android.widget.TextView.<init>(TextView.java:692)
                  at java.lang.reflect.Constructor.newInstance(Native Method)
                  at android.view.LayoutInflater.createView(LayoutInflater.java:619)
                  at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
                  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694)
                  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)
                  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
                  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
                  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
                  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
                  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
                  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                  at com.bigappcompany.grocery.activity.OrderDetailsActivity.onCreate(OrderDetailsActivity.java:11)
                  at android.app.Activity.performCreate(Activity.java:6543)
                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2513)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626)
                  at android.app.ActivityThread.-wrap11(ActivityThread.java)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475)
                  at android.os.Handler.dispatchMessage(Handler.java:111)
                  at android.os.Looper.loop(Looper.java:207)
                  at android.app.ActivityThread.main(ActivityThread.java:5740)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766)

Here is my activity xml file.
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.bigappcompany.grocery.activity.OrderDetailsActivity">

<include layout="@layout/toolbar"/>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"
        android:paddingBottom="@dimen/narrow"
        android:paddingEnd="@dimen/medium"
        android:paddingStart="@dimen/medium"
        android:paddingTop="@dimen/narrow"
        android:text="@string/order_summary"
        android:textSize="@dimen/text_medium"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/narrow"
        android:background="@color/white"
        android:paddingEnd="@dimen/medium"
        android:paddingStart="@dimen/large"
        android:paddingTop="@dimen/standard">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/order_number"/>

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="end"
            android:text="#123123"
            android:textColor="@color/black"
            android:textStyle="bold"/>
    </LinearLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_marginEnd="@dimen/narrow"
        android:layout_marginStart="@dimen/narrow"
        android:layout_marginTop="@dimen/thin"
        android:background="@color/colorBackground"/>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/rv_order"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginTop="@dimen/thin"
        android:layout_weight="1"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/narrow"
        android:background="@color/white"
        android:orientation="vertical"
        android:padding="@dimen/standard">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/white">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/cart_estimated"/>

            <TextView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="end"
                android:text="95"
                android:textColor="@color/colorPrimary"
                android:textStyle="bold"/>
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/narrow"
            android:background="@color/white">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/order_status"/>

            <TextView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="end"
                android:text="shipped"
                android:textColor="@color/black"
                android:textStyle="bold"/>
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorPrimary"
        android:orientation="horizontal"
        android:padding="@dimen/standard">

        <!-- line #125--> <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:text="@string/call_us"
            android:textAllCaps="true"
            android:textColor="@color/white"
            android:textSize="@dimen/text_big"/>

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:text="@string/email_us"
            android:textAllCaps="true"
            android:textColor="@color/white"
            android:textSize="@dimen/text_big"/>

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:text="@string/Cancel"
            android:textAllCaps="true"
            android:textColor="@color/transparent_White"
            android:textSize="@dimen/text_big"/>
    </LinearLayout>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>

As the crash report says the error seems to be on line 125 which is a TextView and if I remove the text view error happens on its sibling TextView.
Any notion or help would be highly appreciated!
UPDATE
I was able to narrow it down to one attribute which is causing the problem,
android:textAllCaps="true"

Any idea why making text all caps gives this exception?

A: In my case I had android:textDirection="firstStrongLtr" and firstStrongLtr was causing the crash, although the compiler was fine with it. so I changed it to ltr and everything was good. so the answer is to also avoid using firstStrongLtr and firstStrongRtl

A: use Button or
.setTransformationMethod(new AllCapsTransformationMethod(getContext()))

A: This can be fixed by calling setAllCaps(true) on the TextView/Button. If you're using databinding that's simply custom_ns:allCaps="@{true}" in XML.

A: I've spent hours resolving this issue as app was working perfectly on 8.1.0+ phones, but on 7.1.2 I had same crash. Resolved this by replacing android with app:
app:textAllCaps="true"

A: In my case, the crash occurs only in Android 7.0 with textAllCaps in a AppCompatButton with android:theme that was used only to change the button text appearance. So, I changed the android:theme to android:textApperance, kept the textAllCaps, and the problem was solved.
I don't know why the crash only occurs at API 24 and what was the relation about theme tag.


text:
Q: Can't open contents of internal laptop HDD via enclosure and I tried to format it using Tails OS but failed I bought a new hard disk enclosure today for my internal drive. I connected it to my laptop using the connection, and everything was working fine. I was able to access all the files stored in it, but when I tried to access the Users folder under the OS partition in it,  it prompted you need administrator permission to access the folder and there were Continue and Cancel options. I clicked Continue, then suddenly my file explorer stopped responding and everything froze.
I tried to eject it but the eject option was not coming, so I directly pulled out the hard disk enclosure without ejecting. And then I tried to reconnect it again. And it keeps on loading and I'm not able to access anything in it. I tried restarting my system, and I also tried connecting to other laptop, but I still have the same issue.
Then somebody suggested me to check in Linux so I live booted Tails OS and tried to connect it, but it was not accessible under normal file manager, there is disk utility in tails OS where it showed my enclosure hard disk and it showed as 1TB free so I thought the data was gone and tried to format it but got this error (check below in the screenshot). Now every time I connect it to Windows computer it runs on 100% usage at all times and the diskpart, chkdsk utilities freeze if I try to use them.
I don't want the data in it any more, but I want this drive to work.
Error message after formatting in Linux:

Magnified image:

A: In Windows, when you make a new installed drive, you get new userids.  These cannot access other users' private data.  Accessing as Administrator on Windows should work.  As Administrator, you can also grant access for other users.  I can't explain the "freeze".
On Linux, what you tried to do was create a new partition.  Since all the space was used, you couldn't do it.
What you probably want to do on Linux is to mount the existing filesystems.


text:
Q: How to check if Username/Email already exists android parse I've searched everywhere but haven't found anything about how to check if a username/email address in the parse database is taken. I've found some answers on the internet on parse.com forums but they weren't clear.
Thanks if you could help.
If this has an answer somewhere, then please comment instead of marking so I can delete it.

A: I think this will do what you need if I understand your question correctly:
final ParseQuery<ParseUser> emailQuery = ParseUser.getQuery();
            emailQuery.whereEqualTo("email", emailAddress);
            final ParseQuery<ParseUser> usernameQuery = ParseUser.getQuery();
            usernameQuery.whereEqualTo("email", username);
            List<ParseQuery> queries = new ArrayList<>();
            queries.add(emailQuery);
            queries.add(usernameQuery);
            final ParseQuery<ParseUser> query = ParseQuery.or(queries);
            query.findInBackground(new FindCallback<ParseUser>() {
                public void done(List<ParseUser> results, ParseException e) {
                    // results has the list of users that match either the email address or username
                }
            });

https://www.parse.com/docs/android/guide#queries-compound-queries
Or you could do it this way:
user.signUpInBackground(new SignUpCallback() {
            public void done(ParseException e) {
                if (e == null) {
                    // yippee!!
                } else {

                    switch (e.getCode()) {
                        case ParseException.USERNAME_TAKEN: {
                            // report error
                            break;
                        }
                        case ParseException.EMAIL_TAKEN: {
                            // report error
                            break;
                        }
                        default: {
                            // Something else went wrong
                        }
                    }
                }
            }
        });

A: Try this to check your data in parse. I hope this will helpful for you.
// this is create query of your parse table
ParseQuery<ParseObject> query = new ParseQuery<>(your prars tableName);
    query.whereEqualTo(YourParseColumeNameEmail, yourEmail);
    query.whereEqualTo(YourParseColumeNamePassword, yourPassword);

    // this is for doing in background
    query.findInBackground(new FindCallback<ParseObject>() {
        public void done(List<ParseObject> scoreList, ParseException e) {
            if (e == null) {
                if (scoreList.size() == 0) {
                   // if there is no data like your email and password then it,s come here
                } else {
                    // if there is data like your email and password then it,s come here
                }
            } else {
                Log.d("score", "Error: " + e.getMessage());
            }
        }
    });


text:
Q: toll-free bridged objects, retain and release I'm currently looking at a NSMutableSet created by the function CFSetCreateMutable(). The documentation states that the return value of CFSetCreateMutable() is toll-free bridged, meaning that I can simply cast it into a NSMutableSet. Does this mean that sending it the release message is perfectly valid? Am I always safe to assume that I can always treat such objects as if they were alloc'ed via an NS-class?

A: Just imagine that CFSetCreateMutable() is equivalent to [[NSMutableSet alloc] init] in that you have to release the object after you are done with it. If you are using ARC, you can cast a CFMutableSet to an NSMutableSet using a bridged cast: (__bridge_transfer NSMutableSet *)theCFSet. This will tell ARC that it is responsible for releasing the set after it goes out of scope.

A:
The documentation states that the return value of CFSetCreateMutable() is toll-free bridged, meaning that I can simply cast it into a NSMutableSet. Does this mean that sending it the release message is perfectly valid?

Yes. This is explicitly guaranteed in the docs:

Note from the example that the memory management functions and methods are also interchangeable—you can use CFRelease with a Cocoa object and release and autorelease with a Core Foundation object.

Am I always safe to assume that I can always treat such objects as if they were alloc'ed via an NS-class?

Not really: Currently, anything that exists in common between CFType and NSObject, such as -description/CFCopyDescription, works regardless of how you created the object, but they're not all explicitly guaranteed to work like the memory-management messages are.


text:
Q: Discriminator column : Class has no field or association named type I have a class contract that contains the abstract attribute contractInfo Type
/**
 * @var ContractInfoType|null
 *
 * @ORM\OneToOne(targetEntity="ContractInfoType", cascade={"persist"})
 * @ORM\JoinColumn(name="contract_info_type_id", referencedColumnName="id", nullable=true)
 */
private $contractInfoType;

ContractInfoType is an abstract entity : ContractInfoPro and ContractInfoAsso inherit from them
/**
 * ContractInfoType
 *
 * @ORM\Table(name="contract_info_type",
 *   indexes={
 *     @ORM\Index(name="IDX_TYPE", columns={"type"}),
 *   }
  * )
 * @ORM\Entity(repositoryClass="App\Repository\Contract\ContractInfoTypeRepository")
 * @ORM\InheritanceType("JOINED")
 * @ORM\DiscriminatorColumn(name="type", type="string")
 * @ORM\DiscriminatorMap(
 *     {
 *      "pro" = "App\Entity\Contract\Type\ContractInfoPro",
 *      "asso" = "App\Entity\Contract\Type\ContractInfoAsso"
 *     }
 * )
 * @ORM\HasLifecycleCallbacks
 */
abstract class ContractInfoType
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    public function getId(): int
    {
        return $this->id;
    }

    public function setId(int $id): self
    {
        $this->id = $id;

        return $this;
    }

    abstract public function getType(): string;
}

and the class that inherit ContractInfoType
/**
 * ContractInfoAsso
 *
 * @ORM\Table(name="contract_info_asso")
 * @ORM\Entity(repositoryClass="App\Repository\Contract\ContractInfoAssoRepository")
 * @ORM\HasLifecycleCallbacks
 */
class ContractInfoAsso extends ContractInfoType
{
    const TYPE = 'asso';

    /**
     * @var string
     *
     * @ORM\Column(name="num_prefecture", type="string", length=40, nullable=true)
     *
     * @Assert\Type(
     *     type="string",
     *     message="The value {{ value }} is not a valid {{ type }}."
     * )
     * @Assert\Length(
     *      max = 40,
     *      maxMessage = "num_prefecture value cannot be longer than {{ limit }} characters"
     * )
     */
    private $numPrefecture;

    /**
     * @return string
     */
    public function getNumPrefecture(): string
    {
        return $this->numPrefecture;
    }

    /**
     * @param string $numPrefecture
     */
    public function setNumPrefecture(string $numPrefecture): self
    {
        $this->numPrefecture = $numPrefecture;

        return $this;
    }

    public function getType(): string
    {
        return self::TYPE;
    }
}

My goal is to filter the contract by the discriminator column type like I would do in SQL:
 select * from contract left join contract_info_type cit on contract.contract_info_type_id = cit.id where cit.type LIKE "pro"

However when I try to do it with doctrine this way
$queryBuilder->leftJoin('contract.contractInfoType', 'type');
$queryBuilder->andWhere('type.type = :type");

I got the error
[Semantical Error] line 0, col 183 near 'type = :type': Error: Class App\\Entity\\Contract\\ContractInfoType has no field or association named type

Which make sense since I have no real field type declared in the entity.
How should I make this work with doctrine ?

A: It seems like you cannot use the discriminator in such a way. In your DQL try using "INSTANCE OF" instead of a join.
More info
Possible duplicate


text:
Q: How to decrypt a file using gpg without knowing its type before encrypting I know how to decrypt a file:
gpg --passphrase mySecretPass -o /home/me/dummy.xml -d /home/me/dummy.gpg
but in my case this dummy.gpg can be xml or zip before encryption.
How could I save the output with the proper extension?

A: You don't need to know the extension before decrypting. You can run:
gpg --passphrase mySecretPass -o /home/me/dummy -d /home/me/dummy.gpg
And then run:
file /home/me/dummy
The file command will return the file type based on the header.
You can also use mimetype


text:
Q: Google oauth2 works with one time code generated from Android but not working for code generated from JS SDK I am trying to authenticate the user using oauth2 api from Google. There are 2 platforms, Android and Web. For new users, I am fetching the one-time auth code on the client and sending it to the server on both platforms. Once server receives the code, it is fetching the access token and after that, the user details. The server is able to fetch the token from the one-time auth code sent from Android device, but it is failing for the code sent from Web.
This is my code snippet in JS for fetching one-time auth code..
gauth2.grantOfflineAccess({
        'scope': 'profile email',
        'redirect_uri': 'postmessage'
    }).then(function(e){
        if(!e){
            // Error
        }
        else{
            console.log('Auth code: '+e.code);
        }
    });

On server side, this is the POST request that I am doing to fetch the token from one-time code..
post_data = {'code': one_time_code, 'client_id': settings.GOOGLE_OAUTH2_CLIENT_ID, 'client_secret': settings.GOOGLE_OAUTH2_CLIENT_SECRET, 'grant_type': 'authorization_code'}
req = urllib2.Request("https://www.googleapis.com/oauth2/v3/token", data=urllib.urlencode(post_data), headers={'User-Agent': 'Mozilla/5.0'})
req.get_method = lambda: 'POST'
res = urllib2.urlopen(req)
if res.code == 200:
    print "response 200 : "
else:
    print "Access Token Validation Return Code: ", res.code

This web service call returns 200 and token when the auth-code is generated from Android. When it is sent from web, the same method throws the following error..

Error: 400, invalid request; missing parameter 'redirect_uri'

In this case, I don't need to send any redirect_uri, because I am reading the response there itself. But I still tried setting an empty value and also tried setting it to some value that exactly matches one of the values in google developers console. In that case, I am still getting..

Error: 400, invalid request; redirect_uri mismatch.

I cannot get my head around the fact that this web service call is working perfectly for android codes and not for web codes. Please note that scopes are different for Android app and Web app. But still, this seems to be some fundamental error. Any help would be appreciated.


text:
Q: Overlapping pyplot.imshow() plot in single grid I want to plot this figures. For the first figure:
Figure1.png
For the code snippet:
import matplotlib.pyplot as plt
row = 30
col = row
areas_pher = [[-0.01 for i in range(col)] for j in range(row)]

for i in range(1, row-1):
    for j in range(1, col-1):
         areas_pher[i][j] = 0
max_pher = 20
for pher in range(1, col-1):
    areas_pher[15][pher] = max_pher * pher/max_pher
plt.imshow(areas_pher, cmap="Blues_r", vmin=0, vmax=max_pher)

And the second figure:
Figure2.png
For the code snippets:
import matplotlib.pyplot as plt
import numpy as np

areas_ant = [[6 for i in range(col)] for j in range(row)]
prob_ant = 0.05

for i in range(1, row-1):
    for j in range(1, col-1):
        rand = np.random.rand()
        if rand < prob_ant:
            areas_ant[i][j] = 5
plt.imshow(areas_ant, cmap="Blues")

My question, what the best way to make its figures overlapping, for illustrate like this image below?
Overlapping Figures Illustration.png


text:
Q: How do I make BitBucket recognize line breaks in commit comments? I work with mercurial, and use long(ish), multi-line commit comments.
Recently, I've put my project on BitBucket.org, and have noticed that when my commit comments are appended to issue pages (see this SO question for information on how/when that happens), the newlines are replaced with spaces, while double-newlines stay double-newlines.
How should I mark single-newlines in commit messages so that BitBucket acknowledges them? I'd like to do this in the least-obtrusive way for when I read the comments normally from the command line.

A: Break paragraphs (generating
 tags) with a blank line. Break lines (generating a
 tag) by ending the first line with two or more spaces, e.g.
Line one␣␣
Line two

Bitbucket formats comments using Markdown, which has this to say about paragraphs and line breaks:

Paragraphs and Line Breaks
A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines. (A blank line is any line that looks like a blank line — a line containing nothing but spaces or tabs is considered blank.) Normal paragraphs should not be indented with spaces or tabs.
The implication of the "one or more consecutive lines of text" rule is that Markdown supports "hard-wrapped" text paragraphs. This differs significantly from most other text-to-HTML formatters (including Movable Type's "Convert Line Breaks" option) which translate every line break character in a paragraph into a
 tag.
When you do want to insert a
 break tag using Markdown, you end a line with two or more spaces, then type return.
Yes, this takes a tad more effort to create a
, but a simplistic "every line break is a
" rule wouldn't work for Markdown. Markdown's email-style blockquoting and multi-paragraph list items work best — and look better — when you format them with hard breaks.


text:
Q: Facebook page: How to add a customized box at the bottom left side of wall tab? Dear all, I have a question about Facebook Page: (NOT user profile page, I mean a facebook page where you can become a fan)
How to add a customized box at the bottom left side of wall tab?
(I am the page creator/admin)
Please don't just give an answer "add the box to the page". Cause I really don't know how.
Also, it seems that putting $facebook->api_client->profile_setFBML and $facebook->api_client->profile_setInfo for the application won't provide a way for the page to add the box.
Below is an example image that is done by the other. I have circled the box at the image. I would like to know how to do the same to the page that I owned. Many thanks for reading.
alt text http://design.outblaze.com/calvin/facebook/facebookPageBoxQ.jpg

A:  $facebook->api_client->profile_setFBML

is absolutely correct afair.  Go to the App Page and Add the App to your Fan Page. It will most properbly appear in the Boxes Tab.
    // get the fbml for the box
    $main_box = $this->render();
    // the first main_box is actually deprecated feel free not to use it
    $this->facebook->api_client->profile_setFBML($main_box, PAGE_ID, $main_box, NULL, $main_box, $main_box);
    // for easier workflow forward the user directly to the page
    $this->facebook->redirect(PAGE_URL);

But as said by others in this thread in 90% of the cases the Static FBML App by Facebook does the job.

A: Unreality's answer helped me best but one clarification is needed. These boxes can be added only to "Pages" that you have admin rights to.  You cannot add one of these boxes to your profile page from what I can see.  (Anybody? Prove me wrong, please!)

A: You write an application that has a box. You add the box to the page, then move the box to the page's wall.
For example, I moved the Notes box on my app's page to my wall so you could see it:
http://www.facebook.com/apps/application.php?id=96193636102
Update, with more info:
In general, the way you do this is you add a function to your app that creates a block of fbml and passes it to setFBML(), using your page's ID instead of a user ID as the destination.
I'm planning to do this myself to add some summary statistics to my app's profile page, but that has to wait til after working hours.

A: I have found the answer. It's using the static fbml made from facebook
http://www.facebook.com/apps/application.php?id=4949752878&ref=s
Go there, click "add to my page", and pick your page.
Then goto your own page, and click "Edit page", then you will find FBML under the applications.
Click the pencil at the FBML box top right, select edit.
Then at the edit page, just write something up and save the changes
Next go back to your own page. Goto the "Boxes" tab, you will find the FBML box that you have just made.
Click the pencil button at the FBML box, select "Move to Wall Tab", and then done! Happy FaceBooking!

A: As far as I understand the profile boxes will be removed soon.


text:
Q: Prove that if $f(a)=f(b)=0$ with $f'$ differentiable then for any $c$ there is $x_0$ st. $f'(x_0)=cf(x_0)$. Assume $f:[a,b] \to \mathbb R$ is continuous on the closed interval $[a,b]$ and differentiable on $(a,b)$ with $f(a)=f(b)=0$. Prove that for every $c \in \mathbb R$ there exists $x_0 \in (a,b)$ such that $f'(x_0)= cf(x_0)$.
Here is my work so far: Assume the case is true for $c = 1$. Then for any other $c$ let $g(x):=f(cx)$. Then since the case holds for $c=1$ there exists $x_0 \in [a/c, b/c]$ such that $f'(cx_0)=1/c f(cx_0)$. My inteuctor said that, while my effort for reducion does not exactly work (since we have to check that our motified value lies ina proper interval and check other things), I can make some similar argument to reduce the case to $c=1$. Some people suggested that I take a look at the logarithmic and exponential functions, but I am not sure how that would lead me anywhere.

A: Standard trick: consider $g(x) = e^{-cx} f(x)$. Then
$$g'(x) = e^{-cx} f'(x) - c e^{-cx} f(x) = e^{-cx} (f'(x) - cf(x)).$$
So you are asking if $g'(x)$ is zero at some point. But $g(a) = g(b) = 0$.


text:
Q: Find and replace opening and closing HTML tag with specific class using Regex I want to change this:

...

to this:
<x-panel>
...
</x-panel>

I am using Replace in Path feature.
What I typed on Search box (this one seems to match correctly):

[^>]*>[^{]*

What I typed on Replace box:
<x-panel>$1</x-panel>

It is giving me this error:
You have entered malformed replacement string $1

A: Here is working example:
https://regex101.com/r/UQrpTV/1
First group is > (
)
second > (.*)
third closing tag > (<\/div>)
and you substitute second group > <x-panel>$2</x-panel>

I don't have phpstorm but also note that you have to enable global, multiline, insensitive case and don't match new line to have it like this working in your editor I think


text:
Q: ASP Button hover area is inconsistent with image The hover works, but only on certain parts of the button image or outside the button image.  Also, the hover doesn't work if the arrow enters the button from above.
Any ideas?
.buttonSearch{
display: block;
background:   url("../Images/btn Search.JPG") no-repeat top;
height: 40px;
width:100px;
border:1px solid #7AB800;
border-width:0px;
margin-left: 210px;}

.buttonSearch:hover
{display: block;
    background: transparent url("../Images/btn Search Click2.JPG") no-repeat top;
    height: 40px;
    width:100px;
    border:none 0 transparent;
   border-width:0px;
   margin-left: 210px;

ASP page:
<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </ajaxToolkit:ToolkitScriptManager>

<asp:Panel ID="p" runat="server" DefaultButton="butName">

<asp:Label ID="TextBox1" runat="server" AutoComplete="Off" CssClass="display-labelsearch" Text="Last Name: " />
<asp:TextBox ID="txtName" runat="server" CssClass="display-fieldsearch" MaxLength="100" ToolTip="Please enter a Provider last name."></asp:TextBox>
        <cc1:TextBoxWatermarkExtender ID="txtName_TextBoxWatermarkExtender"
        runat="server" Enabled="True" TargetControlID="txtName" WatermarkText="Type Last Name Here"  WatermarkCssClass="watermarked">
        </cc1:TextBoxWatermarkExtender>
        <cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
        TargetControlID="txtName" MinimumPrefixLength="1" ServiceMethod="GetNames"
        UseContextKey="True">
        </cc1:AutoCompleteExtender>
</asp:Panel>
<asp:Button ID="butName" runat="server" onclick="tbSearchbutton" CssClass="buttonSearch" />

 <asp:GridView ID="gvProvLookup" runat="server"

AutoGenerateColumns="False" OnRowCommand="ViewProv_RowCommand"  yada yada

A: Something was covering part of the button.  I moved it down a line and it works properly.


text:
Q: Is the instance of Method class in java is global unique In the whole jvm run life, is the Method class instance always unique?
for example,
I have a class which implements InvocationHandler.
In method invoke, which has a Method parameter.
I know all methods that i can handle, and I want to use different strategy to handle different method. So I build a strategy map like Map.
codes like:
@Override public Object invoke(Object proxy, Method method, Object[] args)  throws Throwable {
    Strategy strategy = strategyMap.get(method);
    Method realMethod = strategy.getCorrespondingMethod();
    return realMethod.invoke(this, args);
}

The question is IF i use this strategy, the Method object MUST be global unique in the whole JVM running life. Otherwise, i cannot find the correct strategy.
So, Is the instance of Method class in java is global unique.
Question 2:
How about the efficient of Method:toGenericString(), i the use method object cannot accomplish this job, i think i can use method generic string.
Thank you.

A: You should see it in this way - for a given class, the method instance is always unique. The reason I added for a given class is because 2 same classes loaded using different class loaders will have different instances of the same method.

How about the efficient of Method:toGenericString()

Well, efficiency is a relative concept. You have nothing against which toGenericString() can be compared. So, if toGenericString() does the job, go for it and forget about the efficiency :P


text:
Q: ManyToMany association with extra columns on Spring Data REST creates Error 'attempted to assign id from null one-to-one property' ManyToMany: Recipes <--> Ingredients
But with extra fields.
@Entity
@Getter
@Setter
@RequiredArgsConstructor
public class Recipe {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    private boolean vegetarian;
    private String description;

    @OneToMany(
            mappedBy = "recipe",
            cascade = CascadeType.ALL,
            orphanRemoval = true
    )
    private List<RecipesHasIngredients> ingredients = new ArrayList<>();
}

@Entity
@Getter
@Setter
@NaturalIdCache
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@RequiredArgsConstructor
public class Ingredient {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @NaturalId
    private String name;

    private Boolean isVegetarian;
}

@Entity
@Getter
@Setter
@RequiredArgsConstructor
public class RecipesHasIngredients {
    @EmbeddedId
    private RecipesHasIngredientsId id;

    @ManyToOne(fetch = FetchType.LAZY)
    @MapsId("recipeId")
    private Recipe recipe;

    @ManyToOne(fetch = FetchType.LAZY)
    @MapsId("ingredientId")
    private Ingredient ingredient;

    private String amount;
}

@Embeddable
@Getter
@Setter
@EqualsAndHashCode(of = {"recipeId", "ingredientId"})
@RequiredArgsConstructor
public class RecipesHasIngredientsId implements Serializable {
    private Long recipeId;

    private Long ingredientId;
}

@RepositoryRestResource(collectionResourceRel = "recipes", path = "recipes")
interface RecipesRepository extends JpaRepository<Recipe, Long>, RecipesRepositoryCustom {
}

The DB is created fine, and the app loads properly. However, the moment I try to POST new Recipe with associated to a new Ingredient there is an error in the mapping layer that I can't seem to locate.
For reference, this is the json I POST to /recipes:
{
  "vegetarian": true,
  "description": "something",
  "owner": "http://localhost:8080/users/1",
  "ingredients": [
    {
      "amount": "2.5kg",
      "name": "carrot",
      "isVegetarian": true
    }
  ]
}

Running:
curl http://localhost:8080/recipes/ -X POST -d '{"vegetarian": true, "description": "something", "ingredients":[{"amount": "2.5kg", "name": "carrot", "isVegetarian": true}]}' -H "Content-Type: application/json"

Triggers error
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: attempted to assign id from null one-to-one property [+++.recipesapp.ingredients.RecipesHasIngredients.ingredient]; nested exception is org.hibernate.id.IdentifierGenerationException: attempted to assign id from null one-to-one property [+++.recipesapp.ingredients.RecipesHasIngredients.ingredient]] with root cause

So:
attempted to assign id from null one-to-one property
Does anybody know what am I doing wrong?