问:
java.io.FileNotFoundException: /storage/emulated/0/downloadedfilem.jpg (Permission denied)
i am trying to download and store image using Async task in android , when clicking download button getting following error.

```<code>    W/System.err: java.io.FileNotFoundException: /storage/emulated/0/downloadedfilem.jpg (Permission denied)
12-07 11:01:00.120 28478-28540/myoracle.com.quotes W/System.err:     at java.io.FileOutputStream.open(Native Method)
12-07 11:01:00.120 28478-28540/myoracle.com.quotes W/System.err:     at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
12-07 11:01:00.120 28478-28540/myoracle.com.quotes W/System.err:     at java.io.FileOutputStream.<init>(FileOutputStream.java:108)
12-07 11:01:00.120 28478-28540/myoracle.com.quotes W/System.err:     at myoracle.com.quotes.WallpaperDeatilsActivity$ImageDownload.doInBackground(WallpaperDeatilsActivity.java:113)
12-07 11:01:00.120 28478-28540/myoracle.com.quotes W/System.err:     at myoracle.com.quotes.WallpaperDeatilsActivity$ImageDownload.doInBackground(WallpaperDeatilsActivity.java:91)
</code>```

WallpaperActivity.java

```<code>class ImageDownload extends AsyncTask<String, String, String> {

    @Override
    protected String doInBackground(String... params) {
        int count;
        try {

            String root = Environment.getExternalStorageDirectory().toString();

            System.out.println("Downloading");
            URL url = new URL(params[0]);

            URLConnection conection = url.openConnection();
            conection.connect();
            // getting file length
            int lenghtOfFile = conection.getContentLength();

            // input stream to read file - with 8k buffer
            InputStream input = new BufferedInputStream(url.openStream(), 8192);

            // Output stream to write file
            System.out.println(root);
            OutputStream output = new FileOutputStream(root+"/downloadedfilem.jpg");
            byte data[] = new byte[1024];
            long total = 0;
            while ((count = input.read(data)) != -1) {
                total += count;
                // writing data to file
                output.write(data, 0, count);
                System.out.println(count);
            }
            // flushing output
            output.flush();
            // closing streams
            output.close();
           input.close();

        } catch (Exception e) {
            e.printStackTrace();
        }
</code>```

Android Target Api 7.1.1

Permissions added in manifest

android.permission.READ_EXTERNAL_STORAGE

android.permission.WRITE_EXTERNAL_STORAGE

答: After Android 6.0 Marshmellow you need Runtime Permissions to access user private data like Local storage. https://developer.android.com/training/permissions/requesting.html</p>

Body:
i am trying to download and store image using Async task in android , when clicking download button getting following error.

    W/System.err: java.io.FileNotFoundException: /storage/emulated/0/downloadedfilem.jpg (Permission denied)
12-07 11:01:00.120 28478-28540/myoracle.com.quotes W/System.err:     at java.io.FileOutputStream.open(Native Method)
12-07 11:01:00.120 28478-28540/myoracle.com.quotes W/System.err:     at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
12-07 11:01:00.120 28478-28540/myoracle.com.quotes W/System.err:     at java.io.FileOutputStream.<init>(FileOutputStream.java:108)
12-07 11:01:00.120 28478-28540/myoracle.com.quotes W/System.err:     at myoracle.com.quotes.WallpaperDeatilsActivity$ImageDownload.doInBackground(WallpaperDeatilsActivity.java:113)
12-07 11:01:00.120 28478-28540/myoracle.com.quotes W/System.err:     at myoracle.com.quotes.WallpaperDeatilsActivity$ImageDownload.doInBackground(WallpaperDeatilsActivity.java:91)

WallpaperActivity.java

class ImageDownload extends AsyncTask<String, String, String> {

