text:
Q: Flux: Should Stores inform components about what's changed? I have a question regarding web application architecture such as Flux and related. Note that I don't use React.js, this question is purely about the architecture.
If I understand the concepts in Flux correctly, a Store informs components about changes. Components are then supposed to fetch all the data from the Store. What happens when I want to know exatly what have changed in the data? When ReactJS is used, the whole data could be given to React which then uses well designed diff and virtual DOM algorithms to apply the changes. But what if there's no React and there's a large amount of data?
Real life example
New data comes through WebSockets every 1-2 seconds. The data is added to the Store, but one of the components needs to know exatly what is changed (imagine that new data needs to appear in the view with some kind of animation). There's a lot of data, iterating over the whole array and comparing every element is not an option. Furthermore, intuitively it doesn't feel right because parts of the application know exactly whas it changed so why the view can't?
I was looking for the solution and I found three suggested approaches:

*

*The Store informs exactly what is changed (against the Flux rules)

*The Store keeps last changes and provides a public method getLastChanges()

*Additional Store which keeps only the last changed data.

Architecturally speaking, what's the proper solution here?

A:
But what if there's no React and there's a large amount of data?

In this case, Flux architecture doesn't apply well. Why do you want to use it?
Flux works well when views (or whatever's subscribed to the stores) can efficiently perform operations based on the knowledge of the current (and, sometimes, the previous) state alone. If this is not the case in your domain area, don't use Flux.


text:
Q: I have an error with passport.js implementation in Sails.js I have a problem with Sails Passport implementation. This error appears in my terminal:
/home/tatico/sinGualichoPassport/config/passport.js:19

if (!user.validPassword(password)) {
            ^

    TypeError: user.validPassword is not a function
        at /home/tatico/sinGualichoPassport/config/passport.js:19:17

    at returnResults (/home/tatico/.npm-global/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/finders/basic.js:180:9)
    at /home/tatico/.npm-global/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/finders/basic.js:86:16
    at /home/tatico/.npm-global/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/finders/operations.js:83:7
    at /home/tatico/.npm-global/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:52:16
    at Object.async.forEachOf.async.eachOf (/home/tatico/.npm-global/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:236:30)
    at Object.async.forEach.async.each (/home/tatico/.npm-global/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:209:22)
    at /home/tatico/.npm-global/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/finders/operations.js:436:11
    at /home/tatico/.npm-global/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/finders/operations.js:574:5
    at /home/tatico/.npm-global/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:52:16
    at Object.async.forEachOf.async.eachOf (/home/tatico/.npm-global/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:236:30)
    at Object.async.forEach.async.each (/home/tatico/.npm-global/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:209:22)
    at _buildChildOpts (/home/tatico/.npm-global/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/finders/operations.js:464:9)
    at _execChildOpts (/home/tatico/.npm-global/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/finders/operations.js:432:8)
    at /home/tatico/.npm-global/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/finders/operations.js:81:10
    at wrapper (/home/tatico/.npm-global/lib/node_modules/sails/node_modules/waterline/node_modules/lodash/index.js:3592:19)
    at applyInOriginalCtx (/home/tatico/.npm-global/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/normalize.js:421:80)
    at wrappedCallback (/home/tatico/.npm-global/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/normalize.js:324:18)
    at callback.success (/home/tatico/.npm-global/lib/node_modules/sails/node_modules/waterline/node_modules/switchback/lib/normalize.js:33:31)
    at _switch (/home/tatico/.npm-global/lib/node_modules/sails/node_modules/waterline/node_modules/switchback/lib/factory.js:58:28)
    at /home/tatico/.npm-global/lib/node_modules/sails/node_modules/waterline/lib/waterline/adapter/dql.js:166:7
    at wrapper (/home/tatico/.npm-global/lib/node_modules/sails/node_modules/waterline/node_modules/lodash/index.js:3592:19)

This is my Files:
config/passport.js:
var passport      = require('passport'),
    LocalStrategy = require('passport-local').Strategy
    bcrypt        = require('bcrypt');

passport.use(new LocalStrategy(
  function(username, password, done) {
    User.findOne({ username: username }, function(err, user) {
      if (err) { return done(err); }
      if (!user) {
        return done(null, false, { message: 'Incorrect username.' });
      }
      if (!user.validPassword(password)) {
        return done(null, false, { message: 'Incorrect password.' });
      }
      return done(null, user);
    });
  }
));

passport.serializeUser(function(user, done) {
  done(null, user.id);
});

passport.deserializeUser(function(id, done) {
  User.findById(id, function(err, user) {
    done(err, user);
  });
});

module.exports = {
    http: {
        customMiddleware: function(app){
            console.log('Express midleware for passport');
            app.use(express.static('public'));
            app.use(express.cookieParser());
            app.use(express.bodyParser());
            app.use(express.session({ secret: 'keyboard cat' }));
            app.use(passport.initialize());
            app.use(passport.session());
            app.use(app.router);
            app.use(function(req,res,next){
                // Set the loggedUser in locals *does it work?
                // to get it from the view
                res.locals.loggedUser = req.user;
                next();
            });
        }
    }
};

UserController.js
module.exports = {

    auth: function(req, res) {
        return res.view();
    },

    create: function(req, res, next) {
        User.create( req.params.all(), function createdUser(err, user){
            if (err) {
                return res.negotiate(err);
            }
            req.session.authenticated = true;
            req.session.user = user;
            return res.json(user);
        });
    },

    login: function(req, res, next) {
        // Use Passport LocalStrategy
        require('passport').authenticate('local', function(err, user, info){
            if ((err) || (!user)) next(err);
            req.login(user, function(err){
                if (err) return res.redirect('/user/auth');
                // Redirect to the user page.
                return res.redirect('/user/' + user.id);
            });
        })(req, res);
    },

    logout: function(req, res){
        // Call Passport method to destroy the session.
        req.logout();
        // Redirect to home page.
        return res.redirect('/');
    }
};

User.js:
module.exports = {

    attributes: {
        email: {
            type: 'string',
            required: true,
            email: true,
            unique: true
        },
        password: {
            type: 'string',
            required: true
        },

        username: {
            type: 'string',
            required: true,
            unique: true
        },

        toJSON: function() {
            var obj = this.toObject();
            delete obj.password;
            return obj;
        }
    },

    // Lifecycle Callbacks
    beforeCreate: function(values, next) {
        hashPassword(values, next);
    },
    beforeUpdate: function(values, next) {
        if(values.password) hashPassword(values, next);
        else next();
    }
}

var bcrypt = require('bcrypt');

function hashPassword(values, next) {
    bcrypt.hash(values.password, 10, function(err, hash) {
        if (err) return next(err);

        values.password = hash;
        next();
    });
}

Im new in Sails, and I suppose this is a not good implementantion, Anyone can Help me and give a little feed back to improve my understanding of Sails and Passport? Thanks.

A: ValidPassword is not defined anywhere which is leading to this error.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Passing environment variables in Dockerfile not working when I use 2 baseImages To be brief, I want to build a container in docker with a web project which configuration is modifiable depending on a parameter that is passed to it later when running the image in Docker.
This project tries to read a file call "environment.json" with the custom properties.
My Dockerfile is this:
# NodeJS
FROM node:13.12.0-alpine as build

WORKDIR /app

ENV PATH /app/node_modules/.bin:$PATH

COPY dist /app/dist
COPY define-env.js /app
COPY environments.json /app

# I have changed this with a lot of possible solutions
# that I have found in Internet, I tried everything.
# ARG APP_ENV
# ENV ENVIRONMENT $APP_ENV
RUN node define-env.js ${APP_ENV}

# NGINX
FROM nginx:stable-alpine
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

What I am doing is copying both: built basic web project, a node script responsible of writing the correct environment and a JSON file with all the possible configuration environments.
The Node script is this:
#!/usr/bin/env node

// we will need file system module to write the values
var fs = require("fs");
// this script is going to receive one parameter (see DockerFile)
var option = process.argv[2];
// taking all the possible configurations
var json = require("./environments.json");
// taking the chosen option (by default dev)
var environmentCfg = json[option] || json.dev;

// writing... It is important to do this task sync,
// because we need to be sure is finished before any step
fs.writeFileSync("./dist/environment.json", JSON.stringify(environmentCfg));

And the environments.json is something like this:
{
  "dev": {
    "title": "This is the dev environment",
    "anotherAttribute": "Hello dev, I was configured with Docker!"
  },
  "uat": {
    "title": "This is the uat environment",
    "anotherAttribute": "Hello uat, I was configured with Docker!"
  },
  "prod": {
    "title": "This is the prod environment",
    "anotherAttribute": "Hello prod, I was configured with Docker!"
  }
}

I do not know how to pass the variable when I run my Docker image, I am trying this:
docker build . -t docker-env

and then, once I have created my image I try to run it using this command:
docker run -e APP_ENV=uat -it --rm -p 1337:80 docker-env

When I go to the project I see the "dev" configuration always.
I have checked removing from DockerFile the NGINX configuration and I can see its working fine when I put the parameters.
I think something weird (or I do not know) is happening when I change the baseImage from Node to Nginx.
EDIT: as @babakabadkheir suggested in the comments, I have tried this following approach, but it is still failing:
FROM hoosin/alpine-nginx-nodejs:latest
WORKDIR /app

ENV PATH /app/node_modules/.bin:$PATH

COPY dist /app/dist
COPY define-env.js /app
COPY environments.json /app

RUN node define-env.js ${APP_ENV}
RUN mv ./dist/* /usr/share/nginx/html

EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

If I take a look to the mounted image shell I can see it has put the environment.json as well:

EDIT 2:
I have modified my Dockerfile like this but it is still not working:
# I am taking a base image with NodeJS and Nginx
FROM hoosin/alpine-nginx-nodejs:latest
# Telling Docker I like to work in the app workdir
WORKDIR /app
# Copying all files I need
COPY dist /app/dist
COPY define-env.js /app
COPY environments.json /app

# My environment variable for runtime purposes (dev by devfault)
ENV APP_ENV dev
# This instruction I think is failing, but when I swap it with
# CMD instead RUN and put a console.log works without troubles
RUN node define-env.js

# Once I have all the files I move it to the Nginx workspace
RUN mv ./dist /usr/share/nginx/html

# Setup Nginx server
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

Now my Node script looks like:
#!/usr/bin/env node

var fs = require("fs");
// NOTE: this line is already taken via environment
var option = process.env.APP_ENV;

var json = require("./environments.json");
var environmentCfg = json[option] || json.dev;
fs.writeFileSync("./dist/environment.json", JSON.stringify(environmentCfg));

LAST EDIT!
Finally I have it!
the solution was put all my needs in the CMD Docker instruction:
CMD node define-env && mv ./dist/* /usr/share/nginx/html && nginx -g 'daemon off;'

A: You made two mistakes: mixed ENV with ARGS and a syntax error.
When you define an ARG you can pass a value when build the image, if not specified the default value is used; then read the value on Dockerfile without the braces:
(Note: I used slightly different docker images)
Dockerfile
FROM node:12-alpine as build

# Note: I specified a default value
ARG APP_ENV=dev
WORKDIR /app

ENV PATH /app/node_modules/.bin:$PATH

COPY dist /app/dist
COPY define-env.js /app
COPY environments.json /app

# Note $APP_ENV and NOT ${APP_ENV} without braces
RUN node define-env.js $APP_ENV

# NGINX
FROM nginx:1.19
COPY --from=build /app/dist /usr/share/nginx/html
# Not necessary to specify port and CMD

Now for build the image you must specify the APP_ENV argument value
Build
docker build --build-arg APP_ENV=uat -t docker-uat .

Run
docker run -d -p 8888:80 docker-uat

;TL,DR
Your request is to specify the configuration at runtime, this problem has two solutions:

*

*Use ENV var when running container

*Use ARGS when building container
First solution has a drawback of security but the advantage of distributing a single image: you copy  the entire file from host to container and when running the container you passing the correct ENV value.
Second solution is slightly more complex do not has the security problem but you must build separate images each for each config.
The second solution is the already written answer, for the first solution you must simply read the env variable at runtime
Dockerfile
# NodeJS
FROM node:12-alpine as build

WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH

COPY dist /app/dist
COPY environments.json /app/dist

# NGINX
FROM nginx:1.19

# Define the environment variable
ENV APP_ENV=dev
COPY --from=build /app/dist /usr/share/nginx/html

Build
docker build -t docker-generic .

Run
docker run -d -p 8888:80 -e APP_ENV=uat docker-generic

Code
# On your nodejs code you simply read the ENV value
// ....
var env = process.env.APP_ENV

References
Dockerfile ARG
Docker build ARG
Dockerfile ENV
Docker run ENV

A: The solution for this it is to put all the things that are modifiable at runtime in the CMD instruction.
As I have experienced, RUN only works first time during build time, but CMD does not.
So I have put in my DockerFile:
CMD node define-env && mv ./dist/* /usr/share/nginx/html && nginx -g 'daemon off;'

I run my script, I move all the files and then serve my application.
I hope help other developers with this, because for me has been a pain.
TL;DR
In summary, the Dockerfile should be something like this:
# I am taking a base image with NodeJS and Nginx
FROM hoosin/alpine-nginx-nodejs:latest
# Telling Docker I like to work in the app workdir
WORKDIR /app
# Copying all files I need
COPY dist /app/dist
COPY define-env.js /app
COPY environments.json /app

# My environment variable for runtime purposes (dev by devfault)
ENV APP_ENV dev

# Setup Nginx server
EXPOSE 80
CMD node define-env && mv ./dist/* /usr/share/nginx/html && nginx -g 'daemon off;'


text:
Q: rerender on prop change in react not working I want to re render a component because I want to change the JSX HTML I've tried to create a state to rerender because of the new state change.
function todo(props) {

    function toggleactive(){

    }

    if(props.done === true){return (

{props.title}

                <button className={Styles.maxleft} onClick={() => toggleactive()}><svg xmlns="http://www.w3.org/2000/svg" className="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
                </svg></button>

{props.description}

                <button><svg xmlns="http://www.w3.org/2000/svg" className="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
                    </svg></button>
                <button><svg xmlns="http://www.w3.org/2000/svg" className="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
                </svg></button>

    )}
    else{
        console.log("d")

    }
}

and implement it in an array like this

                <button onClick={   () => settodos([...todos,{"name":faker.name.jobType(),"title":"d"}])}> new </button>

                <button className="bg-red-600 font-normal font-sans rounded-full text-xl bg-opacity-75 p-1" onClick={() => settodos(deleterandom)}>delete random</button>

            {todos.map(function(idx,dx){
                return (
{todo({"name":idx.title,"description":"d","title":idx.title,"done":true,"key":uniqueId()})}
)
            })}

now I want to write code into the toggle active function to re-render with the new props.value variable.

A: you mean something like this?
    const [active, setActive] = useState(false)

    function toggleactive(){
       setActive(!active)
    }

A: There are a couple issues with your code starting with your key's being set with uniqueId(). The ids should be unique but shouldn't change on each run like it currently is. You aren't calling Todo like a proper React function.
function Todo({ todo, toggleActive }) {
 return (
  ...
  <button className={Styles.maxleft} onClick={() => toggleActive(todo.id)}>
  ...
 );
}
function TodoContainer() {
 const [todos, setTodos] = useState([]);
 const toggleActive = useCallback((id) => setTodos((ts) => {
  const t = ts.find(t => t.id === id);
  t.done = !t.done;
  return [...ts];
 }), []);
 return (
  ...
  {todos.map(t => !t.done && (<Todo todo={t} toggleActive={toggleActive} key={t.id} />))}
  ...
 );
}


text:
Q: OpenCV no CodBloks c++ Alguém pode me ajudar, instalei a biblioteca opencv, e configurei ela no codeblocks, mas mesmo assim quando vou compilar o projeto, dis

A: Você não disse como configurou a biblioteca no Code::Blocks. Mas se você usou o "Project Build Options" então precisa fazer para a configuração Release e para a configuração Debug.
Se fez só para uma configuração não vai funcionar na outra.
Você também está usando uma versão muito antiga do Code::Blocks. A versão mais recente é a 17.12

A: Pelo que eu sei bibliotecas desse tipo, precisam antes de ser inseridas no código, serem instaladas direto na máquina, quando trabalhei com openCV primeiro tive de instalar no core da máquina e depois fiz a instancia da biblioteca, talvez esteja faltando algum arquivo pra você.


text:
Q: Can you initialize a derived class with an instance of a baseclass By that I mean a baseclass, which was not itself initialised using an instance of the derived class. i.e. lets assume it is not an abstract class.
class GeomObj{
  Colour x;
}

class Triangle extends GeomObj{
  largestAngle y;
}

GeomObj u;

//now is the following allowed?Taking into account that u was not initialized using an instance of Triangle in the first place

Triangle v = (Triangle)u;

A: No because a GeomObj is not a triangle. But the inverse works:
Triangle u;
GeomObj v = (GeomObj)u;

A: Furthermore, you can say that every Triangle is GeomObj, but not every GeomObj is a Triangle. So the compiler won't allow you to do that.


text:
Q: Web user control self reference (advanced) I am a bit stuck.
I have created a Web user control which renders a Question (I have a question domain object). This Web user control should render itself again for all Child questions of the current question.
Currently I am loading the child questions with LoadControl into the parent control. It works fine the child question controls do not keep viewstate. Nor do they trigger any proper postbacks.
What's the best way to load a web user control again within itself so that viewstate is properly preserved?
I am using VS2005 and ASP.NET 2.0

A: I'm going to take a guess that you have a timing issue. You may be loading your child controls too late in the asp.net page lifecycle for them to be loaded into view state. If you are loading your controls on Load, I can almost assure that this is the case. Try loading your controls earlier, perhaps OnInit?
Here is a diagram of the page lifecycle.


text:
Q: glob() function only returns empty array in php I've been trying to make a simple website that lets you specify a directory, and embeds a player for each mp3 in whatever directory the user specifies. The problem is that no matter how I enter the directory name, glob() does not return any files. I've tried this with local folders, server directories, and the same folder as the php file.
'directoryPath' is the name of the text box where the user enters, you guessed it, the directory path. The 'echo $files' statement displays nothing onscreen. The 'echo "test"' statement DOES run, but the 'echo "hello"' statement in the loop does not execute.
Any help is appreciated!
if (!empty($_POST['directoryPath']))
{
    $path = ($_POST['directoryPath']);
    $files = glob("$path/{*.mp3}", GLOB_BRACE);
    echo $files[0];
    echo "test";
    foreach($files as $i)
        {
            echo "hello";
            echo $files[$i];
            ?>
                <embed src=<?php $files[$i]; ?> width=256 height=32 autostart=false repeat=false loop=false></embed><?php echo $files[$i] ?></p>
            <?php;
        }
    unset($i);
}

A: Validate the input first:
$path = realpath($_POST['directoryPath']);
if (!is_dir($path)) {
    throw new Exception('Invalid path.');
}
...

Additionally check the return value glob returns false on error. Check for that condition (and ensure you are not using one of those systems that even return false when there are no files found).
I hope this is helpful. And yes, check your error log and enable error logging. This is how you can see what is going wrong.
Also see the following related function for a usage-example and syntax of GLOB_BRACE:

*

*Running glob() from an included script returns empty array

A: One one tool I find very useful in helping debug variables in PHP is var_dump(). It's a function that provides you with information about a variable's type, it's contents, and any useful metadata it can attain from that variable. This would be a very useful tool for you here, because you'll quickly realize what you have in the variable $i is not at all what you expect.
$files = glob("$path/{*.mp3}", GLOB_BRACE);
foreach ($files as $i) {
    var_dump($i);
}
/* Here's a hint, $i is not an index to the $files array.
   So $files[$i] makes no sense. $i is actually the value not the key.*/
foreach ($files as $key => $value) { // very different from
    // $key is the key to the current element of $files we're iterating over
    // $value is the value of the current element we're iterating over
}

So in your code $i is the value not the key. See http://php.net/foreach for more information on how the construct works.
Also, what should be noted here is that you are using a relative path, whereas glob will return an absolute path. By relative this means your searching relative to the CWD (Current Working Directory) of your PHP script. To see wha that is you can use the following code.
var_dump(real_path('.'));
// similarly ...
var_dump(getcwd());


text:
Q: Java - How to get and add cookies to request header correctly? I need to go to a bunch of different pages on a web site and collect info.  I'm not sure how to handle cookies.  If I use the chrome debugger console (F12) to look at the Network activity, I can see the request properties and cookies being sent.  If I specifically add the cookie for one of the pages (see the commented out con.setRequestProperty("Cookie", ...), the info is successfully retrieved.
            URL url = new URL(urlStr);
            HttpURLConnection con = (HttpURLConnection) url.openConnection();
            con.setRequestMethod("GET");
            con.setRequestProperty("Host", county +"." +referer +".com");
            con.setRequestProperty("Connection", "keep-alive");
            con.setRequestProperty("Accept", "application/json, text/javascript, */*; q=0.01");
            con.setRequestProperty("X-Requested-With", "XMLHttpRequest");
            con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36");
            con.setRequestProperty("Origin", "http://evil.com/");
            con.setRequestProperty("Referer", "https://" +county +"." +referer +".com/index.cfm?zaction=AUCTION&Zmethod=PREVIEW&AUCTIONDATE=" +df.format(date));
            con.setRequestProperty("Accept-Language", "en-US,en;q=0.9");
            //con.setRequestProperty("Cookie", "cfid=9ed9c083-4696-4712-950d-1c0ad0727883; cftoken=0; AWSELB=CF13C5A70AE16731FBD093515EF0DDB58935BEB4D69838721C70C3BED039F919AF343D891D9A2001BD1070AC4C076AA72DF0A7EA6AEED1091BCD24CC7203622E75C0DE5C92; _gcl_au=1.1.1696117075.1563489288; __utmc=119398810; __utmz=119398810.1563489288.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); CF_CLIENT_" +county.toUpperCase() +"_" +referer.toUpperCase() +"_TC=1563505029291; __utma=119398810.1711105058.1563489288.1563498837.1563505090.3; __utmt_UA-51657054-1=1; __utmb=119398810.10.10.1563505090; testcookiesenabled=disabled; CF_CLIENT_" +county.toUpperCase() +"_" +referer.toUpperCase() +"_LV=1563508162268; CF_CLIENT_" +county.toUpperCase() +"_" +referer.toUpperCase() +"_HC=221");

            //handle cookies
            String cookiesHeader = con.getHeaderField("Set-Cookie");
            List<HttpCookie> cookies = HttpCookie.parse(cookiesHeader);
            CookieManager cookieManager = new CookieManager();
            cookies.forEach(cookie -> cookieManager.getCookieStore().add(null, cookie));
            con.disconnect();
            con = (HttpURLConnection) url.openConnection();     //create new connection with cookies
            con.setRequestProperty("Cookie", StringUtils.join(cookieManager.getCookieStore().getCookies(), ";"));

            BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
            StringBuilder stringBuilder = new StringBuilder();
            while ((str = in.readLine()) != null) {
                stringBuilder.append(str);
            }
            in.close();
            con.disconnect();

But if use the code in the "handle cookies" section (from tutorial https://www.baeldung.com/java-http-request), an empty data set is returned.  Can someone spot what I am doing wrong?

A: The String cookiesHeader = con.getHeaderField("Set-Cookie"); is used to read the cookies from the response. But in your instance, it's not reading anything since the http request is not yet executed.
So first you would need to execute the request, and then you'd be able to read the cookies from the response with String cookiesHeader = con.getHeaderField("Set-Cookie");. So just add a con.connect() before String cookiesHeader = con.getHeaderField("Set-Cookie");, which would execute the request and then help read the cookies from the response. The rest of the code would then add the cookies received back to the request.
con.connect();
String cookiesHeader = con.getHeaderField("Set-Cookie");

You may also first check if the request execution succeeds and only then read the cookies and do the rest of the process as below:
int statusCode = con.getResponseCode();
if (statusCode == 200) {
   String cookiesHeader = con.getHeaderField("Set-Cookie");
   //rest of the code
}

A: It appears I might be barking up the wrong tree.  There are parameters to the url that apparently change over time.  You can see that below.

https://brevard.realforeclose.com/index.cfm?zaction=AUCTION&Zmethod=UPDATE&FNC=LOAD&AREA=W&PageDir=0&doR=1&tx=1563563124890&bypassPage=1&test=1&_=1563563124891
https://brevard.realforeclose.com/index.cfm?zaction=AUCTION&Zmethod=UPDATE&FNC=LOAD&AREA=W&PageDir=0&doR=1&tx=1563508160468&bypassPage=1&test=1&_=1563508160468

I don't know what the numbers mean or how to supply the right one at the right time.  The first one which was created yesterday now returns an empty set, the second one created just now returns good data.
Edit:
Well, I figured out what the numbers mean. There is a separate query to get the time in millis in New York, plus an offset. I've implemented that query and now it creates a valid url that always returns good data, if I paste it separately into a new browser window. But it still isn't showing me that data in my java code.
Here is the request headers and other data I see in the Chrome debugger (F12) Network tab when I access the data the official way from their link:
General
Request URL: https://brevard.realforeclose.com/index.cfm?zaction=AUCTION&Zmethod=UPDATE&FNC=LOAD&AREA=W&PageDir=0&doR=1&tx=1563630471816&bypassPage=1&test=1&_=1563630471816
Request Method: GET
Status Code: 200 OK
Remote Address: 34.236.53.129:443
Referrer Policy: no-referrer-when-downgrade

Response Headers
Access-Control-Allow-Headers: content-type Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE
Access-Control-Allow-Origin: * Allow: POST, GET, OPTIONS, PUT, DELETE
Connection: keep-alive Content-Encoding: gzip Content-Length: 1179
Content-Type: text/html;charset=UTF-8 Date: Sat, 20 Jul 2019 13:47:52 GMT
Server: Realforeclose/1a Vary: Accept-Encoding

Request Headers
Provisional headers are shown
Accept: application/json, text/javascript, */*; q=0.01
Referer: https://brevard.realforeclose.com/index.cfm?zaction=AUCTION&Zmethod=PREVIEW&AUCTIONDATE=07/25/2019
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36
X-Requested-With: XMLHttpRequest

Query String Parameters
zaction=AUCTION&Zmethod=UPDATE&FNC=LOAD&AREA=W&PageDir=0&doR=1&tx=1563630471816&bypassPage=1&test=1&_=1563630471816


text:
Q: Deserialize XML to Nested Objects in symfony 2.8 Following xml format
<fraud_report_responses per_page="100" page="2" total_count="19" pages_count="7">
<fraud_report_response>
<arn>74537604221431003881865</arn>
<transaction_date>2014-01-24</transaction_date>
<fraud_type_code>6</fraud_type_code>
<amount>14625</amount>
<currency>USD</currency>
<card_number>554960******5069</card_number>
<card_brand>master</card_brand>
<customer_email>emil@e-comprocessing.net</customer_email>
<customer_phone>3598851248512</customer_phone>
<transaction_type>sale3d</transaction_type>
<original_transaction_unique_id>f9634ec5e7dbe6ca3871974accb875cd</original_transaction_unique_id>
<original_merchant_transaction_id>f9634ec5e7d5cd</original_merchant_transaction_id>
</fraud_report_response>
<fraud_report_response>
<arn>74537604221431003881862</arn>
<transaction_date>2014-01-27</transaction_date>
<fraud_type_code>4</fraud_type_code>
<amount>3456</amount>
<currency>EUR</currency>
<card_number>454360******5008</card_number>
<card_brand>visa</card_brand>
<customer_email>ivan@e-comprocessing.net</customer_email>
<customer_phone>3598851248123</customer_phone>
<transaction_type>sale</transaction_type>
<original_transaction_unique_id>67fbebc172b743a164a3f3af3d010457</original_transaction_unique_id>
<original_merchant_transaction_id>67fbebc172b743a164a3f3af3d010457</original_merchant_transaction_id>
</fraud_report_response>
</fraud_report_responses>

I was created entity class for store data in doctrine entity
Below code of entity class
class Genesisapicall
{

/**
    * @var int
 */
private $id;

/**
 * @var string
 */
private $arn;

/**
 * @var string
 */
private $typeCode;

/**
 * @var string
 */
private $currency;

/**
 * @var int
 */
private $amount;

/**
 * @var string
 */
private $cardBrand;

/**
 * @var string
 */
private $customerEmail;

/**
 * @var string
 */
private $customerPhone;

/**
 * @var \DateTime
 */
private $transactionDate;

/**
 * @var string
 */
private $transactionType;

/**
 * @var string
 */
private $referenceId;

/**
 * Get id
 *
 * @return int
 */
public function getId()
{
    return $this->id;
}

/**
 * Set arn
 *
 * @param string $arn
 *
 * @return Genesisapicall
 */
public function setArn($arn)
{
    $this->arn = $arn;

    return $this;
}

/**
 * Get arn
 *
 * @return string
 */
public function getArn()
{
    return $this->arn;
}

/**
 * Set typeCode
 *
 * @param string $typeCode
 *
 * @return Genesisapicall
 */
public function setTypeCode($typeCode)
{
    $this->typeCode = $typeCode;

    return $this;
}

/**
 * Get typeCode
 *
 * @return string
 */
public function getTypeCode()
{
    return $this->typeCode;
}

/**
 * Set currency
 *
 * @param string $currency
 *
 * @return Genesisapicall
 */
public function setCurrency($currency)
{
    $this->currency = $currency;

    return $this;
}

/**
 * Get currency
 *
 * @return string
 */
public function getCurrency()
{
    return $this->currency;
}

/**
 * Set amount
 *
 * @param integer $amount
 *
 * @return Genesisapicall
 */
public function setAmount($amount)
{
    $this->amount = $amount;

    return $this;
}

/**
 * Get amount
 *
 * @return int
 */
public function getAmount()
{
    return $this->amount;
}

/**
 * Set cardBrand
 *
 * @param string $cardBrand
 *
 * @return Genesisapicall
 */
public function setCardBrand($cardBrand)
{
    $this->cardBrand = $cardBrand;

    return $this;
}

/**
 * Get cardBrand
 *
 * @return string
 */
public function getCardBrand()
{
    return $this->cardBrand;
}

/**
 * Set customerEmail
 *
 * @param string $customerEmail
 *
 * @return Genesisapicall
 */
public function setCustomerEmail($customerEmail)
{
    $this->customerEmail = $customerEmail;

    return $this;
}

/**
 * Get customerEmail
 *
 * @return string
 */
public function getCustomerEmail()
{
    return $this->customerEmail;
}

/**
 * Set customerPhone
 *
 * @param string $customerPhone
 *
 * @return Genesisapicall
 */
public function setCustomerPhone($customerPhone)
{
    $this->customerPhone = $customerPhone;

    return $this;
}

/**
 * Get customerPhone
 *
 * @return string
 */
public function getCustomerPhone()
{
    return $this->customerPhone;
}

/**
 * Set transactionDate
 *
 * @param \DateTime $transactionDate
 *
 * @return Genesisapicall
 */
public function setTransactionDate($transactionDate)
{
    $this->transactionDate = $transactionDate;

    return $this;
}

/**
 * Get transactionDate
 *
 * @return \DateTime
 */
public function getTransactionDate()
{
    return $this->transactionDate;
}

/**
 * Set transactionType
 *
 * @param string $transactionType
 *
 * @return Genesisapicall
 */
public function setTransactionType($transactionType)
{
    $this->transactionType = $transactionType;

    return $this;
}

/**
 * Get transactionType
 *
 * @return string
 */
public function getTransactionType()
{
    return $this->transactionType;
}

/**
 * Set referenceId
 *
 * @param string $referenceId
 *
 * @return Genesisapicall
 */
public function setReferenceId($referenceId)
{
    $this->referenceId = $referenceId;

    return $this;
}
/**
 * Get referenceId
 *
 * @return string
 */
public function getReferenceId()
{
    return $this->referenceId;

 }
}

When I try to deserialize it, I get the following result:
$encoders = array(new XmlEncoder(), new JsonEncoder());
        $normalizers = array(new ObjectNormalizer());
        $serializer = new Serializer($normalizers, $encoders);
        $person = $serializer->deserialize($data,'GenesisapicallBundle\Entity\Genesisapicall','xml');
        var_dump($person);

Response
object(GenesisapicallBundle\Entity\Genesisapicall)#221 (11) { ["id":"GenesisapicallBundle\Entity\Genesisapicall":private]=> NULL
 ["arn":"GenesisapicallBundle\Entity\Genesisapicall":private]=> NULL
 ["typeCode":"GenesisapicallBundle\Entity\Genesisapicall":private]=> NULL
["currency":"GenesisapicallBundle\Entity\Genesisapicall":private]=> NULL
["amount":"GenesisapicallBundle\Entity\Genesisapicall":private]=> NULL
 ["cardBrand":"GenesisapicallBundle\Entity\Genesisapicall":private]=> NULL
 ["customerEmail":"GenesisapicallBundle\Entity\Genesisapicall":private]=> NULL
 ["customerPhone":"GenesisapicallBundle\Entity\Genesisapicall":private]=> NULL
 ["transactionDate":"GenesisapicallBundle\Entity\Genesisapicall":private]=> NULL
 ["transactionType":"GenesisapicallBundle\Entity\Genesisapicall":private]=> NULL
["referenceId":"GenesisapicallBundle\Entity\Genesisapicall":private]=> NULL
}

So there are 1 issues:
1) How can deserialize xml data with multiple attrubute or inline XML list?
Any ideas how to make it work without manual deserialization in a handler?


