text:
Q: react-native-fbsdk error: No resource found that matches the given name: attr 'android:keyboardNavigationCluster' In my react-native project in android/app/build.gradle i have
...
compileSdkVersion 26
    buildToolsVersion "26.0.1"

    defaultConfig {
        applicationId "..."
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }

...

dependencies {
    compile project(':react-native-fbsdk')
    compile project(':react-native-vector-icons')
    compile project(':react-native-splash-screen')
    compile project(':react-native-spinkit')
    compile project(':react-native-orientation')
    compile project(':react-native-maps')
    compile project(':react-native-android-sms-listener')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:26+"
    compile "com.android.support:design:26+"
    compile "com.android.support:recyclerview-v7:26+"
    compile "com.android.support:cardview-v7:26+"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile("com.crashlytics.sdk.android:crashlytics:2.8.0@aar") {
        transitive = true;
    }
}
...

but I always get
<mypath> .../node_modules/react-native-fbsdk/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:15:21-54: AAPT: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.

<mypath> .../node_modules/react-native-fbsdk/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:15: error: Error: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.

:react-native-fbsdk:processReleaseResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-fbsdk:processReleaseResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt

A: you go to YOUR_PROJECT/node_modules/react-native-fbsdk/android/build.gradle
looking for line 19:
dependencies {
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.facebook.react:react-native:+' // support react-native-v0.22-rc+
    compile('com.facebook.android:facebook-android-sdk:4.+')
}

change compile('com.facebook.android:facebook-android-sdk:4+') to compile('com.facebook.android:facebook-android-sdk:4.28.0')
It work for me

A: Go to React-Native Project : android/build.gradle file and restrict fbsdk Version to 4.28.0.
allprojects {
    repositories {
        ...
        configurations.all {
            resolutionStrategy {
                force 'com.facebook.android:facebook-android-sdk:4.28.0'
            }
        }
    }
}

If you have another error like below:

Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'`.

You can try:
allprojects {
    repositories {
        ...
        configurations.all {
            resolutionStrategy {
                force 'com.facebook.android:facebook-android-sdk:4.22.1'
            }
        }
    }
}

Source: rafaesc


text:
Q: MVC3 Validation for controls in a loop In my View, I'm making an entire html table editable.  Each field in the table has validation.  Here is some sample code...

    foreach (Item item in Model.Items)
    {

                @Html.TextBoxFor(x => em.Value)
                @Html.ValidationMessageFor(x => em.Value)

    }

This is creating two problems on the browser.
1)  Since the name attribute for all the  controls are the same, when one field is invalid, the error messages are displayed on all fields of the same name.
2)  Probably related to the names as well, when validating the form, if the  control in the first row is invalid, the form is invalid.  But  controls in all other rows will not invalidate the form (even though the error messages are displayed).
if (!$(form).valid()) {
    return false;
}

Any thoughts would be helpful.
UPDATE: THE SOLUTION
Per bobek suggestion, I created custom extensions for TextBoxInLoopFor and ValidationMessageInLoop.  Below is the solution:
public static MvcHtmlString TextBoxInLoopFor<TModel, IItem, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, IItem item, object htmlAttributes)
{
    var model = item as IInLoopForModel;
    if (model == null)
        return MvcHtmlString.Empty;

    var metadata = ModelMetadata.FromLambdaExpression(expression, html.ViewData);
    var fieldName = ExpressionHelper.GetExpressionText(expression);
    var name = model.Name + fieldName;

    var tag = new TagBuilder("input");
    tag.MergeAttributes(new RouteValueDictionary(htmlAttributes));
    tag.Attributes.Add("id", name);
    tag.Attributes.Add("for", name);
    tag.Attributes.Add("name", name);
    tag.Attributes.Add("value", metadata.Model.ToString());

    // Add the validation attributes
    ModelState modelState;
    if (html.ViewData.ModelState.TryGetValue(name, out modelState))
    {
        if (modelState.Errors.Count > 0)
            tag.AddCssClass(HtmlHelper.ValidationInputCssClassName);
    }
    tag.MergeAttributes(html.GetUnobtrusiveValidationAttributes(name, metadata));

    return MvcHtmlString.Create(tag.ToString(TagRenderMode.Normal));
}

public static MvcHtmlString ValidationMessageInLoopFor<TModel, IItem, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, IItem item)
{
        var model = item as IInLoopForModel;
    if (model == null)
        return MvcHtmlString.Empty;

    var fieldName = ExpressionHelper.GetExpressionText(expression);
    var name = model.Name + fieldName;

    var tag = new TagBuilder("span");
    tag.Attributes.Add("class", "field-validation-valid");
    tag.Attributes.Add("data-valmsg-replace", "true");
    tag.Attributes.Add("data-valmsg-for", name);
    return MvcHtmlString.Create(tag.ToString(TagRenderMode.Normal));
}

A: This is not valid at all. MVC3 helpers for input are adding an ID for each one so here you will have multiple textboxes with same ID - it's not valid in HTML.
You should manually create a TextBoxFor and ValidationFor your each property on the model, or if it's possible try:
foreach (Item item in Model.Items)
    {

                @Html.TextBoxFor(x => item.Value)
                @Html.ValidationMessageFor(x => item.Value)

    }

A: I would suggest using metadata in your domain.model . Here is a small example for you to understand the process :

namespace yourDomain.Domain.Model
{
    [MetadataType(typeof(fooEntityMeta))]
    public partial class fooEntity
    {
}

and pick the value field from your entity; make it required
public class fooEntityMeta
    {
        [Required(ErrorMessage = "Value is required")]
        public string Value;
       ...
    }

 here's a link that will help you through the process : http://msdn.microsoft.com/en-us/magazine/ee336030.aspx

redpajama_set_name: RedPajamaStackExchange


text:
Q: Unable to capture browser network logs with BrowserStack local, BrowserMobProxy embedded mode and Selenium 3.x using java Below is the dependencies in my maven pom.xml
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.14.0</version>

<groupId>net.lightbody.bmp</groupId>
<artifactId>[browsermob-core][1]</artifactId>
<version>2.1.5</version>

<groupId>com.browserstack</groupId>
<artifactId>[browserstack-local-java][1]</artifactId>
<version>1.0.3</version>

Below is the code which I'm using to initiate the BrowserMobProxy.
    private static void browserMobSeleniumProxyStart() {
        try {
            proxy = new BrowserMobProxyServer();
            proxy.setTrustAllServers(true);
            proxy.chainedProxyAuthorization(
                    System.getProperty("proxy.user"), System.getProperty("proxy.pass"), AuthType.BASIC);
            proxy.setChainedProxy(new InetSocketAddress(httpProxyHost, Integer.parseInt(httpProxyPort)));

            // Enable HAR.
            proxy.enableHarCaptureTypes(
                    EnumSet.of(
                            CaptureType.REQUEST_HEADERS,
                            CaptureType.REQUEST_CONTENT,
                            CaptureType.RESPONSE_CONTENT,
                            CaptureType.RESPONSE_HEADERS
                    )
            );
            proxy.start(browserLocalProxyPort);
            localHostAddress = Inet4Address.getLocalHost().getHostAddress();
            localHostPort = String.valueOf(proxy.getPort());
        } catch (Exception e) {
            proxy.stop();
            e.printStackTrace();
        }

Variables httpProxyHost and httpProxyPort are the corporateProxy IP and Port.
Below is the code to initiate the BrowserStack-local
    private static void browserStackLocalStart() {
        bsLocal = new Local();
        bsLocalArgs = new HashMap<>();
        bsLocalArgs.put("key", AUTOMATE_ACCESS_KEY);

        // BrowserStack local executable.
        bsLocalArgs.put("binarypath", format(BROWSERSTACK_PATH, "/src/test/resources/BrowserStackLocal"));

        // Force to use local and Corp proxy.
        bsLocalArgs.put("forcelocal", "true");
        bsLocalArgs.put("forceproxy", "true");

        // Set Corp Proxy and user crendentials.
        bsLocalArgs.put("proxyHost", httpProxyHost);
        bsLocalArgs.put("proxyPort", httpProxyPort);
        bsLocalArgs.put("proxyUser", System.getProperty("proxy.user"));
        bsLocalArgs.put("proxyPass", System.getProperty("proxy.password"));

        // Set local Proxy to BrowserMobProxy host - localhost ip and port and set user credentials.
        bsLocalArgs.put("localProxyHost", localHostAddress);
        bsLocalArgs.put("localProxyPort", localHostPort);
        bsLocalArgs.put("-localProxyUser", System.getProperty("proxy.user"));
        bsLocalArgs.put("-localProxyPass", System.getProperty("proxy.password"));
        seleniumProxy = ClientUtil.createSeleniumProxy(proxy);

        try {
            if(bsLocal.isRunning()) bsLocal.stop(bsLocalArgs);
            bsLocal.start(bsLocalArgs);
            log.info(format("Browser Stack Local status: %s", bsLocal.isRunning()));
        } catch (Exception e) {
            log.warning("!!! Cannot start browserstack local !!!");
        }
    }

Below is method to initiate the driver on BrowserStack
private static void setDriverWithBrowserstackOptions() {
        // Start BrowserMob proxy and browserstack-local.
        browserMobSeleniumProxyStart();
        browserStackLocalStart();

        String jobName = System.getenv("JOB_BASE_NAME");

        DesiredCapabilities caps = new DesiredCapabilities();
        caps.setCapability("browserstack.local", "true");
        caps.setCapability("browserstack.selenium_version", "3.14.0");
        caps.setCapability("browserstack.debug","true");
        caps.setCapability("browserstack.networkLogs","false");
        caps.setCapability("acceptSslCerts", "true");
        caps.setCapability("name", testName);
        caps.setCapability("project", "SampleProj");
        caps.setCapability("sessionName", "sessionName1");
        caps.setCapability("localIdentifier", "Local Test");
        caps.setCapability("build", "Local");
        caps.setCapability("browserstack.maskCommands", "setValues, getValues, setCookies, getCookies");
        caps.setCapability(CapabilityType.PROXY, seleniumProxy);

        // Chrome Options.
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--ignore-certificate-errors");
        caps.merge(ChromeOptions.CAPABILITY, options);
        URL url = null;
        try {
            url = new URL(URL);
        } catch (MalformedURLException e) {
            log.warning("Browserstack URL may be incorrect."+ URL);
        }

        // Initiate RemoteWebDriver instanc
        WebDriver d = new RemoteWebDriver(url, caps);

        // Create new HAR.
        proxy.newHar();

        try {
            d.get("https://google.com");
            Thread.sleep(10000);

           // Fetch Har entries.
            List<HarEntry> harEntries = proxy.getHar().getLog().getEntries();
            for (HarEntry h : harEntries) {
                System.out.println("---------------- HAR Request -----------------");
                System.out.println(h.getRequest());
                System.out.println("----------------------------------------------");
                System.out.println("---------------- HAR Response -----------------");
                System.out.println(h.getResponse());
                System.out.println("----------------------------------------------");
            }
        } catch (Exception e) {
            e.printStackTrace();

        }
    }

I tried with and without BrowserMobProxy setChainedProxy but had no luck to capture the HAR entries.
Any thoughts and comments are appreciated.

A: You just have to set the following capability to capture the network logs on BrowserStack:
caps.setCapability("browserstack.networkLogs","true");

Also, you can capture the contents of the requests made using browserstack.networkLogsOptions. More details on https://www.browserstack.com/automate/capabilities


text:
Q: How to pass raw string to Command in Rust? I have a fully formed string of the command I want to run with https://doc.rust-lang.org/std/process/struct.Command.html
For example "blah -a 'test arg'", how do I pass it in without parsing it myself which would require parsing quote group into an arg?
I tried passing the rest of the args after splitting.

A: I found shlex which is a lexer for shell words.

A: Another recommended crate for this purpose is shell-words.
It offers potentially better parsing with the difference that it returns a vector of Strings, not references.
Ref: related question

A: You can call out to a shell to run the command. Actually the docs you've linked to have an example of doing just that.
use std::process::Command;

let output = if cfg!(target_os = "windows") {
    Command::new("cmd")
            .args(["/C", "echo hello"])
            .output()
            .expect("failed to execute process")
} else {
    Command::new("sh")
            .arg("-c")
            .arg("echo hello")
            .output()
            .expect("failed to execute process")
};

let hello = output.stdout;

Just replace both instances of "echo hello" with the command you want to run.


text:
Q: Cannot align text next to image Here is the result I need to achieve:

Here is what I have thus far:

As you can see, there are several updates to be made.
My questions are:
1./ How do I get the text next to the avatar to line up 10px to the right of the avatar. Currently its being thrown below the avatar.
2./ Once I align up the text next to the avatar, how do I then line up my text that sits at the very right? I believe I can create a div and float right
I'm only a few days into CSS so I'm still a newbie so please any details would be phenomenial
Here is my HTML:

test

And Here is my CSS:
    @CHARSET "UTF-8";
    .page {
     position: relative;
     background-color: #ffffff;
     width: 1200px;
     margin: 0px auto;
     box-sizing: border-box;
     border-left: 1px solid #d0d0d0;
     border-right: 1px solid #d0d0d0;
    }
    table {
     border:0px;
     width:100%
    }
    table.reviewsouter .reviewleft{
     width:800px
    }
    table.reviewsouter .reviewright{
     width:400px
    }
    #reviewspotlight {
     position: relative;
     background-color:#000000;
     height:111px;
     z-index:19997;
     font-family: DinWebCond, Sans-serif;
     color:#ffffff;
    }
    #reviews {
      position: relative;
      background-color:#ffffff;
      color:#000000;
      border-right:1px solid #d0d0d0;
    }
    #reviews table tr.reviewuserinfo {
      background-color:#f0f0f0;
      height:60px;
      border-left:1px solid #d0d0d0;
    }
    #reviews table tr.reviewuserinfo img.avatar{
      position:relative;
      width:40px;
      height:40px;
      margin:10px 0px 10px 10px;
    }
    #reviews table tr.reviewuserinfo div {
      display:block
    }
    #reviews table tr.reviewuserdata {
      background-color:#ffffff;
      height: 315px;
      border-left:1px solid #ffffff;
    }

