问:
How to retrieve high quality compass orientation (as in Google Maps)?
All of the guides to getting compass orientation in Android I've found have a bug: when you hold the phone in portrait mode and "look" above the horizon, the compass arrow turns 180 degrees from the correct direction.

Google Maps orientation indicator doesn't have this problem.

Another nice thing that Google Maps have is that they somehow estimate compass accuracy. Any idea how they do this?

答:
Compasses will give you what you want, but it's so noisy. It is noisy for 2 reasons, one of reason is, it is picking up, real noise, real signal. So, we live in an environment that's magnetically very noisy. So, this compasses, picking up everything that's magnetic. The other reason is that, it's not integrated, so it doesn't have benefit of dropping the frequency component. So, try to combine your compass with gyroscope data. This video will help you so much for using these sensors. </p>

<p>Some more details, you can combine accelerometers also. So in summary, Gyroscopes provide orientation, Accelerometers provide a correction due to gravity, and compasses provide a correction due to magnetic North. </p>

Body:
Compasses will give you what you want, but it's so noisy. It is noisy for 2 reasons, one of reason is, it is picking up, real noise, real signal. So, we live in an environment that's magnetically very noisy. So, this compasses, picking up everything that's magnetic. The other reason is that, it's not integrated, so it doesn't have benefit of dropping the frequency component. So, try to combine your compass with gyroscope data. This video will help you so much for using these sensors.

Some more details, you can combine accelerometers also. So in summary, Gyroscopes provide orientation, Accelerometers provide a correction due to gravity, and compasses provide a correction due to magnetic North.


来源: stackexchange

问:
unable to register node to hub in selenium
My hub is working successfully and running

```<code>    java -jar selenium-server-standalone-2.53.0.jar -role hub -port 5555
</code>```

my node command

```<code>  java -jar selenium-server-standalone-2.53.0.jar -role webdriver –hub http://localhost:5555/gridhost/register -port 7621
</code>```

but unable to  register my  node forbidden + for + proxy the hub is down or not responding

答:
The registration URL should not be http://localhost:5555/gridhost/register.

Please change it to http://localhost:5555/grid/register and try again.

ContentLicense: CC BY-SA 3.0

Body:
My hub is working successfully and running

    java -jar selenium-server-standalone-2.53.0.jar -role hub -port 5555

my node command

  java -jar selenium-server-standalone-2.53.0.jar -role webdriver –hub http://localhost:5555/gridhost/register -port 7621

but unable to  register my  node forbidden + for + proxy the hub is down or not responding


问:
Error: Only parameterless constructors and initializers are supported in LINQ to Entities
Below is my code. I am trying to get the company list and also employee list under each company. But below code is throwing error

Only parameterless constructors and initializers are supported in LINQ to Entities.

Please help.

```<code>public class Company {
    public int CompID { get; set; }
    public string CompanyName { get; set; }
    public List<Employees> EmplList { get; set; }
}

public class Employees {
    public int EMPID { get; set; }
    public string EMPNAME { get; set; }
}

var empllist = (from c in Db.Company select new Company {
    CompID = c.ID,
    CompanyName = c.Name,
    EmplList = new List<Employees> (
        from e in Db.Employee
        where c.ID == e.ID
        select new Employees {
            EMPID = e.ID,
            EMPNAME = e.Name
        })
    }).ToList();
</code>```

答:
Try Code</p>

```<code>var empllist = (from c in Db.Company
                        select new Company
                        {
                            CompID = c.ID,
                            CompanyName = c.Name,
                            EmplList =  Db.Employee.where(k=>k.EMPID =c.CompID ).select(m=> new Employees{EMPID = m.EMPID,EMPNAME = m.EMPNAME }).ToList()
                        }).ToList();
</code>```

Body:
Below is my code. I am trying to get the company list and also employee list under each company. But below code is throwing error

Only parameterless constructors and initializers are supported in LINQ to Entities.

Please help.

public class Company {
    public int CompID { get; set; }
    public string CompanyName { get; set; }
    public List<Employees> EmplList { get; set; }
}

public class Employees {
    public int EMPID { get; set; }
    public string EMPNAME { get; set; }
}

var empllist = (from c in Db.Company select new Company {
    CompID = c.ID,
    CompanyName = c.Name,
    EmplList = new List<Employees> (
        from e in Db.Employee
        where c.ID == e.ID
        select new Employees {
            EMPID = e.ID,
            EMPNAME = e.Name
        })
    }).ToList();

Body:
Try Code

var empllist = (from c in Db.Company
                        select new Company
                        {
                            CompID = c.ID,
                            CompanyName = c.Name,
                            EmplList =  Db.Employee.where(k=>k.EMPID =c.CompID ).select(m=> new Employees{EMPID = m.EMPID,EMPNAME = m.EMPNAME }).ToList()
                        }).ToList();


问:
Flex: Inline Component is not defined?
I opened up FB3 today, without making any changes, I press F11 and now I am getting this error that I never have gotten before:

ReferenceError: Error #1065: Variable CaratPicker2_inlineComponent1 is not defined.

I find it strange I am getting this error everytime now, when I never got it before and I didn't make any changes before I started getting it.

Anyways it is coming from line 78 which is <mx:Component> the start of an inline item renderer.

So any ideas how or why this error is being thrown? I have never seen an error like this before and the message isn't very clear to me as to what the issue is.

Thanks!!!

答:
I got this inline component not defined error, too.
But my problem is there are two mxml documents with the same name in the project(not in the same package)

so the solution is change the file name and make sure all mxml files have different name.

ContentLicense: CC BY-SA 2.5

Title: Flex: Inline Component is not defined?


问:
rows insert with checkboxes
I have table showing below:

```<code><form method="post" action="insertassign_process.php">
             <table class="table table-bordered table-responsive">

        <?php
        echo"<thead>
                <tr><th>Tenant ID</th>
                    <th>Tenant ZIP</th>
                    <th>Process server ID</th>
                    <th>Process Server Name</th>
                    <th>Phone Nmuber</th>
                    <th>Select Process Server</th>
                    <th>Assign Proces Server</th>
                    </tr>
              </thead>";
        include("connection.php");
        extract($_REQUEST);
            $SQLSELECT = "SELECT * FROM users where zip_codes='$zip'";
            $result_set =  mysql_query($SQLSELECT) or die(mysql_error());
            while($row = mysql_fetch_array($result_set))
            {
            ?>

                <tr>
                    <td><input type="text" readonly name="t_id[]" value="<?php echo $t_id; ?>"/></td>
                    <td><input type="text" readonly name="zip[]" value="<?php echo $zip; ?>"/></td>
                    <td><input type="text" readonly name="pr_id[]" value="<?php echo $row['id']; ?> "></td>
                    <td><input type="text" readonly name="fullname[]" value="<?php echo $row['first_name'].' '.$row['last_name']; ?>"</td>
                    <td><?php echo $row['phone_no']; ?></td>
                    <td><input type="checkbox" name="name[]" select="selected" value="<?php echo $row["t_id"]; ?>" /></td>
                    <td><input type="radio" name="assign_process" value="1"  /></td>
                </tr>
            <?php
            }
        ?>

    </table><button type="submit" class="btn btn-primary button-loading" name="submit" data-loading-text="Loading...">Submit</button></form>
</code>```

Now when I checked any check box (may be multi select) then selected data of that rows will be inserted another table. My query for inserting is:

```<code>        <?php
        session_start();
         include("connection.php");
        extract($_SESSION);
        extract($_POST);
        if(isset($_POST["submit"])==true)
        {
        $counter = count($_POST["name"]); /* COUNT THE PASSED ON NAME */

        for($x=0; $x<=$counter; $x++){

        if(!empty($_POST["name"][$x])){
       $CUSTOMER_NAME = mysql_real_escape_string($_POST["t_id"][$x]);
      $PI_ADDRESS = mysql_real_escape_string($_POST["pr_id"][$x]);

       $qry="INSERT INTO select_process (id,tenant_select_id,process_select_id) VALUES ('','$CUSTOMER_NAME','$PI_ADDRESS')";
      mysql_query($qry);

      } /* END OF CHECKING THE CHECKBOX IF SELECTED */

      } /* END OF FOR LOOP */
      }
      else{

       echo"error";
       }
      ?>
</code>```