text:
Q: Combining 12 MS Access queries with different "where" criteria into one query I have twelve different SELECT queries, each with different WHERE criteria. Each query has the same ID code (APINumber), and I'd like to create an output of:
APINumber | Data from Query 1 | Data from Query 2 | etc
I currently have each query linked to excel, and after refreshing each query in excel, I have a separate tab of vlookups that combines all of the data. My issue is that the queries take a very long time to refresh, so going through excel to then be combined is very inefficient. Ultimately, my goal is to link to a Tableau file for visualizations.
I've found message boards of how to link 2 queries, but I've overwhelmed with trying to link all 12. Some of the data fields will be blank for a given ID code, but I still want the ID code to show.
https://dba.stackexchange.com/questions/63506/merge-two-select-queries-with-different-where-clauses
Here are my queries:
Total Water
SELECT dbo_RegistryUpload.APINumber, Avg(dbo_RegistryUpload.TotalWater) AS AvgOfTotalWater
FROM (dbo_RegistryUpload AS dbo_RegistryUpload INNER JOIN (dbo_RegistryUploadPurpose INNER JOIN dbo_RegistryUploadIngredients ON dbo_RegistryUploadPurpose.pKey = dbo_RegistryUploadIngredients.pKeyPurpose) ON dbo_RegistryUpload.pKey = dbo_RegistryUploadPurpose.pKeyRegistryUpload) INNER JOIN [API Count] ON dbo_RegistryUpload.APINumber = [API Count].APINumber
WHERE ((([API Count].Howmany)=1))
GROUP BY dbo_RegistryUpload.APINumber
HAVING (((dbo_RegistryUpload.APINumber) Like "42*" Or (dbo_RegistryUpload.APINumber) Like "42*" Or (dbo_RegistryUpload.APINumber) Like "42*" Or (dbo_RegistryUpload.APINumber) Like "42*" Or (dbo_RegistryUpload.APINumber) Like "42*"));