Any help would be great.
UPDATE
Ok so I got this far now:

Here is my new HTML for this div(the reviewuserinfo div):

            Text2
            Text3

What I need now is to move the text up so it starts at the same position as the top of the avatar - basically horizontal to the top of the image avatar

A: What do you think about this https://jsfiddle.net/2Lzo9vfc/107/
HTML

Lorem ipsum

Posted bla bla

Joined lorem ipsum

12 reviews bla lorem ipsum

CSS
 body, h4, p {
    margin: 0;
    padding: 0;
}

.page {
    padding: 20px;
    background: #F0F0F0;
    clear: both;
    display:inline-block;
    width: 100%;
}

.left {
    float: left;
}

.right {
    float: right;
}

.left-content, img {
    display: inline-block;
    vertical-align: middle;

}

A: What if you simply add horizontal cells and include the image and text in each one of them?


text:
Q: Cut command doesn't redirect Really curious why this doesn't work.  Spent the better part of a day trying to figure it out.
grep -r --line-buffered --include='*.txt' word . | cut -d ':' -f2-

this works fine and outputs things as expected
grep -r --line-buffered --include='*.txt' word . | cut -d ':' -f2- > reports/word.txt

This sends nothing to a file.  Can anyone tell me why this doesn't work, and perhaps how to get it to work
I am running Ubuntu 18.04


text:
Q: EXCEPTION: Error during evaluation of "click" occurs only after the 1st click I'm doing a ionic2 http post service.
Using the "(click)" function, my http post will be invoked and everything works the first time. The strange thing happens when I press the button the 2nd time.
This error pops up:

So i tried to play around with it. I have added a console.log inside my method which the click function is invoked.
On the 3rd time the button is pressed and so on, there is no error message , neither is my http post is working. Only my console.log inside the method are printing upon click.

This is my html:
<button  class="button button-block" (click)="loginSuccess()" style="width:70%;">
 Log In
</button>

This is my js:
loginSuccess() {
    console.log("Invoked Meod!");
    this.httpService.loginService("VariablesToThrowOver").subscribe(
    data => {this.httpService = data.results; console.log(data);},
    err => console.log(err),
    () => console.log('Invoked Login Service Complete'));
}

And this is my service js:
loginService(httpService) {
  console.log("Service Function Variable: "+httpService);
  var body = 'username=' + "admin" + '&password=' + "admin" +'';
  var headers = new Headers();
  headers.append('Content-Type', 'application/x-www-form-urlencoded');
  var url = 'http://localhost/webservice/userrWS.asmx/login';
  return this.http.post(url,body, {headers: headers}).map(res => res.json());
}

I'm guessing it has something to do with the subscribe service. If that is the case, how do i close the subscribe to allow for a identical request again?

A: Your code is a bit strange, specially at this line:
this.httpService.loginService("VariablesToThrowOver").subscribe(
  data => {this.httpService = data.results; console.log(data);}, // <------

In fact, you try to set the received data into the service variable itself you use to execute the login processing. I'm pretty sure that there is no loginService method into the object data.results. So when you click a second time, you will have an error...
I would choose another (and distinct) property of your component to store this data and display it into the view. Something like this:
this.httpService.loginService("VariablesToThrowOver").subscribe(
  data => {
    this.results = data.results; // <------
    console.log(data);
  },


text:
Q: How do you find a square on a grid from a position? The title might be a bit confusing, since I didn't know how to put this into one sentence.
I have a 10x10 grid and every square on the grid is 100 pixels (this is a programming problem) from edge to edge. If I have a position where the x and y-value represent pixels away from the top or left side of the grid, how can I determine which square on the grid contains the position?

A: The simplest method would be to use the ceiling function: that is, $\lceil x \rceil$ is the smallest integer which is not smaller than $x$. So, supposing the squares are numbered $1$ to $10$, a pair of coordinates $(x,y)$ becomes $(\lceil \frac{x}{100} \rceil , \lceil  \frac{y}{100}\rceil )$ - telling us the "square" coordinates. Take, for example, $(153, 814)$. Then the corresponding square is $(\lceil 1.53\rceil,\lceil 8.14 \rceil ) = (2, 9)$, i.e. the square that is second from the left and 9th from the bottom (alternatively, second from the top).


text:
Q: Serialize an object with an ArrayList inside I have this object Vehicle :
public class Vehicle {
    /**
     *
     */
    private String id;
    private int price;
    private transient ArrayList<String> comments = new ArrayList<>();

    public Vehicle(){

    }

    public String getID() {
        return id;
    }

    public int getPrice(){
        return price;
    }

    public void setID(String id) {
        this.id = id;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public List<String> getComments() {
        return comments;
    }

    public String[] getCommentsArray() {
        String[] commentsArray = new String[comments.size()];

        comments.toArray(commentsArray);

        return commentsArray;
    }
}

And i want to send it over the network with a web service. The problem is since that the vehicle object is composed by an ArrayList object, the server throw an exception (it does not happen when i remove the ArrayList field).
I suppose it's because the ArrayList fields isn't serializable.
I tried to make the Vehicle class serializble by following the intruction on this page. Wich means i tried to put the keyword transient for the comments field and implements the method wirteObject and readObject as follow.
private synchronized void writeObject(java.io.ObjectOutputStream stream) throws java.
io.IOException {
stream.defaultWriteObject( );
stream.writeInt(elementData.length);
for (int i=0; i<size; i++)
stream.writeObject(elementData[i]);
}

BUt it's still not working.
And here the WebService with the 2 methods i want to create :
public class VehicleDatabase {
    private HashMap<String, Vehicle> vehicles = new HashMap<>();

    public VehicleDatabase() {

    }

    //Not working because i use the vehicule wich is not serializable because of the ArrayList inside
    public boolean test1(Vehicle[] ve) {
        for(Vehicle v : ve) {

        }

        return true;
    }

    //Working
    public boolean test2() {

        return true;
    }
}

Here the exception the Apache TOmcat Servet is returning me when i want to create the WebService :

GRAVE: Unable to deploy typemapping: {http://database}>test1Response
  java.lang.ClassNotFoundException: database.Test1Response  at
  org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1285)
    at
  org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
    at org.apache.axis.utils.ClassUtils$2.run(ClassUtils.java:187)  at
  java.security.AccessController.doPrivileged(Native Method)    at
  org.apache.axis.utils.ClassUtils.loadClass(ClassUtils.java:160)   at
  org.apache.axis.utils.ClassUtils.forName(ClassUtils.java:100)     at
  org.apache.axis.deployment.wsdd.WSDDTypeMapping.getLanguageSpecificType(WSDDTypeMapping.java:183)
    at
  org.apache.axis.deployment.wsdd.WSDDService.deployTypeMapping(WSDDService.java:542)
    at
  org.apache.axis.deployment.wsdd.WSDDService.initTMR(WSDDService.java:253)
    at
  org.apache.axis.deployment.wsdd.WSDDService.(WSDDService.java:233)
    at
  org.apache.axis.deployment.wsdd.WSDDDeployment.(WSDDDeployment.java:192)
    at
  org.apache.axis.deployment.wsdd.WSDDDocument.(WSDDDocument.java:78)
    at org.apache.axis.utils.Admin.processWSDD(Admin.java:111)  at
  org.apache.axis.utils.Admin.process(Admin.java:158)   at
  org.apache.axis.utils.Admin.AdminService(Admin.java:65)   at
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)   at
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)     at
  org.apache.axis.providers.java.MsgProvider.processMessage(MsgProvider.java:126)
    at
  org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
    at
  org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)     at
  org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)   at
  org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
    at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)    at
  org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)     at
  org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)     at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at
  org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
    at
  org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
    at
  org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at
  org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at
  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at
  org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    at
  org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at
  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    at
  org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)
    at
  org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at
  org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
    at
  org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410)
    at
  org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at
  java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at
  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at
  org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)