    @Override
    protected String doInBackground(String... params) {
        int count;
        try {

            String root = Environment.getExternalStorageDirectory().toString();

            System.out.println("Downloading");
            URL url = new URL(params[0]);

            URLConnection conection = url.openConnection();
            conection.connect();
            // getting file length
            int lenghtOfFile = conection.getContentLength();

            // input stream to read file - with 8k buffer
            InputStream input = new BufferedInputStream(url.openStream(), 8192);

            // Output stream to write file
            System.out.println(root);
            OutputStream output = new FileOutputStream(root+"/downloadedfilem.jpg");
            byte data[] = new byte[1024];
            long total = 0;
            while ((count = input.read(data)) != -1) {
                total += count;
                // writing data to file
                output.write(data, 0, count);
                System.out.println(count);
            }
            // flushing output
            output.flush();
            // closing streams
            output.close();
           input.close();

        } catch (Exception e) {
            e.printStackTrace();
        }

Android Target Api 7.1.1

Permissions added in manifest

android.permission.READ_EXTERNAL_STORAGE

android.permission.WRITE_EXTERNAL_STORAGE


来源: stackexchange

问:
How can I mod rewrite all traffic to index.php but also to a backend directory?
I have a .htaccess as follows:

```<code><IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*) index.php [L]
</IfModule>
</code>```

My directory is set up as follows:

```<code>root directory:
  html:
      index.php
      .htaccess
  server (code):
      site:
          index.php
          test.php
</code>```

Requests go into html/index.php, and then the server gets initiated in the backend.  Calling $_SERVER['REQUEST_URI']; yields the following for http://localhost/

```<code>Request URL : /index.php
</code>```

This is correct, because I can then add on site/index.php.  However, I want to also do http://localhost/test and have it changed to /site/test.php.  The following is what happens when calling $_SERVER['REQUEST_URI']; for http://localhost/test

```<code>Request URL : /testindex.php
</code>```

What should happen is Request URL : /test so then I can add on the site/test.php myself.

Thank you!

答:
Files / Directories cannot be accessed outside the document_root. The simple solution is to update the index.php as a router. Then the router needs to include the corresponding files, if it exists. Otherwise you need to handle the file not exists situation, such as response 404 error.

You may need to update this .htaccess to redirect all the request to index.php:

```<code><IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^public

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    RewriteRule ^$ index.php [L]
    RewriteRule ^(.*) index.php?route=$1 [QSA,L]

</IfModule>
</code>```

Then, you can parse the route in index.php:

```<code><?php
    if (isset($_GET['route'])) {
        $route = $_GET['route'];
        if (file_exists(__DIR__.'/../site/' . $route)) {
            include __DIR__.'/../site/' . $route;
        }
    }
?>
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have a .htaccess as follows:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*) index.php [L]
</IfModule>

My directory is set up as follows:

root directory:
  html:
      index.php
      .htaccess
  server (code):
      site:
          index.php
          test.php

Requests go into html/index.php, and then the server gets initiated in the backend.  Calling $_SERVER['REQUEST_URI']; yields the following for http://localhost/

Request URL : /index.php

This is correct, because I can then add on site/index.php.  However, I want to also do http://localhost/test and have it changed to /site/test.php.  The following is what happens when calling $_SERVER['REQUEST_URI']; for http://localhost/test

Request URL : /testindex.php

What should happen is Request URL : /test so then I can add on the site/test.php myself.

Thank you!

Body:
Files / Directories cannot be accessed outside the document_root. The simple solution is to update the index.php as a router. Then the router needs to include the corresponding files, if it exists. Otherwise you need to handle the file not exists situation, such as response 404 error.

You may need to update this .htaccess to redirect all the request to index.php:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^public

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    RewriteRule ^$ index.php [L]
    RewriteRule ^(.*) index.php?route=$1 [QSA,L]

</IfModule>

Then, you can parse the route in index.php:

<?php
    if (isset($_GET['route'])) {
        $route = $_GET['route'];
        if (file_exists(__DIR__.'/../site/' . $route)) {
            include __DIR__.'/../site/' . $route;
        }
    }
?>


问:
Pass argument to pub function from React sub in Meteor?
I am publishing all my comments collection with this:

```<code>Meteor.publish('comments', function() {
  return Comments.find(
    {},
    { fields: { date: 1, body: 1, user: 1, attachedTo: 1, attachedToID: 1 } },
  );
});
</code>```

And subscribing in a React component with this:

```<code>export default withTracker(() => {
  let commentsSub = Meteor.subscribe('comments');
  return {
    comments: Comments.find({}).fetch(),
  };
})(MyReactComponent);
</code>```

So far this works but now I want to refine what comments are sent. The attachedTo field for comments can be either 'profile' or 'homepage'. Ive modified my pub function to take an input:

```<code>Meteor.publish('comments', function(attachedTo) {
  return Comments.find(
    { attachedTo: attachedTo },
    { fields: { date: 1, body: 1, user: 1, attachedTo: 1, attachedToID: 1 } },
  );
});
</code>```

But I cant see how to pass this parameter from my React component:

```<code>export default withTracker(() => {
  let commentsSub = Meteor.subscribe('comments');
  return {
    comments: Comments.find({ attachedTo: 'group' }).fetch(),
  };
})(MyReactComponent);
</code>```

答:
Ive expanded on blueren's answer as I wanted to have named parameters: </p>

```<code>export default withTracker(() => {
  let commentsSub = Meteor.subscribe('comments', { attachedTo: 'profile' });
  return {
    comments: Comments.find({}).fetch(),
  };
})(MyReactComponent);

Meteor.publish('comments', function(attachedTo) {
  return Comments.find(
    { attachedTo },
    { fields: { date: 1, body: 1, user: 1, attachedTo: 1, attachedToID: 1 } },
  );
});
</code>```

Body:
I am publishing all my comments collection with this:

Meteor.publish('comments', function() {
  return Comments.find(
    {},
    { fields: { date: 1, body: 1, user: 1, attachedTo: 1, attachedToID: 1 } },
  );
});

And subscribing in a React component with this:

export default withTracker(() => {
  let commentsSub = Meteor.subscribe('comments');
  return {
    comments: Comments.find({}).fetch(),
  };
})(MyReactComponent);

So far this works but now I want to refine what comments are sent. The attachedTo field for comments can be either 'profile' or 'homepage'. Ive modified my pub function to take an input:

Meteor.publish('comments', function(attachedTo) {
  return Comments.find(
    { attachedTo: attachedTo },
    { fields: { date: 1, body: 1, user: 1, attachedTo: 1, attachedToID: 1 } },
  );
});

But I cant see how to pass this parameter from my React component:

export default withTracker(() => {
  let commentsSub = Meteor.subscribe('comments');
  return {
    comments: Comments.find({ attachedTo: 'group' }).fetch(),
  };
})(MyReactComponent);

Body:
Ive expanded on blueren's answer as I wanted to have named parameters:

export default withTracker(() => {
  let commentsSub = Meteor.subscribe('comments', { attachedTo: 'profile' });
  return {
    comments: Comments.find({}).fetch(),
  };
})(MyReactComponent);

Meteor.publish('comments', function(attachedTo) {
  return Comments.find(
    { attachedTo },
    { fields: { date: 1, body: 1, user: 1, attachedTo: 1, attachedToID: 1 } },
  );
});


问:
Slow response-time cheat sheet
Does anyone have links to current and historical papers and authoritative links (statistics and blog posts) regarding response-time for user interfaces?

Naturally the authoritative link is Human factors design criteria in man-computer interaction

Some key quotes include:

[Regarding] response to request for
  next page. […] Delays of longer than 1
  second will seem intrusive on the
  continuity of thought.

And

Assume an inquiry of any kind has been
  made. The user – and his attention –
  is captive to the terminal until he
  receives a response. If he is a busy
  man, captivity of more than 15
  seconds, even for information
  essential to him, may be more than an
  annoyance and disruption. It can
  readily become a demoralizer – that is
  a, reducer of work pace and of
  motivation to work.

These quotes are 40 years old, yet so relevant today.

There is also Jacob Nielsen's authoritative excerpt.

I would like to collect all the links to this kind of research under this community wiki.

Next time you are told to ignore response times by your manager or build a feature that will slow down your application you can simply send them a link to this page.

答:
I just came across:

System Response Time and User Satisfaction: An Experimental Study of Browser-based Application (watch out its a PDF) by John A. Hoxmeier, Ph.D.

The summary of the findings are:

H1 satisfaction decreases as response time increases [supported]

H2 Dissatisfaction leads to discontinued use [supported]

H3 ease of use decreases as satisfaction decreases [supported]

H4 experienced users more tolerant of slower response times [not supported]

ContentLicense: CC BY-SA 2.5

Title: Slow response-time cheat sheet


问:
DataInputStream for input text files?
I am learning to read and write in Java and am stuck with a simple exercise. The program reads from 2 txt files that each contain numbers in rows. It writes to an output file the result of the multiplication of each row of numbers. eg. file 1 row 1 : 10, file 2 row 1: 2 , the program should write 20 to the output file. My code seems to have something missing somewhere. The output file is created but nothing is written to it. Any ideas?</p>

```<code>import java.io.*;
import java.util.*;

class ReadWriteData
{
    public static void main(String[] args) throws Exception
    {

        //create ouput file
        PrintWriter output = new PrintWriter("output2.txt");

        DataInputStream file1 = new DataInputStream(new FileInputStream(args[0]));
        DataInputStream file2 = new DataInputStream(new FileInputStream(args[1]));

        try
        {

        // read data from file
        while (true)
        {
            double number1 = file1.readDouble();
            double number2 = file2.readDouble();
            double result = number1 * number2 ;
            output.println(result);

        }

        }

        catch (IOException e)
        {
            System.err.println("Error");
            System.exit(1);
        }

        output.close() ;

    }
}
</code>```

答:
After </p>

```<code>output.println(result);
</code>```

<p>add </p>

```<code>output.flush();
</code>```

Title: DataInputStream for input text files?

Body:
I am learning to read and write in Java and am stuck with a simple exercise. The program reads from 2 txt files that each contain numbers in rows. It writes to an output file the result of the multiplication of each row of numbers. eg. file 1 row 1 : 10, file 2 row 1: 2 , the program should write 20 to the output file. My code seems to have something missing somewhere. The output file is created but nothing is written to it. Any ideas?

import java.io.*;
import java.util.*;

class ReadWriteData
{
    public static void main(String[] args) throws Exception
    {

        //create ouput file
        PrintWriter output = new PrintWriter("output2.txt");

        DataInputStream file1 = new DataInputStream(new FileInputStream(args[0]));
        DataInputStream file2 = new DataInputStream(new FileInputStream(args[1]));

        try
        {

        // read data from file
        while (true)
        {
            double number1 = file1.readDouble();
            double number2 = file2.readDouble();
            double result = number1 * number2 ;
            output.println(result);

        }

        }

        catch (IOException e)
        {
            System.err.println("Error");
            System.exit(1);
        }

        output.close() ;

    }
}

Body:
After

output.println(result);

add

output.flush();


问:
How To Access Invocation Count in Netbeans?
I have a project I'm working on and I need to do some profiling now that the bulk of the coding is finished. However one of the stipulations for completion is that I need to find out Total Time taken for the methods to execute and also how many times a particular method is executed. However it's driving me nuts trying to find Invocation Count on Netbeans. One of the help pages online said click the Drop Down Arrow in the window but all I can see as a selection column called "Hits"; I googled that and no explanations crop up. Anyone here have experience with NetBeans profiling? Thanks in advance.

答:
I think the solution may be as simple as changing the list selection labeled Profile in the OP screen shot from All classes to Selected methods. However, if that is not the case, here is a walk through of the setup to get the invocation count for selected methods in a results snapshot when profiling in NetBeans:

Select Profile -> Profile Project for your project.

If no profiling has been set up the screen should look similar to this:

Click the Configure Session button (or link) shown in the screen shot above.

From the drop down list check User Defined Profiling Points, and select Methods.

This will cause a Settings cog wheel icon on the far right to be displayed. Click that to display another drop list labeled Profile with a default selection of All classes.

Click that Profile drop list, and select Selected methods which will allow Invocations to be shown in the profiling results. (The screen shot in the OP shows All Classes is selected instead.)

Having chosen the profile Selected methods, click the Add button shown in the screen shot below, and select the methods to profile in the Select Method dialog:

Finally run your app with the selected profiling options by clicking the Profile button with the green triangle to its left.

The Invocations column (n.b. not Invocation Count) should be displayed in the results. If not then click the black inverted triangle on the far right of the column headers row, which allows toggling the display of each column in the results snapshot.

These instruction specifically apply to the most recent stable release of NetBeans (8.2) but the general principles should be valid for earlier releases as well, though possibly with some differences in the details.


问:
How to update multiple things in collection in Pymongo?
```<code>collection.find_one_and_update(
    {'username': hero.name}, {'$set': {'exp': hero.exp}})
collection.find_one_and_update(
    {'username': hero.name}, {'$set': {'level': hero.level}})
</code>```

<p>I have two updates like this. Is there any way to combine them into one? </p>

答:
You need to merge the updated values object like so:

collection.find_one_and_update({
    'username': hero.name
}, {
    '$set': {
        'exp': hero.exp,
        'level': hero.level
}})
```

Body:
collection.find_one_and_update(
    {'username': hero.name}, {'$set': {'exp': hero.exp}})
collection.find_one_and_update(
    {'username': hero.name}, {'$set': {'level': hero.level}})

I have two updates like this. Is there any way to combine them into one?


问:
matplotlib color line by "value"
Various versions of this question have been asked before, and I'm not sure if I'm supposed to ask my question on one of the threads or start a new thread. Here goes:

I have a pandas dataframe where there is a column (eg: speed) that I'm trying to plot, and then another column (eg: active) which is, for now, true/false. Depending on the value of active, I'd like to color the line plot.

This thread seems to be the "right" solution, but I'm having an issue:
seaborn or matplotlib line chart, line color depending on variable The OP and I are trying to achieve the same thing:

Here's a broken plot/reproducer:

```<code>Values=[3,4,6, 6,5,4, 3,2,3, 4,5,6]
Colors=['red','red', 'red', 'blue','blue','blue', 'red', 'red', 'red', 'blue', 'blue', 'blue']
myf = pd.DataFrame({'speed': Values, 'colors': Colors})

grouped = myf.groupby('colors')
fig, ax = plt.subplots(1)

for key, group in grouped:
   group.plot(ax=ax, y="speed", label=key, color=key)
</code>```

The resultant plot has two issues: not only are the changed color lines not "connected", but the colors themselves connect "across" the end points:

What I want to see is the change from red to blue and back look like it's all one contiguous line.

Color line by third variable - Python seems to do the right thing, but I am not dealing with "linear" color data. I basically am assigning a set of line colors in a column. I  could easily set the values of the color column to numericals:

```<code>Colors=['1','1', '1', '2','2'...]
</code>```

if that makes generating the desired plot easier.

There is a comment in the first thread:

You could do it if you'll duplicate points when color changed, I've
  modified answer for that

But I basically copied and pasted the answer, so I'm not sure that comment is entirely accurate.

答:
I took a crack at it. Following the comments in the other question that you linked lead me to this. I did have to get down to matplotlib and couldn't do it in pandas itself. Once I converted the dataframe into lists, its pretty much the same code as the one from the mpl page.

I create the dataframe similar to yours:

```<code>vals=[3,4,6, 6,5,4, 3,2,3, 4,5,6]
colors=['red' if x < 5 else 'blue' for x in vals]
df = pd.DataFrame({'speed': vals, 'danger': colors})
</code>```

Converting the vals and index into lists

```<code>x = df.index.tolist()
y = df['speed'].tolist()
z = np.array(list(y))
</code>```

Break down the vals and index into points and then create line segments
out of them.

```<code>points = np.array([x, y]).T.reshape(-1, 1, 2)
segments = np.concatenate([points[:-1], points[1:]], axis=1)
</code>```

Create the colormap based on the criteria used while creating the dataframe. In my case, speed less than 5 is red and rest is blue.

```<code>cmap = ListedColormap(['r', 'b'])
norm = BoundaryNorm([0, 4, 10], cmap.N)
</code>```

Create the line segments and assign the colors accordingly

```<code>lc = LineCollection(segments, cmap=cmap, norm=norm)
lc.set_array(z)
</code>```

Plot !

```<code>fig = plt.figure()
plt.gca().add_collection(lc)
plt.xlim(min(x), max(x))
plt.ylim(0, 10)
</code>```

Here is the output:

Note: In the current code, the color of the line segment is dependent on the starting point. But hopefully, this gives you an idea.

I'm still new to answering questions here. Let me know if I need to add/remove some details. Thanks!

Title: matplotlib color line by "value"

Body:
Various versions of this question have been asked before, and I'm not sure if I'm supposed to ask my question on one of the threads or start a new thread. Here goes:

I have a pandas dataframe where there is a column (eg: speed) that I'm trying to plot, and then another column (eg: active) which is, for now, true/false. Depending on the value of active, I'd like to color the line plot.

This thread seems to be the "right" solution, but I'm having an issue:
seaborn or matplotlib line chart, line color depending on variable The OP and I are trying to achieve the same thing:

Here's a broken plot/reproducer:

Values=[3,4,6, 6,5,4, 3,2,3, 4,5,6]
Colors=['red','red', 'red', 'blue','blue','blue', 'red', 'red', 'red', 'blue', 'blue', 'blue']
myf = pd.DataFrame({'speed': Values, 'colors': Colors})

grouped = myf.groupby('colors')
fig, ax = plt.subplots(1)

for key, group in grouped:
   group.plot(ax=ax, y="speed", label=key, color=key)

The resultant plot has two issues: not only are the changed color lines not "connected", but the colors themselves connect "across" the end points:

What I want to see is the change from red to blue and back look like it's all one contiguous line.

Color line by third variable - Python seems to do the right thing, but I am not dealing with "linear" color data. I basically am assigning a set of line colors in a column. I  could easily set the values of the color column to numericals:

Colors=['1','1', '1', '2','2'...]

if that makes generating the desired plot easier.

There is a comment in the first thread:

You could do it if you'll duplicate points when color changed, I've
  modified answer for that

But I basically copied and pasted the answer, so I'm not sure that comment is entirely accurate.

Body:
I took a crack at it. Following the comments in the other question that you linked lead me to this. I did have to get down to matplotlib and couldn't do it in pandas itself. Once I converted the dataframe into lists, its pretty much the same code as the one from the mpl page.

I create the dataframe similar to yours:

vals=[3,4,6, 6,5,4, 3,2,3, 4,5,6]
colors=['red' if x < 5 else 'blue' for x in vals]
df = pd.DataFrame({'speed': vals, 'danger': colors})

Converting the vals and index into lists

x = df.index.tolist()
y = df['speed'].tolist()
z = np.array(list(y))

Break down the vals and index into points and then create line segments
out of them.

points = np.array([x, y]).T.reshape(-1, 1, 2)
segments = np.concatenate([points[:-1], points[1:]], axis=1)

Create the colormap based on the criteria used while creating the dataframe. In my case, speed less than 5 is red and rest is blue.

cmap = ListedColormap(['r', 'b'])
norm = BoundaryNorm([0, 4, 10], cmap.N)

Create the line segments and assign the colors accordingly

lc = LineCollection(segments, cmap=cmap, norm=norm)
lc.set_array(z)

Plot !

fig = plt.figure()
plt.gca().add_collection(lc)
plt.xlim(min(x), max(x))
plt.ylim(0, 10)

Here is the output:

Note: In the current code, the color of the line segment is dependent on the starting point. But hopefully, this gives you an idea.

I'm still new to answering questions here. Let me know if I need to add/remove some details. Thanks!


问:
Combine associative array with condition in php
I have an array like this

```<code>Array
(
    [14] => 2
    [28] => 1
)
</code>```

what i need is an array with index value upto 31 where in ,except index 14 and 28 the value should be 0(zero) and the index 14 and 28 should have the value 2 and 1 respectively.

please help me  with this.

thanks in advance

答:
There are more ways how to do it, for example:</p>

```<code><?php

$arr = array(14 => 2, 28 => 1);
$res = array();

for ($i = 0; $i <= 31; $i++) {
    $res[$i] = isset($arr[$i]) ? $arr[$i] : 0;
}

echo '```';
print_r($res);
</code>```

Body:
I have an array like this

Array
(
    [14] => 2
    [28] => 1
)

what i need is an array with index value upto 31 where in ,except index 14 and 28 the value should be 0(zero) and the index 14 and 28 should have the value 2 and 1 respectively.

please help me  with this.

thanks in advance

Body:
There are more ways how to do it, for example:

<?php

$arr = array(14 => 2, 28 => 1);
$res = array();

for ($i = 0; $i <= 31; $i++) {
    $res[$i] = isset($arr[$i]) ? $arr[$i] : 0;
}

echo '<pre>';
print_r($res);


问:
URL rewriting for Magento module
I have created a New Module in Magento and named it as "article". It has two Front end controllers index and article.

And in the article controller i have an action called "archives" to list the articles on the front end / website based on the archives. Everything is fine except the URL.

The Working URL right now is : [http://]mydemostore/article/article/archives/01/2011

What i actually need is   http://mydemostore/article/archives/01/2011

I don't want to have an extra "article" (the controller name)

I know since my module name and controller name are same i am getting this. If i would have placed my actions inside the indexcontroller, i would have got this done. But it was not working.

So what i need right now is I don't want to move my actions from "article" to "index" controllers rather i just want to change

from

[http://]mydemostore/article/article/archives/01/2011 to

to

[http://]mydemostore/article/archives/01/2011

using Zend routing or basic PHP URL rewriting on .htaccess file.

Kindly help me how to get this done by using either of these two ways or both the ways.

Thanks a lot in advance for checking with my question !!!

答:
I've not done this myself, only read about it here, but here goes...

In you config.xml file:

```<code><config>
    <global>
        <rewrite>
            <article_article_archives>
                <from><![CDATA[#^/article/archives/#]]></from>
                <to><![CDATA[/article/article/archives/]]></to>
            </article_article_archives>
        </rewrite>
    </global>
</config>
</code>```

The node <article_article_archives> isn't strictly formed, it only needs to be unique from other rewrites.

Title: URL rewriting for Magento module

Body:
I've not done this myself, only read about it here, but here goes...

In you config.xml file:

<config>
    <global>
        <rewrite>
            <article_article_archives>
                <from><![CDATA[#^/article/archives/#]]></from>
                <to><![CDATA[/article/article/archives/]]></to>
            </article_article_archives>
        </rewrite>
    </global>
</config>

The node <article_article_archives> isn't strictly formed, it only needs to be unique from other rewrites.


问:
how to remove background from any image in android
I want to remove the background of photo .but not able to find anything relevant actually I want this type of application https://play.google.com/store/apps/details?id=com.outthinking.bgeraser
of feature in android java code  remove the background.

My code is :

```<code>public class FingerText extends Activity
     {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(new MyView(this));

    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
    //this is the line that sets the initial pen color
    mPaint.setColor(inkColor);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setStrokeWidth(2);
}

private Paint mPaint;
private Bitmap mBitmap;
private boolean inkChosen;
private int bgColor = 0x00000000;  //set initial bg color var to white
private int inkColor = 0xFF000000; //set initial ink color var to black

public void colorChanged(int color) {
    //This is the implementation of the interface from colorpickerdialog.java

    if (inkChosen) {
        mPaint.setColor(color);
        inkColor = color;
    } else {
        mBitmap.eraseColor(color);
        bgColor = color;
        //set the color to the user's last ink color choice
        mPaint.setColor(inkColor);
    }

}

public class MyView extends View {

    private Canvas mCanvas;
    private Path mPath;
    private Paint mBitmapPaint;

    public MyView(Context c) {
        super(c);

        mBitmap = Bitmap.createBitmap(320, 480, Bitmap.Config.ARGB_8888);

        //this sets the bg color for the bitmap
        mBitmap.eraseColor(bgColor);
        mCanvas = new Canvas(mBitmap);
        mPath = new Path();
        mBitmapPaint = new Paint(Paint.DITHER_FLAG);
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        //this is the line that changes the bg color in the initial canvas
        canvas.drawColor(bgColor);
        canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);

        canvas.drawPath(mPath, mPaint);
        canvas.drawBitmap(((BitmapDrawable)getResources().getDrawable(
                R.drawable.ic_alphabets)).getBitmap(),0, 0, mBitmapPaint);
    }

    private float mX, mY;
    private static final float TOUCH_TOLERANCE = 4;

    private void touch_start(float x, float y) {
        mPath.reset();
        mPath.moveTo(x, y);
        mX = x;
        mY = y;
    }

    private void touch_move(float x, float y) {
        float dx = Math.abs(x - mX);
        float dy = Math.abs(y - mY);
        if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
            mPath.quadTo(mX, mY, (x + mX) / 2, (y + mY) / 2);
            mX = x;
            mY = y;
        }
    }

    private void touch_up() {
        mPath.lineTo(mX, mY);
        // commit the path to our offscreen
        mCanvas.drawPath(mPath, mPaint);
        // kill this so we don't double draw
        mPath.reset();
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        float x = event.getX();
        float y = event.getY();

        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                touch_start(x, y);
                invalidate();
                break;
            case MotionEvent.ACTION_MOVE:
                touch_move(x, y);
                invalidate();
                break;
            case MotionEvent.ACTION_UP:
                touch_up();
                invalidate();
                break;
        }
        return true;
    }
}

private static final int BG_COLOR_ID = Menu.FIRST;
private static final int INK_MENU_ID = Menu.FIRST + 1;
private static final int CLEAR_MENU_ID = Menu.FIRST + 2;
private static final int ERASER_MENU_ID = Menu.FIRST + 3;
private static final int SEND_MENU_ID = Menu.FIRST + 4;

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    menu.add(0, BG_COLOR_ID, 0, "Background Color").setShortcut('3', 'b');
    menu.add(0, INK_MENU_ID, 0, "Ink Color").setShortcut('4', 'c');
    menu.add(0, CLEAR_MENU_ID, 0, "Clear All").setShortcut('5', 'e');
    menu.add(0, ERASER_MENU_ID, 0, "Eraser").setShortcut('6', 'x');
    menu.add(0, SEND_MENU_ID, 0, "Send").setShortcut('7', 's');

