问:
Set custom font in RecyclerView adapter
I have a fragment that loads a RecyclerView but I want to add a custom font to the TextView within one of the RecyclerView's items. Where in my adapter should I set the font? Also how exactly do I set the font?

I can't use this code,

```<code>Typeface font = Typeface.createFromAsset((getAssets(),
            "myfont.ttf");
</code>```

because I am not in the Activity. So how should I get the font?

This is my adapter,

```<code>public class DiscoverRecyclerAdapter
        extends RecyclerView.Adapter<DiscoverRecyclerAdapter.ViewHolder> {

    private String[] mDataset;

    public static class ViewHolder extends RecyclerView.ViewHolder {
        public TextView mText;
        public ViewHolder(android.support.v7.widget.CardView v) {
            super(v);
            mText = (TextView) v.findViewById(R.id.text);
        }
    }

    public DiscoverRecyclerAdapter(String[] myDataset) {
        mDataset = myDataset;
    }

    @Override
    public DiscoverRecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
                                                   int viewType) {
        View v = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_discover, parent, false);
        ViewHolder vh = new ViewHolder((android.support.v7.widget.CardView)v);
        return vh;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.mText.setText(mDataset[position]);
    }

    @Override
    public int getItemCount() {
        return mDataset.length;
    }
}
</code>```

Where within the adapter should I set the font and how would I set the font?

答:
add in onCreateViewHolder()</p>

```<code>Typeface typeface = Typeface.createFromAsset(viewHolder.itemView.getContext().getAssets(), "font/Test.ttf");
    viewHolder.TextView.setTypeface(typeface);
</code>```

Title: Set custom font in RecyclerView adapter

Body:
I have a fragment that loads a RecyclerView but I want to add a custom font to the TextView within one of the RecyclerView's items. Where in my adapter should I set the font? Also how exactly do I set the font?

I can't use this code,

Typeface font = Typeface.createFromAsset((getAssets(),
            "myfont.ttf");

because I am not in the Activity. So how should I get the font?

This is my adapter,

public class DiscoverRecyclerAdapter
        extends RecyclerView.Adapter<DiscoverRecyclerAdapter.ViewHolder> {

    private String[] mDataset;

    public static class ViewHolder extends RecyclerView.ViewHolder {
        public TextView mText;
        public ViewHolder(android.support.v7.widget.CardView v) {
            super(v);
            mText = (TextView) v.findViewById(R.id.text);
        }
    }

    public DiscoverRecyclerAdapter(String[] myDataset) {
        mDataset = myDataset;
    }

    @Override
    public DiscoverRecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
                                                   int viewType) {
        View v = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_discover, parent, false);
        ViewHolder vh = new ViewHolder((android.support.v7.widget.CardView)v);
        return vh;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.mText.setText(mDataset[position]);
    }

    @Override
    public int getItemCount() {
        return mDataset.length;
    }
}

Where within the adapter should I set the font and how would I set the font?

Body:
add in onCreateViewHolder()

Typeface typeface = Typeface.createFromAsset(viewHolder.itemView.getContext().getAssets(), "font/Test.ttf");
    viewHolder.TextView.setTypeface(typeface);


来源: stackexchange

问:
Image out of the container
```<code> <div class="container p0">
    <div class="col-md-12 p0">
        <div class="col-md-6 p0">
           <div class="imagen"></div>
        </div>
        <div class="col-md-6 p0">
           <div class="text-content"></div>
        </div>
    </div>
    </div>
</code>```

I do not have a definite css yet, I still think how I can do this

How can I make the image full width inside a container, just like in the example using bootstrap, The black border is the bootstrap container

What I try to do is the content in a container and the image outside of that container,

答:
Here you go with jsfiddle https://jsfiddle.net/9drawa3h/1/.

```<code><div class="container p0">
    <div class="col-md-12 p0">
        <div class="col-md-6 p0">
            <div class="imagen"></div>
        </div>
        <div class="col-md-6 p0">
            <div class="text-content">
                <img src="http://a57.foxnews.com/images.foxnews.com/content/fox-news/tech/2013/04/13/how-to-do-free-online-background-check/_jcr_content/par/featured-media/media-1.img.jpg/876/493/1422493303787.jpg?ve=1&tl=1" />
            </div>
        </div>
    </div>
</div>
</code>```

I know you are looking for text-content in the second column, but I specified something else.

As I not sure whether you are going to use img tag ro background-image in the 1st column, so I have provided both.

1st Column with background-image and 2nd column with img tag.

ContentLicense: CC BY-SA 3.0

Title: Image out of the container

Body:
Here you go with jsfiddle https://jsfiddle.net/9drawa3h/1/.

<div class="container p0">
    <div class="col-md-12 p0">
        <div class="col-md-6 p0">
            <div class="imagen"></div>
        </div>
        <div class="col-md-6 p0">
            <div class="text-content">
                <img src="http://a57.foxnews.com/images.foxnews.com/content/fox-news/tech/2013/04/13/how-to-do-free-online-background-check/_jcr_content/par/featured-media/media-1.img.jpg/876/493/1422493303787.jpg?ve=1&tl=1" />
            </div>
        </div>
    </div>
</div>

I know you are looking for text-content in the second column, but I specified something else.

As I not sure whether you are going to use img tag ro background-image in the 1st column, so I have provided both.

1st Column with background-image and 2nd column with img tag.


问:
How to call an api from another api in expressjs?
I have an api like this:

```<code>app.get('/test', (req, res) => {
   console.log("this is test");
});
</code>```

and another api:

```<code>app.get('/check', (req, res) => {
   //I want to call "test" api without redirect to it.
});
</code>```

I want to call "test" api in "check" api without redirect to "test" api, just do the function in the "test" api.
Above is the example code. 'Cause I dont' want to rewrite function from "test" api to "check"

答:
first define the /test handling function separately.

then you have two options.

```<code>// ========( 1 )====== testHandler as another function =============
// you can call this function where ever you want.
var testHandler = function(req, res){
    //do something
}
app.get('/test', testHandler);

app.get('/check', function(req, res){
  // you can call testHandler function here
  testHandler(req, res);
});

// ========( 2 )======= testHandler as a middleware =================
// if you want to call testHandler before running check handler function.
//
var testHandler = function(req, res, next){
    //do something
    ...

    next();
}
app.get('/test', testHandler, function(req, res){});

app.get('/check', testHandler, function(req, res){
  // you can call testHandler function here
  testHandler(req, res);
});
</code>```

Body:
I have an api like this:

app.get('/test', (req, res) => {
   console.log("this is test");
});

and another api:

app.get('/check', (req, res) => {
   //I want to call "test" api without redirect to it.
});

I want to call "test" api in "check" api without redirect to "test" api, just do the function in the "test" api.
Above is the example code. 'Cause I dont' want to rewrite function from "test" api to "check"

Body:
first define the /test handling function separately.

then you have two options.

// ========( 1 )====== testHandler as another function =============
// you can call this function where ever you want.
var testHandler = function(req, res){
    //do something
}
app.get('/test', testHandler);

app.get('/check', function(req, res){
  // you can call testHandler function here
  testHandler(req, res);
});

// ========( 2 )======= testHandler as a middleware =================
// if you want to call testHandler before running check handler function.
//
var testHandler = function(req, res, next){
    //do something
    ...

    next();
}
app.get('/test', testHandler, function(req, res){});

app.get('/check', testHandler, function(req, res){
  // you can call testHandler function here
  testHandler(req, res);
});


问:
Styling Polymer paper-slider
So I'm essentially wrapping the standard paper-slider element with a custom element, and wanting to include some styling. Below is what I currently have:

```<code><dom-module id="my-slider">
<template>
    <style>
      /* Works */
      paper-slider {
        --paper-slider-active-color: red;
        --paper-slider-knob-color: red;
        --paper-slider-height: 3px;
      }

      /* Doesn't work */
      paper-slider #sliderContainer.paper-slider {
        margin-left: 0;
      }

      /* Also doesn't work */
      .slider-input {
        width: 100px;
      }
    </style>

    <div>
        <paper-slider editable$="[[editable]]" disabled$="[[disabled]]" value="{{value}}" min="{{min}}" max="{{max}}"></paper-slider>
    </div>
</template>

<script>
    Polymer({
        is: "my-slider",
        properties: {
            value: {
                type: Number,
                value: 0,
                reflectToAttribute: true
            },
            min: {
                type: Number,
                value: 0
            },
            max: {
                type: Number,
                value: 100
            },
            editable: Boolean,
            disabled: Boolean
        }
    });
</script>
</dom-module>
</code>```

JSFiddle: https://jsfiddle.net/nhy7f8tt/

Defining the variables that the paper-slider uses works as expected, but when I try to address anything inside of it directly via its selector, it doesn't work.

I'm fairly new to Polymer, so this may be a very simple/stupid question, but I'm really quite confused and would greatly appreciate any help!

A secondary (but related) issue is the clipping of the input to the right of the editable paper-slider element when the value is 100.

答:
The following code is working for me,</p>

```<code>attached: function(){
  var sliderContainer = document.querySelector("#sliderContainer.editable.paper-slider");
  sliderContainer.style.marginTop = "5px";
  sliderContainer.style.marginBottom = "5px";
},
</code>```

Title: Styling Polymer paper-slider

Body:
So I'm essentially wrapping the standard paper-slider element with a custom element, and wanting to include some styling. Below is what I currently have:

<dom-module id="my-slider">
<template>

        <paper-slider editable$="[[editable]]" disabled$="[[disabled]]" value="{{value}}" min="{{min}}" max="{{max}}"></paper-slider>

</template>

</dom-module>

JSFiddle: https://jsfiddle.net/nhy7f8tt/

