How can I output multiple strings and it not be so clunky?

I find a huge chunky of my code comes from copy and pasted ‘cout’ statements, and I was wondering if there was a way I could just print them all out in a loop?

cout << Eagles.teamname << " - Overall = " << Eagles.Teamov << endl;                              
cout << Tennessee.teamname << " - Overall = " << Tennessee.Teamov << endl 
cout << Bucks.teamname << " - Overall = " << Bucks.Teamov << endl;

And so on for every team…

So is there away where I don’t have to copy and paste for each team?

java – I consistently get an error with respect to the final output

I consistently get an error with respect to the final output. However, the code very apparently is running correctly, providing the desired output elements, with some additional redundant elements like an appetizer and with no errors.

Please, see the attached piece of code, and output when run on the Eclipse IDE.

 m, n, k;

while (true) {


// proocess to select the menu items
System.out.println("Select from menu, " + name);


n = sc.nextInt();
if (n == 0)

if (n == 1) {
while (true) {
System.out.println("Appetizer Menu:");

m = sc.nextInt();
list = list + "Appetizer:(" + appetizerMenu(m) + ": ";

if (m == 0) {

while (true) {

System.out.println("Toppings Menu:");
k = sc.nextInt();
if (k == 0)
list = list + toppingsMenu(k) + " ";

list = list + ")n";



if (n == 2) {

while (true) {
System.out.println("Main Course Menu:");

m = sc.nextInt();
list = list + "Main Course :(" + mainCourseMenu(m) + ": ";

if (m == 0) {

while (true) {

System.out.println("Toppings Menu:");
k = sc.nextInt();
if (k == 0)
list = list + toppingsMenu(k) + ")n";



if (n == 3) {

while (true) {
System.out.println("Dessert Menu:");

m = sc.nextInt();
list = list + "Main Course :(" + dessertMenu(m) + ": ";

if (m == 0) {

while (true) {

System.out.println("Toppings Menu:");
k = sc.nextInt();
if (k == 0)
list = list + toppingsMenu(k) + ")n";



} // end while loop

System.out.println("Here is your order " + name);
System.out.println("Enjoy your meal!");

} // end of if
}// main method
}// end of class

This is the output I am supposed to get :

Here is your order Superman:

Appetizer: ( Hummus: Olives, Olive Oil )

Main Course: ( Fish: Paprika )

Dessert: ( Baklava: )

Enjoy your meal!

Unfortunately, I am getting this output:

Here is your order Superman:
Appetizer:(Hummus: Olives Olive Oil )
Appetizer:(Nothing: Main Course :(Fish: Paprika)
Main Course :(Nothing: Main Course :(Baklava: Main Course :(Nothing:
Enjoy your meal!

Output inesperado struct C – Stack Overflow em Português

Declarei a seguinte função num arquivos .c separado da main:

int inicializaCompromisso(Compromisso *compromisso, Tipo tipo, Data data, int duracao, char *nome)
    static int id = 0;
    compromisso = malloc(sizeof(Compromisso));
    compromisso->tipo = tipo;
    compromisso->duracao = duracao;
    strcpy(compromisso->nome, nome);
    compromisso->adiavel = NAO;
    compromisso->tipo = tipo;
    compromisso->prioridade = tipo;
    compromisso->id = id++ - 1;
    return id;

Dentro da main:

    Compromisso* compromisso;
    int a = inicializaCompromisso(compromisso, AULA, data, 60, nome);
    printf("%i", compromisso->id);
    Compromisso* compromisso2;
    int b = inicializaCompromisso(compromisso2, AULA, data, 60, nome);
    printf("%i", compromisso2->id);

Se eu mando printar os valores de a e b, os id’s estão corretos. Porém se eu printo o campo id de um determinado compromisso como no código acima, o output é 0 e 1077940385. Como posso consertar isso?

woocommerce deposit Form with AJAX and shortcode won’t update but add to previous output

I am trying to create a product page where selecting a field defines a product and this triggers an AJAX call to display the woocommerce deposit form and add to cart submit button that correspond to the relevant product id.

The form that contains the deposit selection fields and submit button is displayed by using a shortcode which is called on page load with the default product.

Then, zhen clicking on the field that corresponds to the product you want to change to, I use an AJAX request to execute that shortcode again. I then try to replace the old form by the new form with innerhtml in Javascript, however for some reason the new form is always added after the old one. I can’t seem to replace that innerhtml content. Here is the code:

This is contained on the page:

//div to be filled with product deposit and add to cart form
<div id="adddepositsection">(add_product id="17364")</div>

//AJAX call on field click to execute the shortcode and replace the innerhtml
jQuery('#product2').on('click', function(){
document.getElementById("product1").className = "unselectedbox";
document.getElementById("product2").className = "selectedbox";
document.getElementById("product3").className = "unselectedbox";

        type: "POST",
        url: "/wp-admin/admin-ajax.php",
        data: {
            action: 'addfunctionshortcode',
            // add your parameters here
            productid: "17372"
        success: function (output) {
document.getElementById("adddepositsection").innerHTML = output; 


Shortcode function to display the deposit and add to cart button as well as function to execute that shortcode via AJAX in functions.php:

 //Display deposit choice and add to cart shortcode
    function add_product_display( $atts ) {
      $atts = shortcode_atts( array(
            'id' => null,
        ), $atts, 'bartag' );
            if( intval( $atts('id') ) > 0 && function_exists( 'wc_get_product' ) ){
             $product = wc_get_product( $atts('id') );
        <form class="cart" action="<?php echo esc_url( apply_filters( 'woocommerce_add_to_cart_form_action', $product->get_permalink() ) ); ?>" method="post" enctype='multipart/form-data'>
            <div class="wc-deposits-wrapper <?php echo WC_Deposits_Product_Manager::deposits_forced( $product->get_id() ) ? 'wc-deposits-forced' : 'wc-deposits-optional'; ?>">
        <?php if ( ! WC_Deposits_Product_Manager::deposits_forced( $product->get_id() ) ) : ?>
            <ul class="wc-deposits-option">
                    <input type="radio" name="wc_deposit_option" value="yes" id="wc-option-pay-deposit" <?php checked( $default_selected_type, 'deposit' ); ?> />
                    <label for="wc-option-pay-deposit">
                        <?php esc_html_e( 'Pay Deposit', 'woocommerce-deposits' ); ?>
                    <input type="radio" name="wc_deposit_option" value="no" id="wc-option-pay-full" <?php checked( $default_selected_type, 'full' ); ?> />
                    <label for="wc-option-pay-full">
                        <?php esc_html_e( 'Pay in Full', 'woocommerce-deposits' ); ?>
        <?php endif; ?>
            <div class="addcartcontainer">
    <?php if ( $product->is_in_stock() ) {  
             if (pll_current_language() == "en"   ) { ?>
                    <button type="submit" name="add-to-cart" value="<?php echo esc_attr( $product->get_id() ); ?>" class="addtocartsubmit">BUY NOW</button> <?php
                    elseif (pll_current_language() == "fr"){ ?>
                        <button type="submit" name="add-to-cart" value="<?php echo esc_attr( $product->get_id() ); ?>" class="addtocartsubmit">ACHETER MAINTENANT</button> <?php
                    elseif (pll_current_language() == "it"){ ?>
                        <button type="submit" name="add-to-cart" value="<?php echo esc_attr( $product->get_id() ); ?>" class="addtocartsubmit">ACQUISTA ORA</button> <?php
                else { 
     if (pll_current_language() == "en"   ) { ?>
                    <button type="submit" name="add-to-cart" value="<?php echo esc_attr( $product->get_id() ); ?>" class="addtocartsubmit">SOLD OUT</button> <?php
                    elseif (pll_current_language() == "fr"){ ?>
                        <button type="submit" name="add-to-cart" value="<?php echo esc_attr( $product->get_id() ); ?>" class="addtocartsubmit">EPUISE</button> <?php
                    elseif (pll_current_language() == "it"){ ?>
                        <button type="submit" name="add-to-cart" value="<?php echo esc_attr( $product->get_id() ); ?>" class="addtocartsubmit">SOLD OUT</button> <?php
                 } ?>
    add_shortcode( 'add_product', 'add_product_display' );

//Function called by AJAX to execute shortcode
// register the ajax action for authenticated users
add_action('wp_ajax_addfunctionshortcode', 'addfunctionshortcode');

// register the ajax action for unauthenticated users
add_action('wp_ajax_nopriv_addfunctionshortcode', 'addfunctionshortcode');

// handle the ajax request
function addfunctionshortcode() {
    $atts('id') = $_REQUEST('productid');
            echo  add_product_display( $atts );

Not showing amazon echo dot as output or input device in ubuntu sound setting after connecting through bluetooth

Though bluetooth pairing is successfull with Amazon Echo dot 3rd gen from Ubuntu 18.04.4 LTS( Echo says Now connected to <my machine's name>), The device is not listed in the sound setting as input/output device, So the problem is ,sound is coming from the inbuilt speaker and not from the echo device.

Things that I’ve already tried

  • connecting/disconnecting device multiple times
  • bluetooth pairing while laptop is playing some music(on youtube)

not really sure which command / logs to be checked for this issue. Please suggest.

What are output descriptors? – Bitcoin Stack Exchange

An output descriptor (note that output descriptor and wallet descriptor refer to the same thing) is a human readable string that represents an output script (a scriptPubKey) and everything needed in order to solve¹ for that script. Descriptors also have a bech32-like checksum which allows for the descriptor to be given to others with less risk of accidentally mistyping or losing some characters in the descriptor string.

Descriptors are unambiguous as to the public keys to use (derivation paths for extended keys are explicit) and the scripts to use. This makes them suitable for importing to other wallets without confusion. In contrast, traditional import mechanisms support only keys with special versioning to indicate the scripts to produce, and don’t provide the derivation paths. This creates a situation where a user imports an extended key into a wallet but is unable to see their addresses because that wallet uses a different derivation path than the original wallet. Descriptors avoids this issue entirely by specifying the derivation paths (if any) and the scripts to produce.

A descriptor wallet is one which stores output descriptors and uses them to create addresses and sign transactions. By abstracting away address creation and transaction signing to a largely standalone module, such wallets can upgrade to using new address types much more easily.

For most users, the only visible effects will be in wallet import/export. Descriptors will only be shown during exporting, and descriptors should only be handled by the user when they want to import their wallet. Wallets that use descriptors internally shouldn’t have any noticeable effect to the user.

¹: Solve – Solving a script means that one would be able to create a final scriptSig/witness with valid signatures if they had a private key. This means that all public keys and other scripts are available.

sql server – Limiting sp_whoisactive output


I am currently putting together a knowledge based article that we can hand to our helpdesk to run through in order to do some preliminary troubleshooting or information gathering. One of the things I did was create the ability (thanks to Brent, to provide non-sysadmin’s the ability to run sp_whoisactive to output some details they could provide to dbas like myself in the ticket. The problem I am running into is I want to exclude “sql_text” from results, but I cannot seem to figure out how?

I understand you have the ability to filter the output when it goes to a table (@output_column_list param) but I am not having the agents export it to a table. Initially, I was under the impression that the “@output_column_list” was where I could adjust the columns I wanted to see in the results, but it is clearly only a parameter used to filter the output to a table. In my desperate attempt, I tried the above parameter anyways and would leave out “sql_text” from the output, but all that did was reposition the column order.

EXEC sp_WhoIsActive @output_column_list = '(dd%)(session_id)(login_name)(wait_info)(tasks)(tran_log%)(cpu%)(temp%)(block%)(reads%)(writes%)(context%)(physical%)(query_plan)(locks)(%)'

Therefore, I want them to be able to copy the contents (with headers) to an excel sheet to attach. The less complicated work, the better as I fear if I provide the help desk with too much info it will confuse them.

Am I missing something? They will not have the ability to run any jobs or even look at logs, so their rights are already VERY limited.

powershell – Understanding an Invoke-WebRequest call with output from Fiddler

I’m trying to upload an XML config file to a Netgate router, and the page they give you is a php form. This is a normal config file upload with the GUI – when I use the GUI page, Fiddler shows that the exchange looks like this (I note that the form data is typed and the value is a file):

Fiddler - using the GUI

I try throwing this at the invoke-web request:

$RestoreArguments =  @{
    conffile=(xml)(get-content $conffile);
    restore='Restore Configuration'
$LoopResult = Invoke-WebRequest -timeoutsec 5 -WebSession $LoopSession -Uri "$Luri/diag_backup.php" -Method 'Post' -Body $RestoreArguments 

and Fiddler capture this:

Fiddler - PS attempt 1

I thought that maybe the issue is how it’s getting the content, so I replaced the conffile parameter like this:

conffile=(xml)(get-content $conffile);

but see Fiddler capture:

Fiddler - PS attempt 2

So now I think that it is how the parameter is typed, but am not sure how to give the page what it wants. As a sidenote, no errors from the code. Thank you for your thoughts!

javascript – Finds customer who live within 100km and output them to a text file

I had an interview task where I had to output customers who live 100km within a particular latitude and longitude and then output them to a file with their username and ID. The customer file looks like the following:

{"latitude": "52.986375", "user_id": 12, "name": "Christina McArdle", "longitude": "-6.043701"}
{"latitude": "51.92893", "user_id": 1, "name": "Alice Cahill", "longitude": "-10.27699"}
{"latitude": "51.8856167", "user_id": 2, "name": "Ian McArdle", "longitude": "-10.4240951"}
{"latitude": "52.3191841", "user_id": 3, "name": "Jack Enright", "longitude": "-8.5072391"}

Here is the code to implement the calculation for the great-circle-distance

 * solution accuired from

const greatCircleDistanceCalc = (lat1, lon1, lat2, lon2) => {
  const R = 6371; // Radius of the earth in km
  const dLat = deg2rad(lat2 - lat1); // deg2rad below
  const dLon = deg2rad(lon2 - lon1);
  const a =
    Math.sin(dLat / 2) * Math.sin(dLat / 2) +
    Math.cos(deg2rad(lat1)) *
      Math.cos(deg2rad(lat2)) *
      Math.sin(dLon / 2) *
      Math.sin(dLon / 2);
  const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
  const d = R * c; // Distance in km
  return d;

const deg2rad = (deg) => {
  return deg * (Math.PI / 180);

module.exports = {

Here is the main app.js where the calculation is used and a customer file is read and a new file is outputted.

const fs = require("fs");
const { greatCircleDistanceCalc } = require("./greatCircleDistanceCalc.js");

const customerFile = fs.readFileSync("./customers.txt", "utf-8"); //Read in file
const customerArr = customerFile.split("n").map((s) => JSON.parse(s)); //Convert file into array of objects

const dublinOffice = {
  latitude: "53.339428",
  longitude: "-6.257664",

const invitedArr = ();

//Sort data in ascending order
const sortedCustomers = customerArr.sort((a, b) => {
  return a.user_id - b.user_id;

const closestCustomers = (sortedCustomers, arr) => {
  for ({ latitude, longitude, user_id, name } of sortedCustomers) {
    if (
      ) <= 100
    ) {

const writeInvitedCustomer = (arr) => {
  const writeStream = fs.createWriteStream("Output.txt");
  const pathName = writeStream.path;

  arr.forEach((value) => writeStream.write(`${value}n`));
  writeStream.on("finish", () => {
    console.log(`wrote all the array data to file ${pathName}`);

  writeStream.on("error", (err) => {
    console.error(`There is an error writing the file ${pathName} => ${err}`);


closestCustomers(sortedCustomers, invitedArr);

Overall I am happy with the solution but I think the only thing is I am not sure how to write a test for this.

As always any feedback and suggestions are much welcome.

Is there any WordPress plugin with conditional output message based on the filled data?

I have 2 columns in an Excel sheet the 1st column is a user name (which is unique) and the other 2nd column is the user’s promo code that he will use later (Offline in local stores)
So my question is there any WordPress plugin with conditional output message based on the filled data? with excel functionality to add the 2 columns to satisfy this example
Whenever user “Admin5562” enters his name “Admin5562” the unique answer for him only would be “Promo50%”