问:
Why does boost::timed_wait block forever when called with absolute time?
I am trying to understand how to use timed_wait. I found only few examples (here and here) and I have a problem when calling it with an absolute time. The following code is a simplified example, in reality this all happens inside a class, so I thought it would be easier to check my predicate manually instead of having to use some binding and pass it to timed_wait.

```<code>#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/thread.hpp>
#include <iostream>

bool done = false;
boost::mutex mutex;
boost::thread waitingThread;
boost::condition_variable cond;

void wait(boost::posix_time::time_duration dt){
    boost::mutex::scoped_lock lock(mutex);
    boost::system_time x = boost::posix_time::microsec_clock::local_time() + dt;
    bool timedOut = false;
    while((done == false) && (x > boost::posix_time::microsec_clock::local_time())) {
        timedOut = ! cond.timed_wait(lock,x);
    }
    if (timedOut){ std::cout << "timeout\n"; }
    else         { std::cout << "success\n"; }
}

void wait2(boost::posix_time::time_duration dt){
    boost::mutex::scoped_lock lock(mutex);
    bool timedOut = ! cond.timed_wait(lock,dt);
    if (timedOut){ std::cout << "timeout\n"; }
    else         { std::cout << "success\n"; }

}

void test(){
    //boost::thread waiter = boost::thread(wait,boost::posix_time::milliseconds(50));
    boost::thread waiter = boost::thread(wait2,boost::posix_time::milliseconds(50));
    boost::this_thread::sleep(boost::posix_time::milliseconds(2000));
}
</code>```

The first version blocks forever and I dont understand why. On the other hand, the second version afaik is subject to spurious wakeups. As I said before, in the real code, all this is place inside a class, so to use the overload that takes a predicate I would have to do something like

```<code>cond.timed_wait(lock,dt, ?bind?(&Foo::isDone,this));
</code>```