But when I select multiple rows or any then it inserting only first row data.

答:
You are trying to insert empty value into id, I think your id field is primary key, so it can not be duplicate, I will suggest make your id key primary auto-increment, and write your code like this - </p>

```<code>    <?php
    session_start();
     include("connection.php");
    extract($_SESSION);
    extract($_POST);
    if(isset($_POST["submit"])==true)
    {
    $counter = count($_POST["name"]); /* COUNT THE PASSED ON NAME */

    for($x=0; $x<=$counter; $x++){

    if(!empty($_POST["name"][$x])){
   $CUSTOMER_NAME = mysql_real_escape_string($_POST["t_id"][$x]);
  $PI_ADDRESS = mysql_real_escape_string($_POST["pr_id"][$x]);

       $qry="INSERT INTO select_process (tenant_select_id,process_select_id) VALUES ('$CUSTOMER_NAME','$PI_ADDRESS')";

  mysql_query($qry);

  } /* END OF CHECKING THE CHECKBOX IF SELECTED */

  } /* END OF FOR LOOP */
  }
  else{

   echo"error";
   }
  ?>
</code>```

Title: rows insert with checkboxes

Body:
I have table showing below:

<form method="post" action="insertassign_process.php">

        <?php
        echo"

Tenant ID
                    Tenant ZIP
                    Process server ID
                    Process Server Name
                    Phone Nmuber
                    Select Process Server
                    Assign Proces Server

";
        include("connection.php");
        extract($_REQUEST);
            $SQLSELECT = "SELECT * FROM users where zip_codes='$zip'";
            $result_set =  mysql_query($SQLSELECT) or die(mysql_error());
            while($row = mysql_fetch_array($result_set))
            {
            ?>

                    <input type="text" readonly name="t_id[]" value="<?php echo $t_id; ?>"/>
                    <input type="text" readonly name="zip[]" value="<?php echo $zip; ?>"/>
                    <input type="text" readonly name="pr_id[]" value="<?php echo $row['id']; ?> ">
                    <input type="text" readonly name="fullname[]" value="<?php echo $row['first_name'].' '.$row['last_name']; ?>"
                    <?php echo $row['phone_no']; ?>
                    <input type="checkbox" name="name[]" select="selected" value="<?php echo $row["t_id"]; ?>" />
                    <input type="radio" name="assign_process" value="1"  />

            <?php
            }
        ?>

<button type="submit" class="btn btn-primary button-loading" name="submit" data-loading-text="Loading...">Submit</button></form>

Now when I checked any check box (may be multi select) then selected data of that rows will be inserted another table. My query for inserting is:

        <?php
        session_start();
         include("connection.php");
        extract($_SESSION);
        extract($_POST);
        if(isset($_POST["submit"])==true)
        {
        $counter = count($_POST["name"]); /* COUNT THE PASSED ON NAME */

        for($x=0; $x<=$counter; $x++){

        if(!empty($_POST["name"][$x])){
       $CUSTOMER_NAME = mysql_real_escape_string($_POST["t_id"][$x]);
      $PI_ADDRESS = mysql_real_escape_string($_POST["pr_id"][$x]);

       $qry="INSERT INTO select_process (id,tenant_select_id,process_select_id) VALUES ('','$CUSTOMER_NAME','$PI_ADDRESS')";
      mysql_query($qry);

      } /* END OF CHECKING THE CHECKBOX IF SELECTED */

      } /* END OF FOR LOOP */
      }
      else{

       echo"error";
       }
      ?>

But when I select multiple rows or any then it inserting only first row data.

Body:
You are trying to insert empty value into id, I think your id field is primary key, so it can not be duplicate, I will suggest make your id key primary auto-increment, and write your code like this -

    <?php
    session_start();
     include("connection.php");
    extract($_SESSION);
    extract($_POST);
    if(isset($_POST["submit"])==true)
    {
    $counter = count($_POST["name"]); /* COUNT THE PASSED ON NAME */

    for($x=0; $x<=$counter; $x++){

    if(!empty($_POST["name"][$x])){
   $CUSTOMER_NAME = mysql_real_escape_string($_POST["t_id"][$x]);
  $PI_ADDRESS = mysql_real_escape_string($_POST["pr_id"][$x]);

       $qry="INSERT INTO select_process (tenant_select_id,process_select_id) VALUES ('$CUSTOMER_NAME','$PI_ADDRESS')";

  mysql_query($qry);

  } /* END OF CHECKING THE CHECKBOX IF SELECTED */

  } /* END OF FOR LOOP */
  }
  else{

   echo"error";
   }
  ?>


问:
Something like Spree for Grails?
Is there something like Spree (Rails) for Grails? I've seen the answers on this question https://stackoverflow.com/questions/6543129/grails-ecommerce-framework-platform but it is more than half a year old and didn't give an answer that is similar to Spree.</p>

答: Please check out Greenfield. http://opengreenfield.org/. Built on the Grails framework.</p>

Title: Something like Spree for Grails?


问:
Retrieving data semi annually in mysql
I wanted to retrieve my data in the database semi-annually. i have a code snippet that i used to retrieve my data quarterly which is:

```<code>select Quarter(TransactionDate) as month, count(*) as counted
from service_invoice
where YEAR(TransactionDate) = "2017"
GRoup by Quarter(TransactionDate)
</code>```

and the output of that query is:

{"quarterly":[{"Quarter":"1","counted":"2"},{"Quarter":"2","counted":"8"},{"Quarter":"3","counted":"6"},{"Quarter":"4","counted":"6"}]}

which is perfectly divided into 4 quarters. now, i want to do the same using semi-annual data. which splits the data into just two types first hale and second half with the output looking like this:

{"semi":[{"half":"1","counted":"2"},{"half":"2","counted":"8"}]}

is there any way i could do that? thanks for your time.

答: Use MONTH(TransactionDate)>6 in your GROUP BY clause.

Title: Retrieving data semi annually in mysql

Body:
I wanted to retrieve my data in the database semi-annually. i have a code snippet that i used to retrieve my data quarterly which is:

select Quarter(TransactionDate) as month, count(*) as counted
from service_invoice
where YEAR(TransactionDate) = "2017"
GRoup by Quarter(TransactionDate)

and the output of that query is:

{"quarterly":[{"Quarter":"1","counted":"2"},{"Quarter":"2","counted":"8"},{"Quarter":"3","counted":"6"},{"Quarter":"4","counted":"6"}]}

which is perfectly divided into 4 quarters. now, i want to do the same using semi-annual data. which splits the data into just two types first hale and second half with the output looking like this:

{"semi":[{"half":"1","counted":"2"},{"half":"2","counted":"8"}]}

is there any way i could do that? thanks for your time.


问:
Swarm node Status down, but node should be Ready
I am trying to run a service on a swarm composed of three Raspberry PIs.

I have one manager and two worker nodes.

The problem is that sometimes the status of the worker nodes is "Down" even if the nodes are correctly switched on and connected to the network.

I just started using Docker so I might be doing something wrong, but everything seems to be correctly set.

How would you avoid that "Down" status?

答:
It can depend on your exact version of docker, but your issue was seen in this thread

A possible workaround was to do a docker ps, which seems to helped nodes to join the swarm.


问:
Java v/s C++ - Returning final objects from a method in Java
I know that 'final' keyword specified in method definition declare that these method cannot be overridden. But what if I want a method to return a final object? How do you specify this in Java?

```<code>class A{
    final int x;
    A(){
        x = 5;
    }
    final int getx(){
        return x;
    }
}
class B extends A{
    final int x;
    B(){
        x = 5;
    }
    final int getx(){
        return x;
    }
}
class he{
    public static void main(String args[]){
        A a = new A();
        final int x = a.getx();
        System.out.println(x);
    }
}
</code>```

The above code gives a compilation error. I know the reason that I am overriding a final method. But my intention was to return a final object from getx() (i.e return x as a final integer).

This is my C++ equivalent code. It works just fine.

```<code>#include <bits/stdc++.h>
class A{
public:
    const int x;
    A():x(5){
    }
    const int getx(){
        return x;
    }
};
class B:public A{
public:
    const int x;
    B():x(5){
    }
    const int getx(){
        return x;
    }
};
int main(){
    A *a = new A();
    const int x = a->getx();
    std::cout<<x<<std::endl;
    return 0;
}
</code>```

