Add rows in a table (with jquery), which is a form element

Question: I have a form which contains a table. Each cell in every row of the table has an input field or a radio button. See below the code:

Material [S]upplied | [R]emoved | [F]ollow up
          <button type="button" class="btn btn-success" id="addRow">Add Row </button>

                Qty
                Part Number
                Description
                Serial Number
                [S]
                [R]
                [F]

                  <input type="text" class="form-control" id="qty" name="qty_1" placeholder="Quantity">

                  <input type="text" class="form-control" id="part_no" name="part_no_1" placeholder="Part No">

                  <input type="text" class="form-control" id="description" name="description_1" placeholder="Description">

                  <input type="text" class="form-control" id="serialnumber" name="serialnumber_1" placeholder="Serial Number">

                  <input type="radio" name="material_1" id="supplied_1" value="supplied">

                  <input type="radio" name="material_1" id="removed_1" value="removed">

                  <input type="radio" name="material_1" id="followup_1" value="followup">

As you may see the table is inside a panel, in the head of which, I have a button for adding new rows in the table when necessary.
For adding new rows in the table I use the below JavaScript code:
$("#addRow").click(funtion(){

  $('#results_material > tbody:last-child').append(
    '

        <input type="text" class="form-control" id="qty" name="qty_1" placeholder="Quantity">

        <input type="text" class="form-control" id="part_no" name="part_no_1" placeholder="Part No">

        <input type="text" class="form-control" id="description" name="description_1" placeholder="Description">

        <input type="text" class="form-control" id="serialnumber" name="serialnumber_1" placeholder="Serial Number">

        <input type="radio" name="material_1" id="supplied_1" value="supplied">

        <input type="radio" name="material_1" id="removed_1" value="removed">

        <input type="radio" name="material_1" id="followup_1" value="followup">

'
    );
});

First problem: The part of the code which is inside the append method must not have white-space, but instead has to be in one line. This makes the code
difficult to be read. Is there any solution?
Second problem: The names of the input fields should be different on each row(needed for the submission). For example the second row should have name="qty_2" etc. Any ideas?
Answer: Modification of your code.

var last_inserted = 2;
$("#addRow").click(function(){

  $('#results_material > tbody:last-child').append(
    '
'+
      ''+
        '<input type="text" class="form-control" id="qty_'+last_inserted+'" name="qty_'+last_inserted+'" placeholder="Quantity">'+
      '	'+
      ''+
        '<input type="text" class="form-control" id="part_no_'+last_inserted+'" name="part_no_'+last_inserted+'" placeholder="Part No">'+
      '	'+
      ''+
        '<input type="text" class="form-control" id="description_'+last_inserted+'" name="description_'+last_inserted+'" placeholder="Description">'+
      '	'+
      ''+
        '<input type="text" class="form-control" id="serialnumbe_'+last_inserted+'r" name="serialnumber_'+last_inserted+'" placeholder="Serial Number">'+
      '	 '+
      ''+
        '<input type="radio" name="material_'+last_inserted+'" id="supplied_'+last_inserted+'" value="supplied">'+
      '	 '+
      ''+
        '<input type="radio" name="material_'+last_inserted+'" id="removed_'+last_inserted+'" value="removed">'+
      '	'+
      ''+
        '<input type="radio" name="material_'+last_inserted+'" id="followup_'+last_inserted+'" value="followup">'+
      '	'+
    '
'
    );
  last_inserted++;
});

Material [S]upplied | [R]emoved | [F]ollow up
          <button type="button" class="btn btn-success" id="addRow">Add Row </button>

                Qty
                Part Number
                Description
                Serial Number
                [S]
                [R]
                [F]

                  <input type="text" class="form-control" id="qty" name="qty_1" placeholder="Quantity">

                  <input type="text" class="form-control" id="part_no" name="part_no_1" placeholder="Part No">

                  <input type="text" class="form-control" id="description" name="description_1" placeholder="Description">

                  <input type="text" class="form-control" id="serialnumber" name="serialnumber_1" placeholder="Serial Number">

                  <input type="radio" name="material_1" id="supplied_1" value="supplied">

                  <input type="radio" name="material_1" id="removed_1" value="removed">

                  <input type="radio" name="material_1" id="followup_1" value="followup">

Comment: Thanks xAqweRx, the answer for the whitespace is the plus sign. I used var rowCount = $('#results_material tr').length; for tha names...
Answer: I'd suggest the following approach:
$('#addRow').on('click', function(){
  // finding the
 elements within the
  // #material
 element, and keeping only
  // last of those:
  var lastRow = $('#material').find('tr').last(),

      // retrieving the rowIndex property of that last
      //
 element, and adding 1 to it (to use it
      // later):
      newLastIndex = lastRow.prop('rowIndex') + 1,

      // cloning the lastRow, along with its event-handlers
      // and data (the first true), along with its descendants
      // and their event-handlers and data (the second true):
      clone = lastRow.clone(true,true);

      // inserting the clone after the last row, then
      // finding the descendant <input> elements, and
      // updating their 'name' and 'id' properties:
      clone.insertAfter(lastRow).find('input').prop({

        // updating the 'name':
        'name' : function(i,c) {
          // replacing the sequence of numbers from
          // end of the string with the newLastIndex:
          // c       : the current value of the property to
          //           be changed,
          // i       : the index of the current element in
          //           the collection of elements,
          // '/.../' : regexp literal,
          // '\d+'   : a sequence of one, or more, number
          //           characters
          // '$'     : end-of-string special character:
          return c.replace(/\d+$/, newLastIndex);
        },
        'id' : function(i,c) {

          switch (this.type) {
            // if the 'type' of the current <input> is
            // 'text:
            case 'text':
              // c is set to the name of the current
              // element:
              c = this.name;
              break;

            // if it's either a 'radio' or 'checkbox':
            case 'radio':
            case 'checkbox':
              // we replace the number at the end of
              // String wtih the newLastIndex variable:
              c = c.replace(/\d+$/, newLastIndex);
          }

          // returning the new property-value:
          return c;
        }
      });
});

$('#addRow').on('click', function() {
  var lastRow = $('#material').find('tr').last(),
    newLastIndex = lastRow.prop('rowIndex') + 1,
    clone = lastRow.clone(true, true),
    inputs = clone.insertAfter(lastRow).find('input').prop({
      'name': function(i, c) {
        return c.replace(/\d+$/, newLastIndex);
      },
      'id': function(i, c) {
        switch (this.type) {
          case 'text':
            c = this.name;
            break;
          case 'radio':
          case 'checkbox':
            c = c.replace(/\d+$/, newLastIndex);
        }
        return c;
      }
    });
});

Material [S]upplied | [R]emoved | [F]ollow up
    <button type="button" class="btn btn-success" id="addRow">Add Row
    </button>

          Qty
          Part Number
          Description
          Serial Number
          [S]
          [R]
          [F]

            <input type="text" class="form-control" id="qty" name="qty_1" placeholder="Quantity">

            <input type="text" class="form-control" id="part_no" name="part_no_1" placeholder="Part No">

            <input type="text" class="form-control" id="description" name="description_1" placeholder="Description">

            <input type="text" class="form-control" id="serialnumber" name="serialnumber_1" placeholder="Serial Number">

            <input type="radio" name="material_1" id="supplied_1" value="supplied">

            <input type="radio" name="material_1" id="removed_1" value="removed">

            <input type="radio" name="material_1" id="followup_1" value="followup">

Comment: Nice code!! I think I will follow your suggestion... I like the way you use JavaScript and produce short code
Comment: I'm glad that I could help :)


Assistance with C++ simple_error()

Question: I am independently learning C++ using the Second Edition of "Programming Principles and Practice Using C++" by Bjarne Stroustrup. I have reached the end of chapter 3 and I am completing the drill. It involves writing a program that produces a "simple form letter, based on user input".
The task for step 5 of this drill is as follows (quoted word for word):

Prompt the user to enter the age of the recipient and assign it to an int variable age. Have your program write "I hear you just had a birthday and you are age years old." If age is 0 or less or 110 or more, call simple_error("you're kidding!") using simple_error() from std_lib_facilities.h.

See my syntax below:
cout << "\n\nEnter the age of " << first_name << ":\n";
int age;
cin >> age;
cout << "   I heared you just had a birthday and you are " << age << " years old. \n\n";
if (age <= 0 || age >= 110)
    simple_error("you're kidding!");

Is my use of the 'if' statement, it's conditions and simple_error() correct as per the instructions of step 5?
It seems strange because the purpose of the program is to write a letter and simple error("you're kidding!") outputs "error: you're kidding!" in the letter... should I take this so literally?
I really appreciate your time and advice.
Comment: Does it work when you try it?
Comment: @NathanOliver yes, the output is correct as far as the if statement goes. But is simple_error("you're kidding!") supposed to output "error: you're kidding!"? This is the first time simple_error() has been mentioned.
Comment: simple_error() is going print "error" before any error message you passed in as a parameter. Your code looks sound to me and your if statement is correct  so don't sweat the "error" part. You could replace simple_error() with cout<< if you wan't the "error" part gone.
Comment: I suspect that the intent is to write the "letter" only if there's no error. (That is, test the age first, and write the letter if I'm not kidding; the error message if I am.)
Comment: @RatHat thank you! I know it is such a trivial question but we all have to start somewhere.
Comment: @molbdnilo Ahh, that makes more sense to be honest, but I have no idea how to do that.
Answer: Your program appears to follow the drill.
As far as the drill goes, it simply wants:
if (age <= 0 || age >= 110)
    simple_error("you're kidding!");

How the program behaves beyond that is out of scope for the drill, you shouldn't be concerned with how it formats the text. Just make sure it compiles, and what you wrote works as intended.
Answer: If you see the definition of simple_error() from std_lib_facilities.h
// error function to be used (only) until error() is introduced in Chapter 5:
inline void simple_error(string s)  // write ``error: s`` and exit program
{
    cerr << "error: " << s << '\n';
    keep_window_open();     // for some Windows environments
    exit(1);
}

The error is intended to go to cerr (standard error stream). By default anything to standard error is redirected to standard output.
If you don't want the error message in the letter, which I think you are concerned about, you can direct your standard error, for example, to a file on *nix systems like
./a.out 2>> error_file

Where, 2 stands for standard error stream.
As far as the drill goes your program is correct.

Assistance with C++ simple_error()


Remove kubuntu-desktop from ubuntu 12.04

Question:
Possible Duplicate:
How to completely remove desktop?

