text:
Q: Why does flex builder insist on a Main class in the root of the source folder? Why does FlexBuilder insist on a main class in the root of the source folder?
By insist I mean that if I create an Actionscript project called MainTest. A file called MainTest.as will be placed in the root of the src folder.
if I now create a package/folder called some/package and place the MainTest.as in it (and adjust the package statement accordingly), I cannot select the project to use this as the application class in Properties/Actionscript Applications as the package is empty as far as Flexbulider is concerned.
So  there is a restriction that a main/application class cannot have a package other than the root package. The mxmlc compiler and FDT do not enforce this restriction so why does Flex Builder?

A: I am not sure if I am getting the problem statement correctly. Still, if I am correct you are unable to set an application as your main application once you place it outside src folder.
In this case why don't you change the 'Flex Build Path' in 'ProjectProperties>>FlexBuildPath>>Main Source Folder' accordingly.
Once this done you may also be required to set your 'MainTest.as' as default application in 'ProjectProperites>>Flex Applications>>set as deafult'.
Hope, it helps.


text:
Q: React copy to clipboard using useRef hook I'm trying to handle copy to clipboard in React with useRef hook. How can I achieve it without any additional libraries? Here is my code but it throws an error myRef.current.select is not a function.
import React, { useRef } from "react";

const Element = () => {
  const myRef = useRef();

  const copyToClipboard = () => {
    myRef.current.select();
    document.execCommand("copy");
  };

  return (

        Text to be copied

  );
};

export default Element;

A: Run the following snippet(s).

*

*Have a separate CopyToClipElement component (with React Hooks) which handles the copy for given text prop. Use this component in your render.

const CopyToClipElement = ({ text }) => {
  const myRef = React.useRef(null);
  const [data, setData] = React.useState(text);
  React.useEffect(() => setData(text), [text]);

  React.useEffect(() => {
    if (myRef.current && data) {
      myRef.current.select();
      document.execCommand("copy");
      setData(null);
    }
  }, [data, myRef.current]);

  return
{data && <textarea ref={myRef}>{data}</textarea>}
;
};

const Element = () => {
  const [copyText, setCopyText] = React.useState("");
  const data = ["Text to be copied", "Copy foo"];

  return (

      {data.map((text) => (
         setCopyText(text)}
        >
          {text}

      ))}
      <CopyToClipElement text={copyText} />

  );
};

const domContainer = document.querySelector('#app');
ReactDOM.render(<Element/>, domContainer);

*Alternatively, Just add the utility method copyToClipboard in plain JS.

const copyToClipboard = (text: string) => {
  const ta = document.createElement("textarea");
  ta.innerText = text;
  document.body.appendChild(ta);
  ta.select();
  document.execCommand("copy");
  ta.remove();
};

const Element = () => {
  const data = ["Text to be copied", "Copy Bar"];

  return (

      {data.map((text) => (
         copyToClipboard(text)}
        >
          {text}

      ))}

  );
};

const domContainer = document.querySelector('#app');
ReactDOM.render(<Element />, domContainer);

A: Take a look at this solution, I just adapted it to your use case.
  const copyToClipboard = () => {
    const range = document.createRange();
    range.selectNode(myRef.current);
    window.getSelection().addRange(range);

    try {
      // Now that we've selected the anchor text, execute the copy command
      const successful = document.execCommand('copy');
      const msg = successful ? 'successful' : 'unsuccessful';
      console.log('Copy email command was ' + msg);
    } catch(err) {
      console.log('Oops, unable to copy');
    }

    // Remove the selections - NOTE: Should use
    // removeRange(range) when it is supported
    window.getSelection().removeAllRanges();
  };

A: Ciao, I found a solution but I had to use input instead of span. And I haven't used useRef hook but just a variable (let myInput = null;) and then on input ref I wrote ref={(ref) => myInput = ref}. In this way, your copyToClipboard works.
The code:
function App() {
  let myInput = null;
  const copyToClipboard = () => {
    myInput.select();
    document.execCommand("copy");
    alert("Copied the text: " + myInput.value);
  };

  return (

      <input readOnly value="Text to copy" onClick={copyToClipboard} ref={(ref) => myInput = ref} />

  );
}

Here the codesandbox example.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Packaging JSF web app with Quarkus with JVM mode Quarkus JVM mode with JSF
I have an existing thorntail 2.4 based web application built using JSF and JEE (CDI/EJB).
For my technology stack above, if I am only using the JVM mode and not the native mode, is it possible to package my application using runtime?
I understand that EJB spec is not implemented with quarkus and I am OK with rewriting EJBs as CDI+JTA services but want to know if it's possible to use JSF with quarkus.

A: There is an extension for it available: https://github.com/tandraschko/quarkus-myfaces
UPDATE: I moved my 'personal' extension to MyFaces Core and we already have an 2.3-next-M1 release ready.
The showcase is available here and already uses the released version: https://github.com/apache/myfaces/tree/master/extensions/quarkus/showcase
UPDATE: We even released M2 today which supports native images!

A: Quarkus doesn't provide a JSF extension.
But it should be possible for your application to directly include a JSF implementation as a dependency and have it work


text:
Q: Why do I get a 32-bit overflow when compiling in 64-bit in C++? So, I decided to test out a new C++ turtle-style graphics library. I decided to test it out by making the fibonacci spiral. however, upon running the program, it stops in the middle. I checked what was going on, and the fibonacci value had reversed to -2147483647, as if it was compiled in 32-bit. Can someone please help? I compiled it with g++ on Windows.
Note: I was using a vector to store the values.
Here's my code:
//Includes and namespaces
#include "Cturtle.hpp"
#include<iostream>
namespace ct = cturtle;

std::vector<long int> fibonacci = {1, 2}; //This vector stores the fib sequence
ct::TurtleScreen scr; //Create a new Screen
ct::Turtle turtle(scr); //Create a new turtle on the screen

int main() {
    turtle.speed(ct::TS_FASTEST); //Set the turtle's speed to max

    while(true) {
        for(int i = 0; i < fibonacci.back(); i++) {

            fibonacci.push_back(fibonacci.back() + fibonacci.back()-1); //Add a new value to the fibonacci vector based off the previous two
            std::cout << fibonacci.back() << '\n'; //This is here for debug
            turtle.forward(1); //Move the turtle 1 step forward
            turtle.right(90 / fibonacci.back()); //Turn according to 90 divided by the current fibonacci value
        }
    }
}

A: MinGW uses the MSVC-friendly LLP64 data model.
In LLP64, int and long int are both 32 bits, regardless of platform bitness (32/64 bit).
To get a 64-bit data type, use long long or int64_t.
e.g. std::vector<long long>. And also here: for(long long i = 0; ...