text:
Q: Sending input value to a MySQL query I have this hidden input box where I store my table's IDs. I want to get this input value and send it to a my SQL Query in the same file: problem is, nothing i've done has worked.
My input box, that stores the values:
<input  name='theNum3' id='theNum3'>
Here's how I store the value:
$("#companieSelect").change(function() {
    $("input[name='theNum3']").val($(this).val());
});

And this is my query:
$result = $conn->query("SELECT empresas.nome, departamentos.nomeDepartamento, funcionarios.nomeFuncionario, funcionarios.email, funcionarios.idFuncionarios FROM empresas INNER JOIN departamentos ON empresas.id = [HERE] INNER JOIN funcionarios ON departamentos.id = funcionarios.idDepartamentos ORDER BY empresas.nome ASC ") or die($conn->error);

Here's the connections and HTML files:
<?php
    require 'includes/dbh.inc.php';
    $result = $conn->query("SELECT * from empresas") or die($conn->error);
?>

<div class="form-group" >
    <select style = "justify-content: center; display: flex;margin-left: 20%;
        margin-right: auto; margin-top: 5%" name="companieSelect"
        class="form-control" id="companieSelect"  >
        <option value="" disabled selected> Selecione a empresa </option>
            <?php
                  while ($row = $result->fetch_assoc()) : ?>
                      <option value="<?= $row['id']; ?>"> <?= $row['nome']; ?>
                      </option>
           <?php endwhile ?>

    </select>
</div>

<input  name='theNum3' id='theNum3'>

<script>
    function getInput() {
        var x = document.getElementById("theNum3").value;
    }
</script>

<?php
    require 'includes/dbh.inc.php';
    $result = $conn->query("SELECT empresas.nome, departamentos.nomeDepartamento,
    funcionarios.nomeFuncionario, funcionarios.email, funcionarios.idFuncionarios FROM empresas INNER
    JOIN departamentos ON empresas.id = departamentos.idEmpresas INNER JOIN funcionarios ON
    departamentos.id = funcionarios.idDepartamentos ORDER BY empresas.nome ASC ") or die($conn->error);
?>

Thank you for your help!


text:
Q: How to generate sample XML documents from their DTD or XSD? We are developing an application that involves a substantial amount of XML transformations. We do not have any proper input test data per se, only DTD or XSD files. We'd like to generate our test data ourselves from these files. Is there an easy/free way to do that?
Edit
There are apparently no free tools for this, and I agree that OxygenXML is one of the best tools for this.

A: Seems like nobody was able to answer the question so far :)
I use EclipseLink's MOXy to dynamically generate binding classes and then recursively go through the bound types. It is somewhat heavy, but it allows XPath value injection once the object tree is instantiated:
InputStream in = new FileInputStream(PATH_TO_XSD);
DynamicJAXBContext jaxbContext =
            DynamicJAXBContextFactory.createContextFromXSD(in, null, Thread.currentThread().getContextClassLoader(), null);
DynamicType rootType = jaxbContext.getDynamicType(YOUR_ROOT_TYPE);
DynamicEntity root = rootType.newDynamicEntity();
traverseProps(jaxbContext, root, rootType, 0);

TraverseProps is pretty simple recursive method:
private void traverseProps(DynamicJAXBContext c, DynamicEntity e, DynamicType t, int level) throws DynamicException, InstantiationException, IllegalAccessException{
        if (t!=null) {
            logger.info(indent(level) + "type [" + t.getName() + "] of class [" + t.getClassName() + "] has " + t.getNumberOfProperties() + " props");
            for (String pName:t.getPropertiesNames()){
                Class<?> clazz = t.getPropertyType(pName);
                logger.info(indent(level) + "prop [" + pName + "] in type: " + clazz);
                //logger.info("prop [" + pName + "] in entity: " + e.get(pName));

                if (clazz==null){
                    // need to create an instance of object
                    String updatedClassName = pName.substring(0, 1).toUpperCase() + pName.substring(1);
                    logger.info(indent(level) + "Creating new type instance for " + pName + " using following class name: " + updatedClassName );
                    DynamicType child = c.getDynamicType("generated." + updatedClassName);
                    DynamicEntity childEntity = child.newDynamicEntity();
                    e.set(pName, childEntity);
                    traverseProps(c, childEntity, child, level+1);
                } else {
                    // just set empty value
                    e.set(pName, clazz.newInstance());
                }
            }
        } else {
            logger.warn("type is null");
        }
    }

Converting everything to XML is pretty easy:
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(root, System.out);

A: You can also use XMLPad (free to use) found here http://www.wmhelp.com
to generate your xml samples.
From the menu : XSD -> generate sample XML file.

A: Microsoft has published a "document generator" tool as a sample.  This is an article that describes the architecture and operation of the sample app in some detail.
If you just want to run the sample generation tool, click here and install the MSI.
It's free.  The source is available. Requires the .NET Framework to run.  Works only with XSDs. (not Relax NG or DTD).

A: XML-XIG: XML Instance Generator
http://xml-xig.sourceforge.net/
This opensource would be helpful.

A: Microsoft Office has 'InfoPath', which takes an XSD as an import and lets you quickly and easily define a form-based editor for creating XML files.  It has two modes - one where you define the form, and another mode where you create the XML file by filling out the form.  I believe it first came with Office 2003, and most people never install it.  It shocks me at how much I like it.

A: For Intellij Idea users:
Have a look at Tools -> XML Actions

Seems to work very well (as far as I have tested).
Edit:
As mentioned by @naXa, you can now also right-click on the XSD file and click  "Generate XML Document from XSD Schema..."