Defining the variables that the paper-slider uses works as expected, but when I try to address anything inside of it directly via its selector, it doesn't work.

I'm fairly new to Polymer, so this may be a very simple/stupid question, but I'm really quite confused and would greatly appreciate any help!

A secondary (but related) issue is the clipping of the input to the right of the editable paper-slider element when the value is 100.

Body:
The following code is working for me,

attached: function(){
  var sliderContainer = document.querySelector("#sliderContainer.editable.paper-slider");
  sliderContainer.style.marginTop = "5px";
  sliderContainer.style.marginBottom = "5px";
},


问:
What is the difference between the ResourceControllerFactory and the DefaultControllerFactory in ASP.NET MVC?
What is the difference between the ResourceControllerFactory and the DefaultControllerFactory in ASP.NET MVC?

Context: I am looking to hook an IOC container into the controller factory - I have previously overriden the DefaultControllerFactory to do this, but I see the ResourceControllerFactory being used in a project I am currently working with.

Does one provide improved support for REST APIs?

Code for each:

DefaultControllerFactory

```<code>public class DefaultControllerFactory : IControllerFactory
{
    // Fields
    private IBuildManager _buildManager;
    private ControllerBuilder _controllerBuilder;
    private ControllerTypeCache _instanceControllerTypeCache;
    private static ControllerTypeCache _staticControllerTypeCache;

    // Methods
    static DefaultControllerFactory();
    public DefaultControllerFactory();
    internal static InvalidOperationException CreateAmbiguousControllerException(RouteBase route, string controllerName, ICollection<Type> matchingTypes);
    public virtual IController CreateController(RequestContext requestContext, string controllerName);
    protected internal virtual IController GetControllerInstance(RequestContext requestContext, Type controllerType);
    protected internal virtual Type GetControllerType(RequestContext requestContext, string controllerName);
    private Type GetControllerTypeWithinNamespaces(RouteBase route, string controllerName, HashSet<string> namespaces);
    public virtual void ReleaseController(IController controller);

    // Properties
    internal IBuildManager BuildManager { get; set; }
    internal ControllerBuilder ControllerBuilder { get; set; }
    internal ControllerTypeCache ControllerTypeCache { get; set; }
}
</code>```

ResourceControllerFactory

```<code>public class ResourceControllerFactory : IControllerFactory
{
    // Fields
    private IControllerFactory inner;
    private const string restActionToken = "$REST$";

    // Methods
    public ResourceControllerFactory();
    public ResourceControllerFactory(IControllerFactory inner);
    public IController CreateController(RequestContext requestContext, string controllerName);
    public void ReleaseController(IController controller);

    // Nested Types
    private class ResourceControllerActionInvoker : ControllerActionInvoker
    {
        // Methods
        public ResourceControllerActionInvoker();
        protected override ActionDescriptor FindAction(ControllerContext controllerContext, ControllerDescriptor controllerDescriptor, string actionName);

        // Nested Types
        private class ResourceErrorActionDescriptor : ActionDescriptor
        {
            // Fields
            private ControllerDescriptor controllerDescriptor;
            private string message;
            private HttpStatusCode statusCode;

            // Methods
            public ResourceErrorActionDescriptor(ControllerDescriptor controllerDescriptor, HttpStatusCode statusCode, string message);
            public override object Execute(ControllerContext controllerContext, IDictionary<string, object> parameters);
            public override ParameterDescriptor[] GetParameters();

            // Properties
            public override string ActionName { get; }
            public override ControllerDescriptor ControllerDescriptor { get; }
        }
    }
}

Expand Methods
</code>```

答: The ResourceControllerFactory offers automatic response serialisation according to the accept HTTP header (I think).</p>

ContentLicense: CC BY-SA 2.5

Body:
What is the difference between the ResourceControllerFactory and the DefaultControllerFactory in ASP.NET MVC?

Context: I am looking to hook an IOC container into the controller factory - I have previously overriden the DefaultControllerFactory to do this, but I see the ResourceControllerFactory being used in a project I am currently working with.

Does one provide improved support for REST APIs?

Code for each:

DefaultControllerFactory

public class DefaultControllerFactory : IControllerFactory
{
    // Fields
    private IBuildManager _buildManager;
    private ControllerBuilder _controllerBuilder;
    private ControllerTypeCache _instanceControllerTypeCache;
    private static ControllerTypeCache _staticControllerTypeCache;

    // Methods
    static DefaultControllerFactory();
    public DefaultControllerFactory();
    internal static InvalidOperationException CreateAmbiguousControllerException(RouteBase route, string controllerName, ICollection<Type> matchingTypes);
    public virtual IController CreateController(RequestContext requestContext, string controllerName);
    protected internal virtual IController GetControllerInstance(RequestContext requestContext, Type controllerType);
    protected internal virtual Type GetControllerType(RequestContext requestContext, string controllerName);
    private Type GetControllerTypeWithinNamespaces(RouteBase route, string controllerName, HashSet<string> namespaces);
    public virtual void ReleaseController(IController controller);

    // Properties
    internal IBuildManager BuildManager { get; set; }
    internal ControllerBuilder ControllerBuilder { get; set; }
    internal ControllerTypeCache ControllerTypeCache { get; set; }
}

ResourceControllerFactory

public class ResourceControllerFactory : IControllerFactory
{
    // Fields
    private IControllerFactory inner;
    private const string restActionToken = "$REST$";

    // Methods
    public ResourceControllerFactory();
    public ResourceControllerFactory(IControllerFactory inner);
    public IController CreateController(RequestContext requestContext, string controllerName);
    public void ReleaseController(IController controller);

    // Nested Types
    private class ResourceControllerActionInvoker : ControllerActionInvoker
    {
        // Methods
        public ResourceControllerActionInvoker();
        protected override ActionDescriptor FindAction(ControllerContext controllerContext, ControllerDescriptor controllerDescriptor, string actionName);

        // Nested Types
        private class ResourceErrorActionDescriptor : ActionDescriptor
        {
            // Fields
            private ControllerDescriptor controllerDescriptor;
            private string message;
            private HttpStatusCode statusCode;

            // Methods
            public ResourceErrorActionDescriptor(ControllerDescriptor controllerDescriptor, HttpStatusCode statusCode, string message);
            public override object Execute(ControllerContext controllerContext, IDictionary<string, object> parameters);
            public override ParameterDescriptor[] GetParameters();

            // Properties
            public override string ActionName { get; }
            public override ControllerDescriptor ControllerDescriptor { get; }
        }
    }
}

Expand Methods


问:
Reduce silence time between two words in Julius speech recognition
I have successfully completed a speech recognition application with  Julius speech recognition for  English, but the problem is:

I want to reduce the silence time between two words to identify both words.

Is there a way to configure this silence time between two words?

答:
reduce the silence time between two words

there's no such thing in speech recognition. Speaker can make short pause between words if he/she wants, or speak two words without pause between them. A special skippable short pause model is added to the end of each word hypothesis during decoding to take care of this situation automatically. Please refer to Tutorial in HTK Book to understand short pause modeling in speech recognition.


问:
Clickable links API in VS Code
Is there an API to create clickable links? VS Code highlights URLs and allows to ctrl-click them, and the typescript integration allows to ctrl-click file path on imports, so the functionality is there.

The activation reference didn't mention anything about text manipulation / highlighting.

答:
There are two different things you mix in your question:

Link detection This is a built in mechanism that identifies links in any text file. It underlines links and provides the CTRL+Click command to open that link inside your browser.

Definition provider Usually implemented by an external language server using the Language Server Protocol. When you perform CTRL+Click on an import statement in a TypeScript file then these things will happen in background