Water %
SELECT dbo_RegistryUpload_1.APINumber, Sum(dbo_RegistryUploadIngredients.PercentHFJob) AS WaterPerc
FROM (dbo_RegistryUpload AS dbo_RegistryUpload_1 INNER JOIN (dbo_RegistryUploadPurpose INNER JOIN dbo_RegistryUploadIngredients ON dbo_RegistryUploadPurpose.pKey = dbo_RegistryUploadIngredients.pKeyPurpose) ON dbo_RegistryUpload_1.pKey = dbo_RegistryUploadPurpose.pKeyRegistryUpload) INNER JOIN [API Count] ON dbo_RegistryUpload_1.APINumber = [API Count].APINumber
WHERE (((dbo_RegistryUploadIngredients.IngredientName) Like "*base*") AND (([API Count].Howmany)=1)) OR (((dbo_RegistryUploadIngredients.IngredientName) Like "*Carrier*") AND (([API Count].Howmany)=1)) OR ((([API Count].Howmany)=1) AND ((dbo_RegistryUploadPurpose.Purpose) Like "*base*")) OR ((([API Count].Howmany)=1) AND ((dbo_RegistryUploadPurpose.Purpose) Like "*carrier*")) OR ((([API Count].Howmany)=1) AND ((dbo_RegistryUploadPurpose.Purpose) Like "*water*"))
GROUP BY dbo_RegistryUpload_1.APINumber
HAVING (((dbo_RegistryUpload_1.APINumber) Like "42*" Or (dbo_RegistryUpload_1.APINumber) Like "42*" Or (dbo_RegistryUpload_1.APINumber) Like "42*" Or (dbo_RegistryUpload_1.APINumber) Like "42*" Or (dbo_RegistryUpload_1.APINumber) Like "42*"));