nov. 06, 2016 10:57:46 AM
  org.apache.axis.deployment.wsdd.WSDDDeployment  INFOS: Ignoring
  non-fatal exception
  org.apache.axis.deployment.wsdd.WSDDNonFatalException:
  java.lang.ClassNotFoundException: database.Test1Response
  java.lang.ClassNotFoundException: database.Test1Response  at
  org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1285)
    at
  org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
    at org.apache.axis.utils.ClassUtils$2.run(ClassUtils.java:187)  at
  java.security.AccessController.doPrivileged(Native Method)    at
  org.apache.axis.utils.ClassUtils.loadClass(ClassUtils.java:160)   at
  org.apache.axis.utils.ClassUtils.forName(ClassUtils.java:100)     at
  org.apache.axis.deployment.wsdd.WSDDTypeMapping.getLanguageSpecificType(WSDDTypeMapping.java:183)
    at
  org.apache.axis.deployment.wsdd.WSDDService.deployTypeMapping(WSDDService.java:542)
    at
  org.apache.axis.deployment.wsdd.WSDDService.initTMR(WSDDService.java:253)
    at
  org.apache.axis.deployment.wsdd.WSDDService.(WSDDService.java:233)
    at
  org.apache.axis.deployment.wsdd.WSDDDeployment.(WSDDDeployment.java:192)
    at
  org.apache.axis.deployment.wsdd.WSDDDocument.(WSDDDocument.java:78)
    at org.apache.axis.utils.Admin.processWSDD(Admin.java:111)  at
  org.apache.axis.utils.Admin.process(Admin.java:158)   at
  org.apache.axis.utils.Admin.AdminService(Admin.java:65)   at
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)   at
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)     at
  org.apache.axis.providers.java.MsgProvider.processMessage(MsgProvider.java:126)
    at
  org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
    at
  org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)     at
  org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)   at
  org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
    at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)    at
  org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)     at
  org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)     at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at
  org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
    at
  org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
    at
  org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at
  org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at
  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at
  org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    at
  org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at
  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    at
  org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)
    at
  org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at
  org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
    at
  org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410)
    at
  org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at
  java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at
  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at
  org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)
org.apache.axis.deployment.wsdd.WSDDNonFatalException:
  java.lang.ClassNotFoundException: database.Test1Response
  java.lang.ClassNotFoundException: database.Test1Response  at
  org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1285)
    at
  org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
    at org.apache.axis.utils.ClassUtils$2.run(ClassUtils.java:187)  at
  java.security.AccessController.doPrivileged(Native Method)    at
  org.apache.axis.utils.ClassUtils.loadClass(ClassUtils.java:160)   at
  org.apache.axis.utils.ClassUtils.forName(ClassUtils.java:100)     at
  org.apache.axis.deployment.wsdd.WSDDTypeMapping.getLanguageSpecificType(WSDDTypeMapping.java:183)
    at
  org.apache.axis.deployment.wsdd.WSDDService.deployTypeMapping(WSDDService.java:542)
    at
  org.apache.axis.deployment.wsdd.WSDDService.initTMR(WSDDService.java:253)
    at
  org.apache.axis.deployment.wsdd.WSDDService.(WSDDService.java:233)
    at
  org.apache.axis.deployment.wsdd.WSDDDeployment.(WSDDDeployment.java:192)
    at
  org.apache.axis.deployment.wsdd.WSDDDocument.(WSDDDocument.java:78)
    at org.apache.axis.utils.Admin.processWSDD(Admin.java:111)  at
  org.apache.axis.utils.Admin.process(Admin.java:158)   at
  org.apache.axis.utils.Admin.AdminService(Admin.java:65)   at
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)   at
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)     at
  org.apache.axis.providers.java.MsgProvider.processMessage(MsgProvider.java:126)
    at
  org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
    at
  org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)     at
  org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)   at
  org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
    at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)    at
  org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)     at
  org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)     at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at
  org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
    at
  org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
    at
  org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at
  org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at
  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at
  org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    at
  org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at
  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    at
  org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)
    at
  org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at
  org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
    at
  org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410)
    at
  org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at
  java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at
  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at
  org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)
at
  org.apache.axis.deployment.wsdd.WSDDService.deployTypeMapping(WSDDService.java:561)
    at
  org.apache.axis.deployment.wsdd.WSDDService.initTMR(WSDDService.java:253)
    at
  org.apache.axis.deployment.wsdd.WSDDService.(WSDDService.java:233)
    at
  org.apache.axis.deployment.wsdd.WSDDDeployment.(WSDDDeployment.java:192)
    at
  org.apache.axis.deployment.wsdd.WSDDDocument.(WSDDDocument.java:78)
    at org.apache.axis.utils.Admin.processWSDD(Admin.java:111)  at
  org.apache.axis.utils.Admin.process(Admin.java:158)   at
  org.apache.axis.utils.Admin.AdminService(Admin.java:65)   at
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)   at
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)     at
  org.apache.axis.providers.java.MsgProvider.processMessage(MsgProvider.java:126)
    at
  org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
    at
  org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)     at
  org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)   at
  org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
    at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)    at
  org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)     at
  org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)     at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at
  org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
    at
  org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
    at
  org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at
  org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at
  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at
  org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    at
  org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at
  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    at
  org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)
    at
  org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at
  org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
    at
  org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410)
    at
  org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at
  java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at
  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at
  org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)
at
  org.apache.axis.deployment.wsdd.WSDDService.deployTypeMapping(WSDDService.java:561)
    at
  org.apache.axis.deployment.wsdd.WSDDService.initTMR(WSDDService.java:253)
    at
  org.apache.axis.deployment.wsdd.WSDDService.(WSDDService.java:233)
    at
  org.apache.axis.deployment.wsdd.WSDDDeployment.(WSDDDeployment.java:192)
    at
  org.apache.axis.deployment.wsdd.WSDDDocument.(WSDDDocument.java:78)
    at org.apache.axis.utils.Admin.processWSDD(Admin.java:111)  at
  org.apache.axis.utils.Admin.process(Admin.java:158)   at
  org.apache.axis.utils.Admin.AdminService(Admin.java:65)   at
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)   at
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)     at
  org.apache.axis.providers.java.MsgProvider.processMessage(MsgProvider.java:126)
    at
  org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
    at
  org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)     at
  org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)   at
  org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
    at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)    at
  org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)     at
  org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)     at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at
  org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
    at
  org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
    at
  org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at
  org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at
  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at
  org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    at
  org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at
  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    at
  org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)
    at
  org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at
  org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
    at
  org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410)
    at
  org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at
  java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at
  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at
  org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)


text:
Q: How common is string manipulation, really? I've noticed a lot of programming introductions (almost any language) usually include a heavy barrage of string manipulation quite early, such as:

*

*Count the number of "xx" in the given string. We'll say that overlapping is allowed, so "xxx" contains 2 "xx".

*Reverse the given string and remove all vowels from it.

Not just online courses, but even in degree programmes.
But the thing is, I've never encountered a situation in "real life" where you had to do anything like that. Is it just luck, or do you really need to do heavy manipulation in the above manner in some fields of programming? Can you give a description or an example where it is needed?
Edit:
Just to clarify, not necessarily string processing itself as in echoing variables to a html template, or other basic stuff like that, but the more arcane type of processing, like reading every second character? But yes, perhaps it is just for training purposes instead of direct needs. The file format conversion is a good note, though.

A: Text files and text data are everywhere.
Converting .csv to .xml, reading .py for execution or .f90 for compilation, building and sending spam from a list of mail addresses, building a database of keywords for indexing the web: all of that is string manipulation.
Do computers do something else than manipulating strings?

A: String manipulation actually is fairly common when you're doing I/O, which includes most network programming. Unicode complicates things, of course, but text remains the closest thing we have to a universal interface.
But where it really shines is as a metaphor. Working with individual characters in strings is, in many ways, not unlike working with cells in memory. At the lowest levels, the operations can be almost identical. This makes strings a less abstract way of learning the very basics of working with data at low levels, and that makes it valuable to learn early.

A: These are very specific examples, really just given as training for string manipulation.
And it is more common than you think - mostly in parsing and UI code.
For example - parsing dates out of strings - this requires extensive string manipulation.
Or parsing HTML into a DOM - same kind of thing.
You will also need to manipulate strings for UI purposes - constructing strings based on specific data and conditions.

A:
Is it just luck, or do you really need to do heavy manipulation in the above manner in some fields of programming?

There are domains where string manipulation is not a necessity, or it is a marginal problem. There are also domains where it is a critical requirement.
For example, web technologies depend critically on text manipulation (web and mail servers and clients); so do most software development tools (IDEs, editors, compilers, etc).