but then I am not 100% sure if a spurious wakeup will make timed_wait return true (if this is the case my while (x > local_time()) would be superfluous.

答:
Use boost::get_system_time() + dt, which is UTC-based, instead of local_time() + dt, which is timezone-adjusted, because wait_lock(...) uses boost::get_system_time() to compare current time with the target absolute time.

The following example illustrates the problem:

```<code>int main() {
    std::cout << "System time: "
              << boost::get_system_time() << std::endl;
    std::cout << "Local time: "
              << boost::posix_time::microsec_clock::local_time() << std::endl;
}
</code>```

Output:

```<code>System time: 2017-Jun-07 08:47:58.836677
Local time: 2017-Jun-07 11:47:58.837003
</code>```

So, your absolute time-based wait() function blocks just for a few hours specified by timezone offset of your computer, not forever.

Body:
I am trying to understand how to use timed_wait. I found only few examples (here and here) and I have a problem when calling it with an absolute time. The following code is a simplified example, in reality this all happens inside a class, so I thought it would be easier to check my predicate manually instead of having to use some binding and pass it to timed_wait.

#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/thread.hpp>
#include <iostream>

bool done = false;
boost::mutex mutex;
boost::thread waitingThread;
boost::condition_variable cond;

void wait(boost::posix_time::time_duration dt){
    boost::mutex::scoped_lock lock(mutex);
    boost::system_time x = boost::posix_time::microsec_clock::local_time() + dt;
    bool timedOut = false;
    while((done == false) && (x > boost::posix_time::microsec_clock::local_time())) {
        timedOut = ! cond.timed_wait(lock,x);
    }
    if (timedOut){ std::cout << "timeout\n"; }
    else         { std::cout << "success\n"; }
}

void wait2(boost::posix_time::time_duration dt){
    boost::mutex::scoped_lock lock(mutex);
    bool timedOut = ! cond.timed_wait(lock,dt);
    if (timedOut){ std::cout << "timeout\n"; }
    else         { std::cout << "success\n"; }

}

void test(){
    //boost::thread waiter = boost::thread(wait,boost::posix_time::milliseconds(50));
    boost::thread waiter = boost::thread(wait2,boost::posix_time::milliseconds(50));
    boost::this_thread::sleep(boost::posix_time::milliseconds(2000));
}

The first version blocks forever and I dont understand why. On the other hand, the second version afaik is subject to spurious wakeups. As I said before, in the real code, all this is place inside a class, so to use the overload that takes a predicate I would have to do something like

cond.timed_wait(lock,dt, ?bind?(&Foo::isDone,this));

but then I am not 100% sure if a spurious wakeup will make timed_wait return true (if this is the case my while (x > local_time()) would be superfluous.

Body:
Use boost::get_system_time() + dt, which is UTC-based, instead of local_time() + dt, which is timezone-adjusted, because wait_lock(...) uses boost::get_system_time() to compare current time with the target absolute time.

The following example illustrates the problem:

int main() {
    std::cout << "System time: "
              << boost::get_system_time() << std::endl;
    std::cout << "Local time: "
              << boost::posix_time::microsec_clock::local_time() << std::endl;
}

Output:

System time: 2017-Jun-07 08:47:58.836677
Local time: 2017-Jun-07 11:47:58.837003

So, your absolute time-based wait() function blocks just for a few hours specified by timezone offset of your computer, not forever.


来源: stackexchange

问:
Xcode 9 : Module compiled with Swift 3.1 cannot be imported in Swift 4.0
After updating to Xcode 9, I tried to build one of my projects.

I use the FacebookLogin pod.
I have a compiler error in FacebookLogin/LoginButton.swift

```<code>@testable import FacebookCore
❌ Module compiled with Swift 3.1 cannot be imported in Swift 4.0
</code>```

In my target's build settings, the Swift language version is set to Swift 3.2.

I guess I need to wait for Facebook to update their pod ? Or any other suggestion ?

Thanks !

答:
Maybe you can clean the target before you build it.
It works fine for me.</p>

ContentLicense: CC BY-SA 3.0

Body:
After updating to Xcode 9, I tried to build one of my projects.

I use the FacebookLogin pod.
I have a compiler error in FacebookLogin/LoginButton.swift

@testable import FacebookCore
❌ Module compiled with Swift 3.1 cannot be imported in Swift 4.0

In my target's build settings, the Swift language version is set to Swift 3.2.

I guess I need to wait for Facebook to update their pod ? Or any other suggestion ?

Thanks !


问:
Vue.js v-bind:src of an  element doesn't showing the image
I have an array of plants. Each plant is an object that includes its name, characteristics, and its image path. I want to show them in a v-for list.

What I've tried:

```<code><img v-bind:src="plant.img">
</code>```

and this:

```<code><img v-bind:src="'./../../assets/plants/' + plant.name + '.jpg'">
</code>```

Neither showed the image.

But when I put the image path, like this:

```<code><img src="./../../assets/plants/rose.jpg">
</code>```

It shows.

It's not v-for error too.
What's wrong with my code?

```<code>data() {
return {
  plants: [
    { name: 'Rose', sun: 4, water: 6, care: 5, img: "./../../assets/plants/rose.jpg" },
    { name: 'Mint', sun: 8, water: 3, care: 4, img: "./../../assets/plants/mint.jpg" },
    { name: 'Thyme', sun: 7, water: 4, care: 3, img: "./../../assets/plants/thyme.jpg" },
    { name: 'Oregano', sun: 4, water: 6, care: 5, img: "./../../assets/plants/oregano.jpg" },
    { name: 'Lavanda', sun: 8, water: 3, care: 4, img: "./../../assets/plants/lavanda.jpg" },
    { name: 'Patchouli', sun: 7, water: 4, care: 3, img: "./../../assets/plants/patchouli.jpg" },
  ]
}};
</code>```

答:
Hi Try this one maybe its a webpack issue

```<code><img :src="getSrc(plant.name)" v-bind:alt="pic">
</code>```

And add to methods.

```<code>methods: {
    getSrc(name) {
        var images = require.context('../../assets/plants/', false, /\.jpg$/);
        return images('./' + name + ".jpg")
    }
}
</code>```

https://jsfiddle.net/khenxi/vcf57d0f/

Title: Vue.js v-bind:src of an <img> element doesn't showing the image

Body:
I have an array of plants. Each plant is an object that includes its name, characteristics, and its image path. I want to show them in a v-for list.

What I've tried:

and this:

Neither showed the image.

But when I put the image path, like this:

It shows.

It's not v-for error too.
What's wrong with my code?

data() {
return {
  plants: [
    { name: 'Rose', sun: 4, water: 6, care: 5, img: "./../../assets/plants/rose.jpg" },
    { name: 'Mint', sun: 8, water: 3, care: 4, img: "./../../assets/plants/mint.jpg" },
    { name: 'Thyme', sun: 7, water: 4, care: 3, img: "./../../assets/plants/thyme.jpg" },
    { name: 'Oregano', sun: 4, water: 6, care: 5, img: "./../../assets/plants/oregano.jpg" },
    { name: 'Lavanda', sun: 8, water: 3, care: 4, img: "./../../assets/plants/lavanda.jpg" },
    { name: 'Patchouli', sun: 7, water: 4, care: 3, img: "./../../assets/plants/patchouli.jpg" },
  ]
}};

Body:
Hi Try this one maybe its a webpack issue

<img :src="getSrc(plant.name)" v-bind:alt="pic">

And add to methods.

methods: {
    getSrc(name) {
        var images = require.context('../../assets/plants/', false, /\.jpg$/);
        return images('./' + name + ".jpg")
    }
}

https://jsfiddle.net/khenxi/vcf57d0f/


问:
Text gets cut off when pinching/scaling/resizing UITtextView
I have a UITextView that can be scaled, rotated and resized using gestures inside a UIImageView.
When I scale or resize it and then type in some text, the text container changes size and the text gets cut off.
I tried changing the size of the text to resize it to fit the container. I also tried changing the container frame inside the textView but it didn't work.
Can anyone help me please?

Here are some images to help out to see what is happening visually.

Normal Image:

https://ibb.co/eAz3Lv

Irregular Image:

https://ibb.co/g932DF

Thank you for your help highly appreciated.

答:
I finally found the solution!
I put my UITextView inside a UIView and it works properly right now.</p>


问:
a large scale java project solution
I would like to start up a project from scratch. I am a java developer for years. I did even write my own mvc framework some time ago for fun. Now I am working in a company using in-house framework - which i think is a total loss of time and money. I respect the idea of  teaming up with different skilled people for a large scale project. The separation of the project is very important; Graphics guys, front end developers, software architectures, software developers, database experts, etc. I cannot risk to use a scripting language like php.

Lately, I am researching java technologies for a large scale project in every aspects. What I mean by that, for the front layer I come across with very famous technologies.

Spring

MyFaces

Tapestry

Google Web Toolkit

Cocoon

Velocity

Every one of them states that it is the simplest, the fastest, the latest technology and whatsoever. Of course only one them can hold the truth. I need a front end technology for fast implementation for ajax, customer/administrator security, themes, templates, internationalization, caching static pages, clustering and a support of ejb. It should also have IDE support, community support, rich documentation and online tutorials. Still I have no experience of those frameworks which to choose from. Maybe there is even better one? And most importantly, I cannot risk to start up on a technology which has development limitations. Is there any suggestions for this layer?

For the business layer, I am sure of EJB and JPA. I do even considering a web service for facade of this layer for interoperability purposes for future extensions. However, I have no idea about securing that layer (it could be applied on its web service level) which is still a problem for me. For the application server I am considering GlassFish.

And for the last question is what IDE should be picked for development. Regarding all the technologies, which are going to be used, an IDE should help me in every step, either doing the configuration for me or helping me configuring with its ready wizards. I suppose the IDE will have proper plugins for to be used technologies.

I know that I want too much, however I have a hope for a combination of technologies which will help me saving time and money in my future plans.

I ll be really glad to hear your responses, experiences for a bigger picture.

edited: There is no ultimate answer, I know that. I am just taking advice. Any answer is appreciated.

答:
All of the above projects started off with simple ideas.  As they gained traction, they have all added neighboring features which are useful to some but not necessarily all.  In other words, you will have to do deep analysis to pick the perfect framework.

You are not going to find a perfect match unless you just happen to be of like mind as the dozens of people working on the particular framework, assuming that all those minds were ever in perfect agreement.  The only "perfect" fit is the one you write yourself, and even then you find it's not perfect as you are limited in time and effort on developing the framework; after all, you DO have a program to write, and the framework development time competes with the program development time.

As far as IDEs go, there's differences in taste and style.  I tend to gravitate between the old standbys of Netbeans and Eclipse, and my next IDE to play with will be IntelliJ Idea.  The thing to remember is that most people commit to one IDE and then defame the rest, so you really can't get a good comparison.  IDEs take too much time to really learn for a person to give a honest unbiased opinion.  A good candidate IDE "X" will be the worst in some eyes and be the best in others.

ContentLicense: CC BY-SA 2.5

Title: a large scale java project solution


问:
Working on rails, i have text fields and text areas to receive text, but it shows the validation error "Topic cannot be empty"
After typing in topic and details in the appropriate text field and area, it still shows "validation error" "Topic cannot be empty". what is the problem? I cannot seem to figure it out.

```<code>This is the task partial
_task.html.erb:

 <li id="task-<%= task.id %>">
      <%= link_to gravatar_for(task.user, size: 50), task.user %>
      <span class="task"><%= link_to task.user.name, task.user %></span>
      <span class="topiclabel">Title:</span>
      <span class="topic"style=color:black> <%= task.topic %></span>
      <span class="detailslabel">Details: </span>
      <span class="detail"><%= task.detail %></span>
      <span class="timestamp">
        Posted <%= time_ago_in_words(task.created_at) %> ago.
      </span>
</li>

Schema:

ActiveRecord::Schema.define(version: 20170526194708) do

  create_table "stages", force: :cascade do |t|
    t.text     "topic"
    t.datetime "duration"
    t.text     "detail"
    t.integer  "task_id"
    t.integer  "user_id"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.index ["task_id"], name: "index_stages_on_task_id"
    t.index ["user_id", "created_at"], name: "index_stages_on_user_id_and_created_at"
    t.index ["user_id"], name: "index_stages_on_user_id"
  end

  create_table "tasks", force: :cascade do |t|
    t.text     "topic"
    t.integer  "member"
    t.text     "detail"
    t.integer  "user_id"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.index ["user_id", "created_at"], name: "index_tasks_on_user_id_and_created_at"
    t.index ["user_id"], name: "index_tasks_on_user_id"
  end

routes.rb:

 resources :tasks,          only: [:create, :destroy]

task.rb
class Task < ApplicationRecord
  belongs_to :user
  has_many :stages
  default_scope -> { order(created_at: :desc) }
   validates :user_id, presence: true
   validates :topic, presence: true, length: { maximum: 140 }
   validates :detail, presence: true, length: { maximum: 140 }

end
</code>```

Project_pages_controller.rb:

```<code>def home
    if logged_in?
      @task = current_user.tasks.build
end

_task_form.html.erb:

<%= form_for(@task) do |f| %>
  <%= render 'shared/error_messages', object: f.object %>
  <div class="field">
    <%= f.text_field :topic, placeholder: "Compose new task..." %>
    <%= f.text_area :detail, placeholder: "Write task details..." %>
  </div>
  <%= f.submit "Post", class: "btn btn-primary" %>
<% end %>

This is the show page
</code>```

show.html.erb

```<code>  <div class="col-md-8">
    <% if @user.tasks.any? %>
      <% if @user.stages.any? %>
      <h3>Tasks (<%= @user.tasks.count %>)</h3>
      <ol class="tasks">
        <%= render @tasks %>
        <%= render @stages %>
      </ol>
      <%= will_paginate @tasks %>
       <% end %>
    <% end %>
  </div>
</code>```

This is my controller;

```<code>class TasksController < ApplicationController
    include TasksHelper
  before_action :logged_in_user, only: [:create, :destroy]

  def create
    @task = current_user.tasks.build(task_params)
    if @task.save
      flash[:success] = "Task created!"
      redirect_to root_url
    else
      @feed_items = []
      render 'workshareapp_pages/home'
    end
  end

  def destroy
  end

  private

    def task_params
      params.require(:task).permit(:detail)
    end

end
</code>```

答: It's probably a validation in your model Task.</p>

Body:
After typing in topic and details in the appropriate text field and area, it still shows "validation error" "Topic cannot be empty". what is the problem? I cannot seem to figure it out.

This is the task partial
_task.html.erb:

 <li id="task-<%= task.id %>">
      <%= link_to gravatar_for(task.user, size: 50), task.user %>
      <%= link_to task.user.name, task.user %>
      Title:
       <%= task.topic %>
      Details:
      <%= task.detail %>

        Posted <%= time_ago_in_words(task.created_at) %> ago.

Schema:

ActiveRecord::Schema.define(version: 20170526194708) do

  create_table "stages", force: :cascade do |t|
    t.text     "topic"
    t.datetime "duration"
    t.text     "detail"
    t.integer  "task_id"
    t.integer  "user_id"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.index ["task_id"], name: "index_stages_on_task_id"
    t.index ["user_id", "created_at"], name: "index_stages_on_user_id_and_created_at"
    t.index ["user_id"], name: "index_stages_on_user_id"
  end

  create_table "tasks", force: :cascade do |t|
    t.text     "topic"
    t.integer  "member"
    t.text     "detail"
    t.integer  "user_id"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.index ["user_id", "created_at"], name: "index_tasks_on_user_id_and_created_at"
    t.index ["user_id"], name: "index_tasks_on_user_id"
  end

routes.rb:

 resources :tasks,          only: [:create, :destroy]

task.rb
class Task < ApplicationRecord
  belongs_to :user
  has_many :stages
  default_scope -> { order(created_at: :desc) }
   validates :user_id, presence: true
   validates :topic, presence: true, length: { maximum: 140 }
   validates :detail, presence: true, length: { maximum: 140 }

end

Project_pages_controller.rb:

def home
    if logged_in?
      @task = current_user.tasks.build
end

_task_form.html.erb:

<%= form_for(@task) do |f| %>
  <%= render 'shared/error_messages', object: f.object %>

    <%= f.text_field :topic, placeholder: "Compose new task..." %>
    <%= f.text_area :detail, placeholder: "Write task details..." %>

  <%= f.submit "Post", class: "btn btn-primary" %>
<% end %>

This is the show page

show.html.erb

    <% if @user.tasks.any? %>
      <% if @user.stages.any? %>

Tasks (<%= @user.tasks.count %>)

        <%= render @tasks %>
        <%= render @stages %>

      <%= will_paginate @tasks %>
       <% end %>
    <% end %>

This is my controller;

class TasksController < ApplicationController
    include TasksHelper
  before_action :logged_in_user, only: [:create, :destroy]

  def create
    @task = current_user.tasks.build(task_params)
    if @task.save
      flash[:success] = "Task created!"
      redirect_to root_url
    else
      @feed_items = []
      render 'workshareapp_pages/home'
    end
  end

  def destroy
  end

  private

    def task_params
      params.require(:task).permit(:detail)
    end

end


问:
Issue with refactoring of a switch statement
Here is the method that performs the switch(Note The switch statement works correctly and according to the requirements)

```<code>public void performChecks() {
        priceInput = priceReader.nextDouble();
       loop: while(true){
           nameInput = nameReader.nextLine();
            switch(nameInput){
                case "A1": Cola colaItem = new Cola();
                                    if(colaItem.checkPrice(priceInput)){
                                            System.out.println("You ordered " + colaItem.getName()+ ", here is it");
                                    } else {
                                            System.out.println("Sorry, the amount is not enough for this purchase. Please add more money and try again");
                                    }
                                    break loop;

                case "B2": Chips chipsItem = new Chips();
                                    if(chipsItem.checkPrice(priceInput)){
                                        System.out.println("You ordered " + chipsItem.getName()+ ", here is it");
                                    } else {
                                        System.out.println("Sorry, the amount is not enough for this purchase. Please add more money and try again");
                                    }
                                    break loop;

                case "C3": Crackers crackerItem = new Crackers();
                                    if(crackerItem.checkPrice(priceInput)){
                                        System.out.println("You ordered " + crackerItem.getName()+ ", here is it");
                                    } else {
                                        System.out.println("Sorry, the amount is not enough for this purchase. Please add more money and try again");
                                    }
                                        break loop;
                default:
                    System.out.println("Sorry, we don't have item with such a code");
            }
        }
     }
</code>```

Now I started doing some refactoring and put the method in the super class of the items(Cola, Chips and Crackers) and it looks like this:

```<code>public void performChecks(){
    inputPrice = priceReader.nextDouble();
    inputCode = codeReader.nextLine();
    initializeItems();
    for(int i = 0; i < items.length; i++){
        if(items[i].checkCode(inputCode)){
                if(items[i].checkPrice(inputPrice)){
                    System.out.println("You ordered " + items[i].getName() + " here it is");
                    break;
                } else {
                    System.out.println("Sorry, the amount is not enough for this purchase. Please add more money and try again");
                    break;
                }
        } else if(!items[i].checkCode(inputCode)){
            continue;
        } else {
            System.out.println("Sorry, we don't have item with such a code");
            inputCode = codeReader.nextLine();
        }
    }
}
</code>```

The issue is the following: When I enter correct/incorrect price and incorrect item code, I should be getting the "Sorry, we don't have an item with such a code" message and the option to enter the item code again. I've ran out of ideas on how to implement this option inside the

```<code>else if(!items[i].checkCode(inputCode)){
                continue;
</code>```

Since I'm pretty sure, it just gets stuck there and returns nothing(for incorrect item code).

答:
What you are trying to achieve can be solved with a simple "found" boolean. Like this: </p>

```<code>boolean found = false;
for(Item item : items) {
    if(item.checkCode(inputCode)){
        found = true;
        [...] // Here you found the item and you can check the price and other stuff
    }
}
if(!found) {
    [...] // Here you can handle the case of the incorrect code
}
</code>```

Body:
Here is the method that performs the switch(Note The switch statement works correctly and according to the requirements)

public void performChecks() {
        priceInput = priceReader.nextDouble();
       loop: while(true){
           nameInput = nameReader.nextLine();
            switch(nameInput){
                case "A1": Cola colaItem = new Cola();
                                    if(colaItem.checkPrice(priceInput)){
                                            System.out.println("You ordered " + colaItem.getName()+ ", here is it");
                                    } else {
                                            System.out.println("Sorry, the amount is not enough for this purchase. Please add more money and try again");
                                    }
                                    break loop;

                case "B2": Chips chipsItem = new Chips();
                                    if(chipsItem.checkPrice(priceInput)){
                                        System.out.println("You ordered " + chipsItem.getName()+ ", here is it");
                                    } else {
                                        System.out.println("Sorry, the amount is not enough for this purchase. Please add more money and try again");
                                    }
                                    break loop;

                case "C3": Crackers crackerItem = new Crackers();
                                    if(crackerItem.checkPrice(priceInput)){
                                        System.out.println("You ordered " + crackerItem.getName()+ ", here is it");
                                    } else {
                                        System.out.println("Sorry, the amount is not enough for this purchase. Please add more money and try again");
                                    }
                                        break loop;
                default:
                    System.out.println("Sorry, we don't have item with such a code");
            }
        }
     }

Now I started doing some refactoring and put the method in the super class of the items(Cola, Chips and Crackers) and it looks like this:

public void performChecks(){
    inputPrice = priceReader.nextDouble();
    inputCode = codeReader.nextLine();
    initializeItems();
    for(int i = 0; i < items.length; i++){
        if(items[i].checkCode(inputCode)){
                if(items[i].checkPrice(inputPrice)){
                    System.out.println("You ordered " + items[i].getName() + " here it is");
                    break;
                } else {
                    System.out.println("Sorry, the amount is not enough for this purchase. Please add more money and try again");
                    break;
                }
        } else if(!items[i].checkCode(inputCode)){
            continue;
        } else {
            System.out.println("Sorry, we don't have item with such a code");
            inputCode = codeReader.nextLine();
        }
    }
}

The issue is the following: When I enter correct/incorrect price and incorrect item code, I should be getting the "Sorry, we don't have an item with such a code" message and the option to enter the item code again. I've ran out of ideas on how to implement this option inside the

else if(!items[i].checkCode(inputCode)){
                continue;

Since I'm pretty sure, it just gets stuck there and returns nothing(for incorrect item code).

Body:
What you are trying to achieve can be solved with a simple "found" boolean. Like this:

boolean found = false;
for(Item item : items) {
    if(item.checkCode(inputCode)){
        found = true;
        [...] // Here you found the item and you can check the price and other stuff
    }
}
if(!found) {
    [...] // Here you can handle the case of the incorrect code
}


问:
Can not see the MobileFirst Operations Console via browser
After installed the develop kit (version 8), I start the console via the script run.sh. However, I couldn't see the details after log on, just like the picture attached.the screen just like that</p>

答: This issue is fixed in the latest ifix that is released on 2017/06/06. Please apply the latest ifix</p>


问:
Do you recommend using semicolons after every statement in JavaScript?
In many situations, JavaScript parsers will insert semicolons for you if you leave them out. My question is, do you leave them out?

If you're unfamiliar with the rules, there's a description of semicolon insertion on the Mozilla site. Here's the key point:

If the first through the nth tokens of a JavaScript program form are grammatically valid but the first through the n+1st tokens are not and there is a line break between the nth tokens and the n+1st tokens, then the parser tries to parse the program again after inserting a virtual semicolon token between the nth and the n+1st tokens.

That description may be incomplete, because it doesn't explain @Dreas's example. Anybody have a link to the complete rules, or see why the example gets a semicolon? (I tried it in JScript.NET.)

This stackoverflow question is related, but only talks about a specific scenario.

答: Yes, you should use semicolons after every statement in JavaScript.</p>

OwnerDisplayName: anon

LastEditorDisplayName: anon


问:
Is there any ActionScript 3 to JavaScript (and vice versa) migration guide?
as a skilled AS3 developer I wonder if there is something like AS3 to JS migration guide. After all both languages have a lot in common.

I have in mind something like the old AS2 to AS3 migration guide - a list where I could simply look up the AS3 functionality and the JS counterpart, or vice versa.

I am not saying you can easily convert all your code like that but it would tell me where to start.

PS: I think it is a great idea and if such guide doesn't exist someone should write one :).

答:
I've read that with Haxe you can compile somewhat transparently to JS code. This requires Haxe code, I think, which is not ActionScript 3.0 but is close and should be easy to pick up if you're already comfortable with AS.

I haven't tried this myself but it's probably worth to check out. Here's a blog post that might give you some ideas: http://gamehaxe.com/2010/05/25/javascript-ready-or-not/

ContentLicense: CC BY-SA 4.0


问:
Nested classes inside a class cannot acces varibale from each other
Please take a look at the following snippet. You can understand what I am trying to do. The vlan_start of PairTwo class must be derived from the values of PortOne. How do I do that?

```<code>>>> class G8032:
...     class PairOne:
...         vlan_start = 1101
...         vlan_count = 600
...     class PairTwo:
...         vlan_start = G8032.PairOne.vlan_start + G8032.PairOne.vlan_count
...         vlan_count = 400
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 5, in G8032
  File "<stdin>", line 6, in PairTwo
NameError: name 'G8032' is not defined
>>>
</code>```

EDIT:
I have tried without G8032 in G8032.PairOne.vlan_***. it still doesn't work.

答:
If you need the mentioned syntax, you could use this:</p>

```<code>class G8032:
    PairOne = type('PairOne', (object,), dict({'vlan_start': 1101, 'vlan_count': 600}))
    PairTwo = type('PairTwo', (object,), dict({'vlan_start': PairOne.vlan_start + PairOne.vlan_count, 'vlan_count': 400 }))

print (G8032.PairOne.vlan_start)
>>> 1101
</code>```

Body:
Please take a look at the following snippet. You can understand what I am trying to do. The vlan_start of PairTwo class must be derived from the values of PortOne. How do I do that?

>>> class G8032:
...     class PairOne:
...         vlan_start = 1101
...         vlan_count = 600
...     class PairTwo:
...         vlan_start = G8032.PairOne.vlan_start + G8032.PairOne.vlan_count
...         vlan_count = 400
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 5, in G8032
  File "<stdin>", line 6, in PairTwo
NameError: name 'G8032' is not defined
>>>

EDIT:
I have tried without G8032 in G8032.PairOne.vlan_***. it still doesn't work.

Body:
If you need the mentioned syntax, you could use this:

class G8032:
    PairOne = type('PairOne', (object,), dict({'vlan_start': 1101, 'vlan_count': 600}))
    PairTwo = type('PairTwo', (object,), dict({'vlan_start': PairOne.vlan_start + PairOne.vlan_count, 'vlan_count': 400 }))

print (G8032.PairOne.vlan_start)
>>> 1101


问:
Gradle Build doesnt find Java source code
I am trying to follow the HelloWorld tutorial for Gradle given by Spring but the Build step is not working - when I run Gradle Build I just see the message, NO-SOURCE for the :compileJava step.
I saw on another question that you should add the sourceSets tag into the gradle.build file. I tried this as well and it still doesnt find my Java source files.

I have organised my Java source following the instructions and
placed the code inside directory structure,

=>src-main-java-hello ("HelloWorld.java, Greeter.java").

I am using Java8 and Gradle 3.5

Can anyone help please ? - seems a really basic problem I must be having.

答: You are defining srcDirs = ['src'] in build.gradle but then using src/main/java as your source directory. Since src/main/java is the (very sensible) default source directory, you can remove your sourceSets { ... } configuration all together.


问:
Android Architecture Components Lifecycle state
https://developer.android.com/reference/android/arch/lifecycle/Lifecycle.State.html

STARTED
  Lifecycle.State STARTED
  For an Activity, this state is reached in two cases: after onStart
  call; right before onPause call.

As the above documentation says, I couldn't understand the rationale behind the STARTED state right before onPause call. Can someone please explain that?

答:
Notice that the values in the Lifecycle.State enum do not include a PAUSED state. There are only five states: CREATED, DESTROYED, INITIALIZED, RESUMED, STARTED. These do not exactly correspond with the normal Activity lifecycle that we all know and love:

Also note the following from the Lifecycle class documentation:

ON_CREATE, ON_START, ON_RESUME events in this class are dispatched after the LifecycleOwner's related method returns.
   ON_PAUSE, ON_STOP, ON_DESTROY events in this class are dispatched before the LifecycleOwner's related method is called

The execution of the onPause() is the closing boundary for the RESUMED state.  At this point, the Activity is no longer considered RESUMED and it is certainly not DESTROYED. Since we don't have a PAUSED state it follows it must now be in the STARTED state. This is technically true, the Activity hasn't yet stopped but it is no longer resumed.


问:
Laravel logs user out randomly
I have a problem with the login session for my laravel project. Login is using the normal Laravel scaffolding and it seems to be working just fine. Once logged in the user is served a single-page application that talks to the backend through Ajax.

But the user gets logged out after just a few minutes. Which kind of breaks the single-page app, since the user is building stuff in it and then is rendered unable to save because of being logged out.

In Laravel's session.php 'lifetime' is set to 120 minutes. And I'm using Auth middleware to protect the routes now. It seems to be a problem there. When calling a protected  route trough ajax the user gets the message "Unauthorized". And when the page is reloaded the user is logged out.

This is the handle function in the auth middleware

```<code>public function handle($request, Closure $next)
    {
        if ($this->auth->guest()) {
            if ($request->ajax()) {
                return response('Unauthorized.', 401);
            } else {
                return redirect()->guest('auth/login');
            }
        }

        return $next($request);
    }
</code>```

Any ideas what this could be?

答:
Set

```<code>   'lifetime' => 120, // number of minutes that you wish the session to be allowed to remain idle before it expires.

        'expire_on_close' => true,
</code>```

in session.php found in config folder

Title: Laravel logs user out randomly

Body:
I have a problem with the login session for my laravel project. Login is using the normal Laravel scaffolding and it seems to be working just fine. Once logged in the user is served a single-page application that talks to the backend through Ajax.

But the user gets logged out after just a few minutes. Which kind of breaks the single-page app, since the user is building stuff in it and then is rendered unable to save because of being logged out.

In Laravel's session.php 'lifetime' is set to 120 minutes. And I'm using Auth middleware to protect the routes now. It seems to be a problem there. When calling a protected  route trough ajax the user gets the message "Unauthorized". And when the page is reloaded the user is logged out.

This is the handle function in the auth middleware

public function handle($request, Closure $next)
    {
        if ($this->auth->guest()) {
            if ($request->ajax()) {
                return response('Unauthorized.', 401);
            } else {
                return redirect()->guest('auth/login');
            }
        }

        return $next($request);
    }

Any ideas what this could be?

Body:
Set

   'lifetime' => 120, // number of minutes that you wish the session to be allowed to remain idle before it expires.

        'expire_on_close' => true,

in session.php found in config folder


问:
Can we apply custom shaders to three.js objects dynamically
I have a MeshBasicMaterial with VideoTexture. Can I apply custom shaders to the material dynamically. I was able to apply shader to the complete scene using THREE.EffectComposer but what if I want to apply custom filters to a specific element inside the scene. I want to test simple filters like sepia, hue-saturation. Also I must be able to switch between the two without reloading the project.

I did not go with js libraries like seriously.js or glfx.js because it may cause problem at later stages when I will work with three.js objects not having canvas/img/video as map.

```<code>videoTexture = new THREE.VideoTexture(video);
videoTexture.minFilter = THREE.LinearFilter;
videoTexture.magFilter = THREE.LinearFilter;
material = new THREE.MeshBasicMaterial({
    map: videoTexture,
    side: THREE.DoubleSide,
    transparent: true,
    depthTest: false,
    depthWrite: false
});

composer = new THREE.EffectComposer( renderer );
composer.addPass( new THREE.RenderPass( scene, camera ) );
var effect = new THREE.ShaderPass( THREE.SepiaShader );
effect.renderToScreen = true;
composer.addPass( effect );
composer.render();
</code>```

Edit 1: filter css( https://developer.mozilla.org/en-US/docs/Web/CSS/filter) won't work either as it only changes visual media and hence though it can manipulate final canvas it can not manipulate internal object textures.

答:
<s>THREE.EffectComposer has a .reset function that you could use to wipe it, and then add the new filters you want. So just load the different filters you want to cycle through into an array, then reset and add passes from that array.</s>

EDIT I thought you were talking about changing shaders in the composer. To change shaders on an object, you can create multiple shadermaterials with different shaders but referencing the same texture, and swap the materials out on the object. So you can write a shader that reinterprets the texture colorspace to sepia, one that reinterprets the texture colorspace to bnw, or swizzles hue and saturation with r,g, or b.

Then you swap multiple materials out on the fly. These effects are basic glsl, but if you have trouble writing the shaders, just post another thread with specific problems. If you're a glsl novice, I highly recommend  the book of shaders. It's a great, fast, interactive crash course on glsl.

But the solution to your problem is to create multiple shadermaterials, or create one shader material that does everything and then use uniforms to enable/lerp between the different effects.

Body:
I have a MeshBasicMaterial with VideoTexture. Can I apply custom shaders to the material dynamically. I was able to apply shader to the complete scene using THREE.EffectComposer but what if I want to apply custom filters to a specific element inside the scene. I want to test simple filters like sepia, hue-saturation. Also I must be able to switch between the two without reloading the project.

I did not go with js libraries like seriously.js or glfx.js because it may cause problem at later stages when I will work with three.js objects not having canvas/img/video as map.

videoTexture = new THREE.VideoTexture(video);
videoTexture.minFilter = THREE.LinearFilter;
videoTexture.magFilter = THREE.LinearFilter;
material = new THREE.MeshBasicMaterial({
    map: videoTexture,
    side: THREE.DoubleSide,
    transparent: true,
    depthTest: false,
    depthWrite: false
});

composer = new THREE.EffectComposer( renderer );
composer.addPass( new THREE.RenderPass( scene, camera ) );
var effect = new THREE.ShaderPass( THREE.SepiaShader );
effect.renderToScreen = true;
composer.addPass( effect );
composer.render();

Edit 1: filter css( https://developer.mozilla.org/en-US/docs/Web/CSS/filter) won't work either as it only changes visual media and hence though it can manipulate final canvas it can not manipulate internal object textures.


问:
How to append text to array value JavaScript
I have two javascript array like this.

```<code>var category = ['Jacket'];
var subcategory = ['Woman', 'Men', 'Kids'];
</code>```

and i want combining array value like this

```<code>var finalCategory = ['Jacket Woman', 'Jacket Men', 'Jacket Kids'];
</code>```

if category more than one, final result

```<code>var category = ['Jacket', 'Bags'];
var subcategory = ['Woman', 'Men', 'Kids'];
var finalCategory = ['Jacket Woman', 'Jacket Men', 'Jacket Kids', 'Bags Woman', 'Bags Men', 'Bags Kids'];
</code>```

Please help, thank you.

答:
```<code>var category = ['Jacket', 'Bags'];
var subcategory = ['Woman', 'Men', 'Kids'];
var finalCategory = []

for(var i = 0; i < category.length; i++){
    for(var ii = 0; ii < subcategory.length; ii++){
        finalCategory.push(category[i] + ' ' + subcategory[ii])
    }
}
console.log(finalCategory)
</code>```

Nested loop. One covering all main categorys, then covering sub categories within it.

Body:
I have two javascript array like this.

var category = ['Jacket'];
var subcategory = ['Woman', 'Men', 'Kids'];

and i want combining array value like this

var finalCategory = ['Jacket Woman', 'Jacket Men', 'Jacket Kids'];

if category more than one, final result

var category = ['Jacket', 'Bags'];
var subcategory = ['Woman', 'Men', 'Kids'];
var finalCategory = ['Jacket Woman', 'Jacket Men', 'Jacket Kids', 'Bags Woman', 'Bags Men', 'Bags Kids'];

Please help, thank you.

Body:
var category = ['Jacket', 'Bags'];
var subcategory = ['Woman', 'Men', 'Kids'];
var finalCategory = []

for(var i = 0; i < category.length; i++){
    for(var ii = 0; ii < subcategory.length; ii++){
        finalCategory.push(category[i] + ' ' + subcategory[ii])
    }
}
console.log(finalCategory)

Nested loop. One covering all main categorys, then covering sub categories within it.


问:
Hbase connection about zookeeper error
Environment :  Ubuntu 14.04 , hadoop-2.2.0 , hbase-0.98.7

when i start hadoop and hbase(single node mode), both all success (I also check the website 8088 for hadoop, 60010 for hbase)

```<code>jps
4507 SecondaryNameNode
5350 HRegionServer
4197 NameNode
4795 NodeManager
3948 QuorumPeerMain
5209 HMaster
4678 ResourceManager
5831 Jps
4310 DataNode
</code>```

but when i check hbase-hadoop-master-localhost.log, i found a information following

```<code>    2014-10-23 14:16:11,392 INFO  [main-SendThread(localhost:2181)] zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2014-10-23 14:16:11,426 INFO  [main-SendThread(localhost:2181)] zookeeper.ClientCnxn: Socket connection established to localhost/127.0.0.1:2181, initiating session
</code>```

i have google lot of website for that unknown error problem, but i can't solve this problem...
Following is my hadoop and hbase configuration

Hadoop :

salves content : localhost

core-site.xml

```<code><configuration>
    <property>
         <name>fs.defaultFS</name>
         <value>hdfs://localhost:8020</value>
     </property>
</configuration>
</code>```

yarn-site.xml

```<code><configuration>
  <property>
    <name>yarn.resourcemanager.resource-tracker.address</name>
    <value>localhost:9001</value>
    <description>host is the hostname of the resource manager and
    port is the port on which the NodeManagers contact the Resource Manager.
    </description>
  </property>

  <property>
    <name>yarn.resourcemanager.scheduler.address</name>
    <value>localhost:9002</value>
    <description>host is the hostname of the resourcemanager and port is the port
    on which the Applications in the cluster talk to the Resource Manager.
    </description>
  </property>

  <property>
    <name>yarn.resourcemanager.scheduler.class</name>
    <value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler</value>
    <description>In case you do not want to use the default scheduler</description>
  </property>

  <property>
    <name>yarn.resourcemanager.address</name>
    <value>localhost:9003</value>
    <description>the host is the hostname of the ResourceManager and the port is the port on
    which the clients can talk to the Resource Manager. </description>
  </property>

  <property>
    <name>yarn.nodemanager.local-dirs</name>
    <value></value>
    <description>the local directories used by the nodemanager</description>
  </property>

  <property>
    <name>yarn.nodemanager.address</name>
    <value>localhost:9004</value>
    <description>the nodemanagers bind to this port</description>
  </property>

  <property>
    <name>yarn.nodemanager.resource.memory-mb</name>
    <value>10240</value>
    <description>the amount of memory on the NodeManager in GB</description>
  </property>

  <property>
    <name>yarn.nodemanager.remote-app-log-dir</name>
    <value>/app-logs</value>
    <description>directory on hdfs where the application logs are moved to </description>
  </property>

   <property>
    <name>yarn.nodemanager.log-dirs</name>
    <value></value>
    <description>the directories used by Nodemanagers as log directories</description>
  </property>

  <property>
    <name>yarn.nodemanager.aux-services</name>
    <value>mapreduce_shuffle</value>
    <description>shuffle service that needs to be set for Map Reduce to run </description>
  </property>
</configuration>
</code>```

Hbase:

hbase-env.sh :

```<code>..
export JAVA_HOME="/usr/lib/jvm/java-7-oracle"
..
export HBASE_MANAGES_ZK=true
..
</code>```

hbase-site.xml

```<code><configuration>
    <property>
        <name>hbase.rootdir</name>
        <value>hdfs://localhost:8020/hbase</value>
    </property>
    <property>
        <name>hbase.cluster.distributed</name>
        <value>true</value>
    </property>
    <property>
        <name>hbase.zookeeper.property.clientPort</name>
        <value>2181</value>
    </property>
</configuration>
</code>```

regionserver content : localhost

my /etc/hosts content:

```<code>127.0.0.1       localhost
#127.0.1.1      localhost

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
</code>```

I try lots of methods to solve it, but all fail, please help me to solve it, i really need to know how to solve.

Originally, i run a mapreuce program and when map 67% reduce 0%, it print out some INFO and some of INFO is following:

```<code>14/10/23 15:50:41 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=localhost:2181 sessionTimeout=60000 watcher=org.apache.hadoop.hbase.client.HConnectionManager$ClientZKWatcher@ce1472
14/10/23 15:50:41 INFO zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
14/10/23 15:50:41 INFO zookeeper.ClientCnxn: Socket connection established to localhost/127.0.0.1:2181, initiating session
14/10/23 15:50:41 INFO zookeeper.ClientCnxn: Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x1493be510380007, negotiated timeout = 40000
14/10/23 15:50:43 INFO mapred.LocalJobRunner: map > sort
14/10/23 15:50:46 INFO mapred.LocalJobRunner: map > sort
</code>```

then it crash.. I think program maybe in dead lock and that is what i want to solve zookeeper problem above.

If want another configuration file i set in hadoop or hbase or others, just tell me, i'll post up.
thanks!

答:
Add follwing properties in hbase-site.xml file

```<code> <property>
 <name>hbase.zookeeper.quorum</name>
 <value>192.168.56.101</value>                       #this is my server ip
 </property>
 <property>
 <name>hbase.zookeeper.property.clientPort</name>
 <value>2181</value>
 </property>
</code>```

restart ./start-hbase.sh

Title: Hbase connection about zookeeper error

Body:
Environment :  Ubuntu 14.04 , hadoop-2.2.0 , hbase-0.98.7

when i start hadoop and hbase(single node mode), both all success (I also check the website 8088 for hadoop, 60010 for hbase)

jps
4507 SecondaryNameNode
5350 HRegionServer
4197 NameNode
4795 NodeManager
3948 QuorumPeerMain
5209 HMaster
4678 ResourceManager
5831 Jps
4310 DataNode

but when i check hbase-hadoop-master-localhost.log, i found a information following

    2014-10-23 14:16:11,392 INFO  [main-SendThread(localhost:2181)] zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2014-10-23 14:16:11,426 INFO  [main-SendThread(localhost:2181)] zookeeper.ClientCnxn: Socket connection established to localhost/127.0.0.1:2181, initiating session

i have google lot of website for that unknown error problem, but i can't solve this problem...
Following is my hadoop and hbase configuration

Hadoop :

salves content : localhost

core-site.xml

<configuration>
    <property>
         <name>fs.defaultFS</name>
         <value>hdfs://localhost:8020</value>
     </property>
</configuration>

yarn-site.xml

<configuration>
  <property>
    <name>yarn.resourcemanager.resource-tracker.address</name>
    <value>localhost:9001</value>
    <description>host is the hostname of the resource manager and
    port is the port on which the NodeManagers contact the Resource Manager.
    </description>
  </property>

  <property>
    <name>yarn.resourcemanager.scheduler.address</name>
    <value>localhost:9002</value>
    <description>host is the hostname of the resourcemanager and port is the port
    on which the Applications in the cluster talk to the Resource Manager.
    </description>
  </property>

  <property>
    <name>yarn.resourcemanager.scheduler.class</name>
    <value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler</value>
    <description>In case you do not want to use the default scheduler</description>
  </property>

  <property>
    <name>yarn.resourcemanager.address</name>
    <value>localhost:9003</value>
    <description>the host is the hostname of the ResourceManager and the port is the port on
    which the clients can talk to the Resource Manager. </description>
  </property>

  <property>
    <name>yarn.nodemanager.local-dirs</name>
    <value></value>
    <description>the local directories used by the nodemanager</description>
  </property>

  <property>
    <name>yarn.nodemanager.address</name>
    <value>localhost:9004</value>
    <description>the nodemanagers bind to this port</description>
  </property>

  <property>
    <name>yarn.nodemanager.resource.memory-mb</name>
    <value>10240</value>
    <description>the amount of memory on the NodeManager in GB</description>
  </property>

  <property>
    <name>yarn.nodemanager.remote-app-log-dir</name>
    <value>/app-logs</value>
    <description>directory on hdfs where the application logs are moved to </description>
  </property>

   <property>
    <name>yarn.nodemanager.log-dirs</name>
    <value></value>
    <description>the directories used by Nodemanagers as log directories</description>
  </property>

  <property>
    <name>yarn.nodemanager.aux-services</name>
    <value>mapreduce_shuffle</value>
    <description>shuffle service that needs to be set for Map Reduce to run </description>
  </property>
</configuration>

Hbase:

hbase-env.sh :

..
export JAVA_HOME="/usr/lib/jvm/java-7-oracle"
..
export HBASE_MANAGES_ZK=true
..

hbase-site.xml

<configuration>
    <property>
        <name>hbase.rootdir</name>
        <value>hdfs://localhost:8020/hbase</value>
    </property>
    <property>
        <name>hbase.cluster.distributed</name>
        <value>true</value>
    </property>
    <property>
        <name>hbase.zookeeper.property.clientPort</name>
        <value>2181</value>
    </property>
</configuration>

regionserver content : localhost

my /etc/hosts content:

127.0.0.1       localhost
#127.0.1.1      localhost

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

I try lots of methods to solve it, but all fail, please help me to solve it, i really need to know how to solve.

Originally, i run a mapreuce program and when map 67% reduce 0%, it print out some INFO and some of INFO is following:

14/10/23 15:50:41 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=localhost:2181 sessionTimeout=60000 watcher=org.apache.hadoop.hbase.client.HConnectionManager$ClientZKWatcher@ce1472
14/10/23 15:50:41 INFO zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
14/10/23 15:50:41 INFO zookeeper.ClientCnxn: Socket connection established to localhost/127.0.0.1:2181, initiating session
14/10/23 15:50:41 INFO zookeeper.ClientCnxn: Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x1493be510380007, negotiated timeout = 40000
14/10/23 15:50:43 INFO mapred.LocalJobRunner: map > sort
14/10/23 15:50:46 INFO mapred.LocalJobRunner: map > sort

then it crash.. I think program maybe in dead lock and that is what i want to solve zookeeper problem above.

If want another configuration file i set in hadoop or hbase or others, just tell me, i'll post up.
thanks!

Body:
Add follwing properties in hbase-site.xml file

 <property>
 <name>hbase.zookeeper.quorum</name>
 <value>192.168.56.101</value>                       #this is my server ip
 </property>
 <property>
 <name>hbase.zookeeper.property.clientPort</name>
 <value>2181</value>
 </property>

restart ./start-hbase.sh


问:
Printing to logs the "conditon"
NEWEST UPDATE

package com.karanvir.again;

import android.os.AsyncTask;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class MainActivity extends AppCompatActivity {
    EditText city;
    Button go;
    TextView resultofw;
    String text;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        city=(EditText) findViewById(R.id.editText);
        go=(Button) findViewById(R.id.button);
        setSupportActionBar(toolbar);
        DownloadTask task=new DownloadTask();
        resultofw=(TextView) findViewById(R.id.textView);
        task.execute("http://api.apixu.com/v1/current.json?key=76d62bf509e64633a4970055170706&q="+city.toString());

    }

    public class DownloadTask extends AsyncTask<String,Void,String> {
        @Override
        protected String doInBackground(String... urls) {
            String result = "";
            URL url;
            HttpURLConnection urlConnection = null;
            try {
                url = new URL(urls[0]);
                urlConnection = (HttpURLConnection) url.openConnection();
                InputStream in = urlConnection.getInputStream();
                InputStreamReader reader = new InputStreamReader(in);
                int data = reader.read();
                while (data != -1) {
                    char current = (char) data;
                    result += current;
                    data = reader.read();
                }
                return result;

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

        @Override
        protected void onPostExecute(String result) {
            super.onPostExecute(result);
//conver result into json object
            try{
                JSONObject jsonObject=new JSONObject(result);

                //get current JSONObject from result JSONObject
                JSONObject currentJSONObject = jsonObject.getJSONObject("current");

                //Now get condition JSONObject from current JSONObject
                JSONObject conditionJSONObject = currentJSONObject.getJSONObject("condition");
                text = conditionJSONObject.getString("text");

                //Now print condition JSONObject
                Log.i("website content", "condition json object : " + text.toString());
                JSONArray arr= new JSONArray(conditionJSONObject.toString());

            } catch (Exception e){

            }

        }
    }

public  void click(View view){

    resultofw.setText(text);

}

}```
</div>
</div>
</p>

<p>SO how can i fix this aswell, im tryng to add the strings to the array. and then pull out what is said after "text"</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>//conver result into json object
            try{
                JSONObject jsonObject=new JSONObject(result);

                //get current JSONObject from result JSONObject
                JSONObject currentJSONObject = jsonObject.getJSONObject("current");

                //Now get condition JSONObject from current JSONObject
                JSONObject conditionJSONObject = currentJSONObject.getJSONObject("condition");

                //Now print condition JSONObject
                Log.i("website content", "condition json object : " + conditionJSONObject.toString());
                JSONArray arr= new JSONArray(conditionJSONObject.toString());

                for(int i=0;i<arr.length();i++){
                    JSONObject jsonpart= arr.getJSONObject(i);
                    Log.i("Part",jsonpart.getString("text"));
                }</code>```

What im trying to do is print everything after ""condition":{"text":"Partly cloudy","icon":"//cdn.apixu.com/weather/64x64/day/116.png","code":1003},"wind_mph":15.0,"wind_kph":24.1,"wind_degree":240,"wind_dir":"WSW","pressure_mb":1016.0,"pressure_in":30.5,"precip_mm":0.0,"precip_in":0.0,"humidity":71,"cloud":50,"feelslike_c":9.6,"feelslike_f":49.2,"vis_km":10.0,"vis_miles":6.0}}" To my logs, im using JSONG to process the data from this site:http://api.apixu.com/v1/current.json?key=76d62bf509e64633a4970055170706&q=Paris
Its not appearing in my logcat, please help AND YES I HAVE INCLUDED USES PERMISSION IN MY MENIFEST

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.karanvir.again.MainActivity">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </RelativeLayout>

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_main" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        app:srcCompat="@android:drawable/ic_dialog_email" />

</android.support.design.widget.CoordinatorLayout>```
<pre class="snippet-code-css lang-css prettyprint-override"><code>06-07 01:42:19.594 20523-20523/com.karanvir.again E/Zygote: v2
06-07 01:42:19.594 20523-20523/com.karanvir.again I/libpersona: KNOX_SDCARD checking this for 10291
06-07 01:42:19.594 20523-20523/com.karanvir.again I/libpersona: KNOX_SDCARD not a persona
06-07 01:42:19.594 20523-20523/com.karanvir.again I/SELinux: Function: selinux_compare_spd_ram, index[1], SPD-policy is existed. and_ver=SEPF_SM-G870W_5.0 ver=38
06-07 01:42:19.594 20523-20523/com.karanvir.again W/SELinux: Function: selinux_compare_spd_ram, index[1], priority [2], priority version is VE=SEPF_SECMOBILE_6.0.1_0013
06-07 01:42:19.594 20523-20523/com.karanvir.again E/Zygote: accessInfo : 0
06-07 01:42:19.594 20523-20523/com.karanvir.again W/SELinux: SELinux: seapp_context_lookup: seinfo=default, level=s0:c512,c768, pkgname=com.karanvir.again
06-07 01:42:19.594 20523-20523/com.karanvir.again I/art: Late-enabling -Xcheck:jni
06-07 01:42:19.974 20523-20523/com.karanvir.again W/ResourcesManager: getTopLevelResources: /data/app/com.karanvir.again-2/base.apk / 1.0 running in com.karanvir.again rsrc of package null
06-07 01:42:20.064 20523-20523/com.karanvir.again W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.karanvir.again-2/split_lib_dependencies_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.karanvir.again-2@split_lib_dependencies_apk.apk@classes.dex) because non-0 exit status
06-07 01:42:20.304 20523-20523/com.karanvir.again W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.karanvir.again-2/split_lib_slice_0_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.karanvir.again-2@split_lib_slice_0_apk.apk@classes.dex) because non-0 exit status
06-07 01:42:20.364 20523-20523/com.karanvir.again W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.karanvir.again-2/split_lib_slice_1_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.karanvir.again-2@split_lib_slice_1_apk.apk@classes.dex) because non-0 exit status
06-07 01:42:20.414 20523-20523/com.karanvir.again W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.karanvir.again-2/split_lib_slice_2_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.karanvir.again-2@split_lib_slice_2_apk.apk@classes.dex) because non-0 exit status
06-07 01:42:20.484 20523-20523/com.karanvir.again W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.karanvir.again-2/split_lib_slice_3_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.karanvir.again-2@split_lib_slice_3_apk.apk@classes.dex) because non-0 exit status
06-07 01:42:20.544 20523-20523/com.karanvir.again W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.karanvir.again-2/split_lib_slice_4_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.karanvir.again-2@split_lib_slice_4_apk.apk@classes.dex) because non-0 exit status
06-07 01:42:20.614 20523-20523/com.karanvir.again W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.karanvir.again-2/split_lib_slice_5_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.karanvir.again-2@split_lib_slice_5_apk.apk@classes.dex) because non-0 exit status
06-07 01:42:20.694 20523-20523/com.karanvir.again W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.karanvir.again-2/split_lib_slice_6_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.karanvir.again-2@split_lib_slice_6_apk.apk@classes.dex) because non-0 exit status
06-07 01:42:20.754 20523-20523/com.karanvir.again W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.karanvir.again-2/split_lib_slice_7_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.karanvir.again-2@split_lib_slice_7_apk.apk@classes.dex) because non-0 exit status
06-07 01:42:20.814 20523-20523/com.karanvir.again W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.karanvir.again-2/split_lib_slice_8_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.karanvir.again-2@split_lib_slice_8_apk.apk@classes.dex) because non-0 exit status
06-07 01:42:20.894 20523-20523/com.karanvir.again W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.karanvir.again-2/split_lib_slice_9_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.karanvir.again-2@split_lib_slice_9_apk.apk@classes.dex) because non-0 exit status
06-07 01:42:20.894 20523-20523/com.karanvir.again W/System: ClassLoader referenced unknown path: /data/app/com.karanvir.again-2/lib/arm
06-07 01:42:20.914 20523-20523/com.karanvir.again I/InstantRun: starting instant run server: is main process
06-07 01:42:20.994 20523-20523/com.karanvir.again W/ResourcesManager: getTopLevelResources: /data/app/com.karanvir.again-2/base.apk / 1.0 running in com.karanvir.again rsrc of package null
06-07 01:42:20.994 20523-20523/com.karanvir.again W/ResourcesManager: getTopLevelResources: /data/app/com.karanvir.again-2/base.apk / 1.0 running in com.karanvir.again rsrc of package null
06-07 01:42:21.114 20523-20523/com.karanvir.again W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
06-07 01:42:21.424 20523-20780/com.karanvir.again I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
06-07 01:42:21.424 20523-20780/com.karanvir.again I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
06-07 01:42:21.464 20523-20787/com.karanvir.again I/Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: EGL 1.4 QUALCOMM build:  (Ia10634f51b)
                                                                OpenGL ES Shader Compiler Version: E031.29.00.00
                                                                Build Date: 01/28/16 Thu
                                                                Local Branch: ss
                                                                Remote Branch:
                                                                Local Patches:
                                                                Reconstruct Branch:
06-07 01:42:21.474 20523-20787/com.karanvir.again I/OpenGLRenderer: Initialized EGL, version 1.4
06-07 01:42:21.544 20523-20523/com.karanvir.again W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
06-07 01:42:21.574 20523-20523/com.karanvir.again I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@5600697 time:300881669</code>```

package com.karanvir.again;

import android.os.AsyncTask;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;

import org.json.JSONObject;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        DownloadTask task=new DownloadTask();
        task.execute("http://api.apixu.com/v1/current.json?key=76d62bf509e64633a4970055170706&q=Paris");

    }

    public class DownloadTask extends AsyncTask<String,Void,String> {
        @Override
        protected String doInBackground(String... urls) {
            String result = "";
            URL url;
            HttpURLConnection urlConnection = null;
            try {
                url = new URL(urls[0]);
                urlConnection = (HttpURLConnection) url.openConnection();
                InputStream in = urlConnection.getInputStream();
                InputStreamReader reader = new InputStreamReader(in);
                int data = reader.read();
                while (data != -1) {
                    char current = (char) data;
                    result += current;
                    data = reader.read();
                }
                return result;

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

        @Override
        protected void onPostExecute(String result) {
            super.onPostExecute(result);
//conver result into json object
            try{
                JSONObject jsonObject=new JSONObject(result);
String xx=jsonObject.getString("condition");
                Log.i("website content", xx);

            } catch (Exception e){

            }

        }
    }

}```

答:
Actually, condition is a JSONObject so you need to parse it form result JSONObject as below.

```<code>    @Override
    protected void onPostExecute(String result) {
        super.onPostExecute(result);
        //conver result into json object
        try{
            JSONObject jsonObject=new JSONObject(result);

            //get current JSONObject from result JSONObject
            JSONObject currentJSONObject = jsonObject.getJSONObject("current");

            //Now get condition JSONObject from current JSONObject
            JSONObject conditionJSONObject = currentJSONObject.getJSONObject("condition");

            //Now print condition JSONObject
            Log.i("website content", "condition json object : " + conditionJSONObject.toString());

        } catch (Exception e){

        }

    }
</code>```

Update:

Just call getString method on conditionJSONObject to get value of "text" like below

```<code>String text = conditionJSONObject.getString("text");
</code>```

Title: Printing to logs the "conditon"

Body:
NEWEST UPDATE

package com.karanvir.again;

import android.os.AsyncTask;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class MainActivity extends AppCompatActivity {
    EditText city;
    Button go;
    TextView resultofw;
    String text;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        city=(EditText) findViewById(R.id.editText);
        go=(Button) findViewById(R.id.button);
        setSupportActionBar(toolbar);
        DownloadTask task=new DownloadTask();
        resultofw=(TextView) findViewById(R.id.textView);
        task.execute("http://api.apixu.com/v1/current.json?key=76d62bf509e64633a4970055170706&q="+city.toString());

    }

    public class DownloadTask extends AsyncTask<String,Void,String> {
        @Override
        protected String doInBackground(String... urls) {
            String result = "";
            URL url;
            HttpURLConnection urlConnection = null;
            try {
                url = new URL(urls[0]);
                urlConnection = (HttpURLConnection) url.openConnection();
                InputStream in = urlConnection.getInputStream();
                InputStreamReader reader = new InputStreamReader(in);
                int data = reader.read();
                while (data != -1) {
                    char current = (char) data;
                    result += current;
                    data = reader.read();
                }
                return result;

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

        @Override
        protected void onPostExecute(String result) {
            super.onPostExecute(result);
//conver result into json object
            try{
                JSONObject jsonObject=new JSONObject(result);

                //get current JSONObject from result JSONObject
                JSONObject currentJSONObject = jsonObject.getJSONObject("current");

                //Now get condition JSONObject from current JSONObject
                JSONObject conditionJSONObject = currentJSONObject.getJSONObject("condition");
                text = conditionJSONObject.getString("text");

                //Now print condition JSONObject
                Log.i("website content", "condition json object : " + text.toString());
                JSONArray arr= new JSONArray(conditionJSONObject.toString());

            } catch (Exception e){

            }

        }
    }

public  void click(View view){

    resultofw.setText(text);

}

}

SO how can i fix this aswell, im tryng to add the strings to the array. and then pull out what is said after "text"

//conver result into json object
            try{
                JSONObject jsonObject=new JSONObject(result);

                //get current JSONObject from result JSONObject
                JSONObject currentJSONObject = jsonObject.getJSONObject("current");

                //Now get condition JSONObject from current JSONObject
                JSONObject conditionJSONObject = currentJSONObject.getJSONObject("condition");

                //Now print condition JSONObject
                Log.i("website content", "condition json object : " + conditionJSONObject.toString());
                JSONArray arr= new JSONArray(conditionJSONObject.toString());

                for(int i=0;i<arr.length();i++){
                    JSONObject jsonpart= arr.getJSONObject(i);
                    Log.i("Part",jsonpart.getString("text"));
                }

What im trying to do is print everything after ""condition":{"text":"Partly cloudy","icon":"//cdn.apixu.com/weather/64x64/day/116.png","code":1003},"wind_mph":15.0,"wind_kph":24.1,"wind_degree":240,"wind_dir":"WSW","pressure_mb":1016.0,"pressure_in":30.5,"precip_mm":0.0,"precip_in":0.0,"humidity":71,"cloud":50,"feelslike_c":9.6,"feelslike_f":49.2,"vis_km":10.0,"vis_miles":6.0}}" To my logs, im using JSONG to process the data from this site:http://api.apixu.com/v1/current.json?key=76d62bf509e64633a4970055170706&q=Paris
Its not appearing in my logcat, please help AND YES I HAVE INCLUDED USES PERMISSION IN MY MENIFEST

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.karanvir.again.MainActivity">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </RelativeLayout>

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_main" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        app:srcCompat="@android:drawable/ic_dialog_email" />

</android.support.design.widget.CoordinatorLayout>

06-07 01:42:19.594 20523-20523/com.karanvir.again E/Zygote: v2
06-07 01:42:19.594 20523-20523/com.karanvir.again I/libpersona: KNOX_SDCARD checking this for 10291
06-07 01:42:19.594 20523-20523/com.karanvir.again I/libpersona: KNOX_SDCARD not a persona
06-07 01:42:19.594 20523-20523/com.karanvir.again I/SELinux: Function: selinux_compare_spd_ram, index[1], SPD-policy is existed. and_ver=SEPF_SM-G870W_5.0 ver=38
06-07 01:42:19.594 20523-20523/com.karanvir.again W/SELinux: Function: selinux_compare_spd_ram, index[1], priority [2], priority version is VE=SEPF_SECMOBILE_6.0.1_0013
06-07 01:42:19.594 20523-20523/com.karanvir.again E/Zygote: accessInfo : 0
06-07 01:42:19.594 20523-20523/com.karanvir.again W/SELinux: SELinux: seapp_context_lookup: seinfo=default, level=s0:c512,c768, pkgname=com.karanvir.again
06-07 01:42:19.594 20523-20523/com.karanvir.again I/art: Late-enabling -Xcheck:jni
06-07 01:42:19.974 20523-20523/com.karanvir.again W/ResourcesManager: getTopLevelResources: /data/app/com.karanvir.again-2/base.apk / 1.0 running in com.karanvir.again rsrc of package null
06-07 01:42:20.064 20523-20523/com.karanvir.again W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.karanvir.again-2/split_lib_dependencies_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.karanvir.again-2@split_lib_dependencies_apk.apk@classes.dex) because non-0 exit status
06-07 01:42:20.304 20523-20523/com.karanvir.again W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.karanvir.again-2/split_lib_slice_0_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.karanvir.again-2@split_lib_slice_0_apk.apk@classes.dex) because non-0 exit status
06-07 01:42:20.364 20523-20523/com.karanvir.again W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.karanvir.again-2/split_lib_slice_1_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.karanvir.again-2@split_lib_slice_1_apk.apk@classes.dex) because non-0 exit status
06-07 01:42:20.414 20523-20523/com.karanvir.again W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.karanvir.again-2/split_lib_slice_2_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.karanvir.again-2@split_lib_slice_2_apk.apk@classes.dex) because non-0 exit status
06-07 01:42:20.484 20523-20523/com.karanvir.again W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.karanvir.again-2/split_lib_slice_3_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.karanvir.again-2@split_lib_slice_3_apk.apk@classes.dex) because non-0 exit status
06-07 01:42:20.544 20523-20523/com.karanvir.again W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.karanvir.again-2/split_lib_slice_4_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.karanvir.again-2@split_lib_slice_4_apk.apk@classes.dex) because non-0 exit status
06-07 01:42:20.614 20523-20523/com.karanvir.again W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.karanvir.again-2/split_lib_slice_5_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.karanvir.again-2@split_lib_slice_5_apk.apk@classes.dex) because non-0 exit status
06-07 01:42:20.694 20523-20523/com.karanvir.again W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.karanvir.again-2/split_lib_slice_6_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.karanvir.again-2@split_lib_slice_6_apk.apk@classes.dex) because non-0 exit status
06-07 01:42:20.754 20523-20523/com.karanvir.again W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.karanvir.again-2/split_lib_slice_7_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.karanvir.again-2@split_lib_slice_7_apk.apk@classes.dex) because non-0 exit status
06-07 01:42:20.814 20523-20523/com.karanvir.again W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.karanvir.again-2/split_lib_slice_8_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.karanvir.again-2@split_lib_slice_8_apk.apk@classes.dex) because non-0 exit status
06-07 01:42:20.894 20523-20523/com.karanvir.again W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.karanvir.again-2/split_lib_slice_9_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.karanvir.again-2@split_lib_slice_9_apk.apk@classes.dex) because non-0 exit status
06-07 01:42:20.894 20523-20523/com.karanvir.again W/System: ClassLoader referenced unknown path: /data/app/com.karanvir.again-2/lib/arm
06-07 01:42:20.914 20523-20523/com.karanvir.again I/InstantRun: starting instant run server: is main process
06-07 01:42:20.994 20523-20523/com.karanvir.again W/ResourcesManager: getTopLevelResources: /data/app/com.karanvir.again-2/base.apk / 1.0 running in com.karanvir.again rsrc of package null
06-07 01:42:20.994 20523-20523/com.karanvir.again W/ResourcesManager: getTopLevelResources: /data/app/com.karanvir.again-2/base.apk / 1.0 running in com.karanvir.again rsrc of package null
06-07 01:42:21.114 20523-20523/com.karanvir.again W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
06-07 01:42:21.424 20523-20780/com.karanvir.again I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
06-07 01:42:21.424 20523-20780/com.karanvir.again I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
06-07 01:42:21.464 20523-20787/com.karanvir.again I/Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: EGL 1.4 QUALCOMM build:  (Ia10634f51b)
                                                                OpenGL ES Shader Compiler Version: E031.29.00.00
                                                                Build Date: 01/28/16 Thu
                                                                Local Branch: ss
                                                                Remote Branch:
                                                                Local Patches:
                                                                Reconstruct Branch:
06-07 01:42:21.474 20523-20787/com.karanvir.again I/OpenGLRenderer: Initialized EGL, version 1.4
06-07 01:42:21.544 20523-20523/com.karanvir.again W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
06-07 01:42:21.574 20523-20523/com.karanvir.again I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@5600697 time:300881669

package com.karanvir.again;

import android.os.AsyncTask;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;

import org.json.JSONObject;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        DownloadTask task=new DownloadTask();
        task.execute("http://api.apixu.com/v1/current.json?key=76d62bf509e64633a4970055170706&q=Paris");

    }

    public class DownloadTask extends AsyncTask<String,Void,String> {
        @Override
        protected String doInBackground(String... urls) {
            String result = "";
            URL url;
            HttpURLConnection urlConnection = null;
            try {
                url = new URL(urls[0]);
                urlConnection = (HttpURLConnection) url.openConnection();
                InputStream in = urlConnection.getInputStream();
                InputStreamReader reader = new InputStreamReader(in);
                int data = reader.read();
                while (data != -1) {
                    char current = (char) data;
                    result += current;
                    data = reader.read();
                }
                return result;

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

        @Override
        protected void onPostExecute(String result) {
            super.onPostExecute(result);
//conver result into json object
            try{
                JSONObject jsonObject=new JSONObject(result);
String xx=jsonObject.getString("condition");
                Log.i("website content", xx);

            } catch (Exception e){

            }

        }
    }

}

Body:
Actually, condition is a JSONObject so you need to parse it form result JSONObject as below.

    @Override
    protected void onPostExecute(String result) {
        super.onPostExecute(result);
        //conver result into json object
        try{
            JSONObject jsonObject=new JSONObject(result);

            //get current JSONObject from result JSONObject
            JSONObject currentJSONObject = jsonObject.getJSONObject("current");

            //Now get condition JSONObject from current JSONObject
            JSONObject conditionJSONObject = currentJSONObject.getJSONObject("condition");

            //Now print condition JSONObject
            Log.i("website content", "condition json object : " + conditionJSONObject.toString());

        } catch (Exception e){

        }

    }

Update:

Just call getString method on conditionJSONObject to get value of "text" like below

String text = conditionJSONObject.getString("text");


问:
Need to delete all data after third colon of a string
i have a file say test.txt with the following contents

```<code>apple:orange:mango:123:1234:12345
</code>```

i want all data after third colon to be removed

Expected output

```<code>apple:orange:mango:
</code>```

Kinldy help

答:
You can do this using cut, for example cut -d: -f1-3 test.txt. It show first, second and third columns. If you need other range of columns just replace -f1-3 with what you need.

`

Body:
i have a file say test.txt with the following contents

apple:orange:mango:123:1234:12345

i want all data after third colon to be removed

Expected output

apple:orange:mango:

Kinldy help


问:
Is creating instances of a class inside a static PageMethod thread safe?
I am using jQuery to call PageMethods.  For certain operations, the current user credentials must be validated and for other operations, I need to call other static methods.  Here is some sample code:

Sample #1

```<code>[WebMethod]
public static void PostComment(string comment)
{
    UserAuth auth = new UserAuth();
    if (auth.isAuthenticated)
        {
            //Post comment here...
        }
}
</code>```

Sample #2

```<code>[WebMethod]
public static string GetComment(int commentId)
{

    commentDto comment = //get comment data from the database...
    string friendlyDate = ConvertFriendlyDate(comment.commentDate);

    return friendlyDate + " " + comment.text;
}

public static string ConvertFriendlyDate(DateTime commentDate)
{
    string friendlyDate = //call static utility method to convert date to friendly format

    return friendlyDate;

}
</code>```

Will I be safe using these kinds of operations?

Am I better to drop page methods and just call a separate ASPX page for my AJAX requests?

答: As long as you're not touching any shared resources, it should be thread safe. </p>

Body:
I am using jQuery to call PageMethods.  For certain operations, the current user credentials must be validated and for other operations, I need to call other static methods.  Here is some sample code:

Sample #1

[WebMethod]
public static void PostComment(string comment)
{
    UserAuth auth = new UserAuth();
    if (auth.isAuthenticated)
        {
            //Post comment here...
        }
}

Sample #2

[WebMethod]
public static string GetComment(int commentId)
{

    commentDto comment = //get comment data from the database...
    string friendlyDate = ConvertFriendlyDate(comment.commentDate);

    return friendlyDate + " " + comment.text;
}

public static string ConvertFriendlyDate(DateTime commentDate)
{
    string friendlyDate = //call static utility method to convert date to friendly format

    return friendlyDate;

}

Will I be safe using these kinds of operations?

Am I better to drop page methods and just call a separate ASPX page for my AJAX requests?