This is because C++ has a two different keywords - "const" and "final". In C++ 'final' keyword is specified in the end of function prototype, something like this:

```<code>virtual int getx() final {}
</code>```

And so the two keyword distinguishes "what is the return type of a method" and "which methods cannot be overridden".

My question is: Is there a way of doing the same in Java?

答:
final in Java and const in C++ are very different things and trying to applying ideas from C++ about constants to Java does not work.

In Java, final for datatypes means

This object is immutable (only for native types).

The reference to this object is immutable (for user defined types). This means that the variable holding the reference to this object cannot be changed to point to a different object. It doesn't mean however that the underlying object is immutable.

Now, if I am returning a value from a function in Java, it is either a native type, which we return by value, or a user defined type, which we return by reference. In both of these cases, the final qualifier on our return value is redundant.

Rvalues returned from functions for native types are already immutable.

References returned from functions are also rvalues and are also immutable.

In C++ however, a const qualified return value (let's say a reference to const for simplicity) means that the object underlying the returned reference is immutable, and so you cannot call non const functions using that reference.

final was added in C++11 and means that this member function cannot be overridden by an inheriting class (same as Java).

The takeaway is that Java does not have const correctness that same way that C++ does and your life will be easier if you don't mix these concepts.

Body:
I know that 'final' keyword specified in method definition declare that these method cannot be overridden. But what if I want a method to return a final object? How do you specify this in Java?

class A{
    final int x;
    A(){
        x = 5;
    }
    final int getx(){
        return x;
    }
}
class B extends A{
    final int x;
    B(){
        x = 5;
    }
    final int getx(){
        return x;
    }
}
class he{
    public static void main(String args[]){
        A a = new A();
        final int x = a.getx();
        System.out.println(x);
    }
}

The above code gives a compilation error. I know the reason that I am overriding a final method. But my intention was to return a final object from getx() (i.e return x as a final integer).

This is my C++ equivalent code. It works just fine.

#include <bits/stdc++.h>
class A{
public:
    const int x;
    A():x(5){
    }
    const int getx(){
        return x;
    }
};
class B:public A{
public:
    const int x;
    B():x(5){
    }
    const int getx(){
        return x;
    }
};
int main(){
    A *a = new A();
    const int x = a->getx();
    std::cout<<x<<std::endl;
    return 0;
}

This is because C++ has a two different keywords - "const" and "final". In C++ 'final' keyword is specified in the end of function prototype, something like this:

virtual int getx() final {}

And so the two keyword distinguishes "what is the return type of a method" and "which methods cannot be overridden".

My question is: Is there a way of doing the same in Java?

ContentLicense: CC BY-SA 4.0


问:
Browser navigation issue in selenium webdriver
I have started learning selenium WebDriver recently. I was trying to automate a simple task of launching a browser and  logging into an account using Firefox browser.

The difference I noticed is when I opened the browser manually and click on login link from homepage, a small pop-up window is opened to accept login credentials. I captured the elements (i.e username, password and login) using Firebug and completed my script(using Java).

But when I ran the same script, after a click on login link from home page,browser navigated to new page(instead of pop up window on same page which opened during manual process) to accept login credentials (whose web elements(i.e username, password and login)values are completely different than one captured during manual process). Which finally leads to 'NoSuchElementException'.

Any reason why we see the difference while launching browser through selenium? And also how to handle these scenarios in live environment?

Any help will be appreciated.

Thanks,
Sri.

答:
There are many ways to handle dynamic element .One is as below:
firstly ,differenciate the data which is changing dynamically and accordingly try to find element like
1.for text box
XPath: //input[contains(@class, 'Common Data')]
2.for Button
XPath: //button[starts-with(@id, 'Common Data anything which starts with')]
It would be more clear if you provide your HTML code.
Hope this will help.</p>


问:
Query cities and their country from dbpedia
I'm trying to construct an ontology in OWL for countries and cities(If such an implementation already exist, please point it to me)

To get the data, I'm trying to use sparql with the following code:

```<code>SELECT ?c WHERE {
   ?c rdfs:label ?name .
   ?c dbpedia-owl:country <http://dbpedia.org/resource/Country> .
}
</code>```

I'm a newbie in sparql and dbpedia. The above code is not returning me all cities and the country they are situated in. I really to need to use dbpedia to achieve this.

any suggestion?

答:
Use following code on https://dbpedia.org/sparql</p>

```<code>SELECT DISTINCT ?city ?country
WHERE { ?city rdf:type dbo:City ;
        rdfs:label ?label ;
        dbo:country ?country
     }
</code>```

Body:
I'm trying to construct an ontology in OWL for countries and cities(If such an implementation already exist, please point it to me)

To get the data, I'm trying to use sparql with the following code:

SELECT ?c WHERE {
   ?c rdfs:label ?name .
   ?c dbpedia-owl:country <http://dbpedia.org/resource/Country> .
}

I'm a newbie in sparql and dbpedia. The above code is not returning me all cities and the country they are situated in. I really to need to use dbpedia to achieve this.

any suggestion?

Body:
Use following code on https://dbpedia.org/sparql

SELECT DISTINCT ?city ?country
WHERE { ?city rdf:type dbo:City ;
        rdfs:label ?label ;
        dbo:country ?country
     }


问:
Connecting local psql db with web app inside the docker container
I am new to docker and know basic things. I have postgresql installed on my local Ubuntu server and i want to connect it with the web application which is inside of the docker container. What setting should I apply to allow that?</p>

答:
You can use your server's Public IP address for this instead of localhost in your docker container.

Make sure that your firewall allows the port 5432

When you run an application on your local computer, the application can easily access all the services on your PC (i.e. localhost). When your application runs inside a Docker container it became a completely isolated environment from that machine (i.e. No access localhost and other system services unless you expose it directly) and can only use Host OS services directly served to Docker-Engine by Host OS. This is why you have to route through the Internet to access your service. Postgres in your case.


问:
how can i track users without cookies
ok... im looking to have a good round of brainstorming here...

say i was google... the adword/adsense/analytics division. i would be getting a little worried about the future, when users start to disable cookies (or at least delete them on a regular basis), use private browsing, roam on multiple devices. how could google alternatively track users without the benefits of cookies?

some ideas to get started (please elaborate on these and any others):

-track users using some other persistent local/client side storage

-use user-agent string fingerprinting

-test cache response - if user 304's an image, they were here

-track mac address

-any random/out of the box ideas?

答: Take a look at http://samy.pl/evercookie/, it's a JS API for ultra-persistent cookies, but you can take idea(s) from it's mechanism to find storage for your data.</p>

Title: how can i track users without cookies


问:
LoadApplication(new App()) throws error on IOS! Working fine on Android Xamarin forms
My application is working as desired on Android but when I try to run it on ios (Emulator/device) it throws Null reference exception.

Here is the code in App.xaml.cs

```<code>public App()
        {
            InitializeComponent();

            if (true)
            {
                if (CrossConnectivity.Current.IsConnected)
                {
                    do something
                }
                MainPage = new MyApp.MenuItems();
            }
            else
            {
                MainPage = new MyApp.MainPage();
            }

        }
</code>```

Please help as app is fully ready for android and something going wrong with ios.

答:
try with

```<code>switch(Device.RuntimePlatform)
{

     case Device.iOS:
          MainPage = new NavigationPage(new MyApp.MainPage());
          break;
     case Device.Android:
          MainPage = new MyApp.MainPage();
          break;
}
</code>```

may be it's help you

Body:
My application is working as desired on Android but when I try to run it on ios (Emulator/device) it throws Null reference exception.

Here is the code in App.xaml.cs

public App()
        {
            InitializeComponent();

            if (true)
            {
                if (CrossConnectivity.Current.IsConnected)
                {
                    do something
                }
                MainPage = new MyApp.MenuItems();
            }
            else
            {
                MainPage = new MyApp.MainPage();
            }

        }

Please help as app is fully ready for android and something going wrong with ios.

Body:
try with

switch(Device.RuntimePlatform)
{

     case Device.iOS:
          MainPage = new NavigationPage(new MyApp.MainPage());
          break;
     case Device.Android:
          MainPage = new MyApp.MainPage();
          break;
}

may be it's help you


问:
Retrieve an image from folder
How to retrieve an image from folder using MVC C#, and display cell of datatables?

We have captured image through Android saved in one folder on server like D:/Image_Upload.

```<code>"aoColumns": [

               { data: 'ProjectNo' },
               { data: 'FarmerGID' },
               { data: 'FarmerName', 'sWidth': '20%' },
               { data: 'Contact' },
               { data: 'CapacityDesc' },
               { data: 'Unit_Code' },
               { data: 'Unit_Desc' },
               { data: 'VillageCode' },
               { data: 'Village Name', 's Width': '15%' },

               { data: 'SurveyStatus', 'sWidth': '15%', "render": function (data) {

                return '<img width="25px" height="25px" src="file:/D:/Image_Uploa/xyz.jpg">';
               }
               }
            ],
</code>```

We are getting image box in output, but not able to display the image.

答:
You can use do something like this to convert string to IHtmlString.

Make sure image path is correct

```<code>@Html.Raw("<img width='25px' height='25px' src='file:/D:/Image_Uploa/xyz.jpg'>")

@Html.Raw("<span>hi</span>")
</code>```

In your case you can use

```<code>@Html.Raw(model.SurveyStatus)
</code>```

Title: Retrieve an image from folder

Body:
How to retrieve an image from folder using MVC C#, and display cell of datatables?

We have captured image through Android saved in one folder on server like D:/Image_Upload.

"aoColumns": [

               { data: 'ProjectNo' },
               { data: 'FarmerGID' },
               { data: 'FarmerName', 'sWidth': '20%' },
               { data: 'Contact' },
               { data: 'CapacityDesc' },
               { data: 'Unit_Code' },
               { data: 'Unit_Desc' },
               { data: 'VillageCode' },
               { data: 'Village Name', 's Width': '15%' },

               { data: 'SurveyStatus', 'sWidth': '15%', "render": function (data) {

                return '';
               }
               }
            ],

We are getting image box in output, but not able to display the image.

Body:
You can use do something like this to convert string to IHtmlString.

Make sure image path is correct

@Html.Raw("<img width='25px' height='25px' src='file:/D:/Image_Uploa/xyz.jpg'>")

@Html.Raw("<span>hi</span>")

In your case you can use

@Html.Raw(model.SurveyStatus)


问:
Is it possible to redirect all types of error to a common page in codeigniter?
Is it possible redirect all following error page contents to a common page?
normally codeigniter packages include following pages for error handling:

application->views->errors->html (error_exception.php, error_db.php, error_general.php, error_php.php, error_404.php)
Is it possible to redirect these contents to a common page?

答:
Code Igniter has some error logging functions built in.

Make your /application/logs folder writable

In /application/config/config.php set
$config['log_threshold'] = 1;
or use a higher number, depending on how much detail you want in your logs

Use log_message('');

see more http://www.codeigniter.com/user_guide/general/errors.html


问:
Visual Studio emulator for Android stuck at "OS is starting...", only on API Level 23 / Android 6
Since I read the news about Xamarin now being "free", I immediately installed Visual Studio 2015 Update 2 and the Android tooling (NDKs, SDKs for 19-23, Visual Studio Emulator for Android dated January 2016) to start working on an Android application.

Excited I launched the emulator from Tools -> Visual Studio Emulator for Android and installed the profile that is the best match for my own phone. Since my phone is on Android 6, I decided to get a profile for API Level 23 / Android 6.

Since I had already enabled Hyper-V a few months ago, the installation for the profile only had to add me to the Administrators group and create 2 network adapters.

So far, so good.

Upon starting the emulator, it would stay at "OS is starting...". I figured I'd wait a while. I figured I'd wait a while longer too. After that, I gave up the possibility of it going to work and started investigating.

I also tried other profiles, a few others from API Level 23, one from 22 and one from 19. Only the ones from API Level 23 did not work.

The following steps are what I came up with so far by Googling etc. I tried them in all sorts of combinations:

Rebooting

Disabling / enabling Hyper-V

Removing vEthernet adapters (through the Hyper-V Manager).

Running XDECleanup

Allowing XDE through my Windows Firewall as application (incoming)

Restoring the emulator software in Programs and Features

Enabling / disabling "Processor Compatibility" in Hyper-V Manager.

This is the data I've gathered so far:

A screenshot of the error message that the emulator gives after waiting a long time (10 - 15 minutes, maybe a little longer)

A screenshot of the last part of the log when being connected to the Android 6 VM:

A screenshot of the last part of the log of a working VM (this one's from an Android 4.4 VM):

答:
My problem was that the system image was missing for the emulator.
When I opened the android virtual device manager it had an exclamation mark next to actions(i had to download the system image via the download link).


问:
Azure App Service Plan cannot be changed
I have an App Service plan on which we have deployed some applications.
For the needs of reorganizing server and applications I wanted to rename the service plan which was in a standard resource group "Default-Web-WestEurope-blablabla".

Given that an App service plan cannot be renamed I have during the time created another resource group and gradually moved all my apps and services (Storage, Database ,etc.) inside the new resource group. Also the old App Service plan has been moved to the new resource group.

The scope was to have everything inside a new resource group and then create a new App Service plan where to move all the app services in the previous one by using the "Change App Service plan feature".

However I have discovered, after having created a new App service plan, that when I try to hit the "Change App Service plan feature" option, the answer is "No App Service plan found"!

How can I move all the resource between the two App Service plan?

EDIT:

I have tried by using Powershell and I get a a reason.

Set-AzureRmWebApp : Cannot change the site xxxxx to the App Service
  Plan XXXXX due to hosting constraints. At line:1 char:1

答:
In other words this operation can't be done if the original app service plan is in a different web space.

Yes, you are right. There is a limit when move an app to a different App Service plan. The resource group in the limit is the initial resource group when you create your App Service Plan.

```<code>Only valid plans (in the same resource group and geographical location) are shown.
</code>```

For your issue, you could create a new App Service Plan in your original resource group. After finished the web app move operation, you could move all the resources to the new resource group.

If you moved your web app to the new resource group, Web App backup and restore is a good choice to copy all the contents and configurations from your old Web App to a new Web App.

Body:
In other words this operation can't be done if the original app service plan is in a different web space.

Yes, you are right. There is a limit when move an app to a different App Service plan. The resource group in the limit is the initial resource group when you create your App Service Plan.

Only valid plans (in the same resource group and geographical location) are shown.

For your issue, you could create a new App Service Plan in your original resource group. After finished the web app move operation, you could move all the resources to the new resource group.

If you moved your web app to the new resource group, Web App backup and restore is a good choice to copy all the contents and configurations from your old Web App to a new Web App.


问:
Windows + Cygwin + Single Line If Else + Puppet
So I have a single line bash command that checks if a directory exists. If it does, it git pulls, if it doesn't, it clones the repository. I am running a Cygwin on my Windows box and when I run this command in Cygwin it works perfectly:

```<code>if [ -d C:/repo ]; then cd C:/repo && "C:/Program Files (x86)/Git/bin/git.exe" pull; else "C:/Program Files (x86)/Git/bin/git.exe" clone -b develop https://repo.git C:/repo; fi
</code>```

When I run the same command from Puppet though like  this:

```<code>exec {'checkout repository':
    command => "if [ -d C:/repo ]; then cd C:/repo && "C:/Program Files (x86)/Git/bin/git.exe" pull; else "C:/Program Files (x86)/Git/bin/git.exe" clone -b develop https://repo.git C:/repo; fi"
}
</code>```

I get error:

Error: ' if [ -d C:/repo ]; then cd C:/repo && "C:/Program Files
  (x86)/Git/bin/git.exe" pull; else "C:/Program Files
  (x86)/Git/bin/git.exe" clone -b develop https://repo.git C:/repo; fi'
  is not qualified and no path was specified. Please qualify the command
  or specify a path.

Any ideas why?

答:
escape your quotes or use single quotes and use cygdrive, so your code should look like this:

```<code>exec {'checkout repository':
    command => "if [ -d C:/repo ]; then cd C:/repo && 'C:/Program Files (x86)/Git/bin/git.exe' pull; else 'C:/Program Files (x86)/Git/bin/git.exe' clone -b develop https://repo.git C:/repo; fi"
}
</code>```

and this:

```<code>exec {'checkout repository':
    command => "if [ -d /cygdrive/c/repo ]; then cd /cygdrive/c/repo && '/cygdrive/c/Program Files (x86)/Git/bin/git.exe' pull; else '/cygdrive/c/Program Files (x86)/Git/bin/git.exe' clone -b develop https://repo.git /cygdrive/c/repo; fi"
}
</code>```

And if you even install git inside cygwin, you can make it simpler:

```<code>exec {'checkout repository':
    command => "if [ -d /cygdrive/c/repo ]; then cd /cygdrive/c/repo && git pull; else git clone -b develop https://repo.git /cygdrive/c/repo; fi"
}
</code>```

Body:
So I have a single line bash command that checks if a directory exists. If it does, it git pulls, if it doesn't, it clones the repository. I am running a Cygwin on my Windows box and when I run this command in Cygwin it works perfectly:

if [ -d C:/repo ]; then cd C:/repo && "C:/Program Files (x86)/Git/bin/git.exe" pull; else "C:/Program Files (x86)/Git/bin/git.exe" clone -b develop https://repo.git C:/repo; fi

When I run the same command from Puppet though like  this:

exec {'checkout repository':
    command => "if [ -d C:/repo ]; then cd C:/repo && "C:/Program Files (x86)/Git/bin/git.exe" pull; else "C:/Program Files (x86)/Git/bin/git.exe" clone -b develop https://repo.git C:/repo; fi"
}

I get error:

Error: ' if [ -d C:/repo ]; then cd C:/repo && "C:/Program Files
  (x86)/Git/bin/git.exe" pull; else "C:/Program Files
  (x86)/Git/bin/git.exe" clone -b develop https://repo.git C:/repo; fi'
  is not qualified and no path was specified. Please qualify the command
  or specify a path.

Any ideas why?

Body:
escape your quotes or use single quotes and use cygdrive, so your code should look like this:

exec {'checkout repository':
    command => "if [ -d C:/repo ]; then cd C:/repo && 'C:/Program Files (x86)/Git/bin/git.exe' pull; else 'C:/Program Files (x86)/Git/bin/git.exe' clone -b develop https://repo.git C:/repo; fi"
}

and this:

exec {'checkout repository':
    command => "if [ -d /cygdrive/c/repo ]; then cd /cygdrive/c/repo && '/cygdrive/c/Program Files (x86)/Git/bin/git.exe' pull; else '/cygdrive/c/Program Files (x86)/Git/bin/git.exe' clone -b develop https://repo.git /cygdrive/c/repo; fi"
}

And if you even install git inside cygwin, you can make it simpler:

exec {'checkout repository':
    command => "if [ -d /cygdrive/c/repo ]; then cd /cygdrive/c/repo && git pull; else git clone -b develop https://repo.git /cygdrive/c/repo; fi"
}


问:
Android, Retrofit catch specific response code for all requests
I have Retrofit Rest client interface with more than 40 http calls. I initialize my RestClient like this:

```<code>public class RestClient {

    private static final String BASE_URL = "http://example.com/";

    private static final int TIMEOUT_IN_SECONDS = 30;

    private static OkHttpClient okHttpClient = new OkHttpClient.Builder()
        .addInterceptor(getInterceptor())
        .connectTimeout(TIMEOUT_IN_SECONDS, TimeUnit.SECONDS)
        .readTimeout(TIMEOUT_IN_SECONDS, TimeUnit.SECONDS)
        .writeTimeout(TIMEOUT_IN_SECONDS, TimeUnit.SECONDS)
        .build();

    private static Retrofit retrofit = new Retrofit.Builder()
        .baseUrl(BASE_URL)
        .client(okHttpClient)
        .addConverterFactory(GsonConverterFactory.create())
        .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
        .build();

    private RestClient() {

    }

    private static HttpLoggingInterceptor getInterceptor() {
    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(BuildConfig.DEBUG ? HttpLoggingInterceptor.Level.BODY
            : HttpLoggingInterceptor.Level.NONE);
        return interceptor;
    }

    public static MyService request() {
        return retrofit.create(MyService.class);
    }

}
</code>```

All requests, except authorization, requires special token. When this token expires REST API responds with 403 code error.

I can't add checking for this code response from each of my API call, because there are more than 100 api calls in my application.

Is it possible to somehow catch 403 response code in the level of my RestClient class so I could open Authorization Activity again?

答:
First, I think 403 is wrong, 401 may be right. If you are sure When this token expires REST API responds with 403 code error. You can't use Authenticator which will be used when 401 happens. So, you need use Interceptor. you can create TokenInterceptor implements Interceptor

```<code>public class TokenInterceptor implements Interceptor {

    @Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request();
        Response response = chain.proceed(request);
        if (response.code() == 403) {
            doSomething();
        }
        return response;
    }
}
</code>```

okHttpClient add this TokenInterceptor.

Body:
I have Retrofit Rest client interface with more than 40 http calls. I initialize my RestClient like this:

public class RestClient {

    private static final String BASE_URL = "http://example.com/";

    private static final int TIMEOUT_IN_SECONDS = 30;

    private static OkHttpClient okHttpClient = new OkHttpClient.Builder()
        .addInterceptor(getInterceptor())
        .connectTimeout(TIMEOUT_IN_SECONDS, TimeUnit.SECONDS)
        .readTimeout(TIMEOUT_IN_SECONDS, TimeUnit.SECONDS)
        .writeTimeout(TIMEOUT_IN_SECONDS, TimeUnit.SECONDS)
        .build();

    private static Retrofit retrofit = new Retrofit.Builder()
        .baseUrl(BASE_URL)
        .client(okHttpClient)
        .addConverterFactory(GsonConverterFactory.create())
        .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
        .build();

    private RestClient() {

    }

    private static HttpLoggingInterceptor getInterceptor() {
    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(BuildConfig.DEBUG ? HttpLoggingInterceptor.Level.BODY
            : HttpLoggingInterceptor.Level.NONE);
        return interceptor;
    }

    public static MyService request() {
        return retrofit.create(MyService.class);
    }

}

All requests, except authorization, requires special token. When this token expires REST API responds with 403 code error.

I can't add checking for this code response from each of my API call, because there are more than 100 api calls in my application.

Is it possible to somehow catch 403 response code in the level of my RestClient class so I could open Authorization Activity again?

Body:
First, I think 403 is wrong, 401 may be right. If you are sure When this token expires REST API responds with 403 code error. You can't use Authenticator which will be used when 401 happens. So, you need use Interceptor. you can create TokenInterceptor implements Interceptor

public class TokenInterceptor implements Interceptor {

    @Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request();
        Response response = chain.proceed(request);
        if (response.code() == 403) {
            doSomething();
        }
        return response;
    }
}

okHttpClient add this TokenInterceptor.


问:
How to sign an android apk file
I am trying to sign my apk file. I can't figure out how to do it. I can't find good in-depth directions. I have very little programing experience, so any help would be appreciated.</p>

答:
APK Signing Process

To manually sign an Android APK file run these three commands:

Generate Keystore file

```<code>keytool -genkey -v -keystore YOUR_KEYSTORE_NAME.keystore -alias ALIAS_NAME -keyalg RSA -keysize 2048 -validity 10000
</code>```

Sign Your APK file using jarsigner

```<code>jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore KEYSTORE_FILE_PATH UNSIGNED_APK_PATH ALIAS_NAME
</code>```

Align Signed APK using zipalign tool

```<code>zipalign -v 4 JARSIGNED_APK_FILE_PATH ZIPALIGNED_SIGNED_APK_FILE_PATH
</code>```

STEP 1

Generate Keystore file

keytool -genkey -v -keystore YOUR_KEYSTORE_NAME.keystore -alias ALIAS_NAME -keyalg RSA -keysize 2048 -validity 10000

Example:

```<code>keytool -genkey -v -keystore id.keystore -alias MySignedApp -keyalg RSA -keysize 2048 -validity 10000
</code>```

keystore password : yourApp@123
key password      : yourApp@123

CMD O/P

```<code>D:\ru\SignedBuilds\MySignedApp>keytool -genkey -v -keystore id.keystore
 -alias MySignedApp -keyalg RSA -keysize 2048 -validity 10000
Enter keystore password:
Re-enter new password:
What is your first and last name?
  [Unknown]:  MySignedApp Sample
What is the name of your organizational unit?
  [Unknown]:  Information Technology
What is the name of your organization?
  [Unknown]:  MySignedApp Demo
What is the name of your City or Locality?
  [Unknown]:  Mumbai
What is the name of your State or Province?
  [Unknown]:  Maharashtra
What is the two-letter country code for this unit?
  [Unknown]:  IN
Is CN=MySignedApp Demo, OU=Information Technology, O=MySignedApp Demo, L=Mumbai, ST=Maharashtra, C=IN corr
ect?
  [no]:  y

Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 10,
000 days
        for: CN=MySignedApp Demo, OU=Information Technology, O=MySignedApp Demo, L=Mumbai, ST=Maharashtra,
 C=IN
Enter key password for <MySignedApp>
        (RETURN if same as keystore password):
Re-enter new password:
[Storing id.keystore]

D:\ru\SignedBuilds\MySignedApp>
</code>```

STEP 2

Sign your app with your private keystore using jarsigner

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore
  KEYSTORE_FILE_PATH UNSIGNED_APK_PATH ALIAS_NAME

Example

```<code>jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore D:\ru\SignedBuilds\MySignedApp\id.keystore D:\ru\SignedBuilds\MySignedApp\MySignedAppS1-release-unsigned.apk id
</code>```

CMD O/P

```<code>D:\ru\SignedBuilds\MySignedApp>jarsigner -verbose -sigalg SHA1withRSA -
digestalg SHA1 -keystore D:\ru\SignedBuilds\MySignedApp\id.keystore D:\ru\SignedBuilds\MySignedApp\MySignedAppS1-release-unsigned.apk id ---
ect
Enter Passphrase for keystore:
   adding: META-INF/MANIFEST.MF
   adding: META-INF/---.SF
   adding: META-INF/---.RSA
  signing: AndroidManifest.xml
  .....
    signing: classes.dex
  signing: lib/commons-codec-1.6.jar
  signing: lib/armeabi/libkonyjsvm.so
jar signed.

Warning:
No -tsa or -tsacert is provided and this jar is not timestamped. Without a timestamp, users may not
be able to validate this jar after the signer certificate's expiration date (2044-02-07) or after an
y future revocation date.

D:\ru\SignedBuilds\MySignedApp>
</code>```

Verify that your APK is signed

jarsigner -verify -verbose -certs JARSIGNED_APK_FILE_PATH

Example

```<code>jarsigner -verify -verbose -certs MySignedAppS1-release-unsigned.apk
</code>```

CMD O/P

```<code>D:\ru\SignedBuilds\MySignedApp>jarsigner -verify -verbose -certs MySignedAppS1-release-unsigned.apk
 s = signature was verified
  m = entry is listed in manifest
  k = at least one certificate was found in keystore
  i = at least one certificate was found in identity scope

jar verified.

Warning:
This jar contains entries whose certificate chain is not validated.
This jar contains signatures that does not include a timestamp. Without a timestamp, users may not b
e able to validate this jar after the signer certificate's expiration date (2044-02-09) or after any
 future revocation date.

D:\ru\SignedBuilds\MySignedApp>
</code>```

STEP 3

Align the final APK package using zipalign

zipalign -v 4 JARSIGNED_APK_FILE_PATH ZIPALIGNED_SIGNED_APK_FILE_PATH_WITH_NAME_ofSignedAPK

Example

```<code>zipalign -v 4 D:\ru\SignedBuilds\MySignedApp\MySignedAppS1-release-unsigned.apk D:\ru\SignedBuilds\MySignedApp\MySignedApp.apk
</code>```

CMD O/P

```<code>jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore KEYSTORE_FILE_PATH UNSIGNED_APK_PATH ALIAS_NAME
</code>```0

Verify that your APK is Aligned successfully

zipalign -c -v 4 YOUR_APK_PATH

Example

```<code>jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore KEYSTORE_FILE_PATH UNSIGNED_APK_PATH ALIAS_NAME
</code>```1

CMD O/P

```<code>jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore KEYSTORE_FILE_PATH UNSIGNED_APK_PATH ALIAS_NAME
</code>```2

Note:

The verify command is just to check whether APK is built and signed correctly!

References

signing-manually

androidapk-code-signing-process

I hope this will help one and all :)