A: I think Oxygen (http://www.oxygenxml.com/) does it as well, but that's another commerical product. It's a nice one, though... I'd strongly recommend it for anyone doing a lot of XML work. It comes in a nice Eclipse plugin, too.
I do believe there is a free, fully-featured 30 day trial.

A: In Visual Studio 2008 SP1 and later the XML Schema Explorer can create an XML document with some basic sample data:

*

*Open your XSD document

*Switch to XML Schema Explorer

*Right click the root node and choose "Generate Sample Xml"

A: In recent versions of the free and open source Eclipse IDE you can generate XML documents from DTD and XSD files. Right-click on a given *.dtd or *.xsd file and select "Generate -> XML File...". You can choose which root element to generate and whether optional attributes and elements should be generated.

Of course you can use Eclipse to create and edit your DTD and XSD schema files, too. And you don't need to install any plugins. It is included in the standard distribution.

A: The camprocessor available on Sourceforge.net will do xml test case generation for any XSD.  There is a tutorial available to show you how to generate your own test examples - including using content hints to ensure realistic examples, not just random junk ones.
The tutorial is available here:
http://www.oasis-open.org/committees/download.php/29661/XSD%20and%20jCAM%20tutorial.pdf
And more information on the tool - which is using the OASIS Content Assembly Mechanism (CAM) standard to refactor your XSD into a more XSLT friendly structure - can be found from the resource website - http://www.jcam.org.uk
Enjoy, DW

A: XMLSpy does that for you, although that's not free...
I believe that Liquid Xml Studio does it for you and is free, but I have not personally used it to create test data.

A: You can use the XML Instance Generator which is part of the Sun/Oracle Multi-Schema Validator.
It's README.txt states:

Sun XML Generator is a Java tool to generate various XML instances from
  several kinds of schemas. It supports DTD, RELAX Namespace, RELAX Core,
  TREX, and a subset of W3C XML Schema Part 1. [...]
This is a command-line tool that can generate both valid and invalid
  instances from schemas. It can be used for generating test cases for XML
  applications that need to conform to a particular schema.

Download and unpack xmlgen.zip from the msv download page and run the following command to get detailed usage instructions:

java -jar xmlgen.jar -help

The tool appears to be released under a BSD license; the source code is accessible from here

A: XMLBlueprint 7.5 can do the following:
- generate sample xml from dtd
- generate sample xml from relax ng schema
- generate sample xml from xml schema

A: Liquid XML Studio has an XML Sample Generator wizard which will build sample XML files from an XML Schema. The resulting data seems to comply with the schema (it just can't generate data for regex patterns).

A: The open source Version of SoapUI can generate SOAP requests from WSDL (which contains XSD type definitions), so it looks like there IS an open source implementation of this functionality. Unfortunately, I haven't figured out which library is used to to this.

A: The OpenXSD library mentions that they have support for generating XML instances based on the XSD. Check that out.

A: For completeness I'll add http://code.google.com/p/jlibs/wiki/XSInstance, which was mentioned in a similar (but Java-specific) question: Any Java "API" to generate Sample XML from XSD?

A: XML Blueprint also does that; instructions here
http://www.xmlblueprint.com/help/html/topic_170.htm
It's not free, but there's a 10-day free trial; it seems fast and efficient; unfortunately it's Windows only.

A: There's also http://xsd2xml.com/, an online XSD to XML generator

redpajama_set_name: RedPajamaStackExchange


text:
Q: Trying to make a leveling system, however it only works once and then stops working? I'm making a leveling system and it only levels me up once and then stops working. Once it levels me the xp doesn't reset and my level does not go up. Here's the code!
level = int(1)
crexp = int(260)
reqxp = int(100)
while crexp >= reqxp:
    level = level+1
    crexp = crexp-reqxp
    reqxp = (reqxp/100)*120
    continue
while 3 > 2:
    pinput = input()
    if pinput == "1":
        crexp = crexp + 60
    elif pinput == "2":
        print(level)
    elif pinput == "3":
        print(crexp)
    elif pinput == "4":
        print(reqxp)
    elif pinput == "5":
        break

A: The problem with your current code is that you are not rerunning the 'level up' part of the code. Python generally (when not in a while/for loop e.c.t) reads your code from top to bottom. This means by the time you get into the second while loop the first while loop has finished and will never be run again.
To fix this you want to tell python to recalculate the level and experience variables at certain points - the easiest way to do this is to make the first while loop into a function and call it at the start of the second while loop. You would get something like this -
def checkLevelUp(currentXp, requiredXp, currentLevel):
    while currentXp >= requiredXp:
        currentLevel = currentLevel+1
        currentXp = currentXp-requiredXp
        requiredXp = int(requiredXp * 1.2)
    return currentLevel, currentXp, requiredXp

level = 1
crexp = 260
reqxp = 100

while True:
    level, crexp, reqxp = checkLevelUp(crexp, reqxp, level)
    pinput = input()
    if pinput == "1":
        crexp = crexp + 60
    elif pinput == "2":
        print(level)
    elif pinput == "3":
        print(crexp)
    elif pinput == "4":
        print(reqxp)
    elif pinput == "5":
        break

Note also the changes to calculating the next required xp - dividing by 100 and then multiplying by 120 is just the same as multiplying by 1.2.


text:
Q: How to use pydensecrf in Python3.7? I am running the following python code
import numpy as np
import pydensecrf.densecrf as dcrf
import matplotlib.pyplot as plt

which results in
    ModuleNotFoundError                       Traceback (most recent call last)
    <ipython-input-4-cbaa174fb5e7> in <module>
          1 import numpy as np
    ----> 2 import pydensecrf.densecrf as dcrf
          3 import matplotlib.pyplot as plt

ModuleNotFoundError: No module named 'pydensecrf'

I have tried installing: pip install pydensecrf
But whenever I do, i get the following error
C:\Users\Aparajita Das>pip install pydensecrf
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/pydensecrf/
Collecting pydensecrf
  Using cached pydensecrf-1.0rc3.tar.gz (1.0 MB)
Building wheels for collected packages: pydensecrf
  Building wheel for pydensecrf (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\Users\Aparajita Das\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\APARAJ~1\\AppData\\Local\\Temp\\pip-install-pqhh72by\\pydensecrf\\setup.py'"'"'; __file__='"'"'C:\\Users\\APARAJ~1\\AppData\\Local\\Temp\\pip-install-pqhh72by\\pydensecrf\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\APARAJ~1\AppData\Local\Temp\pip-wheel-v3toa6sn'
       cwd: C:\Users\APARAJ~1\AppData\Local\Temp\pip-install-pqhh72by\pydensecrf\
  Complete output (44 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.7
  creating build\lib.win-amd64-3.7\pydensecrf
  copying pydensecrf\utils.py -> build\lib.win-amd64-3.7\pydensecrf
  copying pydensecrf\__init__.py -> build\lib.win-amd64-3.7\pydensecrf
  running build_ext
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\APARAJ~1\AppData\Local\Temp\pip-install-pqhh72by\pydensecrf\setup.py", line 41, in <module>
      "Topic :: Scientific/Engineering :: Artificial Intelligence",
    File "C:\Users\Aparajita Das\Anaconda3\lib\site-packages\setuptools\__init__.py", line 144, in setup
      return distutils.core.setup(**attrs)
    File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\core.py", line 148, in setup
      dist.run_commands()
    File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "C:\Users\Aparajita Das\Anaconda3\lib\site-packages\wheel\bdist_wheel.py", line 223, in run
      self.run_command('build')
    File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\command\build.py", line 135, in run
      self.run_command(cmd_name)
    File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "C:\Users\Aparajita Das\Anaconda3\lib\site-packages\setuptools\command\build_ext.py", line 87, in run
      _build_ext.run(self)
    File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\command\build_ext.py", line 309, in run
      force=self.force)
    File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\ccompiler.py", line 1031, in new_compiler
      return klass(None, dry_run, force)
    File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\cygwinccompiler.py", line 285, in __init__
      CygwinCCompiler.__init__ (self, verbose, dry_run, force)
    File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\cygwinccompiler.py", line 129, in __init__
      if self.ld_version >= "2.10.90":
  TypeError: '>=' not supported between instances of 'NoneType' and 'str'
  ----------------------------------------
  ERROR: Failed building wheel for pydensecrf
  Running setup.py clean for pydensecrf
Failed to build pydensecrf
Installing collected packages: pydensecrf
    Running setup.py install for pydensecrf ... error
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\Aparajita Das\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\APARAJ~1\\AppData\\Local\\Temp\\pip-install-pqhh72by\\pydensecrf\\setup.py'"'"'; __file__='"'"'C:\\Users\\APARAJ~1\\AppData\\Local\\Temp\\pip-install-pqhh72by\\pydensecrf\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\APARAJ~1\AppData\Local\Temp\pip-record-tms9_lds\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Aparajita Das\Anaconda3\Include\pydensecrf'
         cwd: C:\Users\APARAJ~1\AppData\Local\Temp\pip-install-pqhh72by\pydensecrf\
    Complete output (46 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.7
    creating build\lib.win-amd64-3.7\pydensecrf
    copying pydensecrf\utils.py -> build\lib.win-amd64-3.7\pydensecrf
    copying pydensecrf\__init__.py -> build\lib.win-amd64-3.7\pydensecrf
    running build_ext
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\APARAJ~1\AppData\Local\Temp\pip-install-pqhh72by\pydensecrf\setup.py", line 41, in <module>
        "Topic :: Scientific/Engineering :: Artificial Intelligence",
      File "C:\Users\Aparajita Das\Anaconda3\lib\site-packages\setuptools\__init__.py", line 144, in setup
        return distutils.core.setup(**attrs)
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\Aparajita Das\Anaconda3\lib\site-packages\setuptools\command\install.py", line 61, in run
        return orig.install.run(self)
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\command\install.py", line 545, in run
        self.run_command('build')
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\command\build.py", line 135, in run
        self.run_command(cmd_name)
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\Aparajita Das\Anaconda3\lib\site-packages\setuptools\command\build_ext.py", line 87, in run
        _build_ext.run(self)
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\command\build_ext.py", line 309, in run
        force=self.force)
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\ccompiler.py", line 1031, in new_compiler
        return klass(None, dry_run, force)
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\cygwinccompiler.py", line 285, in __init__
        CygwinCCompiler.__init__ (self, verbose, dry_run, force)
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\cygwinccompiler.py", line 129, in __init__
        if self.ld_version >= "2.10.90":
    TypeError: '>=' not supported between instances of 'NoneType' and 'str'
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\Aparajita Das\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\APARAJ~1\\AppData\\Local\\Temp\\pip-install-pqhh72by\\pydensecrf\\setup.py'"'"'; __file__='"'"'C:\\Users\\APARAJ~1\\AppData\\Local\\Temp\\pip-install-pqhh72by\\pydensecrf\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\APARAJ~1\AppData\Local\Temp\pip-record-tms9_lds\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Aparajita Das\Anaconda3\Include\pydensecrf' Check the logs for full command output.

I am using Python 3.7.3 and I have cpython installed. I have checked everywhere and no solution is working for me. I have tried downgrading python, thinking it might work for older version using the following but it does not even downgrade it to the given version.
conda install python=3.5.0

How do I solve this?

A: Step1: download package of pydensecrf compatible with python version from link https://anaconda.org/conda-forge/pydensecrf/files?version=1.0rc2&page=2
Step2: Extract the package and copy two subfolders "pydensecrf and pydensecrf-1.0rc2.dist-info" in folder "Lib" to installed folder of python (Example: C:\Python 3.6\Lib\site-packages)

A: For me installation failed with error: command 'gcc' failed with exit status 1.
This worked for me:
pip install cython
pip install git+https://github.com/lucasb-eyer/pydensecrf.git

Installing cython is the first thing you need to try out.That alone didn't work for me.Combination of both worked like a charm.
Referred to the comments at https://github.com/lucasb-eyer/pydensecrf/issues/78


text:
Q: I need to match strings that don't contain a keyword at an arbitrary position I need to match strings that don't contain a keyword (beta2) at an arbitrary position.
Consider:
var aStr    = [
                '/beta1/foo',
                'beta1/foo',
                '/beta1_xyz/foo',
                'blahBlah/beta1/foo',
                'beta1',

                '/beta2/foo',
                'beta2/foo',
                '/beta2_xyz/foo',
                'blahBlah/beta2/foo',
                'beta2',

                '/beat2/foo',
                'beat2/foo',
                '/beat2_xyz/foo',
                'blahBlah/beat2/foo',
                'beat2'
            ];

function bTestForMatch (Str)
{
    return /.*\b(?!beta2).*/i.test (Str);
}

for (var J=0, iLen=aStr.length;  J < iLen;  J++)
{
    console.log (J, bTestForMatch (aStr[J]), aStr[J]);
}

We need a regex that matches all strings that exclude beta2.  beta2 will always start at a word boundary, but not necessarily end at one.  It can be at a variety of positions in the string.
The desired results would be:
 0    true    /beta1/foo
 1    true    beta1/foo
 2    true    /beta1_xyz/foo
 3    true    blahBlah/beta1/foo
 4    true    beta1
 5    false   /beta2/foo
 6    false   beta2/foo
 7    false   /beta2_xyz/foo
 8    false   blahBlah/beta2/foo
 9    false   beta2
10    true    /beat2/foo
11    true    beat2/foo
12    true    /beat2_xyz/foo
13    true    blahBlah/beat2/foo
14    true    beat2

The regex is for a 3rd-party analysis tool that takes JavaScript regular expressions to filter sub-results.   The tool takes a single line of regex.  There is no API and we don't have access to its source-code.
Is there a JavaScript regex that will filter the second beta results (beta2) from this analysis run?

A: Try
/^(?!.*beta2).*$/

A: Would this be considered cheating?
return !/beta2/i.test (Str);


text:
Q: complicated calculation based on categories selection on JS or Jquery I have an excel like table asThe image version, I will need to do real time calculation on HTML using JS or JQuery.
Below example do the calculation based on single value as you can see mine changes and I have two drop-down 10 selection other one with 16 selection.
Calculation rules are:
If user selects Origin Europe and select Volume 10, then for the matching 10 number fields I will need calculate amount x Volume 10 corresponding value from below the table
Apple  = User input 3 and corresponding value from table is 0  so my result will be 0.
Boysenberry  = User input 233 and corresponding value from table is 1  so my result will be 233.
so on, I have 10 tables for lookup for corresponding calculation value it changes based on the Origin Drop-down and Volume.
If I had one it was easy when I have more table I bit straggle I think there are some good way to do the calculation.
Thanks for your help in advance.
jquery- calculate a total value after filling out a checkbox/radio/dropdown form

   Product Origin
   <select class="element select medium" id="element_2" name="element_2">
      <option value="" selected="selected"></option>
      <option value="1" >Europe</option>
      <option value="2" >Asia</option>
      <option value="3" >China</option>
      <option value="3" >India</option>
      <option value="3" >USA</option>
      <option value="3" >Africa</option>
   </select>

   Volume
   <select class="element select medium" id="element_1" name="element_1">
      <option value="" selected="selected"></option>
      <option value="10" >10</option>
      <option value="100" >100</option>
      <option value="1000" >1000</option>
      <option value="2000" >2000</option>
      <option value="3000" >3000</option>
      <option value="4000" >4000</option>
      <option value="5000" >5000</option>
      <option value="6000" >6000</option>
      <option value="6000" >6000</option>
      <option value="8000" >8000</option>
      <option value="9000" >9000</option>
      <option value="10000" >10000</option>
      <option value="20000" >20000</option>
      <option value="30000" >30000</option>
      <option value="40000" >40000</option>
      <option value="50000" >50000</option>
   </select>

   Apple
   <input id="element_1" name="element_1" class="element text medium" type="text" maxlength="255" value=""/>

   Apricot
   <input id="element_2" name="element_2" class="element text medium" type="text" maxlength="255" value=""/>

   Banana
   <input id="element_3" name="element_3" class="element text medium" type="text" maxlength="255" value=""/>

   Bilberry
   <input id="element_4" name="element_4" class="element text medium" type="text" maxlength="255" value=""/>

   Blackberry
   <input id="element_5" name="element_5" class="element text medium" type="text" maxlength="255" value=""/>

   Blackcurrant
   <input id="element_6" name="element_6" class="element text medium" type="text" maxlength="255" value=""/>

   Blueberry
   <input id="element_7" name="element_7" class="element text medium" type="text" maxlength="255" value=""/>

   Boysenberry
   <input id="element_8" name="element_8" class="element text medium" type="text" maxlength="255" value=""/>

   Cherry
   <input id="element_9" name="element_9" class="element text medium" type="text" maxlength="255" value=""/>

   Coconut
   <input id="element_10" name="element_10" class="element text medium" type="text" maxlength="255" value=""/>

         Category 1: Origin Europe
         10
         100
         1000
         2000
         3000
         4000
         5000
         6000
         7000
         8000
         9000
         1000
         10000
         20000
         30000
         40000

         Apple
         0.1
         0.5
         1
         2
         3
         4
         5
         6
         7
         8
         9
         10
         11
         12
         13
         14

         Apricot
         0
         0
         0
         0.5
         1
         1.5
         2
         2.5
         3
         3.5
         4
         4.5
         5
         5.5
         6
         7

         Banana
         0.1
         0.5
         1
         2
         4
         5
         6
         7
         8
         9
         10
         12
         14
         16
         18
         20

         Bilberry
         1
         5
         10
         10
         15
         20
         25
         30
         35
         40
         45
         50
         55
         60
         65
         70

         Blackberry
         0.1
         5
         10
         20
         50
         75
         100
         125
         150
         175
         200
         225
         250
         275
         300
         350

         Blackcurrant
         0.1
         0.5
         1
         2
         2
         4
         4
         4
         6
         6
         6
         8
         8
         10
         12
         14

         Blueberry
         0.1
         0.5
         1
         4
         6
         8
         10
         12
         14
         16
         18
         20
         24
         28
         30
         36

         Boysenberry
         0.5
         1
         2.5
         4
         5.5
         7
         8.5
         10
         11.5
         13
         14.5
         16
         17.5
         19
         20.5
         22

         Cherry
         0.5
         1
         2.5
         5
         8
         10
         15
         20
         25
         28
         31
         35
         40
         45
         50
         55

         Coconut
         0.1
         0.25
         0.5
         0.5
         1
         1
         2
         2
         2
         2
         2.5
         2.5
         3
         3
         3
         3

         Category 2 Origin Asia
         10
         100
         1000
         2000
         3000
         4000
         5000
         6000
         7000
         8000
         9000
         1000
         10000
         20000
         30000
         40000

         Apple
         0.1
         0.5
         1
         5
         10
         15
         17.7
         21.5
         25.3
         29.1
         32.9
         36.7
         40.5
         44.3
         48.1
         51.9

         Apricot
         0
         0
         0
         0.5
         1
         1.5
         2
         2.5
         3
         3.5
         4
         4.5
         5
         5.5
         6
         7

         Banana
         0.1
         0.5
         1
         5
         10
         15
         20
         25
         27
         30
         33
         36
         40
         45
         50
         55

         Bilberry
         1
         5
         10
         15
         20
         25
         30
         35
         40
         45
         50
         55
         60
         65
         70
         75

         Blackberry
         0.1
         5
         10
         20
         50
         75
         100
         125
         150
         175
         200
         225
         250
         275
         300
         350

         Blackcurrant
         0.1
         0.5
         1
         2
         2
         4
         4
         4
         6
         6
         6
         8
         8
         10
         12
         14

         Blueberry
         0.1
         0.5
         1
         4
         6
         8
         10
         12
         14
         16
         18
         20
         24
         28
         30
         36

         Boysenberry
         0.5
         1
         2.5
         4
         5.5
         7
         8.5
         10
         11.5
         13
         14.5
         16
         17.5
         19
         20.5
         22

         Cherry
         0.5
         1
         2.5
         5
         8
         10
         15
         20
         25
         28
         31
         35
         40
         45
         50
         55

         Coconut
         0.1
         0.25
         0.5
         0.5
         1
         1
         2
         2
         2
         2
         2.5
         2.5
         3
         3
         3
         3

A: Your html makes your task far more difficult then it needs to be.  The fact that your select options do not directly relate to the table you need a value from is likely your main source of grief.  This answer leaves your HTML alone and works with it.  For a simpler solution I recommend;

*

*Give your reference tables an ID, and make that ID the value of the origin select options.

*Give your table cells an attribute that relates or is the value of the related volume select option.

EXAMPLE of HTML changes

...Europe...

...0.5	...

 $("input[type='text'].element").blur(function(e) {
  var result = $("");
  var multiplier = $(`table#${$("#element_2").val()} tbody > tr[product='${$(this).attr("id")}'] > td[volume='${$("#element_1>option:selected").val()}']`).text();
  $(this).next("span").remove();
  result.text($(this).val() * multiplier);
  $(this).after(result);
});

EXISTING HTML SNIPPET

$("input[type='text'].element").blur(function(e) {
  //get the origin
  var origin = $("#element_2>option:selected").text();
  //get the right lookup table (would be simpler if it had an ID with the value of the ORIGIN select)
  var $tblOrig = $($("table>thead>tr>th:first-child()>strong")
    .filter((index, elem) => $(elem).text().includes(origin)).closest("table"));
  //get the volume
  var volume = $("#element_1>option:selected").val();
  //calculate the targeted table row, we can use the ID for this
  var product_ord = $(this).attr("id").split("_")[1];
  //get the cell number that we need (would be easier of the value of the volume option was the index)
  var volume_ord =
    $("#element_1>option").map((i, e) => {
      return e.value == volume ? {
        index: i + 1
      } : null;
    })[0].index;
  //console.log(volume_ord);

  //get the multiplier
  //make somewhere to store the answer
  var result = $("");
  //get the value from the right cell
  var multiplier = $tblOrig
    .find(`tbody > tr:nth-child(${product_ord}) > td:nth-child(${volume_ord})`).text();
  //console.log(multiplier);
  //remove a previous answer if there is one
  $(this).next("span").remove();
  //get the new answer
  result.text($(this).val() * multiplier);
  //put it after the text input
  $(this).after(result);

});

  Product Origin
  <select class="element select medium" id="element_2" name="element_2">
    <option value="" selected="selected"></option>
    <option value="1">Europe</option>
    <option value="2">Asia</option>
    <option value="3">China</option>
    <option value="3">India</option>
    <option value="3">USA</option>
    <option value="3">Africa</option>
  </select>

  Volume
  <select class="element select medium" id="element_1" name="element_1">
    <option value="" selected="selected"></option>
    <option value="10">10</option>
    <option value="100">100</option>
    <option value="1000">1000</option>
    <option value="2000">2000</option>
    <option value="3000">3000</option>
    <option value="4000">4000</option>
    <option value="5000">5000</option>
    <option value="6000">6000</option>
    <option value="6000">6000</option>
    <option value="8000">8000</option>
    <option value="9000">9000</option>
    <option value="10000">10000</option>
    <option value="20000">20000</option>
    <option value="30000">30000</option>
    <option value="40000">40000</option>
    <option value="50000">50000</option>
  </select>

  Apple
  <input id="element_1" name="element_1" class="element text medium" type="text" maxlength="255" value="" />

  Apricot
  <input id="element_2" name="element_2" class="element text medium" type="text" maxlength="255" value="" />

  Banana
  <input id="element_3" name="element_3" class="element text medium" type="text" maxlength="255" value="" />

  Bilberry
  <input id="element_4" name="element_4" class="element text medium" type="text" maxlength="255" value="" />

  Blackberry
  <input id="element_5" name="element_5" class="element text medium" type="text" maxlength="255" value="" />

  Blackcurrant
  <input id="element_6" name="element_6" class="element text medium" type="text" maxlength="255" value="" />

  Blueberry
  <input id="element_7" name="element_7" class="element text medium" type="text" maxlength="255" value="" />

  Boysenberry
  <input id="element_8" name="element_8" class="element text medium" type="text" maxlength="255" value="" />

  Cherry
  <input id="element_9" name="element_9" class="element text medium" type="text" maxlength="255" value="" />

  Coconut
  <input id="element_10" name="element_10" class="element text medium" type="text" maxlength="255" value="" />

      Category 1: Origin Europe
      10
      100
      1000
      2000
      3000
      4000
      5000
      6000
      7000
      8000
      9000
      1000
      10000
      20000
      30000
      40000

      Apple
      0.1
      0.5
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14

      Apricot
      0
      0
      0
      0.5
      1
      1.5
      2
      2.5
      3
      3.5
      4
      4.5
      5
      5.5
      6
      7

      Banana
      0.1
      0.5
      1
      2
      4
      5
      6
      7
      8
      9
      10
      12
      14
      16
      18
      20

      Bilberry
      1
      5
      10
      10
      15
      20
      25
      30
      35
      40
      45
      50
      55
      60
      65
      70

      Blackberry
      0.1
      5
      10
      20
      50
      75
      100
      125
      150
      175
      200
      225
      250
      275
      300
      350

      Blackcurrant
      0.1
      0.5
      1
      2
      2
      4
      4
      4
      6
      6
      6
      8
      8
      10
      12
      14

      Blueberry
      0.1
      0.5
      1
      4
      6
      8
      10
      12
      14
      16
      18
      20
      24
      28
      30
      36

      Boysenberry
      0.5
      1
      2.5
      4
      5.5
      7
      8.5
      10
      11.5
      13
      14.5
      16
      17.5
      19
      20.5
      22

      Cherry
      0.5
      1
      2.5
      5
      8
      10
      15
      20
      25
      28
      31
      35
      40
      45
      50
      55

      Coconut
      0.1
      0.25
      0.5
      0.5
      1
      1
      2
      2
      2
      2
      2.5
      2.5
      3
      3
      3
      3

      Category 2 Origin Asia
      10
      100
      1000
      2000
      3000
      4000
      5000
      6000
      7000
      8000
      9000
      1000
      10000
      20000
      30000
      40000

      Apple
      0.1
      0.5
      1
      5
      10
      15
      17.7
      21.5
      25.3
      29.1
      32.9
      36.7
      40.5
      44.3
      48.1
      51.9

      Apricot
      0
      0
      0
      0.5
      1
      1.5
      2
      2.5
      3
      3.5
      4
      4.5
      5
      5.5
      6
      7

      Banana
      0.1
      0.5
      1
      5
      10
      15
      20
      25
      27
      30
      33
      36
      40
      45
      50
      55

      Bilberry
      1
      5
      10
      15
      20
      25
      30
      35
      40
      45
      50
      55
      60
      65
      70
      75

      Blackberry
      0.1
      5
      10
      20
      50
      75
      100
      125
      150
      175
      200
      225
      250
      275
      300
      350

      Blackcurrant
      0.1
      0.5
      1
      2
      2
      4
      4
      4
      6
      6
      6
      8
      8
      10
      12
      14

      Blueberry
      0.1
      0.5
      1
      4
      6
      8
      10
      12
      14
      16
      18
      20
      24
      28
      30
      36

      Boysenberry
      0.5
      1
      2.5
      4
      5.5
      7
      8.5
      10
      11.5
      13
      14.5
      16
      17.5
      19
      20.5
      22

      Cherry
      0.5
      1
      2.5
      5
      8
      10
      15
      20
      25
      28
      31
      35
      40
      45
      50
      55

      Coconut
      0.1
      0.25
      0.5
      0.5
      1
      1
      2
      2
      2
      2
      2.5
      2.5
      3
      3
      3
      3

A:

  $("input[type='text'].element").blur(function(e) {
  var result = $("");
  var multiplier = $(`table#${$("#ProductOrigin").val()} tbody > tr[product='${$(this).attr("id")}'] > td[volume='${$("#Volume>option:selected").val()}']`).text();
  $(this).next("span").remove();
  result.text($(this).val() * multiplier);
  $(this).after(result);
});

    Product Origin
    <select class="element select medium" id="ProductOrigin" name="ProductOrigin">
        <option value="" selected="selected"></option>
        <option value="Europe">Europe</option>
        <option value="Asia">Asia</option>
        <option value="China">China</option>
        <option value="India">India</option>
        <option value="USA">USA</option>
        <option value="Africa">Africa</option>
    </select>

    Volume
    <select class="element select medium" id="Volume" name="Volume">
        <option value="" selected="selected"></option>
        <option value="10">10</option>
        <option value="100">100</option>
        <option value="1000">1000</option>
        <option value="2000">2000</option>
        <option value="3000">3000</option>
        <option value="4000">4000</option>
        <option value="5000">5000</option>
        <option value="6000">6000</option>
        <option value="6000">6000</option>
        <option value="8000">8000</option>
        <option value="9000">9000</option>
        <option value="10000">10000</option>
        <option value="20000">20000</option>
        <option value="30000">30000</option>
        <option value="40000">40000</option>
        <option value="50000">50000</option>
    </select>

    Apple
    <input id="Apple" name="Apple" class="element text medium" type="text" maxlength="255" value="" />

    Apricot
    <input id="Apricot" name="Apricot" class="element text medium" type="text" maxlength="255" value="" />

    Banana
    <input id="Banana" name="Banana" class="element text medium" type="text" maxlength="255" value="" />

    Bilberry
    <input id="Bilberry" name="Bilberry" class="element text medium" type="text" maxlength="255" value="" />

    Blackberry
    <input id="Blackberry" name="Blackberry" class="element text medium" type="text" maxlength="255" value="" />

    Blackcurrant
    <input id="Blackcurrant" name="Blackcurrant" class="element text medium" type="text" maxlength="255" value="" />

    Blueberry
    <input id="Blueberry" name="Blueberry" class="element text medium" type="text" maxlength="255" value="" />

    Boysenberry
    <input id="Boysenberry" name="Boysenberry" class="element text medium" type="text" maxlength="255" value="" />

    Cherry
    <input id="Cherry" name="Cherry" class="element text medium" type="text" maxlength="255" value="" />

    Coconut
    <input id="Coconut" name="Coconut" class="element text medium" type="text" maxlength="255" value="" />

Europe

            Europe
            10
            100
            1000
            2000
            3000
            4000
            5000
            6000
            7000
            8000
            9000
            10000
            20000
            30000
            40000
            50000

            Apple
            0.1
            0.5
            1
            2
            3
            4
            5
            6
            7
            8
            9
            10
            11
            12
            13
            14

                Apricot
                0
                0
                0
                0.5
                1
                1.5
                2
                2.5
                3
                3.5
                4
                4.5
                5
                5.5
                6
                7

                Banana
                0.1
                0.5
                1
                5
                10
                15
                20
                25
                27
                30
                33
                36
                40
                45
                50
                55

                Bilberry
                1
                5
                10
                15
                20
                25
                30
                35
                40
                45
                50
                55
                60
                65
                70
                75

                Blackberry
                0.1
                5
                10
                20
                50
                75
                100
                125
                150
                175
                200
                225
                250
                275
                300
                350

                Blackcurrant
                0.1
                0.5
                1
                2
                2
                4
                4
                4
                6
                6
                6
                8
                8
                10
                12
                14

                Blueberry
                0.1
                0.5
                1
                4
                6
                8
                10
                12
                14
                16
                18
                20
                24
                28
                30
                36

                Boysenberry
                0.5
                1
                2.5
                4
                5.5
                7
                8.5
                10
                11.5
                13
                14.5
                16
                17.5
                19
                20.5
                22

                Cherry
                0.5
                1
                2.5
                5
                8
                10
                15
                20
                25
                28
                31
                35
                40
                45
                50
                55

                Coconut
                0.1
                0.25
                0.5
                0.5
                1
                1
                2
                2
                2
                2
                2.5
                2.5
                3
                3
                3
                3

Calculate dropdown matching Tables

This is working version.


text:
Q: Rails: whats the best way to divide a large group of users to run a task in different days without repeating the same user? I'm coding an automated mailer report for my Rails app and I want to divide thousands of users into 7 different groups to send e-mails to one group each weekday (Time.now.wday).
The reason is if the mailer is fired at the same time for everybody, a traffic spike will occur and support might not handle all those users at the same time.
What's the best way of dividing users so that:

*

*The rake task is run once a week, and the user should only be in one group in the same week (so he doesn't get mailed twice in the same week)

*The # of users can grow during the week (new users) and they need to be included in one group at least

A: One of the most common approaches is to keep track of the date and time when you last sent an email to an user.
You add a last_emailed_at column to your users table.
Then you can have the rake task query the first X number of users
where('last_emailed_at IS NULL OR last_emailed_at < ?', 1.week.ago)

You should order the results by last_emailed_at in ascending order (with NULLS FIRST if your database supports it).


text:
Q: Facing issue while creating user through keycloak I am trying to create users in keycloak through java web application and below is the code that I am using:
    Keycloak kc = Keycloak.getInstance("http://localhost:8080/auth/", "realm", "username", "password", "Client");

    CredentialRepresentation credential = new CredentialRepresentation();
    credential.setType(CredentialRepresentation.PASSWORD);
    credential.setValue("test123");
    UserRepresentation user = new UserRepresentation();
    user.setUsername("testuser");
    user.setFirstName("Test");
    user.setLastName("User");
    user.setCredentials(Arrays.asList(credential));
    kc.realm("demo").users().create(user);

I have added the below dependencies my pom.xml:
<dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jaxrs</artifactId>
            <version>3.0.19.Final</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-client</artifactId>
            <version>3.0.19.Final</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jackson-provider</artifactId>
            <version>3.0.19.Final</version>
        </dependency>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <version>2.0-m07</version>
        </dependency>
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-admin-client</artifactId>
            <version>3.0.0.Final</version>

    </dependency>

and below entries in web.xml:
<context-param>
    <param-name>resteasy.scan</param-name>
    <param-value>true</param-value>
</context-param>

<!-- this need same with resteasy servlet url-pattern -->
<context-param>
    <param-name>resteasy.servlet.mapping.prefix</param-name>
    <param-value>/auth</param-value>
</context-param>

<listener>
    <listener-class>
        org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
    </listener-class>
</listener>

<servlet>
    <servlet-name>resteasy-servlet</servlet-name>
    <servlet-class>
        org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
    </servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>resteasy-servlet</servlet-name>
    <url-pattern>/auth/*</url-pattern>
</servlet-mapping>

and I have also created a jboss-deployment-structure.xml with the below code:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <deployment>
        <dependencies>
            <module name="org.jboss.resteasy.resteasy-jaxrs" export="true"
                meta-inf="export" slot="main" />
            <module name="org.jboss.resteasy.resteasy-jackson-provider"
                export="true" meta-inf="export" slot="main" />
            <module name="javax.ws.rs.api" services="export" export="true" />
        </dependencies>
    </deployment>
</jboss-deployment-structure>

I am getting the below error:
10:56:39,428 WARN  [org.jboss.modules] (http-127.0.0.1:8080-1) Failed to define class org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder in Module "deployment.Test.war:main" from Service Module Loader: java.lang.LinkageError: Failed to link org/jboss/resteasy/client/jaxrs/ResteasyClientBuilder (Module "deployment.Test.war:main" from Service Module Loader)
       at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:487) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:277) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:92) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.Module.loadModuleClass(Module.java:568) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.keycloak.admin.client.Keycloak.<init>(Keycloak.java:52) [keycloak-admin-client-3.0.0.Final.jar:3.0.0.Final]
       at org.keycloak.admin.client.Keycloak.getInstance(Keycloak.java:78) [keycloak-admin-client-3.0.0.Final.jar:3.0.0.Final]
       at com.test.ui.login.controller.KeycloakLoginActionController.initialize(KeycloakLoginActionController.java:86) [classes:]
       at com.test.ui.login.controller.KeycloakLoginActionController$Proxy$_$$_WeldClientProxy.initialize(KeycloakLoginActionController$Proxy$_$$_WeldClientProxy.java) [classes:]
       at com.test.ui.login.bean.KeycloakLoginBean.initialize(KeycloakLoginBean.java:31) [classes:]
       at com.test.ui.login.bean.KeycloakLoginBean$Proxy$_$$_WeldClientProxy.initialize(KeycloakLoginBean$Proxy$_$$_WeldClientProxy.java) [classes:]
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_67]
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_67]
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_67]
       at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_67]
       at org.apache.el.parser.AstValue.invoke(AstValue.java:258) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40) [weld-core-1.1.33.Final-redhat-1.jar:1.1.33.Final-redhat-1]
       at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) [weld-core-1.1.33.Final-redhat-1.jar:1.1.33.Final-redhat-1]
       at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.1.28.SP9-redhat-1.jar:2.1.28.SP9-redhat-1]
       at com.sun.faces.facelets.tag.jsf.core.DeclarativeSystemEventListener.processEvent(EventHandler.java:128) [jsf-impl-2.1.28.SP9-redhat-1.jar:2.1.28.SP9-redhat-1]
       at javax.faces.component.UIComponent$ComponentSystemEventListenerAdapter.processEvent(UIComponent.java:2526) [jboss-jsf-api_2.1_spec-2.1.28.SP1-redhat-1.jar:2.1.28.SP1-redhat-1]
       at javax.faces.event.SystemEvent.processListener(SystemEvent.java:106) [jboss-jsf-api_2.1_spec-2.1.28.SP1-redhat-1.jar:2.1.28.SP1-redhat-1]
       at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2166) [jsf-impl-2.1.28.SP9-redhat-1.jar:2.1.28.SP9-redhat-1]
       at com.sun.faces.application.ApplicationImpl.invokeComponentListenersFor(ApplicationImpl.java:2111) [jsf-impl-2.1.28.SP9-redhat-1.jar:2.1.28.SP9-redhat-1]
       at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:289) [jsf-impl-2.1.28.SP9-redhat-1.jar:2.1.28.SP9-redhat-1]
       at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:247) [jsf-impl-2.1.28.SP9-redhat-1.jar:2.1.28.SP9-redhat-1]
       at org.jboss.as.weld.webtier.jsf.ForwardingApplication.publishEvent(ForwardingApplication.java:293) [jboss-as-weld-7.5.7.Final-redhat-3.jar:7.5.7.Final-redhat-3]
       at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107) [jsf-impl-2.1.28.SP9-redhat-1.jar:2.1.28.SP9-redhat-1]
       at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.28.SP9-redhat-1.jar:2.1.28.SP9-redhat-1]
       at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [jsf-impl-2.1.28.SP9-redhat-1.jar:2.1.28.SP9-redhat-1]
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) [jboss-jsf-api_2.1_spec-2.1.28.SP1-redhat-1.jar:2.1.28.SP1-redhat-1]
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:100) [primefaces-5.2.jar:5.2]
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.5.7.Final-redhat-3.jar:7.5.7.Final-redhat-3]
       at org.keycloak.adapters.tomcat.AuthenticatedActionsValve.invoke(AuthenticatedActionsValve.java:68) [keycloak-tomcat-core-adapter-3.3.0.CR2.jar:3.3.0.CR2]
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:512) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.keycloak.adapters.tomcat.AbstractKeycloakAuthenticatorValve.invoke(AbstractKeycloakAuthenticatorValve.java:185) [keycloak-tomcat-core-adapter-3.3.0.CR2.jar:3.3.0.CR2]
       at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.5.7.Final-redhat-3.jar:7.5.7.Final-redhat-3]
       at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.5.7.Final-redhat-3.jar:7.5.7.Final-redhat-3]
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:150) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:854) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_67]
Caused by: java.lang.NoClassDefFoundError: javax/ws/rs/client/ClientBuilder
       at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.7.0_67]
       at java.lang.ClassLoader.defineClass(ClassLoader.java:800) [rt.jar:1.7.0_67]
       at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:361) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:482) [jboss-modules.jar:1.3.7.Final-redhat-1]
       ... 56 more
Caused by: java.lang.ClassNotFoundException: javax.ws.rs.client.ClientBuilder from [Module "deployment.Test.war:main" from Service Module Loader]
       at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.7.Final-redhat-1]
       ... 60 more

11:03:11,155 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/Test].[Faces Servlet]] (http-127.0.0.1:8080-1) JBWEB000236: Servlet.service() for servlet Faces Servlet threw exception: java.lang.ClassNotFoundException: javax.ws.rs.client.ClientBuilder from [Module "deployment.Test.war:main" from Service Module Loader]
       at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.7.0_67]
       at java.lang.ClassLoader.defineClass(ClassLoader.java:800) [rt.jar:1.7.0_67]
       at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:361) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:482) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:277) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:92) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.Module.loadModuleClass(Module.java:568) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.7.Final-redhat-1]
       at org.keycloak.admin.client.Keycloak.<init>(Keycloak.java:52) [keycloak-admin-client-3.0.0.Final.jar:3.0.0.Final]
       at org.keycloak.admin.client.Keycloak.getInstance(Keycloak.java:78) [keycloak-admin-client-3.0.0.Final.jar:3.0.0.Final]
       at com.test.ui.login.controller.KeycloakLoginActionController.initialize(KeycloakLoginActionController.java:86) [classes:]
       at com.test.ui.login.controller.KeycloakLoginActionController$Proxy$_$$_WeldClientProxy.initialize(KeycloakLoginActionController$Proxy$_$$_WeldClientProxy.java) [classes:]
       at com.test.ui.login.bean.KeycloakLoginBean.initialize(KeycloakLoginBean.java:31) [classes:]
       at com.test.ui.login.bean.KeycloakLoginBean$Proxy$_$$_WeldClientProxy.initialize(KeycloakLoginBean$Proxy$_$$_WeldClientProxy.java) [classes:]
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_67]
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_67]
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_67]
       at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_67]
       at org.apache.el.parser.AstValue.invoke(AstValue.java:258) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40) [weld-core-1.1.33.Final-redhat-1.jar:1.1.33.Final-redhat-1]
       at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) [weld-core-1.1.33.Final-redhat-1.jar:1.1.33.Final-redhat-1]
       at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.1.28.SP9-redhat-1.jar:2.1.28.SP9-redhat-1]
       at com.sun.faces.facelets.tag.jsf.core.DeclarativeSystemEventListener.processEvent(EventHandler.java:128) [jsf-impl-2.1.28.SP9-redhat-1.jar:2.1.28.SP9-redhat-1]
       at javax.faces.component.UIComponent$ComponentSystemEventListenerAdapter.processEvent(UIComponent.java:2526) [jboss-jsf-api_2.1_spec-2.1.28.SP1-redhat-1.jar:2.1.28.SP1-redhat-1]
       at javax.faces.event.SystemEvent.processListener(SystemEvent.java:106) [jboss-jsf-api_2.1_spec-2.1.28.SP1-redhat-1.jar:2.1.28.SP1-redhat-1]
       at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2166) [jsf-impl-2.1.28.SP9-redhat-1.jar:2.1.28.SP9-redhat-1]
       at com.sun.faces.application.ApplicationImpl.invokeComponentListenersFor(ApplicationImpl.java:2111) [jsf-impl-2.1.28.SP9-redhat-1.jar:2.1.28.SP9-redhat-1]
       at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:289) [jsf-impl-2.1.28.SP9-redhat-1.jar:2.1.28.SP9-redhat-1]
       at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:247) [jsf-impl-2.1.28.SP9-redhat-1.jar:2.1.28.SP9-redhat-1]
       at org.jboss.as.weld.webtier.jsf.ForwardingApplication.publishEvent(ForwardingApplication.java:293) [jboss-as-weld-7.5.7.Final-redhat-3.jar:7.5.7.Final-redhat-3]
       at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107) [jsf-impl-2.1.28.SP9-redhat-1.jar:2.1.28.SP9-redhat-1]
       at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.28.SP9-redhat-1.jar:2.1.28.SP9-redhat-1]
       at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [jsf-impl-2.1.28.SP9-redhat-1.jar:2.1.28.SP9-redhat-1]
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) [jboss-jsf-api_2.1_spec-2.1.28.SP1-redhat-1.jar:2.1.28.SP1-redhat-1]
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:100) [primefaces-5.2.jar:5.2]
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.5.7.Final-redhat-3.jar:7.5.7.Final-redhat-3]
       at org.keycloak.adapters.tomcat.AuthenticatedActionsValve.invoke(AuthenticatedActionsValve.java:68) [keycloak-tomcat-core-adapter-3.3.0.CR2.jar:3.3.0.CR2]
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:512) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.keycloak.adapters.tomcat.AbstractKeycloakAuthenticatorValve.invoke(AbstractKeycloakAuthenticatorValve.java:185) [keycloak-tomcat-core-adapter-3.3.0.CR2.jar:3.3.0.CR2]
       at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.5.7.Final-redhat-3.jar:7.5.7.Final-redhat-3]
       at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.5.7.Final-redhat-3.jar:7.5.7.Final-redhat-3]
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:150) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:854) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
       at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_67]

I see that keycloak is internally using RestEasy framework to call the rest api to create the user. Is it possible to redirect the keycloak to use com.sun.jersey to do this operation or if I am making any mistake in my setup?

A: I was able to perform this task by migrating my application to JBoss EAP 7.0. Seems like something is missing in JBoss EAP 6.4.7 related to Keycloak dependency.


text:
Q: Typing game made in python (timer, multithreading, def(), etc import random
from threading import Timer

class color:
   PURPLE = '\033[95m'
   CYAN = '\033[96m'
   DARKCYAN = '\033[36m'
   BLUE = '\033[94m'
   GREEN = '\033[92m'
   YELLOW = '\033[93m'
   RED = '\033[91m'
   BOLD = '\033[1m'
   UNDERLINE = '\033[4m'
   END = '\033[0m'

score = 0

list = ("Toothpaste", "Seashell", "Binder", "Computer", "Laptop", "Tablet", "Turing", "Python", "Circuit")
list2 = ("Mathematics", "Onomatopoeia", "Obnoxious", "Archiving", "Licencing")

endgame = 0

def printbob():
    print("you lose bro")
    endgame = 1

def boys():
    points = 0
    while(score >= 0):
        timeout = 3
        timer = Timer(timeout, printbob)
        timer.start()
        if(points < 5):
            cs = random.choice(list)
        else:
            cs = random.choice(list2)
        print("Type this sentence:", color.GREEN + cs + color.END)
        user = "You have %d seconds to choose the correct answer...\n" % timeout
        answer = input(user)
        timer.cancel()
        if (answer == cs) and (endgame == 0):
            print("Nice")
            points += 1
        else:
            print("Bye")
            exit()
boys()

This is a program that prints an chosen word from a list, and requires the user to print the exact same word within the constrained time. However, the issue is that if no input is given, the code does not exit since it is waiting for an input.
In short, how can I adjust my code so that the program exits when no input is given.
Thanks,
Robert Daniro

A: You can use a special keyword input like QUIT or EXIT to exit the program or you can set up an upper limit for the wait time. If the time exceed some value you quit the program with a message.


text:
Q: zshell command named "prompt" in macOS? I'm using the zshell for macOS Catalina (10.15.6). The book "Learning Shell Scripting With Zsh" describes an executable command named prompt, usable in such forms as:
$ prompt -p
$ prompt -h
$ prompt <theme_name>
$ prompt adam1 red yellow magenta

But zsh report "command not found: prompt".
How do I obtain that command, or an equivalent one.
(Everywhere I've tried to search about this just gives me links to places explaining how to set the zsh prompt, with all the usual escape sequences, "$..." symbols, etc.)

A: From man zshcontrib:
PROMPT THEMES
   Installation
       You  should  make  sure  all  the  functions from the Functions/Prompts
       directory of the source distribution are available; they all begin with
       the  string `prompt_' except for the special function`promptinit'.  You
       also  need  the  `colors'  and  `add-zsh-hook'  functions  from   Func-
       tions/Misc.   All these functions may already be installed on your sys-
       tem; if not, you will need to find them and copy them.   The  directory
       should  appear  as  one of the elements of the fpath array (this should
       already be the case if they were installed), and at least the  function
       promptinit  should  be autoloaded; it will autoload the rest.  Finally,
       to initialize the use of the system you need  to  call  the  promptinit
       function.   The  following  code  in your .zshrc will arrange for this;
       assume the functions are stored in the directory ~/myfns:

              fpath=(~/myfns $fpath)
              autoload -U promptinit
              promptinit

So, to get the prompt command, you can just run
$ autoload -U promptinit
$ promptinit


text:
Q: jquery date picker - specific months Is there a way to set the jquery ui date picker to only show a couple of specific months? For example I'm setting this up on a form so when a user is inquiring about availability the only months that show up on the jquery date picker are June / July?

A: You can restrict dates by placing a max/min:
http://jqueryui.com/demos/datepicker/#min-max
But I don't think you can't pick & choose specific months
i.e. Allow May & July, but disable June

A: Try this one also: very cool month and year picker. you can select only specific months:
http://tinytools.codesells.com/PeriodSelector

A: Try using the maxDate and minDate options.


text:
Q: LEFT JOIN doesn't consider ON clause My query below is used to retrieve list of items which has been ordered and returned by the customer. I'm confused with the last join, ReturnCustomer, where I want the query to return data with status = 20 or otherwise it returns NULL. Below is my query:
SELECT Product.id AS product_id, Product.supplier_product_id AS vip_id, Product.name AS product_name, detailSO.qty, detailRC.return_qty
FROM Product
RIGHT JOIN detailSO ON detailSO.product_id = Product.id
RIGHT JOIN SalesOrder ON SalesOrder.id = detailSO.so_id AND SalesOrder.status >= 20
LEFT JOIN detailRC ON detailRC.sur_key = detailSO.sur_key
LEFT JOIN ReturnCustomer ON ReturnCustomer.id = detailRC.rc_id AND ReturnCustomer.status >= 20

If I use LEFT JOIN, it doesn't consider about ReturnCustomer.status >= 20 since it returns all data. On the other hand, if I use RIGHT JOIN it will only return data with ReturnCustomer.status >= 20,
LEFT JOIN Result:
P_id    Pp_id   P_name  i_qty   r_qty
P000001 P000001 Item 1  15      1
P000001 P000001 Item 1  5       1
P000002 P000002 Item 2  5       NULL

RIGHT JOIN Result:
P_id    Pp_id   P_name  i_qty   r_qty
P000001 P000001 Item 1  15      1

Expected Result:
P_id    Pp_id   P_name  i_qty   r_qty
P000001 P000001 Item 1  15      1
P000001 P000001 Item 1  5       NULL <-- null since it comes from ReturnCustomer with status = 0
P000002 P000002 Item 2  5       NULL

I know maybe I could solve this using nested query, hopefully you guys can provide me a better solution. Thanks in advance
UPDATE:
Here is my simplified problem sqlfiddle..

A: a LEFT JOIN b works exactly like that.. (the a will always be present, where b may be null)
ON works only removing the b, where a won't be affected..
WHERE works by removing rows
so when
 A have 1,2,3
 B have 1,2
 C have 1,3

when those three left joined, for example:
 SELECT *
 FROM A
 LEFT JOIN B ON A.x = B.x
 LEFT JOIN C ON B.x = C.x

it would give:
 A B C
 1 1 1
 2 2
 3

if the second LEFT JOIN joined to A, for example:
 SELECT *
 FROM A
 LEFT JOIN B ON A.x = B.x
 LEFT JOIN C ON A.x = C.x

it would give:
 A B C
 1 1 1
 2 2
 3   3

any more criteria on the last ON won't remove the B part, since  it's already joined before, any criteria on WHERE part will remove whole row.
In your case, if you want to hide the B part, you should not use ON or WHERE, the correct one would be using CASE WHEN in the SELECT part, for example:
SELECT detailSO.product_id
, detailSO.qty
, CASE WHEN RC.id IS NULL THEN NULL ELSE detailRC.qty END AS x
FROM SO
LEFT JOIN detailSO ON detailSO.so_id = SO.id
LEFT JOIN detailRC ON detailRC.sur_key = detailSO.sur_key
LEFT JOIN RC ON RC.id = detailRC.rc_id AND RC.status >= 20
WHERE SO.status >= 20

Result in sql Fiddle
product_id  qty x
P00001      15  1
P00001      5   (null)
P00002      5   (null)

A: this may works
SELECT
  Product.id AS product_id,
  Product.supplier_product_id AS vip_id,
  Product.name AS product_name,
  detailSO.qty,
  detailRC.return_qty
FROM
  Product
  RIGHT JOIN detailSO
    ON detailSO.product_id = Product.id
  RIGHT JOIN SalesOrder
    ON SalesOrder.id = detailSO.so_id
    AND SalesOrder.status >= 20
  LEFT JOIN detailRC
    ON detailRC.sur_key = detailSO.sur_key
  LEFT JOIN ReturnCustomer
    ON ReturnCustomer.id = detailRC.rc_id
    WHERE ReturnCustomer.status >= 20

A: did you try the below:
SELECT Product.id AS product_id, Product.supplier_product_id AS vip_id,
       Product.name AS product_name, detailSO.qty, detailRC.return_qty
       FROM Product
       RIGHT JOIN detailSO ON detailSO.product_id = Product.id
       RIGHT JOIN SalesOrder ON SalesOrder.id = detailSO.so_id
       LEFT JOIN detailRC ON detailRC.sur_key = detailSO.sur_key
       LEFT JOIN ReturnCustomer ON ReturnCustomer.id = detailRC.rc_id
where
       ReturnCustomer.status >= 20
  AND  SalesOrder.status >= 20

A: I suspect this is how it evaluates the NULL values.  Try using ISNULL in your ON clause:
SELECT Product.id AS product_id, Product.supplier_product_id AS vip_id, Product.name AS product_name, detailSO.qty, detailRC.return_qty
FROM Product
RIGHT JOIN detailSO ON detailSO.product_id = Product.id
RIGHT JOIN SalesOrder ON SalesOrder.id = detailSO.so_id AND SalesOrder.status >= 20
LEFT JOIN detailRC ON detailRC.sur_key = detailSO.sur_key
LEFT JOIN ReturnCustomer ON ReturnCustomer.id = detailRC.rc_id AND ISNULL(ReturnCustomer.status, 0) >= 20

A: Using nested query gives you desired result
 SELECT temp.* from (
      SELECT
      Product.id AS product_id,
      Product.supplier_product_id AS vip_id,
      Product.name AS product_name,
      detailSO.qty,
      detailRC.return_qty
    FROM
      Product
      RIGHT JOIN detailSO
        ON detailSO.product_id = Product.id
      RIGHT JOIN SalesOrder
        ON SalesOrder.id = detailSO.so_id
      LEFT JOIN detailRC
        ON detailRC.sur_key = detailSO.sur_key
      LEFT JOIN ReturnCustomer
        ON ReturnCustomer.id = detailRC.rc_id

    ) as temp
     WHERE temp .status >= 20


text:
Q: Internal server error after changin php.ini So i was having issues while sending emails from my php code, the emails doulnd't get out from my domain, but they worked with in the domain, example, from info@domain.com to another_mail@domain.com it was ok, but from info@domain.com to my_personal_mail@gmail.com it wasn't. So i tried to add the following line to my php.ini:
sendmail_path="/mail"

And the following started to appear in my index (and all other pages):
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at webmaster@domain.com to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

After that I erased that line, but there was no turning back.
Also I tried to use the cpanel MultiPHP INI editor to override the php.ini file, but the problem still persist
Also i tried to add this line to my php.ini:
sendmail_path = "/usr/sbin/sendmail -t -i"

I wasn't able to find the server error log.

A: The solution was given by the support of my service, they "reloaded the php version" and "restoring" the permissions on the system files.


text:
Q: Bitbucket for Salesforce I want to set up bitbucket so that i can push the code changes to the bitbucket and the changes should get deployed to the Salesforce org from bitbucket.
How to achieve this?

A: You might this project useful:

*

*SFDX Bitbucket Pipelines Example

This project is meant to demonstrate how bitbucket pipelines can be used in conjuction with Saleforce DX to provide a continuous integration solution.


text:
Q: python re.match doesn't work for a multipleline text file I would like to write a Python program that searches and saves the vocabulary definition of an English word.
I have converted a Babylon English-Italian dictionary into a text file.
I would like that re.match() matches the first word of each line, but it doesn't.
I get always: 'not found', namely None for any query (word copied in my code) I use.
The Babylon text file can be found here:
https://tempfile.io/en/ba2voaBnDJsn24P/file
Thanks
import clipboard
import json
import re

wordcopied = clipboard.paste()
print(wordcopied)
dictionary = {}

with open("/home/user/Babylon-EI.txt", "r") as source:
    lsource = source.readlines()
    for line in lsource:
        #print(type(line))
        matc = re.match(wordcopied, line, re.MULTILINE | re.DOTALL)
        if matc != None:
            print(line)
            dictionary = {wordcopied:line}
        else:
            print('not found')
            break

I've tried also with re.search, and with multiple flags..
Related questions are all answered regarding flags and blanks


text:
Q: Expo BarCodeScanner crashes in some android devices I added the Expo BarCodeScanner. On some android devices the app crashes when scanning a code. Is this a known issue maybe? I tested this and on some android devices it works fine but some other android devices the app crashes and restart.
Here is my code:
import React, { useState, useEffect } from 'react';
import { Text, View, StyleSheet, Button, Image, TouchableOpacity, Dimensions, Vibration, Platform } from 'react-native';
import { useFocusEffect } from '@react-navigation/native';
import { BarCodeScanner } from 'expo-barcode-scanner';

export default function QrCodeScanScreen ({ navigation }) {

  const [hasPermission, setHasPermission] = useState(null);
  const [errorMessage, setErrorMessage] = useState('');
  const [scanned, setScanned] = useState(false);
  const [voucher, setVoucher] = useState('');
  const [type, setType] = useState(null);
  const [data, setData] = useState(null);

const handleBarCodeScanned = ({ data }) => {
    Vibration.vibrate();
    if (!scanned) {
        setVoucher('');
        scanApi(data);
        setScanned(true);
      } else {
        setData(data);
      }
  }

useEffect(() => {
    (async () => {
      const { status } = await BarCodeScanner.requestPermissionsAsync();
      setHasPermission(status === 'granted');
    })();
  }, []);

const scanApi = async (data) => {
    console.log(data);
  }

if (hasPermission === null) {
    return <Text style={{ textAlign: 'center', marginTop: 35, fontFamily: 'Book' }}>Camera laden...</Text>;
  }
  if (hasPermission === false) {
    return <Text style={{ textAlign: 'center', marginTop: 35, fontFamily: 'Book' }}>Geen toegang tot de camera. Ga naar je instellingen om toegang te verlenen.</Text>;
  }

return (
  <BarCodeScanner
   onBarCodeScanned={scanned ? undefined : handleBarCodeScanned}
   width={Dimensions.get('window').width}
   height={Dimensions.get('window').height - 100}
  />
);
}


text:
Q: react-hook-form: How validate object works I see in the docs
<input
  {...register("test1", {
    validate: {
      positive: v => parseInt(v) > 0,
      lessThanTen: v => parseInt(v) < 10,
      checkUrl: async () => await fetch(),
    }
  })}
/>

So here how can i show different messages for each validation.
like number is -5, then i show
"Number is not positive"
"Number less than 10"

HOw to access each error positive and lessThanTen

A: Per default RHF will only show one error per field, so if there are multiple you will you don't have to loop over them. You can just use the errors object provided by RHF and access the name of your field and then the message property.
If you need to have all errors to be shown simultaneously you can set the config criteriaMode, check the docs here for more info.
function App() {
  const {
    register,
    handleSubmit,
    formState: { errors }
  } = useForm();

  const onSubmit = (data) => {
    console.log(data);
  };

  return (
    <form onSubmit={handleSubmit(onSubmit)}>
      Test Field
      <input
        {...register("test1", {
          validate: {
            positive: (v) => parseInt(v) > 0 || "Number is not positive",
            lessThanTen: (v) => parseInt(v) < 10 || "Number less than 10",
            checkUrl: async () => {
              const result = await Promise.resolve(true);

              return result || "result was false so show this message";
            }
          }
        })}
      />
      {errors.test1 &&
{errors.test1.message}
}

      <input type="submit" />
    </form>
  );
}

A: To apply multiple validations, you can build a custom hook as a resolver. A custom hook can easily integrate with yup/Joi/Superstruct as a validation method, and be used inside validation resolver.
You can find more doc and examples here:
https://react-hook-form.com/advanced-usage/
in the section:
Custom Hook with Resolver
I recommend you yup.


text:
Q: qTip2: how to make a tooltip move to left when a link is close to the right side of the browser? I am using qTip 2.0.1 for displaying tooltips.
I make the tooltip show up in the bottom right of a link. The issue is that when the link is close to the right side of the browser, the tooltip box looks squeezed and ugly.
Can I configure qTip to make it auto-adjust its tooltip position to bottom-left?

A: You can use the collision detection as demonstrated on their demo:
position: {
        at: $('#at').val(),
        my: $('#my').val(),
        viewport: $(window),
        adjust: {
            method: [your method]
        }
    },
...

Documentation


text:
Q: Google maps rectangle selection tool: how to keep the rectangle displayed in keydragzoom library With the keydragzoom library, you can mouse drag over a map to make rectangle selection, see this example: http://google-maps-utility-library-v3.googlecode.com/svn/tags/keydragzoom/2.0.9/examples/events.html
What I want is to use this as a selection tool, i.e. to select particular rectangle, and keep the rectangle (the selection) displayed. But the rectangle always dissapears after ending the mouse drag. Is there any way how to achieve this with this library?
I tried to set noZoom option to true, but it didn't help. I know I can draw my own rectangle, but it would require to handle situations when selecting a new rectangle, etc. So I would like to do it within this library.


text:
Q: How can Captain America's shield make any sound? In Captain America: The First Avenger, Howard Stark introduces Vibranium to us, saying that it's 'a lot stronger than steel, and a third the weight, and it's completely vibration-absorbent'. This is while Steve is trying out the Vibranium shield.
And we all know that when you hit something, the reason it might make a sound, like the ringing of a bell or the sound of a gong, it's because hitting the object causes it to vibrate, thus causing the air around it to vibrate, and so we perceive this as sound. For a bell, the surface is smaller, so it vibrates faster (higher frequency) so the note we hear is higher. For a gong, the vibration frequency is lower, so the note is lower.
Then in Captain America: The Winter Soldier, Bucky Barnes punches the shield in the fight sequence on the bridge, just after he shoots Natasha. And the shield made a sound very similar to a gong.
How is this possible if Vibranium is supposed to absorb all vibration (being completely vibration-absorbent). The shield should not be making any sound at all when hit...


text:
Q: Installshield write to 64-bit registry I'm building an installer that automatically selects which software to install based on the architecture (VersionNT64 condition on one feature, NOT VersionNT64 on the other), but there are a couple of registry keys that need to go in as well. If I turn on "64-Bit Component", it will (apparently) write to the appropriate part of the registry, but that requires a flag in the installer info that prevents it from opening on a 32-bit machine. The component even has the VersionNT64 condition on it, so it wouldn't even be used on a 32-bit machine, so is there another way around this? I have a couple of alternatives in mind (reset the flag after compile; custom action on a .reg file) but I'd prefer something more streamlined.

A: From what I know you can a component marked as a 64-bit one in a 32 bit package without preventing the package to work on x86 machines. Only if the package type is set to x64 it will stop working on x86 machines.


text:
Q: This equation returns NaN only when certain values are passed So for my C# programming class I have to calculate the number of months it would take to pay off a credit card balance given the balance, monthly payment and APR.
Here is the formula we were given to interpret:

Here is the C# version I made:
months = (double)decimal.Divide(-1, 30) * (
  Math.Log(1 + (double)(balance / payment) * (1 - Math.Pow((1 + (apr / 365)), 30)))
    / Math.Log(1 + (apr / 365))
);

It works for every example I've tried, except one, which is specified in a question I need to have the answer for:

How many months will it take Alice to pay off a $7,500.00 balance if the
  APR value is 0.22 and she pays $125.00 per month?

The output of which looks like:
Enter the credit card balance (example: 10000.00)
7500
Enter the monthly payment amount (example: 250.00)
125
Enter the annual percentage rate (example: 0.15)
0.22
It will take NaN months to pay off the balance.
Goodbye! Press any key to exit.

In my investigations, I plugged the formula into WolframAlpha and it returns two different values (http://bit.ly/1LQSsEx) perhaps this has something to do with it, but I am new to C# and have reached the end of my knowledge.
What is happening here, and how do I fix it?

A: the result of the following code yields a negative number.
1 + (double)(7500 / 125) * (1 - Math.Pow((1 + (0.22 / 365)), 30))

Math.Log for obvious reasons only works with numbers > 0
that's what giving you a NaN.


text:
Q: Highcharts export chart using node.js I am currently working to export the charts using highcharts. Highcharts has introduced export using node.js as mentioned in the link below. https://www.highcharts.com/blog/news/256-introducing-the-highcharts-node-js-export-server/
In the website above they have mentioned that "The CLI mode also replaces the old highcharts-convert.js PhantomJS script"
 But the link below clearly states they use phantom js.
https://www.highcharts.com/docs/export-module/setting-up-the-server
Do they use the in memory browser 'phantom js' internally to render charts?

A: Look dependencies at https://github.com/highcharts/node-export-server/blob/master/package.json for highcharts-export-server package
They use phantomjs-prebuilt package.


text:
Q: PHP for each drop down selected I got this piece of code here...
<form action="InvoiceNotice.php?action=invoicenotice" method="post">
Select Day
<select name="daySelected" id="daySelected">
<option value="0">Today</option>
<?php
$array = array_combine(range(1,$InvoiceDaysArray['days']), range(1,$InvoiceDaysArray['days']));
foreach($array as $row => $value){
    $selected = '';
    $daySelected = 0;
    if($daySelected == $row){
    $selected = 'SELECTED';
    }
    echo "<option selected='" . $selected . "' value='" . $row . "'>" . $value . " days ago</option>";
}
?>
</select>
<input type="submit" name="button" id="button" value="Submit" />
</form>

My issue is with the $selected the $daysSelected variable comes from what has been selected. What I am trying to do is when a user selects an option, that option is now selected in the dropdown and the page returns, after the client hits submit.
Does any one know what I am talking about?
Thanks

A: I would do something like:
foreach($array as $row => $value){
    $selected = '';
    if($_POST['daySelected'] == $row){
        $selected = ' selected="selected"';
    }
    echo "<option" . $selected . " value='" . $row . "'>" . $value . " days ago</option>";
}

Although you probably only need selected instead of selected="selected".

A: I see some problems in your code:
first you are setting $daySelected = 0; and then try compare with variable from database, day 0 is not in your foreach loop try this
    <form action="InvoiceNotice.php?action=invoicenotice" method="post">
Select Day
<select name="daySelected" id="daySelected">
<option value="0">Today</option>
<?php
$array = array_combine(range(1,$InvoiceDaysArray['days']), range(1,$InvoiceDaysArray['days']));
foreach($array as $row => $value){
    $selected = '';
    $daySelected = $_POST['daySelected'];
    if($daySelected == $row){
    $selected = "selected=SELECTED";
    }else {$selected='';}
    echo "<option '" . $selected . "' value='" . $row . "'>" . $value . " days ago</option>";
}
?>
</select>
<input type="submit" name="button" id="button" value="Submit" />
</form>


text:
Q: $S^n$ is not a retract of the disk $D^{n+1}$ and Brouwer's Fixed Point Theorem. I was trying to understand Hirsch's proof of this fact:

"There is also a quick proof, by Morris Hirsch, based on the
  impossibility of a differentiable retraction. The indirect proof
  starts by noting that the map f can be approximated by a smooth map
  retaining the property of not fixing a point; this can be done by
  using the Weierstrass approximation theorem, for example. One then
  defines a retraction as above which must now be differentiable. Such a
  retraction must have a non-singular value, by Sard's theorem, which is
  also non-singular for the restriction to the boundary (which is just
  the identity). Thus the inverse image would be a 1-manifold with
  boundary. The boundary would have to contain at least two end points,
  both of which would have to lie on the boundary of the original
  ball—which is impossible in a retraction." - Wikipedia - Brouwer fixed-point theorem

But I am confused about usage of Sard's theorem. Why does it say about "1-manifold with boundary?" I thought Sard's gives us only "1-manifold."

A: Here is a slightly more general theorem on regular values.
Suppose $f: M \to N$ is a smooth function, where $M$ has boundary and $N$ does not. Suppose $p \in N$ is a regular value of $f$. Then $S = f^{-1}(p)$ is a "properly embedded" submanifold of $M$, which means precisely that $S \cap \partial M = \partial S$. This is proved in the exact same way as the theorem where $M$ has no boundary. (The reason $\partial S \subset \partial M$, for instance, is that if you apply the standard theorem to $f\big|_{\text{int } M}$, then you obtain a submanifold without boundary $S \cap \text{int }(M)$.)
Now because $D^{n+1}$ is compact and the above theorem, a regular value $p$ of a map $f: D^{n+1} \to S^n$ has $f^{-1}(p)$ a compact, properly embedded 1-manifold. Compact 1-manifolds have an even number of boundary points. But if $s \in f^{-1}(p)$ is a boundary point, because $f$ is a retraction, $f(s) = s$; so $s = p$. Because $p \in f^{-1}(p)$, we see that this compact 1-manifold would have a single boundary point. Nonsense.


text:
Q: What's the term for telling the DMV that your vehicle isn't in use? In Sweden, when we don't use a vehicle, we tell our local DMV that it's not going to be on the road. Then, they sign it as such and we can pay less or no insurance (although we're extremely limited in terms of the permitted usage).
I want to tell that to someone about a vehicle and initially I said that it might be unregistered but that's not correct terminology. The vehicle is registered, it has plates and an owner.
What's the correct term for it in English? As it's a legal term, I wouldn't be surprised if it's different on the different sides of the oceans.

A: In California, this is called Planned Non-Operation (PNO):

PNO means that the vehicle will not be driven, towed, stored, or parked on public roads or highways for the entire registration year.

From another site, I found:

The DVM offers a special non-operational car registration for non operation vehicles which are neither to be driven nor parked on the communal street.

A: I just found out that the correct term in UK is

SORN

which stands for Statutory Off Road Notification.
I also just learned that DMV (Department of Motorization and Vehicles) isn't called RA (Road Administration) but DVLA (Driver and Vehicle Licensing Agency).


text:
Q: Can you get an auth code for Vodapay mini programs while in the simulator? For Vodapay mini-programs, is there a way to get an auth code while in the IDE simulator or is it only available while on the device?

A: You could make use of the applyAuthCode request to the test environment.
You can read more about it in the docs.


text:
Q: What is the equivalent of this BeautifulSoup expression in Xpath? I'm trying to scrape this link using scrapy and BeautifulSoup but for some reason BeautifulSoup is not working in the spider, it's only working in scrapy shell. I know this might sound silly, however, how to translate that to Xpath?
soup.find('li', {'class': 'at-listing__list-icons_location'})

I tried
response.xpath('//li[contains(text(),"at-listing__list icons_location")]/../descendant::text()').extract()

Please refer to my other question in which I included the logs I was trying to make things work using splash and BeautifulSoup but all attempts failed so far.

A: I suppose you're trying to get the 3 values 'Süddeutschland', 'Feste Anstellung' and 'Vollzeit'?
In that case the below xpath works for me:
response.xpath('//*[has-class("at-listing__list-icons_location")]/../descendant::text()').extract()

I think the problem in your xpath is that you're trying to look in the text for value 'at-listing__list icons_location', instead of the class.