VSCode will look up a definition provider for the current language (in this case it's TypeScript)

VSCode will call provideDefinition on the definition provider object having the clicked cursor position as argument

The definition provider has got the knowledge about the programming language. So it will be able to parse the source code and to find out where the clicked identifier is defined. It will return the corresponding file location.

VSCode jumps to that file location

This is a simplified example. In fact all this will happen as soon as you hold CTRL and hover over an identifer. When a definition provider responds with a valid location the identifer will be displayed underlined.

Checkout the extension samples to learn how to create your own definition provider.

Title: Clickable links API in VS Code


问:
spring scheduling a job with fixed delay and initial delay
I am trying o schedule a method call. I want to schedule this method call as soon as server starts and then after every 30 seconds.

Below code:

```<code>@Configuration
@EnableScheduling
@EnableTransactionManagement
public class Schedular implements SchedulingConfigurer {
    @Override
    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {

        taskRegistrar.setScheduler(poolScheduler());

        taskRegistrar.addTriggerTask(new Runnable() {
            @Override
            public void run() {
                testScheduling();
            }
        }, new Trigger() {

            @Override
            public Date nextExecutionTime(TriggerContext triggerContext) {
                Calendar nextExecutionTime = Calendar.getInstance();
                nextExecutionTime.add(Calendar.SECOND, <some value from database>);
                return nextExecutionTime.getTime();
            }
        });
    }

    @Bean
    public TaskScheduler poolScheduler() {
        ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
        scheduler.setThreadNamePrefix("poolScheduler");
        scheduler.setPoolSize(10);
        return scheduler;
    }

    public void testScheduling(){
        System.out.println("Scheduling Testing");
    }
}
</code>```

The code below schedule the method code after 30 seconds after the server started BUT NOT just after server started. I know I need to do some other config to schedule the method call just after server start and then after every 30 seconds (or whatever time I want to).

I am using spring boot. Could anyone please suggest.

Also, is it possible to get both initial and fixeddelay/fixedrate value from database. I want to set the initial value as well from database

Thanks in advance.

答:
let me know if this worked for you

```<code>@PostConstruct
@Scheduled(fixedDelay=30000)
public void testScheduling(){
     System.out.println("Scheduling Testing");
}
</code>```

Use the @PostConstuct annotation to start the method after the application starts.

Body:
I am trying o schedule a method call. I want to schedule this method call as soon as server starts and then after every 30 seconds.

Below code:

@Configuration
@EnableScheduling
@EnableTransactionManagement
public class Schedular implements SchedulingConfigurer {
    @Override
    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {

        taskRegistrar.setScheduler(poolScheduler());

        taskRegistrar.addTriggerTask(new Runnable() {
            @Override
            public void run() {
                testScheduling();
            }
        }, new Trigger() {

            @Override
            public Date nextExecutionTime(TriggerContext triggerContext) {
                Calendar nextExecutionTime = Calendar.getInstance();
                nextExecutionTime.add(Calendar.SECOND, <some value from database>);
                return nextExecutionTime.getTime();
            }
        });
    }

    @Bean
    public TaskScheduler poolScheduler() {
        ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
        scheduler.setThreadNamePrefix("poolScheduler");
        scheduler.setPoolSize(10);
        return scheduler;
    }

    public void testScheduling(){
        System.out.println("Scheduling Testing");
    }
}

The code below schedule the method code after 30 seconds after the server started BUT NOT just after server started. I know I need to do some other config to schedule the method call just after server start and then after every 30 seconds (or whatever time I want to).

I am using spring boot. Could anyone please suggest.

Also, is it possible to get both initial and fixeddelay/fixedrate value from database. I want to set the initial value as well from database

Thanks in advance.

Body:
let me know if this worked for you

@PostConstruct
@Scheduled(fixedDelay=30000)
public void testScheduling(){
     System.out.println("Scheduling Testing");
}

Use the @PostConstuct annotation to start the method after the application starts.


问:
mesos-agent error failed to start: Unsupported container image type: DOCKER
I'm running mesos-master and mesos-agent on the same machine where docker is also installed and running. I'm trying to run a docker app just to see that my Mesos installation is able to run containers but keep getting this error.

mesos-execute log:

```<code>I0702 14:18:09.823320 26648 scheduler.cpp:184] Version: 1.3.0
I0702 14:18:09.827054 26644 scheduler.cpp:470] New master detected at master@127.0.0.1:5050
Subscribed with ID d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005
Submitted task 'test' to agent 'd3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-S0'
Received status update TASK_FAILED for task 'test'
  message: 'Failed to launch container: Unsupported container image type: DOCKER'
  source: SOURCE_AGENT
  reason: REASON_CONTAINER_LAUNCH_FAILED
</code>```

mesos-agent log:

```<code>I0702 14:18:09.857992 26541 slave.cpp:1613] Got assigned task 'test' for framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005
I0702 14:18:09.859424 26541 slave.cpp:1894] Authorizing task 'test' for framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005
I0702 14:18:09.860486 26541 slave.cpp:2081] Launching task 'test' for framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005
I0702 14:18:09.861920 26541 paths.cpp:573] Trying to chown '/tmp/mesos/agent/slaves/d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-S0/frameworks/d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005/executors/test/runs/9ec3ea4c-a5b3-43c3-9e93-6958093dd0ed' to user 'root'
I0702 14:18:09.862447 26541 slave.cpp:6933] Launching executor 'test' of framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005 with resources cpus(*)(allocated: *):0.1; mem(*)(allocated: *):32 in work directory '/tmp/mesos/agent/slaves/d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-S0/frameworks/d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005/executors/test/runs/9ec3ea4c-a5b3-43c3-9e93-6958093dd0ed'
I0702 14:18:09.863500 26541 slave.cpp:2310] Queued task 'test' for executor 'test' of framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005
I0702 14:18:09.863682 26541 docker.cpp:1148] Skipping non-docker container
I0702 14:18:09.864451 26545 containerizer.cpp:1001] Starting container 9ec3ea4c-a5b3-43c3-9e93-6958093dd0ed for executor 'test' of framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005
E0702 14:18:09.866122 26545 slave.cpp:5048] Container '9ec3ea4c-a5b3-43c3-9e93-6958093dd0ed' for executor 'test' of framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005 failed to start: Unsupported container image type: DOCKER
I0702 14:18:09.866266 26545 containerizer.cpp:2102] Destroying container 9ec3ea4c-a5b3-43c3-9e93-6958093dd0ed in PROVISIONING state
I0702 14:18:09.867729 26530 slave.cpp:5161] Executor 'test' of framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005 has terminated with unknown status
I0702 14:18:09.868988 26530 slave.cpp:4215] Handling status update TASK_FAILED (UUID: 2b5b5610-86c3-4f4d-ae20-ecac64eabce3) for task test of framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005 from @0.0.0.0:0
E0702 14:18:09.870321 26530 slave.cpp:4496] Failed to update resources for container 9ec3ea4c-a5b3-43c3-9e93-6958093dd0ed of executor 'test' running task test on status update for terminal task, destroying container: Container not found
W0702 14:18:09.870443 26545 composing.cpp:638] Attempted to destroy unknown container 9ec3ea4c-a5b3-43c3-9e93-6958093dd0ed
I0702 14:18:09.870578 26540 status_update_manager.cpp:323] Received status update TASK_FAILED (UUID: 2b5b5610-86c3-4f4d-ae20-ecac64eabce3) for task test of framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005
I0702 14:18:09.871279 26533 slave.cpp:4655] Forwarding the update TASK_FAILED (UUID: 2b5b5610-86c3-4f4d-ae20-ecac64eabce3) for task test of framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005 to master@127.0.0.1:5050
I0702 14:18:09.885476 26540 slave.cpp:3082] Shutting down framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005
I0702 14:18:09.885699 26540 slave.cpp:5268] Cleaning up executor 'test' of framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005
I0702 14:18:09.886189 26540 slave.cpp:5356] Cleaning up framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005
</code>```

I run mesos-agent with this command:

```<code>sudo /home/erezo/mesos/mesos-1.3.0/src/.libs/lt-mesos-agent
--master=127.0.0.1:5050 -zk=zk://127.0.0.1:2181/mesos
--containerizers=docker,mesos --executor_registration_timeout=5mins
--isolation=docker/runtime --work_dir=/tmp/mesos/agent
</code>```

And mesos-execute with this:

```<code>sudo /mesos13/bin/mesos-execute --master=127.0.0.1:5050 --name=test
--docker_image=library/redis --shell=false
</code>```

Could this be permissions(mesos not allowed to run docker) related?

答:
I found the problem.
The mesos-agent needs to be started with --image_providers=appc,docker.
It was missing and when I add this it works ok. The mesos documentation samples did not include it so I figured it out..</p>

Body:
I'm running mesos-master and mesos-agent on the same machine where docker is also installed and running. I'm trying to run a docker app just to see that my Mesos installation is able to run containers but keep getting this error.

mesos-execute log:

I0702 14:18:09.823320 26648 scheduler.cpp:184] Version: 1.3.0
I0702 14:18:09.827054 26644 scheduler.cpp:470] New master detected at master@127.0.0.1:5050
Subscribed with ID d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005
Submitted task 'test' to agent 'd3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-S0'
Received status update TASK_FAILED for task 'test'
  message: 'Failed to launch container: Unsupported container image type: DOCKER'
  source: SOURCE_AGENT
  reason: REASON_CONTAINER_LAUNCH_FAILED

mesos-agent log:

I0702 14:18:09.857992 26541 slave.cpp:1613] Got assigned task 'test' for framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005
I0702 14:18:09.859424 26541 slave.cpp:1894] Authorizing task 'test' for framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005
I0702 14:18:09.860486 26541 slave.cpp:2081] Launching task 'test' for framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005
I0702 14:18:09.861920 26541 paths.cpp:573] Trying to chown '/tmp/mesos/agent/slaves/d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-S0/frameworks/d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005/executors/test/runs/9ec3ea4c-a5b3-43c3-9e93-6958093dd0ed' to user 'root'
I0702 14:18:09.862447 26541 slave.cpp:6933] Launching executor 'test' of framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005 with resources cpus(*)(allocated: *):0.1; mem(*)(allocated: *):32 in work directory '/tmp/mesos/agent/slaves/d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-S0/frameworks/d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005/executors/test/runs/9ec3ea4c-a5b3-43c3-9e93-6958093dd0ed'
I0702 14:18:09.863500 26541 slave.cpp:2310] Queued task 'test' for executor 'test' of framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005
I0702 14:18:09.863682 26541 docker.cpp:1148] Skipping non-docker container
I0702 14:18:09.864451 26545 containerizer.cpp:1001] Starting container 9ec3ea4c-a5b3-43c3-9e93-6958093dd0ed for executor 'test' of framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005
E0702 14:18:09.866122 26545 slave.cpp:5048] Container '9ec3ea4c-a5b3-43c3-9e93-6958093dd0ed' for executor 'test' of framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005 failed to start: Unsupported container image type: DOCKER
I0702 14:18:09.866266 26545 containerizer.cpp:2102] Destroying container 9ec3ea4c-a5b3-43c3-9e93-6958093dd0ed in PROVISIONING state
I0702 14:18:09.867729 26530 slave.cpp:5161] Executor 'test' of framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005 has terminated with unknown status
I0702 14:18:09.868988 26530 slave.cpp:4215] Handling status update TASK_FAILED (UUID: 2b5b5610-86c3-4f4d-ae20-ecac64eabce3) for task test of framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005 from @0.0.0.0:0
E0702 14:18:09.870321 26530 slave.cpp:4496] Failed to update resources for container 9ec3ea4c-a5b3-43c3-9e93-6958093dd0ed of executor 'test' running task test on status update for terminal task, destroying container: Container not found
W0702 14:18:09.870443 26545 composing.cpp:638] Attempted to destroy unknown container 9ec3ea4c-a5b3-43c3-9e93-6958093dd0ed
I0702 14:18:09.870578 26540 status_update_manager.cpp:323] Received status update TASK_FAILED (UUID: 2b5b5610-86c3-4f4d-ae20-ecac64eabce3) for task test of framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005
I0702 14:18:09.871279 26533 slave.cpp:4655] Forwarding the update TASK_FAILED (UUID: 2b5b5610-86c3-4f4d-ae20-ecac64eabce3) for task test of framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005 to master@127.0.0.1:5050
I0702 14:18:09.885476 26540 slave.cpp:3082] Shutting down framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005
I0702 14:18:09.885699 26540 slave.cpp:5268] Cleaning up executor 'test' of framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005
I0702 14:18:09.886189 26540 slave.cpp:5356] Cleaning up framework d3c94f9d-ff71-48d7-b27f-6b3e0f1e7bd3-0005

