问:
How to zero-pad numeric variables in zsh (and maybe also bash?)
In zsh, when I have to create a bunch of files with zsh, I usually do something like:

```<code>for x in $(seq 1 1000); do .....; done
</code>```

This works fine, it gives me files with names foo-1.txt .. foo-1000.txt.

However, these files do not sort nicely, so I would like to zero-pad the $x variable, thus producing names of foo-0001.txt .. foo-1000.txt.

How to do that in zsh? (and bonus question, how to do it in bash?)

答:
printf

Using printf to pad with zeros works in any shell:

```<code>$ printf 'foo%03d.txt\n' $(seq 4)
foo001.txt
foo002.txt
foo003.txt
foo004.txt

$           printf  'foo%03d.txt\n' {1..4}       # works in bash, ksh, zsh.
$ n=4;      printf  'foo%03d.txt\n' {1..$n}      # only ksh, zsh
$ n=4; eval printf '"foo%03d.txt\n" {1..'"$n"'}' # workaround needed for bash
</code>```

Use brace expansion (only bash and zsh keep the leading zeros ksh don't).

```<code>$ printf '%s\n' foo{1..004}.txt
foo001.txt
foo002.txt
foo003.txt
foo004.txt
</code>```

Body:
In zsh, when I have to create a bunch of files with zsh, I usually do something like:

for x in $(seq 1 1000); do .....; done

This works fine, it gives me files with names foo-1.txt .. foo-1000.txt.

However, these files do not sort nicely, so I would like to zero-pad the $x variable, thus producing names of foo-0001.txt .. foo-1000.txt.

How to do that in zsh? (and bonus question, how to do it in bash?)

Body:
printf

Using printf to pad with zeros works in any shell:

$ printf 'foo%03d.txt\n' $(seq 4)
foo001.txt
foo002.txt
foo003.txt
foo004.txt

$           printf  'foo%03d.txt\n' {1..4}       # works in bash, ksh, zsh.
$ n=4;      printf  'foo%03d.txt\n' {1..$n}      # only ksh, zsh
$ n=4; eval printf '"foo%03d.txt\n" {1..'"$n"'}' # workaround needed for bash

Use brace expansion (only bash and zsh keep the leading zeros ksh don't).

$ printf '%s\n' foo{1..004}.txt
foo001.txt
foo002.txt
foo003.txt
foo004.txt


来源: stackexchange

问:
Make graphviz from sklearn RandomForestClassifier (not from individual clf.estimators_)
Python. Sklearn. RandomForestClassifier. After fitting RandomForestClassifier, does it produce some kind of single "best" "averaged" consensus tree that could be used to create a graphviz?

Yes, I looked at the documentation. No it doesn't say anything about it. No RandomForestClassifier doesn't have a tree_ attribute. However, you can get the individual trees in the forest from clf.estimators_ so I know I could make a graphviz from one of those. There is an example of that here. I could even score all trees and find the tree with the highest score amongst the forest and choose that one... but that's not what I'm asking.

I want to make a graphviz from the "averaged" final random forest classifier result. Is this possible? Or, does the final classifier use the underlying trees to produce scores and predictions?

答:
A RandomForest is an ensemble method that uses averaging to do prediction, i.e. all the fitted sub classifiers are used, typically (but not always) in a majority voting ensemble, to arrive at the final prediction. This is usually true for all ensemble methods. As Vivek Kumar points out in the comments, the prediction is not necessarily always a pure majority vote but can also be a weighted majority or indeed some other exotic form of combining the individual predictions (research on ensemble methods is ongoing although somewhat sidelined by deep learning).

There is no average tree that could be graphed, only the decision stumps that were trained from random sub samples of the whole dataset and the predictions that each of those produces. It's the predictions themselves that are averaged, not the trees / stumps.

Just for completeness, from the wikipedia article: (emphasis mine)

Random forests or random decision forests1[2] are an ensemble learning method for classification, regression and other tasks, that operate by constructing a multitude of decision trees at training time and outputting the class that is the mode of the classes (classification) or mean prediction (regression) of the individual trees.

mode being the most common value, in other words the majority prediction.

ContentLicense: CC BY-SA 3.0


问:
Replace anything in certain position in string using javascript regular expression
I am trying to remove empty all paragraph tags, regardless of what style attributes might be in the p tag, from a string. I want to remove, for example, all of these and replace with an empty string.

```<code><p style="margin-left:0px"></p>
<p></p>
<p style="margin-left:1cm; margin-right:1cm"></p>
</code>```

So far, to deal with one situation I have, I am doing this:

```<code>str = str.replace(/<p style=\"margin:0cm 0cm 10pt\"><\/p>/g,'')
</code>```

which is working in that particular situation. How can I write it so it removes

```<code><p AnythingHereInThisTag></p>
</code>```

and replaces it with an empty string?

Edit - further to answer below - if I do this:

```<code>str = str.replace(/<p(.*)><\/p>/g,'')
</code>```

it is replacing the whole string which might look like

```<code><p>Hello</p><p>Some text in the middle</p><p>Goodbye</p>
</code>```

It needs to look at each pair of

 tags

答:
Something like this?

```<code>str = 'asd<p style="margin-left:0px"></p><p></p><p style="margin-left:1cm; margin-right:1cm"></p>'
str.replace(/<p(.*)><\/p>/g,'') // "asd"
</code>```

Reading the question again, it is unclear if you wanted to remove only the attributes within the
 tag, or the tag completely. Please clarify.

You can read more about regular expression here.

Body:
I am trying to remove empty all paragraph tags, regardless of what style attributes might be in the p tag, from a string. I want to remove, for example, all of these and replace with an empty string.

So far, to deal with one situation I have, I am doing this:

str = str.replace(/
<\/p>/g,'')

which is working in that particular situation. How can I write it so it removes

and replaces it with an empty string?

Edit - further to answer below - if I do this:

str = str.replace(/
<\/p>/g,'')

it is replacing the whole string which might look like

Hello

Some text in the middle

Goodbye

It needs to look at each pair of

 tags

Body:
Something like this?

str = 'asd<p style="margin-left:0px"></p><p></p><p style="margin-left:1cm; margin-right:1cm"></p>'
str.replace(/<p(.*)><\/p>/g,'') // "asd"

Reading the question again, it is unclear if you wanted to remove only the attributes within the
 tag, or the tag completely. Please clarify.

You can read more about regular expression here.


问:
Linking raw data/resource into executable using LD
Until now I've always used resources under MSVC++ to get access to raw data from inside of my programs and I've never worked with a linker directly, but now I'm under Linux and I'm using a cross-compiler to produce elf files. A friend and I are working on a toy OS.

One thing we need to get accomplished at some point is for a rather large piece of arbitrary raw data to be linked into the executable. We want the data to be located near the end of the executable and need to be able to get a pointer to that raw data as well. It's probably worth noting that GRUB is loading the kernel into memory at boot time.

One of our previous ideas was to just write a program to convert the data into a C source file where the data was represented as an array of bytes, but we figure that's a little bit messy and we'd rather have it linked in directly.

Any insights? I don't need the gruesome details just a broad overview of what needs to be done. I figure we probably have to make some changes to our linker script.

答:
Take a look at calling objdump --add-section after you complete the link to add the arbitrary data to the ELF file.

Alternatively, if you are writing a kernel, you can do what Linux does to load an initrd and just have GRUB load your kernel and then load the data seperately to a known memory location and access it that way.


问:
spread syntax with map doesn't work
```<code>data.map(obj =>
        {person_name: obj.user.name,
        ...obj})
</code>```

Why above code failed?

my data look like this

```<code>[{user:{name:'hello'},age:1},{user:{name:'world'},age:1,{user:{name:'another_name'},age:1]
</code>```

I want to 'pull' the obj.user.name out from the nested obj.

答:
Try this:

```<code>data.map(obj => ({person_name: obj.user.name,...obj}))
</code>```

The { at the beginning of the object was interpreted as the beginning of a block instead of an object.

You can read more about this on MDN

EDIT:
As Pawel mentioned, using the spread operator with objects does not work with pure es6 you need to use a specific transform like in this proposal: https://github.com/tc39/proposal-object-rest-spread

Title: spread syntax with map doesn't work

Body:
data.map(obj =>
        {person_name: obj.user.name,
        ...obj})

Why above code failed?

my data look like this

[{user:{name:'hello'},age:1},{user:{name:'world'},age:1,{user:{name:'another_name'},age:1]

I want to 'pull' the obj.user.name out from the nested obj.

Body:
Try this:

data.map(obj => ({person_name: obj.user.name,...obj}))

The { at the beginning of the object was interpreted as the beginning of a block instead of an object.

You can read more about this on MDN

EDIT:
As Pawel mentioned, using the spread operator with objects does not work with pure es6 you need to use a specific transform like in this proposal: https://github.com/tc39/proposal-object-rest-spread


问:
adding two values using react native and display the result
I'm developing simple calculator using react native, just for addition of two numbers. How can I store values to variable and display them using TextInput? And how to add those variables?

答:
```<code>  import React, { Component } from 'react';
import {AppRegistry,StyleSheet,Text,TextInput,View,Button, } from 'react-native';
export default class logintut extends Component{

  constructor(props){
        super(props);
        this.state ={ f1: '',f2: '',result: '' };
    }
    render() {
      var f1 = this.state.f1;
      var f2 = this.state.f2 ;
          const result = f1 && f2 ?  f2 + f1 : null;

        return (

           <View>
                 <TextInput keyboardType ='numeric' onChangeText= {(text) => this.setState({f1:parseInt(text)})} />

                 <TextInput keyboardType ='numeric' onChangeText={(text) => this.setState({f2: parseInt(text)})} />

                 { result ? <Text>{ result }</Text> : null }
           </View>
        );
      }
}
AppRegistry.registerComponent('logintut', () => logintut);
</code>```


问:
Running files from within project
I have a project where I'm trying to run a batch file from within a class

The ultimate goal is to run this on many machines - so I can't use a "magic" path to use this file because it's located within my project not my C drive

The absolute path works (obviously), but I'm struggling to create a path within Eclipse to reference it

I have the batch.bat within a folder called "batchfiles" but when I try to run the following command I get a file not found error

```<code>Runtime.getRuntime().exec("cmd /c start \\batchfiles\\batch.bat");
</code>```

even though batch.bat exists in that folder within my project

答:
You should take a look to ProcessBuilder. Here's a complete example from documentation :

```<code> ProcessBuilder pb = new ProcessBuilder("myCommand", "myArg1", "myArg2");
 Map<String, String> env = pb.environment();
 env.put("VAR1", "myValue");
 env.remove("OTHERVAR");
 env.put("VAR2", env.get("VAR1") + "suffix");
 pb.directory(new File("myDir"));
 File log = new File("log");
 pb.redirectErrorStream(true);
 pb.redirectOutput(Redirect.appendTo(log));
 Process p = pb.start();
 assert pb.redirectInput() == Redirect.PIPE;
 assert pb.redirectOutput().file() == log;
 assert p.getInputStream().read() == -1;
</code>```

In your case, I think the command should be :

```<code> ProcessBuilder pb = new ProcessBuilder("cmd", "/c", "start", "\\batchfiles\\batch.bat");
</code>```

Title: Running files from within project

Body:
I have a project where I'm trying to run a batch file from within a class

The ultimate goal is to run this on many machines - so I can't use a "magic" path to use this file because it's located within my project not my C drive

The absolute path works (obviously), but I'm struggling to create a path within Eclipse to reference it

I have the batch.bat within a folder called "batchfiles" but when I try to run the following command I get a file not found error

Runtime.getRuntime().exec("cmd /c start \\batchfiles\\batch.bat");

even though batch.bat exists in that folder within my project

Body:
You should take a look to ProcessBuilder. Here's a complete example from documentation :

 ProcessBuilder pb = new ProcessBuilder("myCommand", "myArg1", "myArg2");
 Map<String, String> env = pb.environment();
 env.put("VAR1", "myValue");
 env.remove("OTHERVAR");
 env.put("VAR2", env.get("VAR1") + "suffix");
 pb.directory(new File("myDir"));
 File log = new File("log");
 pb.redirectErrorStream(true);
 pb.redirectOutput(Redirect.appendTo(log));
 Process p = pb.start();
 assert pb.redirectInput() == Redirect.PIPE;
 assert pb.redirectOutput().file() == log;
 assert p.getInputStream().read() == -1;

In your case, I think the command should be :

 ProcessBuilder pb = new ProcessBuilder("cmd", "/c", "start", "\\batchfiles\\batch.bat");


问:
issue with column width
ISSUE DEMO

In HTML table, on select of an item in 1st row, 2nd row is made visible(Table has 2 columns).

Now here in 2nd row, column width is shrinked which is highlighted in blue. Why is that so?

Have been trying to surf for couple of days but none seems to be working.

It would be helpful if anyone would point out what's wrong.

function showDiv(select){
   if(select.value==2){
    document.getElementById('future_date').style.display = "block";
   } else{
        document.getElementById('future_date').style.display = "none";
   }
} ```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.table1 {
  color: #2a2929;
  padding-top: 20px;
  margin-bottom: 7px;
  text-align: center;
}

.col-md-12 {
  width: 100%;
}

.table1 table {
  width: 100%;
  text-align: center;
  padding: 10px;
  background-color: grey;
  padding-left: 10px;
  padding-right: 10px;
  margin-top: 25px;
}

.table-text-filed{
  width:100%;
  border:1px solid #d4d5d7;
  color:#2a2929;
  text-align: center;
}

.body {
  color: #fff;
  font-size: 18px;
  line-height: 23px;
  font-family: calibri;
}

.table1 td {
  padding: 5px;
  background-color: white;
}

.table1 tr {
  padding: 5px;
  background-color: blue;
}</code>```

        Type

            <select name="token_date_id" onchange="showDiv(this)" class="table-text-filed" required>
                <option value="1">Today</option>
                <option value="2">Future Date</option>
            </select>

        Select Date

            <input type="date" name="token_date" value="" class="table-text-filed" data-date='{"startView": 2}'>

```

答:
change display value from 'block' to 'table-row'

function showDiv(select){
   if(select.value==2){
    document.getElementById('future_date').style.display = "table-row";
   } else{
        document.getElementById('future_date').style.display = "none";
   }
} ```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.table1 {
  color: #2a2929;
  padding-top: 20px;
  margin-bottom: 7px;
  text-align: center;
}

.col-md-12 {
  width: 100%;
}

.table1 table {
  width: 100%;
  text-align: center;
  padding: 10px;
  background-color: grey;
  padding-left: 10px;
  padding-right: 10px;
  margin-top: 25px;
}

.table-text-filed{
  width:100%;
  border:1px solid #d4d5d7;
  color:#2a2929;
  text-align: center;
}

.body {
  color: #fff;
  font-size: 18px;
  line-height: 23px;
  font-family: calibri;
}

.table1 td {
  padding: 5px;
  background-color: white;
}

.table1 tr {
  padding: 5px;
  background-color: blue;
}</code>```

        Type

            <select name="token_date_id" onchange="showDiv(this)" class="table-text-filed" required>
                <option value="1">Today</option>
                <option value="2">Future Date</option>
            </select>

        Select Date

            <input type="date" name="token_date" value="" class="table-text-filed" data-date='{"startView": 2}'>

```

Title: issue with column width

Body:
ISSUE DEMO

In HTML table, on select of an item in 1st row, 2nd row is made visible(Table has 2 columns).

Now here in 2nd row, column width is shrinked which is highlighted in blue. Why is that so?

Have been trying to surf for couple of days but none seems to be working.

It would be helpful if anyone would point out what's wrong.

function showDiv(select){
   if(select.value==2){
    document.getElementById('future_date').style.display = "block";
   } else{
        document.getElementById('future_date').style.display = "none";
   }
}

.table1 {
  color: #2a2929;
  padding-top: 20px;
  margin-bottom: 7px;
  text-align: center;
}

.col-md-12 {
  width: 100%;
}

.table1 table {
  width: 100%;
  text-align: center;
  padding: 10px;
  background-color: grey;
  padding-left: 10px;
  padding-right: 10px;
  margin-top: 25px;
}

.table-text-filed{
  width:100%;
  border:1px solid #d4d5d7;
  color:#2a2929;
  text-align: center;
}

.body {
  color: #fff;
  font-size: 18px;
  line-height: 23px;
  font-family: calibri;
}

.table1 td {
  padding: 5px;
  background-color: white;
}

.table1 tr {
  padding: 5px;
  background-color: blue;
}

        Type

            <select name="token_date_id" onchange="showDiv(this)" class="table-text-filed" required>
                <option value="1">Today</option>
                <option value="2">Future Date</option>
            </select>

        Select Date

            <input type="date" name="token_date" value="" class="table-text-filed" data-date='{"startView": 2}'>

Body:
change display value from 'block' to 'table-row'

function showDiv(select){
   if(select.value==2){
    document.getElementById('future_date').style.display = "table-row";
   } else{
        document.getElementById('future_date').style.display = "none";
   }
}

.table1 {
  color: #2a2929;
  padding-top: 20px;
  margin-bottom: 7px;
  text-align: center;
}

.col-md-12 {
  width: 100%;
}

.table1 table {
  width: 100%;
  text-align: center;
  padding: 10px;
  background-color: grey;
  padding-left: 10px;
  padding-right: 10px;
  margin-top: 25px;
}

.table-text-filed{
  width:100%;
  border:1px solid #d4d5d7;
  color:#2a2929;
  text-align: center;
}

.body {
  color: #fff;
  font-size: 18px;
  line-height: 23px;
  font-family: calibri;
}

.table1 td {
  padding: 5px;
  background-color: white;
}

.table1 tr {
  padding: 5px;
  background-color: blue;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<div class="col-md-12 table1">
  <table border="1">
    <tr>
        <td col width="40%">Type</td>
        <td>
            <select name="token_date_id" onchange="showDiv(this)" class="table-text-filed" required>
                <option value="1">Today</option>
                <option value="2">Future Date</option>
            </select>
        </td>
    </tr>
    <tr id="future_date" style="display:none">
        <td  col width="40%">Select Date</td>
        <td>
            <input type="date" name="token_date" value="" class="table-text-filed" data-date='{"startView": 2}'>
        </td>
    </tr>
  </table>
</div>


问:
Long-running operation to update an Android appwidget
I have a widget that needs to perform a potentially long-running operation in onUpdate(). Just performing the operation directly resulted in ANR's. To solve this, my first attempt was to create a thread therein. I noticed that the widget would not get updated in some cases. My guess here is that once onUpdate() exits, Android may kill the process along with the unfinished thread.

My next attempt was to create an intent service. The widget's onUpdate() just starts the intent service, which does the work directly and updates the widget when done. This works, but much to my surprise it appears that onHandleIntent() is single-threaded. If I have two widgets, and then both update and start the intent service, they update sequentially ...

The two widgets case is not really important, but I'm just wondering about a best practice for this type of pattern.

To solve the two widgets case I ended up updating all the widget instances with the same data whenever any one of them is clicked. e.g., I perform the long-running process once and apply the results to all the widget instances. In my scenario this doesn't matter, but for many widgets, it might be important not to do that.

Thoughts?

答:
but much to my surprise it appears that onHandleIntent() is single threaded

Yes.

if i have two widgets, and then both update and start the intent service, they update sequentially ...

Yes.

but i'm just wondering about a best practice for this type of pattern.

Your IntentService was a fine upstanding solution, IMHO. Remember that Android runs on slow CPUs, with devices with little RAM. Running lots of threads in parallel is generally not a good idea.

then i'm getting into starting a thread in onHandleIntent(), which requires a wake lock, and it just seems it's getting all too complicated.

Try my WakefulIntentService.

ContentLicense: CC BY-SA 4.0

ContentLicense: CC BY-SA 2.5


问:
Function giving strange error?
```<code>    function returnNumPlus1(num)
    return num + 1
end

print(returnNumPlus1(0))

print(returnNumPlus1(9000))

local func1 = returnNumPlus1
print(func1(11))
</code>```

I was testing it to try to get it to work without error, but i always get the same error as i post below. Im fairly new to lua, so i hope i can get this to work :D
and gives off the error:

```<code>stdin:1: attempt to call global 'func1' (a nil value)
stack traceback
        stdin:1: in main chunk
        [C]: ?
</code>```

does anyone know why? Thanks!

答:
Assuming you are running this code in lua REPL, you need to define func1 as global rather than local as the local context is specific to each line execution in the REPL and is not available for the next line.

Try:

```<code>function returnNumPlus1(num)
    return num + 1
end

print(returnNumPlus1(0))

print(returnNumPlus1(9000))

func1 = returnNumPlus1
print(func1(11))
</code>```

Title: Function giving strange error?

Body:
    function returnNumPlus1(num)
    return num + 1
end

print(returnNumPlus1(0))

print(returnNumPlus1(9000))

local func1 = returnNumPlus1
print(func1(11))

I was testing it to try to get it to work without error, but i always get the same error as i post below. Im fairly new to lua, so i hope i can get this to work :D
and gives off the error:

stdin:1: attempt to call global 'func1' (a nil value)
stack traceback
        stdin:1: in main chunk
        [C]: ?

does anyone know why? Thanks!

Body:
Assuming you are running this code in lua REPL, you need to define func1 as global rather than local as the local context is specific to each line execution in the REPL and is not available for the next line.

Try:

function returnNumPlus1(num)
    return num + 1
end

print(returnNumPlus1(0))

print(returnNumPlus1(9000))

func1 = returnNumPlus1
print(func1(11))


问:
User input and do while loop with negation
I was trying to make an user input in an do while loop. The loop should continue if the user input is not yes OR not.
    When I write:

```<code>BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    String userInput = "";
    String yes = "yes";
    String no = "no";

    do {
        System.out.print("Type yes or no: ");
        userInput = input.readLine();
    } while (userInput.equals(yes) || userInput.equals(no));
</code>```

If the user type "yes" OR "no" the loop will continue, all other inputs will result the end of the loop.

When I write:

```<code>while (!userInput.equals(yes) || !userInput.equals(no));
</code>```

The loop continues everytime, no matter what the user enters.

Only when I use the AND operator it works.

```<code>while (!userInput.equals(yes) && !userInput.equals(no));
</code>```

Why is that so?
Should it not be the OR operator because I want to say, if the user enters yes OR no stop the loop.

答: Because this is how boolean expressions work. The opposite of A || B is not !A || !B but !(A || B) which is the same as !A && !B.</p>

Body:
I was trying to make an user input in an do while loop. The loop should continue if the user input is not yes OR not.
    When I write:

BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    String userInput = "";
    String yes = "yes";
    String no = "no";

    do {
        System.out.print("Type yes or no: ");
        userInput = input.readLine();
    } while (userInput.equals(yes) || userInput.equals(no));

If the user type "yes" OR "no" the loop will continue, all other inputs will result the end of the loop.

When I write:

while (!userInput.equals(yes) || !userInput.equals(no));

The loop continues everytime, no matter what the user enters.

Only when I use the AND operator it works.

while (!userInput.equals(yes) && !userInput.equals(no));

Why is that so?
Should it not be the OR operator because I want to say, if the user enters yes OR no stop the loop.


问:
Apply Stereotype to operation in Eclipse UML-Designer
Applying a stereotype to an operation

Hi, in the image I have a "REST" stereotype that I would like to apply to the "Operation_2". In effect, at a system level, I want to say that this is a REST API.

I have tried Melanie's suggestion (thank you), but my REST stereotype does not seem to appear as an option.

Stereotype in profile

I have also tried creating a profile, and putting the REST stereotype in the profile. Then tried by selecting the stereotype option from the context/symbol menu that appears when the cursor is over the operation in the class diagram. That is illustrated above, but no luck there either.

Many thanks

Nathan

答:
There is many different ways to apply a stereotype on an operation. The easiest one is to activate the Stereotype layer.

This will add a new Stereotype tool in the palette. Then select this tool and click on your operation, it opens a dialog to select a stereotype.

You will see the stereotype appplied on your operation.


问:
what is the impact tp disable elasticsearch in sonarqube
I am using sonarqube 5.6.3, and found elasticsearch always crash after analysis 5k ~ 50k projects, I intend to disable elasticsearch, is it doable and what is the impact?</p>

答:
Nope, SonarQube won't work without Elasticsearch.

I highly suggest to post your crash with your environment and the log files to the forum at https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!forum/sonarqube


问:
Error:scalac: bad symbolic reference. A signature in RDD.class refers to term hadoop in package org.apache which is not available

Error:scalac: bad symbolic reference. A signature in RDD.class refers
  to term hadoop in package org.apache which is not available. It may be
  completely missing from the current classpath, or the version on the
  classpath might be incompatible with the version used when compiling
  RDD.class.

Error:scalac: missing or invalid dependency detected while loading
  class file 'RDD.class'. Could not access term io in value
  org.apache.hadoop, because it (or its dependencies) are missing. Check
  your build definition for missing or conflicting dependencies. (Re-run
  with -Ylog-classpath to see the problematic classpath.) A full
  rebuild may help if 'RDD.class' was compiled against an incompatible
  version of org.apache.hadoop.

Error:scalac: missing or invalid dependency detected while loading
  class file 'PairRDDFunctions.class'. Could not access term io in value
  org.apache.hadoop, because it (or its dependencies) are missing. Check
  your build definition for missing or conflicting dependencies. (Re-run
  with -Ylog-classpath to see the problematic classpath.) A full
  rebuild may help if 'PairRDDFunctions.class' was compiled against an
  incompatible version of org.apache.hadoop.

答: I have already solved now ,  add hadoop jars can solve </p>


问:
SQL to convert distinct item in row to column
I have a table as

```<code>Date          Item          Quantity
20170101      Mango         5
20170101      Orange        6
20170102      Mango         7
20170102      Orange        8
</code>```

I want below output

```<code>Date        Mango       Orange
20170101    5           6
20170102    7           8
</code>```

for this i used below sql query

```<code>SELECT
   Date,
   SUM(case when Item='Mango' then Quantity else 0 end) AS Mango,
   SUM(case when Item='Orange' then Quantity else 0 end) AS Orange
FROM orderTable
GROUP BY date
</code>```

but this is kind of hard coding for Mango and Orange. What if I need new item in orderTable. Can any one suggest me how can I make this query dynamic. So that if I add new item it automatically create new coulmn having item name as name and it will have 0 value under column against date when order not placed for that item.

like

```<code>Date          Item          Quantity
20170101      Mango         5
20170101      Orange        6
20170102      Mango         7
20170102      Orange        8
20170102      Cherry        9
</code>```

then output should be as ...

```<code>Date        Mango       Orange    Cherry
20170101    5           6         0
20170102    7           8         9
</code>```

答:
Try this :

```<code>CREATE TABLE [dbo].[test](
    [Date] [int] NULL,
    [Item] [nvarchar](50) NULL,
    [Quantity] [int] NULL
) ON [PRIMARY]

GO
INSERT [dbo].[test] ([Date], [Item], [Quantity]) VALUES (20170101, N'Mango', 5)
GO
INSERT [dbo].[test] ([Date], [Item], [Quantity]) VALUES (20170101, N'Orange', 6)
GO
INSERT [dbo].[test] ([Date], [Item], [Quantity]) VALUES (20170102, N'Mango', 7)
GO
INSERT [dbo].[test] ([Date], [Item], [Quantity]) VALUES (20170102, N'Orange', 8)
GO
INSERT [dbo].[test] ([Date], [Item], [Quantity]) VALUES (20170102, N'Cherry', 5)
GO
INSERT [dbo].[test] ([Date], [Item], [Quantity]) VALUES (20170103, N'Cherry', 2)
GO
</code>```

dynamic sql :

```<code>DECLARE @cols AS NVARCHAR(MAX),
    @query  AS NVARCHAR(MAX)

select @cols = STUFF((SELECT DISTINCT ',' + QUOTENAME(Item)
                    from test
            FOR XML PATH(''), TYPE
            ).value('.', 'NVARCHAR(MAX)')
        ,1,1,'')

set @query = N'SELECT DATE, ' + @cols + N' from
             (
                select Date,Item, Quantity from test
            ) x
            pivot
            (
                max(Quantity)
                for Item in (' + @cols + N')
            ) p '

exec sp_executesql @query;
</code>```

result :

```<code>DATE       Cherry   Mango   Orange
20170101    NULL    5       6
20170102    5       7       8
20170103    2      NULL     NULL
</code>```

Body:
I have a table as

Date          Item          Quantity
20170101      Mango         5
20170101      Orange        6
20170102      Mango         7
20170102      Orange        8

I want below output

Date        Mango       Orange
20170101    5           6
20170102    7           8

for this i used below sql query

SELECT
   Date,
   SUM(case when Item='Mango' then Quantity else 0 end) AS Mango,
   SUM(case when Item='Orange' then Quantity else 0 end) AS Orange
FROM orderTable
GROUP BY date

but this is kind of hard coding for Mango and Orange. What if I need new item in orderTable. Can any one suggest me how can I make this query dynamic. So that if I add new item it automatically create new coulmn having item name as name and it will have 0 value under column against date when order not placed for that item.

like

Date          Item          Quantity
20170101      Mango         5
20170101      Orange        6
20170102      Mango         7
20170102      Orange        8
20170102      Cherry        9

then output should be as ...

Date        Mango       Orange    Cherry
20170101    5           6         0
20170102    7           8         9

Body:
Try this :

CREATE TABLE [dbo].[test](
    [Date] [int] NULL,
    [Item] [nvarchar](50) NULL,
    [Quantity] [int] NULL
) ON [PRIMARY]

GO
INSERT [dbo].[test] ([Date], [Item], [Quantity]) VALUES (20170101, N'Mango', 5)
GO
INSERT [dbo].[test] ([Date], [Item], [Quantity]) VALUES (20170101, N'Orange', 6)
GO
INSERT [dbo].[test] ([Date], [Item], [Quantity]) VALUES (20170102, N'Mango', 7)
GO
INSERT [dbo].[test] ([Date], [Item], [Quantity]) VALUES (20170102, N'Orange', 8)
GO
INSERT [dbo].[test] ([Date], [Item], [Quantity]) VALUES (20170102, N'Cherry', 5)
GO
INSERT [dbo].[test] ([Date], [Item], [Quantity]) VALUES (20170103, N'Cherry', 2)
GO

dynamic sql :

DECLARE @cols AS NVARCHAR(MAX),
    @query  AS NVARCHAR(MAX)

select @cols = STUFF((SELECT DISTINCT ',' + QUOTENAME(Item)
                    from test
            FOR XML PATH(''), TYPE
            ).value('.', 'NVARCHAR(MAX)')
        ,1,1,'')

set @query = N'SELECT DATE, ' + @cols + N' from
             (
                select Date,Item, Quantity from test
            ) x
            pivot
            (
                max(Quantity)
                for Item in (' + @cols + N')
            ) p '

exec sp_executesql @query;

result :

DATE       Cherry   Mango   Orange
20170101    NULL    5       6
20170102    5       7       8
20170103    2      NULL     NULL


问:
When to use NSInteger vs. int
When should I be using NSInteger vs. int when developing for iOS?  I see in the Apple sample code they use NSInteger (or NSUInteger) when passing a value as an argument to a function or returning a value from a function.

```<code>- (NSInteger)someFunc;...
- (void)someFuncWithInt:(NSInteger)value;...
</code>```

But within a function they're just using int to track a value

```<code>for (int i; i < something; i++)
...

int something;
something += somethingElseThatsAnInt;
...
</code>```

I've read (been told) that NSInteger is a safe way to reference an integer in either a 64-bit or 32-bit environment so why use int at all?

答:
You usually want to use NSInteger when you don't know what kind of processor architecture your code might run on, so you may for some reason want the largest possible integer type, which on 32 bit systems is just an int, while on a 64-bit system it's a long.

I'd stick with using NSInteger instead of int/long unless you specifically require them.

NSInteger/NSUInteger are defined as *dynamic typedef*s to one of these types, and they are defined like this:

```<code>#if __LP64__ || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
typedef long NSInteger;
typedef unsigned long NSUInteger;
#else
typedef int NSInteger;
typedef unsigned int NSUInteger;
#endif
</code>```

With regard to the correct format specifier you should use for each of these types, see the String Programming Guide's section on Platform Dependencies

Title: When to use NSInteger vs. int

Body:
When should I be using NSInteger vs. int when developing for iOS?  I see in the Apple sample code they use NSInteger (or NSUInteger) when passing a value as an argument to a function or returning a value from a function.

- (NSInteger)someFunc;...
- (void)someFuncWithInt:(NSInteger)value;...

But within a function they're just using int to track a value

for (int i; i < something; i++)
...

int something;
something += somethingElseThatsAnInt;
...

I've read (been told) that NSInteger is a safe way to reference an integer in either a 64-bit or 32-bit environment so why use int at all?

Body:
You usually want to use NSInteger when you don't know what kind of processor architecture your code might run on, so you may for some reason want the largest possible integer type, which on 32 bit systems is just an int, while on a 64-bit system it's a long.

I'd stick with using NSInteger instead of int/long unless you specifically require them.

NSInteger/NSUInteger are defined as *dynamic typedef*s to one of these types, and they are defined like this:

#if __LP64__ || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
typedef long NSInteger;
typedef unsigned long NSUInteger;
#else
typedef int NSInteger;
typedef unsigned int NSUInteger;
#endif

With regard to the correct format specifier you should use for each of these types, see the String Programming Guide's section on Platform Dependencies


问:
Unable to find main (Error) while launching Unity from Android
I am trying to launch UnityPlayerActivity on button click. But its throwing up an error as "Unable to find main".

In Manifest,

```<code><activity
        android:name="com.unity3d.player.UnityPlayerActivity"
        android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection"
        android:label="@string/app_name"
        android:launchMode="singleTask"
        android:screenOrientation="landscape">
        <intent-filter>
            <category android:name="com.google.intent.category.CARDBOARD" />
        </intent-filter>
        <meta-data
            android:name="unityplayer.UnityActivity"
            android:value="true" />
    </activity>
</code>```

I am launching using the below code

```<code>Intent intent = new Intent(CurrentActivity.this, UnityPlayerActivity.class);
    startActivity(intent);
</code>```

答:
Just building the armeabi-v7a build will work. But if you are trying to build other builds like x86 or universal apk, then you are goind to get this sort of error.

So, in gradle specify to build only armeabi-v7a apk.

```<code>splits {

    // Configures multiple APKs based on ABI.
    abi {

        // Enables building multiple APKs per ABI.
        enable true

        // By default all ABIs are included, so use reset() and include to specify that we only
        // want APKs for x86, armeabi-v7a, and mips.

        // Resets the list of ABIs that Gradle should create APKs for to none.
        reset()

        // Specifies a list of ABIs that Gradle should create APKs for.
        include "armeabi-v7a"
    }
}
</code>```

Body:
I am trying to launch UnityPlayerActivity on button click. But its throwing up an error as "Unable to find main".

In Manifest,

<activity
        android:name="com.unity3d.player.UnityPlayerActivity"
        android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection"
        android:label="@string/app_name"
        android:launchMode="singleTask"
        android:screenOrientation="landscape">
        <intent-filter>
            <category android:name="com.google.intent.category.CARDBOARD" />
        </intent-filter>
        <meta-data
            android:name="unityplayer.UnityActivity"
            android:value="true" />
    </activity>

I am launching using the below code

Intent intent = new Intent(CurrentActivity.this, UnityPlayerActivity.class);
    startActivity(intent);

Body:
Just building the armeabi-v7a build will work. But if you are trying to build other builds like x86 or universal apk, then you are goind to get this sort of error.

So, in gradle specify to build only armeabi-v7a apk.

splits {

    // Configures multiple APKs based on ABI.
    abi {

        // Enables building multiple APKs per ABI.
        enable true

        // By default all ABIs are included, so use reset() and include to specify that we only
        // want APKs for x86, armeabi-v7a, and mips.

        // Resets the list of ABIs that Gradle should create APKs for to none.
        reset()

        // Specifies a list of ABIs that Gradle should create APKs for.
        include "armeabi-v7a"
    }
}


问:
sql-to fetch reciprocal data
I have a table in Oracle db, which contains data like this, a+b, b+a, c+d, d+c.

My question is, when a+b = b+a, how to fetch distinct records.

```<code>PK         CODE
1000    87DIA4+BAJI204
1001    87DIA4+BIJI939
1002    87DIA4+C3IDI02
1003    87DIA4+C3IZI419
1004    BAJI204+87DIA4
1005    BIJI939+87DIA4
1006    C3IDI02+87DIA4
1007    C3IZI419+87DIA4
</code>```

答:
If I understand your question, you may need something like this:

```<code>with yourTable(PK, CODE) as (
    select '1000',    '87DIA4+BAJI204' from dual union all
    select '1001',    '87DIA4+BIJI939' from dual union all
    select '1002',    '87DIA4+C3IDI02' from dual union all
    select '1003',    '87DIA4+C3IZI419' from dual union all
    select '1004',    'BAJI204+87DIA4' from dual union all
    select '1005',    'BIJI939+87DIA4' from dual union all
    select '1006',    'C3IDI02+87DIA4' from dual union all
    select '1007',    'C3IZI419+87DIA4' from dual
)
select least( substr(code, 1, instr(code, '+') -1), substr(code, instr(code, '+') +1)) as A,
       greatest( substr(code, 1, instr(code, '+') -1), substr(code, instr(code, '+') +1)) as B
from yourTable
group by least( substr(code, 1, instr(code, '+') -1), substr(code, instr(code, '+') +1)),
       greatest( substr(code, 1, instr(code, '+') -1), substr(code, instr(code, '+') +1))
</code>```

that gives:

```<code>A               B
--------------- ---------------
87DIA4          BAJI204
87DIA4          BIJI939
87DIA4          C3IDI02
87DIA4          C3IZI419
</code>```

The idea is to separate the values in each row and, for each row, evaluate the "smallest" and the "greatest" value. This way, you can use these results  to group and get only one row A+B if you have A+B and B+A.

Title: sql-to fetch reciprocal data

Body:
I have a table in Oracle db, which contains data like this, a+b, b+a, c+d, d+c.

My question is, when a+b = b+a, how to fetch distinct records.

PK         CODE
1000    87DIA4+BAJI204
1001    87DIA4+BIJI939
1002    87DIA4+C3IDI02
1003    87DIA4+C3IZI419
1004    BAJI204+87DIA4
1005    BIJI939+87DIA4
1006    C3IDI02+87DIA4
1007    C3IZI419+87DIA4

Body:
If I understand your question, you may need something like this:

with yourTable(PK, CODE) as (
    select '1000',    '87DIA4+BAJI204' from dual union all
    select '1001',    '87DIA4+BIJI939' from dual union all
    select '1002',    '87DIA4+C3IDI02' from dual union all
    select '1003',    '87DIA4+C3IZI419' from dual union all
    select '1004',    'BAJI204+87DIA4' from dual union all
    select '1005',    'BIJI939+87DIA4' from dual union all
    select '1006',    'C3IDI02+87DIA4' from dual union all
    select '1007',    'C3IZI419+87DIA4' from dual
)
select least( substr(code, 1, instr(code, '+') -1), substr(code, instr(code, '+') +1)) as A,
       greatest( substr(code, 1, instr(code, '+') -1), substr(code, instr(code, '+') +1)) as B
from yourTable
group by least( substr(code, 1, instr(code, '+') -1), substr(code, instr(code, '+') +1)),
       greatest( substr(code, 1, instr(code, '+') -1), substr(code, instr(code, '+') +1))

that gives:

A               B
--------------- ---------------
87DIA4          BAJI204
87DIA4          BIJI939
87DIA4          C3IDI02
87DIA4          C3IZI419

The idea is to separate the values in each row and, for each row, evaluate the "smallest" and the "greatest" value. This way, you can use these results  to group and get only one row A+B if you have A+B and B+A.


问:
C# How to find a 1x1 image tag in HTML
I would like to know how to find an image tag in a string of HTML that has dimensions of 1x1, basically I am looking for tracking pixels. So for example:

```<code><img src=\"http://somewhere.com\" width=\"1\" height=\"1\" style=\"display:none!important;\">
</code>```

My end goal is to be able to find this part of the code and remove it from the string.

I have read few a few posts already on how to find all img tags but that is not what I am looking for. I only want the img tags that are 1x1.

Can anyone help with this?

答:
Not really a very good practice of parsing HTML with regexp, but I guess you colud get all  tags with  and then do your regular

```<code>if (str.IndexOf("width=\"1\"" > 0 && str.IndexOf("height=\"1\"") > 0)
</code>```

but there is much more to it, and I suggest you take a look at HTML Agility Pack

Title: C# How to find a 1x1 image tag in HTML

Body:
I would like to know how to find an image tag in a string of HTML that has dimensions of 1x1, basically I am looking for tracking pixels. So for example:

My end goal is to be able to find this part of the code and remove it from the string.

I have read few a few posts already on how to find all img tags but that is not what I am looking for. I only want the img tags that are 1x1.

Can anyone help with this?

Body:
Not really a very good practice of parsing HTML with regexp, but I guess you colud get all <img> tags with <img.*?> and then do your regular

if (str.IndexOf("width=\"1\"" > 0 && str.IndexOf("height=\"1\"") > 0)

but there is much more to it, and I suggest you take a look at HTML Agility Pack


问:
Doxygen addtogroup issue with a special function FUNC(..)
I have embedded system C code and I used doxygen to document using addtogroup command. When reviewing the html output, one of the function after special function FUNC(..) is not appear in module page. Here is a short sample code.

```<code>
    /*!
      \addtogroup Test
      \brief This is a TestModule
      \{
     */
    extern FUNC(void, IOHWAB_APPL_CODE) Init_Tester(void);

    void TimerOn(void)
    {
    }
    void ADC_On(void)
    {
    }

    /*! \} */ //end of addtogroup

</code>```

On the example above, the doxygen shows only the following.

extern FUNC(void, IOHWAB_APPL_CODE)
 void ADC_On(void)

If I add a dummy function (i.e. void dummy()) in between extern FUNC(..) and void TimerOn(), all the functions are shown except the dummy function.

extern FUNC(void, IOHWAB_APPL_CODE)
  void TimerOn(void)
 void
  ADC_On(void)

Any idea how to fix this issue?

答:
I have test the following code:

```<code>/*!
  \addtogroup   Test
  \brief        This is a TestModule
  \{
 */
extern FUNC(void, IOHWAB_APPL_CODE) Init_Tester(void)
{
}

void Timer(void){}

void TimerOn(void)
{
}

void ADC_On(void)
{
}

/*! \} */ //end of addtogroup
</code>```

And I get the document like this:

```<code>> Functions
>FUNC (void, IOHWAB_APPL_CODE)
>void Timer (void)
>void TimerOn (void)
>void ADC_On (void)
</code>```

If I change the function implement into declare, the function in document disappeared.
It's seemed that the doxygen only document the implement for function, and it parse the TimerOn's implement for FUNC incorrectly. So, miss the TimerOn function in the document.

I am not sure, just test it and guess the result. Hope this can help you.

Body:
I have embedded system C code and I used doxygen to document using addtogroup command. When reviewing the html output, one of the function after special function FUNC(..) is not appear in module page. Here is a short sample code.

    /*!
      \addtogroup Test
      \brief This is a TestModule
      \{
     */
    extern FUNC(void, IOHWAB_APPL_CODE) Init_Tester(void);

    void TimerOn(void)
    {
    }
    void ADC_On(void)
    {
    }

    /*! \} */ //end of addtogroup

On the example above, the doxygen shows only the following.

extern FUNC(void, IOHWAB_APPL_CODE)
 void ADC_On(void)

If I add a dummy function (i.e. void dummy()) in between extern FUNC(..) and void TimerOn(), all the functions are shown except the dummy function.

extern FUNC(void, IOHWAB_APPL_CODE)
  void TimerOn(void)
 void
  ADC_On(void)

Any idea how to fix this issue?

Body:
I have test the following code:

/*!
  \addtogroup   Test
  \brief        This is a TestModule
  \{
 */
extern FUNC(void, IOHWAB_APPL_CODE) Init_Tester(void)
{
}

void Timer(void){}

void TimerOn(void)
{
}

void ADC_On(void)
{
}

/*! \} */ //end of addtogroup

And I get the document like this:

> Functions
>FUNC (void, IOHWAB_APPL_CODE)
>void Timer (void)
>void TimerOn (void)
>void ADC_On (void)

If I change the function implement into declare, the function in document disappeared.
It's seemed that the doxygen only document the implement for function, and it parse the TimerOn's implement for FUNC incorrectly. So, miss the TimerOn function in the document.

I am not sure, just test it and guess the result. Hope this can help you.


问:
how to secure zip file upload?
I've a project in netbeans which my employer wants me to add a bulk file upload.
The requirement was ,the user will put a csv file and some images in a folder in client side. on the file upload page he will choose the csv file and i have to upload the images in the folder along with the csv.
After a short research i found that the client side file location and details can't be accessed from the server side so instead of uploading a single file and  the contents in the folder which it belong, the user will zip all the files and upload the zip file .
Now i'm conserned about the security risks of uploading a zip file.

What all are the measures should i take to prevent the upload of malecious scripts and files along with the zip?

Is it possible to validate the file content before it reach the server ?

Is it possible to validate it securely even after it reached the server side ?

答:
1.- scan the zip files once they arrive at the server.

2.- unlikely. even if you use Javascript as front-end, it doesn't have access to the users file system.

3.- yes, for example with "clamav", but notice that no antivirus is 100% effective.

the steps are:

install clamav

configure clamav to update periodically its virus database

schedule a cron job that continuously scans all files that are in certain directory (the directory where you upload the users files)

delete files that contain viruses

for example:

# dnf install -y clamav

  # dnf install -y clamav-update

$ clamscan java_error_in_IDEA_6451.log.zip

LibClamAV Warning: **************************************************

LibClamAV Warning: *  The virus database is older than 7 days!

LibClamAV Warning:    Please update it as soon as possible.    *

LibClamAV Warning: **************************************************

java_error_in_IDEA_6451.log.zip: OK

----------- SCAN SUMMARY -----------

Known viruses: 4490129

Engine version: 0.99.2

Scanned directories: 0

Scanned files: 1

Infected files: 0

Data scanned: 0.37 MB

Data read: 0.03 MB (ratio 13.43:1)

Time: 6.239 sec (0 m 6 s)

Title: how to secure zip file upload?


答: if( A || B) means either A true or B true. If say A is true then it won't check B it will directly go inside the block. So when you say if(!yes || !no) and if you enter yes then second condition becomes true and when you enter no the first condition becomes true and it continues to execute. And if you enter abdc its again true.

Title: User input and do while loop with negation


问:
Bootstrap 4 Custom Styling CSS For Accordion Cards
So I have now been going at this for too long and would really like some help in getting this Bootstrap 4 accordion customised.

I would like the Background of the cards & Links transparent, the font Size changed, the font color changed and no underline. I have hooked every ID & Class possible using default and special classes, with !important and have had no luck. The Bootstrap 4 documentation only gives inline styles that are limited in color.

.testing {
  background-color: transparent !important;
}

.special-card {
  background-color: transparent !important;
}

.special-card a {
  color: grey !important;
  font-size: 15px !important;
  text-decoration: none !important;
}

.special-card a:hover {
  color: white !important;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>

<div class="panel-group" id="accordion">
  <div class="card text-center">
    <div class="card-header testing">
      <h6 class="card-title">
        Title
      </h6>
    </div>
    <div id="collapseOne" class="panel-collapse collapse">
      <div class="card-block special-card">
        Link 1
        Link 2
        Link 3
      </div>
    </div>
  </div>
</div></code>```

答:
hi try below code i have added background color to body you can change it if needed

html

```<code><div class="panel-group" id="accordion">
  <div class="card text-center testing">
    <div class="card-header ">
      <h6 class="card-title">
        <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">Title</a>
      </h6>
    </div>
    <div id="collapseOne" class="panel-collapse collapse">
      <div class="card-block special-card">
        <a href="" class="list-group-item">Link 1</a>
        <a href="" class="list-group-item">Link 2</a>
        <a href="" class="list-group-item">Link 3</a>
      </div>
    </div>
  </div>
</div>
</code>```

css

```<code>body
{
  background-color: #212121;
}

.testing{
  background-color: transparent;
}
.testing .card-header
{
  background-color: transparent;
}
.testing .card-title a
{
  text-decoration:none;
  font-size:20px;
  color:grey;
}

.special-card {
  background-color: transparent;
}

.special-card
{
  background-color: transparent;
}

.special-card a {
  color: grey;
  font-size: 15px;
   background-color: transparent;
}

.special-card a:hover {
  color: white;
   text-decoration: none;
}
</code>```

no need of using !important flag..

hope this helps
Here is a link for reference

Body:
So I have now been going at this for too long and would really like some help in getting this Bootstrap 4 accordion customised.

I would like the Background of the cards & Links transparent, the font Size changed, the font color changed and no underline. I have hooked every ID & Class possible using default and special classes, with !important and have had no luck. The Bootstrap 4 documentation only gives inline styles that are limited in color.

.testing {
  background-color: transparent !important;
}

.special-card {
  background-color: transparent !important;
}

.special-card a {
  color: grey !important;
  font-size: 15px !important;
  text-decoration: none !important;
}

.special-card a:hover {
  color: white !important;
}

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>

        Title

        Link 1
        Link 2
        Link 3

Body:
hi try below code i have added background color to body you can change it if needed

html

<div class="panel-group" id="accordion">
  <div class="card text-center testing">
    <div class="card-header ">
      <h6 class="card-title">
        <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">Title</a>
      </h6>
    </div>
    <div id="collapseOne" class="panel-collapse collapse">
      <div class="card-block special-card">
        <a href="" class="list-group-item">Link 1</a>
        <a href="" class="list-group-item">Link 2</a>
        <a href="" class="list-group-item">Link 3</a>
      </div>
    </div>
  </div>
</div>

css

body
{
  background-color: #212121;
}

.testing{
  background-color: transparent;
}
.testing .card-header
{
  background-color: transparent;
}
.testing .card-title a
{
  text-decoration:none;
  font-size:20px;
  color:grey;
}

.special-card {
  background-color: transparent;
}

.special-card
{
  background-color: transparent;
}

.special-card a {
  color: grey;
  font-size: 15px;
   background-color: transparent;
}

.special-card a:hover {
  color: white;
   text-decoration: none;
}

no need of using !important flag..

hope this helps
Here is a link for reference


问:
Outlook Email via a Webpage
I have a web application developed with ASP.net and C#  that is running on my companies' intranet.  Because all the users for this application are all using Microsoft Outlook without exception, I would like for the the application to open up an Outlook message on the client-side.  I understand that Office is designed to be run on the desktop and not from a server, however I have no trouble creating a Word or Excel document on the client-side.

I have code that instantiates the Outlook object using the Microsoft.Office.Interop.Outlook namespace and Outlook installed on the server.  When I try to run the code from the server, I get a DCOM source error message that states "The machine-default permission settings do not grant Local Activation permission for the COM Server application with CLSID {000C101C-0000-0000-C000-000000000046} to the user This security permission can be modified using the Component Services administrative tool."  I have modified the permissions using the Component Services tool, but still get this same error.

Is there a way to overcome this or is this a fruitless exercise because Outlook cannot be opened on the client side from the server-side code?

Mailto will not work due to the extreme length that the emails can obtain.  Also, the user that sends it needs add in eye-candy to the text for the recipients.

答:
Do you want to open an existing E-Mail or create a new one?
Perhaps I misunderstood your question; could you provide a link like:

```<code>mailto:recipient@email.tld?subject=This%20is%20the%20subject&body=Hello%20there!
</code>```

When the user clicks on that a link, a new Outlook-E-Mail will be opened and the:

Recipient: recipient@email-tld

Subject: This is the subject

Body: Hello there!

All these fields are already filled from the link.

OwnerDisplayName: Keng

Title: Outlook Email via a Webpage

LastEditorDisplayName: Keng

Body:
Do you want to open an existing E-Mail or create a new one?
Perhaps I misunderstood your question; could you provide a link like:

mailto:recipient@email.tld?subject=This%20is%20the%20subject&body=Hello%20there!

When the user clicks on that a link, a new Outlook-E-Mail will be opened and the:

Recipient: recipient@email-tld

Subject: This is the subject

Body: Hello there!

All these fields are already filled from the link.

OwnerDisplayName: Doozer


问:
Disable selectability for a space
I have the following HTML code:

.meta {
  user-select: none;
}

.meta + .bash::first-letter {
  user-select: none;
  background-color: #ff0000;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><span class="meta">$</span>
<span class="bash"> ls</span></code>```

Now I want the user to be able to select the ls, but not the $ (including the space).

While this works for the $ character, it does not work for the space after it. Why not? what's wrong with my selector?

PS: I have no influence on the HTML code, my only option is to make changes to the CSS.

答:
Try this, created on @ajreal's comment.

.meta {
  user-select: none;
}
.bash{
  display: inline-block;
}
.meta:after {
  content: '\00a0';
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><span class="meta">$</span><span class="bash"> ls</span></code>```

Title: Disable selectability for a space

Body:
I have the following HTML code:

.meta {
  user-select: none;
}

.meta + .bash::first-letter {
  user-select: none;
  background-color: #ff0000;
}

$
 ls

Now I want the user to be able to select the ls, but not the $ (including the space).

While this works for the $ character, it does not work for the space after it. Why not? what's wrong with my selector?

PS: I have no influence on the HTML code, my only option is to make changes to the CSS.

Body:
Try this, created on @ajreal's comment.

.meta {
  user-select: none;
}
.bash{
  display: inline-block;
}
.meta:after {
  content: '\00a0';
}

<span class="meta">$</span><span class="bash"> ls</span>


答:
First, the ::first-letter selector works only for block container boxes (won't work for inline elements).

Second, it seems it can't select a space. If you set the spans to inline-blocks, still the first letter that gets colored red is "l" and not a space.

.meta, .bash {
  display: inline-block;
}

.meta {
  user-select: none;
}

.meta + .bash::first-letter {
  user-select: none;
  background-color: #ff0000;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><span class="meta">$</span>
<span class="bash"> ls</span></code>```

Title: Disable selectability for a space

Body:
First, the ::first-letter selector works only for block container boxes (won't work for inline elements).

Second, it seems it can't select a space. If you set the spans to inline-blocks, still the first letter that gets colored red is "l" and not a space.

.meta, .bash {
  display: inline-block;
}

.meta {
  user-select: none;
}

.meta + .bash::first-letter {
  user-select: none;
  background-color: #ff0000;
}

<span class="meta">$</span>
<span class="bash"> ls</span>


问:
Transpose table
I want to transpose a file like below, where the 2nd column and onward each column header (B4, B3, E0) can take two values. I want all the values for B4 B3 ... to be in one row.  Which means B4 B3 E0 will be separate rows.

How can it be done with e.g. awk sed or python. I can do simple transpose in python but I don't understand how to solve this particular problem.

Input : 2nd and 3rd column have the same column name i.e B4, similarly 4th and 5th column have same column name i.e B3 and so on.When we transpose both the values corresponding to B4 should transpose together as a unit like 12 13 13 14 13 13 12 13 13 13 12 13.  It should be on one line.  The input file consists of over 20 columns and 2000 rows.

Input:

```<code>ID  B4    B3
 1  12  13  19  21
 2  13  14  19  21
 3  13  13  19  21
 4  12  13  19  19
 5  13  13  18  19
 6  12  13  19  21
</code>```

Desired Output:

```<code>ID 1 1 2 2 3 3 4 4 5 5 6 6
B4 12  13 13  14 13  13 12  13 13  13 12  13
B3 19  21 19  21 19  21 19  19 18  19 19  21
</code>```

This is what i have tried:

```<code>python -c "import sys; print('\n'.join(' '.join(c) for c in zip(*(l.split() for l in sys.stdin.readlines() if l.strip()))))" < input file>output file
</code>```

Also tried an awk code but with no luck.

答:
This python code solves your issue</p>

```<code>import sys

header = sys.stdin.readline().strip().split()
transposed = [[item] for item in header]

for line in sys.stdin.readlines():
    items = line.strip().split()
    transposed[0].append(items[0])
    for i in range(1, len(transposed)):
        transposed[i].extend(items[2*i - 1: 2*i + 1])

for line in transposed:
    print(" ".join(line))
</code>```

Title: Transpose table

Body:
I want to transpose a file like below, where the 2nd column and onward each column header (B4, B3, E0) can take two values. I want all the values for B4 B3 ... to be in one row.  Which means B4 B3 E0 will be separate rows.

How can it be done with e.g. awk sed or python. I can do simple transpose in python but I don't understand how to solve this particular problem.

Input : 2nd and 3rd column have the same column name i.e B4, similarly 4th and 5th column have same column name i.e B3 and so on.When we transpose both the values corresponding to B4 should transpose together as a unit like 12 13 13 14 13 13 12 13 13 13 12 13.  It should be on one line.  The input file consists of over 20 columns and 2000 rows.

Input:

ID  B4    B3
 1  12  13  19  21
 2  13  14  19  21
 3  13  13  19  21
 4  12  13  19  19
 5  13  13  18  19
 6  12  13  19  21

Desired Output:

ID 1 1 2 2 3 3 4 4 5 5 6 6
B4 12  13 13  14 13  13 12  13 13  13 12  13
B3 19  21 19  21 19  21 19  19 18  19 19  21

This is what i have tried:

python -c "import sys; print('\n'.join(' '.join(c) for c in zip(*(l.split() for l in sys.stdin.readlines() if l.strip()))))" < input file>output file

Also tried an awk code but with no luck.

Body:
This python code solves your issue

import sys

header = sys.stdin.readline().strip().split()
transposed = [[item] for item in header]

for line in sys.stdin.readlines():
    items = line.strip().split()
    transposed[0].append(items[0])
    for i in range(1, len(transposed)):
        transposed[i].extend(items[2*i - 1: 2*i + 1])

for line in transposed:
    print(" ".join(line))


问:
PushViewController to VC embedded in Navigation Controller
I am trying to remove all the segues from my project and start using PushViewController.

In one VC I segue to a second VC using this

```<code>if let detailVC = storyboard?.instantiateViewController(withIdentifier: "CardDetailVC") as? CardDetailViewController {
        detailVC.cardID = card.key
        navigationController?.pushViewController(detailVC, animated: true)
    }
</code>```

That VC is embedded in a Nav Cont and the 2nd VC is also.

On an entirely different part I have a VC not embedded in a Nav C, but the VC that I am going into does.

so I tried this

```<code>if let addVC = self.storyboard?.instantiateViewController(withIdentifier: "AddCardVC") as? AddCardViewController {
  self.navigationController?.pushViewController(addVC, animated: true)
}
</code>```

When I tap the button to call this nothing happens. I do not get a crash which is great, but I also do not go to the VC that I want to.

I have gone to the Storyboard -> VC -> Identity Inspector -> StoryBoard ID and set it to be AddCardVC

Any idea as to what I am missing?

答:
From the answers in the comments I decided to embed the first VC in a Navigation Controller. Since I did not want the top bar I added this to the ViewDidLoad

```<code>self.navigationController?.isNavigationBarHidden = true
</code>```

and for safe measure I added the opposite to the other VC's =

Body:
I am trying to remove all the segues from my project and start using PushViewController.

In one VC I segue to a second VC using this

if let detailVC = storyboard?.instantiateViewController(withIdentifier: "CardDetailVC") as? CardDetailViewController {
        detailVC.cardID = card.key
        navigationController?.pushViewController(detailVC, animated: true)
    }

That VC is embedded in a Nav Cont and the 2nd VC is also.

On an entirely different part I have a VC not embedded in a Nav C, but the VC that I am going into does.

so I tried this

if let addVC = self.storyboard?.instantiateViewController(withIdentifier: "AddCardVC") as? AddCardViewController {
  self.navigationController?.pushViewController(addVC, animated: true)
}

When I tap the button to call this nothing happens. I do not get a crash which is great, but I also do not go to the VC that I want to.

I have gone to the Storyboard -> VC -> Identity Inspector -> StoryBoard ID and set it to be AddCardVC

Any idea as to what I am missing?

Body:
From the answers in the comments I decided to embed the first VC in a Navigation Controller. Since I did not want the top bar I added this to the ViewDidLoad

self.navigationController?.isNavigationBarHidden = true

and for safe measure I added the opposite to the other VC's =


问:
Is it possible to build the following layout with flex without nesting?

Example:

Is it possible to built this kind of layout with flex without nesting? Purely, with a structure like this:

```<code><div class="long">
</div>

<div class="short">
</div>

<div class="short">
</div>

<div class="short">
</div>

<div class="short">
</div>
</code>```

答:
Sure. See below

* {
  box-sizing: border-box;
}

.container {
  display: flex;
  flex-flow: column;
  flex-wrap: wrap;
  max-height: 200px;
  max-width: 320px;
}

.long {
  background-color: red;
  border: thin solid darkgray;
  width: 100px;
  height: 200px;
}

.short {
  background-color: blue;
  border: thin solid darkgray;
  width: 100px;
  height: 100px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="container">
  <div class="long"></div>
  <div class="short"></div>
  <div class="short"></div>
  <div class="short"></div>
  <div class="short"></div>
</div></code>```

*

Body:
Sure. See below

* {
  box-sizing: border-box;
}

.container {
  display: flex;
  flex-flow: column;
  flex-wrap: wrap;
  max-height: 200px;
  max-width: 320px;
}

.long {
  background-color: red;
  border: thin solid darkgray;
  width: 100px;
  height: 200px;
}

.short {
  background-color: blue;
  border: thin solid darkgray;
  width: 100px;
  height: 100px;
}

<div class="container">
  <div class="long"></div>
  <div class="short"></div>
  <div class="short"></div>
  <div class="short"></div>
  <div class="short"></div>
</div>

*


问:
Android application crashes while launch camera activity (Visual studio Xamarin)
Hello to all programmers.

While creating my first android app in Visual studio Xamarin, I stuck with one more problem (there was lot of them =) ). I try to make permissions check for Android Marshmallow+. And while I try to launch Camera Activity (MediaStore.ActionImageCapture), my app crashes. Here the code

```<code>const int REQUEST_CAMERA = 1;
const int REQUEST_EXTERNAL_STORAGE = 2;
const string cameraPermission = Android.Manifest.Permission.Camera;
const string storageWritePermission = Android.Manifest.Permission.WriteExternalStorage;
const string storageReadPermission = Android.Manifest.Permission.ReadExternalStorage;
public static class App
{
  public static File _file;
  public static File _dir;
  public static Bitmap bitmap;
  public static string fileName;
}
private bool IsThereAnAppToTakePicture()
{
  Intent intent = new Intent(MediaStore.ActionImageCapture);
  IList<ResolveInfo> availableActivities =
  PackageManager.QueryIntentActivities(intent, PackageInfoFlags.MatchDefaultOnly);
  return availableActivities != null && availableActivities.Count > 0;
}
private void CreateDirectoryForPictures()
{
  App._dir = new File(Enviroment.GetExternalStoragePublicDirectory(Enviroment.DirectoryPictures), "Kuponguru");
  if (!App._dir.Exists())
  {
    App._dir.Mkdirs();
  }
}
private void StartCameraActivity()
{
  Intent intent = new Intent(MediaStore.ActionImageCapture);
  App.fileName = String.Format("picture_{0}.jpg", Guid.NewGuid());
  App._file = new File(App._dir, App.fileName);
  intent.PutExtra(MediaStore.ExtraOutput, Uri.FromFile(App._file));
  StartActivityForResult(intent, REQUEST_CAMERA);
}
protected override void OnCreate(Bundle savedInstanceState)
{
  base.OnCreate(savedInstanceState);
  SetContentView(Resource.Layout.TakePicture);
  pictureImageButton = FindViewById<ImageView>(Resource.Id.pictureButton);
  pictureImageButton.Click += TakePicture;
  if (Build.VERSION.SdkInt >= BuildVersionCodes.M)
  {
    if (CheckSelfPermission(storageReadPermission) == (int)Permission.Granted &&
    CheckSelfPermission(storageWritePermission) == (int)Permission.Granted)
    {
      if (IsThereAnAppToTakePicture())
      {
        CreateDirectoryForPictures();
      }
    }
    else
    {
      RequestPermissions(new string[] { storageWritePermission, storageReadPermission }, REQUEST_EXTERNAL_STORAGE);
    }
  }
}
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
{
  switch (requestCode)
  {
    case REQUEST_EXTERNAL_STORAGE:
    {
      if (grantResults[0] == Permission.Granted)
      {
        if (IsThereAnAppToTakePicture())
        {
          CreateDirectoryForPictures();
        }
      }
    }
    break;
    case REQUEST_CAMERA:
    {
      if (grantResults[0] == Permission.Granted)
      {
        StartCameraActivity();
      }
    }
  }
}
private void TakePicture(object sender, EventArgs e)
{
  if (Build.VERSION.SdkInt >= BuildVersionCodes.M) {
    if (CheckSelfPermission(cameraPermission) == (int)Permission.Granted &&
                    CheckSelfPermission(storageWritePermission) == (int)Permission.Granted)
    {
      StartCameraActivity();
    }
    else
    {
      RequestPermissions(new string[] { cameraPermission, storageWritePermission }, REQUEST_CAMERA);
    }
  }
  else
  {
    StartCameraActivity();
  }
}
</code>```

If I delete string intent.PutExtra(MediaStore.ExtraOutput, Uri.FromFile(App._file)); in StartCameraActivity, then camera works, but with this command app crashed.

I'll be appreciated for all suggestions.

--UPDATED--

I check Uri.FromFile(App._file) in intent.PutExtra(MediaStore.ExtraOutput, Uri.FromFile(App._file)); File is not exists So, problem is - app can't create file (but can create directory)

--UPDATED--

I check application on Marshmallow emulator. All works fine. Also I check on emulated device - file, where camera should save photo, is not exists when I send it to Camera activity in intent.PutExtra(MediaStore.ExtraOutput, Uri.FromFile(App._file)); Well problem is still here.

--UPDATED--

Added try catch for Camera activity start and get exception file:///storage/emulated/0/Pictures/MyApp/picture_123.jpg exposed beyond app through ClipData.Item.getUri

答:
At least I found whats wrong. It's god damned version issue. In Android N+ there are no more file:// URIs, only content:// URIs instead. That's why Camera Activity can't work with Uri.FromFile(App._file).
For this solution I have to thank request Answer of question by questioner SuperThomasLab and users Pkosta, hqzxzwb and Java coder

The solution, changed for VS Xamarin, I used:

**Solution **

```<code>protected override void OnCreate(Bundle savedInstanceState){
  StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
  StrictMode.SetVmPolicy(builder.Build());
  base.OnCreate(savedInstanceState);
  ...
}
</code>```

Other code is without changes.

I tried it on Android N 7.1.1 on real device and it's works.

Thanks to all, who take attention to my problem.

Body:
Hello to all programmers.

While creating my first android app in Visual studio Xamarin, I stuck with one more problem (there was lot of them =) ). I try to make permissions check for Android Marshmallow+. And while I try to launch Camera Activity (MediaStore.ActionImageCapture), my app crashes. Here the code

const int REQUEST_CAMERA = 1;
const int REQUEST_EXTERNAL_STORAGE = 2;
const string cameraPermission = Android.Manifest.Permission.Camera;
const string storageWritePermission = Android.Manifest.Permission.WriteExternalStorage;
const string storageReadPermission = Android.Manifest.Permission.ReadExternalStorage;
public static class App
{
  public static File _file;
  public static File _dir;
  public static Bitmap bitmap;
  public static string fileName;
}
private bool IsThereAnAppToTakePicture()
{
  Intent intent = new Intent(MediaStore.ActionImageCapture);
  IList<ResolveInfo> availableActivities =
  PackageManager.QueryIntentActivities(intent, PackageInfoFlags.MatchDefaultOnly);
  return availableActivities != null && availableActivities.Count > 0;
}
private void CreateDirectoryForPictures()
{
  App._dir = new File(Enviroment.GetExternalStoragePublicDirectory(Enviroment.DirectoryPictures), "Kuponguru");
  if (!App._dir.Exists())
  {
    App._dir.Mkdirs();
  }
}
private void StartCameraActivity()
{
  Intent intent = new Intent(MediaStore.ActionImageCapture);
  App.fileName = String.Format("picture_{0}.jpg", Guid.NewGuid());
  App._file = new File(App._dir, App.fileName);
  intent.PutExtra(MediaStore.ExtraOutput, Uri.FromFile(App._file));
  StartActivityForResult(intent, REQUEST_CAMERA);
}
protected override void OnCreate(Bundle savedInstanceState)
{
  base.OnCreate(savedInstanceState);
  SetContentView(Resource.Layout.TakePicture);
  pictureImageButton = FindViewById<ImageView>(Resource.Id.pictureButton);
  pictureImageButton.Click += TakePicture;
  if (Build.VERSION.SdkInt >= BuildVersionCodes.M)
  {
    if (CheckSelfPermission(storageReadPermission) == (int)Permission.Granted &&
    CheckSelfPermission(storageWritePermission) == (int)Permission.Granted)
    {
      if (IsThereAnAppToTakePicture())
      {
        CreateDirectoryForPictures();
      }
    }
    else
    {
      RequestPermissions(new string[] { storageWritePermission, storageReadPermission }, REQUEST_EXTERNAL_STORAGE);
    }
  }
}
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
{
  switch (requestCode)
  {
    case REQUEST_EXTERNAL_STORAGE:
    {
      if (grantResults[0] == Permission.Granted)
      {
        if (IsThereAnAppToTakePicture())
        {
          CreateDirectoryForPictures();
        }
      }
    }
    break;
    case REQUEST_CAMERA:
    {
      if (grantResults[0] == Permission.Granted)
      {
        StartCameraActivity();
      }
    }
  }
}
private void TakePicture(object sender, EventArgs e)
{
  if (Build.VERSION.SdkInt >= BuildVersionCodes.M) {
    if (CheckSelfPermission(cameraPermission) == (int)Permission.Granted &&
                    CheckSelfPermission(storageWritePermission) == (int)Permission.Granted)
    {
      StartCameraActivity();
    }
    else
    {
      RequestPermissions(new string[] { cameraPermission, storageWritePermission }, REQUEST_CAMERA);
    }
  }
  else
  {
    StartCameraActivity();
  }
}

If I delete string intent.PutExtra(MediaStore.ExtraOutput, Uri.FromFile(App._file)); in StartCameraActivity, then camera works, but with this command app crashed.

I'll be appreciated for all suggestions.

--UPDATED--

I check Uri.FromFile(App._file) in intent.PutExtra(MediaStore.ExtraOutput, Uri.FromFile(App._file)); File is not exists So, problem is - app can't create file (but can create directory)

--UPDATED--

I check application on Marshmallow emulator. All works fine. Also I check on emulated device - file, where camera should save photo, is not exists when I send it to Camera activity in intent.PutExtra(MediaStore.ExtraOutput, Uri.FromFile(App._file)); Well problem is still here.

--UPDATED--

Added try catch for Camera activity start and get exception file:///storage/emulated/0/Pictures/MyApp/picture_123.jpg exposed beyond app through ClipData.Item.getUri

Body:
At least I found whats wrong. It's god damned version issue. In Android N+ there are no more file:// URIs, only content:// URIs instead. That's why Camera Activity can't work with Uri.FromFile(App._file).
For this solution I have to thank request Answer of question by questioner SuperThomasLab and users Pkosta, hqzxzwb and Java coder

The solution, changed for VS Xamarin, I used:

**Solution **

protected override void OnCreate(Bundle savedInstanceState){
  StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
  StrictMode.SetVmPolicy(builder.Build());
  base.OnCreate(savedInstanceState);
  ...
}

Other code is without changes.

I tried it on Android N 7.1.1 on real device and it's works.

Thanks to all, who take attention to my problem.


问:
How to deactivate all the old versions of APK's in NEW Google Play Console?
We are having an Android App, which is currently supporting API 16 and above. The very old version ( before approx six releases ) was supporting API 14.

When releasing new version, we are able to deactivate the currently active version in the NEW Google play console.

But we have following issues, in NEW Google play console.

1) We can not view very old APK versions ( we are able to see the list of past three versions only )

2) We are unable to deactivate any of other older versions.

As older versions are not deactivated, the users of older Android devices ( with older versions below 16 ) can download the older versions of APK. This versions does not work properly in current conditions, so it is very important for us to deactivate older versions.

I have tried to search for the issue, but could get answers for older Google Play console.

Thanks in advance for any help ...

Regards
Sanjay.

答:
I try in my console, but i still see all older release: App release -> Manage product -> release history. Can you post your image here.

And as you know, each time when new version was released, old version will be deactivated automatically. Are you sure that older android version can get older app version because older version is not deactivated yet ? or because you can't view older app version so you think that it's not deactivated ?


问:
Android AWS s3 CognitoCachingCredentialsProvider throws NoSuchMethodError
I am trying to upload/download/list file at aws bucket.

I wrote following code in my fragment for setting up credentials it throws NoSuchMethodErrorException at line (mActivity.getApplicationContext)

```<code>CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(

               mActivity.getApplicationContext(),   // using in fragments
               "ap-XXXX-X:0XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXb4", // Identity Pool ID
               Regions.AP_XXXX_X // Region
       );

AmazonS3 s3Client = new AmazonS3Client(credentialsProvider) ;
</code>```

The following error it throws :

Caused by: java.lang.NoSuchMethodError: No direct method (Lcom/amazonaws/ClientConfiguration;Lcom/amazonaws/http/HttpClient;)V in class Lcom/amazonaws/AmazonWebServiceClient; or its super classes (declaration of 'com.amazonaws.AmazonWebServiceClient' appears in /data/app/com.hs.userportal-1/split_lib_dependencies_apk.apk:classes6.dex)

Here is my gradle file:

```<code>apply plugin: 'com.android.application'

android {

    compileSdkVersion 24
    buildToolsVersion '25.0.3'
    useLibrary 'org.apache.http.legacy'
    dexOptions {

        javaMaxHeapSize "4g"
    }
    defaultConfig {

        applicationId "XXX.XX.XXXXX"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 30
        versionName "4.5"
        multiDexEnabled true
    }
    buildTypes {

        release {

            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            applicationVariants.all { variant ->
                appendVersionName(variant, defaultConfig)
            }
        }
    }
    aaptOptions {

        cruncherEnabled = false
    }

    packagingOptions {

        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/ECLIPSE_.SF'
        exclude 'META-INF/ECLIPSE_.RSA'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/classes.jar'
        exclude '...'
    }

}
def appendVersionName(variant, defaultConfig) {

    variant.outputs.each { output ->
        if (output.zipAlign) {
            def file = output.outputFile
            def fileName = file.name.replace("app-release.apk", "HealthScion- " + defaultConfig.versionName + "v.apk")
            output.outputFile = new File(file.parent, fileName)
        }

        def file = output.packageApplication.outputFile
        def fileName = file.name.replace("app-release.apk", "HealthScion- " + defaultConfig.versionName + "v.apk")
        output.packageApplication.outputFile = new File(file.parent, fileName)
    }
}

dependencies {

    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.amazonaws:aws-android-sdk-core:2.4.4'
    compile 'com.amazonaws:aws-android-sdk-s3:2.4.4'
    compile 'com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.4.4'
    compile 'com.amazonaws:aws-android-sdk-cognito:2.4.4'
    compile 'com.amazonaws:aws-android-sdk-kms:2.4.4'
    compile 'com.amazonaws:aws-android-sdk-ddb:2.4.4'
    compile 'dev.dworks.libs:astickyheader:0.1.0'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'se.emilsjolander:StickyScrollViewItems:1.1.0'
    compile 'org.apache.commons:commons-lang3:3.4'
    compile 'com.facebook.android:facebook-android-sdk:4.15.0'
    compile files('libs/volley.jar')
    compile files('libs/android-viewbadger.jar')
    compile files('libs/itextpdf-5.5.7.jar')
    compile files('libs/xmlworker-5.5.6.jar')
    compile project(':SlidingMenuLibrary')
    compile project(':ViewPagerIndicatorlibrary')
    compile project(':swipelistview')
    compile project(':demo_cloud_tagview')
    compile project(':SegmentedControlLibrary')
    compile project(':Simpl3r')
    compile project(':MPChartLib')
    compile 'com.google.firebase:firebase-core:10.0.1'
    compile 'com.google.firebase:firebase-messaging:10.0.1'
    compile 'com.android.support:recyclerview-v7:25.3.1'
    compile 'com.applozic.communication.uiwidget:audiovideo:1.2'

}
apply plugin: 'com.google.gms.google-services'
</code>```

I also created new project and integrated aws s3 code with same CognitoCredentialsProvider, it works perfectly.

Therefore, apparently issue must reside in my gradle file.

Any help would be appreciated .

答:
I was using 3rd party library "Simpl3r"  which uploads file to my bucket. Since i inserted this library quiet some time ago, so the aws-sdk-s3 version it was using was outdated.

Solution which works for me:

open simpler gradle file.

removed line: compile fileTree(dir: 'libs', include: ['*.jar'])

added line : compile 'com.amazonaws:aws-android-sdk-core:2.4.4'

update aws sdk ver over there i.e 2.4.4 (latest at the moment)

integrated aws sdk ver 2.4.4 (similar with Simpl3r library version) in    build.gradle(app), to use this aws library function throughout my app module .

Atlast, my duplicate entry of classes.class (which builds at run time) issue gets resolved.

Tip: Try to make version of your sub-module(gradle files) similar to app gradle file.

Also, make sure that you use compile fileTree(dir:'libs', include: ['*jar']) in sub module gradle file only if , any particular jar file needs to be run with that particular module .

Body:
I am trying to upload/download/list file at aws bucket.

I wrote following code in my fragment for setting up credentials it throws NoSuchMethodErrorException at line (mActivity.getApplicationContext)

CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(

               mActivity.getApplicationContext(),   // using in fragments
               "ap-XXXX-X:0XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXb4", // Identity Pool ID
               Regions.AP_XXXX_X // Region
       );

AmazonS3 s3Client = new AmazonS3Client(credentialsProvider) ;

The following error it throws :

Caused by: java.lang.NoSuchMethodError: No direct method (Lcom/amazonaws/ClientConfiguration;Lcom/amazonaws/http/HttpClient;)V in class Lcom/amazonaws/AmazonWebServiceClient; or its super classes (declaration of 'com.amazonaws.AmazonWebServiceClient' appears in /data/app/com.hs.userportal-1/split_lib_dependencies_apk.apk:classes6.dex)

Here is my gradle file:

apply plugin: 'com.android.application'

android {

    compileSdkVersion 24
    buildToolsVersion '25.0.3'
    useLibrary 'org.apache.http.legacy'
    dexOptions {

        javaMaxHeapSize "4g"
    }
    defaultConfig {

        applicationId "XXX.XX.XXXXX"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 30
        versionName "4.5"
        multiDexEnabled true
    }
    buildTypes {

        release {

            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            applicationVariants.all { variant ->
                appendVersionName(variant, defaultConfig)
            }
        }
    }
    aaptOptions {

        cruncherEnabled = false
    }

    packagingOptions {

        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/ECLIPSE_.SF'
        exclude 'META-INF/ECLIPSE_.RSA'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/classes.jar'
        exclude '...'
    }

}
def appendVersionName(variant, defaultConfig) {

    variant.outputs.each { output ->
        if (output.zipAlign) {
            def file = output.outputFile
            def fileName = file.name.replace("app-release.apk", "HealthScion- " + defaultConfig.versionName + "v.apk")
            output.outputFile = new File(file.parent, fileName)
        }

        def file = output.packageApplication.outputFile
        def fileName = file.name.replace("app-release.apk", "HealthScion- " + defaultConfig.versionName + "v.apk")
        output.packageApplication.outputFile = new File(file.parent, fileName)
    }
}

dependencies {

    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.amazonaws:aws-android-sdk-core:2.4.4'
    compile 'com.amazonaws:aws-android-sdk-s3:2.4.4'
    compile 'com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.4.4'
    compile 'com.amazonaws:aws-android-sdk-cognito:2.4.4'
    compile 'com.amazonaws:aws-android-sdk-kms:2.4.4'
    compile 'com.amazonaws:aws-android-sdk-ddb:2.4.4'
    compile 'dev.dworks.libs:astickyheader:0.1.0'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'se.emilsjolander:StickyScrollViewItems:1.1.0'
    compile 'org.apache.commons:commons-lang3:3.4'
    compile 'com.facebook.android:facebook-android-sdk:4.15.0'
    compile files('libs/volley.jar')
    compile files('libs/android-viewbadger.jar')
    compile files('libs/itextpdf-5.5.7.jar')
    compile files('libs/xmlworker-5.5.6.jar')
    compile project(':SlidingMenuLibrary')
    compile project(':ViewPagerIndicatorlibrary')
    compile project(':swipelistview')
    compile project(':demo_cloud_tagview')
    compile project(':SegmentedControlLibrary')
    compile project(':Simpl3r')
    compile project(':MPChartLib')
    compile 'com.google.firebase:firebase-core:10.0.1'
    compile 'com.google.firebase:firebase-messaging:10.0.1'
    compile 'com.android.support:recyclerview-v7:25.3.1'
    compile 'com.applozic.communication.uiwidget:audiovideo:1.2'

}
apply plugin: 'com.google.gms.google-services'

I also created new project and integrated aws s3 code with same CognitoCredentialsProvider, it works perfectly.

Therefore, apparently issue must reside in my gradle file.

Any help would be appreciated .


问:
Finding reachable vertices of a vertice in a graph
I am having problem in my code to calculate the reachable vertices in a graph.

I have the following code for the graph

```<code>class Vertices():
    number = 0
    def __init__(self):
        Vertices.number += 1
        self.number = Vertices.number
        self.Reachable= []
</code>```

I create the graph in the following way

```<code>a = Vertices()
a.Reachable = [1,2]
b = Vertices()
b.Reachable = [3]
c = Vertices()
c.Reachable= [3]
List = []
List.append(a)
List.append(b)
List.append(c)
</code>```

Thus vertice 1 that is a has an edge to itself and b . Similarly for b and for c.

We can move around the graph using List ie for vertex a it is reachable to List[trans-1] where trans refers to the Reachable list of a (List[0] and List[1])

Now in this graph I have to calculate the reachability for each vertice ie for each vertice calculate the vertices that it can reach.For eg a can reach a,b and c

I have read that I can use sets to do depth first search in all the list. Can you provide me a solution as to how to proceed.

Can anyone tell me how to use sets as I think that it is quite ideal for this problem seeing that it has union and difference functions associated with it....
PS : This is'nt a school based assignment.....

答:
Well first off it's Vertex, not Vertice. Secondly, you have (approximately) implemented an   adjacency list as the data structure for your graph; it would be more standard to use an adjacency matrix.

Do you know what depth-first search is? Roughly, you start at a vertex and pick a neighbour, then pick a neighbour of that, and so on until you run out of neighbours to pick. Then you backtrack and pick the next neighbour, and so on. It is elegantly implemented recursively (have you come across that before?), because the problem can easily be separated into smaller pieces: to search a graph depth-first you simply start from any vertex and then depth-first search from all its neighbours in turn.

Concretely, you need to break the problem into smaller problems: suppose you can find the nodes reachable from b and c. What can you reach from a? Well, b, everything reachable from b, c, and everything reachable from c.

Body:
I am having problem in my code to calculate the reachable vertices in a graph.

I have the following code for the graph

class Vertices():
    number = 0
    def __init__(self):
        Vertices.number += 1
        self.number = Vertices.number
        self.Reachable= []

I create the graph in the following way

a = Vertices()
a.Reachable = [1,2]
b = Vertices()
b.Reachable = [3]
c = Vertices()
c.Reachable= [3]
List = []
List.append(a)
List.append(b)
List.append(c)

Thus vertice 1 that is a has an edge to itself and b . Similarly for b and for c.

We can move around the graph using List ie for vertex a it is reachable to List[trans-1] where trans refers to the Reachable list of a (List[0] and List[1])

Now in this graph I have to calculate the reachability for each vertice ie for each vertice calculate the vertices that it can reach.For eg a can reach a,b and c

I have read that I can use sets to do depth first search in all the list. Can you provide me a solution as to how to proceed.

Can anyone tell me how to use sets as I think that it is quite ideal for this problem seeing that it has union and difference functions associated with it....
PS : This is'nt a school based assignment.....


问:
getting warning Invalid argument for foreach in codeigniter
In foreach loop i am getting warning Invalid argument supplied for foreach() below is my loop code and modal code please let me know where i done wrong

Controller

```<code>$concond = array("con_id"=>1,"con_status"=>1);
$this->data['contact']=$this->Frontend_model->get_contact($concond);
$this->load->view('frontend/clienthome',$this->data);
</code>```

foreach Loop

```<code>if($contact)
{
  foreach($contact as $foot)
  {
     $footadr1 = $foot->con_addr_line_1;
     $footadr2 = $foot->con_addr_line_2;
     $footcity = $foot->con_city;
     $footstate = $foot->con_state;
     $footcountry = $foot->con_country;
     $footpin = $foot->con_pincode;
     $footp1 = $foot->con_phone_1;
     $footp2 = $foot->con_phone_2;
     $footp3 = $foot->con_phone_3;
     $footp4 = $foot->con_phone_4;
     $footemail = $foot->con_email_id;
  }
}
</code>```

modal

```<code>function get_contact($concond)
{
  $this->db->select('*');
  $this->db->from('is_addres_contact');
  $this->db->where($concond);
  $query = $this->db->get();
  return $query->result();
}
</code>```

答:
Can you just try this,

In model,

```<code>function get_contact($concond)
{
  $this->db->select('*');
  $this->db->from('is_addres_contact');
  $this->db->where($concond);
  $query = $this->db->get();
  return $query->result_array();
}
</code>```

In View

```<code>if($contact)
{
  foreach($contact as $foot)
  {
     $footadr1 = $foot['con_addr_line_1'];
     $footadr2 = $foot['con_addr_line_2'];
     $footcity =$foot['con_city'];
     $footstate = $foot['con_state'];
     $footcountry = $foot['con_country'];
     $footpin = $foot['con_pincode'];
     $footp1 = $foot['con_phone_1'];
     $footp2 = $foot['con_phone_2'];
     $footp3 = $foot['con_phone_3'];
     $footp4 = $foot['con_phone_4'];
     $footemail = $foot['con_email_id'];
  }
}
</code>```

Body:
In foreach loop i am getting warning Invalid argument supplied for foreach() below is my loop code and modal code please let me know where i done wrong

Controller

$concond = array("con_id"=>1,"con_status"=>1);
$this->data['contact']=$this->Frontend_model->get_contact($concond);
$this->load->view('frontend/clienthome',$this->data);

foreach Loop

if($contact)
{
  foreach($contact as $foot)
  {
     $footadr1 = $foot->con_addr_line_1;
     $footadr2 = $foot->con_addr_line_2;
     $footcity = $foot->con_city;
     $footstate = $foot->con_state;
     $footcountry = $foot->con_country;
     $footpin = $foot->con_pincode;
     $footp1 = $foot->con_phone_1;
     $footp2 = $foot->con_phone_2;
     $footp3 = $foot->con_phone_3;
     $footp4 = $foot->con_phone_4;
     $footemail = $foot->con_email_id;
  }
}

modal

function get_contact($concond)
{
  $this->db->select('*');
  $this->db->from('is_addres_contact');
  $this->db->where($concond);
  $query = $this->db->get();
  return $query->result();
}

Body:
Can you just try this,

In model,

function get_contact($concond)
{
  $this->db->select('*');
  $this->db->from('is_addres_contact');
  $this->db->where($concond);
  $query = $this->db->get();
  return $query->result_array();
}

In View

if($contact)
{
  foreach($contact as $foot)
  {
     $footadr1 = $foot['con_addr_line_1'];
     $footadr2 = $foot['con_addr_line_2'];
     $footcity =$foot['con_city'];
     $footstate = $foot['con_state'];
     $footcountry = $foot['con_country'];
     $footpin = $foot['con_pincode'];
     $footp1 = $foot['con_phone_1'];
     $footp2 = $foot['con_phone_2'];
     $footp3 = $foot['con_phone_3'];
     $footp4 = $foot['con_phone_4'];
     $footemail = $foot['con_email_id'];
  }
}