A: Real life programming will almost certainly involve string manipulation at one point or another. Your example is a very specific case and may or may not appear in a real life scenario (In reality, I'm sure somebody, somewhere has had to tackle that problem in real life).
However, the real life applicability of a particular use case is not necessarily the point of those exercises when introducing a new language or teaching someone brand new to programming. The point of those exercises are likely to be any of the following (depending on context):

*

*To teach a programmer the basic syntax of a given language using an easily understood problem.

*To provide an exercise allowing novice programmers to learn basic programming logic without having to understand a complex problem.

*To express a languages ability to solve a particular string manipulation problem.


text:
Q: Calculating log-sum-exp function in c++ Are there any functions in the c++ standard library that calculate the log of the sum of exponentials? If not, how should I go about writing my own? Do you have any suggestions not mentioned in this wiki article?
I am concerned specifically with the possibility that the summands will underflow. This is the situation where you are exponentiating negative numbers that have a large absolute value. I am using c++11.

A: (C++11 variant of shuvro's code, using the Standard Library as per the question.)
template <typename Iter>
std::iterator_traits<Iter>::value_type
log_sum_exp(Iter begin, Iter end)
{
  using VT = std::iterator_traits<Iter>::value_type{};
  if (begin==end) return VT{};
  using std::exp;
  using std::log;
  auto max_elem = *std::max_element(begin, end);
  auto sum = std::accumulate(begin, end, VT{},
     [max_elem](VT a, VT b) { return a + exp(b - max_elem); });
  return max_elem + log(sum);
}

This version is more generic - it will work on any type of value, in any type of container, as long as it has the relevant operators. In particular, it will use std::exp and std::log unless the value type has its own overloads.
To be really robust against underflow, even for unknown numeric types, it probably would be beneficial to sort the values. If you sort the inputs, the very first value will be max_elem, so the first term of sum will be exp(VT{0} which presumably is VT{1}. That's clearly free from underflow.

A: If you want smaller code, this implementation could do the job:
double log_sum_exp(double arr[], int count)
{
   if(count > 0 ){
      double maxVal = arr[0];
      double sum = 0;

      for (int i = 1 ; i < count ; i++){
         if (arr[i] > maxVal){
            maxVal = arr[i];
         }
      }

      for (int i = 0; i < count ; i++){
         sum += exp(arr[i] - maxVal);
      }
      return log(sum) + maxVal;

   }
   else
   {
      return 0.0;
   }
}

You can see a more robust implementation on Takeda 25's blog (Japanese) (or, see it in English, via Google Translate).


text:
Q: Problems with top and left option in jQGrid for event viewGridRow, cant parse cursor location I'm having a problem with my jQGrid. I'm trying to make it so that when the viewGridRow event triggers, to set the position of the popup window to the position of the cursor. I have a long list in the grid and defaults put the window at the top of the grid.
atm i have functions that retrieve the cursor position via jQuery:
var CursorX;
var CursorY;
$(document).bind('dblclick', function (e) { CursorX = e.pageX; })
$(document).bind('dblclick', function (e) { CursorY = e.pageY; })

and the configuration for the viewGridRow is as follows:
ondblClickRow: function (rowid) {
    jQuery("#grid").jqGrid('viewGridRow', rowid, {
        top: CursorY,
        left: CursorX,
        modal: true,
        width: 1500,
        caption: "View Item",
        recreateForm: true,
        beforeShowForm: function (form) {
            jQuery("#grid").
            setColProp('last_instruct', { formatter: "unformat" });
        },
    });
},

Problem is it doesn't seem to work.
Anyone have an idea what i did wrong?

A: Just tested on one of my own grids and as wrote the problem is that the jQgrid is processing the ondblClick event before the variables are getting updated.
Do away with your binding of:
var CursorX;
var CursorY;
$(document).bind('dblclick', function (e) { CursorX = e.pageX; })
$(document).bind('dblclick', function (e) { CursorY = e.pageY; })

and just move to
    top: e.pageY,
    left: e.pageX,

you will also need to update your ondblClickRow to
ondblClickRow: function (rowid, iRow, iCol, e) {

Edit (to ensure the jQgrid is recreating a new view/edit, etc window each time.
Ex (Recreate a new edit form each time)
    $.extend($.jgrid.edit, { closeAfterEdit: true, recreateForm: true });

As a side note, you might want to think about what will happen when a user doubleclicks on an area that produces a form that will be outside the normal viewing area.


text:
Q: Como utilizar a API do Youtube? Tenho uma pagina com um video que abre num modal, preciso que ele fique pausado quando o modal estiver ocultado.
Testei exemplos que encontrei em outros sites mas não funcionou.
Preciso adicionar algum arquivo extra para utilizar o control da API?

A: Não sei como você está fechando o seu modal, mas se vc está utilizando .hide() do jQuery, você pode fazer o seguinte:
function pause_video(){
    $('#youtube_iframe_id')[0].contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
}

function hideCallBack() {
    pause_video()
}

Com as duas funções adicionadas no seu código, seu vídeo será pausado quando você fechar o modal usando:
$('#modal_id').hide(hideCallBack);


text:
Q: Control which monitor a window opens on How can I control which monitor a window opens on in Windows 10? Windows seems quite random this way. Some windows open on whichever monitor they last were on (a reasonable option), while others (most annoyingly Adobe Reader) always open on the primary monitor instead of the monitor I want them on. Of course I can hit Shift+Win+Left or Right to move the window, but I'd prefer to not have to do that. If there was some program that could just be configured to always place windows from configured applications on a specific monitor, that would be awesome.
There are other related questions, but a) they're really old, mostly predating Windows 10, and b) they end up recommending changing to an entirely new window manager, which seems rather drastic to solve one issue.
For background, I'm a longtime Linux user, and in Ubuntu when I open a window it opens on whichever monitor has the mouse pointer. This is convenient as it gives me a simple way to influence the choice.


text:
Q: How to set the redirect uri in the stack overflow rest api I am trying to authorize google app script to the stack overflow rest api.
My script asks me to open the authorization window and everything looks good from there except after I have authorized the app I get.

redirect_uri is not under the registered domain for this application

The redirect URI app script is creating is as follows.

https://script.google.com/macros/d/1iGFdsYBrkOTRYdyv0A81xITdFetvhfxcR_s_3iOj0dyds_Zbk1wzGAG9/usercallback

I have searched all over and I cant seem to figure out how to configure the redirect uri in my client for stack overflow API.

A: stackApps side:
In your situation, please set the Stackoverflow side as follows.

*

*OAuth Domain is script.google.com.

*Application Website is https://script.google.com/macros/d/1iGFdsYBrkOTRYdyv0A81xITdFetvhfxcR_s_3iOj0dyds_Zbk1wzGAG9/usercallback.

Google Apps Script side:
Please modify your script as follows.
From:
var tokenExchangeUrl = "https://stackoverflow.com/oauth/access_token"

To:
var tokenExchangeUrl = "https://stackoverflow.com/oauth/access_token/json"

And, in your script, the scope is not included. So, please modify getService_() as follows.
function getService_() {
  return OAuth2.createService('StackOverflow')
      // Set the endpoint URLs.
      .setAuthorizationBaseUrl(authorizationUrl)
      .setTokenUrl(tokenExchangeUrl)
      .setScope(scope) // Added

      // Set the client ID and secret.
      .setClientId(CLIENT_ID)
      .setClientSecret(CLIENT_SECRET)

      // Set the name of the callback function that should be invoked to
      // complete the OAuth flow.
      .setCallbackFunction('authCallback')

      // Set the property store where authorized tokens should be persisted.
      .setPropertyStore(PropertiesService.getUserProperties());
}

And, I think that the sample request is required to be modified. So, how about the following sample?
From:
var url = authorizationUrl;

var response = UrlFetchApp.fetch(url, {
  headers: {
    'Authorization': 'Bearer ' + service.getAccessToken()
  }
});

To:
var url = `https://api.stackexchange.com/2.3/me/inbox?site=stackoverflow&key=${key}&access_token=${service.getAccessToken()}`;
var response = UrlFetchApp.fetch(url);

*

*By this modification, the access token can be retrieved and the inbox can be retrieved using the access token.

Note:

*

*As additional information, the whole modified script is as follows.

var CLIENT_ID = [REDACTED];
var CLIENT_SECRET = [REDACTED]
var key = [REDACTEd]

var authorizationUrl = "https://stackoverflow.com/oauth"
var tokenExchangeUrl = "https://stackoverflow.com/oauth/access_token/json"
var scope = "read_inbox"

/**
 * Authorizes and makes a request to the Stackoverflow API.
 */
function run() {
  var service = getService_();
  console.log(service.getRedirectUri())
  if (service.hasAccess()) {
    var url = `https://api.stackexchange.com/2.3/me/inbox?site=stackoverflow&key=${key}&access_token=${service.getAccessToken()}`;
    var response = UrlFetchApp.fetch(url);
    var result = JSON.parse(response.getContentText());
    Logger.log(JSON.stringify(result, null, 2));
  } else {
    var authorizationUrl = service.getAuthorizationUrl();
    Logger.log('Open the following URL and re-run the script: %s',
        authorizationUrl);
  }
}

/**
 * Reset the authorization state, so that it can be re-tested.
 */
function reset() {
  getService_().reset();
}

/**
 * Configures the service.
 */
function getService_() {
  return OAuth2.createService('StackOverflow')
      // Set the endpoint URLs.
      .setAuthorizationBaseUrl(authorizationUrl)
      .setTokenUrl(tokenExchangeUrl)
      .setScope(scope)

      // Set the client ID and secret.
      .setClientId(CLIENT_ID)
      .setClientSecret(CLIENT_SECRET)

      // Set the name of the callback function that should be invoked to
      // complete the OAuth flow.
      .setCallbackFunction('authCallback')

      // Set the property store where authorized tokens should be persisted.
      .setPropertyStore(PropertiesService.getUserProperties());
}

/**
 * Handles the OAuth callback.
 */
function authCallback(request) {
  var service = getService_();
  var authorized = service.handleCallback(request);
  if (authorized) {
    return HtmlService.createHtmlOutput('Success!');
  } else {
    return HtmlService.createHtmlOutput('Denied.');
  }
}

/**
 * Logs the redict URI to register.
 */
function logRedirectUri() {
  Logger.log(OAuth2.getRedirectUri());
}

Reference:

*

*apps-script-oauth2


text:
Q: Event Propagation in react-native-maps I'm working with a map in react-native-maps that displays a number of Polygons. Each polygon has listeners and the map itself has listeners. On click, I'd like to either highlight a polygon or drop a marker if the click happens where there is no polygon. Unfortunately, I'm not seeing a way to stopPropagation after a polygon click. For now, I'm just using a setTimeout to disable new markers from being made for .5 secs after a polygon is clicked.
Is there a more graceful solution that I'm not aware of. I was unable to get event.stopPropagation to work with the event react-native-maps sends back.


text:
Q: Is this random variable exponential? My problem:
Suppose $Y$ is a real random variable with $Y \sim Exp(\lambda)$ and $Z$ is indipendent from $Y$, with density and $Z \geq 0$.
Why can I say $\mathbb{P}(Y-Z \geq t|Y>Z)=e^{-\lambda t}$?
My attempt:
I actually do not know how to proceed.

A: $P(Y >t+s)=e^{-\lambda(t+s)}=e^{-\lambda t} P(Y>s)$ for each $s$. Integrating w.r.t. the distribution $F_Z$ of $Z$ and using indepedence this becomes $P(Y>t+Z)=e^{-\lambda t} P(Y>Z)$. Divide by $P(Y>Z)$ to finish the proof.


text:
Q: c programming, linked list error When i try to compile the following code, i get the error
test.c: In function 'main':
test.c:16: error: incompatible types in assignment

and the code is..
#include <stdio.h>
#include <ctype.h>
#include <string.h>

typedef struct {
    char name[20];
    struct planet* next;
} planet;

int main(int argc, char *argv[])
{
    planet *p, *start, *first, *second, *third;

    strcpy(start->name, "Suthan");
    start->next = *first;

}

A: 1) Allocate some memory to your pointers.
planet *start, *first; these are uninitialized pointers.

start->next // that's dereferencing an uninitialized pointer.

2) You're setting start->next (a pointer to a planet) to a deferenced pointer first. That's the root of your error.
start->next = *first;  // should be  = first;

3) Move the typedef name to get rid of the warning you were seeing.
typedef struct planet{
   char name[20];
   struct planet* next;
};

A: Since are trying to assign an instance of planet (*first) to a pointer to planet (start->next).
Try this instead:
start->next = first;

However, I'm also wondering about your declaration of planet. Does this help?
typedef struct _planet {
    char name[20];
    struct _planet* next;
} planet;

A: I think you did your struct incorrectly
typedef struct _planet {
    char name[20];
    struct _planet* next;
} planet;

Should be:
typedef struct planet {
char name[20];
struct planet* next;
}

A: I remember tripping over this aspect of self-referential structs.
typedef struct {
    char name[20];
    struct planet* next; /* <-- the trouble is here */
} planet;

In the middle of the struct definition, which is in the middle of a typedef definition, the compiler doesn't know what a struct planet looks like, but is happy to let you define a pointer to it. The compiler doesn't really need to know what it looks like until you dereference *next. By the time you get to the body of main() you still haven't told the compiler what a struct planet is, only a type called planet which happens to be an unnamed struct.
Consider the following approach.
struct foo {
    int bar;
};

typedef struct foo foo_type;

struct foo bar;
foo_type baz;

This shows that the name of the struct is foo and the name of the defined type is foo_type. I could combine them like this:
typedef struct foo {
    int bar;
} foo_type;

You can resolve the compiler warning by adding a dummy name to your inline struct definition.
typedef struct planet_struct {
    char name[20];
    struct planet_struct* next;
} planet;

You will also need to address the memory allocation issue that others have pointed out, but this answers the question you didn't actually ask.


text:
Q: How to add file browsing window to Notepad++ I've been looking into the plugin manager for this, but when i installed the "Explorer" plugin, it totally crashed the application.
I was unable to launch it again, untill i removed the .dll from the plugins directory.
Any insights on this ?

A: Try removing all of your Notepad++ plugins. Then reinstall only the Explorer plugin. If it works, then another Notepad++ plugin that you had installed was probably interfering with the Explorer plugin.


text:
Q: Accessing soap over https in silverlight I have a server that i am hosting on another computer with axis2 and apache. IM simply trying to connect to it over https.
CustomBinding binding = new CustomBinding(SecurityBindingElement.CreateUserNameOverTransportBindingElement());

binding.Elements.Add(new HttpsTransportBindingElement());
EndpointAddress endpoint = new EndpointAddress("https://othercomputer/axis2/services/DataModel");
DataClient client = new DataClient(binding, endpoint);
client.ClientCredentials.UserName.UserName = "a";
client.ClientCredentials.UserName.Password = "a12345";
return client;

I get a communication exception was unhandled by user code with this code, am i doing it right?
Edit with further requested info:
Heres the exception:

An error occurred while trying to make a request to URI 'https://othercomputer/axis
  /services/DataModel'. This could be due to attempting to access a service in a cross-
  domain way without a proper cross-domain policy in place, or a policy that is
  unsuitable for SOAP services. You may need to contact the owner of the service to
  publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers
  to be sent. This error may also be caused by using internal types in the web service
  proxy without using the InternalsVisibleToAttribute attribute. Please see the inner
  exception for more details.

The authentication is basic authentication, one of my coworkers thinks its a problem with the certificate and thought that it might be because the certificate is self-generated.

A: Its being treated as a cross-domain call.  You need to add a clientaccesspolicy.xml file that is accessible through the same server that you are making the SOAP call to.


text:
Q: Amount of real numbers, in a given sequence, whose fractional part lies in a given closed interval Fix an interval $[a,b] \subset [0,1]$ and let $S$ be a given sequence of real numbers. Are there any ad-hoc methods that may be used to estimate
$$
T := \#\{ s \in S \ : \ \{s\} \in [a,b]\}?
$$
Here $\{s\} := s - \lfloor s \rfloor$ denotes the fractional part of $s$. I have some ideas but I'm not sure these will be useful. Perhaps some of you have seen these things before?
For example suppose that $S = (f(n))_{n \in [1,N] \cap \mathbb{Z}}$ for some smooth function $f : \mathbb{R} \to \mathbb{R}$ (you may think of an easy example for $f$; I'm interested in a general methodology here) and some positive integer $N$. Now
$$
T = \sum_{n=1}^N 1_{[a,b]}(\{f(n)\}).
$$
A possible direction here (but I don't know if this strategy could work) could be to introduce a smooth bump or cuttoff function $\phi$ supported on $[a,b]$ and approximate $T$ by
$$
T_\phi = \sum_{n=1}^N \phi(\{f(n)\}).
$$
Since $f,\phi$ are smooth and the function $\{x\}$ is differentiable on $\mathbb{R}\setminus \mathbb{Z}$, then, assuming $f(x) \in \mathbb{Z}$ for only finitely many $x \in [1,N]$, (I think) one could use the Euler-Maclaurin formula to express $T_\phi$ as an integral on $[1,N]$. Then hopefully use what is known about integrals involving the fractional-part function (see here for instance http://www.springer.com/cda/content/document/cda_downloaddocument/9781461467618-c1.pdf?SGWID=0-0-45-1446028-p174908973) to get an estimate. Do you think this approach might work? Have you seen these types of things before? It would be interesting if you know some examples. For instance what cutt-off functions could be useful here? Thanks!

A: The most common approach is to use Fourier analysis.
Start with your sum
$$T_\phi = \sum_{n=1}^N \phi(\{f(n)\}).$$
We may replace $\phi$ by a $1$-periodic function on $\mathbb{R}/\mathbb{Z}$, since the fractional parts function is $1$-periodic. Thus, we wish to estimate
$$T_\phi = \sum_{n=1}^N \phi(f(n)).$$
Since $\phi$ is periodic and smooth, it has a Fourier series whose coefficients have nice decay properties. The zero frequency will give the main term, and the nonzero frequencies should contribute to the error term.
Showing the the contribution of the nonzero frequencies is small requires showing the relevant exponential sums are small (i.e. exhibit cancellation). The sums to estimate look like
$$\sum_{n=1}^N e^{2\pi i h f(n)},$$
for some $h \neq 0$.
Let's give a sketch of how this works for a specific example. Let $[a,b] \subset [0,1]$ be a fixed interval, and suppose we wish to study
$$F := \sum_{n = 1}^N \textbf{1}(a \leq \{\sqrt{n}\} \leq b).$$
We let $\phi$ be a smooth function supported on $[a,b]$ which is equal to $1$ on $[a+\epsilon,b - \epsilon]$, and extend $\phi$ by periodicity. Therefore $\phi$ has a Fourier series
$$\phi(x) = \sum_{h \in \mathbb{Z}} c_h e(hx),$$
where $e(y) = e^{2\pi i y}$ and
$$c_h = \int_0^1 \phi(t) e(-ht)dt.$$
Integration by parts shows
$$|c_h| \ll_j (1+|h|)^{-j}$$
for all $j \geq 0$.
We now return to studying $F$. We have
$$F \geq \sum_{n=1}^N \phi(\sqrt{n}),$$
and expanding $\phi$ in its Fourier series yields
$$F \geq \widehat{\phi}(0) N + \sum_{h \neq 0} c_h \sum_{n=1}^N e(h \sqrt{n}).$$
We can study the exponential sum
$$\sum_{n=1}^N e(h \sqrt{n}), \ \ \ \ \ \ h \neq 0,$$
by Euler-Maclaurin summation. Indeed, we have
$$\sum_{n=1}^N e(h \sqrt{n}) = \int_1^N e(h\sqrt{t})dt + 2\pi i h \int_1^N \frac{\{t\}e(h\sqrt{t})}{\sqrt{t}}dt + O(1),$$
which implies
$$\sum_{n=1}^N e(h \sqrt{n}) \ll \frac{N^{1/2}}{|h|} + |h| N^{1/2}.$$
Upon summing over $h$ we obtain
$$F \geq \widehat{\phi}(0) N + O(N^{1/2}) \geq (b-a-2\epsilon) N + O(N^{1/2}).$$
We may handle an upper bound for $F$ in an entirely similar fashion. Letting $\epsilon \rightarrow 0$ slowly, we get
$$F = \sum_{n = 1}^N \textbf{1}(a \leq \{\sqrt{n}\} \leq b) \sim (b-a)N$$
as $N \rightarrow \infty$.

A: I give a different method not involving Fourier analysis. It is based on mollifiers, which serve to smooth out rough functions such as indicators. For some background on mollifiers see for instance the wiki and these set of notes.
As a way of comparison with the Fourier analytic method described above by Kyle, let us treat again the example with $f(x) = \sqrt{x}$:
Fix real numbers $0\leq a < b < 1$ and consider
$$
S := \#\{ 1 \leq n \leq N \ : \ a \leq \{\sqrt{n}\} \leq b\}.
$$
Let $\chi$ be the characteristic function of the union $\bigcup_{1 \leq k \leq \sqrt{N}} [k+a, k+b]$ of intervals, where $k$ runs over the integers in $[1,\sqrt{N}]$. Then it is clear that
$$
S = \sum_{n=1}^N \chi(\sqrt{n}).
$$
For $\delta > 0$, let $\phi_\delta$ be the standard mollifier and let
$$
\chi_\delta(x) := (\chi \ast \phi_\delta)(x) = \int_{\mathbb{R}} \chi(y)\phi_\delta(x - y)dy = \sum_{k \leq \sqrt{N}}\int_{k+a}^{k+b} \phi_\delta(x-y) dy
$$
be a mollification of $\chi$.
Note that $\chi_\delta$ is smooth for each $\delta > 0$, and $\chi_\delta(x)\to \chi(x)$ as $\delta \to 0^+$, for any $x \in \mathbb{R}$.
Consequently
$$
S_\delta := \sum_{n=1}^N \chi_\delta(\sqrt{n}) \to S
$$
as $\delta \to 0^+$. Now since the function $\chi_\delta(\sqrt{x})$ is smooth in $x$ on the interval $[1,N]$, the Euler-Maclaurin summation formula gives
\begin{align*}
S_\delta &= \int_{1}^N \chi_\delta(\sqrt{x})dx + \dfrac{1}{2}\int_{1}^N \dfrac{\{x\}}{\sqrt{x}}\chi_\delta'(\sqrt{x}) dx + O(1)\\
&= 2\int_1^{\sqrt{N} }t\chi_\delta(t) dt + \int_{1}^{\sqrt{N}} \{t^2\}\chi_\delta'(t) dt + O(1).
\end{align*}
The $O(1)$ comes from the fact that $\chi_\delta(1) = O(1)$. Indeed, from the definition of $\chi_\delta$ one can show that $|\chi_\delta(c)| \leq 1$ uniformly for every $\delta > 0$ and every $c \in \mathbb{R}$. Since $\chi_\delta$ is absolutely bounded by 1 uniformly in $\delta > 0$, the dominated convergence theorem ensures that the first integral satisfies
\begin{equation}\label{eqn: 0}
2\int_1^{\sqrt{N} }t\chi_\delta(t) dt \to 2\int_1^{\sqrt{N} }t\chi(t) dt
\end{equation}
as $\delta \to 0^+$. We have
\begin{align*}
2\int_1^{\sqrt{N} }t\chi(t) dt &= 2\sum_{k \leq \sqrt{N}} \int_{k+a}^{k+b} t dt + O(1) \\
&= \sum_{k \leq \sqrt{N}}(2(b-a)k + b^2 - a^2) + O(1)\\
&= (b-a)N + O(\sqrt{N}).
\end{align*}
Consider now the second integral. We have
\begin{align*}
\int_1^{\sqrt{N}}\{t^2\}\chi_\delta'(t)dt &= \int_1^{\sqrt{N}}\{t^2\}(\chi \ast \phi_\delta')(t)dt\\
&= \int_{1}^{\sqrt{N}} \{t^2\}\sum_{k \leq \sqrt{N}} \int_{k+a}^{k+b} \phi_\delta'(t-y) dy dt\\
&= \sum_{k \leq \sqrt{N}} \int_1^{\sqrt{N}}\{t^2\}(\phi_\delta(t - k - a) - \phi_\delta(t - k - b))dt\\
&= \sum_{k \leq \sqrt{N}} \int_1^{\sqrt{N}}\{t^2\}(\phi_\delta(k+a - t) - \phi_\delta(k+b - t))dt.
\end{align*}
The last equality uses the symmetry of $\phi_\delta$. Note that for each $k$,
$$
\int_1^{\sqrt{N}}\{t^2\}(\phi_\delta(k+a - t) - \phi_\delta(k+b - t))dt = (h \ast \phi_\delta)(k+a) - (h \ast \phi_\delta)(k+b),
$$
where $h$ is the function $h(x) = 1_{[1, \sqrt{N}]}(x) \cdot \{x^2\}$. It follows that
\begin{align*}
\lim_{\delta \to 0^+} \int_1^{\sqrt{N}}\{t^2\}\chi_\delta'(t)dt &= \sum_{k \leq \sqrt{N}} \lim_{\delta \to 0^+}((h \ast \phi_\delta)(k+a) - (h \ast \phi_\delta)(k+b))\\
&= \sum_{k \leq \sqrt{N}}(h(k+a) - h(k+b))\\
&= O(\sqrt{N}).
\end{align*}
Putting everything together we conclude that $S = (b-a)N + O(\sqrt{N})$.


text:
Q: VBA Automation/Monitoring/Development I am working as coordinator of EUCs at my department (more than 50 people and more than 150 MS Excel macros for controls and reporting). In order to keep good track of Macros usage and measuring tool performance, I have added a simple code to each workbook that collects usage data (who and when had opened/closed workbook, how much it takes for a macro to perform certain tasks, etc...). The code is pretty simple, it collects all data in a public variable and before the close of the workbook, it saves the content of a variable to a .txt file in a folder.
Option Explicit

Dim info_data as String

Sub check_point(x as integer)
Select x
 Case 0
 Call WBK_close
 Case 1
 Call WBK_open
 Case 2
 Call WBK_main_start
 Case 3
 Call WBK_main_end
End Select
End Sub

Private Sub WBK_close()
 info_data = info_data & "WBK Close;" & Now()
 Open myFile For Output As #1
 Print #1, info_data
 Close #1
End Sub

Private Sub WBK_open()
 info_data = "WBK Open;" & Now() & vbNewLine
End Sub

Private Sub WBK_main_start()
 info_data = "WBK Main Start;" & Now() & vbNewLine
End Sub

Private Sub WBK_main_end()
 info_data = "WBK Main End;" & Now() & vbNewLine
End Sub

I am using a check_point sub at a certain point in the code to make a record.
Sometimes there happen some errors, especially when other macros also writing something to text files. Or when purely written code exit Sub with use of End statement, erasing all data saved to info_data.
Therefore, I am wondering if there is a smarter way to collect MS Excel usage data (other codes, add-in, use of another programming language, alternative ways of data storing (not txt)).

A: Is the problem that they have multiple workbooks open at once each with a macro running? And Each of those macros is trying to write to the text file?  If that's the case then write to a database (SQL Server of a network located Access DB)? The DB gets rid of the multiple concurrent users issue and also means all your data is already in one place (as opposed to you periodically collecting text file from their computers).
If you write to a DB they of course need to be on your domain. Maybe that is not always possible. But maybe those circumstances in which they are not on the domain it is acceptable to lose the tracking. Alternatively, you could write to a dedicated text file in those circumstances then once domain connectivity is restored, write whatever info you need from there to your DB.

A: You can use Azure Application Insights to track usage, performance, error tracking for your VBA projects (Excel & Access) in real-time, online.
It uses a little tool called VBA Telemetry.
If you don't have a Microsoft Azure account you can create and use a free one.
A few days ago I create a Udemy course on how to do all that.
It is a quick, short course (30 minutes) and in first 24h there were 2400+ people enrolled.
You can watch a preview of this course to see if this is for you.
The link to this course:
VBA Application & Usage Monitoring Online with Azure cloud-Udemy course
Hope this helps,
Davor


text:
Q: Will lots of entries in .htaccess file slow site access down? I am planning on redirecting about 100 using (301 .htaccess) and was wondering if this will slow down the performance or have any effect since the file will get heavy ?
Are there any types of entries in .htaccess that affect performance more than others ?
Example:
redirect 301 /old page.shtml  http://www.example.com/newdir/newpage.shtml

A: If you can, you may move your .htaccess directives into the VHost file.
Using the VHost will be faster because apache will not read the .htaccess everytime a page is loaded, the VHost will be executed when apache loads.

(Reference: Move .htaccess content into vhost, for performance)


text:
Q: Why won't this OpenGL ES code create a texture? I am workiong on the Android platform. I have just started with OpenGL and am trying to put an image on a rectangle. This is my code:
public class IntroActivity extends Activity {

private GLSurfaceView glsv = null;

 @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        glsv = new GLSurfaceView(this);
        glsv.setRenderer(new IntroRenderer());
        setContentView(glsv);

 }

 @Override
    protected void onResume() {
        // Ideally a game should implement onResume() and onPause()
        // to take appropriate action when the activity looses focus
        super.onResume();
       glsv.onResume();
    }

    @Override
    protected void onPause() {
        // Ideally a game should implement onResume() and onPause()
        // to take appropriate action when the activity looses focus
        super.onPause();
        glsv.onPause();
    }

Here IntroRenderer is an inner class.
 class IntroRenderer implements GLSurfaceView.Renderer{

    @Override
    public void onDrawFrame(GL10 gl) {
        gl.glClearColor(0,1.0f,1.0f,1.0f);
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

        float positions[] = {
                0.0f,1.0f,0.0f,
                0.0f, 0.0f, 0.0f,
                1.0f,1.0f,0.0f,

                0.0f,0.0f,0.0f,
                1.0f,1.0f, 0.0f,
                1.0f,0.0f,0.0f
        };

        ByteBuffer bb = ByteBuffer.allocateDirect(positions.length*4);
        bb.order(ByteOrder.nativeOrder());

        FloatBuffer fb = bb.asFloatBuffer();
        fb.put(positions);
        fb.position(0);

        gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
        gl.glVertexPointer(3,GL10.GL_FLOAT, 0, fb);
        gl.glDrawArrays(GL10.GL_TRIANGLES, 0, 3*2);

        Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.rect2985);
        Bitmap bmp256 = Bitmap.createScaledBitmap(bmp, 256,256,false);
        gl.glEnable(GL10.GL_TEXTURE_2D);
        int[] buffers = new int[1];
        gl.glGenTextures(1,buffers,0);

        int texture = buffers[0];

        gl.glBindTexture(GL10.GL_TEXTURE_2D, texture);
        GLUtils.texImage2D(GL10.GL_TEXTURE_2D,0,bmp256,0);

        //gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER,GL10.GL_NEAREST);
        //gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER,GL10.GL_NEAREST);

        bmp.recycle();

    }

    @Override
    public void onSurfaceChanged(GL10 gl, int width, int height) {
        gl.glViewport(0, 0, width, height);

    }

    @Override
    public void onSurfaceCreated(GL10 gl, EGLConfig config) {
        // TODO Auto-generated method stub

    }

 }

}
On running this activity, the background rectangle is rendered but ther eis no image. What am I doing wrong?

A: I modified your renderer a bit:
class IntroRenderer implements GLSurfaceView.Renderer {

    private boolean textureReady = false;

    public void onDrawFrame(GL10 gl) {

        if (!this.textureReady) {
            this.prepareTexture(gl); // only initialize once
        }

        gl.glClearColor(0, 0.4f, 0.4f, 1.0f);
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

        float positions[] = {
                      0.0f, 1.0f, 0.0f,
                      0.0f, 0.0f, 0.0f,
                      1.0f, 1.0f, 0.0f,
          0.0f, 0.0f, 0.0f,
                      1.0f, 1.0f, 0.0f,
                      1.0f, 0.0f, 0.0f };

        float texCoords[] = {  // define texture coordinates
                      0.0f, 1.0f,
                      0.0f, 0.0f,
                      1.0f, 1.0f,
                      0.0f, 0.0f,
                      1.0f, 1.0f,
                      1.0f, 0.0f };

        ByteBuffer bb = ByteBuffer.allocateDirect(positions.length * 4);
        bb.order(ByteOrder.nativeOrder());

        FloatBuffer fb = bb.asFloatBuffer();
        fb.put(positions);
        fb.position(0);

        // create buffer for texture coordinates
        ByteBuffer texCoordByteBuffer = ByteBuffer.allocateDirect(texCoords.length * 4);
        texCoordByteBuffer.order(ByteOrder.nativeOrder());

        FloatBuffer texCoordBuffer = texCoordByteBuffer.asFloatBuffer();
        texCoordBuffer.put(texCoords);
        texCoordBuffer.position(0);

        gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
        gl.glVertexPointer(3, GL10.GL_FLOAT, 0, fb);

        // enable texture buffer
        gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
        gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, texCoordBuffer);

        gl.glDrawArrays(GL10.GL_TRIANGLES, 0, 3 * 2);

    }

    private void prepareTexture(GL10 gl) {
        int[] buffers = new int[1];
        gl.glGenTextures(1, buffers, 0);
        int texture = buffers[0];

        // enable texturing and bind texture
        gl.glEnable(GL10.GL_TEXTURE_2D);
        gl.glBindTexture(GL10.GL_TEXTURE_2D, texture);

        Bitmap bmp = BitmapFactory.decodeResource(IntroActivity.this.getResources(), R.drawable.rect2985);
        Bitmap bmp256 = Bitmap.createScaledBitmap(bmp, 256, 256, false);

        GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bmp256, 0);

        // setup filters
        gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST);
        gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_NEAREST);

        bmp.recycle();
        this.textureReady = true;
    }

    public void onSurfaceChanged(GL10 gl, int width, int height) {
        gl.glViewport(0, 0, width, height);
    }

    public void onSurfaceCreated(GL10 gl, EGLConfig config) {
        // TODO Auto-generated method stub
    }

}