Title: How to sign an android apk file

Body:
APK Signing Process

To manually sign an Android APK file run these three commands:

Generate Keystore file

keytool -genkey -v -keystore YOUR_KEYSTORE_NAME.keystore -alias ALIAS_NAME -keyalg RSA -keysize 2048 -validity 10000

Sign Your APK file using jarsigner

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore KEYSTORE_FILE_PATH UNSIGNED_APK_PATH ALIAS_NAME

Align Signed APK using zipalign tool

zipalign -v 4 JARSIGNED_APK_FILE_PATH ZIPALIGNED_SIGNED_APK_FILE_PATH

STEP 1

Generate Keystore file

keytool -genkey -v -keystore YOUR_KEYSTORE_NAME.keystore -alias ALIAS_NAME -keyalg RSA -keysize 2048 -validity 10000

Example:

keytool -genkey -v -keystore id.keystore -alias MySignedApp -keyalg RSA -keysize 2048 -validity 10000

keystore password : yourApp@123
key password      : yourApp@123

CMD O/P

D:\ru\SignedBuilds\MySignedApp>keytool -genkey -v -keystore id.keystore
 -alias MySignedApp -keyalg RSA -keysize 2048 -validity 10000
Enter keystore password:
Re-enter new password:
What is your first and last name?
  [Unknown]:  MySignedApp Sample