Proppant
SELECT dbo_RegistryUpload.APINumber, Sum(dbo_RegistryUploadIngredients.PercentHFJob) AS Prop
FROM [API Count] INNER JOIN ((dbo_RegistryUpload INNER JOIN dbo_RegistryUploadPurpose ON dbo_RegistryUpload.pKey = dbo_RegistryUploadPurpose.pKeyRegistryUpload) INNER JOIN dbo_RegistryUploadIngredients ON dbo_RegistryUploadPurpose.pKey = dbo_RegistryUploadIngredients.pKeyPurpose) ON [API Count].APINumber = dbo_RegistryUpload.APINumber
WHERE (((dbo_RegistryUploadPurpose.Purpose) Like "*prop*" And (dbo_RegistryUploadPurpose.Purpose) Not Like "*GEL*") AND (([API Count].Howmany)=1)) OR (((dbo_RegistryUploadPurpose.Purpose) Like "*sand*" And (dbo_RegistryUploadPurpose.Purpose) Not Like "*gel*") AND (([API Count].Howmany)=1))
GROUP BY dbo_RegistryUpload.APINumber
HAVING (((dbo_RegistryUpload.APINumber) Like "42*" Or (dbo_RegistryUpload.APINumber) Like "42*" Or (dbo_RegistryUpload.APINumber)="42"));

100 Mesh Proppant
SELECT dbo_RegistryUpload.APINumber, Sum(dbo_RegistryUploadIngredients.PercentHFJob) AS 100mesh
FROM [API Count] INNER JOIN ((dbo_RegistryUpload INNER JOIN dbo_RegistryUploadPurpose ON dbo_RegistryUpload.pKey = dbo_RegistryUploadPurpose.pKeyRegistryUpload) INNER JOIN dbo_RegistryUploadIngredients ON dbo_RegistryUploadPurpose.pKey = dbo_RegistryUploadIngredients.pKeyPurpose) ON [API Count].APINumber = dbo_RegistryUpload.APINumber
WHERE (((dbo_RegistryUploadPurpose.TradeName) Like "*100 mesh*") AND (([API Count].Howmany)=1))
GROUP BY dbo_RegistryUpload.APINumber
HAVING (((dbo_RegistryUpload.APINumber) Like "42*"));

20/40 Proppant
SELECT dbo_RegistryUpload.APINumber, Sum(dbo_RegistryUploadIngredients.PercentHFJob) AS 2040
FROM [API Count] INNER JOIN ((dbo_RegistryUpload INNER JOIN dbo_RegistryUploadPurpose ON dbo_RegistryUpload.pKey = dbo_RegistryUploadPurpose.pKeyRegistryUpload) INNER JOIN dbo_RegistryUploadIngredients ON dbo_RegistryUploadPurpose.pKey = dbo_RegistryUploadIngredients.pKeyPurpose) ON [API Count].APINumber = dbo_RegistryUpload.APINumber
WHERE (((dbo_RegistryUploadPurpose.TradeName) Like "*20/40*") AND (([API Count].Howmany)=1)) OR (((dbo_RegistryUploadPurpose.TradeName) Like "*20-40*") AND (([API Count].Howmany)=1))
GROUP BY dbo_RegistryUpload.APINumber
HAVING (((dbo_RegistryUpload.APINumber) Like "42*" Or (dbo_RegistryUpload.APINumber) Like "42*"));

30/50 Proppant
SELECT dbo_RegistryUpload.APINumber, Sum(dbo_RegistryUploadIngredients.PercentHFJob) AS 3050
FROM [API Count] INNER JOIN ((dbo_RegistryUpload INNER JOIN dbo_RegistryUploadPurpose ON dbo_RegistryUpload.pKey = dbo_RegistryUploadPurpose.pKeyRegistryUpload) INNER JOIN dbo_RegistryUploadIngredients ON dbo_RegistryUploadPurpose.pKey = dbo_RegistryUploadIngredients.pKeyPurpose) ON [API Count].APINumber = dbo_RegistryUpload.APINumber
WHERE (((dbo_RegistryUploadPurpose.TradeName) Like "*30/50*") AND (([API Count].Howmany)=1)) OR (((dbo_RegistryUploadPurpose.TradeName) Like "*30-50*") AND (([API Count].Howmany)=1))
GROUP BY dbo_RegistryUpload.APINumber
HAVING (((dbo_RegistryUpload.APINumber) Like "42*" Or (dbo_RegistryUpload.APINumber) Like "42*"));

40/70 Proppant
SELECT dbo_RegistryUpload.APINumber, Sum(dbo_RegistryUploadIngredients.PercentHFJob) AS 4070
FROM [API Count] INNER JOIN ((dbo_RegistryUpload INNER JOIN dbo_RegistryUploadPurpose ON dbo_RegistryUpload.pKey = dbo_RegistryUploadPurpose.pKeyRegistryUpload) INNER JOIN dbo_RegistryUploadIngredients ON dbo_RegistryUploadPurpose.pKey = dbo_RegistryUploadIngredients.pKeyPurpose) ON [API Count].APINumber = dbo_RegistryUpload.APINumber
WHERE (((dbo_RegistryUploadPurpose.TradeName) Like "*40/70*") AND (([API Count].Howmany)=1)) OR (((dbo_RegistryUploadPurpose.TradeName) Like "*40-70*") AND (([API Count].Howmany)=1))
GROUP BY dbo_RegistryUpload.APINumber
HAVING (((dbo_RegistryUpload.APINumber) Like "42*" Or (dbo_RegistryUpload.APINumber) Like "42*"));

Breaker %
SELECT dbo_RegistryUpload.APINumber, Sum(dbo_RegistryUploadIngredients.PercentHFJob) AS BreakerPerc
FROM [API Count] INNER JOIN ((dbo_RegistryUpload INNER JOIN dbo_RegistryUploadPurpose ON dbo_RegistryUpload.pKey = dbo_RegistryUploadPurpose.pKeyRegistryUpload) INNER JOIN dbo_RegistryUploadIngredients ON dbo_RegistryUploadPurpose.pKey = dbo_RegistryUploadIngredients.pKeyPurpose) ON [API Count].APINumber = dbo_RegistryUpload.APINumber
WHERE ((([API Count].Howmany)=1) AND ((dbo_RegistryUploadPurpose.Purpose) Like "*breaker*"))
GROUP BY dbo_RegistryUpload.APINumber
HAVING (((dbo_RegistryUpload.APINumber) Like "42*" Or (dbo_RegistryUpload.APINumber) Like "42*"));

CrossLink Mass %
SELECT dbo_RegistryUpload.APINumber, Sum(dbo_RegistryUploadIngredients.PercentHFJob) AS Crosslink
FROM ((dbo_RegistryUpload INNER JOIN dbo_RegistryUploadPurpose ON dbo_RegistryUpload.pKey = dbo_RegistryUploadPurpose.pKeyRegistryUpload) INNER JOIN dbo_RegistryUploadIngredients ON dbo_RegistryUploadPurpose.pKey = dbo_RegistryUploadIngredients.pKeyPurpose) INNER JOIN [API Count] ON dbo_RegistryUpload.APINumber = [API Count].APINumber
WHERE (((dbo_RegistryUploadPurpose.Purpose) Like "cross*" And (dbo_RegistryUploadPurpose.Purpose) Not Like "*breaker*") AND (([API Count].Howmany)=1))
GROUP BY dbo_RegistryUpload.APINumber
HAVING (((dbo_RegistryUpload.APINumber) Like "42*" Or (dbo_RegistryUpload.APINumber) Like "42*" Or (dbo_RegistryUpload.APINumber) Like "42*"));

Gel Mass
SELECT dbo_RegistryUpload.APINumber, Sum(dbo_RegistryUploadIngredients.PercentHFJob) AS GelMass
FROM ((dbo_RegistryUpload INNER JOIN dbo_RegistryUploadPurpose ON dbo_RegistryUpload.pKey = dbo_RegistryUploadPurpose.pKeyRegistryUpload) INNER JOIN dbo_RegistryUploadIngredients ON dbo_RegistryUploadPurpose.pKey = dbo_RegistryUploadIngredients.pKeyPurpose) INNER JOIN [API Count] ON dbo_RegistryUpload.APINumber = [API Count].APINumber
WHERE (((dbo_RegistryUploadPurpose.Purpose) Like "gel*" And (dbo_RegistryUploadPurpose.Purpose) Not Like "*breaker*") AND (([API Count].Howmany)=1)) OR (((dbo_RegistryUploadPurpose.Purpose) Like "*guar*" And (dbo_RegistryUploadPurpose.Purpose) Not Like "*breaker*") AND (([API Count].Howmany)=1))
GROUP BY dbo_RegistryUpload.APINumber
HAVING (((dbo_RegistryUpload.APINumber) Like "42*" Or (dbo_RegistryUpload.APINumber) Like "42*"));

Resin
SELECT dbo_RegistryUpload.APINumber, Sum(dbo_RegistryUploadIngredients.PercentHFJob) AS Resin
FROM [API Count] INNER JOIN ((dbo_RegistryUpload INNER JOIN dbo_RegistryUploadPurpose ON dbo_RegistryUpload.pKey = dbo_RegistryUploadPurpose.pKeyRegistryUpload) INNER JOIN dbo_RegistryUploadIngredients ON dbo_RegistryUploadPurpose.pKey = dbo_RegistryUploadIngredients.pKeyPurpose) ON [API Count].APINumber = dbo_RegistryUpload.APINumber
WHERE (((dbo_RegistryUploadPurpose.Purpose) Like "*resin*") AND (([API Count].Howmany)=1)) OR ((([API Count].Howmany)=1) AND ((dbo_RegistryUploadPurpose.TradeName) Like "*RCS*"))
GROUP BY dbo_RegistryUpload.APINumber
HAVING (((dbo_RegistryUpload.APINumber) Like "42*"));