I added comments at the modified parts:

*

*You have to define texture coordinates and create a buffer (like you did for vertex positions)

*Enable texturing with gl.glEnable(GL10.GL_TEXTURE_2D);

*You need min/mag filters

As oren suggested you should do the initialization only once.
The texture coordinates define how the texture is mapped to your triangles. You can think of a coordinate system from 0.0 to 1.0 in x and y axis where the corners (0,0; 1,0; 1,1; 0,1) define the corners of your texture. You have to assign a texture coordinate to each vertex you define.
Maybe this can help you to understand how texture coordinates work: http://www.opengl.org/resources/code/samples/sig99/advanced99/notes/node52.html

A: I'm not sure why is doesn't render, but your code is inefficient.
You are loading the bitmap and binding it on EVERY frame.
You should do it only once.
Also, this link can help you with great examples with this Nehe port for Android:
Nehe Port for Android
Good luck :)


text:
Q: How can I display wireless client mac addresses with tcpdump? If using tcpdump to monitor a wireless interface and listen on a specific channel for traffic associated with a BSSID, how can I display information (e.g. mac address) about any connected clients?
The following command can capture beacon packets:
tcpdump "type mgt subtype beacon and ether src $BSSID" -I -c200 -i en1 -vv

Is it possible to alter the type and subtype and display connected clients?
tcpdump version is 4.9.3 on MacOS - airmon and airodump do not work on that platform and airport sniff only seems to write cap files.