What is the name of your organizational unit?
  [Unknown]:  Information Technology
What is the name of your organization?
  [Unknown]:  MySignedApp Demo
What is the name of your City or Locality?
  [Unknown]:  Mumbai
What is the name of your State or Province?
  [Unknown]:  Maharashtra
What is the two-letter country code for this unit?
  [Unknown]:  IN
Is CN=MySignedApp Demo, OU=Information Technology, O=MySignedApp Demo, L=Mumbai, ST=Maharashtra, C=IN corr
ect?
  [no]:  y

Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 10,
000 days
        for: CN=MySignedApp Demo, OU=Information Technology, O=MySignedApp Demo, L=Mumbai, ST=Maharashtra,
 C=IN
Enter key password for <MySignedApp>
        (RETURN if same as keystore password):
Re-enter new password:
[Storing id.keystore]

D:\ru\SignedBuilds\MySignedApp>

STEP 2

Sign your app with your private keystore using jarsigner

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore
  KEYSTORE_FILE_PATH UNSIGNED_APK_PATH ALIAS_NAME

Example

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore D:\ru\SignedBuilds\MySignedApp\id.keystore D:\ru\SignedBuilds\MySignedApp\MySignedAppS1-release-unsigned.apk id

CMD O/P

D:\ru\SignedBuilds\MySignedApp>jarsigner -verbose -sigalg SHA1withRSA -
digestalg SHA1 -keystore D:\ru\SignedBuilds\MySignedApp\id.keystore D:\ru\SignedBuilds\MySignedApp\MySignedAppS1-release-unsigned.apk id ---
ect
Enter Passphrase for keystore:
   adding: META-INF/MANIFEST.MF
   adding: META-INF/---.SF
   adding: META-INF/---.RSA
  signing: AndroidManifest.xml
  .....
    signing: classes.dex
  signing: lib/commons-codec-1.6.jar
  signing: lib/armeabi/libkonyjsvm.so