    return true;
}

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    mPaint.setXfermode(null);
    mPaint.setAlpha(0xFF);

    switch (item.getItemId()) {

        case BG_COLOR_ID:
            inkChosen = false;
            return true;
        case INK_MENU_ID:
            inkColor = mPaint.getColor();
            inkChosen = true;
            return true;
        case CLEAR_MENU_ID:
            mBitmap.eraseColor(bgColor);
            return true;
        case ERASER_MENU_ID:
            //set pen color to bg color for 'erasing'
            mPaint.setColor(bgColor);
            return true;
        case SEND_MENU_ID:

            FileInputStream ifs;
            try {
                FileOutputStream fs = openFileOutput("message_image", Context.MODE_PRIVATE);
                mBitmap.compress(Bitmap.CompressFormat.PNG, 100, fs);
                ifs = openFileInput("message_image");
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                return true;
            }
            // inserts file pointed to by ifs into image gallery
            String url = MediaStore.Images.Media.insertImage(getContentResolver(),
                    BitmapFactory.decodeStream(ifs),
                    "Message image1", "Message image");

            Intent sendIntent = new Intent(Intent.ACTION_SEND);
            sendIntent.putExtra("sms_body", "Message created using FingerText");
            sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
            sendIntent.setType("image/png");
            startActivity(sendIntent);
            bgColor = 0xFFFFFFFF;  //set bg color var back to white
            inkColor = 0xFF000000; //set ink color var back to black
            mBitmap.eraseColor(bgColor);
            return true;
    }
    return super.onOptionsItemSelected(item);
}
}
</code>```

Please Help Me Thanks in advance.

答:
i am done it here is my code use as it is:

```<code>public class DrawView extends View implements View.OnTouchListener {
private ArrayList<PathPoints> paths = new ArrayList<PathPoints>();
private ArrayList<PathPoints> undonePaths = new ArrayList<PathPoints>();
private Path mPath;
private int x = 0;
private int y = 0;

Bitmap bitmap;
Bitmap bitmap2;
Canvas bitmapCanvas;

Drawable d;

private final Paint paint = new Paint();
private final Paint eraserPaint = new Paint();

Matrix matrix;

// We can be in one of these 3 states
static final int NONE = 0;
static final int DRAG = 1;
static final int ZOOM = 2;
int mode = NONE;

// Remember some things for zooming
PointF last = new PointF();
PointF start = new PointF();
float minScale = 1f;
float maxScale = 3f;
float[] m;

int viewWidth, viewHeight;
static final int CLICK = 3;
float saveScale = 1f;
protected float origWidth, origHeight;
int oldMeasuredWidth, oldMeasuredHeight;

ScaleGestureDetector mScaleDetector;

Context context;

public DrawView(Context context) {
    super(context);
    setFocusable(true);
    setFocusableInTouchMode(true);

    this.setOnTouchListener(this);

    // Set background
    this.setBackgroundResource(R.drawable.transparentbg);

    // Set bitmap
    bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.shert).copy(Bitmap.Config.ARGB_8888, true);
    bitmap = Bitmap.createScaledBitmap(bitmap, 600, 900, true);

    bitmapCanvas = new Canvas();
    bitmapCanvas.setBitmap(bitmap);//Bitmap.createScaledBitmap(bitmap, 350,400, true)

    bitmapCanvas.drawColor(Color.TRANSPARENT);

    // Set eraser paint properties
    eraserPaint.setColor(Color.TRANSPARENT);
    eraserPaint.setAlpha(0);
    eraserPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
    eraserPaint.setAntiAlias(true);
    mPath = new Path();
    paths.add(new PathPoints(mPath, Color.TRANSPARENT, false));

}