A: An AP will only send data frames to, and accept data frames from, connected clients. So capture data frames. If you see a FromDS data frame from your AP's MAC address (BSSID) to a certain MAC address, you know that that client is connected (or at least that the AP had not yet realized the client was gone). If you see a ToDS data frame to your BSSID, and it is not quickly followed with a deauth from the AP, then you know the client that sent that data frame was connected when it sent it.
There is no sure way to know if there may be other clients connected, that just happen to be idle or you didn't manage to capture any packet to/from them.


text:
Q: Cakephp email gives error : "Connection timed out" I am sending email with CakePHP framework.
Following is the code I have added in function :
App::uses('CakeEmail', 'Network/Email');
$Email = new CakeEmail('gmail');
$Email->from(array(
    ADMIN_EMAIL => 'kioui'
));
$Email->to('pankhiwalia@gmail.com');
$Email->subject('test');
$Email->emailFormat('text');
$p = $Email->send();

and under Config/email.php file I have added following smtp settings:
public $smtp = array(
        'transport' => 'Smtp',
        'from' => array(ADMIN_EMAIL => ADMIN_NAME),
        'host' => 'ssl://localhost',
        'username' => 'kiouiapp@kioui-apps.com',
        'password' => 'Fr00Fr00',
        'client' => null,
        'log' => true,
        'timeout' => '30',
        'tls' => false,
        'port' => 465,
);