A: Since you already have all the queries written, why not use them as subqueries and join them together?
select dbo_RegistryUpload.APINumber, AvgOfTotalWater, WaterPerc
from (dbo_RegistryUpload as dbo_RegistryUpload
left join (SELECT dbo_RegistryUpload.APINumber,

    Avg(dbo_RegistryUpload.TotalWater) AS AvgOfTotalWater
FROM (dbo_RegistryUpload AS dbo_RegistryUpload INNER JOIN (dbo_RegistryUploadPurpose INNER JOIN dbo_RegistryUploadIngredients ON dbo_RegistryUploadPurpose.pKey = dbo_RegistryUploadIngredients.pKeyPurpose) ON dbo_RegistryUpload.pKey = dbo_RegistryUploadPurpose.pKeyRegistryUpload) INNER JOIN [API Count] ON dbo_RegistryUpload.APINumber = [API Count].APINumber
WHERE ((([API Count].Howmany)=1))
GROUP BY dbo_RegistryUpload.APINumber
HAVING (((dbo_RegistryUpload.APINumber) Like "42*" Or (dbo_RegistryUpload.APINumber) Like "42*" Or (dbo_RegistryUpload.APINumber) Like "42*" Or (dbo_RegistryUpload.APINumber) Like "42*" Or (dbo_RegistryUpload.APINumber) Like "42*"))
) as atw on atw.APINumber = dbo_RegistryUpload.APINumber)

left join

(SELECT dbo_RegistryUpload_1.APINumber, Sum(dbo_RegistryUploadIngredients.PercentHFJob) AS WaterPerc
FROM (dbo_RegistryUpload AS dbo_RegistryUpload_1 INNER JOIN (dbo_RegistryUploadPurpose INNER JOIN dbo_RegistryUploadIngredients ON dbo_RegistryUploadPurpose.pKey = dbo_RegistryUploadIngredients.pKeyPurpose) ON dbo_RegistryUpload_1.pKey = dbo_RegistryUploadPurpose.pKeyRegistryUpload) INNER JOIN [API Count] ON dbo_RegistryUpload_1.APINumber = [API Count].APINumber
WHERE (((dbo_RegistryUploadIngredients.IngredientName) Like "*base*") AND (([API Count].Howmany)=1)) OR (((dbo_RegistryUploadIngredients.IngredientName) Like "*Carrier*") AND (([API Count].Howmany)=1)) OR ((([API Count].Howmany)=1) AND ((dbo_RegistryUploadPurpose.Purpose) Like "*base*")) OR ((([API Count].Howmany)=1) AND ((dbo_RegistryUploadPurpose.Purpose) Like "*carrier*")) OR ((([API Count].Howmany)=1) AND ((dbo_RegistryUploadPurpose.Purpose) Like "*water*"))
GROUP BY dbo_RegistryUpload_1.APINumber
HAVING (((dbo_RegistryUpload_1.APINumber) Like "42*" Or (dbo_RegistryUpload_1.APINumber) Like "42*" Or (dbo_RegistryUpload_1.APINumber) Like "42*" Or (dbo_RegistryUpload_1.APINumber) Like "42*" Or (dbo_RegistryUpload_1.APINumber) Like "42*"))
) as wp on wp.APINumber = dbo_RegistryUpload.APINumber

Hopefully that gets the point across, just do the same thing for the rest of your queries.


text:
Q: How get HTML without remove child (jQuery) There are some problems with changing the js-object.
It has the html structure.
Example:
myObj.html ='la-la-la
            la-la-la';

And structure due to user actions is changing( add,delete elements ):
$(myObj.html).find('.second').remove()

Theoretically it has to help. But I work with just string (it is not real DOM element).
myObj.html don't save changing, and .remove() return deleted element.
And I want that myObj.html changed too:
myObj.html ='la-la-la;

How to be in this situation? (RegExp is not better idea)

A: If you call .html(myObj.html) on a temporary element, you can do whatever you want, then read it back afterwards:

var myObj = {};

myObj.html ='la-la-lala-la-la';