@Override
public void onDraw(Canvas canvas) {
    canvas.drawColor(Color.TRANSPARENT);
    bitmapCanvas.drawColor(Color.TRANSPARENT);
    bitmapCanvas.drawCircle(x, y, 20, eraserPaint);

    canvas.drawBitmap(bitmap, 0, 0, paint);

}

public boolean onTouch(View view, MotionEvent event) {
    x = (int) event.getX();
    y = (int) event.getY();
    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:

            touch_start(x, y);
            invalidate();

            break;
        case MotionEvent.ACTION_MOVE:

            touch_move(x, y);
            invalidate();

            break;
        case MotionEvent.ACTION_UP:

            touch_up();
            invalidate();

            break;
    }

    return true;
}

private float mX, mY;
private static final float TOUCH_TOLERANCE = 0;

private void touch_start(float x, float y) {
    mPath.reset();
    mPath.moveTo(x, y);
    mX = x;
    mY = y;
}

private void touch_move(float x, float y) {
    float dx = Math.abs(x - mX);
    float dy = Math.abs(y - mY);
    if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
        mPath.quadTo(mX, mY, (x + mX) / 2, (y + mY) / 2);
        mX = x;
        mY = y;
    }
}

private void touch_up() {
    mPath.lineTo(mX, mY);
    // commit the path to our offscreen
    bitmapCanvas.drawPath(mPath, eraserPaint);
    // kill this so we don't double draw
    mPath = new Path();
    paths.add(new PathPoints(mPath, Color.TRANSPARENT, false));

}

public static Bitmap scaleDown(Bitmap realImage, float maxImageSize,
                               boolean filter) {
    float ratio = Math.min(
            (float) maxImageSize / realImage.getWidth(),
            (float) maxImageSize / realImage.getHeight());
    int width = Math.round((float) ratio * realImage.getWidth());
    int height = Math.round((float) ratio * realImage.getHeight());

    Bitmap newBitmap = Bitmap.createScaledBitmap(realImage, width,
            height, filter);
    return newBitmap;
}

void fixTrans() {
    matrix.getValues(m);
    float transX = m[Matrix.MTRANS_X];
    float transY = m[Matrix.MTRANS_Y];

    float fixTransX = getFixTrans(transX, viewWidth, origWidth * saveScale);
    float fixTransY = getFixTrans(transY, viewHeight, origHeight
            * saveScale);

    if (fixTransX != 0 || fixTransY != 0)
        matrix.postTranslate(fixTransX, fixTransY);
}

float getFixTrans(float trans, float viewSize, float contentSize) {
    float minTrans, maxTrans;

    if (contentSize <= viewSize) {
        minTrans = 0;
        maxTrans = viewSize - contentSize;
    } else {
        minTrans = viewSize - contentSize;
        maxTrans = 0;
    }

    if (trans < minTrans)
        return -trans + minTrans;
    if (trans > maxTrans)
        return -trans + maxTrans;
    return 0;
}

float getFixDragTrans(float delta, float viewSize, float contentSize) {
    if (contentSize <= viewSize) {
        return 0;
    }
    return delta;
}

public void onClickUndo() {
    if (paths.size() > 0) {
        undonePaths.add(paths.remove(paths.size() - 1));
        invalidate();
    } else {

    }
    // toast the user
}

public void onClickRedo() {
    if (undonePaths.size() > 0) {
        paths.add(undonePaths.remove(undonePaths.size() - 1));
        invalidate();
    } else {

    }
    // toast the user
}

class PathPoints {
    private Path path;
    // private Paint eraserPaint;
    private int color;
    private String textToDraw;
    private boolean isTextToDraw;
    private int x, y;

    public PathPoints(Path path, int color, boolean isTextToDraw) {
        this.path = path;
        this.color = color;
        this.isTextToDraw = isTextToDraw;
    }

    public PathPoints(int color, String textToDraw, boolean isTextToDraw,
                      int x, int y) {
        this.color = color;
        this.textToDraw = textToDraw;
        this.isTextToDraw = isTextToDraw;
        this.x = x;
        this.y = y;
    }

    public Path getPath() {
        return path;
    }

    public void setPath(Path path) {
        this.path = path;
    }

    public int getColor() {
        return color;
    }

    public void setColor(int color) {
        this.color = color;
    }

    public String getTextToDraw() {
        return textToDraw;
    }

    public void setTextToDraw(String textToDraw) {
        this.textToDraw = textToDraw;
    }

    public boolean isTextToDraw() {
        return isTextToDraw;
    }