jar signed.

Warning:
No -tsa or -tsacert is provided and this jar is not timestamped. Without a timestamp, users may not
be able to validate this jar after the signer certificate's expiration date (2044-02-07) or after an
y future revocation date.

D:\ru\SignedBuilds\MySignedApp>

Verify that your APK is signed

jarsigner -verify -verbose -certs JARSIGNED_APK_FILE_PATH

Example

jarsigner -verify -verbose -certs MySignedAppS1-release-unsigned.apk

CMD O/P

D:\ru\SignedBuilds\MySignedApp>jarsigner -verify -verbose -certs MySignedAppS1-release-unsigned.apk
 s = signature was verified
  m = entry is listed in manifest
  k = at least one certificate was found in keystore
  i = at least one certificate was found in identity scope

jar verified.

Warning:
This jar contains entries whose certificate chain is not validated.
This jar contains signatures that does not include a timestamp. Without a timestamp, users may not b
e able to validate this jar after the signer certificate's expiration date (2044-02-09) or after any
 future revocation date.

D:\ru\SignedBuilds\MySignedApp>

STEP 3

Align the final APK package using zipalign

zipalign -v 4 JARSIGNED_APK_FILE_PATH ZIPALIGNED_SIGNED_APK_FILE_PATH_WITH_NAME_ofSignedAPK