Please tell me did I miss any line?


text:
Q: Is there any way to set the default data source for the SQL Server Import and Export Wizard? When I launch the SQL Server Import and Export Wizard for SQL Server 2014, the selection in the Data source drop-down defaults to .Net Framework Data Provider for ODBC.  This happens regardless of whether I launch the wizard standalone, or from the context menu after right-clicking on a database within the SSMS Object Explorer.
Is there a way, perhaps through a registry setting, to change that default value to a data source I will use regularly, such as SQL Server Native Client or the Microsoft OLEDB Provider for SQL Server?


text:
Q: Uploading a file in Laravel Helllo, Hello
I am trying to upload a file at Laravel. However when I am at the controller, whatever method that tries to contact the object complains that it is not such an object and it cannot get its properties.
I have three fields, category, title and content, and then the file itself. I have searched here and there is some complicated code for uploading multiple files and then what resembles mine, yet without approved answers.
I also dont understand how the process is, I am just imagining it. I mean, one method can actually place the file in a folder in the server but I also need its path to be stored in the table of the database. I dont know that that actually happens, I read the documentation in Laravel docs and this is below what I have.
$category = Input::get('category');
$title = Input::get('title');
$content = Input::get('content');
$thefile = Input::file('fichero');
$filename = Input::file($thefile)->getClientOriginalName();
$destinationPath = "etc etc://../laravel/cosas";
Input::file('fichero')->move($destinationPath, $fileName);
$path = Input::file('fichero')->getRealPath();

Then this is what I should be sending to the Model, (just by intuition, never did it before)
(new document)->insertDocs($category, $title, $content, $path);

Does anyone know how this is done?
thank you very much

A: In your controller :
public function store()
{
    // Upload file
    $file = Input::file('fichero');
    $destinationPath = 'uploads/folder';
    $file->move($destinationPath);

    // Create model
    $model = new Model;
    $model->category = Input::get('category');
    $model->title = Input::get('title');
    $model->content = Input::get('content');
    $model->filename = $file->getClientOriginalName();
    $model->destinationPath = $destinationPath;

    // Save model
    $model->save();
}


text:
Q: Can we restore the files that were removed by a reset if they are staged? In general, we can restore all the objects that are stored as commits even if they are reset by using reflog. As I understand it, this is because they work with the git objects present in the .git directory. So, is it possible to restore files if they are staged? Since, blobs will be created for the files when they are staged.
DETAILED EXPLANATION: I have made several changes to my repository and I have staged them. Now, I wanted to remove the unstaged changes but instead I reset the entire repository thereby losing all the changes made. I want to recover only the staged changes.
When I staged the files blogs would have been created..will it be possible for me to find out the blobs and recover them(the changes)?

A: Well, likely, technically the changes are still there. The only problem that they're only known by their hashes (which you don't know, obviously). So without a known reference, even "weak", such a reference from reflog you don't have a method to pick them up. So, my guess, you can't resurrect them anymore, sorry.


text:
Q: All my information is erased when I reset GoogleAppEngine. How can't i avoid this? I have some problemas with Datastore.
when i restart googleappengine all my data is deleted.
i don't know Why my data is deleted when restart AppEngine ?
what can't i do?

A: If you're using the 1.6.6 SDK on Windows, we're aware of the problem, and it'll be fixed in an upcoming release.

A: It should be fixed in 1.6.6.  @Erikson Murrugarra: please update your SDK.