I run mesos-agent with this command:

sudo /home/erezo/mesos/mesos-1.3.0/src/.libs/lt-mesos-agent
--master=127.0.0.1:5050 -zk=zk://127.0.0.1:2181/mesos
--containerizers=docker,mesos --executor_registration_timeout=5mins
--isolation=docker/runtime --work_dir=/tmp/mesos/agent

And mesos-execute with this:

sudo /mesos13/bin/mesos-execute --master=127.0.0.1:5050 --name=test
--docker_image=library/redis --shell=false

Could this be permissions(mesos not allowed to run docker) related?


问:
Performance of Java enums
I was thinking about using enum type to manage i18n in a Java game I'm developing but I was curious about performance issues that can occur when working with enums that have lots of elements (thousands I think).

Actually I'm trying something like:

```<code>public enum Text {
  STRING1,
  STRING2,
  STRING3;

  public String text() {
    return text;
  }

  public String setText() {
    this.text = text;
  }
}
</code>```

Then to load them I can just fill the fields:

```<code>static
{
  Text.STRING1.setText("My localized string1");
  Text.STRING2.setText("My localized string2");
  Text.STRING3.setText("My localized string3");
}
</code>```

Of course when I'll have to manage many languages I'll load them from a file.

What I'm asking is

is an obect allocated (in addition to the string) for every element? (I guess yes, since enums are implemented with objects)

how is the right element retrieved from the enum? is it static at compile time? (I mean when somewhere I use Text.STRING1.text()). So it should be constant complexity or maybe they are just replaced during the compiling phase..

in general, is it a good approach or should I look forward something else?

Thanks

答: I hate to hijack to topic, but relying on enums for i18n is going to eventually paint you into a corner.  Java has proper i18n support, even going so far as to have a tutorial for it.</p>

Title: Performance of Java enums

Body:
I was thinking about using enum type to manage i18n in a Java game I'm developing but I was curious about performance issues that can occur when working with enums that have lots of elements (thousands I think).

Actually I'm trying something like:

public enum Text {
  STRING1,
  STRING2,
  STRING3;

  public String text() {
    return text;
  }

  public String setText() {
    this.text = text;
  }
}

Then to load them I can just fill the fields:

static
{
  Text.STRING1.setText("My localized string1");
  Text.STRING2.setText("My localized string2");
  Text.STRING3.setText("My localized string3");
}

Of course when I'll have to manage many languages I'll load them from a file.

What I'm asking is

is an obect allocated (in addition to the string) for every element? (I guess yes, since enums are implemented with objects)

how is the right element retrieved from the enum? is it static at compile time? (I mean when somewhere I use Text.STRING1.text()). So it should be constant complexity or maybe they are just replaced during the compiling phase..

in general, is it a good approach or should I look forward something else?

Thanks


问:
'utf-8' codec can't decode when using readshapefile on python basemap
I'm trying to read boundary from Canadian Map from here

```<code>import matplotlib.pyplot as plt
import matplotlib.cm

from mpl_toolkits.basemap import Basemap
from matplotlib.patches import Polygon
from matplotlib.collections import PatchCollection
from matplotlib.colors import Normalize

m = Basemap(resolution='c', # c, l, i, h, f or None
            projection='merc',
            lat_0=56.1304, lon_0=106.3468,
            llcrnrlon=-141.0, llcrnrlat= 41.2, urcrnrlon=-52.3, urcrnrlat=69.8)

m.drawmapboundary(fill_color='#46bcec')
m.fillcontinents(color='#f2f2f2',lake_color='#46bcec')
m.drawcoastlines()
</code>```

until here everything works great, but when I try to add boundary,

```<code>m.readshapefile('mypaths/gcma000b11a_e/gcma000b11a_e', 'gcma000b11a_e')
</code>```

I have this utf-8 error:

the code is from this great tutorial

```<code>UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 11: invalid continuation byte
</code>```

答:
The shape file you linked in fact consists of 4 files (.dbf, .prj, .shp, .shx). The problem is the dbf file (gcma000b11a_e.dbf), which is not in utf-8. It contains french characters (like é). You have to convert this file to utf-8, then your code works.
An easy way to convert the .dbf file is to open it with libre office calc, and in the import dialog select "Unicode (UTF-8)". Save the file, and m.readshapefile will work.</p>

Body:
I'm trying to read boundary from Canadian Map from here

import matplotlib.pyplot as plt
import matplotlib.cm

from mpl_toolkits.basemap import Basemap
from matplotlib.patches import Polygon
from matplotlib.collections import PatchCollection
from matplotlib.colors import Normalize

m = Basemap(resolution='c', # c, l, i, h, f or None
            projection='merc',
            lat_0=56.1304, lon_0=106.3468,
            llcrnrlon=-141.0, llcrnrlat= 41.2, urcrnrlon=-52.3, urcrnrlat=69.8)

m.drawmapboundary(fill_color='#46bcec')
m.fillcontinents(color='#f2f2f2',lake_color='#46bcec')
m.drawcoastlines()

until here everything works great, but when I try to add boundary,

m.readshapefile('mypaths/gcma000b11a_e/gcma000b11a_e', 'gcma000b11a_e')

I have this utf-8 error:

the code is from this great tutorial

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 11: invalid continuation byte


问:
How to import a large SQL file in the server?
Unfortunately I have a SQL file more than 350 MB. I have to import this file on the server to connect the database with one of my clients website. How I can do this? If it was my PC, then I can easily do it by editing the php.ini file. But it's in the live server and the sql file upload limit is only 50 MB. What can I do? I have the cPanel and also the server access. Can anyone help me? Thanks in advance.</p>

答:
If you have SSH access then login to MySQL server and use the following command:

```<code>mysql -u username -p database_name < file.sql
</code>```

This is only basic for more detail you can find here

Body:
If you have SSH access then login to MySQL server and use the following command:

mysql -u username -p database_name < file.sql

This is only basic for more detail you can find here


问:
Spreedsheet ':number_format' is woking in 'open office' but not in 'Excel'
```<code>@currency_format = Spreadsheet::Format.new  :number_format => '#,###'
</code>```

I am using this @currency_format wherever needed in ruby code. After generating .xls file, @currency_format is applied if I open file in 'open office', but not working if I open same file in Excel.

Any help please?

答:
If you don't have complex data (like math of excel formulas), you can use plain .csv and that might solve your problem.

In the case when that is not an option, can you please expand on your question.

Show us some sample data, and outputs, and show us the Format class and an usage of that.

Body:
@currency_format = Spreadsheet::Format.new  :number_format => '#,###'

I am using this @currency_format wherever needed in ruby code. After generating .xls file, @currency_format is applied if I open file in 'open office', but not working if I open same file in Excel.

Any help please?


问:
priority-web-sdk: No data from getRows
I'm formStarting a form and calling getRows(0). I'm not sure if the getRows parameter is 1 or 0 based (to start reading from the first row), but I've tried both with the same results described below.

```<code>    function priorityReady() {
        login(config).then(
            function(){
                formStart('CUSTOMERS', showMessage, updateFields, config.company).then(
                    function(appgen){
                        appgen.getRows(1).then(
                            function(rows) {
                                console.log(rows);
                            }, showMessage
                        )
                    }, showMessage
                )
            }, showMessage
        )
    }
</code>```

The Rows result from getRows contains no records... any ideas please?

Update 2

I've added the company to the formStart call and am now using 1 as the getRows parameter. Unfortunately there are still no records returned.

If I set autoRetrieveFirstRows = 1 however, I get an API error.

```<code>{type: "apiError",
code: "exception",
message: "(TypeError) : g is not a function",
form: Object,
fatal: false}
</code>```

答:
Rows are only returned to getRows when the formStart call specifies the autoRetrieveFirstRows as 1. e.g.

```<code>formStart('CUSTOMERS', showMessage, updateFields, config.company, 1)
</code>```

There was a confirmed bug in the version 1.5 package (thanks to @Leor for assistance with this) where specifying the autoRetrieveFirstRows caused the formStart function to fail.

This was resolved in version 1.6 of the package, which can be referenced like so...

```<code><script src=
    "https://cdn.priority-software.com/upgrades/var/api/head/priorityapp.nocache.js">
</script>
</code>```

Title: priority-web-sdk: No data from getRows

Body:
I'm formStarting a form and calling getRows(0). I'm not sure if the getRows parameter is 1 or 0 based (to start reading from the first row), but I've tried both with the same results described below.

    function priorityReady() {
        login(config).then(
            function(){
                formStart('CUSTOMERS', showMessage, updateFields, config.company).then(
                    function(appgen){
                        appgen.getRows(1).then(
                            function(rows) {
                                console.log(rows);
                            }, showMessage
                        )
                    }, showMessage
                )
            }, showMessage
        )
    }