Example

zipalign -v 4 D:\ru\SignedBuilds\MySignedApp\MySignedAppS1-release-unsigned.apk D:\ru\SignedBuilds\MySignedApp\MySignedApp.apk

CMD O/P

D:\Android\android-sdk\build-tools\19.1.0>zipalign -v 4 D:\ru\ru_doc\Signed_apk\MySignedApp\28.09.16
_prod_playstore\MySignedAppS1-release-unsigned.apk D:\ru\ru_doc\Signed_apk\MySignedApp\28.09.16_prod
_playstore\MySignedApp.apk
Verifying alignment of D:\ru\SignedBuilds\MySignedApp\MySignedApp.apk (
4)...

  4528613 classes.dex (OK - compressed)
 5656594 lib/commons-codec-1.6.jar (OK - compressed)
 5841869 lib/armeabi/libkonyjsvm.so (OK - compressed)
Verification succesful

D:\Android\android-sdk\build-tools\19.1.0>

Verify that your APK is Aligned successfully

zipalign -c -v 4 YOUR_APK_PATH

Example

zipalign -c -v 4 D:\ru\SignedBuilds\MySignedApp\MySignedApp.apk

CMD O/P

D:\Android\android-sdk\build-tools\19.1.0>zipalign -c -v 4 D:\ru\SignedBuilds\MySignedApp\MySignedApp.apk
Verifying alignment of D:\ru\SignedBuilds\MySignedApp\MySignedApp.apk (
4)...

 4453984 res/drawable/zoomout.png (OK)
 4454772 res/layout/tabview.xml (OK - compressed)
 4455243 res/layout/wheel_item.xml (OK - compressed)
 4455608 resources.arsc (OK)
 4470161 classes.dex (OK - compressed)
 5597923 lib/commons-codec-1.6.jar (OK - compressed)
 5783198 lib/armeabi/libkonyjsvm.so (OK - compressed)
Verification succesful

D:\Android\android-sdk\build-tools\19.1.0>

Note:

The verify command is just to check whether APK is built and signed correctly!

References

signing-manually

androidapk-code-signing-process

I hope this will help one and all :)


问:
How does OpenVR, SteamVR and Unity3D work together?
I am trying to understand the VR platform stack of Vive, and how it's games are developed.
I am struggling to understand where exactly does openVR, steamVR and Unity fit into picture.

My understanding so far has been that:

```<code>openVR - Hardware independent layer providing APIs for peripheral access.
         That is it can provide access to either Oculus or Vive hardware via
         a defined interface.

SteamVR - Provides access to hardware to games developed either in unity or
          unreal.
Unity3D - A game engine to develop games.
</code>```

If anyone can correct me, I will be much grateful.
Or if my understanding is correct, then why can't games being developed in unity 3D access hardware directly via openVR.

答:
OpenVR is an API and runtime that allows access to VR hardware from multiple vendors without requiring that applications have specific knowledge of the hardware they are targeting (ref1), SteamVR is the customer facing name that we use for what users actually use and install (for details check this video: Using Unity at Valve)

Also Check to see that can you use the Vive with OpenVR without Steam ??.

Lets finally look all these terms, thanks to Reddit post:

How a Game Appears on your Head Mounted Display(HMD):

A game renders an image, sends it to it's corresponding runtime. The runtime then renders it to the HMD:

Rendered Image using the :

[OVR/OpenVR] SDK -> [Oculus/SteamVR] Runtime -> [Rift/Vive]

SDKs:

SDKs are used to build the games. A game can either implement OVR or OpenVR or both. This means that the game has access to native functionality in it's corresponding runtime. SDKs do not handle async timewarp or reprojection, those are handled by the runtime!

OVR: Made by Oculus for the Oculus Rift. Current version (14th May 2016) is 1.3.1 and can access all features of the Oculus runtime.

OpenVR made by Valve and supports Vive and Rift via the SteamVR runtime

Sidenote to SDK's and Unity games: Unity 5.3 currently has optimizations for VR in their native mode. The native mode supports Rift, Gear and PSVR, but not SteamVR. A game compiled with Unity 5.3 can use those optimzations with the Oculus SDK but not the OpenVR SDK. The OpenVR SDK has it's own optimizations, which may or may not result in similar performance. However, the upcoming Unity 5.4 will support SteamVR natively and performance should be more or less identical. Please note: this is Unity specific and other engines might have similar or different optimizations for some or all headsets.

Runtimes
Oculus Runtime responsible for async timewarp and handles device detection, display, etc. It (the runtime service) needs to be running for Oculus Home to launch

SteamVR Runtime responsible for reprojection and supports Rift and Vive

Software Distribution Platforms

Oculus Home needs to be running for the Rift to work. By default only supports apps from the store (checkbox in the settings of the 2d desktop client to enable other sources). It downloads games and runs them. It also handles the Universal Menu on the Xbox button

Steam/SteamVR technically does not need to run when launching OpenVR games, but highly recommended (room setup and config is pulled from there). Also handles overlay menu on the Xbox button, or when running on the Rift, it launches by pressing the select/start button in the Oculus Universal Menu

Finally worth reading.

Body:
I am trying to understand the VR platform stack of Vive, and how it's games are developed.
I am struggling to understand where exactly does openVR, steamVR and Unity fit into picture.

My understanding so far has been that:

openVR - Hardware independent layer providing APIs for peripheral access.
         That is it can provide access to either Oculus or Vive hardware via
         a defined interface.

SteamVR - Provides access to hardware to games developed either in unity or
          unreal.
Unity3D - A game engine to develop games.

If anyone can correct me, I will be much grateful.
Or if my understanding is correct, then why can't games being developed in unity 3D access hardware directly via openVR.


问:
Python - convert .txt content into json format
```<code>Name: Donald J. Trump
Username: @realDonaldTrump
Post: I look forward to paying my respects to our brave men and women on this Memorial Day at Arlington National Cemetery later this morning.
post's link: https://twitter.com/realDonaldTrump/status/869170615881793536
Replies: 16,259 replies
Retweet: 15,103 retweets
Likes: 90,839 likes
Date: 5:36 AM - 29 May 2017
</code>```

Hi all, above is the format of each chunk of data in my first.txt file. I would like to read it and change it to to the json format like the one below, and store it to second.txt file.

```<code>def convert_to_json(path, name, username, post, link, replies, retweets, likes, retweetby, date, domainname):
with open(path, 'a') as file:
    stringData = [{"ContentUrl": link,
    "Text": post,
    "PublishDate": date.strip(),
    "Title": "",
    "SourceUrl": domainname,
    "SocialNetwork": media,
    "Source": "",
    "Author": name,
    "Like_count": likes.strip(),
    "Replies_count": replies.strip(),
    "Retweets_count": retweets.strip(),
    "Schema": "SOCIAL_MEDIA"}]

    objData = json.load(stringData)
    file.write(stringData)
</code>```

The above code was suppose to take in data and then append it to second.txt file. However, my code did not manage to append the data i want into my second.txt file. No apparent error was shown at the console, and i seek suggestions and help from all of the experts here.

答:
You are not using json.load correctly; try it like this:

```<code>record = {"ContentUrl": link,
    "Text": post,
    "PublishDate": date.strip(),
    "Title": "",
    "SourceUrl": domainname,
    "SocialNetwork": media,
    "Source": "",
    "Author": name,
    "Like_count": likes.strip(),
    "Replies_count": replies.strip(),
    "Retweets_count": retweets.strip(),
    "Schema": "SOCIAL_MEDIA"}

with open(path, 'a') as file:
    objData = json.load(file)
    objData.append(record)
    file.write(json.dumps(objData))
</code>```