text:
Q: Issue running reading a JSON file then creating a new one in the same LotusScript agent I have a Lotusscript agent that calls one subroutine to read a JSON file using the following line:
Set jsnav = session.CreateJSONNavigator(json)
After that subroutine is done, I call another subroutine that creates a new JSON file using the following:
Set jsonNav = session.Createjsonnavigator("")
When this agent is run from a Notes client it works great. When it is set to run as a scheduled agent on the server, I receive this error when 2nd line (above) is called:
Err=4240, error=Problem with input variant
What is causing this and why does it work on the client and not the server?


text:
Q: How to change the background image of a Listview button according to the position? My listview contains more than 200 items. In every row of the listview, there is a Button. I want to change the Button background according to the position.Well I am able to change it too but the problem is after scrolling the listview, the images are assigned to some other button.If I am changing the button text, everything is fine but if changing the button background, this weird problem comes.
Below is what I have tried so far,
public class MyAdapter extends BaseAdapter {

    private Activity activity;
    private String[] data;
    private static LayoutInflater inflater=null;
    public ImageLoader imageLoader;

    public MyAdapter(Activity a, String[] d) {
        activity = a;
        data=d;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        imageLoader=new ImageLoader(activity.getApplicationContext());
    }

    public int getCount() {
        return data.length;
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        View vi=convertView;
        if(convertView==null)
            vi = inflater.inflate(R.layout.item, null);

        Button button=(Button)vi.findViewById(R.id.text);;

        if (position==2 || position==3) {
           button.setText("Invited");
           }
         else if (position==5 || position==8) {
         button.setBackgroundResource(R.drawable.graph);
          }
       else {
       text.setText("Invite");
       }

        return vi;
    }
}

Any help will be appreciated.

A: You have a simple problem my friend, this is caused cause Android Adapter implementation re-uses the components once it get off the screen, thats so it take a button which background already had been changed, so you have to set in your logic to make it back to the default background.
This is a common error by missing full doc reads.
Here is a similar problem: Setting color of ListView items

A: ListView recycles the views, what that mean is you have to reset the states in getView() method so do it like this:
public View getView(int position, View convertView, ViewGroup parent) {
    View vi=convertView;
    if(convertView==null)
        vi = inflater.inflate(R.layout.item, null);

    Button button=(Button)vi.findViewById(R.id.text);;
    button.setBackgroundResource(0); // reset the color again
    if (position==2 || position==3) {
       button.setText("Invited");
     } else if (position==5 || position==8) {
       button.setBackgroundResource(R.drawable.graph);
     } else {
       text.setText("Invite");
     }

    return vi;
}

A: use the odd-even number logic in getview method.............
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView==null)
    vi = inflater.inflate(R.layout.item, null);

if (position % 2 == 0) {
   button.setBackgroundResource(R.drawable.list_1);
 }else {
   button.setBackgroundResource(R.drawable.list_2);
 }

return vi;

}


text:
Q: Daily average tiered fee Struggling to work out if this can be done.
Scenario: I am charging a client a daily fee using tiered fee rates
First $10,000,000 of value is charged 0.15%
Next $20,000,000 of value is charged at 0.10%
Anything over $30,000,000 is charged at 0.075%
Doing this daily is all well and good, but is there a way I can take an average of the daily values, over say a month, and return the same value as doing individual daily calculations and summing the answers together?
If the value is always above 30 million I have no issue. But what if the value dips below $30M - the arithmetic average of the daily values will no longer return the same value as individual daily calculations.


text:
Q: Prove that if $f$ is linear, then for any $\textbf{a},\textbf{v} \in \mathbb{R}^2$, $f(\textbf{a}+\textbf{v})=f(\textbf{a})+[Df(\textbf{a})]\vec{v}$ Let $f: \mathbb{R}^2 \rightarrow \mathbb{R}^2$ be a function. Prove that if $f$ is linear, then for any $\textbf{a},\textbf{v} \in \mathbb{R}^2$, $f(\textbf{a}+\textbf{v})=f(\textbf{a})+[Df(\textbf{a})]\vec{v}$. Here $[Df(\textbf{a})]$ is the Jacobian matrix of $f$ evaluated at the point $\textbf{a}$. Thus, $[Df(\textbf{a})]\vec{v}$ is the directional derivative of $f$ at $\textbf{a}$ in the direction of $\vec{v}$
My attempt
Since $f$ is linear, $$f(\textbf{a}+\textbf{v})=f(\textbf{a})+f(\textbf{v}).$$
We need to show that $f(\textbf{v})=[Df(\textbf{a})]\vec{v}$. If $f=\begin{pmatrix} g_1 \\ g_2 \end{pmatrix}$, then $$[Df(\textbf{a})]=\begin{pmatrix} D_1 g_1 & D_2g_1 \\ D_1 g_2 & D_2 g_2\end{pmatrix}$$ Where $D_i f$ is the derivative of $f$ with respect to the $i^{th}$ variable with the rest of the variables held constant. Since $f$ is linear, we should have $D_1 g_2$ and $D_2g_1$ both zero (not sure how to prove this but it seems to make sense if we consider $g_1$ and $g_2$ to be the $x$ and $y$ co-ordinates, respectively. Thus:
\begin{align}
[Df(\textbf{a})]\vec{v}&= \begin{pmatrix} D_1 g_1 & 0 \\ 0 & D_2 g_2\end{pmatrix}\vec{v} \\
\\
&=\begin{pmatrix} D_1g_1(x_1) v_1 \\ D_2 g_2(x_2) v_2 \end{pmatrix}_{(x_1,x_2)=(a_1,a_2)}
\end{align}
Where $\vec{v}=\begin{pmatrix} v_1 \\ v_2 \end{pmatrix}$. I'm not sure how to proceed from here.

A: Actually $D_1 g_2$ and $D_2 g_1$ are not zero.
The key observation is that $Df$ is constant (i.e. independent of $x$) and hence, higher derivatives are zero.
Oh, you may also consider the differential quotient $(f(a) - f(a+tv))/t$, use linearity and send $t$ to zero…

A: Using definition of derivative we see that for linear maps $Df_a=f$, (in the $\lim$ there $A_x(h)$ becomes $f(v)$, and the $\lim$ itself not needed). Let us now choose bases in the two spaces and find the (Jacobian) matrix of the linear map $f$. $f(v)=f(v^1e_1+v^2e_2)=f(e_1)v^1+f(e_2)v^2 = \bigl( \begin{smallmatrix} f(e_1) & f(e_2) \end{smallmatrix} \bigr)\bigl( \begin{smallmatrix} v^1 \\ v^2 \end{smallmatrix} \bigr)=Av,$ where the columns of A are the vectors $f(e_i)$ in the chosen image basis and independent of any particular $a$.


text:
Q: boost interprocess race condition prevention I am having some issues with a code that is occasionally and sporadically throwing the following exception:
boost interprocess: no such file or directory

There are multiple codes accessing the same set of files, but some of the codes will move the files around to different directories in real time.
The codes handling and moving the files are using file locks, e.g.
boost::interprocess::file_lock

The process happening in code is the following:
1)  Program 1 checks to see the file it wants to lock exists
2)  If the above check passes, it then locks the file using file_lock
The problem, I think, is that between step 1 and 2, Program 2 can use boost::filesystem::rename on the file Program 1 is working on and move it.
If both programs are running simultaneously, is there any way to prevent this from happening?

A: Don't check if the file exists before locking. Instead, just attempt to lock it; if the file doesn't exist, Boost will throw an interprocess_exception alerting you that the file is locked.


text: Q: Floating navigation bar ONLY works with UTF-8 charset I have a website with a floating navigation bar which works perfectly when the charset is set at UTF-8, but if I change it to Windows-1252 or iso-8859-1, it doesn't display.Does anyone have any idea why this may be happening?


text:
Q: Ionic 3 Keyboard Transition Issue I am using Ionic 3.8.0, and I am having an issue with the keyboard transition animation.
When the keyboard slides up, there is a white/black background where the keyboard will go.
When the keyboard slides down, there is a white/black background where the keyboard was.
This issue appears to affect the Ionic DevApp as well. In this case, there is a white background.
Here is a screenshot:
Ionic DevApp Keyboard Transition Issue:

Is there a way to make the keyboard slide without the white/black background behind it?
Thanks.


text:
Q: How to predict y value for given time in Kaplan-Meier curve In a Kaplan-Meier curve, how can I predict the y value for a given time.

A: There is a pretty good example given on http://www.cancerguide.org/scurve_km.html

A: Fit a Model to your data, the you can predict from this model.
See the survival package and the examples therein.


text:
Q: Regex matching with wildcard and where each character in expression can only be used once I need some help to write a Regex for character matching. The scenario is that I have a text file with about 300 000 lines, with one word on each line. I need to find the words that match a certain set of characters.
Think of Scrabble as a very similar example, where a user has a set of characters, say for example P E S plus a wildcard character that can match any character (but only once).
If the text file contains the following words:

*

*PIE

*PIES

*PEES

*PASS

*PLEASE

...only the words in bold should be matched, as each of the user's characters, including the wildcard, can only be used maximum once in matching.
Is there a way to write a regex expression for this?
I have started with...:

\b[P,E,S]\b

...but don't know how I should express that:

*

*Each character (P, E, S) can only be used once

*Any character (the wildcard) can also be used once

Thank you in advance! Please let me know if I need to clarify the problem.
// Peter

A: This is not very easy with regex (if at all possible).
Much simpler would be something like this:
List<char> set = new List<char>("PES");

string s = "PIES";

bool matches = s.Count(ch => !set.Remove(ch)) < 2;

A: Impossible is nothing :
You can do this with regexes using lookahaeds :
(?=^.+$)(?=^[^P]*?P?[^P]*?$)(?=^[^E]*?E?[^E]*?$)(?=^[^S]*?S?[^S]*?$)

Basically if you break it down there are five components :
First lookahead :
(?=^.+$)

Checks if length is >= 1
Then the three parts :
(?=^[^P]*?P?[^P]*?$)

for E and S respectively check if a maximum of 1 of these characters exist.
The above simply tells to check the whole string for a single occurrence of P. If more than one P is found the regex fails. Same is applied to the following two lookaheads.
For the wildcard I have to think a smart way to do it :)..