So, I thought I managed to remove KDE completely, but apparently that did not work at all, because every KDE application is back, including the KDE splash screen.
I ran
sudo apt-get autoremove --purge kubuntu-desktop

Then I ran
sudo apt-get install --reinstall ubuntu-desktop

Then I ran
sudo sudo update-alternatives --config default.plymouth

Then I rebooted and everything seemed to be the original ubuntu-desktop (without the kde splash screen and other KDE applications). But now, one week later I still boot to ubuntu-desktop, but like I said, the kde splash screen and applications are all back.
How should I remove kubuntu-desktop?
Comment: @Meijuh just follow the link provided by penreturn and get your cemented desktop remove.
Answer: Probably you have to delete each dependency by hand:
apt-cache depends kubuntu-desktop

These scripts should work for 12.04: www.psychocats.net
Comment: Well I did just that and now i am getting the following error.

   Unpacking libqtcore4 (from .../libqtcore4_4%3a4.8.1-0ubuntu4.2_amd64.deb) ...
dpkg: error processing /var/cache/apt/archives/libqtcore4_4%3a4.8.1-0ubuntu4.2_amd64.deb (--unpack):
 conffile './etc/xdg/Trolltech.conf' is not in sync with other instances of the same package
Errors were encountered while processing:
 /var/cache/apt/archives/libqtcore4_4%3a4.8.1-0ubuntu4.2_amd64.deb
Comment: After issueing apt-get install -f, I got broken packages, because libqtcore4 would not install. Magically, I was able to remove libqtcore4 via synaptic and then reinstall it via apt-get.
Comment: So - does it work now? And do you think it is an issue caused by one of the scripts mentioned in the link above?


gradle error "Execution failed for task ':app:compileDebugJava' " while build groovy in android studio

Question: I got a error while building groovy code in android studio.
the error msg is
C:\Users\Administrator\Desktop\lytest110\app\src\main\java\gzzhe\com\lytest110\MainActivity.java:41: error: can't find symbol
        Log.d("lytest110", GroovyTest.getMsg());
                           ^
  symbol:   parameter GroovyTest
  possition: class MainActivity
1 error

 FAILED
:app:compileDebugGroovy

FAILURE: Build failed with an exception.

my build.gradle is:
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.13.2'
        classpath 'me.champeau.gradle:gradle-groovy-android-plugin:0.3.4'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

the build.gradle in app directory:
    apply plugin: 'com.android.application'
apply plugin: 'me.champeau.gradle.groovy-android'
android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    defaultConfig {
        applicationId "gzzhe.com.lytest110"
        minSdkVersion 14
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile files('libs/groovy-2.4.0-beta-3-grooid.jar')
    compile files('libs/android-support-v4.jar')
    compile fileTree(include: ['*.jar'], dir: 'libs')
    //    compile 'com.android.support:support-v4:19.+'
}

I have put the groovy file into main/groovy/package/name directory.
the groovy is annotated with @CompileStatic.

This problem have puzzled me for several days.
Answer: From your error it seems like you are calling Groovy class with Java. According to the Android Groovy plugin readme. it says
Groovy sources must be found inside src/main/groovy. Note that the plugin follows the behavior of the Groovy plugin in Gradle, which means that if you want to be able to have Groovy classes referencing Java classes that themselves reference Groovy classes, then those Java classes must be found inside src/main/groovy too (this is called joint compilation).
So you just put your MainActivity.java to your ../main/groovy/package/name directory


How to determine the number of integer solutions to this particular case?

Question:
Consider the equation $$z_1 + z_2 + z_3 + z_4 + z_5 + z_6 = k$$ For:
  $i = 1, \dotsc,6$ $z_i$ is a positive natural number and they must
  satisfy the following: \begin{align} z_1 & \ge 4  \\ z_2 & \ge 10 \\
 z_3 & \ge 12 \\ z_4 & \ge 18 \\ z_5 & \ge 6 \\ z_6 & \ge 30
\end{align}
(a) For what values of $k$ are there no solutions?
  (b) Determine the
  number of solutions for other values of $k$
Comment: Please add what you have tried so far to the question so that people on the site can help you solve your problem.
Comment: Can you not say anything at all about (a), wout? Can you not see that there's no solution for $k=-17$? for $k=100\sqrt2$? for $k=20$?
Answer: (a) The minimal $k$ value is for $z = b$:
$$
k = 4 + 10 + 12 + 18 + 6 + 30 = 80
$$
For smaller $k$ values there is no solution.
(b)
For $k = 80 + 1$ we have $6$ components to distribute the additional $1$ to.
For $k = 80 + 2$ we have $6$ possible choices for the first additional $1$ and again $6$ possible choices for the second additional $1$. However some of the choices lead to an indistinguishable result, like $(1,2)$ and $(2,1)$, so we have $(6^2 - 6)/2 + 6 = 15 + 6 = 21$ choices.
For $k = 80 + n$, $n \in \mathbb{N}$, it is the general combinatorial problem of putting $n$ identical objects into $6$ bins. See e.g. here.
This gives
$\binom{n+6-1}{6-1} = \binom{n+5}{5}$
choices.
Answer: $(a)$ $^{k-(4+10+12+18+6+30)+(n-1)}C_{(n-1)}=^{(k-81+6)}C_{(6-1)}=^{(k-75)}C_5 \neq 0 $
For minimum one solution : $^{(k-75)}C_5=1 \implies (k-75)=5, \implies k=80$.

So, solution is not possible only when $k<80$ for given conditions.

$(b)$ When restriction is not applied the number of solutions $=^{(k+(n-1))}C_{(n-1)}$.
If these conditions applied :

 Value of $k$ should be $k\geq 80$ for atleast one solution and $k$ should be integer.

In how many ways can 20 identical balls be distributed into 4 distinct boxes subject?


Apply displacement map via Imagick after version update

Question: I had the code running to create a "cylinder" effect via ImageMagick v6.7.9 and PHP (Imagick extension v3.2.0), it's like described in the accepted answer of my previous question: https://stackoverflow.com/a/54807019/1800172 It's inspired by Fred's cylinderize script: http://www.fmwconcepts.com/imagemagick/cylinderize/
After creating the X/Y-displacements ($a3/$a4) it's combined like this:
// merge x-displacement and y-displacement into one displacement-map
$displaceMask = new Imagick();
$displaceMask->addImage($a3);
$displaceMask->addImage($a4);
$displaceMask->addImage($a4);
$displaceMask->mergeImageLayers(Imagick::LAYERMETHOD_FLATTEN);
$displaceMask = $displaceMask->combineImages(Imagick::CHANNEL_ALL);

$displaceMask->setImageArtifact('compose:args', '1600x83.669513037752');
$image->compositeImage($displaceMask, Imagick::COMPOSITE_DISPLACE, 0, 0);
$image->trimImage(0);

Now that I updated to ImageMagick v6.9.10 and Imagick v3.4.3 this does not produce the same image anymore. I already figured out that I had to change the way how to create the displacement map, to make it look the same as before:
// merge x-displacement and y-displacement into one displacement-map
$displaceMask = new Imagick();
$displaceMask->newImage($a3->getImageWidth(), $a3->getImageHeight(), new ImagickPixel('white'));
$displaceMask->setImageFormat('png');
$displaceMask->setImageColorspace(Imagick::COLORSPACE_RGB);

$displaceMask->compositeImage($a3, imagick::COMPOSITE_COPYRED, 0, 0);
$displaceMask->compositeImage($a4, imagick::COMPOSITE_COPYGREEN, 0, 0);
$displaceMask->compositeImage($a4, imagick::COMPOSITE_COPYBLUE, 0, 0);

But if I now apply the "composite" function with "displace" operator, the result looks not the same as with the old version:
$displaceMask->setImageArtifact('compose:args', '1600x83.669513037752');
$image->compositeImage($displaceMask, Imagick::COMPOSITE_DISPLACE, 0, 0);
$image->trimImage(0);

Input image:

Displacement map:

Expected resulting image (like before version update):

Resulting image (i.e. after version update):