Body:
Name: Donald J. Trump
Username: @realDonaldTrump
Post: I look forward to paying my respects to our brave men and women on this Memorial Day at Arlington National Cemetery later this morning.
post's link: https://twitter.com/realDonaldTrump/status/869170615881793536
Replies: 16,259 replies
Retweet: 15,103 retweets
Likes: 90,839 likes
Date: 5:36 AM - 29 May 2017

Hi all, above is the format of each chunk of data in my first.txt file. I would like to read it and change it to to the json format like the one below, and store it to second.txt file.

def convert_to_json(path, name, username, post, link, replies, retweets, likes, retweetby, date, domainname):
with open(path, 'a') as file:
    stringData = [{"ContentUrl": link,
    "Text": post,
    "PublishDate": date.strip(),
    "Title": "",
    "SourceUrl": domainname,
    "SocialNetwork": media,
    "Source": "",
    "Author": name,
    "Like_count": likes.strip(),
    "Replies_count": replies.strip(),
    "Retweets_count": retweets.strip(),
    "Schema": "SOCIAL_MEDIA"}]

    objData = json.load(stringData)
    file.write(stringData)

The above code was suppose to take in data and then append it to second.txt file. However, my code did not manage to append the data i want into my second.txt file. No apparent error was shown at the console, and i seek suggestions and help from all of the experts here.

Body:
You are not using json.load correctly; try it like this:

record = {"ContentUrl": link,
    "Text": post,
    "PublishDate": date.strip(),
    "Title": "",
    "SourceUrl": domainname,
    "SocialNetwork": media,
    "Source": "",
    "Author": name,
    "Like_count": likes.strip(),
    "Replies_count": replies.strip(),
    "Retweets_count": retweets.strip(),
    "Schema": "SOCIAL_MEDIA"}

with open(path, 'a') as file:
    objData = json.load(file)
    objData.append(record)
    file.write(json.dumps(objData))


问:
Get Order Total before order is placed in payment_fields function
I'm using WooCommerce and the following plugin:
https://codecanyon.net/item/woocommerce-point-of-sale-pos/7869665

The following code should print a URL on the payment field which should open an app on the computer. All of this is working fine, but the URL needs to contain the total order price (in cents, so multiplied by 100) and I can't manage to get this done. I already wrote the following code and the only thing I'm missing is $order_price_cents.

```<code>public function payment_fields()
{

    $smartpinurl = "smartpin://payment?price=" . $order_price_cents . "&vat=zero&reference=Bestelling%20bij%DE-IT%20";

    echo '<a class="x-btn x-btn-rounded x-btn-regular" href="' . $smartpinurl . '" target="_blank">Activeer Smartpin App</a>';

}
</code>```

Orders aren't placed yet when this button is clicked, so I can't use the default way to get the price.

E.g: I select a product worth €10.00 in the POS system. So $order_price_cents needs to be 1000.

答:
Try this one

```<code>public function payment_fields()
{
    global $woocommerce;
    $order_price_cents = $woocommerce->cart->total * 100;

    $smartpinurl = "smartpin://payment?price=" . $order_price_cents . "&vat=zero&reference=Bestelling%20bij%DE-IT%20";

    echo '<a class="x-btn x-btn-rounded x-btn-regular" href="' . $smartpinurl . '" target="_blank">Activeer Smartpin App</a>';

}
</code>```

If it will not work properly so you can just check out the right replacement here for WooCommerce POS. This one is the best process for WooCommerce Point of Sale.

Body:
I'm using WooCommerce and the following plugin:
https://codecanyon.net/item/woocommerce-point-of-sale-pos/7869665

The following code should print a URL on the payment field which should open an app on the computer. All of this is working fine, but the URL needs to contain the total order price (in cents, so multiplied by 100) and I can't manage to get this done. I already wrote the following code and the only thing I'm missing is $order_price_cents.

public function payment_fields()
{

    $smartpinurl = "smartpin://payment?price=" . $order_price_cents . "&vat=zero&reference=Bestelling%20bij%DE-IT%20";

    echo 'Activeer Smartpin App';

}

Orders aren't placed yet when this button is clicked, so I can't use the default way to get the price.

E.g: I select a product worth €10.00 in the POS system. So $order_price_cents needs to be 1000.

Body:
Try this one

public function payment_fields()
{
    global $woocommerce;
    $order_price_cents = $woocommerce->cart->total * 100;

    $smartpinurl = "smartpin://payment?price=" . $order_price_cents . "&vat=zero&reference=Bestelling%20bij%DE-IT%20";

    echo '<a class="x-btn x-btn-rounded x-btn-regular" href="' . $smartpinurl . '" target="_blank">Activeer Smartpin App</a>';

}

If it will not work properly so you can just check out the right replacement here for WooCommerce POS. This one is the best process for WooCommerce Point of Sale.


答:
Try json.dumps instead of load

Why do you wrap you dict in a list?

Write to file the result of the json.dumps, not the object

```<code>with open(path, 'a+') as file:
    stringData = {"ContentUrl": link,
    "Text": post,
    "PublishDate": date.strip(),
    "Title": "",
    "SourceUrl": domainname,
    "SocialNetwork": media,
    "Source": "",
    "Author": name,
    "Like_count": likes.strip(),
    "Replies_count": replies.strip(),
    "Retweets_count": retweets.strip(),
    "Schema": "SOCIAL_MEDIA"}

    objData = json.dumps(stringData)
    file.write(objData)
</code>```

Title: Python - convert .txt content into json format

Body:
Try json.dumps instead of load

Why do you wrap you dict in a list?

Write to file the result of the json.dumps, not the object

with open(path, 'a+') as file:
    stringData = {"ContentUrl": link,
    "Text": post,
    "PublishDate": date.strip(),
    "Title": "",
    "SourceUrl": domainname,
    "SocialNetwork": media,
    "Source": "",
    "Author": name,
    "Like_count": likes.strip(),
    "Replies_count": replies.strip(),
    "Retweets_count": retweets.strip(),
    "Schema": "SOCIAL_MEDIA"}

    objData = json.dumps(stringData)
    file.write(objData)


问:
display soap response on JSP
I'm new to java.
I receive a soap response to my servlet. but when i try to display it in my JSP page, the response is not correctly shown. This is how i forward response attached to the request ,

```<code>RequestDispatcher dispatcher = req.getRequestDispatcher("response.jsp");
            req.setAttribute("result", soapResponse);
            dispatcher.forward(req, resp);
</code>```

In response.jsp

```<code> <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1> Response</h1>
<table>
    <tr>
        <td><%=request.getAttribute("result")%></td>
    </tr>
</table>
</body>
</html>
</code>```

Soap response is here,

```<code> <?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <ns2:chargeResponse xmlns:ns2="http://p.com/">
         <return>
            <referralDestination>
               <address>919825010001</address>
            </referralDestination>
            <transactionId>REF59369</transactionId>
            <transactionState>CONFIRMED</transactionState>
         </return>
      </ns2:chargeResponse>
   </soap:Body>
</soap:Envelope>
</code>```

But what JSP display is,

```<code>919825010001 REF59369 CONFIRMED
</code>```

答:
Using textarea worked for me.

```<code><textarea rows="20" cols="40" style="border:none;">

          <%=request.getAttribute("result")%>

</textarea>
</code>```

Title: display soap response on JSP

Body:
I'm new to java.
I receive a soap response to my servlet. but when i try to display it in my JSP page, the response is not correctly shown. This is how i forward response attached to the request ,

RequestDispatcher dispatcher = req.getRequestDispatcher("response.jsp");
            req.setAttribute("result", soapResponse);
            dispatcher.forward(req, resp);

In response.jsp

 <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>

 Response

        <%=request.getAttribute("result")%>

Soap response is here,

 <?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <ns2:chargeResponse xmlns:ns2="http://p.com/">
         <return>
            <referralDestination>
               <address>919825010001</address>
            </referralDestination>
            <transactionId>REF59369</transactionId>
            <transactionState>CONFIRMED</transactionState>
         </return>
      </ns2:chargeResponse>
   </soap:Body>
</soap:Envelope>

But what JSP display is,

919825010001 REF59369 CONFIRMED

Body:
Using textarea worked for me.

<textarea rows="20" cols="40" style="border:none;">

          <%=request.getAttribute("result")%>

</textarea>