$tmp = $("
").html(myObj.html);
$tmp.find(".second").remove();
myObj.html = $tmp.html();

console.log(myObj);

A: May be you can try the following by using createElement() and delete the element afterwords:

let myObj ='la-la-lala-la-la';
let myObjHTMLDiv = document.createElement('div');
myObjHTMLDiv.innerHTML = myObj;
$(myObjHTMLDiv).find('.second').remove();
myObj = myObjHTMLDiv.innerHTML;
delete myObjHTMLDiv;
console.log(myObj);


text:
Q: How to edit the default icon of Add Media button? I am trying to replace the default Add Media icon in my Wordpress site. I searched for the same on the web and got this:
How to replace default icon on "Add Media" button?
This seems to work for the OP, and ofcourse should've worked for others too. But, I am getting confused as the answer contains words like Child Theme and all. I could understand the first part of the answer, but I lost the track when the answer talked about this:
wp_enqueue_style('my-css', get_stylesheet_directory_uri().'/css/my-admin.css'

From where did this part of the url came: '/css/my-admin.css. I searched in my database at the backend but couldn't find this particular file anywhere. I know this might be a silly thing to ask, but this is it. Can someone help in this regard?

A: /css/my-admin.css is located in the current theme directory as specified from the return value of get_stylesheet_directory_uri() prepended to this path.

A: this function get_stylesheet_directory_uri() return  URI to current theme's stylesheet directory and /css/my-admin.css is path to their file which you can create in your theme directory
example :
<link rel="stylesheet" type="text/css" id="my-css" href="https://yourdomain.com/wp-content/themes/yourtheme/css/my-admin.css">

this is the output of the code in your source


text:
Q: How to create a fixed size generic buffer in java? If I want to create a fixed size buffer of ints, I would use new int[size]. Now, suppose I want to create a buffer over a generic type.
One possibly solution is:
List<T> buffer = new ArrayList<T>(size);
for (int i = 0; i < size; ++i)
  buffer.add(null);

// now simply access the buffer via buffer.get() and buffer.set()

Is there something better I should use? A sample use-case would be to implement a queue. Note, this is not a real life usecase, but rather an interview question.

A: You can do something like this
private final T[] items;

public RingBuffer(Class<T> clazz, int capacity) {
    this.items = (T[]) Array.newInstance(clazz, capacity);
}

You have to cast to T[] but it really is a T[] as opposed to Object[]

A: Due to a broken generics system in Java, you cannot use a parametric Array definition, but due to type erasure, you know alternatively you can have an array of Objects assigned to a parametric Array declaration, and then it can get around the VM's type system at run-time.
After this, any operation with this array will have to satisfy type T and the compiler will make sure that happens at compile-time. You just need to get around the definition.
class ArrayList<V> {
  private V[] backingArray;
  public ArrayList() {
    backingArray = (V[]) new Object[DEFAULT_SIZE];
  }
}

Java theory and practice: Generics gotchas

A: Just wrap a generic collection inside a custom class where you can control the fixed size collection. For example:
class Queue<T> {
   private ArrayList<T> q;
   private int size;

   public Queue(int size) {
      this.size = size;
      this.q = new ArrayList<T>(size);
   }

   public int size() {
      return size;
   }

   // ...

   public T get(int index) {
      if (index > q.size()) {
          return null;
      }
      // ... or whatever

      return q.get(index);
   }

}

** EDIT **
Or more specifically, create your own Collection-compatible generic class. For example :
public class FixedQueue<E> extends AbstractList<E> {

   private Object[] queue;

   public FixedQueue(int size) {
      queue = new Object[size];
   }

   @Override
   public E set(int index, E element) {
      Object old = queue[index];
      queue[index] = element;
      modCount++;
      return (E) old;
   }

   @Override
   public E get(int index) {
      return (E) queue[index];
   }

   @Override
   public int size() {
      return queue.length;
   }

   @Override
   public E remove(int index) {
      Object old = queue[index];
      System.arraycopy(queue, index+1, queue, index, queue.length - index - 1);
      modCount++;
      return (E) old;
   }
}

This untested class will allow get and set and remove operations, but not add, etc. But you may implement it for your own specifications if you want. Implementing a class instead of using a fixed size array will allow you to, if you need to add a functionality (for example ensureCapacity) to implement it without touching any other source.
** UPDATE **
I just saw your edit, basically, you're starting off right. Just use an array of Object that you cast to your generic type when you get an element. See Java's ArrayList implementation, for example.

A: java.util.ArrayDeque (or java.util.concurrent.ArrayBlockingQueue) is what you are looking for. Yet, I'd advise you to implement your own cyclic buffer/queue. It's a very good exercise.
As for caching int[] I'd advise you against doing so.
Important note: if you want to use some caching mechanism do not do like tomcat and use ConcurrentLinkedQueue. Caches SHOULD use stacks not queues, both ArrayDeque and ArrayBlockingQueue are good for stacks.


text:
Q: Vue.js - how to get specified fields from object via axios reponse data This is my JSON object
{
    "id": 2,
    "dani": 5,
    "asset": {
        "id": 2,
        "code": "1",
        "name": "asset1",
        "descr": null,
        "version": "2020-09-01T15:39:53.821+0000",
        "model": {
            "id": 3,
            "code": "4",
            "name": "ZXc43V",
            "descr": "",
            "version": "2020-09-01T15:22:36.953+0000",
            "year": "2020-03-26"
        },
        "location": {
            "id": 1,
            "code": "4",
            "name": "Lokacija 5",
            "descr": "",
            "version": "2020-06-03T12:22:55.693+0000",
            "adress": "Obilicev venac 24",
            "dateFrom": "2020-06-03",
            "dateTo": "2022-05-07",
            "active": false
        }
    }
}

Let's say I have declared array "assets[]".
What I want to do with it is that when I use
axios.get('url').then(response => this.array = response.data

I want to extract from my object (which response.data provides) name of asset (asset.name) and put only name of assets in my array "assets[]", so it contains only asset names from JSON objects, and nothing else.
Thanks

A: You could use map function as follows :
this.assets=response.data.map(item=>({name:item.asset.name}));

or if you don't need the field :
this.assets=response.data.map(item=>item.asset.name);

A: you can iterate the object and push into the array.
axios.get('url').then((response) => {
  response.data.forEach((item) => {
     this.assets.push(item.asset.name)
  })
})


text:
Q: Procedure sp_Get-- has no parameters and arguments were supplied I am getting the error "Procedure sp_Get--  has no parameters and arguments were supplied".
I am calling a simple stored-proc from a CF component.
The Stored proc is as follows
GO ALTER PROCEDURE [dbo].[sp_GetTest]
  @TestId INT AS BEGIN
  SET NOCOUNT ON;

  SELECT T.TestId
        ,T.TestDetail
        ,T.isPassedTest
    FROM Test T
   WHERE T.TestId = @TestId
ORDER BY T.TestDetail

END

I am calling it in CF8 component/method in the following manner:-
<cffunction name="GetTest" returntype="query" access="public" output="false">
  <cfargument name="Test" type="......Test.Test" required="true">
  <cfstoredproc procedure="sp_GetTest" datasource="#variables.datasource#">
    <cfprocparam cfsqltype="CF_SQL_INTEGER" value="#arguments.Test.GetTestId()#">
    <cfprocresult name="theTest" resultset="1">
  </cfstoredproc>

  <cfscript>return theTest;</cfscript>
</cffunction>

Kindly help me in debugging the error!
Thanks

A: Is it possible you have two versions of the stored procedure created, one with dbo as owner and with this parameter defined, and the other with the user via which you connect to the database as owner and with this parameter not defined? Can you try using "dbo.sp_GetTest" as the procedure name in CF?


text:
Q: How to check if an item is in a list (column) and select another column item value based on that in Excel? I have an Excel sheet with:

How can I create the URL (as shown in F4) given the input in E4, from the table in (B3:C7)?

SOLUTION:
Thanks to the accepted answer, I managed to get this working with:
=HYPERLINK(INDEX(B4:C7,MATCH(E4,B4:B7,0),2)&"pathTo/"&E4, E4)

where I also added a hyperlink to the created URL.

A: You can use a INDEX/MATCH-Formula:
=INDEX(tblData[Base],MATCH(D3,tblData[Name],0)) & "pathTo" & D3


text:
Q: JavaScript: My switch statement always defaults to the first case I'm making a blackjack game that helps with counting cards in javascript. One of the functions is to update the count. To do that I put a switch statement that will increment the count up 1 if the card is a two through six, and increment it down 1 if the card is a jack, king, queen, or ace. I have looked over my code multiple times and cannot figure out what is wrong. No matter what the variable dc or ac equals it will always default to the first case in the switch statement. I even tried setting  ac = "three"  and it still defaulted to the first case.  Can someone please figure out what is wrong? Thanks!
Just the update count function:

//Update the count
function updateCount(){
  var dc;
  var pc;
  var dealerCount = 0;
  var playerCount = 0;

  for(var d = 0; d < dealerCards.length; d += 1){

    dc = dealerCards[d].name; //String
    console.log("DC: " + dc);
    switch(dc){
      case "two":
        dealerCount += 1;
        console.log("d2");
        break;
      case "three":
        dealerCount += 1;
        console.log("d3");
        break;
      case "four":
        dealerCount += 1;
        console.log("d4");
        break;
      case "five":
        dealerCount += 1;
        console.log("d5");
        break;
      case "six":
        dealerCount += 1;
        console.log("d6");
        break;
      case "jack":
        dealerCount -= 1;
        console.log("dj");
        break;
      case "queen":
        dealerCount -= 1;
        console.log("dq");
        break;
      case "king":
        dealerCount -= 1;
        console.log("dk");
        break;
      case "ace":
        dealerCount -= 1;
        console.log("da");
        break;
      default:
        dealerCount += 0;

    }
  }

  for(var p = 0; p < playerCards.length; p += 1){
    pc = playerCards[p].name; //String
    console.log("PC: " + pc);
    switch(pc){
      case "two":
        playerCount += 1;
        console.log("p2");
        break;
      case "three":
        playerCount += 1;
        console.log("p3");
        break;
      case "four":
        playerCount += 1;
        console.log("p4");
        break;
      case "five":
        playerCount += 1;
        console.log("p5");
        break;
      case "six":
        playerCount += 1;
        console.log("p6");
        break;
      case "jack":
        playerCount -= 1;
        console.log("pj");
        break;
      case "queen":
        playerCount -= 1;
        console.log("pq");
        break;
      case "king":
        playerCount -= 1;
        console.log("pk");
        break;
      case "ace":
        playerCount -= 1;
        console.log("pa");
        break;
      default:
        playerCount += 0;

    }
  }
  //count = Count + Count
  //setText("countLbl", "Count: " + (playerCount + dealerCount));
}
var dealerCards = [];

Console output:

DC = ace
da
DC = nine
d2
PC = three
p2
PC = three
p2

My whole program (NOTE: it will not run in stack overflow due to the fact that it was written in code.org's app lab which I am forced to use for my class)

/* TODO:
 * 1) Make play again button
 * 2) Make reset button
 * 3) Make count work
 * 4) Make hide/show count button
 * 5) Make first dealer card hidden
 * 6) Check for blackjack on first deal
 * 7) Make Ace = 1 if total is greater than 21
 * 8) Make deck re-shuffle upon reset or cards run out
*/

//var Count = 0;
var playerCards = [];
var dealerCards = new Array();
var deckArr = new Array();

//Stores the properties each card can have
var cardProp = {
  suit: ['heart', 'spade', 'club', 'diamond'],
  value: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 11],
  name: ['ace', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'jack', 'queen', 'king']
};

/*--------------------------------------------------------------------------------------------*/
console.log(playerCards.length);
populateDeck();
//console.log(deckArr.length);
//printDeck();

//deckArr = shuffleDeck(deckArr).slice(0);
printDeck();
console.log("----------------------------");

//STAND BUTTON
onEvent("standBtn", "click", function(){
  //Check player for blackjack
  if(getPlayerTotal() > 21){
    showElement("winLoseLbl");
    setText("winLoseLbl", "BUST! \n Dealer Wins!");
  } else {
    //Deal until dealer total is greater than 17
    //then check for win
    while(getDealerTotal() < 17){
      dealerHit();
    }

    //Check for dealer or player win
    if(getDealerTotal() < getPlayerTotal() || getDealerTotal() > 21){
      showElement("winLoseLbl");
      setText("winLoseLbl", "Player Wins!!");
    } else {
      showElement("winLoseLbl");
      setText("winLoseLbl", "Dealer Wins!!");
    }
  }
});

//START BUTTON
onEvent("startBtn", "click", function(){
  hideElement("startBtn");
  dealPlayerCards();
  dealDealerCards();
  updateCount();
  //TEMP Hide cards used for hit button
  hideElement("dealerCard3");
  hideElement("dealerCard4");
  hideElement("playerCard3");
  hideElement("playerCard4");

});

//DEAL BUTTON
//deal 2 cards to the player and 2 to the dealer
onEvent("dealBtn", "click", function(){
  //Deal player cards
  for(var c = 0; c < 2; c += 1){

    console.log("Deck Arr Length: " + deckArr.length);
    playerCards[c] = drawCard();
    console.log("Deck Arr Length: " + deckArr.length);
    displayCard(playerCards[c], "playerCard" + (c + 1));
    console.log(playerCards[c]);

  }
});

//HIT BUTTON

onEvent("hitBtn", "click", function(){
  //Draws a card then displays it in the first hidden card
  //slot if not already displayed, otherwise displays
  //in the second hidden card slot
  if(getProperty("playerCard3","hidden") === true){
    playerCards[2] = drawCard();
    showElement("playerCard3");
    displayCard(playerCards[2], "playerCard" + 3);
  } else if(getProperty("playerCard3", "hidden") === false && getProperty("playerCard4", "hidden") === true){
    playerCards[3] = drawCard();
    showElement("playerCard4");
    displayCard(playerCards[3], "playerCard" + 4);
  }
  updateCount();

});

/*--------------------------------------------------------------------------------------------*/

function dealerHit(){
  if(getProperty("dealerCard3","hidden") === true){
    dealerCards[2] = drawCard();
    showElement("dealerCard3");
    displayCard(dealerCards[2], "dealerCard" + 3);
  } else if(getProperty("dealerCard3", "hidden") === false && getProperty("dealerCard4", "hidden") === true){
    dealerCards[3] = drawCard();
    showElement("dealerCard4");
    displayCard(dealerCards[3], "dealerCard" + 4);
  }
}

function getDealerTotal(){
  var total = 0;
  for(var x = 0; x < dealerCards.length; x += 1){
    total += dealerCards[x].value;
  }
  return total;
}

function getPlayerTotal(){
  var total = 0;
  for(var x = 0; x < playerCards.length; x += 1){
    total += playerCards[x].value;
  }
  console.log(total);
  return total;
}

function dealPlayerCards(){
    for(var c = 0; c < 2; c += 1){

      //console.log("Deck Arr Length: " + deckArr.length);
      playerCards[c] = drawCard();
      //console.log("Deck Arr Length: " + deckArr.length);
      displayCard(playerCards[c], "playerCard" + (c + 1));
     // console.log(playerCards[c]);

  }
}

function dealDealerCards(){
    for(var c = 0; c < 2; c += 1){

      //console.log("Deck Arr Length: " + deckArr.length);
      dealerCards[c] = drawCard();
      //console.log("Deck Arr Length: " + deckArr.length);
      displayCard(dealerCards[c], "dealerCard" + (c + 1));
      //console.log(dealerCards[c]);

  }
}

//Checks the deltCards array to see if a card was delt

//Draws a random card from the deck
function drawCard(){
  var randomNum = randomNumber(0, deckArr.length - 1);
  var returnCard;
  //console.log("Random Num " + randomNum);

  returnCard = deckArr[randomNum];
  deckArr.splice(randomNum, 1);
  //printDeck();
  return returnCard;
}

//Displays the input card in the inputted position
function displayCard(card, position){
  if(card !== undefined){
    getKeyValue(card.name + "_" + card.suit, function(image){
      setProperty(position, "image", image);
    });
  } else {
    console.log("ERROR: NAME undefined");
    write("UNDEFINED");
  }
}

//Prints the deck for debugging
function printDeck(){
  for(var x = 0; x < deckArr.length; x += 1){
    console.log("#: " + x + " S: " + deckArr[x].suit + " V: " + deckArr[x].value + " N: " + deckArr[x].name);
  }
}

//Sets each index of deckArr to
//a new object with the PROPERTIES: Value, Name, Suit, Image
function populateDeck(){

  var count = 0;

  for(var s = 0; s < cardProp.suit.length; s += 1)
    for(var v = 0; v < cardProp.value.length; v += 1){
      //Create new object
      //ready to store properties in
      deckArr[count] = {};

      //Set Properties to object created above
      deckArr[count].value = cardProp.value[v];
      deckArr[count].name = cardProp.name[v];
      deckArr[count].suit = cardProp.suit[s];

      count += 1;
    }
}

function shuffleDeck(deck){
  var newDeck = new Array(deck.length);
  var randomNum = randomNumber(0, deck.length - 1);

  for(var c = deck.length - 1; c >= 0; c -= 1){
    while(newDeck[randomNum] !== undefined){ //need to fix
      randomNum = randomNumber((0, deck.length - 1));
    }
    newDeck[randomNum] = deck[c];
    randomNum = randomNumber(0, deck.length - 1);
  }
  return newDeck;

}

//Checks for a win in the player or the dealer
function checkWin(){
  for(var x = 0; x < playerCards.length; x += 1){

  }
}

//Update the count
function updateCount(){
  var dc;
  var pc;
  var dealerCount = 0;
  var playerCount = 0;

  for(var d = 0; d < dealerCards.length; d += 1){

    dc = dealerCards[d].name;
    console.log("DC: " + dc);
    switch(dc.valueOf()){
      case "two":
        dealerCount += 1;
        console.log("d2");
        break;
      case "three":
        dealerCount += 1;
        console.log("d3");
        break;
      case "four":
        dealerCount += 1;
        console.log("d4");
        break;
      case "five":
        dealerCount += 1;
        console.log("d5");
        break;
      case "six":
        dealerCount += 1;
        console.log("d6");
        break;
      case "jack":
        dealerCount -= 1;
        console.log("dj");
        break;
      case "queen":
        dealerCount -= 1;
        console.log("dq");
        break;
      case "king":
        dealerCount -= 1;
        console.log("dk");
        break;
      case "ace":
        dealerCount -= 1;
        console.log("da");
        break;
      default:
      dealerCount += 0;

    }
  }

  for(var p = 0; p < playerCards.length; p += 1){
    pc = "three";
    console.log("PC: " + pc);
    switch(pc.valueOf){
      case "two":
        playerCount += 1;
        console.log("p2");
        break;
      case "three":
        playerCount += 1;
        console.log("p3");
        break;
      case "four":
        playerCount += 1;
        console.log("p4");
        break;
      case "five":
        playerCount += 1;
        console.log("p5");
        break;
      case "six":
        playerCount += 1;
        console.log("p6");
        break;
      case "jack":
        playerCount -= 1;
        console.log("pj");
        break;
      case "queen":
        playerCount -= 1;
        console.log("pq");
        break;
      case "king":
        playerCount -= 1;
        console.log("pk");
        break;
      case "ace":
        playerCount -= 1;
        console.log("pa");
        break;
        default:
        playerCount += 0;

    }
  }
  //count = Count + Count
  setText("countLbl", "Count: " + (playerCount + dealerCount));
}

A:

dealerCards=[{name:'ace'},{name:'two'}]
playerCards=[{name:'three'},{name:'three'}]
updateCount();

//Update the count
function updateCount(){
  var dc;
  var pc;
  var dealerCount = 0;
  var playerCount = 0;

  for(var d = 0; d < dealerCards.length; d += 1){

    dc = dealerCards[d].name; //String
    console.log("DC: " + dc);
    switch(dc.valueOf()){
      case "two":
        dealerCount += 1;
        console.log("d2");
        break;
      case "three":
        dealerCount += 1;
        console.log("d3");
        break;
      case "four":
        dealerCount += 1;
        console.log("d4");
        break;
      case "five":
        dealerCount += 1;
        console.log("d5");
        break;
      case "six":
        dealerCount += 1;
        console.log("d6");
        break;
      case "jack":
        dealerCount -= 1;
        console.log("dj");
        break;
      case "queen":
        dealerCount -= 1;
        console.log("dq");
        break;
      case "king":
        dealerCount -= 1;
        console.log("dk");
        break;
      case "ace":
        dealerCount -= 1;
        console.log("da");
        break;
      default:
        dealerCount += 0;

    }
  }

  for(var p = 0; p < playerCards.length; p += 1){
    pc = playerCards[p].name; //String
    console.log("PC: " + pc);
    switch(pc.valueOf()){
      case "two":
        playerCount += 1;
        console.log("p2");
        break;
      case "three":
        playerCount += 1;
        console.log("p3");
        break;
      case "four":
        playerCount += 1;
        console.log("p4");
        break;
      case "five":
        playerCount += 1;
        console.log("p5");
        break;
      case "six":
        playerCount += 1;
        console.log("p6");
        break;
      case "jack":
        playerCount -= 1;
        console.log("pj");
        break;
      case "queen":
        playerCount -= 1;
        console.log("pq");
        break;
      case "king":
        playerCount -= 1;
        console.log("pk");
        break;
      case "ace":
        playerCount -= 1;
        console.log("pa");
        break;
      default:
        playerCount += 0;

    }
  }
  //count = Count + Count
 // setText("countLbl", "Count: " + (playerCount + dealerCount));
}


text:
Q: Declaring date in SSRS via logic Can anyone let me know how to declare a date in SSRS via some logic?
if today = Monday then start date = today - 3days
if today != (not equal to ) Monday then start date = today - 1day
This should be given in SSRS so that if I click today's date, yesterday's data should come in my report.

A: Assuming that on Sunday this should also default to Friday, you can set your parameter default to:
=IIf(WeekdayName(Weekday(Today)) = "Sunday", DateAdd("d", -2, today),
 iif(WeekdayName(Weekday(Today)) = "Monday", DateAdd("d", -3, today),
 DateAdd("d", -1, today)))

Or For SQL:
DECLARE @Date DATE = '2016-04-18'; -- Monday
SET @Date = DATEADD(DAY, CASE (DATEPART(WEEKDAY, @Date) + @@DATEFIRST) % 7
                            WHEN 1 THEN -2
                            WHEN 2 THEN -3
                            ELSE -1
                        END, DATEDIFF(DAY, 0, @Date));

SELECT  @Date;

Which gives 2016-04-15 (Friday)

A: Write an expression in SSRS to set Date
=IIF(Weekday(Today()) = 2,DateAdd(DateInterval.Day,-3, Today()),DateAdd(DateInterval.Day,-1, Today()))


text:
Q: Java - replace string: charAt VS substring I'm making a simple test, just removing a char from string. It goes like this:
String str = "kitten";
    int i = 2;
    //substring version - works good
    System.out.println(str.replaceFirst(str.substring(i, i+1), ""));
    //charAt (tried as regex):
    System.out.println(str.replaceFirst("[str.charAt(i)]", ""));
    //charAt (tried as char):
    System.out.println(str.replaceFirst("str.charAt(i)", ""));

Substring version works good, charAt works good only if i=1. What is wrong here ?

A: In your second and third snippet, you're replacing not the result of charAt() call, but "charAt(i)" string. See, it is in quotes. Also, charAt() returns char so you have to convert it to String before using.
Try this:
System.out.println(str.replaceFirst("[" + String.valueOf(str.charAt(i)) + "]", ""));
System.out.println(str.replaceFirst(String.valueOf(str.charAt(i)), ""));

A: System.out.println(str.replaceFirst("str.charAt(i)", ""));
doesn't do what you think it does.  It isn't looking for a character at i.  It is looking for the first instance that matches the regex pattern "str.charAt(i)".  Similar issues exist with your other "replaceFirst" implementation.
That means that "strAchar(i)" matches "str.charAt(i)" but when i happens to equal 2, "i" does not match "str.charAt(i)".  The stuff between the double quotes is not interpreted as Java code.

A: System.out.println(str.replaceFirst("str.charAt(i)", ""));

This line will replace the string "str,charAt(i)" by "" (if it occurs) in the string str.
You need to read more about replace() and charAt() here.

A: Using the first example, which you say "works good", I'd expect this output:

kiten
ktten
kitten

str.substring(i+1) returns 't' (i+1th or "3rd" character). You then pass this into str.replaceFirst which replaces the first occurrence of 't' with "", effectively erasing it.
What you are doing in the second one is weird: You are invoking replaceFirst with the regex "[str.charAt(i)]" which basically means "replace the first of any of the characters in the square brackets (except the round brackets I think" so you may as well be saying "match any of the characters a,A,c,h,i,r,s,t" (I alphabetised, removed duplicates and '(', ')' and '.'), and the first of these characters that matches "kitten" just so happens to be 'i' so that charachter is removed.
The final example is looking for a complete match on the string "str.charAt(i)" which is of course nowhere to be found in "kitten" you may as well be searching for "dog".
The following code is equivalent to what you have just done:
String str = "kitten";
int i = 2;
// Eliminated redundant regex replacement:
System.out.println(new StringBuffer(str.substring(0, i)).append(str.substring(i+1)));
// Search for any of the characters in "str.substring(i)"
System.out.println(str.replaceFirst("[aAchirst]", ""));
// Search for non-matching string
System.out.println(str.replaceFirst("dog", ""));


text:
Q: how to make tensorflow ops non trainable I'm building a stacked convolutional autoencoder with Tensorflow Core(no API pure Tensorflow). I want to add non trainable layers between encoder and decoder. Does anybody know how to add non trainable layers in tensorflow graph. The tensorboard graph picture is attached, the ops which appears in the blue marked box are the ones that I want to make non trainable, or one can say I do not want gradient computation on them.
TF Version: 1.15
I've tried out tf.stop_gradient() method but this method prevents the contribution of all the input before it. Tensorboard Graph

A: You have two options:

*

*When you define the weights variable with tf.Variable or tf.get_variable, pass trainable=False. This will stop the variable from being added to the trainable variables collection (accessible through tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES)), which is used by default as the list of variables to train by the optimizer.

*When you define the optimization step with minimize or compute_gradients, pass a var_list argument with the list of variables that you want to train. The optimizer will then ignore the trainable variables collection and will only affect the listed variables.


text:
Q: Globally set lintOptions in android studio gradle file How should I set Lint Option and VersionCode/Name globally for all modules
I have 3 module and 1 application module
for every module/build.gradle file I need to set as
lintOptions {
        checkReleaseBuilds false
        abortOnError false
}

But I want to set this in project level e.g in /build.gradle
I have try to paste above code in upper level gradle file but not work
allprojects {

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
}

Is there any way to set this globally ?

A: Create a new Gradle script file, e.g. android-lint.gradle with the following contents:
android {
    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
}

And then add this line below apply plugin: 'com.android.library' (or com.android.application) to every module:
apply from: '../android-lint.gradle'


text:
Q: Compare two dates in SQL Server using DateDiff I've tried to calculate the number of months using datediff in SQL Server, but when I calculate:
Select DATEDIFF(Month,'1/1/2019','12/31/2019')

It returns 11 so I increment the value by 1 to be 12. But when I calculate:
select DATEDIFF(Month,'11/19/2019','11/18/2020') + 1

it returns 13 and that's wrong.


text:
Q: Drawable resources: Failed to re-package resources, see the console for details In my AndroidManifest.xml file, I have these lines:
  <meta-data android:name="com.google.android.vr.icon"
             android:resource="@drawable/front_icon" />
  <meta-data android:name="com.google.android.vr.icon_background"
             android:resource="@drawable/back_icon" />

These lines specify icon files to use for VR app icons, and are required for Daydream. Unfortunately, the instructions on where these files go is unclear:

Note: Assets for VR should be placed inside the nodpi/ resource directory to ensure display density scaling is not applied on load.

Where in my Unity project am I supposed to place these files?
The error when I try to build is

Failed to re-package resources. See the console for details.

With this in the console (error trimmed from its massive 4000 lines down to the relevant information):

CommandInvokationFailure: Failed to re-package resources.
stderr[
AndroidManifest.xml:6: error: Error: No resource found that matches the given name
  (at 'resource' with value '@drawable/front_icon').

AndroidManifest.xml:7: error: Error: No resource found that matches the given name
  (at 'resource' with value '@drawable/back_icon').
]

The manifest file is located in the Assets/Plugins/Android directory and there is a res directory at Assets/Plugins/Android/res
I have tried:
res/drawable
res/drawable/nodpi
res/nodpi/drawable
res/nodpi

With the front_icon.png and back_icon.png inside that folder. None of these have worked.

A: You were almost correct. The folder you want is
res/drawable-nodpi

You can find the documentation on how Android specifies these folders here, which I got to by first finding this page on providing resources, searching for "nodpi", and clicking the "See Supporting Multiple Screens for more information" link, and then just having to find the right section.
There was a link under the heading "How to Support Multiple Screens" near the top of the page ("The configuration qualifiers (described in detail below)") that took me to the right section while skimming the page's content.

To use a configuration qualifier:

*

*Create a new directory in your project's res/ directory and name it using the format: <resources_name>-<qualifier>

*

*<resources_name> is the standard resource name (such as drawable or layout).

*<qualifier> is a configuration qualifier from table 1, below, specifying the screen configuration for which these resources are to be used (such as hdpi or xlarge).

*You can use more than one <qualifier> at a time—simply separate each qualifier with a dash.

*

*Save the appropriate configuration-specific resources in this new directory. The resource files must be named exactly the same as the default resource files.

  For example, xlarge is a configuration qualifier for extra-large screens. When you append this string to a resource directory name (such as layout-xlarge), it indicates to the system that these resources are to be used on devices that have an extra-large screen.

I definitely think that from a Unity developer standpoint this information does feel hidden, as it's an Android thing and the relevant page you were starting from didn't include a link back to the supporting documentation, as it assumed you were already familiar with specifying other resources (which Unity handles automatically for you).


text:
Q: running multiple loops simultaneosly I tried google, youtube, stackexchange but couldn't find a proper answer.
I am trying to design a home automation system with arduino which need to control a fan and a light. Simply activating a relay with arduino is not a thing, but here is the problem. I am controlling the speed of the fan also. So here is the basic code structure would look like.
if pin 1 is high
[
identify the zero crossing point of ac source;
add some delay to regulate the output power;
pulse it to the triac;
activate the relay related to fan;
]
if pin 2 is high
[
activate the relay related to light;
]
When the pin 1 is high the loop starts running and it stays inside the loop until the pin 1 is low. then it looks for pin 2's status[high or low].
So question is how do i control the light while the fan is in on condition. A lot of forums are suggesting timers but none with this kind of situation. If possible please give a minimum code, so i can start from that. Thank you.

A: If you want to do things with a loop, then you need to change things around so the loop repeat is governed by the repeating synchronous mains cycle. This is not the cleanest way to do things, but it should be possible to get it to work.
Note there is only one slow thing to control, the phase-shift speed control of the fan. It can accomodate many other 'fast' things, read a switch, set a relay, within the time it takes to wait for the next zero crossing.
while running:
    {
    wait_for_zero_crossing();
    read_fan_speed_control();
    compute_speed_to_delay_for_fan();
    delay_for_fan_speed_control_time();
    pulse_fan_triac();

    set_fan_relay();
    read_light_control();
    set_light_relay();
    ...
    read_other_control();
    set_other_relay();
    }

A rather better method is to use interrupts. Where you have a synchronous task like waiting for mains cycles, and an asynchronous task like reading switches, it is good to use interrupts to handle the timing critical part of the job, like this. Generally you want the interrupt service routine (ISR) to execute as quickly as possible, ie do as little work as possible. As long as a few cycles are spent outside the ISR, then your asynchronous code will run.
volatile int fan_control;      # needed so main and ISR communicate correctly

setup_ISR_to_run_every_100uS;  # for instance, 10kHz

while running:
    {
    read_fan_speed_control();
    fan_control = compute_speed_to_delay_for_fan();
    read_light_control();
    set_light_relay();
    ...
    read_other_control();
    set_other_relay();
    }

ISR:
    {
    if zero_crossing_just_happened():
        count = 0;
    else:
        count += 1;
    if count == fan_control:
        pulse_fan_triac();
    ...
    if count == other_control:
        pulse_other_triac();
    }

As you can see, it's easy to expand this ISR section to accommodate other phase shift control channels easily. I'll leave how to implement zero_crossing_just_happened() as an exercise for the reader.
These fragments are sketches, obviously much has been omitted. I've shown the volatile declaration as this is often forgotten in these situations. It forces the compiler to re-read the value from memory on every read, and not to try to optimise by using a register-based copy.
Once you've learnt to use interrupts, you can use them for things like scanning a multiplexed device, grabbing data from ADCs in the background, all sorts of things you can't do nicely with a single asynchronous loop.


text:
Q: Can we compare data type in javascript runtime Is it possible to compare the data type of object in javascript run-type by typescript class or interface.
ex:
interface IresponseObject{
 data:{name: string},
 errors:[]
}

const responseObject1 = {
   data: {name:"res"},
   error:[]
}

const responseObject2 = {
   data: {name:"res"},
   error:{}
}

function test(responseObject:IresponseObject) {
 if(responseObject instanceof IresponseObject) {
   console.log("true")
 } else {
     console.log("false");
 }

}

test(responseObject1) // true
test(responseObject2) // false


text:
Q: In bootstrap, How do I make an image a dropdown? In bootstrap, How do I make an image a dropdown?
Hi, I have created a dropdown in bootstrap, I want to put an image such that it will be the item to click so as to see the dropdown.
Here is my code below.
<!doctype html>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Getting Started with Bootstrap</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">

      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-limanAbba-navbar-collapse-1" aria-expanded="false">
    Toggle navigation

  </button>
      LimanAbba

Freelance

About

Contact
\

Liman

Code90

Coding

Separated link

One more separated link

A: If you want a pure image as the dropdown toggle, you can use an anchor (a) instead of a button to have only the image displayed.

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">

Pure Image Dropdown

Click the image to see the dropdown

Menu item 1

Menu item 2

Menu item 3

Menu item 4

A: Just put the image link on the dropdown button. See below code

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">

Dropdowns

The .dropdown with image link.

    <button class="btn btn-default dropdown-toggle" type="button" id="menu1" data-toggle="dropdown">

    </button>

Menu item 1

Menu item 2

Menu item 3

Menu item 4


text:
Q: How can I make same day message in one section? import UIKit

class MessageDetailViewController: UIViewController {

    @IBOutlet weak var tableview: UITableView!

    struct data{
        let time: String
        let message: String
        let date: String
        let type: String
    }

    struct section {
        let date: String
        var array = [data]()
    }

    let sectionArray = [
        section(date: "yesterday", array: [
            data(time: "3:30 PM", message: "I am looking for your service, can you please give more information on that.", date: "yesterday", type: "sender"),
            data(time: "3:40 PM", message: "Sure i am here to help you", date: "yesterday", type: "receiver")
            ]),
        section(date: "today", array: [data(time: "4:40 PM", message: "Ok, I wil contact you on your phone for that.", date: "today", type: "sender")])
    ]

    override func viewDidLoad() {
        super.viewDidLoad()

        self.tableview.register(UINib(nibName: "SenderCell", bundle: nil), forCellReuseIdentifier: "SenderCell")
        self.tableview.register(UINib(nibName: "ReceiverCell", bundle: nil), forCellReuseIdentifier: "ReceiverCell")
        self.tableview.register(UINib(nibName: "customHeaderViewCell", bundle: nil), forCellReuseIdentifier: "customHeaderViewCell")
    }
}

extension MessageDetailViewController: UITableViewDelegate, UITableViewDataSource{

    func numberOfSections(in tableView: UITableView) -> Int {
        return sectionArray.count
    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return sectionArray.count
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
         if sectionArray[indexPath.section].array[indexPath.row].type == "sender"
        {
            let cell = tableview.dequeueReusableCell(withIdentifier: "SenderCell", for: indexPath) as! SenderCell
            cell.setData(reciverTime: sectionArray[indexPath.section].array[indexPath.row].time, reciverMsg: sectionArray[indexPath.section].array[indexPath.row].message)
            return cell
        }
        else
        {
            let cell = tableView.dequeueReusableCell(withIdentifier: "ReceiverCell", for: indexPath) as! ReceiverCell
            cell.setData(reciverTime: sectionArray[indexPath.section].array[indexPath.row].time, reciverMsg: sectionArray[indexPath.section].array[indexPath.row].message)
            return cell
        }
    }

    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 100
    }

    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {

        let headerView = UIView()
        let headerCell = tableView.dequeueReusableCell(withIdentifier: "customHeaderViewCell") as! customHeaderViewCell
        if sectionArray[section].date == "yesterday"{
            headerCell.labelHeader.text = "yesterday"
        }
        else{
            headerCell.labelHeader.text = "today"
        }
        headerView.addSubview(headerCell)
        return headerView
    }
}

This is my message detail code.
I want to achieve these
But through these array I achieved these
what changes should I do in my code so that I can get same day message in one section
this ---
sectionArray.append(section(date: "yesterday", array: [data(time: "3:40 PM", message: "SURE i am here to help you", date: "yesterday", type: "receiver")]))
Making a new section I don't want to make new section when sure I am here o help you array comes.

A: As I've seen your code, you're using String to indicate the day of the message which is bad practice. Instead, you should use Date, which will help you group the messages by date:
let sectionArray = messages.reduce(into: [section]()) { result, element in
    if let section = result.firstIndex(where: {Calendar.current.isDate($0.date, inSameDayAs: element.date)}) {
        result[section].append(element)//append message to section
    }else {
        //create new section
    }
}

If you really need to use String, use this:
let sectionArray = messages.reduce(into: [section]()) { result, element in
    if let section = result.firstIndex(where: {$0.date == element.date}) {
        result[section].append(element)//append message to section
    }else {
        //create new section
    }
}


text:
Q: PHP preg_match_all() not capturing subgroups I'm trying to parse a Twitter atom feed in PHP but am running into this strange issue. I'm calling preg_match_all with this regexp string:
"|<entry>.*<title>(.*)</title>.*<published>(.*)</published>.*</entry>|xsU"

It matches all the entries OK, but the captured subgroups title/published do not show up in the results (no arrays for the captured subgroups are created in the result object).
Now to the strange part, I try to capture the last bit as well:
"|<entry>.*<title>(.*)</title>.*<published>(.*)</published>(.*)</entry>|xsU"

And now the capturing works. I get the title and the published date and the large chunk of final data that I don't want.
I tried to add the non capturing string "?:" to the last subgroup but then capturing stopped working alltogether again.
So how do I capture the data I want, without having to capture the large chunk of unwanted data at the end?

A: I recommend you use DOM (or SimpleXML) for parsing RSS/Atom feeds. You will get way better results than with regular expressions.
Here's an example (using SimpleXML):
$rss_feed = file_get_contents('http://stackoverflow.com/feeds/question/4187945');
$sxml = new SimpleXMLElement($rss_feed);

$title = $sxml->entry[0]->title;
echo $title;


text:
Q: Django Rest Framework serializer returning nested records that should be filtered out on update I override my FormSerializer's update method. It marks some nested field records as is_deprecated if necessary. However, the Api call returns all records, even though my get_queryset filters out everything is_deprecated. As far as I can tell, the get_queryset is being called to get the instance, which is then passed to the serializer. This instance does not contain any previously deprecated records.
After the update method completes, it looks like another query must be run that gets ALL of these nested records and serializes them.  This only occurs on updates. This may be occurring when serializer is saved in UpdateModelMixin.update() when self.perform_update() is called.
I get the correct records on a standard GET request. Any idea where this second query is being called and how to override it? Alternatively, I should be able to edit the serialized data in to_representation, but this would be inefficient and I'd like to understand what is going on here first.
View
class FormViewSet(LoginRequiredMixin, viewsets.ModelViewSet):
    serializer_class = FormSerializer
    queryset = Form.objects.all()

    def get_queryset(self):
        if 'pk' in self.kwargs:
            qs = Form.objects.filter(id=self.kwargs['pk'])
        else:
            qs = Form.objects.filter(id__in=name_dict.values()).order_by('name')
        queryset = FormSerializer.eager_loading(qs)
        return queryset

Serializer
class FormSerializer(serializers.ModelSerializer):
  id = serializers.IntegerField(required=False, allow_null=True)
  fields = FieldSerializer(many=True)

  class Meta:
      model = Form
      fields = '__all__'

  @staticmethod
  def eager_loading(queryset):
      return queryset.prefetch_related(Prefetch('fields',queryset=Field.objects.filter(is_deprecated=False).order_by('field_order')))

A: I think, this answer should be a comment, but have no enough reputation.
get_queryset method called before update method of serializer.
What I mean by that:

*

*Call for update -> PUT for view

*View calls get_queryset -> Now we have not updated is_deprecated yet

*View finds object to update and calls update of serializer -> You make changes

*View returns instance from update method of serializer

So your fields field is same as on 2 point. Doesn't eager_loading, prefetch works like that? I mean loaded once, and that's it.
So you need to somehow manage to update your prefetched fields field.

A: If you look at the update method for the modelviewset, you will see that it invalidates the prefetch_related data so your eager loading doesn't work.
def update(self, request, *args, **kwargs):
    partial = kwargs.pop('partial', False)
    instance = self.get_object()
    serializer = self.get_serializer(instance, data=request.data, partial=partial)
    serializer.is_valid(raise_exception=True)
    self.perform_update(serializer)

    if getattr(instance, '_prefetched_objects_cache', None):
        # If 'prefetch_related' has been applied to a queryset, we need to
        # forcibly invalidate the prefetch cache on the instance.
        instance._prefetched_objects_cache = {}

    return Response(serializer.data)

This is done because the prefetched data could become obsolete after the update. So you can override the update method and redo the prefetch after the update