The Rows result from getRows contains no records... any ideas please?

Update 2

I've added the company to the formStart call and am now using 1 as the getRows parameter. Unfortunately there are still no records returned.

If I set autoRetrieveFirstRows = 1 however, I get an API error.

{type: "apiError",
code: "exception",
message: "(TypeError) : g is not a function",
form: Object,
fatal: false}

Body:
Rows are only returned to getRows when the formStart call specifies the autoRetrieveFirstRows as 1. e.g.

formStart('CUSTOMERS', showMessage, updateFields, config.company, 1)

There was a confirmed bug in the version 1.5 package (thanks to @Leor for assistance with this) where specifying the autoRetrieveFirstRows caused the formStart function to fail.

This was resolved in version 1.6 of the package, which can be referenced like so...

<script src=
    "https://cdn.priority-software.com/upgrades/var/api/head/priorityapp.nocache.js">
</script>


问:
Error mapping stateless beans with Spring
I have a Java EE application that runs on JBoss 6.4 EAP and uses Spring Security. Apparently all Maven dependencies are mapped. However, at the moment stateless beans are loaded, the following message appears:

```<code>Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'autenticacaoBO': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: ajg2/AutenticacaoBO -- service jboss.naming.context.java.app."ajg2-0.0.1-SNAPSHOT".ajg2.AutenticacaoBO
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1514) [spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521) [spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) [spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293) [spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) [spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290) [spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191) [spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328) [spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    ... 26 more
Caused by: javax.naming.NameNotFoundException: ajg2/AutenticacaoBO -- service jboss.naming.context.java.app."ajg2-0.0.1-SNAPSHOT".ajg2.AutenticacaoBO
    at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:104)
    at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:197)
    at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:174)
    at org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:245)
</code>```

File spring-security.xml:

```<code><?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:sec="http://www.springframework.org/schema/security"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">

    <jee:local-slsb id="autenticacaoBO" jndi-name="java:app/ajg2/AutenticacaoBO" business-interface="br.jus.ajg.bo.IAutenticacaoBO"/>

    <bean id="appInternetAuthenticationProvider" class="br.jus.ajg.seguranca.AppInternetAuthenticationProvider">
        <property name="autenticacaoBO" ref="autenticacaoBO"/>
    </bean>
    <bean id="appIntranetAuthenticationProvider" class="br.jus.ajg.seguranca.AppIntranetAuthenticationProvider">
        <property name="autenticacaoBO" ref="autenticacaoBO"/>
    </bean>

</beans>
</code>```

File AppInternetAuthenticationProvider.java:

```<code>package br.jus.ajg.seguranca;

import java.io.IOException;
import java.io.Serializable;

import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.stereotype.Component;

import br.jus.ajg.bo.IAutenticacaoBO;
import br.jus.ajg.modelo.Profissional;
import br.jus.ajg.util.VerifyRecaptcha;

@Component
public class AppInternetAuthenticationProvider implements AuthenticationProvider, Serializable {

    private IAutenticacaoBO autenticacaoBO;

    /**
     * Este set é usado para injeção do EJB
     */
    public void setAutenticacaoBO(IAutenticacaoBO autenticacaoBO) {
        this.autenticacaoBO = autenticacaoBO;
    }

    public AppInternetAuthenticationProvider() {

    }

    @Override
    public Authentication authenticate(Authentication authentication) throws AuthenticationException {
        if (!autenticacaoBO.isSistemaEmManutencao()) {

            AppWebAuthenticationDetails webAuthDetail = (AppWebAuthenticationDetails) authentication.getDetails();

            String gRecaptchaResponse = webAuthDetail.getRecaptcha_response();
            boolean validouRecaptcha = false;
            try {
                validouRecaptcha = VerifyRecaptcha.verify(gRecaptchaResponse);
            } catch (IOException e) {
                new AuthenticationServiceException("Problema na validação do recaptcha", e);
            }

            if (validouRecaptcha) {
                String login = authentication.getName();
                String senha = authentication.getCredentials().toString();
                String infoNavegador = ((AppWebAuthenticationDetails) authentication.getDetails()).getHeaderRequest();

                Profissional p = autenticacaoBO.getProfissionalBO().autenticaProfissional(login, senha, infoNavegador);
                if (p != null) {
                    return autenticacaoBO.geraTokenProfissional(p, senha);
                } else {
                    throw new AuthenticationServiceException("CPF ou senha inválidos");
                }
            } else {
                throw new AuthenticationServiceException("O desafio reCAPTCHA foi respondido incorretamente!");
            }

        } else {
            throw new AuthenticationServiceException("Sistema em manutenção. Tente mais tarde.");
        }
    }

    @Override
    public boolean supports(Class<?> authentication) {
        return authentication.equals(UsernamePasswordAuthenticationToken.class);
    }

}
</code>```

Can someone help?

答:
Thanks Pavel. In fact, I forgot a tip sent by the original developer of this project. Just added project libs to the classpath tab of the 'Open laucnh configuration' JBoss option.

JBoss started without errors and app is running fine.

Body:
I have a Java EE application that runs on JBoss 6.4 EAP and uses Spring Security. Apparently all Maven dependencies are mapped. However, at the moment stateless beans are loaded, the following message appears:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'autenticacaoBO': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: ajg2/AutenticacaoBO -- service jboss.naming.context.java.app."ajg2-0.0.1-SNAPSHOT".ajg2.AutenticacaoBO
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1514) [spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521) [spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) [spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293) [spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) [spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290) [spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191) [spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328) [spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    ... 26 more
Caused by: javax.naming.NameNotFoundException: ajg2/AutenticacaoBO -- service jboss.naming.context.java.app."ajg2-0.0.1-SNAPSHOT".ajg2.AutenticacaoBO
    at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:104)
    at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:197)
    at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:174)
    at org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:245)

File spring-security.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:sec="http://www.springframework.org/schema/security"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">

    <jee:local-slsb id="autenticacaoBO" jndi-name="java:app/ajg2/AutenticacaoBO" business-interface="br.jus.ajg.bo.IAutenticacaoBO"/>

    <bean id="appInternetAuthenticationProvider" class="br.jus.ajg.seguranca.AppInternetAuthenticationProvider">
        <property name="autenticacaoBO" ref="autenticacaoBO"/>
    </bean>
    <bean id="appIntranetAuthenticationProvider" class="br.jus.ajg.seguranca.AppIntranetAuthenticationProvider">
        <property name="autenticacaoBO" ref="autenticacaoBO"/>
    </bean>

</beans>

File AppInternetAuthenticationProvider.java:

package br.jus.ajg.seguranca;

import java.io.IOException;
import java.io.Serializable;

import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.stereotype.Component;

import br.jus.ajg.bo.IAutenticacaoBO;
import br.jus.ajg.modelo.Profissional;
import br.jus.ajg.util.VerifyRecaptcha;

@Component
public class AppInternetAuthenticationProvider implements AuthenticationProvider, Serializable {

    private IAutenticacaoBO autenticacaoBO;

    /**
     * Este set é usado para injeção do EJB
     */
    public void setAutenticacaoBO(IAutenticacaoBO autenticacaoBO) {
        this.autenticacaoBO = autenticacaoBO;
    }

    public AppInternetAuthenticationProvider() {

    }

    @Override
    public Authentication authenticate(Authentication authentication) throws AuthenticationException {
        if (!autenticacaoBO.isSistemaEmManutencao()) {

            AppWebAuthenticationDetails webAuthDetail = (AppWebAuthenticationDetails) authentication.getDetails();

            String gRecaptchaResponse = webAuthDetail.getRecaptcha_response();
            boolean validouRecaptcha = false;
            try {
                validouRecaptcha = VerifyRecaptcha.verify(gRecaptchaResponse);
            } catch (IOException e) {
                new AuthenticationServiceException("Problema na validação do recaptcha", e);
            }

            if (validouRecaptcha) {
                String login = authentication.getName();
                String senha = authentication.getCredentials().toString();
                String infoNavegador = ((AppWebAuthenticationDetails) authentication.getDetails()).getHeaderRequest();

                Profissional p = autenticacaoBO.getProfissionalBO().autenticaProfissional(login, senha, infoNavegador);
                if (p != null) {
                    return autenticacaoBO.geraTokenProfissional(p, senha);
                } else {
                    throw new AuthenticationServiceException("CPF ou senha inválidos");
                }
            } else {
                throw new AuthenticationServiceException("O desafio reCAPTCHA foi respondido incorretamente!");
            }

        } else {
            throw new AuthenticationServiceException("Sistema em manutenção. Tente mais tarde.");
        }
    }

    @Override
    public boolean supports(Class<?> authentication) {
        return authentication.equals(UsernamePasswordAuthenticationToken.class);
    }

}

Can someone help?


问:
Key Error with Zip Function
While using zip, I know that there is a {} in my text that doesn't let the zip function run that many times. and I know that its the {} because when I erase them. the code runs perfectly. but I need the {} to be in that text.
To give you the big picture,
I have a ready made text, that I want to "unpack" values from the 3 lists(the three lists are defined before this line of code comes), each will go to the appropriate place.

```<code>text = '''curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{
"name": "{}",
"lei": " ",
"parentId": "0",
"status": "ACTIVE",
"type": "1",
"country": "{}",
"region": "1",
"address": "{}",
"domains": "string.com"
}' 'http://qa-eu-entities.capitol.is/org'
'''

for i in zip(df['Name'], df['Country'], df['Address']):
    print(text.format(*i))
</code>```

The Error that I get is KeyError

```<code> KeyError: '\n  "name"'
</code>```