My guess is that anything changed in Imagick and/or ImageMagick implementation, or in it's (default) configuration. Anyone who can point me to the solution?
Thanks in advance!
Edit: I updated the input image, it was not the one that I use as the input of the displacement.
Edit2: I tried to apply the displacement via ImageMagick directly instead of using Imagick, and there it seems to work (ignoring the fact that the resulting image is somehow pixelated, so it's not usable as a workaround so far):
convert input.png ( a3.png a4.png a4.png -combine ) -channel rgba -alpha on -virtual-pixel transparent -background none -define compose:args=1600x83.669513037752 -compose displace -composite result.png

--> Might be a problem/bug/change in Imagick itself?
Comment: Some pixelation is expected when you have extreme distortion around the sides of the cylinder. You might try using some other -interpolation method for the distortion. Also it could be due to the way you create the displacement image -- that is that it might not have the accuracy needed. You may have to create the displacement in HDRI mode with floating format images.
Comment: Your images do not show much pixelation. But I get much more extreme pixelation than you show using your images on ImageMagick. That does not look correct to me. How did you create your displacement images. Your argument of 1600 is rather extreme. Perhaps it is too much for the displacement?
Answer: I think the problem was a change within ImageMagick and/or the Imagick PHP-extension between the versions that I used. I found this issue in the changelog of ImageMagick: https://github.com/ImageMagick/ImageMagick/issues/597
And one step further here is the actual change they did some time ago: https://github.com/ImageMagick/ImageMagick/commit/87be42439e1df8c51e7af5ea5d6591a8af499cf2
--> to solve the issue, I had to set the compose arguments not on the displacement map, but instead on the source image. Then It was working fine again, even without the jagged lines (I had them as well when I tried it via the command line).
So instead of
$displaceMask->setImageArtifact('compose:args', '1600x83.669513037752');
$image->compositeImage($displaceMask, Imagick::COMPOSITE_DISPLACE, 0, 0);

I had to do it like this:
$image->setImageArtifact('compose:args', '1600x83.669513037752');
$image->compositeImage($displaceMask, Imagick::COMPOSITE_DISPLACE, 0, 0);

Answer: I cannot reproduce your results with ImageMagick 188.8.131.52 nor 220.127.116.11.
Both are extremely jagged for the border of the center circle. But the straight lines are not jagged, which is puzzling. You need to download the images and view at full resolution to see how jagged they are.
How did you create your displacement map? I think that is the source of your issue -- It is too coarse, i.e. not smooth enough. It is 8-bits per channel per pixel and needs to be saved as 16-bits or even higher for such a large image.
convert img.png displace.png \
-channel rgba -alpha on -virtual-pixel transparent -background none \
-define compose:args=1600x83 -compose displace -composite result.png

Result from IM 184.108.40.206:

Result from IM 126.96.36.199:


login loop: systemd-udevd[713]: failed to execute '/bin/systemctl start --no-block nvidia-persistenced.service': No such file or directory

Question: My PC was working yesterday without any problem. I shut it down and tried to open this morning. It prints out these messages on the black screen:
systemd-udevd[713]: failed to execute '/bin/systemctl' '/bin/systemctl start --no-block nvidia-persistenced.service': No such file or directory

systemd-udevd[852]: failed to execute '/bin/systemctl' '/bin/systemctl stop--no-block nvidia-persistenced': No such file or directory

It then continued with the login screen. I entered my password and pressed enter. It waited for a while and the login screen reappeared again.
How can I fix the problem?
Answer: In case someone else has this problem, this is what worked for me:

Press Ctrl+Alt+F1 to open a terminal and log in.
Run sudo apt-get install nvidia-current, then sudo reboot

It downgraded to nvidia-304 and everything was fine after reboot
Comment: I had this message since I upgraded to nvidia-384, but also random freezes after wake-up, which I never had before; hope this will solve this problem too. Thanks!
Answer: It sounds like you've got two problems; the systemd-udevd looks like it is a problem with the Nvidia driver. I managed to cure mine by reinstalling an earlier version from 367.57 back to 340.98, it's all in the Software & Updates screen.
That of course is no good at all if you are in a login loop. I've also had that problem in the past a few times and had to got to the terminal (Ctrl+Alt+F1) and put this code in:
sudo mv ~/.Xauthority ~/.Xauthority.backup

Then
sudo service lightdm restart

That should at least get you past the login loop so you can change the driver.
Comment: I tried what you suggest but it didn't help. I also went through other suggested solutions and checks. None of them solved my problem. Since I was in hurry, I had to format my PC.
Answer: This message appears to be fairly innocuous, not affecting the driver function. You can confirm the driver function by running inxi -Fxz: you should see something like:
Graphics:  Card: NVIDIA Device 1b81 bus-ID: 01:00.0
           Display Server: X.Org 1.15.1 drivers: nvidia (unloaded: fbdev,vesa,nouveau)
           Resolution: email@example.com
           GLX Renderer: GeForce GTX 1070/PCIe/SSE2 GLX Version: 4.5.0 NVIDIA 375.82 Direct Rendering: Yes

I get the OP's error message running Linux Mint Rosa 17.3, which does not use systemd (it uses Upstart as init). Thus, no surprise that /bin/systemctl does not exist. Nvidia should not be trying to call it. More info in this thread.
If you're unable to log in, there's likely something else wrong.
Comment: FYI for those reading: `inxi` is very useful, but it doesn't come standard on Ubuntu 16.04 and must be installed with `sudo apt-get install inxi`


In Minecraft can you use an array in a /fill command?

Question: So I was trying to replace any stone or air in a 2x6x1 square in-front of me.
This is the command I am using.
/Fill 64 13 87 67 16 90 coal_ore 0 replace {stone air}

I am just getting into understanding some of the commands in Minecraft. This is the first one I am experimenting with. My background comes from using Excel. I am assuming an array is something I can use in a Minecraft command line.
Any help would be appreciated.
I tried looking into this but couldn't find my answer.

Minecraft fill command using slabs
how do you use /fill command
Minecraft Command NBT Array Add
Comment: Which edition of Minecraft are you playing? The `0` makes me assume MCBE, but it could also be MCJava 1.12.2.
Comment: I once had a dream about Minecraft and almost that exact syntax was in it. But no, it does not exist in reality.
Answer: The wiki already lists every possible syntax of the /fill command, so you cannot use lists of blocks.
The closest you can get to that is using a block tag (archive). For example to replace all types of logs with stone, you can use this command:
/fill <coords> <coords> stone replace #logs

There are a few built-in block tags, but you can also create your own using a datapack.
Block tags only exist in Minecraft Java edition. At the time I'm writing this, the asker did not specify a Minecraft edition.
Answer: Such functionality isn't in-built into the fill command. I've tried it before, and my solution was to have an armor stand scan over the area and replace the blocks you want.
Note this method is the most laggy, as you will have an armor stand at every block on the XZ plane at one point. It can be simplified, but it will take longer to run. Use at own risk, and do not use for exceedingly large areas!
You will need 3 dummy scoreboard objectives, named fillReplaceX, fillReplaceY and fillReplaceZ.
Start by resetting all the objectives:
/scoreboard players reset fillReplaceX
/scoreboard players reset fillReplaceY
/scoreboard players reset fillReplaceZ

Then summon a unique armor stand:
/execute positioned [corner of area, lowest coordinates xyz] run summon minecraft:armor_stand ~ ~ ~ {Tags=["fillReplaceAlongX"]}

Then power this:
[repeat] /execute as @e[type=minecraft:armor_stand,tag=fillReplaceAlongX] at @s if score @s fillReplaceX matches ..[x size of area] run summon minecraft:armor_stand ~ ~ ~ {Tags=["fillReplaceAlongZ"]}
[conditional] /execute as @e[type=minecraft:armor_stand,tag=fillReplaceAlongX] at @s run tp @s ~1 ~ ~
[conditional] /execute as @e[type=minecraft:armor_stand,tag=fillReplaceAlongX] run scoreboard players add @s fillReplaceX 1

Then:
/execute as @e[type=minecraft:armor_stand,tag=fillReplaceAlongX] run scoreboard players reset @s fillReplaceX
/kill @e[type=minecraft:armor_stand,tag=fillReplaceAlongX]

Once that is completed power this:
[repeat] /execute as @e[type=minecraft:armor_stand,tag=fillReplaceAlongZ] at @s if score @s fillReplaceZ matches ..[z size of area] run summon minecraft:armor_stand ~ ~ ~ {Tags=["fillReplaceFinal"]}
[conditional] /execute as @e[type=minecraft:armor_stand,tag=fillReplaceAlongZ] at @s run tp @s ~ ~ ~1
[conditional] /execute as @e[type=minecraft:armor_stand,tag=fillReplaceAlongZ] run scoreboard players add @s fillReplaceZ 1

Then:
/execute as @e[type=minecraft:armor_stand,tag=fillReplaceAlongZ] run scoreboard players reset @s fillReplaceZ
/kill @e[type=minecraft:armor_stand,tag=fillReplaceAlongZ]

Once that is completed power this:
[repeat] /execute as @e[type=minecraft:armor_stand,tag=fillReplaceFinal] at @s if score @s fillReplaceY matches ..[y size of area] run [COMMAND TO RUN OVER AREA]
[conditional] /execute as @e[type=minecraft:armor_stand,tag=fillReplaceFinal] at @s run tp @s ~ ~1 ~
[conditional] /execute as @e[type=minecraft:armor_stand,tag=fillReplaceFinal] run scoreboard players add @s fillReplaceY 1

And finally, kill the armor stands.
/execute as @e[type=minecraft:armor_stand,tag=fillReplaceFinal] run scoreboard players reset @s fillReplaceY
/kill @e[type=minecraft:armor_stand,tag=fillReplaceFinal]

Replace [COMMAND TO RUN OVER AREA] with what will be done for every block in the area. If you wanted to replace all stone in the area with air, then enter:
execute if block ~ ~ ~ minecraft:stone run setblock ~ ~ ~ minecraft:air

I may have gotten some syntax wrong, as this is from memory. LMK and I will fix.
Edit: If you want to run multiple commands over the area, just add another command block as a conditional chain, before the TP command:
/execute as @e[type=minecraft:armor_stand,tag=fillReplaceFinal] at @s run [COMMAND TO RUN OVER AREA]

Comment: But they can simply do `/fill  coal_ore replace stone` and `/fill  coal_ore replace air` as well! That's WAY simpler and causes WAY less lag.
Comment: That's an interest trick that I have used before, but it is not required in this case, because `/fill` exists. It's also not at all what the question was about.
Comment: OP wanted a way to replace certain blocks in an area with other certain blocks. This method does that. If he wanted to replace stone and air with coal_ore, he can do that with ```execute if block ~ ~ ~ stone run setblock ~ ~ ~ coal_ore``` and ```execute if block ~ ~ ~ air run setblock ~ ~ ~ coal_ore``` in my method.
Comment: Oh, sorry, I was under the impression that 'replace' was a method of placing the blocks, like 'destroy' would break the block that was already there and drop its item. I didn't know you could actually use it to replace certain blocks! My mistake.


Can you tell what enemies your soldiers would be able to see/fire on before moving?

Question: When moving, XCOM provides a helpful blue line indicating what path your soldier will take.  This is extremely helpful to see BEFORE you move, in situations like:

When you're trying to sneak up on an enemy, but your soldier is going to jump through a glass window, you know, just because
When the game is glitching out and can't tell what square your mouse is over and wants to move you down a level

Is there any similar indicator of which enemies will be in view from a potential destination square?  Examples of situations where it is frustrating not to have one:

You move in to shoot at a far-off enemy... and find out you haven't moved in far enough
There's an object sorta in the way between you and the potential target... and you find out that, actually, the game thinks it's completely in the way
The game is glitching out (ESPECIALLY bad when you're climbing on top of the enemy ships) and thinks you can't see an enemy who's two squares away because they're up a tiny slope.
Comment: 2.When the game is glitching out and can't tell what square your mouse is over and wants to move you down a level... try going up or down with the mouse wheel.
Answer: Your third example is a bug, I believe.  I've run into it, it's super annoying (and occasionally devastating).
Unfortunately, I have never seen anything from the UI/options that would help in either situation #1 or #2.  About the only thing you can do in these situations is to move to the closest possible cover within the blue, and then if you can't take the shot you want, either go to overwatch or possibly re-position as part of the dash with the goal of moving into a more advantageous position on the following turn.  The cover thing is especially vexing, I feel your pain there.  The game is forcing you to eyeball it; unfortunately, cover is at high enough level of abstraction such that eyeballing it is not always possible.
Note that Assaults, once leveled, are really good to use in these situations. You can move to wherever you think is best in the blue radius and then if you're unsatisfied with the results you can pop Run n Gun and advance further and then shoot (and you can even do Rapid Fire after doing a run and gun, it's quite a potent combo).


Add switches for two new lights to an existing switch box

Question: My question is a bit complex. I'll try to be short and to the point as best I can. I am trying to add two more light switches to make a total of three at a light switch. The first one that was there controls the ceiling fan in the middle of the ceiling. That was there and I had no issues. I want to install four recessed lights in the corners of the ceiling that will be controlled by the second switch. The third switch runs to an outlet that I'd like to be able to power a desk or table lamp. I already have all the wires in place as there was no drywall up and I had access to drilling through joists, etc. I just installed all the drywall earlier this week and taped it all up.
So back to the three gang light switch: I tried to "pigtail" two more times from the wiring that controlled the ceiling fan but that didn't work. Then I realized that the hot wire was actually not at the switch box at the wall but rather it was in the ceiling junction box that the fan connects to. So I'm leaving that wire connection alone and am trying to connect my two other lights to another source.

To describe what's in the photo above the ceiling fan switch is on the right (the switch is connected but hanging and not visible in photo), the middle switch will control the ceiling recessed lights and I will eventually put a third switch on the left (hoping to pigtail from the middle switch) to control power to an outlet for a lamp. The yellow Romex on the bottom left is my "mock up" to run power from the outlet below). If and once I am successful I will run it behind the drywall.
So then I tried to grab power from a nearby electrical outlet. I am enclosing photos to help with my description. When I got into the electrical outlet nearby I saw that it had two black and white wires connected into the back of the outlet. Between the two sets of black wires I located the hot wire and disconnected it from the outlet (alone with its corresponding white and ground wire). I then did a "mock test" to wire it to my second switch by using Romex to connect my second switch to the hot black and neutral wire that I disconnected from the outlet nearby. After I wired it up I turned the power on and my temporary ceiling light (where my permanent recesses lights will be installed) lit up. I thought I was successful. But here's the thing. When I tested the light switch by turning it on and off it trips the circuit and I lose power. But if I leave the light switch on and then turn the circuit back on at the circuit breaker box the power works. But once I use the light switch to test it, something is tripping the circuit and cutting off power. I have never experienced this before.

The image above shows the electrical socket pulled out from the wall. You can see a black and white wire connected to the back which I did not touch. I am not certain but I think this set of wires run to another outlet on the opposite wall. I'm almost certain. The hot black and white wires that I disconnected from the back of the outlet are now connected to my yellow Romex wire to my middle switch for my ceiling lights.
For the third and final light switch at my three gang light switch box on the wall I was hoping to pigtail from the second light (which will control the ceiling recessed lights) to power the outlet for a desk or table lamp.

Above pic shows the temporary light I connected as part of my mock up. It works when I turn the power back on at the circuit breaker box in the basement. But once I turn the light switch on and off at the wall in the room the circuit trips and the power is cut off.
Does anyone have any advice or can anyone help? Let me know if I need to further explain anything be more clear.
Comment: It's funny. You've got little fragments of semi-knowing what you are doing, among big chunks of territory of not knowing at all.  *It's almost like you're Googling this stuff*, which is a bad idea, because it gets you swiss cheese knowledge, not the *broad base* of knowledge you need to do this safely.  I generally advise people hit the library and browse their how-to-do-home-wiring section (621.31), find a book that appeals, and read it through and through.
Comment: As things are, your knowledge gaps are so large we'd have to effectively *write that book for you*, in answers.  That's too broad for our format here, but maybe I'm wrong so we'll see if answers emerge.
Comment: It's not a forum. I'd encourage you to  [take the tour](https://diy.stackexchange.com/tour) and then [edit] your question to narrow it to a single question.
Comment: As I understand it, the comments section is designed for clarification purposes; not to badger me in multiple comments reminding me that I have no idea what I'm doing. If I knew what I was doing I wouldn't be asking for help. This is a DIY forum, is it not?
Comment: Here is what it says for the DIY Stack Exchange website: "Home Improvement Stack Exchange
https://diy.stackexchange.com/
Home Improvement Stack Exchange is a question and answer site for contractors and serious DIYers. " I just looked up the definition of forum on dictionary.com and it says: "a place, meeting, or medium where ideas and views on a particular issue can be exchanged." I didn't ask multiple questions. I admit I went on loquaciously with my post but my intent was to be as clear as posssible.
Comment: Hello, and welcome to the Home Improvement site (btw, **not** the "DIY" site, despite the URL). Once you've [taken the tour](https://diy.stackexchange.com/tour), and read about what is and isn't appropriate here, and how to ask a good question, then we can talk further. Until then, @Harper is absolutely right: this is too broad for here.
Comment: And, until then, answering careful, helpful comments with "you're badgering me" isn't going to get you very far.
Comment: You call this comment, "your knowledge gaps are so large we'd have to effectively write that book for you, in answers." careful and helpful? I hope some asshole tells you this to your face the next time you go around asking for help so you can finally comprehend what I'm talking about.
Comment: By the way, I have gotten help from people here before. There is a user on here Jim Stewart with "retired master electrician" as part of his title who has been the most amazing helpful person on this site. He gave me the impression of having the most skills and never came off as belittling or insulting.
Comment: Everyone calm down. These comments seem to have gotten a bit out of hand, perhaps due to initial perceptions from a long list of "tried this, tried that" + unclear pictures. I think this is all fixable and will write up my thoughts.
Answer: There are basically two ways to wire up a switched device (light, fan, receptacle, whatever).

Switch Loop
A switch loop essentially looks like:

Panel => Device => Switch
That matches your description of the existing fan/switch. Power is at the fan in the ceiling. The hot wire (should be black, at least the part from the panel to the fan) goes past the device (i.e., does not connect to the fan directly) and connects to the switch. The other wire connected to the switch is the switched hot and connects to the hot connection on the fan. The neutral connection on the fan goes to the white wire back to the panel. Or to put it all together:
Panel hot => [through device junction box] => Switch => device hot => device => device neutral => neutral back to panel
It is possible to tap into that to power other devices, but it gets messy. Don't do it when you have another source (the receptacle you identified).

A regular switched circuit
Panel => Switch => Device

This is what you want to do here. Or more specifically:
Panel hot => receptacle => Switch => device hot => device => device neutral => neutral [through switch box] => neutral to receptacle => neutral back to panel

There are a few steps involved in your specific situation:

Patching in to the receptacle

It appears that your existing receptacle has two sets of wires. One set is backstabs (== bad) and one set on screws. Since you were able to pull power for testing purposes while leaving the backstab connections on, I'll assume those wires were on screws. You need to do the following for hot, neutral and ground:

Disconnect the backstab
Make quadruple sets of wires: Wire to next receptacle (was backstab), wire from panel (what you disconnected from screws and used to test the lights), new Romex that will go to the switch box, and a short pigtail (you can make it from wire removed from a short piece of Romex). Connect each set of 4 wires with an appropriate size wire nut.
Connect the pigtails to the receptacle. Black to brass screw (hot), white to silver screw (neutral), green to green screw (ground).

At this point I would cap the other end of the Romex with wire nuts and test the receptacle to make sure it is working correctly (ideally with a "magic 8-ball" outlet tester as a quick confirmation that hot and neutral are not reversed and ground is connected.

Receptacle to switches

This is easy. Black = hot goes to the "line" or "hot" connection on the switch. But if it is a simple toggle switch - no dimmer, timer, smart anything - then it really doesn't matter which screw gets hot and which gets switched hot. White = neutral does not connect to the switch unless you have a timer/dimmer/smart something that has a neutral connection.
Just remembered - you have two new switches. So we are back to pigtails again, specifically, black from receptacle + two pigtails to the two switches. If you need neutral for the switch (dimmer/timer/smart) then you will have white pigtails too.

Switch to device

Black goes to the other screw on the switch and at the device connects to "line" or "hot" (or colored wire if there is a short wire attached to the device). White connects to the white wire that came from the receptacle (so two white wires from the two devices connect to the one white wire from the receptacle) and at the device connects to "neutral" (or to the white wire if there is a short wire attached to the device). If you have multiple devices then you can chain on to the others with more Romex.

What went wrong?
This still leaves open the question of "what went wrong with the switch that it tripped the breaker"? A faulty switch is unlikely - a simple toggle acts as either totally open totally closed - there are only 2 wires and no "in between" settings. So unless you used a 3-way switch (designed for connecting two switches to control one device), all I can think of is that you connected the hot & neutral chained from the receptacle to the switch and then chained from the switch to the lights. Something like:
Black from receptacle -> switch brass -> black to light
White from receptacle -> switch silver -> white to light
If you did that, the light would be always on, as long as the switch was off. As soon as you turned the switch on, you would be short circuiting black & white from the receptacle and the breaker would (hopefully!) trip very quickly.
This should solve the problems, but please read up on things a bit more before just trying different cables, switches, etc. There are situations where breakers won't trip to stop a problem, either due to existing faulty wiring or due to bad breakers. Plus there are situations where even a tiny amount of leaked current can be deadly. Safety first!
Comment: Thank you for your thoughtful and detailed answer, manassehkatz. I must admit I'm a bit confused when you used characters like - >. I think the only way I could understand is through diagrams. I'm more of a visual person. I'll try to look it over and diagram it myself and see if I can get this right. I do plan on using dimmers to control both switches to the left of the fan. I appreciate your time, thank you.
Answer: I just put up drywall and discovered the supply I was counted on is actually a switch loop. How do I make this work with the wires in the wall?
The crux of the answer is getting always-hot and neutral to the switch box, so you can complete your circuit as originally intended.
Since I assume you don't want to bust up any drywall, I'll discuss options in order of practicality.
Fish a cable from a receptacle
Your test cable is on the right track.  The trick will be safely/legally routing it inside the wall and getting it properly entered into both junction boxes, without busting up any drywall.   I don't know your wall layout, so I leave it to you to decide if it's practicable. You might search for questions/ask a question about a particular routing.
This isn't worth working very hard on, though. There's a plan B.
Re-task the fan-switch cable to be supply
Right now, power comes into the fan, and the cable between fan and switch is a switch loop.  We re-task this cable to carry always-hot and neutral, and we control the fan another way.
Now that always-hot and neutral are in the switch box, we connect the switches in the conventional way.  At this point, none of the switches are switch loops, so no NEC 404.2(C) worries.
What about that fan?  We place an electronic module inside the fan dome.  The module connects to always-hot, neutral and fan-hot.  It communicates with some kind of remote using either wireless or powerline signaling.  The remote could be wireless, a smart phone, or a smart-home system ("Alexa, turn up the fan")... but my favorite is a wired remote that installs exactly where the old fan switch goes -- it looks, walks and quacks just like a wired switch (except it is using powerline comms or radio to communicate with the module).
SE is not a shopping assistance site and such answers go stale quick, but there are a variety of module/remote pairs available.
Then wire the switches conventionally
And we have lots of Q&A on that.
Now, about the fan switch. If you used the "re-task fan wires" option with a wired remote, it simply needs the always-hot and neutral that you brought down from the fan.
However if do not use the "re-task fan wires" plan, it is vital that the white and black (always-hot and switched-hot) wires from the fan remain totally separate from the other wires. If you ever want a smart-switch there which requires neutral, follow my "Re-task" plan above right now -- you must not steal a neutral from the other switches.
Grounds, on the other hand, should all be tied together.
The above will put the right wires in the right places. Noting the work I see discussed and pictured in your question, there are a number of other skill issues that would benefit from either an expert's help or some additional skill-up.  Take the time, do it right.  Those are beyond the scope of SE's Q&A format.


What are your prefered tech tools to note take during a usability study?

Question: What are your preferred tools to take notes during a usability session or UX fieldwork?
looking for creative ways to put together a list for HCI students.
there might be some cool software out there but students are on a budget.
Any good suggestions?
Comment: You might want to distinguish between real time note taking: ie recording points to pick up there and then;  and session recording for later analysis.
Comment: Welcome to ux.stackexchange; For future reference please note that the site's [usage guidelines](http://ux.stackexchange.com/about) ask to avoid "Questions requesting examples of 'X', or questions where all answers are equally valid". While my view is that questions like yours are beneficial to the community, in the future this sort of question may be closed by moderators.
Answer: For me, the single most useful software (which happens to be free) in the UX process (and often outside it) is XMind.
It is particularly good for brainstorming, quick collection of data that then needs sorting. Making it ideal in many stages of the process, like during many requirements gathering activities, or IA.
The notes feature is extremely powerful; the Markers also help (to signify priorities, for instance); and the resultant diagram can be made highly aesthetic.
It is also dead easy to learn (key features will take about 2 minutes to master).
Answer: I tend to use

pencil
paper

Sometimes a pen. If it's a nice one.
Comment: I find just writing keywords is still the best way to note stuff down that I want to investigate there and then.
Answer: I am a fan of using Evernote's recording feature. It still requires translation down the line, but used in conjunction with a peer note taker, it can help fill in the gaps so I can pay attention to user behavior.
Answer: Power Point
I usually just use Power Point. Here is how the study usually goes:
Power Point contains a script (overall intro) and a separate page for each user task. When user is performing a task, I put notes right where the corresponding task is in the Power Point. That allows keeping all of the notes organized per task.
Pros compared to pen and paper:

I can still watch the user while typing and can type faster than write. Personally, it's hard for me to write and look at what the user is doing.
Less time organizing notes after each session since they are already in electronic form.
If you are not the one taking notes, it's easier to read typed notes that someone's handwriting.

Camera (e.g. GoPro)
Recording videos helps if you really need to pay attention to how the user is moving. If you are taking notes it's hard to catch all little details. For example, we recently tested some driving scenarios and camera was a must to capture driving impact. Watching videos after the session helped to add additional notes that I didn't catch while observing initially. But for a lot of studies, recording a video is an overkill. It takes a lot of time to watch the sessions.
Answer: As well as recording video I run a backup audio recording.
Because having a backup version is a good idea...particularly on people who are expensive to recruit.


UnknownFormatConversionException in a program that prints a percentage

Question: I have to write a program where I put in baseball stats and it comes out with slugging % batting avg and re says the name of the player then put it on a sentinel loop. My current code is below. I'm trying to get it to work with just one before I turn it into a loop. When I run to test, I get UnknownFormatConversionException. What does it mean? How can I fix my code?
import java.util.Scanner;
public class bata
{
    public static void main(String[] args) throws Exception
    {
    double ba,sp,tb;
    int tri,dou,sin,hr,ab,hits;
    String name;
    Scanner sc = new Scanner(System.in);
    System.out.print("Enter Singles");
    sin = sc.nextInt();
    System.out.print("Enter Doubles");
    dou = sc.nextInt();
    System.out.print("Enter Triples");
    tri = sc.nextInt();
    System.out.print("Enter Homeruns");
    hr = sc.nextInt();
    System.out.print("Enter At bats");
    ab = sc.nextInt();
    System.out.print("Enter Player name");
    name = sc.nextLine();
    System.in.read();
    tb= (sin + (dou*2) + (tri *3) +(hr *4));
    hits = sin+dou+tri+hr;
    sp= tb/ab;
    ba= hits/ab;
    System.out.println(""+name);
    System.out.printf("Slugging % is %.3f\n", sp);
    System.out.printf("Batting avg os %.3f\n", ba);
    }
}

Comment: Tertiary to this question, Google "Java Language Specification 15.17.2" for a discussion of the division operator.  That might save you from a SO question in the near future.
Answer: Escape % sign,by using double %%:
System.out.printf("Slugging %% is %.3f\n", sp);
//                           ^------------- escaping

Comment: @edholland Are you looking for this-> `System.out.printf("Slugging %% is %.3f for %s\n", sp, name)`?
Comment: this fixed my first problem thank you i m new so sorry if i screwed so many things up but now how do  i get the player name to print with the batting and and slugging percent. Again i m totally new and i m probably making stupid stupid mistakes
Answer: UnknownFormatConversionException happens when you are expecting an integer and read a string from your scanner. It would be helpful if you could post your input file.
Also, escape the % sign using another %.
  System.out.printf("Slugging %% is %.3f\n", sp);


how to create openCL test that run on multiple devices

Question: I'd like to have questions about how to create openCL test that run on multiple devices
Assume I want to create an openCL program that calculates the expression AB + CD,and  this is what I think of

Create 3 kernels , one for AB, one for CD, and other for M + N (AB+CD)
Create a host code that do 3 tasks in parallel and each task to run in different device but I dont know how to assign specific device for a single task

Please help me
Thank you
Comment: where did you stop? did you select platform and devices then select queues but couldn't assign tasks to those devices?
Comment: which version of opencl? What kind of devices? What kind of work distribution?
Answer: OpenCL is, all things considered, a pretty explicit API. It asks you to specify a specific device when creating a context, and it asks you to specify a specific context when creating a queue. So in the most literal terms, accomplishing your task is as simple as
//This is going to be pseudocode; I'm not going to look up the literal syntax for this stuff
//It is going to closely resemble how you'd write this code in C++, though
std::vector<_type> perform_tasks(cl_device_id ab_device, cl_device_id cd_device, cl_device_id n_m_device) {
    cl_context ab_context = clCreateContext(ab_device);
    cl_context cd_context = clCreateContext(cd_device);
    cl_context n_m_context = clCreateContext(n_m_device);
    cl_command_queue ab_queue = clCreateQueue(ab_context, ab_device);
    cl_command_queue cd_queue = clCreateQueue(cd_context, cd_device);
    cl_command_queue n_m_queue = clCreateQueue(n_m_context, n_m_device);
    cl_kernel ab_kernel = get_ab_kernel(ab_context, ab_device);
    cl_kernel cd_kernel = get_ab_kernel(cd_context, cd_device);
    cl_kernel n_m_kernel = get_ab_kernel(n_m_context, n_m_device);
    set_args_for_ab(ab_kernel);
    set_args_for_cd(cd_kernel);
    set_args_for_n_m(n_m_kernel);
    cl_event events[2];
    clEnqueueKernel(ab_queue, ab_kernel, &events[0]);
    clEnqueueKernel(cd_queue, cd_kernel, &events[1]);
    //Here, I'm assuming that the n_m kernel depends on the results of ab and cd, and thus
    //must be sequenced afterwards.
    clWaitForEvents(2, events);
    copy_ab_and_cd_data_into_n_m_buffers();
    cl_event n_m_event;
    clEnqueueKernel(n_m_queue, n_m_kernel, &n_m_event);
    clWaitForEvents(1, &n_m_event);
    return copy_n_m_data_to_host();
}

But there's a bigger question that needs to be addressed, which seems to have gone unconsidered by your question: Why?
What kind of performance gains are you expecting to gain from this kind of logic, rather than simply writing something like the following, executed on a single device?
kernel void ab_cd(global _type * a, global _type * b, global _type * c, global _type * d, global _type * output) {
    long id = get_global_id(0);
    output[id] = a[id] * b[id] + c[id] * d[id];
}

With the kind of program logic you're proposing, you're going to incur unavoidable overhead from simply trying to transfer data between different devices (which would occur inside copy_ab_and_cd_data_into_n_m_buffers() in the pseudocode I described). If you're committed to using multiple devices for this kind of program, it's still simpler (and probably more performant!) to write something like this:
//Again; using pseudocode. Again, gonna look like C++ code.
cl_event perform_tasks(cl_device_id device, cl_context * context, cl_command_queue * queue, cl_kernel * kernel) {
    *context = clCreateContext(device);
    *queue = clCreateQueue(context, device);
    *kernel = get_kernel();
    cl_event event;
    clEnqueueKernel(queue, kernel, &event);
    return event;
}

int main() {
    std::vector<cl_device_id> device_ids = get_device_ids();
    std::vector<_type> results;
    std::vector<cl_context> contexts(device_ids.size());
    std::vector<cl_command_queue> queues(device_ids.size());
    std::vector<cl_kernel> kernels(device_ids.size());
    std::vector<cl_event> events;
    for(size_t i = 0; i < device_ids.size(); i++) {
        events.emplace_back(perform_tasks(device_ids[i], &contexts[i], &queues[i], &kernels[i]));
    }
    clWaitForEvents(events.size(), events.data());
    for(cl_command_queue const& queue : queues) {
        std::vector<_type> result = read_results_from_queue(queue);
        results.insert(results.end(), result.begin(), result.end());
    }
    //results now contains the results of all executions
    return 0;
}

Unless you're working with FPGAs, or dealing with a particularly exotic workload, where it's absolutely essential to have different devices doing different work, you're probably just creating more work for yourself than you need to.
Comment: Thank you Xirema, I am working on a openCL test that run on multiple FPGA devices so it is really causing me headcahe
Comment: @tpham1002002 Wait, you actually *are* dealing with FPGA's?? Huh. Well, as I mentioned, the first code I provided will deal with that model. Bear in mind though that my original assertion still applies: there are very few scenarios where it makes sense to split a single calculation across multiple devices, especially if the sub-components of that calculation are similar between devices.


PriorityQueue Constructor in Java

Question: Given the example code:
Comparator<Node> comparator = this.createCompartor(algorithmChoice , matrix);

this.m_openList1 = new PriorityQueue<Node>(100, comparator);

What does the 100 in the PriorityQueue constructor stand for?
Comment: Did you try to read the documentation? http://docs.oracle.com/javase/1.5.0/docs/api/java/util/PriorityQueue.html
Comment: @Itay In future I would provide the Java 7 Javadoc as Java 6 is almost end of life. ;)
Answer: It's the initial capacity of the PriorityQueue. You would generally specify the initial capacity explicitly if you knew before hand how many items you were going to add (or had an approximation).
This can also be seen in the documentation:

public PriorityQueue(int initialCapacity, Comparator<? super E> comparator)
Creates a PriorityQueue with the specified initial capacity that orders its elements according to the specified comparator.
Parameters:
  - initialCapacity - the initial capacity for this priority queue.
  - comparator - the comparator used to order this priority queue. If null then the order depends on the elements' natural ordering.
Throws:
  - IllegalArgumentException - if initialCapacity is less than 1

In fact, most collections in Java have constructors that take an int argument specifying the initial capacity.
Comment: I am not getting what exactly the initial capacity mean here. Could you please explain it in bit more detail?  Does it mean there can't be more items than that value?

PriorityQueue Constructor in Java


Minisplit ductless communication wire question

Question: Simple question and I am obviously missing something, but the manual calls for 14/4 to be used as the communication/power cable.  That is 1 wire for communication, 2 hot wires and lastly one for ground.  Could I simply use 14/3 w/g - that is your typical romex? The only difference seems to be with the romex the ground is a bare wire.
Thanks in advance!
Comment: 14/4 is not the same as 14/3.  If they wanted you to use 14/3 they would say so.
Comment: @Harper-ReinstateMonica -- the mini split makers are not accounting for the quirky way North American mains cables are spec'ed
Answer: This is because most mini splits are meant for a global audience
One of the quirky things about mini-split air conditioners is that they are basically the air conditioner of choice if you want central air conditioning outside of North American and the existing installed base in places like Europe and Australia.  North American-style split systems simply aren't used in the rest of the world, for a variety of reasons that have largely to do with space and efficiency, and as thus, mini-split manuals are written for a global audience, not a US one, even when written in English by major global manufacturers who are used to selling to North America (such as Mitsubishi).
One artefact of this is that they often specify cables in a way that's only crudely translated to US nomenclature.  Most of the time in the rest of the world, something akin to a tray cable is used, and in tray cable nomenclature, the green wire is counted among the wires of the cable, as it may or may not be necessary as an equipment grounding conductor, depending on the application of the tray cable.  However, Exposed Rating/Joist Pull rated tray cables (designated TC-ER-JP), the only ones that can legally be used without conduit in a dwelling unit application under the NEC (as per NEC 336.10 point 9), are thin on the ground from what I can tell; many HVAC sellers will try to sell you tray cable as "mini-split cable", but it's not appropriate for the application.
So, I'd run individual 14AWG THHNs (black, black, red) up the flex whip to the disconnect box, then tie them into 14/3 W/G NM at the AC disconnect with black and a remarked white for the hot wires in the NM cable, red for the comms wire, and the ground of course tied to the disconnect's ground terminal.  Then, this 14/3 W/G NM can be run to the indoor unit, just like you would run any other mains circuit. (Of course, if you're under codes that prohibit NM, you can substitute a MC or AC cable instead, or individual 14AWG THHN wires in metal conduit for that matter.)
Comment: Thanks for the thorough explanation! And the idea of tying up the romex and THHN in the disconnect.
Comment: Also, the manual appears to call for a fused disconnect - the place I bought it from did spec out a nonfused disconnect.  I thought might double check because not sure why the fused disconnect when it is on a dedicated circuit.  That coupled with finding a 45Amp disconnect is very difficult.
Comment: @ecco88 -- do you have the unit in front of you (so you can look at its nameplate), or has it yet to arrive/be ordered?  (And if you did need a fused disconnect, those only come in two sizes, 30A and 60A, corresponding to the two smallest *case sizes* available for ordinary (Class RK5) mains fuses
Comment: Yes delivered - lg lmu420hhv
Comment: @ecco88 -- does the outdoor unit's nameplate say "maximum *fuse* size", or does it say "maximum OCPD size" or something like that that doesn't explicitly state "fuse" by itself?
Comment: MOP - 45 A. MCA 30.2A
Comment: @ecco88 -- then you don't need a fused disconnect since you don't *need* fuses for overcurrent protection
Answer: I just finished wiring a Fujitsu mini-split system for my son's new house build (3 indoor units and one outdoor unit). The wiring was very simple:  14/3 with ground between the indoor units and outdoor unit. 10/2 with ground to the outdoor unit from the panel.
As others have said: these are international units and the English versions of the manual use odd terms.   For instance a GFCI is an "Earth Leakage Breaker", a ground wire is an "Earthing wire".
Regarding the fused disconnect, yes, the installer wanted a disconnect with actual fuses, not a circuit breaker and certainly not a simple switch.
Last year I also wired up a Mitsubishi mini-split for a home my mother owns. If I remember right there was a very convenient color coded cable (4 conductor, I think), that made it super simple to connect. I believe it was all low voltage.  If the OP wants, I could research again, but the install manuals should clearly show what the cabling requirements are.
What brand mini-split is being installed?
Comment: LG - LMU420HHV is the model of the condenser.
Comment: I just spent a few minutes in the installation manual for your unit and the English is terrible. One of the worst I've seen,  IE:  quote from manual: "Also when handling storage, pipe must be careful to prevent a fracture, deformity and wound"  The specs for the wiring are unclear.  The OP will probably have to contact an experienced installer to sort this out.
Comment: SMH, how do these manuals get past the UL Listing process or other competent NRTL?   Is this some GATT thing we have to do, accept their foreign certification as they accept ours?  At least ours are any good.
Comment: Fully agree Harp.  While I've run across a few odd terms here and there like "earth leakage breaker", at least it's just a different name for something and we just have to sort out the terminology.  But the LG manual for the condenser had terrible English throughout it.   If you want a good laugh and be disgusted at the same time, see if you can run down a copy of it. It's bad. And the "warnings" and "cautions" are like "don't let it fall on you", etc.
Comment: OK, I know we aren't supposed to chit chat here, but begging some tolerance from the moderators during this frustrating lockdown time.    Here is one of the "best" cautions I read in the manual:  "Do not use an appliance for special purposes such as preserving animals vegetables, precision machine, or art articles.
- Otherwise, it may damage your properties."     Let's just say it never would have occurred to me to use a mini-split system condenser to preserve animals vegetables,..etc.   LOL


How often do criticals happen in Fruit Ninja?

Question: I know that criticals are random occurrences that give an additional ten points, and I know how to get them.
However, what are the odds of getting the additional 10 points? How often do criticals happen in Fruit Ninja?
Comment: Welcome to the arcade! [This question](https://gaming.stackexchange.com/questions/41270/how-do-i-get-critical-hits-in-fruit-ninja-and-what-are-they) should shed some light on the subject.
Answer: All we know is that it is random. Unfortunately, there are a lot of ways a game developer could program in random, some of which could rely on elements in the same environment that would drastically differ from player to player. As a result, we can only really approximate the chances, and we can only really do so by playing the game and working out how frequently they come up.
At present, it appears the critical chance rate on Android rests at about 2-3%

Android
I installed the game on my Android phone, and played ten matches. Here are my results:

Round
Final Score
Critical Cuts
Rough Score at Critical Cut

1
10
1
1

2
50
1
45

3
60
1
50

4
140
2
73, 105

5
126
3
29, 59, 109

6
119
2
36

7
147
4
39, 56, 126, 146

8
28
0

9
141
3
18, 54, 125

10
83
1
27

Based off these rough numbers, we can see I get a critical between roughly every 30th and 50th cut. That equates to between 3.33% and 2%, with an average of roughly 2.5%.
As I have time, I will do more tests. If the numbers change in larger quantity, I will let you know; it is also entirely possible that the random number generator in my version of the game will give me better or poorer odds based off environmental changes that can not easily be replicated by other players; and not for any particular reason, either. Simply because that is how random number generators work in video games.


Code behaviour changes when replacing internal .JSON with AJAX request

Question: I've replaced my internal .JSON with an AJAX request and now my code stopped working properly. My goal is it to write a chrome extension that closes a tab if its link contains certain keywords saved in the .JSON file. This is what the code looked before:
chrome.webNavigation.onCompleted.addListener(closeTab, {
  url: [
    {urlPrefix: 'https://www.google.de/'},
    {urlPrefix: 'https://sghm.eu/iserv/login'},
  ]
});

function closeTab(e) {
  if (!e.frameId) {
    chrome.tabs.remove(e.tabId);
  }
}

This code worked for me.
Now the new one:
var obj = {};
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function(){
    if(xhttp.readyState == 4 && xhttp.status == 200){
        obj = JSON.parse(xhttp.response);
        console.log(obj);
    }};
    xhttp.open('GET', "banned.json", true);
    xhttp.send();

    chrome.webNavigation.onCompleted.addListener(closeTab, obj);

    function closeTab(e) {
      if (!e.frameId) {
        console.log("Hallo2");
        chrome.tabs.remove(e.tabId);
      }
    }

And the banned.json file:
[
    "www.google.de",
    "www.youtube.com/?gl=DE"
]

This code now closes every tab disreagarding the link or antything else. But I don't know why. The AJAX works as the console successfully displays the JSON array, which was previously loaded.
Comment: `XMLHttpRequest` is asynchronous ... so `chrome.webNavigation.onCompleted.addListener(closeTab, obj);` is called with `obj` === `{}` - because the xmlhttprequest isn't yet even called, let alone responded
Comment: you may also notice that the code that works, the object is `{
  url: [
    {urlPrefix: 'https://www.google.de/'},
    {urlPrefix: 'https://sghm.eu/iserv/login'},
  ]
}` .. but the object you get from your XHR is `[
    "www.google.de",
    "www.youtube.com/?gl=DE"
]` - which is clearly not the same
Comment: See also [Why is my variable unaltered after I modify it inside of a function? - Asynchronous code reference](https://stackoverflow.com/questions/23667086/why-is-my-variable-unaltered-after-i-modify-it-inside-of-a-function-asynchron)
Comment: If that would be my mistake, in which I don't really believe in, because it doesn't work if I change it to synchronous as well, how would I solve this problem?
Comment: @Jaromanda: if I change the json to exactly what you've posted I will get an Error from chrome that states: ``Uncaught SyntaxError: Unexpected token u in JSON at position 4``
Comment: because you're getting `undefined` somewhere
Comment: but why and were
Answer: Are you sure that obj isn't still empty when you hit this line?:
chrome.webNavigation.onCompleted.addListener(closeTab, obj);

You may reach there before xhttp.readyState == 4 && xhttp.status == 200 evaluates to true (because the onreadystatechange callback function runs asynchronously).
Have you tried moving the above line just underneath console.log(obj); in your onreadystatechange callback function?
Comment: Thanks for your suggestion, but I've also put a ``console.log`` in the ``closesTab`` function before and it printed the array into the console. Furthermore I changed AJAX to a synchronous request by by changing this line ``xhttp.open('GET', "banned.json", true);``to ``xhttp.open('GET', "banned.json", false);``


How to fix washing machine door handle

Question: A door handle on my Bosch washing machine is broken and I am trying to replace it. I have bought a replacement handle, but swapping the two is not as easy as I hoped it would be.
It consists of 2 parts, small one (part A) that goes through the hole in the door frame and the handle itself. I am able to fit it with the broken handle, because the part of the handle that the metal pin goes into is broken therefore I am able to move it enough to put the small part though the square plastic bit in it. Top metal pin I don't have, and I hope handle would still be functional without it.
What I tried to do with the new handle is:

put the bottom metal pin into the handle (pin slides out of the frame easily)
put the small plastic hook into the door frame (part A)
put the handle (with the pin) into the frame
connect the small part (A) with the handle (put the back hook into the handle)

Part A

Frame with the pin in, with no part A nor handle

Part A in the frame, marked spot is what goes into the handle hole

Part A in the handle, you can see where the handle is broken at the bottom so the pin does not stay in place

Is the 1 - 4 method above correct?
Do I maybe need to take the whole door frame apart to fix the handle?
Answer: I am suspicious your fix will not work unless you fix this (arrow).

Your handle is meant to have a top and bottom pin.  Those transmit the pull forces equally to the top and bottom of the door.  Your top pin is gone and the plastic there has cracked.
If you have the handle with only the bottom pin it will pull asymmetrically and pull the top forward.  It will not stay.  If you substitute some sort of top pin (a bolt with a nut would probably work) the problem is that the plastic of the frame is cracked and the bolt will pull loose or worsen the crack with use of the handle.
Fixing cracked structural plastic is not easy.  You cannot just glue it together because the forces on that area will (again) crack thru the joint.  You would need to reinforce it with some overlay.  Before I embarked on that I might see if there were a dead washing machine of the same make at the washing machine junkyard, and take the whole door off of that.  You might be able to fix the cracked plastic with a layer of epoxy over fiberglass mesh to reinforce over the crack but you need to make sure that the fix does not bulk it up such that it cannot clear other things in its path when you close it.
Comment: Thank you for your answer. I will try to source the top pin as well, and I don't mind bit of duct tape for now. But even with the another pin, I am unsure if door frame needs to be taken apart to insert the handle, therefore I will leave the question open.

How to fix washing machine door handle


Is it crucial for a UX designer to understand the principles and concepts behind Object Oriented Programming?

Question: As a designer and sometimes coder myself, I have been exposed to the idea and principles behind Object Oriented Programming, and having a knowledge in this area definitely helps when it comes to conceptualizing screens for proposed software applications. Developers would immediately get the gist of the screens.
I'm curious though if the knowledge of a designer of OOP would have a big impact when it comes to User Experience Design? What kind of scenarios would it be a huge factor in the effectiveness of a design? Are there any instances where it is?
Comment: OOP has literally nothing to do with UX.
Comment: OOP is an implementation _detail_. It has nothing to do w UX.
Comment: It looks like you're confusing OOP with some kind of component architecture. I found that it really helps when the design team understand how the devs team create (sometimes reusable) components. We then get coherent screens and less micro-differences we need to implement for a million edge cases.
Comment: It might not be crucial for UX Designers to understand OOP, but it IS crucial for designers and developers to share a common understanding/language for communication design and implementation details.
Comment: There's a newly emerging discipline called Object-oriented UX - https://www.objectorientedux.com .
Comment: Software developers should forget most of the principals of OOP and move to a more functional style of programming. Composition over inheritance.
Comment: Reactive Programming does not use OOP at all (it uses Flux, go watch some talks on it from the creater, do not bother with the Redux BS), and it's used at Instagram and Facebook and many other companies.
Comment: Practically speaking, there is some overlap. At the very least, your Visio skills will come in handy for both.
Answer: No.
Those are two fundamentally different jobs. Except in the scenario that the UX design is for a product the primary purpose of which is OOP development (e.g. an IDE).
Otherwise, of course, there is no harm to knowing the "principles" of OOP. Further, knowing about a broad range of different things (including OOP) can certainly help you to think differently. But it is equally important to understand that OOP is just one of many approaches to programming, there are others (e.g. functional programming).  But to get to a level where your skills are actually useful in a production environment, you need a lot of practice/experience as a programmer.
On the other hand, there are designers, who out of their own personal interest, learn programming and get good at it. But that's the same as a marketeer learning programming and getting good at it.
This is a fantasy that some hiring managers and many recruiters tend to have - that they need to hire genius all-rounders for all jobs. Usually, it reflects a lack of understanding of the role they themselves are hiring for.
The only (rare) situations where it is useful is in extremely small product teams and barebones startups. Even then, it is far more practical to have a programmer who can do some basic design work, than the other way round (designer moonlighting as programmer). It is easier to have a programmer do a crash course on design and get them to do some basic design work, but a crash course in programming won't make your skills actually useful for anything other than building simplistic toys/prototypes.
"Developers would immediately get the gist of the screens."
That is not the job of the designer. Products are designed so that the users, not the developers, immediately get the gist of things. The designers' customer is the user, not the developer.
As a practical example, consider Jony Ive, the legendary ux/ui designer. It is easy to check that he is in no way a qualified developer. One can assume that degree courses in industrial design are meant to prepare people to work as designers. It is easy to check if the curricula of some of these courses include any real OOP/programming content (they don't).
Here is a quote from Don Norman, the guy who invented the term ux

I invented the term because I thought human interface and usability
  were extremely good. I wanted to cover all aspects of the person's
  experience with the system including industrial design graphics, the
  interface, the physical interaction and the manual. Since then the
  term has spread widely, so much so that it is starting to gain its
  meaning.
Comment: You are right that for a dev venturing into design, there are similarities which can make learning by analogy easier.

But as it is phrased, the question is from the perspective of someone whose primary skill is design. Their design training would already have exposed them to all the aspects of design (personas/stories/etc.).

Also, OOP is more about inheritance, polymorphism, etc. UML is more about software architecture. I can do UML for a Haskell/Erlang project - which is really not OOP, but functional.

I think it is a question of software architecture/design vs. product design.
Comment: **That is not the job of the designer. Products are designed so that the users, not the developers, immediately get the gist of things.** *This*. Ultimately you're developing for a group of people who will use your product. That is what you create your product for. If something is better to develop for a developer, but has the effect of the end user having a harder time understanding your product, then where are you keeping UX in account?
Comment: Aren't the actors defined in UML similar to the users and personas in UX Design? and aren't the interaction diagrams used in UML similar to describing the user journey? These techniques are often used in OOP to describe problems and solutions, and for a developer venturing into UX design it wouldn't be the worst way to familiarize themselves with some of the fundamental concepts.
Comment: @Yogesch Indeed, but this does not go just for programmers, but for **ANYTHING** one might use a tool for. If doing the UX for an accounting tool, it helps to have done the books, a CAD tool, you really want to have designed something in CAD, music software, you want a musician... I am not sure that training someone with task domain skill in UX design is not actually the easier route. The result will be imperfect, but will work the way someone from that background expects it to work, and 'Least Surprise' has a quality all of its own.
Comment: In case someone misunderstands the applicability of UML to functional programming, I should clarify that while UML is mostly used by OOP programmers and is not common in FP (mainly because FP works at a higher level of abstraction than OOP) the design (not implementation) related parts of UML (use cases, activities, etc.) are just as useful in FP as in OOP. But that's a very different discussion, https://stackoverflow.com/questions/2457903/can-uml-be-used-to-model-a-functional-program and https://www.quora.com/What-is-the-equivalent-of-a-UML-class-diagram-when-designing-an-Erlang-system
Comment: @Condor Far more important is that the UX designer have Task domain knowledge relevant to what the User is trying to achieve. If you are designing the steering column for a car, it is useful if you already know how to drive, not so?   This applies just as strongly in software, and no, specs or even watching someone doing whatever the job is are no substitute. I have been 'blessed' by using software from both sorts of designer and one was pretty and obvious to a newbie, the other had a command line that actually helped me get my work done (And was scriptable).  Guess which one got more use...
Comment: @DanMills I think you're raising a nice point... so in the scenario that a ux designer is doing a product for programmers, he should have a good enough idea of how programmers go about their job.. and the most practical way of doing that is by having been a decent programmer themselves.
Comment: @DanMills Yeah, I agree. Since this answer seems to have become the top voted, I am updating it to reflect this ^.
Answer: Perhaps not so much learning the principles, but understanding the principles of Object Oriented Programming or the equivalent does help with some aspects of UX design.
The short answer would be NO (i.e. it is not crucial), but the long answer would be YES because by developing a process that helps you articulate the relationship between different entities within a business process or workflow, it helps you make very strong connections between people, process and technology.
There are techniques common to OOP such as using UML (Unified Modelling Language) to document the actors (i.e. users), processes and the swim lanes to understand the different roles and responsibilities people play within a business process that also overlaps with BPMN (Business Process Modelling Notation) that are particularly useful for documenting technical details that can be translated into design decisions on the user interface side of things.
There are concepts in OOP such as inheritance (relating to the definition and instantiation of classes) that can help reinforce ideas of modularization and progressive enhancement in design assets for your design systems.
Of course, there are alternative approaches to OOP in helping you to conceptualize and document information and requirements in a structured way, but because UML and BPMN are so prevalent in the business analyst and software development circles (and because UX design doesn't really have its own standard methodology for this), it is quite worth investing some time to at least understand the core principles.
Comment: I'd disagree with the suggestion that UML is somehow related to OOP. It isn't - you can use UML *without* OOP - a use case diagram shows how an actor would use something. The actor could be a user, it could be an automated system. There is, however, no OOP concept in that, as it's very abstract and very focused on *usage*. Entity relationship diagrams also have nothing to do with OOP - mostly used for mapping out databases but can be used foe even more abstract relationships. UML is orthogonal to OOP.
Comment: +1 Good asnwer! You don't have to learn OOP, but understanding it's principles can certainly help in UX design.
Comment: @MichaelLai I think you are quite right that knowing UML etc. will give devs and designers some common ground. It also helps when ux designers have a basic understanding of software architecture - but that is UML, not OOP. If the question replaced OOP with UML, we'd agree about everything ;-D
Comment: Thank you for your detailed answer Michael! I have learned new things (UML and BPMN) and also I like how you delivered the long answer and how it helps UX design in general.
Comment: @VLAZ you are correct. You can use UML without OOP (and vice versa). It is not the actual method or process that I am emphasizing here, but the principles in UML and OOP that help us describe problems and solutions in a consistent way. The same could be said for UX Design and Design Thinking - you can do UX Design without Design Thinking, and you can also apply Design Thinking without doing UX Design. However, you will find that most UX Designers practice some of the elements of Design Thinking, just as UML encapsulates aspects of OOP.
Answer: As someone who works as a designer and knows OOP languages, I think some of the philosophies of OO kinda help with understanding structure, particularly if you're getting into SCSS and modularizing your design to create reusable chunks of content. But that's not really  OO, but more understanding of variables and basic programming concepts (like keeping it DRY).
Overall, depends on your role as a designer but I think the challenges you face in OOP like Dependency Inversion and SOLID principles don't really overlap with your ability to do UX well.
Comment: Any thoughts on the concept of design tokens and how it is (or isn't) helping to bridge the gap between design and development?
Answer: I'm a web developer and darn good at what I do. I once applied to a mechanical engineering company to re-build their lousy web site which was originally created by a mechanical engineer part-time. To get the job, I had to take a mechanical test. Most of the things on the test I had never even heard of before much less knew how to answer. (It mostly tested on hydraulics, metal folding and such.)
Would passing that test make their web site work better? No.
Object Oriented Programming is computer science and the purview of Programmers and not User Interface designers.
This whole idea nowadays that everyone needs to know programming is insane.
Comment: I don't think everyone needs to know programming, but there are probably a few too many projects out there where the designers are asked to design things that can't be easily implemented. The fact that there are more full stack developers compared to full stack designers suggests that more developers are being asked to know how to design.
Answer: Wow, a satisfying thread. There is often a debate in modern society - should a designer be able to programming?
Personally, I think that knowledge of programming patterns or concepts (OOP) is necessary to become a high-class designer.
Why do I think so?

You can model the database in cooperation with a back-end developer. (Creating models)
The design process is differently, knowing that the interface will be programmed, attention is paid to the whole process, and not only until it is passed for implementation with the "cope for yourself...
Cooperation with a front-end developer is a pleasure when it affects
the final solutions, and you can provide it with sample animations
on Codepen.
Programming helps to create scalable systems, in addition to see that a photo is only a string of bits, depending
on what the user provides, not a great aesthetic photography.

It depends on the scale and phase of the project, but there is always a issue of specialization.
However, it seems problematic that companies often treat UI Design as a sales tool - and later there are usually implementation costs / unforeseen scenarios.

As Michael said, real design begins on UML + BPMN.
Comment: I think that having a common or shared understanding between business analysts, designers and developers can only be good for any complex projects. Leaving aside legacy systems, these days most business aspire to take a customer-centric business model and develop their products and services around it. Soon business systems and business logic will start to align with the mental model of users, and this is where roles like a UX/BA and also UX Designers assisting with business requirements are more common. All the points that you have made are very valid, yet we don't see it done often enough.
Comment: I'm glad you are satisfied with the thread. Your answer sheds light on my thoughts about programming patterns helping design. I agree with it helping with the scalability of systems, and I also think it gives a basis and solid foundation of the data presented within the screens themselves.
Comment: Yes, so often the processes and operation evolves depending on the client's needs / user requirements.
I also think that this way it will progress.
Answer: One thing I would add to this conversation is that UX designers should also understand how a webpage is marked up as well. Too many designers don't realize that divs are containers, that one can move containers around but one can't readily pull these containers apart. This lack of understanding often comes up when discussing media queries and break points.
Take the example of a three-columned site with content in each each column. Assuming each column is it's own container UX designers SHOULD know that one cannot pull apart the content within each of the columns and place them elsewhere.
I cannot tell you how much time and energy is wasted dealing with designs that cannot work for just this reason.
Answer: Other answers have basically said "no, but there's no harm in knowing it". I'd like to challenge that and suggest that not only do UX designers not need to know OOP principles, but they should not do UX design from a perspective of having been freshly exposed to OOP principles or long-term infatuated with them. UX design has nothing to do with OOP, but it's easy to do bad UX design around how the computer/programmer organizes data rather than what's meaningful to users of the system. This can be found in all sorts of desktop and web apps done by inexperienced UX designers or programmers with no background in UX design, where the UI ends up being just a thin wrapper around a database and it's painfully obvious that that's what it is.
Answer: I don't agree with the answers, especially with the one that has most votes. It is 2019 outside and the industry is developed enough to blur the borders between the roles.
In short, UX Designer + Programmer = UX Engineer
A role description from Google Jobs:

As a UX Engineer, you'll weave together strong design aesthetics with technical know-how.
You'll partner with researchers and designers to define and deliver
new features, translate concepts into living, breathing prototypes,
and iterate on interactions, animations, and details to deliver the
perfect experience. UX Engineers also collaborate closely with UX
Researchers to user-test new concepts and assist engineering.

Because the UX engineer is hands-on with the actual implementation, he has even deeper insights on the user experience and user interaction. He is tweaking the tiniest settings that distinct the great experience from good experience. He is an innovator as well because he knows the constraints and looking for ways to go beyond them. So the answer should be definitely YES, knowing programming have a huge impact on your efficiency, your product and your salary ;)
Further reading on the topic:
Who is a "UX Engineer"? by Alex Ewerlöf


How do I set the animation color of a LinearProgressIndicator?

Question: The LinearProgressIndicator documentation helpfully displays the existence of a valueColor property and even mentions "To specify a constant color use: new AlwaysStoppedAnimation(color).", but if I try to set the color I get an error that LinearProgressIndicator has no instance setter for valueColor and the constructor for the class only accepts a key and a numerical value for the progress amount.
If I want a LinearProgressIndicator with a custom color do I need to create my own class? Is there really no way to specify this?
Answer: If you want to set a constant color you can use :
CircularProgressIndicator(
  valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
)

Answer: Looks like it's controlled from the Theme's accent color:
https://github.com/flutter/flutter/blob/b670ce4bcc49bbab745221eae24fcebcbc9dba7c/packages/flutter/lib/src/material/progress_indicator.dart#L61
Wrap the relevant subtree in a modified Theme setting the accentColor to whatever you might like.
Answer: LinearProgressIndicator(
    backgroundColor: Color(0xFFB4B4B4),
    valueColor: AlwaysStoppedAnimation<Color>(Colors.green),
)

Answer: I think you can provide in the below way,
LinearProgressIndicator( valueColor: AlwaysStoppedAnimation<Color> (Color(0xFFA86E52)),),

Answer: LinearProgressIndicator(
      backgroundColor: Colors.black,
      valueColor: AlwaysStoppedAnimation<Color>(Colors.yellow)  ,
      color: Colors.red,
      minHeight: 10,
),


Dynamically update dataTable Row Count

Question: I'm trying to update the row_count of my dataTable upon retrieval of data
I create an empty dataTable and render it myDiv:
var dataTable = new Y.DataTable({
            columns: columns,
            footerView:   Y.FooterView,
            footerConfig: {
                fixed:   true,
                heading: {
                    colspan:    3,
                    content:    "Number Records : {row_count}  "
                }
            }
        }).render("#myDiv");

On the click of a button, the dataTable gets populated by an IO request.
var node = Y.one('#searchButton');
node.on(
            'click',
            function() {
            dataSource = new Y.DataSource.IO({source:'mySource'});
            ...
            //code to set data in dataTable
            ...
            size = dataTable.data.size(); //retrieves the number of records, but row_count in the footer of course remains '0'

How could I dynamically update the footerView content's 'row_count' to reflect size?
Answer: Rendering my table on 'click' of #searchButton fetches the number of rows and displays them within the table:
var node = Y.one('#searchButton');
node.on(
    ...
    dataTable.render("#myDiv"); //renders the table to the Div, # of records and all

Dynamically update dataTable Row Count


How to parse JSON string with array in php

Question: I am sending a JSON string in php post request. JSON string look like this:
{"mobile":"0000000000","otp":"970996", "items":[{"pid":"12", "vid":"20"},{"pid":"13", "vid":"2"}]}

At server side i want to get mobile, otp and pid and vid for all items.
I am getting mobile number from this:
$data = json_decode(file_get_contents('php://input'), true);
//print_r($data);
echo $data["mobile"];

But when i am trying to get pid and vid like this:
foreach($data["items"] as $mydata){

     echo $mydata->pid;
}

i am getting error: Trying to get property of non-object.
How to solve this?
Edit:
If there is any better way to parse JSON in php, please suggest that also.
Comment: try `echo $mydata["pid"];`
Comment: You've already used array syntax for `'mobile'`, why are you suddenly switching to use object syntax?!
Answer: Just access pid with:
$mydata['pid']

You pass true as a second argument for json_decode

When TRUE, returned objects will be converted into associative arrays.

So you have to treat is as an array, not an object.


How to install desktop environments such as kubuntu and gnome safely

Question: Help! Last time I tried to install desktop environments I broke Unity! I want some variety, but I am too scared! I don't want to reinstall ubuntu again! Please help!
I want to install extra interfaces without breaking unity or being able to fix everything with the terminal, should I break it.
EDIT: Guys, I need a failsafe, should I put something I don't like on my system.
Answer: Open a terminal and run the following commands to install a gnome-shell background.

sudo su - #will ask for your system password to become the superuser
sudo add-apt-repository ppa:gnome3-team/gnome3-next #press enter again
sudo add-apt-repository ppa:gnome3-team/gnome3-staging #press enter again
sudo apt-get update
sudo apt-get install gnome-shell gnome-shell-extensions #after this installation gnome-shell configuration menu will come and you can choose between gdm and lightdm options of which gdm has a different login appearance while lightdm has the one similar to unity. So better choose gdm here.

You are done.
You can always switch between gdm and lightdm with the following command:
sudo dpkg-reconfigure gdm     # here select gdm or lightdm and press enter.
Comment: I've decided to stick to unity for now, but thanks anyway!