text:
Q: Gradle: Copy application.properties file from sub project TL;DR Create a FatJar, but copy the `application.properties`` file from a subproject into the build output folder (any of them).
Hello Everyone,
I've got a gradle project that doesn't contain source code in the parent project, but has subprojects which do. One of these subprojects has an application.properties file that I would like to have appear in my build folder.  The structure of the app looks like this.
ParentProject
|
|-datamodel(Sub Project)
|   |
|   |-build.gradle
|-datadb(Sub Project)
|   |
|   |-build.gradle
|-dataservices(Sub Project)
|   |
|   |-src
|   |   |
|   |   |-main
|   |       |
|   |       |-resources
|               |
|               |-application.properties(File I need)
|   |-build.gradle
|
|-build.gradle

I would like to have it so that when I build the ParentProject, the build directory will look something like this.
build
  |
  |-libs
  |   |
  |   |-outputted.jar
  |
  |-resources
      |
      |-application.properties

As of now, I'm making my build script output what I believe is called a FatJar.  I'm not sure if this is creating issues.
jar {
   ...
   from {
       (configurations.runtime).collect {
        it.isDirectory() ? it : zipTree(it)
       }
   }
   ...
}

What I've Tried:
Everything.  I've tried the whole custom task route in the ParentProject build file
task copyStuff (dependsOn : 'subproject:build'){...

task copyStuff and then copyStuff.dependsOn...

task copyStuff..{
   doLast {

No matter what, I've never gotten it to copy, and it's been a waterfall of failure the entire night.
Any help is greatly appreciated.

A: Just use Copy task from Gradle, thats depends on Jar task
task customBuild(type: Copy, dependsOn: [jar]) {
    from "dataservices/src/main/resources/"
    into "build/resources"
    include "application.properties"
}


text:
Q: Why am I not able to change form location in method? I have a form with a load event and in that I am changing location.
This code works fine:
private void MainForm_Load(object sender, EventArgs e)
{
    this.Location = new Point(1200,500); // as example
}

But if I give the location change to a method and call this method from load event, it does not work.
private void MainForm_Load(object sender, EventArgs e)
{
    ChangeLocation();
}

private void ChangeLocation()
{
    this.Location = new Point(1200,500); // as example
}

I am wondering why it can't be in method.
Thank you

A: Set This
StartPosition = FormStartPosition.Manual;

You will be able to set it manually

redpajama_set_name: RedPajamaStackExchange


text:
Q: New to PDO function not doing anything? Here is my code:
function connect() {
    $pdo = new PDO("mysql:host=localhost;dbname=www","user","pass");
   $xmax = "SELECT MAX(x) FROM headerfooter WHERE site = 'Brighter_Vista'";
   $xresult = $pdo->query($xmax);
   while($row = $xresult->fetch(PDO::FETCH_ASSOC)) {
       print_r($row);
    }
    $ymax = "SELECT MAX(y) FROM headerfooter WHERE site = 'Brighter_Vista'";
   $yresult = $pdo->query($ymax);
   while($row = $yresult->fetch(PDO::FETCH_ASSOC)) {
       print_r($row);
   }
}

I call the function and nothing shows up.
I checked the query in mysql terminal and it does work.
I am new to PDO, what am I doing wrong?

A: Wrap your query in a try catch block.  Chances are the connection is failing quietly.
function connect() {
  try{
      $pdo = new PDO("mysql:host=localhost;dbname=www","user","pass");
      $xmax = "SELECT MAX(x) FROM headerfooter WHERE site = 'Brighter_Vista'";
      $xresult = $pdo->query($xmax);
      while($row = $xresult->fetch(PDO::FETCH_ASSOC)) {
          print_r($row);
      }

      $ymax = "SELECT MAX(y) FROM headerfooter WHERE site = 'Brighter_Vista'";
      $yresult = $pdo->query($ymax);
      while($row = $yresult->fetch(PDO::FETCH_ASSOC)) {
          print_r($row);
      }
   }catch (Exception $e){
      echo $e->getMessage();
      exit;
   }

}

If the exception is thrown, the message indicate where your issue is.

A: The function is syntactically correct. Everything seems to be all right and the only problem I could see is related to a problem of PDO trying to connect. Just replace your function with this one:
function connect() {
    try {
        $pdo = new \PDO("mysql:host=localhost;dbname=www","user","pass");
        $xmax = "SELECT MAX(x) FROM headerfooter WHERE site = 'Brighter_Vista'";
        $xresult = $pdo->query($xmax);
            while($row = $xresult->fetch(PDO::FETCH_ASSOC))
                print_r($row);
        $ymax = "SELECT MAX(y) FROM headerfooter WHERE site = 'Brighter_Vista'";
        $yresult = $pdo->query($ymax);
            while($row = $yresult->fetch(PDO::FETCH_ASSOC))
                print_r($row);
    } catch (\PDOException $e) {
        exit($e->getMessage());
    }
}

This function show or prevent errors in case of:

*

*any PDO error

*context in which you are using namespaces


text:
Q: Download file from URL if not modified recently using Powershell I have a Powershell script that is downloading files continuously from a URL public directory. The script is supposed to download files from the directory that does not currently exist in our local directory. The script looks like this:
$outputdir = 'C:\mydir\public\demos'
$url       = 'https://xxx.xxx.net/fastdl/xxx/xxx/public/'

# enable TLS 1.2 and TLS 1.1 protocols
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12, [Net.SecurityProtocolType]::Tls11

$WebResponse = Invoke-WebRequest -Uri $url
# get the list of links, skip the first one ("../") and download the files
$WebResponse.Links | Select-Object -ExpandProperty href -Skip 0 | ForEach-Object {
    Write-Host "Downloading file '$_'"
    $filePath = Join-Path -Path $outputdir -ChildPath $_
    $fileUrl  = '{0}/{1}' -f $url.TrimEnd('/'), $_

    if (Test-Path($filePath))
    {
        Write-Host 'Skipping file, already downloaded' -ForegroundColor Yellow
        return
    }
    Invoke-WebRequest -Uri $fileUrl -OutFile $filePath
}

Now, since I want to download all files from the $url directory I need to check one more condition. The file in the $url can't be modified in the last 10 minutes, if it has then the script should skip the file and download it once the last modification time is greater than 10 minutes.
I have not found any syntax that seem to be able to fit an if statement like that. Any ideas?

A: I would change Test-Path to Get-Item so if that returns something, the file exists and you can examine its LastWriteTime property:
$WebResponse.Links | Select-Object -ExpandProperty href -Skip 0 | ForEach-Object {
    $filePath = Join-Path -Path $outputdir -ChildPath $_
    $fileUrl  = '{0}/{1}' -f $url.TrimEnd('/'), $_

    # set up a boolean fag to download or not
    $downloadThis = $true
    if ($file = Get-Item -Path $filePath -ErrorAction SilentlyContinue) {
        # $file exists, check the LastWriteTime property
        if ($file.LastWriteTime -ge (Get-Date).AddMinutes(-10)) {
            Write-Host 'Skipping file, already downloaded' -ForegroundColor Yellow
            $downloadThis = $false
        }
    }
    if ($downloadThis) {
        Write-Host "Downloading file '$($file.Name)'"
        Invoke-WebRequest -Uri $fileUrl -OutFile $filePath
    }
}

A: I think all you need is to calculate time from now to the last modified time of the file. I once write a function to check a file created less than 10 mins or more than 10 mins and action accordingly, Hope fully it will help
#function to check whether a file is more than 10 mins age, if yes, return TRUE. If not, return FALSE
function file_age ($file){
#$file_info = Get-Item $file
$createtime = $file.CreationTime
$now = get-date

if (($now - $createtime).totalminutes -ge 10) {
    Write-host "file [$file] created equal or more than 10 mins ago"
    return $true
    }
else
    {#Write-host  "file [$file] created within the 10 mins"
    return $false
    }
}


text:
Q: while loop only returning 1 product row Evening all,
I have the following script setup on the backend of an eCommerce platform I am developing. Essentially I want to pull the products through and also pull all of the current categories through so that products can be assigned to a particular category.
However my product edit page is only displaying 1 result.
Its interesting to note that if i remove the script relating to the last SQL query my products show but with no category options. With the script only 1 product shows with the correct categories.
<?php
$myusername= $_SESSION['login_user'];

include '../ecommerce/connection.php';

        $sql="SELECT * FROM products where status='yes' ";

        // Posting Result
        $result = mysqli_query($connection, $sql);

        // Counting Results
        $count=mysqli_num_rows($result);

            if($count==0) {

                echo "

No products setup

";

            } else {

                    if ($result = mysqli_query($connection, $sql)){

                          echo "
";
                            echo "Image	";
                            echo "Product ID	";
                            echo "Name	";
                            echo "Description	";
                            echo "Price	";
                            echo "Weight	";
                            echo "Options 	";

                            while($row = $result->fetch_array())

                                     {

                                     $product_no = $row['product_id'];

                                            echo "
";

                                            echo '';
                                            echo "	 ";

                                            echo "" .$row['product_id'];
                                            echo "	 ";

                                            echo "" .$row['product_name'];
                                            echo "	 ";

                                            echo "" .$row['product_description'];
                                            echo "	 ";

                                            echo "" .'&pound'.$row['product_price'];
                                            echo "	 ";

                                            echo "" .$row['product_weight'].'kg';
                                            echo "	 ";

                                            echo "<form action='store_configuration/edit_product' method='post' id='delivery_change_form'>";
                                            echo "<input type='text' name='product' value='$product_no' style='opacity: 0;'/>";
                                            echo "<input type='Submit' value='Edit Product' >";
                                            echo "</form>	";

                                            echo "<form action='store_configuration/change_parent_category' method='post' id='delivery_change_form'>";

                                            echo "Parent Category <select name='category' style='height: auto;' >";

                                            **include '../ecommerce/connection.php';

                                            $sql="SELECT category_name FROM categories where status='yes' ";

                                            // Posting Result
                                            $result = mysqli_query($connection, $sql);

                                            // Counting Results
                                            $count=mysqli_num_rows($result);

                                                if($count==0) {

                                                    echo "

No categories setup

";

                                                } else {

                                                if ($result = mysqli_query($connection, $sql)){

                                                    while($row = $result->fetch_array()) {

                                                        $category = $row['category_name'];

                                                        echo" <option value='$category' >".$category ."</option>";

                                                    }

                                                }

                                            }**

                                            echo "</select>";
                                            echo "

<input type='Submit' value='Update Category' >";
                                            echo "</form>	";

                                            echo "
";

                                      }

                                        echo "
";

                            }

            }

?>

I would love any help on how I can show all products with all categories.
I have tried everything I can think of.
Thanks.
Stan.

A: You've used the same names of variables for products and categories queries. While the categories are inside of products loop you reassign that variable with new query and that's why it's crashes. Change name of variables for second query and that should fix your script.
<?php
$myusername= $_SESSION['login_user'];

include '../ecommerce/connection.php';

        $sql="SELECT * FROM products where status='yes' ";

        // Posting Result
        $result = mysqli_query($connection, $sql);

        // Counting Results
        $count=mysqli_num_rows($result);

            if($count==0) {

                echo "

No products setup

";

            } else {

                    if ($result = mysqli_query($connection, $sql)){

                          echo "
";
                            echo "Image	";
                            echo "Product ID	";
                            echo "Name	";
                            echo "Description	";
                            echo "Price	";
                            echo "Weight	";
                            echo "Options 	";

                            while($row = $result->fetch_array())

                                     {

                                     $product_no = $row['product_id'];

                                            echo "
";

                                            echo '';
                                            echo "	 ";

                                            echo "" .$row['product_id'];
                                            echo "	 ";

                                            echo "" .$row['product_name'];
                                            echo "	 ";

                                            echo "" .$row['product_description'];
                                            echo "	 ";

                                            echo "" .'&pound'.$row['product_price'];
                                            echo "	 ";

                                            echo "" .$row['product_weight'].'kg';
                                            echo "	 ";

                                            echo "<form action='store_configuration/edit_product' method='post' id='delivery_change_form'>";
                                            echo "<input type='text' name='product' value='$product_no' style='opacity: 0;'/>";
                                            echo "<input type='Submit' value='Edit Product' >";
                                            echo "</form>	";

                                            echo "<form action='store_configuration/change_parent_category' method='post' id='delivery_change_form'>";

                                            echo "Parent Category <select name='category' style='height: auto;' >";

                                            **include '../ecommerce/connection.php';

                                            $sql2="SELECT category_name FROM categories where status='yes' ";

                                            // Posting Result
                                            $result2 = mysqli_query($connection, $sql2);

                                            // Counting Results
                                            $count=mysqli_num_rows($result2);

                                                if($count==0) {

                                                    echo "

No categories setup

";

                                                } else {

                                                if ($result2 = mysqli_query($connection, $sql2)){

                                                    while($row2 = $result2->fetch_array()) {

                                                        $category = $row2['category_name'];

                                                        echo" <option value='$category' >".$category ."</option>";

                                                    }

                                                }

                                            }**

                                            echo "</select>";
                                            echo "

<input type='Submit' value='Update Category' >";
                                            echo "</form>	";

                                            echo "
";

                                      }

                                        echo "
";

                            }

            }
?>


text:
Q: Python button to change style of html div I have a project in python that will hide a div when my icon is clicked and then collapse when it is clicked again. Right now I have the following html code

Press the icon to see more stuff

one

two

three

So my question is what is the best way to remove the style on the div with the id showOrHide when the user clicks on the image?
Thanks!

A: Python isn't best equipped to do what you're trying to accomplish - is there no way you can use Javascript? A simple onclick() http://www.w3schools.com/jsref/event_onclick.asp will get the job done in JS.


text:
Q: Finding out if Ubuntu supports a specific laptop?
Possible Duplicate:
How do I know if a laptop will work with Ubuntu?

According to How to install hardware drivers for my laptop, the answer supplied by NorTicUs says:

"If your hardware as open drivers for Ubuntu, they will be install with Ubuntu. If there is driver from HP, you can find them into your Setting->Additional drivers.
This is Jockey, and it will let you know which drivers are available for your hardware. Just select which one you want and click Install."

But what if you do not already own the system, and you want to find out before you buy?

A: Check out sites like linlap.com to see if any specific model works with Linux.  They seem to have more info than the more official compatibility lists.

A: Google is your friend in this case. Simply run a Google search for something like "[your laptop model] Ubuntu compatibility" and you will generally find the information you need.
That said, here are a few general things to know:

*

*A large number of new Dell computers are Ubuntu certified (and, from what I understand, nearly all of them have actually been tested with Ubuntu, as they ship it almost exclusively outside of the US). This means Ubuntu has been tested to run on them and will work (usually out of the box). So, if the computer you're getting is a Dell, then you shouldn't need to worry about the hardware in general (though, unfortunately, if you live in the US, you can't get a machine with Ubuntu pre-installed on it; thank you, marketing department). Ubuntu's certified page also lists that several HP and IBM models are certified as well. Even if you can't get the exact models, matching specs/hardware should also perform equally well.

*Most computers will be supported at least on a basic level. Usually the hangups occur with network cards (specifically, the wireless card), and graphics cards. Both nVidia and ATI/AMD have fairly good support for most cards on the market. The biggest issue I've seen is with cutting edge ATI/AMD cards, due to the lag in the open source driver development. nVidia supplies their own proprietary driver, which usually avoids the issue the ATI cards have.

*Intel laptops ship with a feature called Optimus. It's a power saving feature that allows the computer to switch between the descrete and shared video, depending on the current needs of the computer. By default, this is known to cause issues with Ubuntu, but there are two ways to deal with it - install Bumblebee, or go into your BIOS settings and disable Optimus.

A: There is a list that the Ubuntu Team complied it has all the Hardware OEMs and the desktops(and laptops) they put through certification.
http://www.ubuntu.com/certification/desktop/

A: You should probably ask the employees at the store what the specs are, then look up "Ubuntu driver " Most of the time, you'll find a page that says "Ubuntu supports  out of the box, but a proprietary, non-open-source driver can be found here."
Ubuntu actually has a great collection of built-in drivers, so it shouldn't be too much of a concern whether it has the necessary drivers, but I'd recommend just asking the employees what the hardware is. (e.g., my computer is a Pentium 4 with dual logical processors @300GHz and 3 Gig of RAM. :)


text:
Q: CakePHP and .htaccess: how to redirect url with query string I wanted to redirect this url from /main.php?page=pages&id=gettingpaidfortakingsurveys to /main/pages/getting-paid-for-taking-surveys.
Thanks!
[UDPATE]
i tested it on my existing cakephp .htaccess and it didn't work.
<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteRule ^/main.php?page=(.+)&id=(.+) /main/$1/$2 [NC]
 RewriteRule ^$ app/webroot/    [L]
 RewriteRule (.*) app/webroot/$1 [L]
</IfModule>

A: Since you appear to want to do this with Apache's .htaccess, you'll need the mod_rewrite module.  In the .htaccess, you'll want something like:
RewriteEngine on
RewriteRule ^main.php?page=(.+)&id=(.+) /main/$1/$2 [NC]

This should get you /main/pages/gettingpaidfortakingsurveys.  This won't hyphenate the word and I'm unsure you'll be able to do that without something overly complex.

A: Have you tried this, I'm assuming that this is a redirect for one page only. You'll need to put it above the Cake rewrite block. The second part must be the full URL:
Redirect 301 /main.php?page=pages&id=gettingpaidfortakingsurveys http://www.domain.com/main/pages/getting-paid-for-taking-surveys
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^$ app/webroot/    [L]
    RewriteRule (.*) app/webroot/$1 [L]
</IfModule>

If the rewrite is temporary, substitute 302 for 301.
The /main part of the url doesn't look very Cake-friendly. Shouldn't it just be /pages/...?


text:
Q: how to set the oauth_verifier in the header twitteroauth php I'm getting the following error:
Error processing your OAuth request: Invalid oauth_verifier parameter
I keep reading that the issue is that in the library TwitterOAuth by Abraham we need to set the oauth_verifier in the header and not the body.
I don't know how to do this.
Here is my code:
// twitterlogin.php
session_start();
$twitterKey = 'xxx';
$twitterSecret = 'xxx';
$callback = "https://xxx/socialmedia/twittercallback.php";

require_once("/xxx/twitteroauth/vendor/autoload.php");
use Abraham\TwitterOAuth\TwitterOAuth;

$twitter = new TwitterOAuth($twitterKey,$twitterSecret);
$result = $twitter->oauth('oauth/request_token', ['oauth_callback' => $callback]);
$_SESSION['oauth_token'] = $result['oauth_token'];
$_SESSION['oauth_token_secret'] = $result['oauth_token_secret'];
$url = $twitter->url('oauth/authorize', array('oauth_token' => $result['oauth_token']));
header("Location: $url");

// twittercallback.php
session_start();
require_once("/xxx/api");
$twitterKey = 'xxx';
$twitterSecret = 'xxx';
require_once("/xxx/twitteroauth/vendor/autoload.php");
$twitter = new \Abraham\TwitterOAuth\TwitterOAuth($twitterKey,$twitterSecret,$_SESSION['oauth_token'],$_SESSION['oauth_token_secret']);

try {
 $access_token = $twitter->oauth("oauth/access_token", ["oauth_verifier" => $_GET['oauth_verifier']]);
 $_SESSION['access_token'] = $access_token;
} catch(\Exception $e){
 print "<pre>".print_r($e,true)."</pre>";
}
var_dump($access_token);

How do I set the oauth_verifier in the header?
Thanks!


text:
Q: Showing sequence is Cauchy in L^1 norm Let
$$f_n(x)=\begin{cases}
\left(x+\frac{1}{2}\right)^n,&\text{if }0\le x<\frac{1}{2}\\\\
1,&\text{if } \frac{1}{2}\le x\le 1\;.
\end{cases}$$
Then clearly $(f_n)$ is sequence in $C[0,1]$. I need to show this is cauchy sequence in $C[0,1]$ with $L^1$ norm.
My attempt  By definition of cauchy sequence, i think we need establish
$||f_n-f_m||<\epsilon$ for sufficiently large $m, n$
i.e. $\int^{1}_0 |f_n(x)-f_m(x)|dx<\epsilon$ for sufficiently large $m, n$
But,
$\int^{1}_0 |f_n(x)-f_m(x)|dx\\
=\int^{1/2}_0 |(x+1/2)^n-(x+1/2)^m|dx$
(Since on $[1/2,1]$ both $f_n$, $f_m$ are equal for all $m, n$ )
In next step i had used traingle inequality and spit the integral into two parts and obtained,
$\int^{1}_0 |f_n(x)-f_m(x)|dx\\
≤\int^{1/2}_0 |(x+1/2)^n| dx+\int^{1/2}_0 |(x+1/2)^m| dx$\
$=\frac{1}{n+1}[1-(1/2)^{n+1}]+\frac{1}{m+1}[1-(1/2)^{m+1}]$
But i am unable to obtain conclusion
Further, i like to know is there is any direct approach to conclude it is Cauchy sequence?

A: Let $\varepsilon > 0$ be fixed. Note that
\begin{eqnarray*}
\int_{0}^{1/2} \left| (x + 1/2)^n - (x + 1/2)^m \right| \, dx & \leq & \int_{0}^{1/2}  \left| (x + 1/2)^n \right| \, dx + \int_{0}^{1/2}  \left| (x + 1/2)^n \right| \, dx \\
& = & \left[\frac{1}{n+1} - \frac{(1/2)^{n+1}}{n + 1} \right] + \left[ \frac{1}{n+1} - \frac{(1/2)^{m+1}}{m + 1} \right]\\
& < & \frac{1}{n} + \frac{1}{m}.
\end{eqnarray*}
From here, can you determine what constraints you must put on $n$ (resp. $m$) so tha $\dfrac{1}{n} < \dfrac{\varepsilon}{2}$?


text:
Q: How to Select Elements Between A range in jQuery Can you pls take a look at this demo and let me know how I can remove .d-none class from element which located between two given numbers? Foe example I just want to show .box which are between 1 to 6 and hide all other boxes

$("button").on("click", function(e) {
  var id = $(this).attr('id');

  if (id == 1) {
    $('.box').addClass('d-none');
    // Now only display boxes from  1 to 6
  }
  if (id == 2) {
    $('.box').addClass('d-none');
    // Now only display boxes from  10 to 26
  }
  if (id == 3) {
    $('.box').addClass('d-none');
    // Now only display boxes from  12 to 36
  }
});
.box {
  background: gold;
  height: 60px;
  width: 60px;
  color: black;
  text-align: center;
  line-height: 50px;
  float: left;
  margin: 2px;
}

.d-none {
  display: none !important;
}

<button id="1">1 - 6</button>
<button id="2">10 - 26</button>
<button id="3">12 - 36</button>

0

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

A: You can do it easily using jquery slice() method. The slice() method helps us to reduce the set of matched elements to a subset specified by a range of indices, which is exactly we need here.

$("button").on("click", function(e) {
  var id = $(this).attr('id');
  $('.box').addClass('d-none');
  if (id == 1) {
    $('.box').slice(1,7).removeClass('d-none');
    // Now only display boxes from  1 to 6
  }
  if (id == 2) {
    $('.box').slice(10,27).removeClass('d-none');
    // Now only display boxes from  10 to 26
  }
  if (id == 3) {
    $('.box').slice(12,37).removeClass('d-none');
    // Now only display boxes from  12 to 36
  }
});
.box {
  background: gold;
  height: 60px;
  width: 60px;
  color: black;
  text-align: center;
  line-height: 50px;
  float: left;
  margin: 2px;
}

.d-none {
  display: none !important;
}

<button id="1">1 - 6</button>
<button id="2">10 - 26</button>
<button id="3">12 - 36</button>

0

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

A: An additional solution if you have to check for the
 content:

$("button").on("click", function(e) {
  var id = parseInt($(this).attr('id')); // get button id to decide

  // if you need to determine the range directly from the button content
  // you should here extract the start and end value and use it
  // afterwards for the if. In this case you can omit fixed ranges and
  // the switch statement.
  // var start = parseInt($(this).html().split(" - ")[0]);
  // var end = parseInt($(this).html().split(" - ")[1]);

  $('.box').addClass('d-none'); // hide all divs
  var func = function() {
    var val = parseInt($(this).html()); // get div content value

    // use the button start and end values instead of the switch below
    // if(val >= start && val <= end) {
    //   $(this).removeClass('d-none');
    // }

    switch(id) {
      case 1:
       if(val >= 1 && val <= 6) { // show only ids for button 1
         $(this).removeClass('d-none');
       }
       break;
      case 2:
       if(val >= 10 && val <= 26) { // show only ids for button 2
         $(this).removeClass('d-none');
       }
       break;
      case 3:
       if(val >= 12 && val <= 36) { // show only ids for button 3
         $(this).removeClass('d-none');
       }
       break;
    }
  };

  $('.box').each(func);
});
.box {
  background: gold;
  height: 60px;
  width: 60px;
  color: black;
  text-align: center;
  line-height: 50px;
  float: left;
  margin: 2px;
}

.d-none {
  display: none !important;
}

<button id="1">1 - 6</button>
<button id="2">10 - 26</button>
<button id="3">12 - 36</button>

0

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

Explanation in the code!

A: In plain es20xx

{
  // helper to determine if number is between min and max
  const between = (number, min, max) => number >= min && number <= max;
  document.addEventListener("click", showSelection);

  function showSelection(evt) {
    // act only if clicked element contains [data-between] ('event delegation')
    if (evt.target.dataset.between) {
      // determine min and max based on [data-between]
      const minMax = evt.target.dataset.between.split(",").map(Number);
      [...document.querySelectorAll(".box")]
      .forEach(box => {
        // determine what to do with box.classList based on
        // number between min and max
        const addOrRemove = between(+box.textContent, minMax[0], minMax[1]) ?
          "remove" : "add";
        // do it
        box.classList[addOrRemove]("d-none");
      });
    }
  }
}
.box {
  background: gold;
  height: 60px;
  width: 60px;
  color: black;
  text-align: center;
  line-height: 50px;
  float: left;
  margin: 2px;
}

.d-none {
  display: none;
}
<button data-between="1,6">1 - 6</button>
<button data-between="10,26">10 - 26</button>
<button data-between="12,36">12 - 36</button>
<button data-between="0,40">all</button>

0

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

A: Use .removeClass() on the elements along with slice().
Call your selector, then slice the elements index adding the elements you wish to show and then removeClass('d-none').
Also, get the values of your elements attr('id'), slice that info and grab the actual values set in the buttons. Adjust key value starting at 0 with -1 and it is more dynamic.

$("button").on("click", function(e) {
    var id = $(this).attr('id');
    var opt1 = $('#1').text().split(' - ');
    var opt2 = $('#2').text().split(' - ');
    var opt3 = $('#3').text().split(' - ');

    if (id == 1) {
        $('.box').addClass('d-none');
        $('.box').slice(opt1[0]-1,opt1[1]).removeClass('d-none');
        }
    if (id == 2) {
        $('.box').addClass('d-none');
        $('.box').slice(opt2[0]-1,opt2[1]).removeClass('d-none');
    }
    if (id == 3) {
        $('.box').addClass('d-none');
        $('.box').slice(opt3[0]-1,opt3[1]).removeClass('d-none');
    }
    if (id == 4) {
        $('.box').removeClass('d-none');
    }
});
.box {
  background: gold;
  height: 60px;
  width: 60px;
  color: black;
  text-align: center;
  line-height: 50px;
  float: left;
  margin: 2px;
}

.d-none {
  display: none !important;
}

<button id="1">1 - 6</button>
<button id="2">10 - 26</button>
<button id="3">12 - 36</button>
<button id="4">Show All</button>

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40


text:
Q: want to change the text for different label with one for c# i want to do a logo quiz game . and i did this code for now
int a=0;

private void button1_Click(object sender, EventArgs e)
{
    pictureBox1.BackgroundImage = button1.BackgroundImage;
    a = 1;

}

private void button2_Click(object sender, EventArgs e)
{
    pictureBox1.BackgroundImage = button2.BackgroundImage;
    a = 2;
}

private void button3_Click(object sender, EventArgs e)
{
    pictureBox1.BackgroundImage = button3.BackgroundImage;
    a = 3;
}

private void button4_Click(object sender, EventArgs e)
{
    pictureBox1.BackgroundImage = button4.BackgroundImage;
    a = 4;
}

private void button5_Click(object sender, EventArgs e)
{
    pictureBox1.BackgroundImage = button5.BackgroundImage;
    a = 5;
}

private void button6_Click(object sender, EventArgs e)
{
    pictureBox1.BackgroundImage = button6.BackgroundImage;
    a = 6;
}

private void button7_Click(object sender, EventArgs e)
{
    pictureBox1.BackgroundImage = button7.BackgroundImage;
    a = 7;
}

private void button8_Click(object sender, EventArgs e)
{
    pictureBox1.BackgroundImage = button8.BackgroundImage;
    a = 8;
}

private void button9_Click(object sender, EventArgs e)
{
    pictureBox1.BackgroundImage = button9.BackgroundImage;
    a = 9;
}

private void button10_Click(object sender, EventArgs e)
{
    pictureBox1.BackgroundImage = button10.BackgroundImage;
    a = 10;
}

private void button11_Click(object sender, EventArgs e)
{
    pictureBox1.BackgroundImage = button11.BackgroundImage;
    a = 11;
}

private void button12_Click(object sender, EventArgs e)
{
    pictureBox1.BackgroundImage = button12.BackgroundImage;
    a = 12;
}

private void button13_Click(object sender, EventArgs e)
{
    pictureBox1.BackgroundImage = button13.BackgroundImage;
    a = 13;
}

private void button14_Click(object sender, EventArgs e)
{
    pictureBox1.BackgroundImage = button14.BackgroundImage;
    a = 14;
}

private void button15_Click(object sender, EventArgs e)
{
    pictureBox1.BackgroundImage = button15.BackgroundImage;
    a = 15;
}

private void button16_Click(object sender, EventArgs e)
{
    pictureBox1.BackgroundImage = button16.BackgroundImage;
    a = 16;
}

private void button17_Click(object sender, EventArgs e)
{
    int i;
    int scor = 0;

    List<string> numeLogo = new List<string>(); // audi,bentley,cadillac,chevrolet,dodge,alfa romeo
    numeLogo.Add("audi");                       // ferrari,peugeot,volkswagen,trabant,mitsubishi,mazda
    numeLogo.Add("bentley");                       // opel,maserati,lamborghini,mercedes
    numeLogo.Add("cadillac");
    numeLogo.Add("chevrolet");
    numeLogo.Add("dodge");
    numeLogo.Add("alfa romeo");
    numeLogo.Add("ferrari");
    numeLogo.Add("peugeot");
    numeLogo.Add("volkswagen");
    numeLogo.Add("trabant");
    numeLogo.Add("mitsubishi");
    numeLogo.Add("mazda");
    numeLogo.Add("opel");
    numeLogo.Add("maserati");
    numeLogo.Add("lamborghini");
    numeLogo.Add("mercedes");

    for (i = 1; i <= 16; i++)
    {
        if (a == i)
            if (textBox1.Text == numeLogo[i - 1])
            {

                MessageBox.Show("bravo");

            }
            else
                MessageBox.Show("nu e bine");
    }

}

under each button i have a label . if the player guesses the logo , under the button the label.text must change.
i don't know how to do this with a for.
i can do something like for(i=1; i<=n; i++){ label[i].Text == "x" }  ?

A: Yes, you can, just declare your label array:
private List<Label> Labels {
get {
   return new List<Label>() {label1, label2, label3}; }
}


text:
Q: Random Color Background I am trying to get this code to change the background color to a random color when I press 'r'. So far everything is working ok other than changing the background color to a random color. This program is a screen saver that I have to generate random shapes in random positions with random colors.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Random;

public class ScreenSaver1 extends JPanel {
    private JFrame frame = new JFrame("FullSize");
    private Rectangle rectangle;
    boolean full;

    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        setBackground(Color.BLACK);
    }

    ScreenSaver1() {
        // Remove the title bar, min, max, close stuff
        frame.setUndecorated(true);
        // Add a Key Listener to the frame
        frame.addKeyListener(new KeyHandler());
        // Add this panel object to the frame
        frame.add(this);
        // Get the dimensions of the screen
        rectangle = GraphicsEnvironment.getLocalGraphicsEnvironment()
        .getDefaultScreenDevice().getDefaultConfiguration().getBounds();
        // Set the size of the frame to the size of the screen
        frame.setSize(rectangle.width, rectangle.height);
        frame.setVisible(true);
        // Remember that we are currently at full size
        full = true;
    }

// This method will run when any key is pressed in the window
class KeyHandler extends KeyAdapter {
    public void keyPressed(KeyEvent e) {
        // Terminate the program.
        if (e.getKeyChar() == 'x') {
            System.out.println("Exiting");
            System.exit(0);
        }
        else if (e.getKeyChar() == 'r') {
            System.out.println("Change background color");
            setBackground(new Color((int)Math.random() * 256, (int)Math.random() * 256, (int)Math.random() * 256));
        }
        else if (e.getKeyChar() == 'z') {
            System.out.println("Resizing");
            frame.setSize((int)rectangle.getWidth() / 2, (int)rectangle.getHeight());
        }
    }

}

public static void main(String[] args) {
        ScreenSaver1 obj = new ScreenSaver1();
    }
}

A: I would start by removing setBackground(Color.BLACK); from your paintComponent method
The other problem you're having is with the way you are calculating your random values...
(int)Math.random() * 256

This is basically casting the result of Math.random() to an int, which will, typically, result in it becoming 0, before it's multiplied by 256, which is 0...
Instead, try using something like
(int)(Math.random() * 256)

Which will perform the calculation of Math.random() * 256 before casting the result to int
You may also want to take a look at Frame#getExtendedState and Frame#setExtendedState...it will make your life considerably eaiser...

A: Try this:
(int)(Math.random() * 256)

Or this:
Random gen= new Random();
getContentPane().setBackground(Color.Black);

To get random colors, try this:
.setBackground(Color.(gen.nextInt(256), gen.nextInt(256),
                gen.nextInt(256));


text:
Q: Function Isn't Excluding Repeat Data I am trying to insert a large amount of data into a table.  The source for the data has the potential to repeat data in what is suppose to be a UNIQUE column.  I created the following to insert the data into my table:
DECLARE @OrderNum VARCHAR(20), @JobNum VARCHAR(20), @Supplier VARCHAR(100), @OldOrderID int, @UserNum int,
        @OrderID int, @JobID int, @SupplierID int, @ContactID int, @UserID int

DECLARE MY_CURSOR CURSOR
LOCAL STATIC READ_ONLY FORWARD_ONLY
FOR
    SELECT order_id, job_num, supp_name, user_num
    FROM _po_temp_b

OPEN MY_CURSOR
    FETCH NEXT FROM MY_CURSOR INTO @OldOrderID, @JobNum, @Supplier, @UserNum
WHILE @@FETCH_STATUS = 0
BEGIN

    SELECT @OrderNum = order_num
    FROM _po_temp_a
    WHERE order_id = @OldOrderID

    IF NOT EXISTS(SELECT order_number FROM purchase_order WHERE order_number = @OrderNum)

        SELECT @JobID = j.job_id
          FROM job AS j
         WHERE j.job_number = @JobNum

        SELECT @SupplierID = s.supplier_id
          FROM supplier AS s
         WHERE s.supplier_name = @Supplier

        SELECT @ContactID = sc.contact_id
          FROM supplier_contact AS sc
         WHERE sc.supplier_id = @SupplierID

        SELECT @UserID = ul.user_list_id
          FROM user_list AS ul
         WHERE ul.user_order_number = @UserNum

        INSERT purchase_order(order_number, job_id, supplier_id, contact_id, user_list_id, status_id, notes)
        VALUES (@OrderNum, @JobID, @SupplierID, @ContactID, @UserID, 2, NULL);

    FETCH NEXT FROM MY_CURSOR INTO @OldOrderID, @JobNum, @Supplier, @UserNum

END
CLOSE MY_CURSOR
DEALLOCATE MY_CURSOR
GO

Now my thought was that the IF NOT EXISTS line would stop me from getting a bunch of data repetitions.  However, I am still getting repeat data entries, preventing me from setting the column up as UNIQUE, which is what it needs to be.
What exactly is wrong with my setup?  Am I missing something somewhere?

A: Looking at the code, I don't see a reason for the cursor. It's unclear what column is supposed to be unique, but you can handle your EXIST in a WHERE clause (i used NOT IN) and remove all the variables, and cursor as well.
insert into purchase_order (order_number, job_id, supplier_id, contact_id, user_list_id, status_id, notes)
SELECT
    a.order_id
    ,j.job_id
    ,s.supplier_id
    ,sc.contact_id
    ,ul.user_list_id
    ,2
    ,null
FROM
    _po_temp_b b
inner join
    _po_temp_a a on a.order_id = b.order_id
inner join
    job j on j.job_number = b.job_num
inner join
    supplier s on s.supplier_name = b.supp_name
inner join
    supplier_contact sc on sc.supplier_id = s.supplier_id
inner join
    user_list ul on ul.user_order_number = b.user_num
where
    a.order_number not in (SELECT order_number FROM purchase_order)

You may need LEFT joins... it all depends.

A: IF Syntax is for more than one sql line:
IF (whatever)
   BEGIN
       sql line 1
       sql line 2
       .....
       sql line n
   END

good luck


text:
Q: Receiving java.lang.UnsatisfiedLinkError on badlogic.BufferUtils When lunching the application with DesktopLuncher i experience UnsatisfiedLinkError on root class (Main) in core module inside the project.
public class Main extends Game {

    @Override
    public void create() {
        this.cameraBuilder = ...
        setScreen(new LandingMenu(this));
    }

    @Override
    public void render() {
        super.render();
    }

    @Override
    public void dispose() {
        batch.dispose();
    }

    public World getWorld() {
        return world;
    }

    public SpriteBatch getBatch() {
        return batch;
    }

    public CameraBuilder<OrthographicCamera> getCameraBuilder() {
        return cameraBuilder;
    }

    private final SpriteBatch batch = new SpriteBatch();;

    private CameraBuilder<OrthographicCamera> cameraBuilder;

    private final World world = new World(new Vector2(0, -9.8f), true);
}

any answer will be appreciated.

A: The exception is a cause and issue lives on create method on ApplicationListener Called when the Application is first created, on the other hand SpriteBatch is a Batch which is used for drawing Sprites, more specifically, it deals with drawing a bunch of textures on Quads in OpenGL thus is must be initialized inside of create method and not in the root class level.
    @Override
    public void create() {
        batch = new SpriteBatch();
        setScreen(new LandingMenu(this));
    }

    ...

    private SpriteBatch batch;

Find more in here.


text:
Q: Average duplicates before fitting? Common practice for calibration curves is to take several duplicate measurements for each timepoint (or concentration, whatever variable) and fit using the average of each measurement set. The dependent and independent variables are both known.
E.g. a 3-point calibration with 5 duplicates generates 15 datapoints, but we only fit against the 3 average values.
What is the major difference with fitting against all 15 datapoints, other than being less computationally intensive? Is there even a difference?

A: One big advantage to including all the data points rather than just analyzing the average value at each time point or concentration is that you get information on the variability of the measurements. In analytical systems this is a very important characteristic that one often wants to determine. Including all the data points also will provide more reliable estimates of the errors in the coefficients for the calibration curve, as the information about measurement error is pooled among all the data points rather than confounded into the average values at each concentration or time point.
It's almost never a good idea to throw away information. Now that we are no longer limited by the hand-operated calculators that were the norm half a century ago, the issue of computational intensiveness seldom matters except with immense data sets.


text:
Q: Style messing up when screen size is reduced Please take a look at my practice site - http://codepen.io/silentarrowz/pen/rLJABR
I am having few problems with it:

*

*At reduced screen size the eElectronics and cart at the top are not centered but appear at one side of the screen. I'd like it to be centered for small screen sizes. I am able to center the eElectronics logo but unable to center the cart div, even though I am using media queries.

*The navigation bar overflows for small screen sizes and the links at the end such as OTHERS & CONTACT flow on to the next row. How do I  fix this?

*The carousel caption moves off the screen for reduced size. How do I fix this?
Please offer your suggestions and advice.
.navcolor{
  background-color:#1abc9c;
}
.logo a{
  padding-bottom:10px;
  color:#999;
}
.logo a span{
  color:#1abc9c;
}
.cart {
  border:1px solid rgb(221,221,221);
  font-family:"Titillium Web";
  font-size:18px;
  width:140px;
  height:50px;
  padding-top:10px;
  padding-left:10px;
}
.cart a{
  color:#666;
}
.cart a span{
  color:#1abc9c;
  font-weight:bold;
}
.cart:hover {
  background-color : #1abc9c;
}
.cart:hover span, .cart:hover a{
  color:white;
}
.no-underline :hover{
  text-decoration:none;
}
.navbar-default .navbar-menu{
   height:50px;
}
.navbar-default .navbar-menu li > a{
  color:white;
  font-weight:bold;
  font-size:14px;
}
.navbar-default .navbar-menu > .active > a {
  background-color:#333;
  color:white;
}
.navbar-default .navbar-menu > .active > a:hover {
  background-color:#333;
  color:white;
}
.navbar-default .navbar-menu li>a:hover{
  background-color:#333;
  color:white;
}
#carousel1 img{
  width:100%;
  height:70%;
}
.logo{
  font-family:"Titillium Web";
  font-size:40px;
}
.cart{
  font-size:18px;
}
.carouse-inner{
  position:relative;
}
.carousel-caption{
  background-color:rgba(0,0,0,0.5);
  color:white;
  display:block;
  width:600px;
  padding-left:20px;
  text-align:left;
  position:absolute;
  left:600px;
  bottom:150px;
}
.latest img{
  border:1px solid grey;
}
.details p{
  height:150px;
  display:block;
  border:1px solid #17a78b;
  margin-top:30px;
  margin-bottom:30px;
  padding-top:10px;
  padding-bottom:10px;
  font-size: 30px;
  font-weight:200;
  color:#fff;
  text-align:center;
}
.details p:hover{
  background-color:black;
}
.details p>i{
  font-size:50px;
  font-weight:500;
}
.details{
  background-color:rgb(26,188,156);
}
.latest{
  text-align:center;
}
@media (max-width: 300px) {
  .logo{
    text-align:center;
  }
  .cart{
    width:100%;
    text-align: center;
  }
}

@media (min-width: 501px) {
  .logo {
    float: left;
  }
  .cart {
    float:right;
  }
}

A: If you are trying to center divs with text-align that's not the way to go. You need to set up margin on right and left to auto:
    @media (max-width: 300px) {
      .logo{
        text-align: center;
        margin: 0 auto;
     }
     .cart{
        width:100%;
        margin: 0 auto;
     }
}

The thing is your eElectronics is not taking all the space of the div, center div with margin auto on sides and text-align center inside the div.
For the menu in collapse mode, i get a scroll bar and everything is fine except it is a little small. Override with overflow: visible; and set z-index if it overlaps under other items.
.navbar-collapse.in {
    overflow-y: visible;
}

The carousel captions are fine for me on Firefox. You just need to set a width in % and set margins on each side to auto. That div needs to be adaptative. Right now it stay at a size of 600px set in .carousel-caption.

A: Problem 2: Your OTHER & CONTACT menu buttons go on the next row because your navbar is in a div.container with a width of 750px for resolutions under 768px, and there is no place for themin the same row.
@media (min-width: 768px){
    .container {
        width: 750px;
    }
}

You could give it another class, with different width, since you have the .container class assigned to more divs, and make it wider.
You could also give a min-height of 330px to your .navbar-colapse.in class to make the collapsed menu higher when resolution is under 768px:
@media (min-width: 768px){
    .navbar-collapse.in {
        overflow-y: auto;
        min-height: 330px;
    }
}

Problem 3: As Steve said, change your .carousel-caption style, giving width in percents (100%) and margins set to auto.
.carousel-caption {
    width: 100%;
    left: auto;
    right: auto;
}


text:
Q: android_intent Error First Install Flutter Plugin This is the first time I installed the Android_intent plugin in my application,During the experiment I installed plugins in a simple application and the plugin went well, but when I did the same thing in the application I actually had a plugin that no longer worked. but when I installed it an error like this appeared:
/home/denis/AndroidStudioProjects/spmi_conference/build/android_intent/generated/source/buildConfig/debug/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:23: error: duplicate class: io.flutter.plugins.androidintent.AndroidIntentPlugin
public class AndroidIntentPlugin implements MethodCallHandler {
       ^
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:13: error: package io.flutter.plugin.common does not exist
import io.flutter.plugin.common.MethodCall;
                               ^
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:14: error: package io.flutter.plugin.common does not exist
import io.flutter.plugin.common.MethodChannel;
                               ^
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:15: error: package io.flutter.plugin.common.MethodChannel does not exist
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
                                             ^
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:16: error: package io.flutter.plugin.common.MethodChannel does not exist
import io.flutter.plugin.common.MethodChannel.Result;
                                             ^
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:17: error: package io.flutter.plugin.common.PluginRegistry does not exist
import io.flutter.plugin.common.PluginRegistry.Registrar;
                                              ^
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:23: error: cannot find symbol
public class AndroidIntentPlugin implements MethodCallHandler {
                                            ^
  symbol: class MethodCallHandler
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:25: error: cannot find symbol
  private final Registrar mRegistrar;
                ^
  symbol:   class Registrar
  location: class AndroidIntentPlugin
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:28: error: cannot find symbol
  public static void registerWith(Registrar registrar) {
                                  ^
  symbol:   class Registrar
  location: class AndroidIntentPlugin
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:34: error: cannot find symbol
  private AndroidIntentPlugin(Registrar registrar) {
                              ^
  symbol:   class Registrar
  location: class AndroidIntentPlugin
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:117: error: cannot find symbol
  public void onMethodCall(MethodCall call, Result result) {
                           ^
  symbol:   class MethodCall
  location: class AndroidIntentPlugin
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:117: error: cannot find symbol
  public void onMethodCall(MethodCall call, Result result) {
                                            ^
  symbol:   class Result
  location: class AndroidIntentPlugin
/home/denis/AndroidStudioProjects/spmi_conference/build/android_intent/generated/source/buildConfig/debug/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:13: error: package io.flutter.plugin.common does not exist
import io.flutter.plugin.common.MethodCall;
                               ^
/home/denis/AndroidStudioProjects/spmi_conference/build/android_intent/generated/source/buildConfig/debug/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:14: error: package io.flutter.plugin.common does not exist
import io.flutter.plugin.common.MethodChannel;
                               ^
/home/denis/AndroidStudioProjects/spmi_conference/build/android_intent/generated/source/buildConfig/debug/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:15: error: package io.flutter.plugin.common.MethodChannel does not exist
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
                                             ^
/home/denis/AndroidStudioProjects/spmi_conference/build/android_intent/generated/source/buildConfig/debug/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:16: error: package io.flutter.plugin.common.MethodChannel does not exist
import io.flutter.plugin.common.MethodChannel.Result;
                                             ^
/home/denis/AndroidStudioProjects/spmi_conference/build/android_intent/generated/source/buildConfig/debug/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:17: error: package io.flutter.plugin.common.PluginRegistry does not exist
import io.flutter.plugin.common.PluginRegistry.Registrar;
                                              ^
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:29: error: cannot find symbol
    final MethodChannel channel =
          ^
  symbol:   class MethodChannel
  location: class AndroidIntentPlugin
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:30: error: cannot find symbol
        new MethodChannel(registrar.messenger(), "plugins.flutter.io/android_intent");
            ^
  symbol:   class MethodChannel
  location: class AndroidIntentPlugin
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:116: error: method does not override or implement a method from a supertype
  @Override
  ^
20 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':android_intent:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s
Finished with error: Gradle task assembleDebug failed with exit code 1

I have tried this for several days.
am I wrong with my code?
can someone help me? thank you
best regards.

A: Add this code into your project's android build Gradle file.
subprojects {
project.evaluationDependsOn(':app')
project.configurations.all {
    resolutionStrategy.eachDependency { details ->

        if (details.requested.group == 'androidx.core'
                && !details.requested.name.contains('androidx')) {
            details.useVersion "1.0.1"
        }

      }
   }
}

Dont forget to clean your project before trying again.

A: I just had the same problem with another plugin, and found little useful information. The steps that ultimately worked for me were to:

*

*Upgrade the version of gradle:

*

*In android/gradle/wrapper/gradle-wrapper.properties I switched to using 5.4.1

*In android/build.gradle I switched to classpath 'com.android.tools.build:gradle:3.5.1'

*Ensuring that AndroidX support libraries are used:

*

*In android/app/build.gradle this was a matter of switching all android.support prefixes to androidx.support (and com.android.support to com.androidx.support, respectively).

Based on my experimentation, I believe it is #2 that is the root cause of the problem - indeed, step #1 may be entirely unnecessary, but seemed like a reasonable place to start while I was trying to figure out what the problem was.
As you did not provide information about your gradle properties, I can only assume that you are facing a similar issue based on the similarity in build issues encountered.


text:
Q: how to upload different files (images & documents) in codeigniter hi i'm new to codeigniter, can you please help me in insert multiple files(documents and images) in code igniter. here's my sample code
view:
Picture
            <input type="file" name="userfile" size="100" />

Document
           <input type="file" name="documentfile" size="10" />

controller:
 $m = $_FILES['userfile']['name'];
 $n = $_FILES['documentfile']['name'];
  if ($m !== "")
        {
            $config['upload_path'] = './upload_images/';
            $config['allowed_types'] = 'jpg|png|jpeg|gif';
            $config['max_size'] = '0'; // 0 = no file size limit
            $config['max_width']  = '0';
            $config['max_height']  = '0';
            $config['overwrite'] = TRUE;
            $this->load->library('upload', $config);
             $this->upload->do_upload();
             $upload_result = $this->upload->data();
        }
       elseif ($n !== "")
        {
            $config_document['upload_path'] = './upload_documents/';
            $config_document['allowed_types'] = 'pdf';
            $config_document['max_size'] = '0';
            $config_document['overwrite'] = TRUE;
            $this->load->library('upload', $config_document);
             $this->upload->do_upload();
             $upload_result2 = $this->upload->data();
        }
 $image_filename = $upload_result['file_name'];
 $docu_filename = $upload_result2['file_name '];
$this->MODEL->add_asset($image_filename, $docu_filename);

i tried to echo both file names and it works but my $docu_filename generates NULL value;
please help. thank you

A: hi its simple just check the file extension of uploaded file and make settings according to that. one more thing you have to set your html form enctype also. check the following example
form View
<form method="post" action="controller" enctype="multipart/form-data">
    <input type="file" name="test">
    <input type="submit" value="submit" />
</form>

in controller
 $path = $_FILES['test']['name'];
 $ext = pathinfo($path, PATHINFO_EXTENSION);
 $img_ext_chk = array('jpg','png','gif','jpeg');
 $doc_ext_chk = array('pdf','doc');

if (in_array($ext,$img_ext_chk))
        {
            $config['upload_path'] = './upload_images/';
            $config['allowed_types'] = 'jpg|png|jpeg|gif';
            $config['max_size'] = '0'; // 0 = no file size limit
            $config['max_width']  = '0';
            $config['max_height']  = '0';
            $config['overwrite'] = TRUE;
            $this->load->library('upload', $config);
             $this->upload->do_upload();
             $upload_result = $this->upload->data();
        }
       elseif (in_array($ext,$doc_ext_chk))
        {
            $config_document['upload_path'] = './upload_documents/';
            $config_document['allowed_types'] = 'pdf';
            $config_document['max_size'] = '0';
            $config_document['overwrite'] = TRUE;
            $this->load->library('upload', $config_document);
             $this->upload->do_upload();
             $upload_result2 = $this->upload->data();
        }


text:
Q: Saving data to an existing entity with Kinvey I am using Kinvey as a backend on my app and I need to know how to modify an object. Whenever I pull the object and modify the object it creates a new object in the server. I need it to modify the existing object. How can I do that?

A: All you have to do is update the object and set the entityID to the id you update and save it like you are saving a new object.


text:
Q: Can't install tmap R Package I am having trouble installing the tmap R package. I am trying to install it using install.packages("tmap") and mn receiving this error:
Error: package or namespace load failed for 'tmap' in namespaceExport(ns, exports):
 undefined exports: providers
Error: loading failed
Execution halted
ERROR: loading failed

Warning in install.packages :
  installation of package 'tmap' had non-zero exit status

I'm new to R, but have tried many of the basic bug fix approaches (Reinstalling R Studio, quitting and restarting a session, installing from a local tar.gz instead of CRAN) but none seem to work. I think the package is being installed successfully but is not being loaded. Is that correct? How would I get tmap to load correctly?
I'm using R vers 3.6.1
Cheers

A: The object providers is re-exported from leaflet. Please make sure that leaflet is installed correctly, and check if leaflet::providers exists.
I would also strongly recommend to upgrade R to 4.x, if possible. I recall that there were some packages in the dependency/imports tree that didn't work well for R 3.x.


text:
Q: Owin Self-Host WebApi Windows Authentication and Anonymous I have a self-hosted Owin WebAPI. I want to protect a few routes with authentication. The majority of the routes should be accessible anonymously.
I have succesfully implemented Windows-Auth, but now I get 401 - Unauthorized when trying to access the routes marked with [AllowAnonymous] when accessing them anonymously. If I call the method with valid credentials all works fine.
The perfect solution would be to allow anonymous by default and only require credentials when the action has the [Authorize] attribute.
Owin config
public void Configuration(IAppBuilder appBuilder)
{
    // Enable Windows Authentification
    HttpListener listener = (HttpListener)appBuilder.Properties["System.Net.HttpListener"];
    listener.AuthenticationSchemes = AuthenticationSchemes.IntegratedWindowsAuthentication;

    HttpConfiguration config = new HttpConfiguration();
    config.MapHttpAttributeRoutes();

    appBuilder.Use(typeof(WinAuthMiddleware));
    appBuilder.UseWebApi(config);
}

WinAuth OwinMiddleware
public class WinAuthMiddleware : OwinMiddleware
{
    public WinAuthMiddleware(OwinMiddleware next) : base(next) {}
    public async override Task Invoke(IOwinContext context)
    {
        WindowsPrincipal user = context.Request.User as WindowsPrincipal;
        //..
    }
}

An example Action
public class ValuesController : ApiController
{
    [AllowAnonymous] // attribute gets ignored
    [Route("Demo")]
    [HttpGet]
    public string Get()
    {
        //..
    }
}

A: Your issue is that you configured the HttpListener to support only Windows authentication. This is similar to configuring an IIS site with just Windows Authentication: every request to the site has to go through windows Authentication.
To selectively activate authentication, you need to allow both Windows authentication and anonymous authentication by changing your configuration to this
public void Configuration(IAppBuilder appBuilder)
{
    // Enable Windows Authentification and Anonymous authentication
    HttpListener listener =
    (HttpListener)appBuilder.Properties["System.Net.HttpListener"];
    listener.AuthenticationSchemes =
    AuthenticationSchemes.IntegratedWindowsAuthentication |
    AuthenticationSchemes.Anonymous;

    HttpConfiguration config = new HttpConfiguration();
    config.MapHttpAttributeRoutes();

    appBuilder.Use(typeof(WinAuthMiddleware));
    appBuilder.UseWebApi(config);
}

Do that and your standard [Authorize] and [AllowAnymous] tags start working as expected.


text:
Q: net/http server freezes under ab (ApacheBench) heavy load Golang net/http server on MacOS freezes after 16000 requests:
$ ab -c 4 -n 20000 http://127.0.0.1:8080/
This is ApacheBench, Version 2.3 <$Revision: 1826891 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 2000 requests
Completed 4000 requests
...
Completed 14000 requests
Completed 16000 requests
^C

A: Following is the explanation by Bill Neubauer:

This issue is caused by the OS running out of sockets.  ab and Go are
  cycling through socket pairs for communication faster than the OS can
  reallocate them for reuse.

Refer to https://github.com/golang/go/issues/66#issuecomment-66047858


text:
Q: Search a "title" and show "description" from XML in AS3 I have inputtext Search field if i Enter Title for ex(1-prop or 2-prop) in the field and press/Enter search then it should search the title and Title Codes for ex(t1...t4) or (a1....a4) from XML. and display in Dynamic Text field
How can i do that please help me!!....
<letter>
    <title>#</title>
    <mainTerm>
        <title>1-prop</title>
        <cell col="2">t1</cell>
        <cell col="3">t2</cell>
        <cell col="4">t3</cell>
        <cell col="5">t4</cell>
        <cell col="6">--</cell>
        <cell col="7">--</cell>
    </mainTerm>
    <mainTerm>
        <title>2-prop</title>
        <cell col="2">a1</cell>
        <cell col="3">a2</cell>
        <cell col="4">a3</cell>
        <cell col="5">a4</cell>
        <cell col="6">--</cell>
        <cell col="7">--</cell>
    </mainTerm>
</letter>

A: You can search a text (the title in your case) in your XML content using E4X ( ECMAScript for XML ) like this for example :
var xml:XML =
    <letter>
        <title>#</title>
        <mainTerm>
            <title>1-prop</title>
            <cell col="2">t1</cell>
            <cell col="3">t2</cell>
            <cell col="4">t3</cell>
            <cell col="5">t4</cell>
            <cell col="6">--</cell>
            <cell col="7">--</cell>
        </mainTerm>
        <mainTerm>
            <title>2-prop</title>
            <cell col="2">a1</cell>
            <cell col="3">a2</cell>
            <cell col="4">a3</cell>
            <cell col="5">a4</cell>
            <cell col="6">--</cell>
            <cell col="7">--</cell>
        </mainTerm>
    </letter>;

var cells:XMLList = xml.mainTerm.(title == '2-prop').cell;

for each(var cell:XML in cells) {
    trace(cell);    // gives for example : "a1"
}

you can also use for each loops like this :
for each(var term:XML in xml.mainTerm){
    if(term.title == '2-prop'){
        for each(var cell:XML in term.cell){
            trace(cell);    // gives for example : a3
        }
    }
}

For more about working with XML, take a look here.
Hope that can help.


text:
Q: Can I disable RTTI selectively in my code base to reduce the binary size? I'm working on an iPhone app that uses C++ and is almost at the 100 MB mark (the point at which Apple won't let people download it via WWAN). I've taken many steps to reduce the binary size, such as removing unneeded third-party dependencies. However, the app, and in particular the binary, is still large because it has a lot of features.
I've heard that disabling RTTI can reduce the binary size. Would it be possible to turn off RTTI for some files, e.g. all files without the strings "typeid" or "dynamic_cast" in them?

A: The space cost of RTTI is not associated with using it (via typeid or dynamic_cast), but of the type information associated with each class.  Thus the benefit would be to disable RTTI for individual classes (or groups of classes).
I know no such way to do that.
You might find that if you can reduce the number of classes with virtual functions, you can reduce the amount of RTTI information.  (For example, not all base classes need to have a virtual destructor - you only need that if you might call delete pBase.)
The other thing that can blow up executable size, is lots of templates.  In many cases you can make template functions which just forward to non-template functions to do the real work.


text:
Q: awk to match file1 with file2 and output matches I am trying to use awk to match file1 with file2 and print the lines that match in a separate file. File1 is ~4MB and I am getting the below error and I can not seem to fix it.  Thank you :).
awk 'NR==FNR{c[$0]; next} ($0 in c)' RS="," file1.txt RS="\n" file2.txt > match.txt

awk: program limit exceeded: maximum number of fields size=32767
  FILENAME="sort.2.txt" FNR=1 NR=1

File1
chr1:3063265-3063458 AVP:exon.3 8.55959
chr1:947806-947967 RSPO4:exon.3 246.54
chr2:12758246-12758422 CTD-2192J16.22:exon.2;MAN2B1:exon.1;MAN2B1:exon.20;MAN2B1:exon.22 221.483
chr2:57975642-57975745 KIF5A:exon.1;KIF5A:exon.23;KIF5A:exon.26 222.932

File2
AVP
KIF5A

Desired output
chr1:3063265-3063458 AVP:exon.3 8.55959
chr2:57975642-57975745 KIF5A:exon.1;KIF5A:exon.23;KIF5A:exon.26 222.932

A: you can try,
awk '
    FNR==NR{d[$0]; next;}          #Store each key to find, from file2
    {                              #for each line in file1
        for(k in d){               #for each key in d (file2)
            pat="(^|;)"k":";       #pattern to search (regular expression)
            if($2 ~ pat){
                print;             #print if match with RE
                break;
            }
        }
    }' file2 file1

you get,

chr1:3063265-3063458 AVP:exon.3 8.55959
chr2:57975642-57975745 KIF5A:exon.1;KIF5A:exon.23;KIF5A:exon.26 222.932


text:
Q: OpenGL ES 2 Projection Switching Foregroung and Background I have an array containing the the height of the vertices of a terrain map.
When I first draw the terrain it looks fine:

But as I rotate it across the z-axis, parts of the shape seem to be projected behind vertices on the back:
90 degree rotation (z-axis):

~180 degree rotation (z-axis):

Besides my implementation of the map, my code is fairly simple:
Vertex Shader:
attribute vec4 position;
attribute vec4 color;

uniform mat4 matrix;
varying vec4 interpolated_color;

void main() {
    gl_Position = matrix * position;
    interpolated_color = color;
}

Fragment_shader:
precision mediump float;

varying vec4 interpolated_color;

void main(){
   gl_FragColor = interpolated_color;
}

Renderer:
public class MapRenderer implements GLSurfaceView.Renderer {

    ...

    @Override
    public void onSurfaceCreated(GL10 gl, EGLConfig config) {
        GLES20.glClearColor(1.0f, 0.0f,0.0f, 1.0f);
        map = mapGen.composeMap(); //gets array with vertices heights
        mapView = new MapView(context, map, mapGen);
    }

    @Override
    public void onSurfaceChanged(GL10 gl, int width, int height) {
        GLES20.glViewport(0, 0, width, height);
        float aspect_ratio = (float) width/height;
        Matrix.perspectiveM(projectionMatrix, 0, 45, aspect_ratio, 1f, 10f);
    }

    @Override
    public void onDrawFrame(GL10 gl) {
        float[] scratch = new float[16];

        GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);

        Matrix.setIdentityM(modelMatrix, 0);

        Matrix.translateM(modelMatrix, 0, 0, 0, -4);
        Matrix.rotateM(modelMatrix, 0, -cameraAngle, 1, 0, 0); //cameraAngle initialized at 0 changes with user input
        Matrix.rotateM(modelMatrix, 0, mapAngle, 0, 0, 1); //mapAngle initialized at 0 changes with user input

        Matrix.multiplyMM(scratch, 0, projectionMatrix, 0, modelMatrix, 0);

        mapView.draw(scratch);
    }
}

MapView Class:
    public void draw(float[] mvpMatrix){
        int matrix = GLES20.glGetUniformLocation(program, "matrix");

        GLES20.glUniformMatrix4fv(matrix, 1, false, mvpMatrix, 0);

        //nFaces and facesBuffer are class variables
        GLES20.glDrawElements(GLES20.GL_TRIANGLES, nFaces*3, GLES20.GL_UNSIGNED_SHORT, facesBuffer);
    }

I tried to turn on and off face culling to see if any differences occurred but none did.
Changing the projection matrix also did not seem to have any effects besides changing the angle the error starts to occur. It seems to happen at ~90 degrees and up to ~270 degrees when using Matrix.perspectiveM and exactly at 90 and 270 when using Matrix.orthoM.
I also checked if OpenGL returned any errors by the glGetErrors() method and did not get anything.
My vertices are sorted in the buffer sequentially from the one located at (-1, 1, 0) to the last one located at (1, -1, 0). I don't know if that could cause this issue or, even if that was the case, how I could solve this in OpenGL ES 2 to support rotation accross the z-axis.

A: Depth Test needs to be enabled in order for OpenGL take distance into consideration.
On the Renderer:
    public void onSurfaceCreated(GL10 gl, EGLConfig config) {
        GLES20.glClearColor(1.0f, 0.0f,0.0f, 1.0f);

        GLES20.glEnable(GLES20.GL_DEPTH_TEST);

        map = mapGen.composeMap(); //gets array with vertices heights
        mapView = new MapView(context, map, mapGen);
    }


text:
Q: Why do we specify arrays size as a parameter when passing to function in C++? I searched this question, most of them says the same thing. Since we only pass the arrays address in a function, compiler can not know the arrays size by looking at the address, they say. I tried to test this by using this code, and both functions gave the same results. So, how does specifying the arrays size as a function parameter help me in a practical way?. In which conditions does specifying the size help us?.
class ArrayTest
{
    public:
     void say(int ar[])
     {
         cout<<ar[1]<<endl;
         cout<<ar[7]<<endl;
     }

      void say(int ar[],int sizeAn)
     {
         cout<<ar[1]<<endl;
         cout<<ar[7]<<endl;
     }

};

int main()
{
    ArrayTest test;
   int anAr[5] = {1,2,3,4,5};
   test.say(anAr);
   test.say(anAr,5);
    return 0;

}

A: Passing array size as a function parameter is a bad idea, because if you need an array as an array in function passing its size won't have any effect. The array you passed will be decayed to a pointer. So you need to maintain array as is.
Templates provide a simple and effective way to prevent array decay while passing them as function arguments.
template<std::size_t N>
void foo(int (&your_array)[N])
{
   for(int i = 0; i < N; i++)
      //process array, N will be your array size.
}
//simply pass array when calling the function. N be taken automatically.

//somewhere else
int main()
{
  int arr[10];
  foo(arr);
}

hope this helps.

A: Note that your code is invoking undefined behavior because you're accessing element 7 of an array that is only 5 elements big. Using the size parameter, you could for instance check if the index is past its size and not do that call instead.
In your example, you get the same results becaue you aren't actually using the parameter:
 void say(int ar[],int sizeAn)
 {
     cout<<ar[1]<<endl;
     cout<<ar[7]<<endl;
 }

sizeAn is unused, so it's not making any difference. But consider for instance the following code:
void say(int ar[],int sizeAn)
     {
         for (int i = 0; i < sizeAn; i++){
             cout<<ar[i]<<endl;
         }
     }

Here, it's printing all the items in the array, so it needs to know how big the array is. If you used an std::vector, for instance, you wouldn't need to pass the size as you can just call the size function, but you can't do that with C style arrays, so you need to pass that size as a parameter if you want to write a function that behaves differently depending on the size).
Or here's a more practical example of your code where the size parameter is used to avoid the undefined behavior:
void say(int ar[],int sizeAn)
 {
     cout<<ar[1]<<endl;
     if (sizeAn >= 8){
         cout<<ar[7]<<endl;
     }
 }

Now it's the same as your code with the change that it's only printing the element 7 if it actually exists.

A: As you say, compilers can't tell how big an array is if passed to a function.  Your first say function tries to reference past the end of the array (ar[7] is beyond the size of 5).  Your second say function means you can length check to make sure you don't make this error.
  void say(int ar[], int sizeAn)
  {
     if(sizeAn>1)
        cout<<ar[1];endl;
     if(sizeAn>7)
        cout<<ar[7];endl;
  }

This way, YOU know the length and the function can check it before accessing invalid memory locations.

A:
Why do we specify arrays size as a parameter when passing to function in C++?

Do we?
Well, sometimes. The canonical way to pass a range in C++ is using an iterator-pair though, even if I can see it evolve to using ranges when the Range-TS is finally used everywhere.
Anyway, there are other ways to convey what (sub-)range we want to work with. So, let's take a look:

*

*In-band-signalling, like NUL-terminator for c-strings.

*An implicit part of the functions contract, like "it will always be exactly 12 elements".

*Passing a view of the part we want. Unfortunately, until the ranges-TS is fully incorporated, standard-library-support for that is severely anemic, being restricted to std::string_view in C++17 and extended with std::span for contiguous ranges (like arrays) in C++20 (look at the guideline-support-library for now).

*Using an iterator-pair. The full flexibility of iterators, though calculating the length might be costly, or impossible without consuming the range. This is the preferred way in the standard-library.

*Using start-iterator and length. Also quite common, but not to the same degree, and does not allow iterators determining the length as you iterate, not that that is an issue here.

*Using a (constant where appropriate) reference to the whole container or range, probably templated for generality. This might be combined with point 3, but need not.

Of those, if you know the element-type, and restrict to contiguous arrays, pointer+length is the most comfortable and flexible to use for now, which does not need different code for different lengths, so that's that.

A: This is about you as a programmer having the chance to boundary check, not whether the compiler can do it.
Just try to print out all the elements in the array, with the size:
 void say(int ar[],int sizeAn)
 {
     for(int i=0; i< sizeAn; ++i)
         cout<<ar[i]<<endl;
 }

now without the size:
 void say(int ar[])
 {
     for(int i=0; i< /*HOW DO I KNOW NOW?*/; ++i)
         cout<<ar[i]<<endl;
 }


text:
Q: Installing patched version of R 3.4.0 on ubuntu When R upgraded to 3.4.0, a bug was introduced (Sweave commands exit 1 on success, rather than 0), which has broken all my reporting make files. I can fiddle with the make files to fix them, but a patched version of 3.4.0 has been released (see https://cran.r-project.org/, "CHANGES IN R 3.4.0 patched", and I would like to upgrade my R installation to get this fix.
I am using R on ubuntu (xenial), with this line in my apt sources file:
deb http://cran.stat.auckland.ac.nz/bin/linux/ubuntu xenial/.  I have run sudo apt update but no fixes for R have come through since 3.4.0 was released.
The question is, what is the "right" way to install the patched R?


text:
Q: Removing double quotes- Excel to Notepad I have written a macro to dump excel cells on to a notepad file. The cell contents appear along with a " in the .txt file. How do I get rid of the double quotes before writing it to the file?
Sub makeFile1()

    Dim ce As Range
    Dim ws As Worksheet

    Open "C:\queries.txt" For Output As #1
    For Each ws In ActiveWorkbook.Worksheets
          Write #1, "Create Table " & ws.Name
            For Each ce In Range("G2:G10")
               If ce.Next = "" Then
               Write #1, ce.Value
               ElseIf ce.Value <> "" Then
               Write #1, ce.Value & ","
               End If

            Next ce
    Next ws
    Close #1

End Sub

A: Use Print #1 instead of Write #1
Sub makeFile1()
Dim ce As Range
Dim ws As Worksheet

Open "C:\queries.txt" For Output As #1
For Each ws In ActiveWorkbook.Worksheets
      Print #1, "Create Table " & ws.Name
        For Each ce In Range("G2:G10")
           If ce.Next = "" Then
           Print #1, ce.Value
           ElseIf ce.Value <> "" Then
           Print #1, ce.Value & ","
           End If

        Next ce
Next ws
Close #1

End Sub


text:
Q: Insert Row and Update the same row In PHP / MYSQL simultaneously Please help me with this:
I am creating a survey facility for the administrator. The administrator is asked for the number of questions in the questionnaire. And based on this the rows are created in the survey details table. In the question table the corresponding number of rows are created for the same in the question table.
Now the admin can enter the questions and answers. For this I need to insert the row in question table and update it from the informations collected from FORM using a loop. But the inserted rows are not getting updated simultaneously. Help me with this or is there any other way to do this?
This is my code: Please ignore the programming style as this is the script by a novice:
$sid = intval ($_GET['ids']);
$noq = intval ($_GET['qn']);
for($noq !=0;$noq >=1;$noq--){
    $q = "insert into sur_ques (sur_id) values ('$sid')";
    $ex = mysql_query($q);
    $rs = mysql_affected_rows();
    if($rs ==1){ echo" Questions Rows Created Corresponding to Survey Subject";}
?>
<form name="form1" method="post" action="<?php echo($PHP_SELF); ?>">

Ques No-<?php echo"$noq";?>

<textarea name = "q" rows ="10" cols = "70" wrap = "hard" ></textarea>

Ans 1:	<input type="text" name="a1" size="37" />

Ans 2:	<input type="text" name="a2" size="37"  />

Ans 3:	<input type="text" name="a3" size="37"  />

Ans 4:	<input type="text" name="a4" size="37" />

<input type = "submit" name="qa" Value = "Add Q&A" />
<input type ="reset" Value="Reset" />
</form>
<?
    if ($_POST['qa']){
        $id = mysql_insert_id();
        $result = mysql_query("update ques set q_txt = '$q', ans1 = '$a1' ans2 = '$a2'  ans4 = '$a4' ans4 = '$a4' where q_id = '$id'");
        if($r = mysql_num_rows($result)){
            echo" Question and answers updated";
        }
    } else {
        break;
    }
}
?>

A: I dont get you .. may be you can put more info like table structure so that i can understand it well.
but one thing for sure you can not update and insert row simultaneously... you will have to insert row into database in order to update row.

A: I think what you are looking for is mysql_insert_id.
session_start();
$q = "INSERT INTO table (id,key1,key2) VALUES (null,'value1','value2')";
$r = mysql_query($q);
$_SESSION['rowid'] = mysql_insert_id();

then subsequent queries would do:
$sq = "UPDATE table SET key='value',secondkey='secondvalue', WHERE id=$_SESSION['rowid'] ";
$sr = mysql_query($sq);

I don't see the need for a loop when you can insert/update as many columnsas you need in one go as you can see above. Doing it like this you will never need to insert and update at the same time (which is impossible), because you simply start the record with whatever info is available, or even if no info is available, you create an empty row, store the id and then update the row as new infomration becomes available.

A: "In the question table the corresponding number of rows are created for the same in the question table." - did you mean questions and answers?
Well you have a form, you have two type of inputs (questions[] and answers[]), then in cycle you just insert a question and a corresponding answer text (based on input's key) and connect them (answer should have quesitonID or vise versa, depending on what you insert first and what type of multiplicity connection is between them.. i guess question can have multiple answers)


text:
Q: Optimize query in Laravel Backpack n-n relationships I am building a backend panel for a website with Laravel Backpack. It is really nice, but I have noticed that relationship queries are very expensive.
I have two models: Product and Center with a many to many relationship between them. In my CenterCrudController I have defined a field this way:
$this->crud->addColumns([
    // More fields...
    [
        'label' => 'Products',
        'type' => 'select2_multiple',
        'name' => 'products', // the method that defines the relationship in your Model
        'entity' => 'products', // the method that defines the relationship in your Model
        'attribute' => 'name', // foreign key attribute that is shown to user
        'model' => 'App\Models\Product', // foreign key model
        'pivot' => true, // on create&update, do you need to add/delete pivot table entries?
     ],
     // More fields...
]);

It works fine, showing a select multiple field with related models. But the query used is SELECT * FROM products, which is highly expensive (table products have thousands of records with about 25 columns).
In this example I only need id and name fields. I am looking for something like Query Builder select() method.
Is there a way for optimizing this type of query?
Thanks in advance!

A: Not sure if this is actually an answer, but I'll post it anyway.
The best solution (as pointed by @tabacitu) was using select2_from_ajax field. It doesn't slow page load and make an ajax request for retrieving data only when user clicks on the select field.


text:
Q: PHP PDO query to mssql server sometimes gets no response from server I'm trying to run a very simple test query using PDO and the dblib driver to get data from a remote MSSQL server. The test query is:
SELECT * FROM product WHERE part = 'ABC123'

When I load the page in Chrome I get a message, almost instantly, saying: "No Data Received" with an error code of ERR_EMPTY_RESPONSE. Loading it in FireFox has the same result but with the message: "The Connection Was Reset".
I've tried using mssql_query instead of PDO and it works perfectly, so I thought it must be a problem with my PDO connection code. The code I use to connect is:
new PDO("dblib:host=xxx.xxx.xxx.xxx:1433;dbname=xxxx","user","pass",
                array(PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION,
                      PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC));

The thing that has got me stumped is that the PDO code connects to the database fine and when I run the query:
SELECT ID,partNumber,description FROM product WHERE part ='ABC123'

It works as expected, and I don't get any of the response/connection errors as before.
I've spent hours searching Google but can't find a reason why I'm getting these errors.
Does anyone have a solution or any idea as to what's causing this problem? I would like to use PDO instead of mssql_query as I want to make use of PDO's features, but at the moment, mssql_query seems to be my only option.


text:
Q: date format displays different in recordeditform I am creating a form for contact object update. I am using recordeditform to display the field values.
in that i am using the below field
<lightning:inputField fieldName="Birthdate" />

when I select any date for the above field, it is displaying as
Nov 27, 2019

But when we create a new contact which is standard one Birthdate is displayed as 11/21/2019
How can I change the date format for lightning:inputField which is inside
lightning:recordEditForm


text:
Q: Import csv into django models I have models defined as
class Event(models.Model):
    event_id=models.IntegerField(primary_key=True)
    OS_CHOICE=(('Win 2003','windows 2003'),
        ('Win 2008','Windows 2008'),
        ('Win XP','Windows XP'),
        ('Win VISTA','Win VISTA'),
        ('Win 2007','Windows 2007'),
        )
    windows=models.CharField(max_length=10,choices=OS_CHOICE,default='Win 2003')

    def __unicode__(self):
        return " %s, event_id :%s" \
            % (self.windows, self.event_id)
    class Meta:
        db_table= 'event'
        verbose_name_plural='events'

class Eventgroups(models.Model):
    event=models.ManyToManyField(Event)
    group_name=models.CharField(max_length=100)

    def __unicode__(self):
        return "%s,  %s" \
            % (self.group_name, self.event)
    class Meta:
        db_table= 'eventgroup'
        verbose_name_plural='eventgroups'

class Groups_import(models.Model):
    event_id=models.IntegerField()
    windows=models.CharField(max_length=100)
    group_name=models.CharField(max_length=100)

I want to write a view that imports a csv to database with the above model definition.The user will be asked to browse to where the csv file is located and click on a button to import csv.
Anybody with an insight on how to do this please?

A: You can use:

*

*django-adaptors

*django-csv-importer
See how to import csv data into django models
Or you can write your own routines:
# sudo code
file = request.FILES['fileUpload']
data = [row for row in csv.reader(file.read().splitlines())]
for raw in data:
    _, created = Event.objects.get_or_create(
            event_id=row[0],
            windows=row[1]
            )


text:
Q: Fastest way to get dynamically updated HTML content from website? I want to scrape a stocks website and get the prices using selenium. I can't use normal HTML requests as the HTML is dynamic.
I am using the headless selenium webdriver to get the data, but it takes around 30 seconds for each request.
Is there a faster way to get the dynamic HTML?

A: No, you are stuck with Selenium's wait-time with rendering
Dynamic HTML requires a full browser. There is not much negotiating with that. If your pages are separate and distinct, i.e. you are scraping stocks.com/oilandgas as well as stocks.com/agriculture, there is a possible way to speed things up.
The one option you might have is to create a separate thread for each Selenium Webdriver instance and have both web pages scraped at the same time by two different Selenium Webdrivers.
The caveat to that is that it will only speed things up if the bottleneck (what is causing the slowness) is the rendering of the website.
If it is the internet speed, the processing power of your computer, or the server speed of the website, this would not improve things.
Actually, Daniel Farrell below suggests that it would improve the networking speed. You may want to give this a shot.

A: That site is getting data from a XHR

so you could just load that with requests and json.loads which is way faster already.
As far as getting updated HTML faster than polling, there are some frameworks (puppeteer) that can send update events from the browser to the main script but AFAIK there's no way to do it in Python.

A: There are two APIs you can use to get summary info and the company profile based on ticker. You can use faster requests and Session for efficiency to make requests for this info.
import requests

tickers = ['FB']
results = {}

with requests.Session() as s:
    for ticker in tickers:
        results[ticker] = {}
        r = s.get(f'https://api.nasdaq.com/api/quote/{ticker}/summary?assetclass=stocks').json()
        results[ticker]['summary'] = r
        r = s.get(f'https://api.nasdaq.com/api/company/{ticker}/company-profile').json()
        results[ticker]['profile'] = r


text:
Q: Является ли правильной практикой, объединять несколько ссылок на объекты POJO классов в один класс, для удобного доступа к ним через последний Например:
public class A {
    // Какие-то переменные экземпляра и т.д.
}

public class B {
    // Какие-то переменные экземпляра и т.д.
}

public class C {
    // Какие-то переменные экземпляра и т.д.
}

И класс который объединяет все остальные:
public class All {
    private A a;
    private B b;
    private C c;

    public All(A a, B b, C c) {
        this.a = a;
        this.b = b;
        this.c = c;
    }
    // Геттеры и сеттеры для получения доступа к переменным экземпляра.
}

Имеет ли такой подход место жить? Или все-таки лучше получать доступ к экземплярам классов по отдельности?

A: По структуре All ничем не отличается от обычного POJO:
class Employee {
     Person person;
     Department department;
     Manager manager;
     ...
}

Т.е. в структуре, как таковой, ничего сверхкриминального нет. Целесообразность же зависит от того как класс будет использоваться.
Имеет ли All логический смысл? Можно ли дать классу какое-то осмысленное имя? Наверняка есть какая-либо причина по которой A, B и C часто используются вместе.
Будут ли у All какие-либо обязанности? Если над «вложенными» объектами выполняются одни и те же действия, то возможно их стоит заключить в методы как раз в All.
В общем, если All улучшает код, то он имеет смысл, если нет — то нет. Дать более точный ответ не зная как и где классы используются нельзя. Паттерны проектирования не висят в воздухе, они очень тесно связаны с алгоритмами.


text:
Q: Visualization of a slit annulus? I have come across the following description of a slit annulus:
$$ \sqrt{e} < |z| < e^2, z \notin(-e^2, -\sqrt{e})$$
I am confused what this means. The first part makes good enough sense. It is an annulus and the outer radius is $e$ and the inner radius is $\sqrt{e}$. Does the second part mean that it is only the positive real axis? Or does it mean that its the annulus but not the part that is on the negative real axis?

A: Nevermind. Thought about it for a second and it just means without the negative real axis. It's just saying that $x + iy \notin (-e^2 + 0i, -\sqrt{e} + 0i)$.


text:
Q: HTML transfer to Filezilla (images won't show) "This won't transfer to the FileZilla correctly from Notepad++ the images  won't show? I asked the teacher for help, but he doesn't know the material well enough to trouble shoot the problem. Internet Explorer will run the module and the text runs just fine, but Google Chrome say Error 2, and FileZilla won't register the pictures, they only show as black box icons, pls help"

    header for the home page
    <title> Woody's Wondering's</title>

Which way did Woody Go?

Home
Places To Go
Whats Free

 Kids....Cheap easy Fun!

Adults Only

You Next Adventure is only a click away!!!

Welcome to Woody's Wonderings were everything is cheep and easy to find in Ohio.....How Cheap, well pracically 20 dollars to free.

Meeting all your fun fun needs!!!

Keeping the site updated with new and improved places & Events year around

Jessica Harper

A: Your image is in the head of the html document. Correct structure for html is,
<!doctype html>

    <meta charset="utf-8">
    <title>The HTML5 Template</title>
    <!–– Style sheets & other importations go here ––>
    <link rel="stylesheet" href="css/styles.css">

    <!–– Your content goes here ––>

    <!–– Javascript files go here ––>

From w3schools,

The  element is a container for metadata (data about data) and
  is placed between the  tag and the  tag.
HTML metadata is data about the HTML document. Metadata is not
  displayed.
Metadata typically define the document title, character set, styles,
  links, scripts, and other meta information.

But I tested myself, and the images do work if the image exists in the path. Please check the image exists in the location you have in the img tag.
I am assuming you have uploaded the images along with the html file. If not please upload the images through filezilla to the correct location.
The best way to find what is the issue is to check the browser console. You may find an error saying no image found in path/to/your/image and that is where you have to put your image!

A: Your HTML is malformed and does not have an opening  tag, which could be causing some issues.  I'd recommend using the W3C HTML Validator to validate your code.
Errors like this are easier to visually spot if you use some sort of code-formatting/"pretty-print" tool (I like this one).
 Notepad++ probably has a plugin for this as well.


text:
Q: Adding all existing AWX inventories to a new group I have a multiple inventories created in AWX. For admin/reporting purpose, I need to execute a playbook in all hosts ( Multiple inventories). Is there a way to execute a playbook across all existing inventories in one go. Any quick help would be much appreciated.
Thanks
Uday

A: Use smart inventory,

*

*Create a smart inventory in awx

*In the 'SMART HOST FILTER' give '.' and click search

*Then click save

*The new smart inventory will have all the hosts containing '.'

*Target your Job to the new smart inventory created

More info on smart inventories
More info on what search patterns you can use