I tried using json.loads and calling it on text, with no success.

Any idea what could be done differently?

答:
The problem with the text contains extra { that's why it's making an error. I would suggest to use like this,

```<code>In [17]: text = """curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{
    ...: "name": "%s",
    ...: "lei": " ",
    ...: "parentId": "0",
    ...: "status": "ACTIVE",
    ...: "type": "1",
    ...: "country": "%s",
    ...: "region": "1",
    ...: "address": "%s",
    ...: "domains": "string.com"
    ...: }' 'http://qa-eu-entities.capitol.is/org'
    ...: """

In [19]: print(text %('hai','hey','test'))
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{
"name": "hai",
"lei": " ",
"parentId": "0",
"status": "ACTIVE",
"type": "1",
"country": "hey",
"region": "1",
"address": "test",
"domains": "string.com"
}' 'http://qa-eu-entities.capitol.is/org'
</code>```

You case it will be like this,

```<code>for i in zip(df['Name'], df['Country'], df['Address']):
    print(text %(i))
</code>```

Title: Key Error with Zip Function

Body:
While using zip, I know that there is a {} in my text that doesn't let the zip function run that many times. and I know that its the {} because when I erase them. the code runs perfectly. but I need the {} to be in that text.
To give you the big picture,
I have a ready made text, that I want to "unpack" values from the 3 lists(the three lists are defined before this line of code comes), each will go to the appropriate place.

text = '''curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{
"name": "{}",
"lei": " ",
"parentId": "0",
"status": "ACTIVE",
"type": "1",
"country": "{}",
"region": "1",
"address": "{}",
"domains": "string.com"
}' 'http://qa-eu-entities.capitol.is/org'
'''

for i in zip(df['Name'], df['Country'], df['Address']):
    print(text.format(*i))

The Error that I get is KeyError

 KeyError: '\n  "name"'

I tried using json.loads and calling it on text, with no success.

Any idea what could be done differently?

Body:
The problem with the text contains extra { that's why it's making an error. I would suggest to use like this,

In [17]: text = """curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{
    ...: "name": "%s",
    ...: "lei": " ",
    ...: "parentId": "0",
    ...: "status": "ACTIVE",
    ...: "type": "1",
    ...: "country": "%s",
    ...: "region": "1",
    ...: "address": "%s",
    ...: "domains": "string.com"
    ...: }' 'http://qa-eu-entities.capitol.is/org'
    ...: """

In [19]: print(text %('hai','hey','test'))
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{
"name": "hai",
"lei": " ",
"parentId": "0",
"status": "ACTIVE",
"type": "1",
"country": "hey",
"region": "1",
"address": "test",
"domains": "string.com"
}' 'http://qa-eu-entities.capitol.is/org'

You case it will be like this,

for i in zip(df['Name'], df['Country'], df['Address']):
    print(text %(i))


问:
Angular 2 ng build
So i need to create a build which can work without running a server.

Run ng build. Got a dist folder.

When i run index.html im getting an error like

GET file:///D:/inline.bundle.js net::ERR_FILE_NOT_FOUND

He is searching that js file in the root of my D:// drive, not in a project folder

So okay, i removed a <base href="/"> from my index.html and got this error:

```<code>Unhandled Promise rejection: No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document. ; Zone: <root> ; Task: Promise.then ; Value: ZoneAwareError {__zone_symbol__error: Error: No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to…, __zone_symbol__stack: "Error: No base href set. Please provide a value fo…testing1/dist/vendor.bundle.js:28631:62) [<root>]", __zone_symbol__message: "No base href set. Please provide a value for the A…HREF token or add a base element to the document."} Error: No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document.
at new PathLocationStrategy (file:///D:/angular/testing1/dist/vendor.bundle.js:66150:19) [angular]
at provideLocationStrategy (file:///D:/angular/testing1/dist/vendor.bundle.js:62944:9) [angular]
at AppModuleInjector.get (/AppModule/module.ngfactory.js:164:77) [angular]
at AppModuleInjector.get (/AppModule/module.ngfactory.js:169:84) [angular]
at AppModuleInjector.get (/AppModule/module.ngfactory.js:198:151) [angular]
at AppModuleInjector.createInternal (/AppModule/module.ngfactory.js:241:60) [angular]
at AppModuleInjector.NgModuleInjector.create (file:///D:/angular/testing1/dist/vendor.bundle.js:56323:76) [angular]
at NgModuleFactory.create (file:///D:/angular/testing1/dist/vendor.bundle.js:56291:18) [angular]
at file:///D:/angular/testing1/dist/vendor.bundle.js:38426:61 [angular]
at Object.onInvoke (file:///D:/angular/testing1/dist/vendor.bundle.js:28762:37) [angular]
at Zone.webpackJsonp.528.Zone.run (file:///D:/angular/testing1/dist/polyfills.bundle.js:2591:43) [<root> => angular]
at NgZone.run (file:///D:/angular/testing1/dist/vendor.bundle.js:28631:62) [<root>]
</code>```

So angular2router doesnt work without <base> and index.html cannot find my local files with <base>

How can i solve it ?

答:
Use below script in index.html.

```<code><script>
    document.write('<base href="' + String(document.location).replace('index.html','') + '">')
</script>
</code>```

let me know it works for you or not.

Title: Angular 2 ng build

Body:
So i need to create a build which can work without running a server.

Run ng build. Got a dist folder.

When i run index.html im getting an error like

GET file:///D:/inline.bundle.js net::ERR_FILE_NOT_FOUND

He is searching that js file in the root of my D:// drive, not in a project folder

So okay, i removed a <base href="/"> from my index.html and got this error:

Unhandled Promise rejection: No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document. ; Zone: <root> ; Task: Promise.then ; Value: ZoneAwareError {__zone_symbol__error: Error: No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to…, __zone_symbol__stack: "Error: No base href set. Please provide a value fo…testing1/dist/vendor.bundle.js:28631:62) [<root>]", __zone_symbol__message: "No base href set. Please provide a value for the A…HREF token or add a base element to the document."} Error: No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document.
at new PathLocationStrategy (file:///D:/angular/testing1/dist/vendor.bundle.js:66150:19) [angular]
at provideLocationStrategy (file:///D:/angular/testing1/dist/vendor.bundle.js:62944:9) [angular]
at AppModuleInjector.get (/AppModule/module.ngfactory.js:164:77) [angular]
at AppModuleInjector.get (/AppModule/module.ngfactory.js:169:84) [angular]
at AppModuleInjector.get (/AppModule/module.ngfactory.js:198:151) [angular]
at AppModuleInjector.createInternal (/AppModule/module.ngfactory.js:241:60) [angular]
at AppModuleInjector.NgModuleInjector.create (file:///D:/angular/testing1/dist/vendor.bundle.js:56323:76) [angular]
at NgModuleFactory.create (file:///D:/angular/testing1/dist/vendor.bundle.js:56291:18) [angular]
at file:///D:/angular/testing1/dist/vendor.bundle.js:38426:61 [angular]
at Object.onInvoke (file:///D:/angular/testing1/dist/vendor.bundle.js:28762:37) [angular]
at Zone.webpackJsonp.528.Zone.run (file:///D:/angular/testing1/dist/polyfills.bundle.js:2591:43) [<root> => angular]
at NgZone.run (file:///D:/angular/testing1/dist/vendor.bundle.js:28631:62) [<root>]

So angular2router doesnt work without <base> and index.html cannot find my local files with <base>

How can i solve it ?

Body:
Use below script in index.html.

<script>
    document.write('<base href="' + String(document.location).replace('index.html','') + '">')
</script>

let me know it works for you or not.


问:
i implement a tabhost but it dont want appear after execute
I try to switching from my main activity(login screen) to the logged(after login) screen. I have build my simple tabhost but it dont want appear if i start the program. where is my mistake ?

```<code>import android.os.Bundle;
        import android.support.v7.app.AppCompatActivity;
        import android.view.View;
        import android.widget.Button;
        import android.widget.EditText;

public class MainActivity extends AppCompatActivity {
    // Fragment TabHost as mTabHost
    EditText text;
    Button login;
    EditText password;
    String username;
    String pw;
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        text = (EditText) findViewById(R.id.editText);
        login = (Button) findViewById(R.id.button);
        password = (EditText) findViewById(R.id.editText2);

        login.setOnClickListener(new View.OnClickListener(){
            public void onClick(View view){
                username =text.getText().toString();
                pw= password.getText().toString();
                System.out.println(text.getText().toString());
                System.out.println(password.getText().toString());

                if(username.equals("test") && pw.equals("test")){
                  setContentView(R.layout.logged);
                }else{
                    System.out.println("Fail");
                }

            }

        });

    }

}
</code>```

logged.class

```<code>import android.os.Build;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TabHost;
import android.widget.TabWidget;

import java.util.zip.Inflater;

/**
 * Created by saddam on 04.07.2017.
 */

public class logged extends FragmentActivity {
    TabHost tabHost;
    TabWidget tw;
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Build savedInstanceState) {

        View v = inflater.inflate(R.layout.logged,container,false);

        TabHost host = (TabHost)findViewById(R.id.tabHost);
        host.setup();

        //Tab 1
        TabHost.TabSpec spec = host.newTabSpec("Tab One");
        spec.setContent(R.id.tab1);
        spec.setIndicator("Tab One");
        host.addTab(spec);

        //Tab 2
        spec = host.newTabSpec("Tab Two");
        spec.setContent(R.id.tab2);
        spec.setIndicator("Tab Two");
        host.addTab(spec);

        //Tab 3
        spec = host.newTabSpec("Tab Three");
        spec.setContent(R.id.tab3);
        spec.setIndicator("Tab Three");
        host.addTab(spec);
        return v;
    }
}
</code>```

logged.xml

```<code><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TabHost
        android:id="@+id/tabHost"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"></TabWidget>

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <LinearLayout
                    android:id="@+id/tab1"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="#ffc916"
                    android:orientation="vertical">

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:text="This is tab 1" />

                </LinearLayout>

                <LinearLayout
                    android:id="@+id/tab2"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="#da8200"
                    android:orientation="vertical">

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:text="This is tab 2" />
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/tab3"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="#5b89ff"
                    android:orientation="vertical">

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:text="This is tab 3" />
                </LinearLayout>
            </FrameLayout>
        </LinearLayout>
    </TabHost>
</code>```

答:
How to use TabHost please check this complete example , it is very helpful to you
http://www.technotalkative.com/android-tab-bar-example-1/</p>

Body:
I try to switching from my main activity(login screen) to the logged(after login) screen. I have build my simple tabhost but it dont want appear if i start the program. where is my mistake ?

import android.os.Bundle;
        import android.support.v7.app.AppCompatActivity;
        import android.view.View;
        import android.widget.Button;
        import android.widget.EditText;

public class MainActivity extends AppCompatActivity {
    // Fragment TabHost as mTabHost
    EditText text;
    Button login;
    EditText password;
    String username;
    String pw;
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        text = (EditText) findViewById(R.id.editText);
        login = (Button) findViewById(R.id.button);
        password = (EditText) findViewById(R.id.editText2);

        login.setOnClickListener(new View.OnClickListener(){
            public void onClick(View view){
                username =text.getText().toString();
                pw= password.getText().toString();
                System.out.println(text.getText().toString());
                System.out.println(password.getText().toString());

                if(username.equals("test") && pw.equals("test")){
                  setContentView(R.layout.logged);
                }else{
                    System.out.println("Fail");
                }

            }

        });

    }

}

logged.class

import android.os.Build;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TabHost;
import android.widget.TabWidget;

import java.util.zip.Inflater;

/**
 * Created by saddam on 04.07.2017.
 */

public class logged extends FragmentActivity {
    TabHost tabHost;
    TabWidget tw;
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Build savedInstanceState) {

        View v = inflater.inflate(R.layout.logged,container,false);

        TabHost host = (TabHost)findViewById(R.id.tabHost);
        host.setup();

        //Tab 1
        TabHost.TabSpec spec = host.newTabSpec("Tab One");
        spec.setContent(R.id.tab1);
        spec.setIndicator("Tab One");
        host.addTab(spec);

        //Tab 2
        spec = host.newTabSpec("Tab Two");
        spec.setContent(R.id.tab2);
        spec.setIndicator("Tab Two");
        host.addTab(spec);

        //Tab 3
        spec = host.newTabSpec("Tab Three");
        spec.setContent(R.id.tab3);
        spec.setIndicator("Tab Three");
        host.addTab(spec);
        return v;
    }
}

logged.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TabHost
        android:id="@+id/tabHost"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"></TabWidget>

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <LinearLayout
                    android:id="@+id/tab1"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="#ffc916"
                    android:orientation="vertical">

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:text="This is tab 1" />

                </LinearLayout>

                <LinearLayout
                    android:id="@+id/tab2"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="#da8200"
                    android:orientation="vertical">

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:text="This is tab 2" />
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/tab3"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="#5b89ff"
                    android:orientation="vertical">

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:text="This is tab 3" />
                </LinearLayout>
            </FrameLayout>
        </LinearLayout>
    </TabHost>


问:
Python selenium unable to click field
I'm trying to request data that I can later scrap. I write the dates in the text field but when I send the request, it does not update according to the dates. I'm trying to click the date field, but I don't see the calendar pop up as it should. How can i go about this? </p>

```<code>from selenium import webdriver
driver = webdriver.Firefox()
driver.get('https://www.fxstreet.com/economic-calendar')

time.sleep(10)

#close popup
driver.find_element_by_xpath('//button[@aria-label="Close Modal"]').click()
driver.find_element_by_id('fxit-advlink').click()

#click filter options
driver.find_element_by_id('fxit-advlink').click()

#set start and end time
driver.find_element_by_xpath("//input[contains(@id,'fxit-start-advance')]").click()
driver.find_element_by_xpath("//input[contains(@id,'fxit-start-advance')]").send_keys("01/01/2017")

driver.find_element_by_xpath("//input[contains(@id,'fxit-end-advance')]").click()
driver.find_element_by_xpath("//input[contains(@id,'fxit-end-advance')]").send_keys("06/01/2017")

#select countries

#select data type
driver.find_element_by_xpath('//a[@class="fxst-selectall" and @data-name="fxst-category"]').click()

#refresh your results
driver.find_element_by_id('fxit-filterbutton').click()
</code>```

答:
I tried your code and it works correctly for me. I am able to see the calender open and input the date.
One point - you may want to include a .clear() between your .click() and .send_keys() as the input box does not automatically clear - this may be why you are not seeing your date update if there is validation looking for a correct date format.</p>

Title: Python selenium unable to click field

Body:
I'm trying to request data that I can later scrap. I write the dates in the text field but when I send the request, it does not update according to the dates. I'm trying to click the date field, but I don't see the calendar pop up as it should. How can i go about this?

from selenium import webdriver
driver = webdriver.Firefox()
driver.get('https://www.fxstreet.com/economic-calendar')

time.sleep(10)

#close popup
driver.find_element_by_xpath('//button[@aria-label="Close Modal"]').click()
driver.find_element_by_id('fxit-advlink').click()

#click filter options
driver.find_element_by_id('fxit-advlink').click()

#set start and end time
driver.find_element_by_xpath("//input[contains(@id,'fxit-start-advance')]").click()
driver.find_element_by_xpath("//input[contains(@id,'fxit-start-advance')]").send_keys("01/01/2017")

driver.find_element_by_xpath("//input[contains(@id,'fxit-end-advance')]").click()
driver.find_element_by_xpath("//input[contains(@id,'fxit-end-advance')]").send_keys("06/01/2017")

#select countries

#select data type
driver.find_element_by_xpath('//a[@class="fxst-selectall" and @data-name="fxst-category"]').click()

#refresh your results
driver.find_element_by_id('fxit-filterbutton').click()


问:
Keras: How to use fit_generator with multiple outputs of different type
In a Keras model with the Functional API I need to call fit_generator to train on augmented images data using an ImageDataGenerator.

The problem is my model has two outputs: the mask I'm trying to predict and a binary value.

I obviously only want to augment the input and the mask output and not the binary value.

How can I achieve this?

答:
If you have separated both mask and binary value you can try something like this:

```<code>generator = ImageDataGenerator(rotation_range=5.,
                                width_shift_range=0.1,
                                height_shift_range=0.1,
                                horizontal_flip=True,
                                vertical_flip=True)

def generate_data_generator(generator, X, Y1, Y2):
    genX = generator.flow(X, seed=7)
    genY1 = generator.flow(Y1, seed=7)
    while True:
            Xi = genX.next()
            Yi1 = genY1.next()
            Yi2 = function(Y2)
            yield Xi, [Yi1, Yi2]
</code>```

So, you use the same generator for both input and mask with the same seed to define the same operation. You may change the binary value or not depending on your needs (Y2). Then, you call the fit_generator():

```<code>model.fit_generator(generate_data_generator(generator, X, Y1, Y2),
                epochs=epochs)
</code>```

ContentLicense: CC BY-SA 4.0

Body:
If you have separated both mask and binary value you can try something like this:

generator = ImageDataGenerator(rotation_range=5.,
                                width_shift_range=0.1,
                                height_shift_range=0.1,
                                horizontal_flip=True,
                                vertical_flip=True)

def generate_data_generator(generator, X, Y1, Y2):
    genX = generator.flow(X, seed=7)
    genY1 = generator.flow(Y1, seed=7)
    while True:
            Xi = genX.next()
            Yi1 = genY1.next()
            Yi2 = function(Y2)
            yield Xi, [Yi1, Yi2]

So, you use the same generator for both input and mask with the same seed to define the same operation. You may change the binary value or not depending on your needs (Y2). Then, you call the fit_generator():

model.fit_generator(generate_data_generator(generator, X, Y1, Y2),
                epochs=epochs)


问:
How can I maintain top-alignment of my JavaFx Toolbar during window rescaling?
As you can see in the following image, the red Toolbar doesn't stay at the top of the screen. How can I top-align the Toolbar regardless of window scaling?

Image: http://i63.tinypic.com/r7iowg.png

scene.fxml:

```<code><?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.*?>
<VBox alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
      prefHeight="650.0" prefWidth="1175.0"
      fx:controller="app.controller.TableViewController" xmlns="http://javafx.com/javafx/8.0.40"
      xmlns:fx="http://javafx.com/fxml/1">
        <ToolBar prefHeight="35.0" prefWidth="1200.0" style="-fx-background-color: #8C0000;">
            <ImageView fitHeight="35.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true">
                <Image url="@../images/react-toolbar-logo.png"/>
            </ImageView>
        </ToolBar>
        <TabPane layoutY="45.0" prefHeight="605.0" prefWidth="1175.0" tabClosingPolicy="UNAVAILABLE" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity">
            <Tab text="Technician View">
                <Pane prefHeight="485.0" prefWidth="1075.0">
                    <opaqueInsets>
                        <Insets/>
                    </opaqueInsets>
                    <ScrollPane hbarPolicy="NEVER" prefHeight="575.0" prefWidth="1175.0" vbarPolicy="NEVER">
                        <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="650.0" prefWidth="1175.0">
                            <TableView fx:id="technicianTable" layoutX="85.0" layoutY="55.0" prefHeight="475.0"
                                       prefWidth="1000.0" />
                            <Label fx:id="viewLabel1" layoutX="85.0" layoutY="26.0" prefHeight="17.0"
                                   prefWidth="351.0"/>
                        </AnchorPane>
                    </ScrollPane>
                </Pane>
            </Tab>
            <Tab text="Group View">
                <Pane prefHeight="485.0" prefWidth="1075.0">
                    <opaqueInsets>
                        <Insets/>
                    </opaqueInsets>
                    <ScrollPane hbarPolicy="NEVER" prefHeight="575.0" prefWidth="1175.0" vbarPolicy="NEVER">
                        <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="650.0" prefWidth="1175.0">
                            <TableView fx:id="groupTable" layoutX="85.0" layoutY="55.0" prefHeight="475.0"
                                       prefWidth="1000.0"/>
                            <Label fx:id="viewLabel2" layoutX="85.0" layoutY="26.0" prefHeight="17.0"
                                   prefWidth="351.0"/>
                        </AnchorPane>
                    </ScrollPane>
                </Pane>
            </Tab>
            <Tab text="1-QUEUE">
                <Pane prefHeight="485.0" prefWidth="1075.0">
                    <opaqueInsets>
                        <Insets/>
                    </opaqueInsets>
                    <ScrollPane hbarPolicy="NEVER" prefHeight="575.0" prefWidth="1175.0" vbarPolicy="NEVER">
                        <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="650.0" prefWidth="1175.0">
                            <TableView fx:id="queueTable" layoutX="85.0" layoutY="55.0" prefHeight="475.0"
                                       prefWidth="1000.0"/>
                            <Label fx:id="viewLabel3" layoutX="85.0" layoutY="26.0" prefHeight="17.0"
                                   prefWidth="351.0"/>
                        </AnchorPane>
                    </ScrollPane>
                </Pane>
            </Tab>
        </TabPane>
</VBox>
</code>```

答:
You can achieve that via putting the ToolBarin another container then setting the container's alignment to TOP_CENTER.

Code:

```<code><?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.*?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.*?>

<VBox xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1"
      fx:controller="app.controller.TableViewController">

    <VBox alignment="TOP_CENTER">
        <ToolBar prefHeight="35.0" prefWidth="1200.0" style="-fx-background-color: #8C0000;">
            <ImageView fitHeight="35.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true">
                <Image url="@../images/react-toolbar-logo.png"/>
            </ImageView>
        </ToolBar>
    </VBox>

    <VBox alignment="CENTER">
        <TabPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
                 prefWidth="1200.0"
                 tabClosingPolicy="UNAVAILABLE">

            <Tab text="Technician View">
                <ScrollPane hbarPolicy="NEVER" vbarPolicy="NEVER" prefHeight="575.0" prefWidth="1175.0">
                    <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="650.0" prefWidth="1175.0">
                        <TableView fx:id="technicianTable" layoutX="85.0" layoutY="55.0" prefHeight="475.0"
                                   prefWidth="1025.0"/>
                        <Label fx:id="viewLabel1" layoutX="85.0" layoutY="26.0" prefHeight="17.0" prefWidth="351.0"/>
                    </AnchorPane>
                </ScrollPane>
            </Tab>

            <Tab text="Group View">
                <ScrollPane hbarPolicy="NEVER" vbarPolicy="NEVER" prefHeight="575.0" prefWidth="1175.0">
                    <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="650.0" prefWidth="1175.0">
                        <TableView fx:id="groupTable" layoutX="85.0" layoutY="55.0" prefHeight="475.0"
                                   prefWidth="1025.0"/>
                        <Label fx:id="viewLabel2" layoutX="85.0" layoutY="26.0" prefHeight="17.0" prefWidth="351.0"/>
                    </AnchorPane>
                </ScrollPane>
            </Tab>

            <Tab text="1-QUEUE">
                <ScrollPane hbarPolicy="NEVER" vbarPolicy="NEVER" prefHeight="575.0" prefWidth="1175.0">
                    <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="650.0" prefWidth="1175.0">
                        <TableView fx:id="queueTable" layoutX="85.0" layoutY="55.0" prefHeight="475.0"
                                   prefWidth="1025.0"/>
                        <Label fx:id="viewLabel3" layoutX="85.0" layoutY="26.0" prefHeight="17.0" prefWidth="351.0"/>
                    </AnchorPane>
                </ScrollPane>
            </Tab>

        </TabPane>
    </VBox>

</VBox>
</code>```

Body:
As you can see in the following image, the red Toolbar doesn't stay at the top of the screen. How can I top-align the Toolbar regardless of window scaling?

Image: http://i63.tinypic.com/r7iowg.png

scene.fxml:

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.*?>
<VBox alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
      prefHeight="650.0" prefWidth="1175.0"
      fx:controller="app.controller.TableViewController" xmlns="http://javafx.com/javafx/8.0.40"
      xmlns:fx="http://javafx.com/fxml/1">
        <ToolBar prefHeight="35.0" prefWidth="1200.0" style="-fx-background-color: #8C0000;">
            <ImageView fitHeight="35.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true">
                <Image url="@../images/react-toolbar-logo.png"/>
            </ImageView>
        </ToolBar>
        <TabPane layoutY="45.0" prefHeight="605.0" prefWidth="1175.0" tabClosingPolicy="UNAVAILABLE" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity">
            <Tab text="Technician View">
                <Pane prefHeight="485.0" prefWidth="1075.0">
                    <opaqueInsets>
                        <Insets/>
                    </opaqueInsets>
                    <ScrollPane hbarPolicy="NEVER" prefHeight="575.0" prefWidth="1175.0" vbarPolicy="NEVER">
                        <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="650.0" prefWidth="1175.0">
                            <TableView fx:id="technicianTable" layoutX="85.0" layoutY="55.0" prefHeight="475.0"
                                       prefWidth="1000.0" />

                        </AnchorPane>
                    </ScrollPane>
                </Pane>
            </Tab>
            <Tab text="Group View">
                <Pane prefHeight="485.0" prefWidth="1075.0">
                    <opaqueInsets>
                        <Insets/>
                    </opaqueInsets>
                    <ScrollPane hbarPolicy="NEVER" prefHeight="575.0" prefWidth="1175.0" vbarPolicy="NEVER">
                        <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="650.0" prefWidth="1175.0">
                            <TableView fx:id="groupTable" layoutX="85.0" layoutY="55.0" prefHeight="475.0"
                                       prefWidth="1000.0"/>

                        </AnchorPane>
                    </ScrollPane>
                </Pane>
            </Tab>
            <Tab text="1-QUEUE">
                <Pane prefHeight="485.0" prefWidth="1075.0">
                    <opaqueInsets>
                        <Insets/>
                    </opaqueInsets>
                    <ScrollPane hbarPolicy="NEVER" prefHeight="575.0" prefWidth="1175.0" vbarPolicy="NEVER">
                        <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="650.0" prefWidth="1175.0">
                            <TableView fx:id="queueTable" layoutX="85.0" layoutY="55.0" prefHeight="475.0"
                                       prefWidth="1000.0"/>

                        </AnchorPane>
                    </ScrollPane>
                </Pane>
            </Tab>
        </TabPane>
</VBox>

Body:
You can achieve that via putting the ToolBarin another container then setting the container's alignment to TOP_CENTER.

Code:

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.*?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.*?>

<VBox xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1"
      fx:controller="app.controller.TableViewController">

    <VBox alignment="TOP_CENTER">
        <ToolBar prefHeight="35.0" prefWidth="1200.0" style="-fx-background-color: #8C0000;">
            <ImageView fitHeight="35.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true">
                <Image url="@../images/react-toolbar-logo.png"/>
            </ImageView>
        </ToolBar>
    </VBox>

    <VBox alignment="CENTER">
        <TabPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
                 prefWidth="1200.0"
                 tabClosingPolicy="UNAVAILABLE">

            <Tab text="Technician View">
                <ScrollPane hbarPolicy="NEVER" vbarPolicy="NEVER" prefHeight="575.0" prefWidth="1175.0">
                    <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="650.0" prefWidth="1175.0">
                        <TableView fx:id="technicianTable" layoutX="85.0" layoutY="55.0" prefHeight="475.0"
                                   prefWidth="1025.0"/>
                        <Label fx:id="viewLabel1" layoutX="85.0" layoutY="26.0" prefHeight="17.0" prefWidth="351.0"/>
                    </AnchorPane>
                </ScrollPane>
            </Tab>

            <Tab text="Group View">
                <ScrollPane hbarPolicy="NEVER" vbarPolicy="NEVER" prefHeight="575.0" prefWidth="1175.0">
                    <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="650.0" prefWidth="1175.0">
                        <TableView fx:id="groupTable" layoutX="85.0" layoutY="55.0" prefHeight="475.0"
                                   prefWidth="1025.0"/>
                        <Label fx:id="viewLabel2" layoutX="85.0" layoutY="26.0" prefHeight="17.0" prefWidth="351.0"/>
                    </AnchorPane>
                </ScrollPane>
            </Tab>

            <Tab text="1-QUEUE">
                <ScrollPane hbarPolicy="NEVER" vbarPolicy="NEVER" prefHeight="575.0" prefWidth="1175.0">
                    <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="650.0" prefWidth="1175.0">
                        <TableView fx:id="queueTable" layoutX="85.0" layoutY="55.0" prefHeight="475.0"
                                   prefWidth="1025.0"/>
                        <Label fx:id="viewLabel3" layoutX="85.0" layoutY="26.0" prefHeight="17.0" prefWidth="351.0"/>
                    </AnchorPane>
                </ScrollPane>
            </Tab>

        </TabPane>
    </VBox>

</VBox>