    public void setTextToDraw(boolean isTextToDraw) {
        this.isTextToDraw = isTextToDraw;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

}
</code>```

}

This code is working in my live project thanks.

Body:
I want to remove the background of photo .but not able to find anything relevant actually I want this type of application https://play.google.com/store/apps/details?id=com.outthinking.bgeraser
of feature in android java code  remove the background.

My code is :

public class FingerText extends Activity
     {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(new MyView(this));

    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
    //this is the line that sets the initial pen color
    mPaint.setColor(inkColor);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setStrokeWidth(2);
}

private Paint mPaint;
private Bitmap mBitmap;
private boolean inkChosen;
private int bgColor = 0x00000000;  //set initial bg color var to white
private int inkColor = 0xFF000000; //set initial ink color var to black

public void colorChanged(int color) {
    //This is the implementation of the interface from colorpickerdialog.java

    if (inkChosen) {
        mPaint.setColor(color);
        inkColor = color;
    } else {
        mBitmap.eraseColor(color);
        bgColor = color;
        //set the color to the user's last ink color choice
        mPaint.setColor(inkColor);
    }

}

public class MyView extends View {

    private Canvas mCanvas;
    private Path mPath;
    private Paint mBitmapPaint;

    public MyView(Context c) {
        super(c);

        mBitmap = Bitmap.createBitmap(320, 480, Bitmap.Config.ARGB_8888);

        //this sets the bg color for the bitmap
        mBitmap.eraseColor(bgColor);
        mCanvas = new Canvas(mBitmap);
        mPath = new Path();
        mBitmapPaint = new Paint(Paint.DITHER_FLAG);
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        //this is the line that changes the bg color in the initial canvas
        canvas.drawColor(bgColor);
        canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);

        canvas.drawPath(mPath, mPaint);
        canvas.drawBitmap(((BitmapDrawable)getResources().getDrawable(
                R.drawable.ic_alphabets)).getBitmap(),0, 0, mBitmapPaint);
    }

    private float mX, mY;
    private static final float TOUCH_TOLERANCE = 4;

    private void touch_start(float x, float y) {
        mPath.reset();
        mPath.moveTo(x, y);
        mX = x;
        mY = y;
    }

    private void touch_move(float x, float y) {
        float dx = Math.abs(x - mX);
        float dy = Math.abs(y - mY);
        if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
            mPath.quadTo(mX, mY, (x + mX) / 2, (y + mY) / 2);
            mX = x;
            mY = y;
        }
    }

    private void touch_up() {
        mPath.lineTo(mX, mY);
        // commit the path to our offscreen
        mCanvas.drawPath(mPath, mPaint);
        // kill this so we don't double draw
        mPath.reset();
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        float x = event.getX();
        float y = event.getY();

        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                touch_start(x, y);
                invalidate();
                break;
            case MotionEvent.ACTION_MOVE:
                touch_move(x, y);
                invalidate();
                break;
            case MotionEvent.ACTION_UP:
                touch_up();
                invalidate();
                break;
        }
        return true;
    }
}

private static final int BG_COLOR_ID = Menu.FIRST;
private static final int INK_MENU_ID = Menu.FIRST + 1;
private static final int CLEAR_MENU_ID = Menu.FIRST + 2;
private static final int ERASER_MENU_ID = Menu.FIRST + 3;
private static final int SEND_MENU_ID = Menu.FIRST + 4;

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    menu.add(0, BG_COLOR_ID, 0, "Background Color").setShortcut('3', 'b');
    menu.add(0, INK_MENU_ID, 0, "Ink Color").setShortcut('4', 'c');
    menu.add(0, CLEAR_MENU_ID, 0, "Clear All").setShortcut('5', 'e');
    menu.add(0, ERASER_MENU_ID, 0, "Eraser").setShortcut('6', 'x');
    menu.add(0, SEND_MENU_ID, 0, "Send").setShortcut('7', 's');

    return true;
}

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    mPaint.setXfermode(null);
    mPaint.setAlpha(0xFF);

    switch (item.getItemId()) {

        case BG_COLOR_ID:
            inkChosen = false;
            return true;
        case INK_MENU_ID:
            inkColor = mPaint.getColor();
            inkChosen = true;
            return true;
        case CLEAR_MENU_ID:
            mBitmap.eraseColor(bgColor);
            return true;
        case ERASER_MENU_ID:
            //set pen color to bg color for 'erasing'
            mPaint.setColor(bgColor);
            return true;
        case SEND_MENU_ID:

            FileInputStream ifs;
            try {
                FileOutputStream fs = openFileOutput("message_image", Context.MODE_PRIVATE);
                mBitmap.compress(Bitmap.CompressFormat.PNG, 100, fs);
                ifs = openFileInput("message_image");
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                return true;
            }
            // inserts file pointed to by ifs into image gallery
            String url = MediaStore.Images.Media.insertImage(getContentResolver(),
                    BitmapFactory.decodeStream(ifs),
                    "Message image1", "Message image");

            Intent sendIntent = new Intent(Intent.ACTION_SEND);
            sendIntent.putExtra("sms_body", "Message created using FingerText");
            sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
            sendIntent.setType("image/png");
            startActivity(sendIntent);
            bgColor = 0xFFFFFFFF;  //set bg color var back to white
            inkColor = 0xFF000000; //set ink color var back to black
            mBitmap.eraseColor(bgColor);
            return true;
    }
    return super.onOptionsItemSelected(item);
}
}

Please Help Me Thanks in advance.

Body:
i am done it here is my code use as it is:

public class DrawView extends View implements View.OnTouchListener {
private ArrayList<PathPoints> paths = new ArrayList<PathPoints>();
private ArrayList<PathPoints> undonePaths = new ArrayList<PathPoints>();
private Path mPath;
private int x = 0;
private int y = 0;

Bitmap bitmap;
Bitmap bitmap2;
Canvas bitmapCanvas;

Drawable d;

private final Paint paint = new Paint();
private final Paint eraserPaint = new Paint();

Matrix matrix;

// We can be in one of these 3 states
static final int NONE = 0;
static final int DRAG = 1;
static final int ZOOM = 2;
int mode = NONE;

// Remember some things for zooming
PointF last = new PointF();
PointF start = new PointF();
float minScale = 1f;
float maxScale = 3f;
float[] m;

int viewWidth, viewHeight;
static final int CLICK = 3;
float saveScale = 1f;
protected float origWidth, origHeight;
int oldMeasuredWidth, oldMeasuredHeight;

ScaleGestureDetector mScaleDetector;

Context context;

public DrawView(Context context) {
    super(context);
    setFocusable(true);
    setFocusableInTouchMode(true);

    this.setOnTouchListener(this);

    // Set background
    this.setBackgroundResource(R.drawable.transparentbg);

    // Set bitmap
    bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.shert).copy(Bitmap.Config.ARGB_8888, true);
    bitmap = Bitmap.createScaledBitmap(bitmap, 600, 900, true);

    bitmapCanvas = new Canvas();
    bitmapCanvas.setBitmap(bitmap);//Bitmap.createScaledBitmap(bitmap, 350,400, true)

    bitmapCanvas.drawColor(Color.TRANSPARENT);

    // Set eraser paint properties
    eraserPaint.setColor(Color.TRANSPARENT);
    eraserPaint.setAlpha(0);
    eraserPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
    eraserPaint.setAntiAlias(true);
    mPath = new Path();
    paths.add(new PathPoints(mPath, Color.TRANSPARENT, false));

}

@Override
public void onDraw(Canvas canvas) {
    canvas.drawColor(Color.TRANSPARENT);
    bitmapCanvas.drawColor(Color.TRANSPARENT);
    bitmapCanvas.drawCircle(x, y, 20, eraserPaint);

    canvas.drawBitmap(bitmap, 0, 0, paint);

}

public boolean onTouch(View view, MotionEvent event) {
    x = (int) event.getX();
    y = (int) event.getY();
    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:

            touch_start(x, y);
            invalidate();

            break;
        case MotionEvent.ACTION_MOVE:

            touch_move(x, y);
            invalidate();

            break;
        case MotionEvent.ACTION_UP:

            touch_up();
            invalidate();

            break;
    }

    return true;
}

private float mX, mY;
private static final float TOUCH_TOLERANCE = 0;

private void touch_start(float x, float y) {
    mPath.reset();
    mPath.moveTo(x, y);
    mX = x;
    mY = y;
}

private void touch_move(float x, float y) {
    float dx = Math.abs(x - mX);
    float dy = Math.abs(y - mY);
    if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
        mPath.quadTo(mX, mY, (x + mX) / 2, (y + mY) / 2);
        mX = x;
        mY = y;
    }
}

private void touch_up() {
    mPath.lineTo(mX, mY);
    // commit the path to our offscreen
    bitmapCanvas.drawPath(mPath, eraserPaint);
    // kill this so we don't double draw
    mPath = new Path();
    paths.add(new PathPoints(mPath, Color.TRANSPARENT, false));

}

public static Bitmap scaleDown(Bitmap realImage, float maxImageSize,
                               boolean filter) {
    float ratio = Math.min(
            (float) maxImageSize / realImage.getWidth(),
            (float) maxImageSize / realImage.getHeight());
    int width = Math.round((float) ratio * realImage.getWidth());
    int height = Math.round((float) ratio * realImage.getHeight());

    Bitmap newBitmap = Bitmap.createScaledBitmap(realImage, width,
            height, filter);
    return newBitmap;
}

void fixTrans() {
    matrix.getValues(m);
    float transX = m[Matrix.MTRANS_X];
    float transY = m[Matrix.MTRANS_Y];

    float fixTransX = getFixTrans(transX, viewWidth, origWidth * saveScale);
    float fixTransY = getFixTrans(transY, viewHeight, origHeight
            * saveScale);

    if (fixTransX != 0 || fixTransY != 0)
        matrix.postTranslate(fixTransX, fixTransY);
}

float getFixTrans(float trans, float viewSize, float contentSize) {
    float minTrans, maxTrans;

    if (contentSize <= viewSize) {
        minTrans = 0;
        maxTrans = viewSize - contentSize;
    } else {
        minTrans = viewSize - contentSize;
        maxTrans = 0;
    }

    if (trans < minTrans)
        return -trans + minTrans;
    if (trans > maxTrans)
        return -trans + maxTrans;
    return 0;
}

float getFixDragTrans(float delta, float viewSize, float contentSize) {
    if (contentSize <= viewSize) {
        return 0;
    }
    return delta;
}

public void onClickUndo() {
    if (paths.size() > 0) {
        undonePaths.add(paths.remove(paths.size() - 1));
        invalidate();
    } else {

    }
    // toast the user
}

public void onClickRedo() {
    if (undonePaths.size() > 0) {
        paths.add(undonePaths.remove(undonePaths.size() - 1));
        invalidate();
    } else {

    }
    // toast the user
}

class PathPoints {
    private Path path;
    // private Paint eraserPaint;
    private int color;
    private String textToDraw;
    private boolean isTextToDraw;
    private int x, y;

    public PathPoints(Path path, int color, boolean isTextToDraw) {
        this.path = path;
        this.color = color;
        this.isTextToDraw = isTextToDraw;
    }

    public PathPoints(int color, String textToDraw, boolean isTextToDraw,
                      int x, int y) {
        this.color = color;
        this.textToDraw = textToDraw;
        this.isTextToDraw = isTextToDraw;
        this.x = x;
        this.y = y;
    }

    public Path getPath() {
        return path;
    }

    public void setPath(Path path) {
        this.path = path;
    }

    public int getColor() {
        return color;
    }

    public void setColor(int color) {
        this.color = color;
    }

    public String getTextToDraw() {
        return textToDraw;
    }

    public void setTextToDraw(String textToDraw) {
        this.textToDraw = textToDraw;
    }

    public boolean isTextToDraw() {
        return isTextToDraw;
    }

    public void setTextToDraw(boolean isTextToDraw) {
        this.isTextToDraw = isTextToDraw;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

}

}

This code is working in my live project thanks.


答:
Do you want like this:-

```<code><?php

$a = array_fill(0, 31, 0);
$a[14] = 2;
$a[28] = 1;
print_r($a);
?>
</code>```

Output:- https://eval.in/913931

Reference:- PHP: array_fill - Manual

Title: Combine associative array with condition in php

Body:
Do you want like this:-

<?php

$a = array_fill(0, 31, 0);
$a[14] = 2;
$a[28] = 1;
print_r($a);
?>

Output:- https://eval.in/913931

Reference:- PHP: array_fill - Manual


问:
Azure Logic App HTTP request 500
I am new to the Azure Logic Apps so this example may look not that useful but its just to learn some basic Azure Logic.

I got a simple HTTP listener (When an HTTP request is received)
Than it should send another HTTP GET request to some service and send a response to the first caller.
It looks like this:
http://imgur.com/a/9fpfu

Now everything is working great until i send wrong data or somehow the Logic apps get a 500 HTTP error from the HTTP requests.

Than the Logic app hangs in the HTTP request for around 1 minute and fails.
The Response after that is never send.

How can i forward the response that the Logic app is getting back to the requester who requested the logic app?

答:
You can update retry policy and timeout setting of Http action as

enter image description here

Title: Azure Logic App HTTP request 500


问:
Access bitbucket with secondary private key
I have multiple bitbucket accounts. One account uses my "primary" private key .ssh/id_rsa where as for the 2nd account I want to use .ssh/id_rsa-infoodle

I have the following entry in .ssh/config:

```<code>Host bitbucket.org-infoodle
    Hostname bitbucket.org
    User jochen
    IdentityFile ~/.ssh/id_rsa-bb_infoodle2
    LogLevel DEBUG3
</code>```

On computer1 this works fine:

```<code>jochen@autodesktop2:~/projects$ git clone git@bitbucket.org-infoodle:richinnz/zog-2017.git clonetest
Cloning into 'clonetest'...
debug2: resolving "bitbucket.org" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to bitbucket.org [104.192.143.1] port 22.
debug1: Connection established.
debug1: identity file /home/jochen/.ssh/id_rsa-bb_infoodle2 type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jochen/.ssh/id_rsa-bb_infoodle2-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2
debug1: Remote protocol version 2.0, remote software version conker_1.0.315-a08d059 app-165
debug1: no match: conker_1.0.315-a08d059 app-165
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to bitbucket.org:22 as 'git'
debug3: hostkeys_foreach: reading file "/home/jochen/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/jochen/.ssh/known_hosts:241
debug3: load_hostkeys: loaded 1 keys from bitbucket.org
debug3: order_hostkeyalgs: prefer hostkeyalgs: ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: host key algorithms: ssh-dss,ssh-rsa
debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,arcfour256,arcfour128
debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,arcfour256,arcfour128
debug2: MACs ctos: hmac-sha2-256-etm@openssh.com,hmac-sha2-256,hmac-sha1,hmac-sha1-96
debug2: MACs stoc: hmac-sha2-256-etm@openssh.com,hmac-sha2-256,hmac-sha1,hmac-sha1-96
debug2: compression ctos: none
debug2: compression stoc: none
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256-etm@openssh.com compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256-etm@openssh.com compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ssh-rsa SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A
debug3: hostkeys_foreach: reading file "/home/jochen/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/jochen/.ssh/known_hosts:241
debug3: load_hostkeys: loaded 1 keys from bitbucket.org
debug3: hostkeys_foreach: reading file "/home/jochen/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/jochen/.ssh/known_hosts:242
debug3: load_hostkeys: loaded 1 keys from 104.192.143.1
debug1: Host 'bitbucket.org' is known and matches the RSA host key.
debug1: Found key in /home/jochen/.ssh/known_hosts:241
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug2: set_newkeys: mode 0
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS received
debug2: key: /home/jochen/.ssh/id_rsa-bb_infoodle2 (0x55f37c38c1c0), explicit, agent
debug2: key: jochen@autolaptop4 (0x55f37c38d860), agent
debug2: key: jochen@autodesktop2 (0x55f37c38d8b0), agent
debug2: key: jochen@autolaptop3 (0x55f37c38f7e0), agent
debug3: send packet: type 5
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/jochen/.ssh/id_rsa-bb_infoodle2
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 60
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug2: input_userauth_pk_ok: fp SHA256:gnnMiy+PtixStLXN09+pHjnmcbdVNtgGhc36MOtG4/Y
debug3: sign_and_send_pubkey: RSA SHA256:gnnMiy+PtixStLXN09+pHjnmcbdVNtgGhc36MOtG4/Y
debug3: send packet: type 50
debug3: receive packet: type 52
debug1: Authentication succeeded (publickey).
Authenticated to bitbucket.org ([104.192.143.1]:22).
debug2: fd 5 setting O_NONBLOCK
debug2: fd 6 setting O_NONBLOCK
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Entering interactive session.
debug1: pledge: network
debug3: receive packet: type 91
debug2: callback start
debug2: fd 3 setting TCP_NODELAY
debug3: ssh_packet_set_tos: set IP_TOS 0x08
debug2: client_session2_setup: id 0
debug1: Sending environment.
debug3: Ignored env XDG_VTNR
debug3: Ignored env XDG_SESSION_ID
debug3: Ignored env XDG_GREETER_DATA_DIR
debug3: Ignored env CLUTTER_IM_MODULE
debug3: Ignored env QT_STYLE_OVERRIDE
debug3: Ignored env SESSION
debug3: Ignored env GPG_AGENT_INFO
debug3: Ignored env GLADE_PIXMAP_PATH
debug3: Ignored env TERM
debug3: Ignored env XDG_MENU_PREFIX
debug3: Ignored env SHELL
debug3: Ignored env QT_LINUX_ACCESSIBILITY_ALWAYS_ON
debug3: Ignored env WINDOWID
debug3: Ignored env UPSTART_SESSION
debug3: Ignored env GNOME_KEYRING_CONTROL
debug3: Ignored env GTK_MODULES
debug3: Ignored env ANSIBLE_HOSTS
debug3: Ignored env USER
debug3: Ignored env LS_COLORS
debug3: Ignored env CLUTTER_BACKEND
debug3: Ignored env QT_ACCESSIBILITY
debug3: Ignored env XDG_SESSION_PATH
debug3: Ignored env GLADE_MODULE_PATH
debug3: Ignored env XDG_SEAT_PATH
debug3: Ignored env SSH_AUTH_SOCK
debug3: Ignored env DEFAULTS_PATH
debug3: Ignored env SESSION_MANAGER
debug3: Ignored env XDG_CONFIG_DIRS
debug3: Ignored env DESKTOP_SESSION
debug3: Ignored env PATH
debug3: Ignored env QT_IM_MODULE
debug3: Ignored env QT_QPA_PLATFORMTHEME
debug3: Ignored env XDG_SESSION_TYPE
debug3: Ignored env PWD
debug3: Ignored env JOB
debug3: Ignored env XMODIFIERS
debug3: Ignored env GNOME_KEYRING_PID
debug1: Sending env LANG = en_NZ.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env GDM_LANG
debug3: Ignored env MANDATORY_PATH
debug3: Ignored env IM_CONFIG_PHASE
debug3: Ignored env GDMSESSION
debug3: Ignored env HISTCONTROL
debug3: Ignored env SESSIONTYPE
debug3: Ignored env GTK2_MODULES
debug3: Ignored env SPEECHD_PORT
debug3: Ignored env SHLVL
debug3: Ignored env HOME
debug3: Ignored env XDG_SEAT
debug3: Ignored env LANGUAGE
debug3: Ignored env UPSTART_INSTANCE
debug3: Ignored env GTK_OVERLAY_SCROLLING
debug3: Ignored env UPSTART_EVENTS
debug3: Ignored env XDG_SESSION_DESKTOP
debug3: Ignored env LOGNAME
debug3: Ignored env DBUS_SESSION_BUS_ADDRESS
debug3: Ignored env XDG_DATA_DIRS
debug3: Ignored env QT4_IM_MODULE
debug3: Ignored env LESSOPEN
debug3: Ignored env INSTANCE
debug3: Ignored env UPSTART_JOB
debug3: Ignored env XDG_RUNTIME_DIR
debug3: Ignored env DISPLAY
debug3: Ignored env GLADE_CATALOG_PATH
debug3: Ignored env XDG_CURRENT_DESKTOP
debug3: Ignored env GTK_IM_MODULE
debug3: Ignored env LESSCLOSE
debug3: Ignored env XAUTHORITY
debug3: Ignored env COLORTERM
debug3: Ignored env OLDPWD
debug3: Ignored env _
debug1: Sending command: git-upload-pack 'richinnz/zog-2017.git'
debug2: channel 0: request exec confirm 1
debug3: send packet: type 98
debug2: callback done
debug2: channel 0: open confirm rwindow 2097152 rmax 32768
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: exec request accepted on channel 0
debug2: channel 0: rcvd adjust 4532
remote: Counting objects: 14510, done.
^Cdebug3: send packet: type 1 23% (1424/6189)
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
  #0 client-session (t4 r0 i0/0 o0/0 fd 5/6 cc -1)

debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
debug1: Killed by signal 2.
fatal: The remote end hung up unexpectedly
</code>```

On computer2 however it fails

```<code>jochen@devserver:~/projects$ git clone git@bitbucket.org-infoodle:richinnz/zog-2017.git zog
Cloning into 'zog'...
debug2: resolving "bitbucket.org" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to bitbucket.org [104.192.143.2] port 22.
debug1: Connection established.
debug1: identity file /home/jochen/.ssh/id_rsa-bb_infoodle2 type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jochen/.ssh/id_rsa-bb_infoodle2-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2
debug1: Remote protocol version 2.0, remote software version conker_1.0.315-a08d059 app-129
debug1: no match: conker_1.0.315-a08d059 app-129
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to bitbucket.org:22 as 'git'
debug3: hostkeys_foreach: reading file "/home/jochen/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/jochen/.ssh/known_hosts:22
debug3: load_hostkeys: loaded 1 keys from bitbucket.org
debug3: order_hostkeyalgs: prefer hostkeyalgs: ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: host key algorithms: ssh-dss,ssh-rsa
debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,arcfour256,arcfour128
debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,arcfour256,arcfour128
debug2: MACs ctos: hmac-sha2-256-etm@openssh.com,hmac-sha2-256,hmac-sha1,hmac-sha1-96
debug2: MACs stoc: hmac-sha2-256-etm@openssh.com,hmac-sha2-256,hmac-sha1,hmac-sha1-96
debug2: compression ctos: none
debug2: compression stoc: none
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256-etm@openssh.com compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256-etm@openssh.com compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ssh-rsa SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A
debug3: hostkeys_foreach: reading file "/home/jochen/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/jochen/.ssh/known_hosts:22
debug3: load_hostkeys: loaded 1 keys from bitbucket.org
debug3: hostkeys_foreach: reading file "/home/jochen/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/jochen/.ssh/known_hosts:23
debug3: load_hostkeys: loaded 1 keys from 104.192.143.2
debug1: Host 'bitbucket.org' is known and matches the RSA host key.
debug1: Found key in /home/jochen/.ssh/known_hosts:22
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug2: set_newkeys: mode 0
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS received
debug2: key: jochen-windows (0x55c4e8b8f3a0), agent
debug2: key: /home/jochen/.ssh/id_rsa-bb_infoodle2 (0x55c4e8b8f2d0), explicit
debug3: send packet: type 5
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: jochen-windows
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 60
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug2: input_userauth_pk_ok: fp SHA256:JiGG4lMVcyq8MOzTMskuOZ7ww6maX6wjpMVjW76t9+Q
debug3: sign_and_send_pubkey: RSA SHA256:JiGG4lMVcyq8MOzTMskuOZ7ww6maX6wjpMVjW76t9+Q
debug3: send packet: type 50
debug3: receive packet: type 52
debug1: Authentication succeeded (publickey).
Authenticated to bitbucket.org ([104.192.143.2]:22).
debug2: fd 5 setting O_NONBLOCK
debug2: fd 6 setting O_NONBLOCK
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Entering interactive session.
debug1: pledge: network
debug3: receive packet: type 91
debug2: callback start
debug2: fd 3 setting TCP_NODELAY
debug3: ssh_packet_set_tos: set IP_TOS 0x08
debug2: client_session2_setup: id 0
debug1: Sending environment.
debug3: Ignored env XDG_SESSION_ID
debug3: Ignored env TERM
debug3: Ignored env SHELL
debug3: Ignored env SSH_CLIENT
debug3: Ignored env SSH_TTY
debug3: Ignored env USER
debug3: Ignored env LS_COLORS
debug3: Ignored env SSH_AUTH_SOCK
debug3: Ignored env MAIL
debug3: Ignored env PATH
debug3: Ignored env PWD
debug1: Sending env LANG = en_US.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env SHLVL
debug3: Ignored env HOME
debug3: Ignored env LOGNAME
debug3: Ignored env SSH_CONNECTION
debug3: Ignored env LESSOPEN
debug3: Ignored env XDG_RUNTIME_DIR
debug3: Ignored env DISPLAY
debug3: Ignored env LESSCLOSE
debug3: Ignored env _
debug3: Ignored env OLDPWD
debug1: Sending command: git-upload-pack 'richinnz/zog-2017.git'
debug2: channel 0: request exec confirm 1
debug3: send packet: type 98
debug2: callback done
debug2: channel 0: open confirm rwindow 2097152 rmax 32768
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: exec request accepted on channel 0
debug2: channel 0: rcvd ext data 26
debug3: receive packet: type 98
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug3: receive packet: type 96
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug3: receive packet: type 97
debug2: channel 0: rcvd close
debug2: channel 0: close_read
debug2: channel 0: input open -> closed
debug3: channel 0: will not send data after close
debug2: channel 0: obuf_empty delayed efd 7/(26)
repository access denied.
debug2: channel 0: written 26 to efd 7
debug3: channel 0: will not send data after close
debug2: channel 0: obuf empty
debug2: channel 0: close_write
debug2: channel 0: output drain -> closed
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug3: send packet: type 97
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
  #0 client-session (t4 r0 i3/0 o3/0 fd -1/-1 cc -1)

debug3: send packet: type 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Transferred: sent 2700, received 1736 bytes, in 0.5 seconds
Bytes per second: sent 5293.0, received 3403.2
debug1: Exit status 1
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
</code>```

Both computer are Ubuntu 16.04, computer1 is located in New Zealand, computer2 is located in AWS Sydney

I have tried:

setting the IP address of bitbucket.org on computer2 to the same as computer1 (in /etc/hosts)

removing .ssh/id_rsa from .ssh/ to be sure the wrong private key is not picked up

creating new keys

copying .ssh/config from computer1 to computer2 to be sure they are the same

What else can I try to resolve this?

答:
For Bitbucket, your .ssh/config file needs to use the User git.

Not User xxx.

```<code>Host bitbucket.org-infoodle
    Hostname bitbucket.org
    User git                                    <============
    IdentityFile ~/.ssh/id_rsa-bb_infoodle2
    LogLevel DEBUG3
</code>```

BitBucket will only accept remote ssh connection for that user.

And it will use the public key to authenticate you.

And you don't need git@bitbucket.org-infoodle, just  bitbucket.org-infoodle:...

See "Why does Git using ssh use git as a username".

You actual issue, though, seems related to the network quality, not to ssh settings.

I believe I cleared my credentials with sudo git config --system --unset credential.helper

I describe that here, but this is for HTTPS URLs, not SSH ones.

Double-check your remote: git remote -v.

Body:
I have multiple bitbucket accounts. One account uses my "primary" private key .ssh/id_rsa where as for the 2nd account I want to use .ssh/id_rsa-infoodle

I have the following entry in .ssh/config:

Host bitbucket.org-infoodle
    Hostname bitbucket.org
    User jochen
    IdentityFile ~/.ssh/id_rsa-bb_infoodle2
    LogLevel DEBUG3

On computer1 this works fine:

jochen@autodesktop2:~/projects$ git clone git@bitbucket.org-infoodle:richinnz/zog-2017.git clonetest
Cloning into 'clonetest'...
debug2: resolving "bitbucket.org" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to bitbucket.org [104.192.143.1] port 22.
debug1: Connection established.
debug1: identity file /home/jochen/.ssh/id_rsa-bb_infoodle2 type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jochen/.ssh/id_rsa-bb_infoodle2-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2
debug1: Remote protocol version 2.0, remote software version conker_1.0.315-a08d059 app-165
debug1: no match: conker_1.0.315-a08d059 app-165
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to bitbucket.org:22 as 'git'
debug3: hostkeys_foreach: reading file "/home/jochen/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/jochen/.ssh/known_hosts:241
debug3: load_hostkeys: loaded 1 keys from bitbucket.org
debug3: order_hostkeyalgs: prefer hostkeyalgs: ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: host key algorithms: ssh-dss,ssh-rsa
debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,arcfour256,arcfour128
debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,arcfour256,arcfour128
debug2: MACs ctos: hmac-sha2-256-etm@openssh.com,hmac-sha2-256,hmac-sha1,hmac-sha1-96
debug2: MACs stoc: hmac-sha2-256-etm@openssh.com,hmac-sha2-256,hmac-sha1,hmac-sha1-96
debug2: compression ctos: none
debug2: compression stoc: none
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256-etm@openssh.com compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256-etm@openssh.com compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ssh-rsa SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A
debug3: hostkeys_foreach: reading file "/home/jochen/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/jochen/.ssh/known_hosts:241
debug3: load_hostkeys: loaded 1 keys from bitbucket.org
debug3: hostkeys_foreach: reading file "/home/jochen/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/jochen/.ssh/known_hosts:242
debug3: load_hostkeys: loaded 1 keys from 104.192.143.1
debug1: Host 'bitbucket.org' is known and matches the RSA host key.
debug1: Found key in /home/jochen/.ssh/known_hosts:241
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug2: set_newkeys: mode 0
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS received
debug2: key: /home/jochen/.ssh/id_rsa-bb_infoodle2 (0x55f37c38c1c0), explicit, agent
debug2: key: jochen@autolaptop4 (0x55f37c38d860), agent
debug2: key: jochen@autodesktop2 (0x55f37c38d8b0), agent
debug2: key: jochen@autolaptop3 (0x55f37c38f7e0), agent
debug3: send packet: type 5
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/jochen/.ssh/id_rsa-bb_infoodle2
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 60
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug2: input_userauth_pk_ok: fp SHA256:gnnMiy+PtixStLXN09+pHjnmcbdVNtgGhc36MOtG4/Y
debug3: sign_and_send_pubkey: RSA SHA256:gnnMiy+PtixStLXN09+pHjnmcbdVNtgGhc36MOtG4/Y
debug3: send packet: type 50
debug3: receive packet: type 52
debug1: Authentication succeeded (publickey).
Authenticated to bitbucket.org ([104.192.143.1]:22).
debug2: fd 5 setting O_NONBLOCK
debug2: fd 6 setting O_NONBLOCK
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Entering interactive session.
debug1: pledge: network
debug3: receive packet: type 91
debug2: callback start
debug2: fd 3 setting TCP_NODELAY
debug3: ssh_packet_set_tos: set IP_TOS 0x08
debug2: client_session2_setup: id 0
debug1: Sending environment.
debug3: Ignored env XDG_VTNR
debug3: Ignored env XDG_SESSION_ID
debug3: Ignored env XDG_GREETER_DATA_DIR
debug3: Ignored env CLUTTER_IM_MODULE
debug3: Ignored env QT_STYLE_OVERRIDE
debug3: Ignored env SESSION
debug3: Ignored env GPG_AGENT_INFO
debug3: Ignored env GLADE_PIXMAP_PATH
debug3: Ignored env TERM
debug3: Ignored env XDG_MENU_PREFIX
debug3: Ignored env SHELL
debug3: Ignored env QT_LINUX_ACCESSIBILITY_ALWAYS_ON
debug3: Ignored env WINDOWID
debug3: Ignored env UPSTART_SESSION
debug3: Ignored env GNOME_KEYRING_CONTROL
debug3: Ignored env GTK_MODULES
debug3: Ignored env ANSIBLE_HOSTS
debug3: Ignored env USER
debug3: Ignored env LS_COLORS
debug3: Ignored env CLUTTER_BACKEND
debug3: Ignored env QT_ACCESSIBILITY
debug3: Ignored env XDG_SESSION_PATH
debug3: Ignored env GLADE_MODULE_PATH
debug3: Ignored env XDG_SEAT_PATH
debug3: Ignored env SSH_AUTH_SOCK
debug3: Ignored env DEFAULTS_PATH
debug3: Ignored env SESSION_MANAGER
debug3: Ignored env XDG_CONFIG_DIRS
debug3: Ignored env DESKTOP_SESSION
debug3: Ignored env PATH
debug3: Ignored env QT_IM_MODULE
debug3: Ignored env QT_QPA_PLATFORMTHEME
debug3: Ignored env XDG_SESSION_TYPE
debug3: Ignored env PWD
debug3: Ignored env JOB
debug3: Ignored env XMODIFIERS
debug3: Ignored env GNOME_KEYRING_PID
debug1: Sending env LANG = en_NZ.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env GDM_LANG
debug3: Ignored env MANDATORY_PATH
debug3: Ignored env IM_CONFIG_PHASE
debug3: Ignored env GDMSESSION
debug3: Ignored env HISTCONTROL
debug3: Ignored env SESSIONTYPE
debug3: Ignored env GTK2_MODULES
debug3: Ignored env SPEECHD_PORT
debug3: Ignored env SHLVL
debug3: Ignored env HOME
debug3: Ignored env XDG_SEAT
debug3: Ignored env LANGUAGE
debug3: Ignored env UPSTART_INSTANCE
debug3: Ignored env GTK_OVERLAY_SCROLLING
debug3: Ignored env UPSTART_EVENTS
debug3: Ignored env XDG_SESSION_DESKTOP
debug3: Ignored env LOGNAME
debug3: Ignored env DBUS_SESSION_BUS_ADDRESS
debug3: Ignored env XDG_DATA_DIRS
debug3: Ignored env QT4_IM_MODULE
debug3: Ignored env LESSOPEN
debug3: Ignored env INSTANCE
debug3: Ignored env UPSTART_JOB
debug3: Ignored env XDG_RUNTIME_DIR
debug3: Ignored env DISPLAY
debug3: Ignored env GLADE_CATALOG_PATH
debug3: Ignored env XDG_CURRENT_DESKTOP
debug3: Ignored env GTK_IM_MODULE
debug3: Ignored env LESSCLOSE
debug3: Ignored env XAUTHORITY
debug3: Ignored env COLORTERM
debug3: Ignored env OLDPWD
debug3: Ignored env _
debug1: Sending command: git-upload-pack 'richinnz/zog-2017.git'
debug2: channel 0: request exec confirm 1
debug3: send packet: type 98
debug2: callback done
debug2: channel 0: open confirm rwindow 2097152 rmax 32768
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: exec request accepted on channel 0
debug2: channel 0: rcvd adjust 4532
remote: Counting objects: 14510, done.
^Cdebug3: send packet: type 1 23% (1424/6189)
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
  #0 client-session (t4 r0 i0/0 o0/0 fd 5/6 cc -1)

debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
debug1: Killed by signal 2.
fatal: The remote end hung up unexpectedly

On computer2 however it fails

jochen@devserver:~/projects$ git clone git@bitbucket.org-infoodle:richinnz/zog-2017.git zog
Cloning into 'zog'...
debug2: resolving "bitbucket.org" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to bitbucket.org [104.192.143.2] port 22.
debug1: Connection established.
debug1: identity file /home/jochen/.ssh/id_rsa-bb_infoodle2 type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jochen/.ssh/id_rsa-bb_infoodle2-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2
debug1: Remote protocol version 2.0, remote software version conker_1.0.315-a08d059 app-129
debug1: no match: conker_1.0.315-a08d059 app-129
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to bitbucket.org:22 as 'git'
debug3: hostkeys_foreach: reading file "/home/jochen/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/jochen/.ssh/known_hosts:22
debug3: load_hostkeys: loaded 1 keys from bitbucket.org
debug3: order_hostkeyalgs: prefer hostkeyalgs: ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: host key algorithms: ssh-dss,ssh-rsa
debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,arcfour256,arcfour128
debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,arcfour256,arcfour128
debug2: MACs ctos: hmac-sha2-256-etm@openssh.com,hmac-sha2-256,hmac-sha1,hmac-sha1-96
debug2: MACs stoc: hmac-sha2-256-etm@openssh.com,hmac-sha2-256,hmac-sha1,hmac-sha1-96
debug2: compression ctos: none
debug2: compression stoc: none
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256-etm@openssh.com compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256-etm@openssh.com compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ssh-rsa SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A
debug3: hostkeys_foreach: reading file "/home/jochen/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/jochen/.ssh/known_hosts:22
debug3: load_hostkeys: loaded 1 keys from bitbucket.org
debug3: hostkeys_foreach: reading file "/home/jochen/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/jochen/.ssh/known_hosts:23
debug3: load_hostkeys: loaded 1 keys from 104.192.143.2
debug1: Host 'bitbucket.org' is known and matches the RSA host key.
debug1: Found key in /home/jochen/.ssh/known_hosts:22
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug2: set_newkeys: mode 0
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS received
debug2: key: jochen-windows (0x55c4e8b8f3a0), agent
debug2: key: /home/jochen/.ssh/id_rsa-bb_infoodle2 (0x55c4e8b8f2d0), explicit
debug3: send packet: type 5
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: jochen-windows
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 60
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug2: input_userauth_pk_ok: fp SHA256:JiGG4lMVcyq8MOzTMskuOZ7ww6maX6wjpMVjW76t9+Q
debug3: sign_and_send_pubkey: RSA SHA256:JiGG4lMVcyq8MOzTMskuOZ7ww6maX6wjpMVjW76t9+Q
debug3: send packet: type 50
debug3: receive packet: type 52
debug1: Authentication succeeded (publickey).
Authenticated to bitbucket.org ([104.192.143.2]:22).
debug2: fd 5 setting O_NONBLOCK
debug2: fd 6 setting O_NONBLOCK
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Entering interactive session.
debug1: pledge: network
debug3: receive packet: type 91
debug2: callback start
debug2: fd 3 setting TCP_NODELAY
debug3: ssh_packet_set_tos: set IP_TOS 0x08
debug2: client_session2_setup: id 0
debug1: Sending environment.
debug3: Ignored env XDG_SESSION_ID
debug3: Ignored env TERM
debug3: Ignored env SHELL
debug3: Ignored env SSH_CLIENT
debug3: Ignored env SSH_TTY
debug3: Ignored env USER
debug3: Ignored env LS_COLORS
debug3: Ignored env SSH_AUTH_SOCK
debug3: Ignored env MAIL
debug3: Ignored env PATH
debug3: Ignored env PWD
debug1: Sending env LANG = en_US.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env SHLVL
debug3: Ignored env HOME
debug3: Ignored env LOGNAME
debug3: Ignored env SSH_CONNECTION
debug3: Ignored env LESSOPEN
debug3: Ignored env XDG_RUNTIME_DIR
debug3: Ignored env DISPLAY
debug3: Ignored env LESSCLOSE
debug3: Ignored env _
debug3: Ignored env OLDPWD
debug1: Sending command: git-upload-pack 'richinnz/zog-2017.git'
debug2: channel 0: request exec confirm 1
debug3: send packet: type 98
debug2: callback done
debug2: channel 0: open confirm rwindow 2097152 rmax 32768
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: exec request accepted on channel 0
debug2: channel 0: rcvd ext data 26
debug3: receive packet: type 98
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug3: receive packet: type 96
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug3: receive packet: type 97
debug2: channel 0: rcvd close
debug2: channel 0: close_read
debug2: channel 0: input open -> closed
debug3: channel 0: will not send data after close
debug2: channel 0: obuf_empty delayed efd 7/(26)
repository access denied.
debug2: channel 0: written 26 to efd 7
debug3: channel 0: will not send data after close
debug2: channel 0: obuf empty
debug2: channel 0: close_write
debug2: channel 0: output drain -> closed
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug3: send packet: type 97
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
  #0 client-session (t4 r0 i3/0 o3/0 fd -1/-1 cc -1)

debug3: send packet: type 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Transferred: sent 2700, received 1736 bytes, in 0.5 seconds
Bytes per second: sent 5293.0, received 3403.2
debug1: Exit status 1
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Both computer are Ubuntu 16.04, computer1 is located in New Zealand, computer2 is located in AWS Sydney

I have tried:

setting the IP address of bitbucket.org on computer2 to the same as computer1 (in /etc/hosts)

removing .ssh/id_rsa from .ssh/ to be sure the wrong private key is not picked up

creating new keys

copying .ssh/config from computer1 to computer2 to be sure they are the same

What else can I try to resolve this?

Body:
For Bitbucket, your .ssh/config file needs to use the User git.

Not User xxx.

Host bitbucket.org-infoodle
    Hostname bitbucket.org
    User git                                    <============
    IdentityFile ~/.ssh/id_rsa-bb_infoodle2
    LogLevel DEBUG3

BitBucket will only accept remote ssh connection for that user.

And it will use the public key to authenticate you.

And you don't need git@bitbucket.org-infoodle, just  bitbucket.org-infoodle:...

See "Why does Git using ssh use git as a username".

You actual issue, though, seems related to the network quality, not to ssh settings.

I believe I cleared my credentials with sudo git config --system --unset credential.helper

I describe that here, but this is for HTTPS URLs, not SSH ones.

Double-check your remote: git remote -v.