问:
Wildfly10 - EJB-Remote Client - no response
I'm currently migrating our code from Jboss7 to Wildfly10.

The Server itself starts up totaly fine.
When trying to connect our client with the working new wildfly10 server for ejb-remote calls it just won't work.

The only thing I get to work with is the following error:

org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector setupEJBReceivers
  WARN: Could not register a EJB receiver for connection to remote-ip:8080
  java.lang.RuntimeException: Operation failed with status WAITING  at
  org.jboss.ejb.client.remoting.IoFutureHelper.get(IoFutureHelper.java:94)
    at
  org.jboss.ejb.client.remoting.ConnectionPool.getConnection(ConnectionPool.java:80)
    at
  org.jboss.ejb.client.remoting.RemotingConnectionManager.getConnection(RemotingConnectionManager.java:51)
    at
  org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.setupEJBReceivers(ConfigBasedEJBClientContextSelector.java:161)
    at
  org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.getCurrent(ConfigBasedEJBClientContextSelector.java:118)
    at
  org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.getCurrent(ConfigBasedEJBClientContextSelector.java:47)
    at
  org.jboss.ejb.client.EJBClientContext.getCurrent(EJBClientContext.java:281)
    at
  org.jboss.ejb.client.EJBClientContext.requireCurrent(EJBClientContext.java:291)
    at
  org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:178)
    at
  org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:146)
    at com.sun.proxy.$Proxy2.connect(Unknown Source)    at
  de.cinovo.rcp.test.RemoteEJBClient.invokeStatelessBean(RemoteEJBClient.java:39)
    at de.cinovo.rcp.test.RemoteEJBClient.main(RemoteEJBClient.java:25)

Exception in thread "main" java.lang.IllegalStateException:
  EJBCLIENT000025: No EJB receiver available for handling
  [appName:de.cinovo.tcc.server-ear,
  moduleName:de-cinovo-tcc-server-ejb-6.0-SNAPSHOT, distinctName:]
  combination for invocation context
  org.jboss.ejb.client.EJBClientInvocationContext@180542f   at
  org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:798)
    at
  org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:128)
    at
  org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:186)
    at
  org.jboss.ejb.client.EJBInvocationHandler.sendRequestWithPossibleRetries(EJBInvocationHandler.java:255)
    at
  org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:200)
    at
  org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:183)
    at
  org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:146)
    at com.sun.proxy.$Proxy2.connect(Unknown Source)    at
  de.cinovo.rcp.test.RemoteEJBClient.invokeStatelessBean(RemoteEJBClient.java:39)
    at de.cinovo.rcp.test.RemoteEJBClient.main(RemoteEJBClient.java:25)

There is no error, warning, info or anything showing up in the server log, while trying to connect.

There is some action on the port via tcp while watching during a call attempt.

The realy funny part is:

If I use the same wildfly setup on my local machine, the exact same connection method works, but only while using localhost as the ip address within the jboss-ejb-client.properties.
As soon as I change the ip into 127.0.0.1 or my current ip address, it will fail with the same error as above.

Relevant information:

Wildfly will respond to a telnet on port 8080

Wildfly is the only service listening on 8080

My /etc/hosts is correctly configured

Changing the port doesn't fix the problem

Wildfly Version 10.1.0.Final

Relevant parts from my standalone.xml

```<code><subsystem xmlns="urn:jboss:domain:remoting:3.0">
    <endpoint/>
    <http-connector name="http-remoting-connector" connector-ref="default" security-realm="ApplicationRealm"/>
</subsystem>
[...]
<subsystem xmlns="urn:jboss:domain:undertow:3.1">
    <buffer-cache name="default"/>
    <server name="default-server">
        <http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true"/>
    [...]
</subsystem>
[...]
<interfaces>
    <interface name="public">
        <any-address/>
    </interface>
</interfaces>
[...]
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
    <socket-binding name="http" interface="public" port="${jboss.http.port:8080}"/>
    <socket-binding name="https" port="${jboss.https.port:8443}"/>
[...]
</socket-binding-group>
</code>```

My jboss-ejb-client.properties

```<code>endpoint.name=client-endpoint
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=<host-ip>
remote.connection.default.port=8080
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.default.username=<usernmae>
remote.connection.default.password=<pswd>
</code>```

Client-Code

```<code>final Hashtable jndiProperties = new Hashtable();
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
final Context context = new InitialContext(jndiProperties);
[...]
return context.lookup("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName);
</code>```

EJB-Client-Maven-Dependency :

```<code><dependency>
    <groupId>org.wildfly</groupId>
    <artifactId>wildfly-ejb-client-bom</artifactId>
    <version>10.1.0.Final</version>
    <type>pom</type>
</dependency>
</code>```

Anyone out there who had the same problem and knows what I'm doing wrong?

答:
Looks like there is a missing definition in the standalone.xml in the socket.binding-group:

```<code><outbound-socket-binding name="remote-ejb">
  <local-destination socket-binding-ref="http"/>
</outbound-socket-binding>
</code>```

Body:
I'm currently migrating our code from Jboss7 to Wildfly10.

The Server itself starts up totaly fine.
When trying to connect our client with the working new wildfly10 server for ejb-remote calls it just won't work.

The only thing I get to work with is the following error:

org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector setupEJBReceivers
  WARN: Could not register a EJB receiver for connection to remote-ip:8080
  java.lang.RuntimeException: Operation failed with status WAITING  at
  org.jboss.ejb.client.remoting.IoFutureHelper.get(IoFutureHelper.java:94)
    at
  org.jboss.ejb.client.remoting.ConnectionPool.getConnection(ConnectionPool.java:80)
    at
  org.jboss.ejb.client.remoting.RemotingConnectionManager.getConnection(RemotingConnectionManager.java:51)
    at
  org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.setupEJBReceivers(ConfigBasedEJBClientContextSelector.java:161)
    at
  org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.getCurrent(ConfigBasedEJBClientContextSelector.java:118)
    at
  org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.getCurrent(ConfigBasedEJBClientContextSelector.java:47)
    at
  org.jboss.ejb.client.EJBClientContext.getCurrent(EJBClientContext.java:281)
    at
  org.jboss.ejb.client.EJBClientContext.requireCurrent(EJBClientContext.java:291)
    at
  org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:178)
    at
  org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:146)
    at com.sun.proxy.$Proxy2.connect(Unknown Source)    at
  de.cinovo.rcp.test.RemoteEJBClient.invokeStatelessBean(RemoteEJBClient.java:39)
    at de.cinovo.rcp.test.RemoteEJBClient.main(RemoteEJBClient.java:25)

Exception in thread "main" java.lang.IllegalStateException:
  EJBCLIENT000025: No EJB receiver available for handling
  [appName:de.cinovo.tcc.server-ear,
  moduleName:de-cinovo-tcc-server-ejb-6.0-SNAPSHOT, distinctName:]
  combination for invocation context
  org.jboss.ejb.client.EJBClientInvocationContext@180542f   at
  org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:798)
    at
  org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:128)
    at
  org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:186)
    at
  org.jboss.ejb.client.EJBInvocationHandler.sendRequestWithPossibleRetries(EJBInvocationHandler.java:255)
    at
  org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:200)
    at
  org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:183)
    at
  org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:146)
    at com.sun.proxy.$Proxy2.connect(Unknown Source)    at
  de.cinovo.rcp.test.RemoteEJBClient.invokeStatelessBean(RemoteEJBClient.java:39)
    at de.cinovo.rcp.test.RemoteEJBClient.main(RemoteEJBClient.java:25)

There is no error, warning, info or anything showing up in the server log, while trying to connect.

There is some action on the port via tcp while watching during a call attempt.

The realy funny part is:

If I use the same wildfly setup on my local machine, the exact same connection method works, but only while using localhost as the ip address within the jboss-ejb-client.properties.
As soon as I change the ip into 127.0.0.1 or my current ip address, it will fail with the same error as above.

Relevant information:

Wildfly will respond to a telnet on port 8080

Wildfly is the only service listening on 8080

My /etc/hosts is correctly configured

Changing the port doesn't fix the problem

Wildfly Version 10.1.0.Final

Relevant parts from my standalone.xml

<subsystem xmlns="urn:jboss:domain:remoting:3.0">
    <endpoint/>
    <http-connector name="http-remoting-connector" connector-ref="default" security-realm="ApplicationRealm"/>
</subsystem>
[...]
<subsystem xmlns="urn:jboss:domain:undertow:3.1">
    <buffer-cache name="default"/>
    <server name="default-server">
        <http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true"/>
    [...]
</subsystem>
[...]
<interfaces>
    <interface name="public">
        <any-address/>
    </interface>
</interfaces>
[...]
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
    <socket-binding name="http" interface="public" port="${jboss.http.port:8080}"/>
    <socket-binding name="https" port="${jboss.https.port:8443}"/>
[...]
</socket-binding-group>

My jboss-ejb-client.properties

endpoint.name=client-endpoint
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=<host-ip>
remote.connection.default.port=8080
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.default.username=<usernmae>
remote.connection.default.password=<pswd>

Client-Code

final Hashtable jndiProperties = new Hashtable();
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
final Context context = new InitialContext(jndiProperties);
[...]
return context.lookup("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName);

EJB-Client-Maven-Dependency :

<dependency>
    <groupId>org.wildfly</groupId>
    <artifactId>wildfly-ejb-client-bom</artifactId>
    <version>10.1.0.Final</version>
    <type>pom</type>
</dependency>

Anyone out there who had the same problem and knows what I'm doing wrong?

Body:
Looks like there is a missing definition in the standalone.xml in the socket.binding-group:

<outbound-socket-binding name="remote-ejb">
  <local-destination socket-binding-ref="http"/>
</outbound-socket-binding>


来源: stackexchange

问:
how to change the font of the EditText hint in android?
As I have mentioned in the Question I am trying to change the font of hint in EditText. But I can't seem to make it happen!

this is my code for the the EditText getting the username:

```<code><!-- Email Label -->
        <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:id="@+id/input_username_id"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="20dp">

            <EditText
                android:id="@+id/input_username"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="@color/white"
                android:textColorHint="@color/white"
                android:hint="@string/hint_username"
                android:layout_marginRight="10dp"
                android:gravity="right" />
        </android.support.design.widget.TextInputLayout>
</code>```

and here is my java code:

```<code>_usernameText = (EditText) (findViewById(R.id.input_username));
font = Typeface.createFromAsset(getAssets(), "fonts/ir.ttf");
_usernameText.setTypeface(font);
</code>```

this didn't change the font of the hint of the EditText.
I have tried other solutions and nothing changed.
http://chintanrathod.com/customizing-textinputlayout-part-2/

答:
Don't

```<code>  _usernameText = (EditText) (findViewById(R.id.input_username));
 font = Typeface.createFromAsset(getAssets(), "fonts/ir.ttf");
 _usernameText.setTypeface(font);
</code>```

Do

```<code>TextInputLayout   usernameTextObj = (TextInputLayout)    findViewById(R.id.input_username_id));
font = Typeface.createFromAsset(getAssets(), "fonts/ir.ttf");
usernameTextObj .setTypeface(font);
</code>```

ContentLicense: CC BY-SA 3.0

Body:
As I have mentioned in the Question I am trying to change the font of hint in EditText. But I can't seem to make it happen!

this is my code for the the EditText getting the username:

        <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:id="@+id/input_username_id"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="20dp">

            <EditText
                android:id="@+id/input_username"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="@color/white"
                android:textColorHint="@color/white"
                android:hint="@string/hint_username"
                android:layout_marginRight="10dp"
                android:gravity="right" />
        </android.support.design.widget.TextInputLayout>

and here is my java code:

_usernameText = (EditText) (findViewById(R.id.input_username));
font = Typeface.createFromAsset(getAssets(), "fonts/ir.ttf");
_usernameText.setTypeface(font);

this didn't change the font of the hint of the EditText.
I have tried other solutions and nothing changed.
http://chintanrathod.com/customizing-textinputlayout-part-2/

Body:
Don't

  _usernameText = (EditText) (findViewById(R.id.input_username));
 font = Typeface.createFromAsset(getAssets(), "fonts/ir.ttf");
 _usernameText.setTypeface(font);

Do

TextInputLayout   usernameTextObj = (TextInputLayout)    findViewById(R.id.input_username_id));
font = Typeface.createFromAsset(getAssets(), "fonts/ir.ttf");
usernameTextObj .setTypeface(font);


问:
How to let a section flow over the previous section slightly
I need help letting the "coiffure" section flow over the "slider" section, as seen on the example page (example).

NOTE: This is my first question on this platform, so inform me if i'm doing something wrong

.slider {
  width: 100%;
}

.coiffure {
  background-color: white;
}

.coiffure h1,
h5 {
  text-align: center;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><section class="slider">
  <div class="hidden-xs col-sm-12">
    <img class="img-responsive" src="img/2.jpg">
  </div>
</section>
<section class="coiffure">
  <div class="col-xs-6 col-xs-offset-3">
    <div class="row">
      <h1>COIFFURE</h1>
      <h5>VOOR DAMES</h5>

      <p>Laat u vakkundig verwennen door het AVENUE coiffure team. Snit -kleur-lok - en ombre technieken hebben voor ons geen geheimen meer.</p>
      <br>
      <p>Opgeleid en begeleid door het L' oreal Professionelle team staan wij garant voor de laatste nieuwe technieken. Onze hoofdhuid en haarverzorgingsprodukten van Kerastase zorgen mee voor een subliem eindresultaat!</p>
    </div>
    <div class="row">
      <img class="img-responsive" src="img/avenue-concept-coiffure-dames-heist-op-den-berg.jpg">
    </div>
    <div class="row">
      <p>Bovendien ontwikkelden we voor u het ultieme comfort in een totaal nieuwe setting:</p>
      <ul>
        <li>Meer rust, dankzij twee verschillende werkruimtes</li>
        <li>Meer flexibiliteit, dankzij verplaatsbaar meubilair</li>
        <li>Meer rust, dankzij wasunits met zicht op de tuin</li>
      </ul>
      <p>Ontdek en ervaar!</p>
    </div>
  </div>
</section></code>```

答:
you have many options to make it but I'll state some options how to make it overlap to the slider

the first one is to add negative margin-top to the "coiffure section" to make the section pull back on top just add zindex and position to make on top of the "slider section"

the second one is to give the slider a position: absolute and add padding on the body so that it push down

Body:
I need help letting the "coiffure" section flow over the "slider" section, as seen on the example page (example).

NOTE: This is my first question on this platform, so inform me if i'm doing something wrong

.slider {
  width: 100%;
}

.coiffure {
  background-color: white;
}

.coiffure h1,
h5 {
  text-align: center;
}

COIFFURE

VOOR DAMES

Laat u vakkundig verwennen door het AVENUE coiffure team. Snit -kleur-lok - en ombre technieken hebben voor ons geen geheimen meer.

Opgeleid en begeleid door het L' oreal Professionelle team staan wij garant voor de laatste nieuwe technieken. Onze hoofdhuid en haarverzorgingsprodukten van Kerastase zorgen mee voor een subliem eindresultaat!

Bovendien ontwikkelden we voor u het ultieme comfort in een totaal nieuwe setting:

Meer rust, dankzij twee verschillende werkruimtes

Meer flexibiliteit, dankzij verplaatsbaar meubilair

Meer rust, dankzij wasunits met zicht op de tuin

Ontdek en ervaar!


问:
Show/Hide events on fullcalendar using javascript
I'm making a religious calendar for a project that shows different events for all major religions. I'm using full calendar, and I have a "religion key" at the top of the calendar, and I want to make it so that when I click, for example, Jewish, it will hide all religious events/holidays on the calendar that don't pertain to the Jewish faith. I'm having some trouble. My thinking was that I would set the ".fc-event" class in css to display:none" and then have a class called .show that would be display:block. and toggle that class / remove that class when the user clicks the menu item that pertains to the holiday. Is there a better / easier way to do this? would love some guidance/tips/help :) thank you.

Here is my code for the calendar js (using made up dates obviously):

```<code>events: [
        {
            title: 'xmas',
            start: '2017-03-19',
            className: 'catholic show',
            description: 'blablablablabla'
        },
        {
            title: 'Hanukkah',
            start: '2017-03-19',
            className: 'jewish show',
            description: 'blablablabla'
        },
        {
            title: 'Hindu Holiday',
            start: '2017-03-24',
            end: '2017-03-27',
            className: 'hindu show',
            description: 'blablablabla'
        }
    ]
});

$('.calendar-nav a').each(function() {

    $(this).on('click', function(e) {
        e.preventDefault();

        var x = $(this).attr('rel');

        $('.fc-event-container').each(function() {

            $(this).removeClass('show');

            if($(this).hasClass(x)) {

                $(this).addClass('show');
            }
        });
    })
});

$('.show-all a').on('click', function() {
    $('.fc-event-container').each(function() {
        if(!$(this).hasClass('show')) {
            $(this).toggleClass('show');
        }
    });
});
});
</code>```

And the php code for the calendar and calendar-key:

```<code><nav class="calendar-nav">
<ul class="menu">
    <li class="christianity-text"><a href="#" rel="christian">><img src="/images/calendar/christianity.png" />CHRISTIAN</a>
        <ul class="sub-menu">
            <li><a href="#">Catholic</a></li>
            <li><a href="#">Protestant</a></li>
            <li><a href="#">Coptic</a></li>
            <li><a href="#">Mormon</a></li>
            <li><a href="#">Neo</a></li>
            <li><a href="#">Anglican</a></li>
            <li><a href="#">Celtic</a></li>
            <li><a href="#">Jehova's Witness</a></li>
        </ul>
    </li>
    <li class="buddhist-text"><a  href="#" rel="buddhist"><img src="/images/calendar/buddhism.png" />BUDDHIST</a></li>
    <li class="hindu-text"><a  href="#" rel="hindu"><img src="/images/calendar/hindu.png" />HINDU</a></li>
    <li class="jewish-text"><a  href="#" rel="jewish"><img src="/images/calendar/jewish.png" />JEWISH</a></li>
    <li class="islam-text"><a  href="#" rel="islam"><img src="/images/calendar/islam.png" />ISLAM</a></li>
    <li class="sikh-text"><a  href="#" rel="sikh"><img src="/images/calendar/sikh.png" />SIKH</a></li>

    <li class="pagan-text"><a  href="#" rel="pagan"><img src="/images/calendar/pagan.png" />PAGAN</a></li>
    <li class="wiccan-text"><a  href="#" rel="wiccan"><img src="/images/calendar/wiccan.png" />WICCAN</a></li>
    <li class="other-text"><a  href="#" rel="other"><img src="/images/calendar/other.png" />OTHER</a></li>
    <li class="all-text"><a href="#" rel="all">ALL</a></li>
</ul>
</nav>

<div id='calendar'></div>
</code>```

答:
I want to give you an advise ! I prefer doing with javascript logic .You have your event object so you can recreate object that your needed data </p>

```<code>$(document).ready(function(){
var events = [
    {
        title: 'xmas',
        start: '2017-03-19',
        className: 'catholic show',
        description: 'blablablablabla'
    },
    {
        title: 'Hanukkah',
        start: '2017-03-19',
        className: 'jewish show',
        description: 'blablablabla'
    },
    {
        title: 'Hindu Holiday',
        start: '2017-03-24',
        end: '2017-03-27',
        className: 'hindu show',
        description: 'blablablabla'
    }
];
//init calendar
$("#calendar").fullCalendar({
  events : events
});

$('.calendar-nav a').click(function(e) {
        e.preventDefault();
        var x = $(this).attr('rel');
        //if all, shows original events object
        if(x == "all") {
          newEvent = events;
        } else{
        var newEvent = checkEvent(x,events); //recreate object function
        }
        $('#calendar').fullCalendar('destroy');
        $("#calendar").fullCalendar({
          events : newEvent
        });
});
});

function checkEvent(x,events) {
  var newEvent = [];
  for(var i in events) {
    var key = events[i].className.split(" ")[0];
    if(key == x) { //check same religious name
      newEvent.push(events[i]);
    }
  }
  return newEvent;
}
</code>```

Body:
I'm making a religious calendar for a project that shows different events for all major religions. I'm using full calendar, and I have a "religion key" at the top of the calendar, and I want to make it so that when I click, for example, Jewish, it will hide all religious events/holidays on the calendar that don't pertain to the Jewish faith. I'm having some trouble. My thinking was that I would set the ".fc-event" class in css to display:none" and then have a class called .show that would be display:block. and toggle that class / remove that class when the user clicks the menu item that pertains to the holiday. Is there a better / easier way to do this? would love some guidance/tips/help :) thank you.

Here is my code for the calendar js (using made up dates obviously):

events: [
        {
            title: 'xmas',
            start: '2017-03-19',
            className: 'catholic show',
            description: 'blablablablabla'
        },
        {
            title: 'Hanukkah',
            start: '2017-03-19',
            className: 'jewish show',
            description: 'blablablabla'
        },
        {
            title: 'Hindu Holiday',
            start: '2017-03-24',
            end: '2017-03-27',
            className: 'hindu show',
            description: 'blablablabla'
        }
    ]
});

$('.calendar-nav a').each(function() {

    $(this).on('click', function(e) {
        e.preventDefault();

        var x = $(this).attr('rel');

        $('.fc-event-container').each(function() {

            $(this).removeClass('show');

            if($(this).hasClass(x)) {

                $(this).addClass('show');
            }
        });
    })
});

$('.show-all a').on('click', function() {
    $('.fc-event-container').each(function() {
        if(!$(this).hasClass('show')) {
            $(this).toggleClass('show');
        }
    });
});
});

And the php code for the calendar and calendar-key:

>CHRISTIAN

Catholic

Protestant

Coptic

Mormon

Neo

Anglican

Celtic

Jehova's Witness

BUDDHIST

HINDU

JEWISH

ISLAM

SIKH

PAGAN

WICCAN

OTHER

ALL

Body:
I want to give you an advise ! I prefer doing with javascript logic .You have your event object so you can recreate object that your needed data

$(document).ready(function(){
var events = [
    {
        title: 'xmas',
        start: '2017-03-19',
        className: 'catholic show',
        description: 'blablablablabla'
    },
    {
        title: 'Hanukkah',
        start: '2017-03-19',
        className: 'jewish show',
        description: 'blablablabla'
    },
    {
        title: 'Hindu Holiday',
        start: '2017-03-24',
        end: '2017-03-27',
        className: 'hindu show',
        description: 'blablablabla'
    }
];
//init calendar
$("#calendar").fullCalendar({
  events : events
});

$('.calendar-nav a').click(function(e) {
        e.preventDefault();
        var x = $(this).attr('rel');
        //if all, shows original events object
        if(x == "all") {
          newEvent = events;
        } else{
        var newEvent = checkEvent(x,events); //recreate object function
        }
        $('#calendar').fullCalendar('destroy');
        $("#calendar").fullCalendar({
          events : newEvent
        });
});
});

function checkEvent(x,events) {
  var newEvent = [];
  for(var i in events) {
    var key = events[i].className.split(" ")[0];
    if(key == x) { //check same religious name
      newEvent.push(events[i]);
    }
  }
  return newEvent;
}


问:
Why does contourf (matplotlib) switch x and y coordinates?
I am trying to get contourf to plot my stuff right, but it seems to switch the x and y coordinates. In the example below, I show this by evaluating a 2d Gaussian function that has different widths in x and y directions. With the values given, the width in y direction should be larger. Here is the script:

```<code>from numpy import *
from matplotlib.pyplot import *

xMax = 50
xNum = 100
w0x = 10
w0y = 15

dx = xMax/xNum
xGrid = linspace(-xMax/2+dx/2, xMax/2-dx/2, xNum, endpoint=True)
yGrid = xGrid

Int = zeros((xNum, xNum))

for idX in range(xNum):
    for idY in range(xNum):
        Int[idX, idY] = exp(-((xGrid[idX]/w0x)**2 + (yGrid[idY]/(w0y))**2))

fig = figure(6)
clf()

ax = subplot(2,1,1)

X, Y = meshgrid(xGrid, yGrid)

contour(X, Y, Int, colors='k')
plot(array([-xMax, xMax])/2, array([0, 0]), '-b')
plot(array([0, 0]), array([-xMax, xMax])/2, '-r')
ax.set_aspect('equal')
xlabel("x")
ylabel("y")

subplot(2,1,2)

plot(xGrid, Int[:, int(xNum/2)], '-b', label='I(x, y=max/2)')
plot(xGrid, Int[int(xNum/2), :], '-r', label='I(x=max/2, y)')
ax.set_aspect('equal')
legend()
xlabel(r"x or y")
ylabel(r"I(x or y)")
</code>```

The figure thrown out is this:

On top the contour plot which has the larger width in x direction (not y). Below are slices shown, one across x direction (at constant y=0, blue), the other in y direction (at constant x=0, red). Here, everything seems fine, the y direction is broader than the x direction. So why would I have to transpose the array in order to have it plotted as I want? This seems unintuitive to me and not in agreement with the documentation.

答:
It helps if you think of a 2D array's shape not as (x, y) but as (rows, columns), because that is how most math routines interpret them - including matplotlib's 2D plotting functions. Therefore, the first dimension is vertical (which you call y) and the second dimension is horizontal (which you call x).

Note that this convention is very prominent, even in numpy. The function np.vstack is supposed to concatenate arrays vertically works along the first dimension and np.hstack works horizontally on the second dimension.

To illustrate the point:

```<code>import numpy as np
import matplotlib.pyplot as plt

a = np.array([[0, 0, 1, 0, 0],
              [0, 1, 1, 1, 0],
              [1, 1, 1, 1, 1]])

a[:, 2] = 2  # set column

print(a)

plt.imshow(a)
plt.contour(a, colors='k')
</code>```

This prints

```<code>[[0 0 2 0 0]
 [0 1 2 1 0]
 [1 1 2 1 1]]
</code>```

and consistently plots

According to your convention that an array is (x, y) the command a[:, 2] = 2 should have assigned to the third row, but numpy and matplotlib both agree that it was the column :)

You can of course use your own convention how to interpret the dimensions of your arrays, but in the long run it will be more consistent to treat them as (y, x).

Body:
I am trying to get contourf to plot my stuff right, but it seems to switch the x and y coordinates. In the example below, I show this by evaluating a 2d Gaussian function that has different widths in x and y directions. With the values given, the width in y direction should be larger. Here is the script:

from numpy import *
from matplotlib.pyplot import *

xMax = 50
xNum = 100
w0x = 10
w0y = 15

dx = xMax/xNum
xGrid = linspace(-xMax/2+dx/2, xMax/2-dx/2, xNum, endpoint=True)
yGrid = xGrid

Int = zeros((xNum, xNum))

for idX in range(xNum):
    for idY in range(xNum):
        Int[idX, idY] = exp(-((xGrid[idX]/w0x)**2 + (yGrid[idY]/(w0y))**2))

fig = figure(6)
clf()

ax = subplot(2,1,1)

X, Y = meshgrid(xGrid, yGrid)

contour(X, Y, Int, colors='k')
plot(array([-xMax, xMax])/2, array([0, 0]), '-b')
plot(array([0, 0]), array([-xMax, xMax])/2, '-r')
ax.set_aspect('equal')
xlabel("x")
ylabel("y")

subplot(2,1,2)

plot(xGrid, Int[:, int(xNum/2)], '-b', label='I(x, y=max/2)')
plot(xGrid, Int[int(xNum/2), :], '-r', label='I(x=max/2, y)')
ax.set_aspect('equal')
legend()
xlabel(r"x or y")
ylabel(r"I(x or y)")

The figure thrown out is this:

On top the contour plot which has the larger width in x direction (not y). Below are slices shown, one across x direction (at constant y=0, blue), the other in y direction (at constant x=0, red). Here, everything seems fine, the y direction is broader than the x direction. So why would I have to transpose the array in order to have it plotted as I want? This seems unintuitive to me and not in agreement with the documentation.

Body:
It helps if you think of a 2D array's shape not as (x, y) but as (rows, columns), because that is how most math routines interpret them - including matplotlib's 2D plotting functions. Therefore, the first dimension is vertical (which you call y) and the second dimension is horizontal (which you call x).

Note that this convention is very prominent, even in numpy. The function np.vstack is supposed to concatenate arrays vertically works along the first dimension and np.hstack works horizontally on the second dimension.

To illustrate the point:

import numpy as np
import matplotlib.pyplot as plt

a = np.array([[0, 0, 1, 0, 0],
              [0, 1, 1, 1, 0],
              [1, 1, 1, 1, 1]])

a[:, 2] = 2  # set column

print(a)

plt.imshow(a)
plt.contour(a, colors='k')

This prints

[[0 0 2 0 0]
 [0 1 2 1 0]
 [1 1 2 1 1]]

and consistently plots

According to your convention that an array is (x, y) the command a[:, 2] = 2 should have assigned to the third row, but numpy and matplotlib both agree that it was the column :)

You can of course use your own convention how to interpret the dimensions of your arrays, but in the long run it will be more consistent to treat them as (y, x).


问:
How to index PDF / MS-Word / Excel files really fast for full text search?
We are building real time search feature for institutions, the index is based on the user uploaded files (mostly are Word/Excel/PDF/PowerPoint, and ASCII files). The I/O is expected at only 10 IOPS -20 IOPS but it can vary depends on the date. Maximum I/O could be 100 IOPS. Current database size is reaching 10GB, it's 4 months old.

For real time search server, I'm considering Solr / Lucene and probably ElasticSearch. But the challenge is how to index these files FAST, so that search server can query the index in real time.

I have found some similar questions on how to index .doc/.xls/.pdf, but they did not mention how to ensure indexing performance:

Search for keywords in Word documents and index them

Index Word/PDF Documents From File System To SQL Server

How to extract text from MS office documents in C#

Using full-text search with PDF files in SQL Server 2005

So my question is: how to build the index FAST ?

Any suggestion on the architecture ? Should I focus on building fast infrastructure (i.e. RAID, SSD, more CPU, Network bandwidth ?) or focus on the index tools & algorithm?

答:
We're building a high perfomance full-text search for office documents. We can share some insights:

We use ElasticSearch. It's difficult to make it perform well on large file. We write several posts about it.

Highlighting Large Documents in ElasticSearch

Making ElasticSearch Perform Well with Large Text Fields

Use microservice architecture and docker to easily scale your application

Do not store original files in elasticsearch as binary data. Store it separately for example in MongoDB

Hope it helps!


问:
How to set the expandable and collapsible tableview cells to be expandable when loading
Im working on a project in swift 3.0 and I wants to set the UITabeViewCells to be expanded when its loading for the first time.So far I have managed to create UITableViewCells to expand once a row is selected. the code as bellow.</p>

```<code>import UIKit

class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {

  var destinationData: [HeaderData?]?

    @IBOutlet weak var expandableTableView: UITableView!

    override func viewDidLoad() {
        super.viewDidLoad()

        destinationData = getData()

    }
    private func getData() -> [HeaderData?] {
      //  let data: [HeaderData?] = []

        let freeGiftsList = [ContainerData(mp3Title: "MP3Title", category: "Category",teaserDescription:"TeaserDescription")]
        let freeGifts = HeaderData(name: "Free Gifts", imageName: "header1", expcell: freeGiftsList)

        let exclusiveOffersList = [ContainerData(mp3Title: "MP3Title", category: "Category",teaserDescription:"TeaserDescription")]
        let exclusiveOffers = HeaderData(name: "Exclusive Offers", imageName: "header2", expcell: exclusiveOffersList)

        let allAudiosAndPackagesList = [ContainerData(mp3Title: "MP3Title", category: "Category",teaserDescription:"TeaserDescription")]
        let allAudiosAndPackages = HeaderData(name: "All Audios & Packages", imageName: "header3", expcell: allAudiosAndPackagesList)

        return [freeGifts, exclusiveOffers, allAudiosAndPackages]
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()

    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if let data = destinationData {
            return data.count
        } else {
            return 0
        }

    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        if let rowData = destinationData?[indexPath.row] {
            let headerCell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! HeaderTableViewCell
            headerCell.headerNameLabel.text = rowData.name
            headerCell.backgroundView = UIImageView(image: UIImage(named: rowData.imageName))
            headerCell.selectionStyle = .none
            return headerCell
        }
            // Row is ExpansionCell
        else {
            if let rowData = destinationData?[getParentCellIndex(expansionIndex: indexPath.row)] {
                //  Create an ExpansionCell
                let expansionCell = tableView.dequeueReusableCell(withIdentifier: "ExpCell", for: indexPath) as! ExpandableTableViewCell

                //  Get the index of the parent Cell (containing the data)
                let parentCellIndex = getParentCellIndex(expansionIndex: indexPath.row)

                //  Get the index of the flight data (e.g. if there are multiple ExpansionCells
                let expIndex = indexPath.row - parentCellIndex - 1

                //  Set the cell's data
                expansionCell.categoryLabel.text = rowData.expOffers?[expIndex].category
                expansionCell.mp3TitleLabel.text = rowData.expOffers?[expIndex].mp3Title
                expansionCell.teaserDescription.text = rowData.expOffers?[expIndex].teaserDescription

                expansionCell.selectionStyle = .none
                return expansionCell
            }
        }
        return UITableViewCell()

    }

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        if (destinationData?[indexPath.row]) != nil {

            // If user clicked last cell, do not try to access cell+1 (out of range)
            if(indexPath.row + 1 >= (destinationData?.count)!) {
                expandCell(tableView: tableView, index: indexPath.row)
            }
            else {
                // If next cell is not nil, then cell is not expanded
                if(destinationData?[indexPath.row+1] != nil) {
                    expandCell(tableView: tableView, index: indexPath.row)
                    // Close Cell (remove ExpansionCells)
                } else {
                    contractCell(tableView: tableView, index: indexPath.row)

                }
            }
        }
    }

    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        if (destinationData?[indexPath.row]) != nil {
            return 40
        } else {
            return 100
        }
    }

    /*  Expand cell at given index  */
    private func expandCell(tableView: UITableView, index: Int) {
        // Expand Cell (add ExpansionCells
        if let flights = destinationData?[index]?.expOffers {
            for i in 1...flights.count {
                destinationData?.insert(nil, at: index + i)
                tableView.insertRows(at: [NSIndexPath(row: index + i, section: 0) as IndexPath] , with: .top)
            }
        }
    }

    /*  Contract cell at given index    */
    private func contractCell(tableView: UITableView, index: Int) {
        if let flights = destinationData?[index]?.expOffers {
            for _ in 1...flights.count {
                destinationData?.remove(at: index+1)
                tableView.deleteRows(at: [NSIndexPath(row: index+1, section: 0) as IndexPath], with: .top)

            }
        }
    }

    /*  Get parent cell index for selected ExpansionCell  */
    private func getParentCellIndex(expansionIndex: Int) -> Int {

        var selectedCell: HeaderData?
        var selectedCellIndex = expansionIndex

        while(selectedCell == nil && selectedCellIndex >= 0) {
            selectedCellIndex -= 1
            selectedCell = destinationData?[selectedCellIndex]
        }

        return selectedCellIndex
    }

}
</code>```

答:
My application has expansion in the listing in 4 screens
What i have set is

(1) I Used table-view's section View as my normal listing view

(2) In tap on button on section view I set rows for that section and reload that section.

(3) Again taping on section button reset rows to 0.

=> This is the best and simplest way to achieve expandable view, without customizing table view and default animation like card is expand/collapse.

```<code>    func numberOfSections(in tableView: UITableView) -> Int {
        return self.arrMainList.count
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if (self.arrIndexPathSelectedRow.contains(section)) {
            let objItem = self.arrExpandedList[section] as! myObj
            let myJournals = JournalOperationModel.sharedInstance.getGroupedJournalList(objItem)
            return myJournals.count
        }
        else{
            return 0
        }
    }
</code>```

I have another array named 'arrIndexPathSelectedRow' will will use to determine either to expand or collapse the card.

And implement IU and other delegate/data source methods

Here are the methods i have used

Body:
Im working on a project in swift 3.0 and I wants to set the UITabeViewCells to be expanded when its loading for the first time.So far I have managed to create UITableViewCells to expand once a row is selected. the code as bellow.

import UIKit

class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {

  var destinationData: [HeaderData?]?

    @IBOutlet weak var expandableTableView: UITableView!

    override func viewDidLoad() {
        super.viewDidLoad()

        destinationData = getData()

    }
    private func getData() -> [HeaderData?] {
      //  let data: [HeaderData?] = []

        let freeGiftsList = [ContainerData(mp3Title: "MP3Title", category: "Category",teaserDescription:"TeaserDescription")]
        let freeGifts = HeaderData(name: "Free Gifts", imageName: "header1", expcell: freeGiftsList)

        let exclusiveOffersList = [ContainerData(mp3Title: "MP3Title", category: "Category",teaserDescription:"TeaserDescription")]
        let exclusiveOffers = HeaderData(name: "Exclusive Offers", imageName: "header2", expcell: exclusiveOffersList)

        let allAudiosAndPackagesList = [ContainerData(mp3Title: "MP3Title", category: "Category",teaserDescription:"TeaserDescription")]
        let allAudiosAndPackages = HeaderData(name: "All Audios & Packages", imageName: "header3", expcell: allAudiosAndPackagesList)

        return [freeGifts, exclusiveOffers, allAudiosAndPackages]
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()

    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if let data = destinationData {
            return data.count
        } else {
            return 0
        }

    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        if let rowData = destinationData?[indexPath.row] {
            let headerCell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! HeaderTableViewCell
            headerCell.headerNameLabel.text = rowData.name
            headerCell.backgroundView = UIImageView(image: UIImage(named: rowData.imageName))
            headerCell.selectionStyle = .none
            return headerCell
        }
            // Row is ExpansionCell
        else {
            if let rowData = destinationData?[getParentCellIndex(expansionIndex: indexPath.row)] {
                //  Create an ExpansionCell
                let expansionCell = tableView.dequeueReusableCell(withIdentifier: "ExpCell", for: indexPath) as! ExpandableTableViewCell

                //  Get the index of the parent Cell (containing the data)
                let parentCellIndex = getParentCellIndex(expansionIndex: indexPath.row)

                //  Get the index of the flight data (e.g. if there are multiple ExpansionCells
                let expIndex = indexPath.row - parentCellIndex - 1

                //  Set the cell's data
                expansionCell.categoryLabel.text = rowData.expOffers?[expIndex].category
                expansionCell.mp3TitleLabel.text = rowData.expOffers?[expIndex].mp3Title
                expansionCell.teaserDescription.text = rowData.expOffers?[expIndex].teaserDescription

                expansionCell.selectionStyle = .none
                return expansionCell
            }
        }
        return UITableViewCell()

    }

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        if (destinationData?[indexPath.row]) != nil {

            // If user clicked last cell, do not try to access cell+1 (out of range)
            if(indexPath.row + 1 >= (destinationData?.count)!) {
                expandCell(tableView: tableView, index: indexPath.row)
            }
            else {
                // If next cell is not nil, then cell is not expanded
                if(destinationData?[indexPath.row+1] != nil) {
                    expandCell(tableView: tableView, index: indexPath.row)
                    // Close Cell (remove ExpansionCells)
                } else {
                    contractCell(tableView: tableView, index: indexPath.row)

                }
            }
        }
    }

    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        if (destinationData?[indexPath.row]) != nil {
            return 40
        } else {
            return 100
        }
    }

    /*  Expand cell at given index  */
    private func expandCell(tableView: UITableView, index: Int) {
        // Expand Cell (add ExpansionCells
        if let flights = destinationData?[index]?.expOffers {
            for i in 1...flights.count {
                destinationData?.insert(nil, at: index + i)
                tableView.insertRows(at: [NSIndexPath(row: index + i, section: 0) as IndexPath] , with: .top)
            }
        }
    }

    /*  Contract cell at given index    */
    private func contractCell(tableView: UITableView, index: Int) {
        if let flights = destinationData?[index]?.expOffers {
            for _ in 1...flights.count {
                destinationData?.remove(at: index+1)
                tableView.deleteRows(at: [NSIndexPath(row: index+1, section: 0) as IndexPath], with: .top)

            }
        }
    }

    /*  Get parent cell index for selected ExpansionCell  */
    private func getParentCellIndex(expansionIndex: Int) -> Int {

        var selectedCell: HeaderData?
        var selectedCellIndex = expansionIndex

        while(selectedCell == nil && selectedCellIndex >= 0) {
            selectedCellIndex -= 1
            selectedCell = destinationData?[selectedCellIndex]
        }

        return selectedCellIndex
    }

}

Body:
My application has expansion in the listing in 4 screens
What i have set is

(1) I Used table-view's section View as my normal listing view

(2) In tap on button on section view I set rows for that section and reload that section.

(3) Again taping on section button reset rows to 0.

=> This is the best and simplest way to achieve expandable view, without customizing table view and default animation like card is expand/collapse.

    func numberOfSections(in tableView: UITableView) -> Int {
        return self.arrMainList.count
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if (self.arrIndexPathSelectedRow.contains(section)) {
            let objItem = self.arrExpandedList[section] as! myObj
            let myJournals = JournalOperationModel.sharedInstance.getGroupedJournalList(objItem)
            return myJournals.count
        }
        else{
            return 0
        }
    }

I have another array named 'arrIndexPathSelectedRow' will will use to determine either to expand or collapse the card.

And implement IU and other delegate/data source methods

Here are the methods i have used


问:
UILabel how to tighten letter spacing
I would like to know how to programatically "Tighten Letter Spacing"?

This option is available for a UILabel made in a xib file, and is really handy sometimes.

I know this question has been asked before, but I don't see an answer that mentions this beeing available in the interface builder, so I was curious...

答:
You might want to use UILabel property:

```<code>allowsDefaultTighteningForTruncation: Bool
</code>```

and set it to true. (Default is false)

According to Apple Documentation:

When this property is set to true, the label tightens intercharacter spacing of its text before allowing any truncation to occur. The label determines the maximum amount of tightening automatically based on the font, current line width, line break mode, and other relevant information.

https://developer.apple.com/reference/uikit/uilabel/1620533-allowsdefaulttighteningfortrunca

Title: UILabel how to tighten letter spacing

Body:
You might want to use UILabel property:

allowsDefaultTighteningForTruncation: Bool

and set it to true. (Default is false)

According to Apple Documentation:

When this property is set to true, the label tightens intercharacter spacing of its text before allowing any truncation to occur. The label determines the maximum amount of tightening automatically based on the font, current line width, line break mode, and other relevant information.

https://developer.apple.com/reference/uikit/uilabel/1620533-allowsdefaulttighteningfortrunca


问:
I want to push an Object or an Array of Objects to an existed Array，and keep elements in the Array unique
when it's an Object i can use this method to get what i want

```<code>var obj=  {value: 'mouseup', label: 'mouseup'};

    var array = [
        {value: 'mouseup', label: 'mouseup'},
        {value: 'mousedown', label: 'mousedown'},
        {value: 'mousemove', label: 'mousemove'},
        {value: 'mouseover', label: 'mouseover'},
        {value: 'mouseout', label: 'mouseout'}
    ]

   function pushUnique(obj) {
        for (var i = 0; i < array.length; i++) {
            if (array[i].value === obj.value) {
            return array;
            }
        }
        array.push(obj);
        return array
   }
</code>```

Are there any methods to do this? What if it's an Array of Objects below(e.g obj1),how can i push an Array of Objects(e.g obj1) to an existed Array(e.g array)，and keep elements in the Array(array) unique ?

```<code>obj1=  [
        {value: 'hover', label: 'hover'},
        {value: 'click', label: 'click'},
        {value: 'mouseup', label: 'mouseup'},
        {value: 'mousedown', label: 'mousedown'},
        {value: 'mousemove', label: 'mousemove'},
   ]

array = [
        {value: 'mouseup', label: 'mouseup'},
        {value: 'mousedown', label: 'mousedown'},
        {value: 'mousemove', label: 'mousemove'},
        {value: 'mouseover', label: 'mouseover'},
        {value: 'mouseout', label: 'mouseout'}
    ]
</code>```

答:
Check out lodash.unionBy

Here is an example:

```<code>// The `_.property` iteratee shorthand.
_.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
// => [{ 'x': 1 }, { 'x': 2 }]
</code>```

Body:
when it's an Object i can use this method to get what i want

var obj=  {value: 'mouseup', label: 'mouseup'};

    var array = [
        {value: 'mouseup', label: 'mouseup'},
        {value: 'mousedown', label: 'mousedown'},
        {value: 'mousemove', label: 'mousemove'},
        {value: 'mouseover', label: 'mouseover'},
        {value: 'mouseout', label: 'mouseout'}
    ]

   function pushUnique(obj) {
        for (var i = 0; i < array.length; i++) {
            if (array[i].value === obj.value) {
            return array;
            }
        }
        array.push(obj);
        return array
   }

Are there any methods to do this? What if it's an Array of Objects below(e.g obj1),how can i push an Array of Objects(e.g obj1) to an existed Array(e.g array)，and keep elements in the Array(array) unique ?

obj1=  [
        {value: 'hover', label: 'hover'},
        {value: 'click', label: 'click'},
        {value: 'mouseup', label: 'mouseup'},
        {value: 'mousedown', label: 'mousedown'},
        {value: 'mousemove', label: 'mousemove'},
   ]

array = [
        {value: 'mouseup', label: 'mouseup'},
        {value: 'mousedown', label: 'mousedown'},
        {value: 'mousemove', label: 'mousemove'},
        {value: 'mouseover', label: 'mouseover'},
        {value: 'mouseout', label: 'mouseout'}
    ]

Body:
Check out lodash.unionBy

Here is an example:

// The `_.property` iteratee shorthand.
_.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
// => [{ 'x': 1 }, { 'x': 2 }]


问:
How can I allow my program to continue when a regex doesn't match?
I want to use the regex crate and capture numbers from a string.

```<code>let input = "abcd123efg";
let re = Regex::new(r"([0-9]+)").unwrap();
let cap = re.captures(e).unwrap().get(1).unwrap().as_str();
println!("{}", cap);
</code>```

It worked if numbers exist in input, but if numbers don't exist in input I get the following error:

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value'
```

I want my program continue if the regex doesn't match. How can I handle this error?

答: You can either check with is_match or just use the return type of captures(e) to check it (it's an Option<Captures<'t>>) instead of unwrapping it, by using a match (see this how to handle options).

Body:
I want to use the regex crate and capture numbers from a string.

let input = "abcd123efg";
let re = Regex::new(r"([0-9]+)").unwrap();
let cap = re.captures(e).unwrap().get(1).unwrap().as_str();
println!("{}", cap);

It worked if numbers exist in input, but if numbers don't exist in input I get the following error:

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value'

I want my program continue if the regex doesn't match. How can I handle this error?

ContentLicense: CC BY-SA 4.0


问:
I got this error message : Access denied for user (Using password YES)
I have a question.

I just created an app using WPF. and trying to connect the database to retrieve the data.
for the first time, I try to use the local database at my computer. using XAMPP and mysql.

Using the XAMPP, I can retrieve the data normally. Now I want to use the database at my website. But when I run the app, it fails and shows me this error message:

Access denied for user '[my user]' (using password: YES)

FYI, I already created a username and password. I also granted all the privileges using the wizard, but still won't work.

Here is my connection string:

```<code>MySqlConnection conn = new MySqlConnection("Server=[IP Address]; Database=[database name];Uid=[user id];Pwd=[password];");
</code>```

Is there any mistake in my connection string?

答:
Like Philip Tinney says you can wildcard the hostname portion. I used this on our dev-server (not recommended for production servers):

```<code>update mysql.user set host = '%' where host='localhost';
</code>```

Then I had to restart the server to make MySQL use it (propably I could just have restarted the MySQL service).

Body:
I have a question.

I just created an app using WPF. and trying to connect the database to retrieve the data.
for the first time, I try to use the local database at my computer. using XAMPP and mysql.

Using the XAMPP, I can retrieve the data normally. Now I want to use the database at my website. But when I run the app, it fails and shows me this error message:

Access denied for user '[my user]' (using password: YES)

FYI, I already created a username and password. I also granted all the privileges using the wizard, but still won't work.

Here is my connection string:

MySqlConnection conn = new MySqlConnection("Server=[IP Address]; Database=[database name];Uid=[user id];Pwd=[password];");

Is there any mistake in my connection string?

Body:
Like Philip Tinney says you can wildcard the hostname portion. I used this on our dev-server (not recommended for production servers):

update mysql.user set host = '%' where host='localhost';

Then I had to restart the server to make MySQL use it (propably I could just have restarted the MySQL service).


问:
how to create a soap request for client saaj of given xml
I am new to SOAP. I want to create a soap request of given below xml.

xml

```<code><?xml version="1.0" encoding="utf-8"?>
        <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <soap:Body>
        <SendRequest xmlns="http://tempuri.org/">
        <request xsi:type="RegisterCheckRequest" Id="7a646d45-ee2f-4b1c-8de8-780c416fbbd0" Service="42" xmlns="http://paygo24.com/v3/protocol">
        <PaymentParameters xmlns="">
        <Parameter Name="account" Value="08374829" />
        </PaymentParameters>
        </request>
        <pointId>46</pointId>
        <password>4QrcOUm6Wau+VuBX8g+IPg==</password>
         </SendRequest>
          </soap:Body>
          </soap:Envelope>
</code>```

I was using below sample java file, to create soap request but I am not able to do so, can anyone give me support.

Sample Java File to create soap request

```<code>import javax.xml.soap.*;

public class SOAPClientSAAJ {

    public static void main(String args[]) throws Exception {
        // Create SOAP Connection
        SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
        SOAPConnection soapConnection = soapConnectionFactory.createConnection();

        // Send SOAP Message to SOAP Server
        String url = "http://ws.cdyne.com/emailverify/Emailvernotestemail.asmx";
        SOAPMessage soapResponse = soapConnection.call(createSOAPRequest(), url);

        // print SOAP Response
        System.out.print("Response SOAP Message:");
        soapResponse.writeTo(System.out);

        soapConnection.close();
    }

    private static SOAPMessage createSOAPRequest() throws Exception {
        MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage soapMessage = messageFactory.createMessage();
        SOAPPart soapPart = soapMessage.getSOAPPart();

        String serverURI = "http://ws.cdyne.com/";

        // SOAP Envelope
        SOAPEnvelope envelope = soapPart.getEnvelope();
        envelope.addNamespaceDeclaration("example", serverURI);

        /*
        Constructed SOAP Request Message:
        <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:example="http://ws.cdyne.com/">
            <SOAP-ENV:Header/>
            <SOAP-ENV:Body>
                <example:VerifyEmail>
                    <example:email>mutantninja@gmail.com</example:email>
                    <example:LicenseKey>123</example:LicenseKey>
                </example:VerifyEmail>
            </SOAP-ENV:Body>
        </SOAP-ENV:Envelope>
         */

        // SOAP Body
        SOAPBody soapBody = envelope.getBody();
        SOAPElement soapBodyElem = soapBody.addChildElement("VerifyEmail", "example");
        SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("email", "example");
        soapBodyElem1.addTextNode("mutantninja@gmail.com");
        SOAPElement soapBodyElem2 = soapBodyElem.addChildElement("LicenseKey", "example");
        soapBodyElem2.addTextNode("123");

        MimeHeaders headers = soapMessage.getMimeHeaders();
        headers.addHeader("SOAPAction", serverURI  + "VerifyEmail");

        soapMessage.saveChanges();

        /* Print the request message */
        System.out.print("Request SOAP Message:");
        soapMessage.writeTo(System.out);
        System.out.println();

        return soapMessage;
    }

}
</code>```

答: You can generate XML from objects using annotations to tie class members to XML elements/attributes. A popular way is using JAX-B. See this tutorial: http://www.vogella.com/tutorials/JAXB/article.html</p>

Body:
I am new to SOAP. I want to create a soap request of given below xml.

xml

<?xml version="1.0" encoding="utf-8"?>
        <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <soap:Body>
        <SendRequest xmlns="http://tempuri.org/">
        <request xsi:type="RegisterCheckRequest" Id="7a646d45-ee2f-4b1c-8de8-780c416fbbd0" Service="42" xmlns="http://paygo24.com/v3/protocol">
        <PaymentParameters xmlns="">
        <Parameter Name="account" Value="08374829" />
        </PaymentParameters>
        </request>
        <pointId>46</pointId>
        <password>4QrcOUm6Wau+VuBX8g+IPg==</password>
         </SendRequest>
          </soap:Body>
          </soap:Envelope>

I was using below sample java file, to create soap request but I am not able to do so, can anyone give me support.

Sample Java File to create soap request

import javax.xml.soap.*;

public class SOAPClientSAAJ {

    public static void main(String args[]) throws Exception {
        // Create SOAP Connection
        SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
        SOAPConnection soapConnection = soapConnectionFactory.createConnection();

        // Send SOAP Message to SOAP Server
        String url = "http://ws.cdyne.com/emailverify/Emailvernotestemail.asmx";
        SOAPMessage soapResponse = soapConnection.call(createSOAPRequest(), url);

        // print SOAP Response
        System.out.print("Response SOAP Message:");
        soapResponse.writeTo(System.out);

        soapConnection.close();
    }

    private static SOAPMessage createSOAPRequest() throws Exception {
        MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage soapMessage = messageFactory.createMessage();
        SOAPPart soapPart = soapMessage.getSOAPPart();

        String serverURI = "http://ws.cdyne.com/";

        // SOAP Envelope
        SOAPEnvelope envelope = soapPart.getEnvelope();
        envelope.addNamespaceDeclaration("example", serverURI);

        /*
        Constructed SOAP Request Message:
        <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:example="http://ws.cdyne.com/">
            <SOAP-ENV:Header/>
            <SOAP-ENV:Body>
                <example:VerifyEmail>
                    <example:email>mutantninja@gmail.com</example:email>
                    <example:LicenseKey>123</example:LicenseKey>
                </example:VerifyEmail>
            </SOAP-ENV:Body>
        </SOAP-ENV:Envelope>
         */

        // SOAP Body
        SOAPBody soapBody = envelope.getBody();
        SOAPElement soapBodyElem = soapBody.addChildElement("VerifyEmail", "example");
        SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("email", "example");
        soapBodyElem1.addTextNode("mutantninja@gmail.com");
        SOAPElement soapBodyElem2 = soapBodyElem.addChildElement("LicenseKey", "example");
        soapBodyElem2.addTextNode("123");

        MimeHeaders headers = soapMessage.getMimeHeaders();
        headers.addHeader("SOAPAction", serverURI  + "VerifyEmail");

        soapMessage.saveChanges();

        /* Print the request message */
        System.out.print("Request SOAP Message:");
        soapMessage.writeTo(System.out);
        System.out.println();

        return soapMessage;
    }

}


问:
Python. Selenium misses element
I need to get feedbacks from site

Feedbacks are inside  tag, so I go to iframe, and i get feedbacks, from the first page, but then i need change page using button:

Selenium can find it by class or xpath, but when it tries to click it returns error

```<code>selenium.common.exceptions.WebDriverException: Message: unknown error: Element <iframe scrolling="no" frameborder="0" marginwidth="0" marginheight="0" width="100%" height="1943" src="//feedback.aliexpress.com/display/productEvaluation.htm?productId=1000003578539&ownerMemberId=825321852&companyId=&memberType=seller&startValidDate=" cd_frame_id_="9dbc34cc8793cee8fbcab5180296b0d6"></iframe> is not clickable at point (1001, 582). Other element would receive the click: <span data-role="show" class="show-history">...</span>
  (Session info: chrome=56.0.2924.87)
  (Driver info: chromedriver=2.28.455520 (cc17746adff54984afff480136733114c6b3704b),platform=Windows NT 6.1.7601 SP1 x86_64)
</code>```

Here is my code:

```<code>driver = webdriver.Chrome()
driver.get(url)

close_popup = driver.find_element_by_class_name('close-layer')
close_popup.click()

tab_feedback = driver.find_element_by_xpath('//*[@id="j-product-tabbed-pane"]/ul/li[2]')
tab_feedback.click()

driver.switch_to.frame(driver.find_element_by_xpath('//iframe[starts-with(@src, "//feedback.aliexpress.com/display/productEvaluation.htm")]'))

text_feedbacks = driver.find_elements_by_class_name('buyer-feedback')

next = driver.find_element_by_class_name('ui-pagination-next ui-goto-page')
next.click()
</code>```

I thought that maybe selenium too fast, I tried to wait and loop but still can't get next page of feedbacks. Also i tried to get this element using xpath:

```<code>next = driver.find_element_by_xpath( "//div[@class='ui-pagination-navi util-left']/a[@class='ui-goto-page']")
</code>```

But nothing helps.

How can i get next page of feedbacks using selenium? Why other element receives click?

答:
You need to set delay for each tab_feedback.click() because the page has not been loaded fully.

```<code>import time
time.sleep(5)
</code>```

Title: Python. Selenium misses element

Body:
I need to get feedbacks from <a href="https://ru.aliexpress.com/item/New-Original-Xiaomi-Mi-Band-2-Miband-Wistband-Bracelet-with-Smart-Heart-Rate-Fitness-Touchpad-OLED/32677212146.html?spm=2114.01010208.3.1.nXc9Wn&ws_ab_test=searchweb0_0%2Csearchweb201602_0_10065_10068_10084_10083_10080_10082_10081_10110_10136_10111_10137_10060_10112_10138_10113_10062_10114_10141_10056_10055_10037_128_10054_10059_10099_10078_10079_10077_10103_10073_10102_10096_10070_10122_10123_10144_10052_10053_10124_10142_10107_10050_10143_10051%2Csearchweb201603_0%2Cafswitch_1%2CppcSwitch_5%2Csingle_sort_0_default&btsid=bb96f999-5b48-47c4-8605-d04f86ebeaf6&algo_expid=b8d752f3-57dc-43e0-8d73-4b008ae3600a-0&algo_pvid=b8d752f3-57dc-43e0-8d73-4b008ae3600a" rel="nofollow noreferrer">site

Feedbacks are inside  tag, so I go to iframe, and i get feedbacks, from the first page, but then i need change page using button:

Selenium can find it by class or xpath, but when it tries to click it returns error

selenium.common.exceptions.WebDriverException: Message: unknown error: Element  is not clickable at point (1001, 582). Other element would receive the click: ...
  (Session info: chrome=56.0.2924.87)
  (Driver info: chromedriver=2.28.455520 (cc17746adff54984afff480136733114c6b3704b),platform=Windows NT 6.1.7601 SP1 x86_64)

Here is my code:

driver = webdriver.Chrome()
driver.get(url)

close_popup = driver.find_element_by_class_name('close-layer')
close_popup.click()

tab_feedback = driver.find_element_by_xpath('//*[@id="j-product-tabbed-pane"]/ul/li[2]')
tab_feedback.click()

driver.switch_to.frame(driver.find_element_by_xpath('//iframe[starts-with(@src, "//feedback.aliexpress.com/display/productEvaluation.htm")]'))

text_feedbacks = driver.find_elements_by_class_name('buyer-feedback')

next = driver.find_element_by_class_name('ui-pagination-next ui-goto-page')
next.click()

I thought that maybe selenium too fast, I tried to wait and loop but still can't get next page of feedbacks. Also i tried to get this element using xpath:

next = driver.find_element_by_xpath( "//div[@class='ui-pagination-navi util-left']/a[@class='ui-goto-page']")

But nothing helps.

How can i get next page of feedbacks using selenium? Why other element receives click?

Body:
You need to set delay for each tab_feedback.click() because the page has not been loaded fully.

import time
time.sleep(5)


问:
What does this "CFNetwork SSLHandshake failed (-9810) error in__connection__block_invoke_2:Connection interupted" means?
When my iphone get locked, why I'm getting this error in Objective c and functionality not work.</p>

答:
Explanation for these error code:

```<code>errSSLInternal              = -9810,    /* Internal error */
</code>```

Check error codes here:

https://opensource.apple.com/source/Security/Security-55179.13/libsecurity_ssl/Security/SecureTransport.h

If your application attempts to connect to any HTTP server that doesn’t support the latest SSL technology (TLSv1.2), your connections will fail with an error like that.

If you trying to connect to a host (www.example.com) that only has TLS 1.0.

Then you have to set following keys into your info.plist:

```<code><key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>www.example.com</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSTemporaryExceptionMinimumTLSVersion</key>
            <string>TLSv1.0</string>
            <key>NSTemporaryExceptionRequiresForwardSecrecy</key>
            <false/>
        </dict>
    </dict>
</dict>
</code>```

OR update HTTP server to latest TLS version.

Hope this will help:)

Source: https://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/

Body:
Explanation for these error code:

errSSLInternal              = -9810,    /* Internal error */

Check error codes here:

https://opensource.apple.com/source/Security/Security-55179.13/libsecurity_ssl/Security/SecureTransport.h

If your application attempts to connect to any HTTP server that doesn’t support the latest SSL technology (TLSv1.2), your connections will fail with an error like that.

If you trying to connect to a host (www.example.com) that only has TLS 1.0.

Then you have to set following keys into your info.plist:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>www.example.com</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSTemporaryExceptionMinimumTLSVersion</key>
            <string>TLSv1.0</string>
            <key>NSTemporaryExceptionRequiresForwardSecrecy</key>
            <false/>
        </dict>
    </dict>
</dict>

OR update HTTP server to latest TLS version.

Hope this will help:)

Source: https://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/


问:
How can I take more control in ASP.NET?
I'm trying to build a very, very simple "micro-webapp" which I suspect will be of interest to a few Stack Overflow'rs if I ever get it done. I'm hosting it on my C# in Depth site, which is vanilla ASP.NET 3.5 (i.e. not MVC).

The flow is very simple:

If a user enters the app with a URL which doesn't specify all the parameters (or if any of them are invalid) I want to just display the user input controls. (There are only two.)

If a user enters the app with a URL which does have all the required parameters, I want to display the results and the input controls (so they can change the parameters)

Here are my self-imposed requirements (mixture of design and implementation):

I want the submission to use GET rather than POST, mostly so users can bookmark the page easily.

I don't want the URL to end up looking silly after submission, with extraneous bits and pieces on it. Just the main URL and the real parameters please.

Ideally I'd like to avoid requiring JavaScript at all. There's no good reason for it in this app.

I want to be able to access the controls during render time and set values etc. In particular, I want to be able to set the default values of the controls to the parameter values passed in, if ASP.NET can't do this automatically for me (within the other restrictions).

I'm happy to do all the parameter validation myself, and I don't need much in the way of server side events. It's really simple to set everything on page load instead of attaching events to buttons etc.

Most of this is okay, but I haven't found any way of completely removing the viewstate and keeping the rest of the useful functionality. Using the post from this blog post I've managed to avoid getting any actual value for the viewstate - but it still ends up as a parameter on the URL, which looks really ugly.

If I make it a plain HTML form instead of an ASP.NET form (i.e. take out runat="server") then I don't get any magic viewstate - but then I can't access the controls programmatically.

I could do all of this by ignoring most of ASP.NET and building up an XML document with LINQ to XML, and implementing IHttpHandler. That feels a bit low level though.

I realise that my problems could be solved by either relaxing my constraints (e.g. using POST and not caring about the surplus parameter) or by using ASP.NET MVC, but are my requirements really unreasonable?

Maybe ASP.NET just doesn't scale down to this sort of app? There's a very likely alternative though: I'm just being stupid, and there's a perfectly simple way of doing it that I just haven't found.

Any thoughts, anyone? (Cue comments of how the mighty are fallen, etc. That's fine - I hope I've never claimed to be an ASP.NET expert, as the truth is quite the opposite...)

答:
I've really been happy to totally abandon the page class altogether and just handler every request with a big switch case based on url. Evey "page" becomes a html template and a c# object. The template class uses a regex with a match delegate that compares against a key collection.

benefits:

It's really fast, even after a recompile, there is almost no lag (the page class must be big)

control is really granular (great for SEO, and crafting the DOM to play well with JS)

the presentation is separate from logic

jQuery has total control of the html

bummers:

simple stuff takes a bit longer in
that a single text box requires code
in several places, but it does scale
up really well

it's always tempting to just do it with page view until i see a
viewstate (urgh) then i snap back to
reality.

Jon, what are we doing on SO on a Saturday morning:) ?

OwnerDisplayName: Jon Skeet

ContentLicense: CC BY-SA 2.5

Title: How can I take more control in ASP.NET?

LastEditorDisplayName: Jon Skeet

OwnerDisplayName: rizzle


问:
Execute multiple SQL commands in one round trip
I am building an application and I want to batch multiple queries into a single round-trip to the database.  For example, lets say a single page needs to display a list of users, a list of groups and a list of permissions.

So I have stored procs (or just simple sql commands like "select * from Users"), and I want to execute three of them.   However, to populate this one page I have to make 3 round trips.

Now I could write a single stored proc ("getUsersTeamsAndPermissions") or execute a single SQL command "select * from Users;exec getTeams;select * from Permissions".

But I was wondering if there was a better way to specify to do 3 operations in a single round trip.  Benefits include being easier to unit test, and allowing the database engine to parrallelize the queries.

I'm using C# 3.5 and SQL Server 2008.

答:
I this this link might be helpful.

Consider using at least the same connection-openning; according to what it says here, openning a connection is almost the top-leader of performance cost in Entity-Framework.


问:
How do I import RDBMS data to a specific hive database using sqoop import
I need to import external database from mysql into hive using sqoop. My requirements are to import the complete database with all the tables into a specified hive database using sqoop import. for example, I want to import mysql database 'hadoop_practice' along with all its tables to hive database 'hadoop_practice'. However, when I perform the following command

$ sqoop import-all-tables --connect jdbc:mysql://localhost/hadoop_practice --username root -P --hive-import

the tables are imported into the hive default database. I have tried logging into hive shell and changing the database but it still copies to the default database in hive. I know sqoop provides options of copying external database table into hive database table, but that will require me to copy a 1000 tables by giving separate commands for each import. I still couldn't find any option which allows me to import all the tables in one instance. I have thought about writing a script, but is there any way I can do it without writing the script.

答: $ sqoop import-all-tables --connect jdbc:mysql://localhost/hadoop_practice --username root -P --hive-import --hive-database database_name --create-hive-table


问:
Adding consecutive x values to a list
Suppose I have a list with items [123, 124, 125, ... 9820] and from that list I want to append to a second list with a string of every 8 items separated by a space up until the end. For example the list would have:

["123 124 125 126 127 128 129 130", "131, 132, 133, 134, 135, 136, 137, 138",..] etc.

What is the best way to do this in python? I have tried a naive solution of looping from 123 to 9820 but this takes way too much runtime and times out some of my simple tests I have set up. Are there any functions that would be useful to me?

Title: Adding consecutive x values to a list

Body:
I think this does the work you want:

The code:

list = [str(x) for x in range(123, 9821)]
results = []

for index in range(0, len(list), 8):
  results.append(" ".join(list[index:index+8]))

print(results)

The output:

[
    '123 124 125 126 127 128 129 130',
    '131 132 133 134 135 136 137 138',
    '139 140 141 142 143 144 145 146',
    '147 148 149 150 151 152 153 154',
    '155 156 157 158 159 160 161 162',
    ...
    '9795 9796 9797 9798 9799 9800 9801 9802',
    '9803 9804 9805 9806 9807 9808 9809 9810',
    '9811 9812 9813 9814 9815 9816 9817 9818',
    '9819 9820'
]


问:
Data separation
I have a txt file which I want to upload to R, it looks like that:

```<code>NAMEOFTHESTUDENT1 CLASS1-NOTE1,NOTE2,NOTE3;CLASS2-NOTE1,NOTE2,NOTE3;CLASS3-NOTE1,NOTE2,NOTE3
NAMEOFTHESTUDENT2 CLASS1-NOTE1,NOTE2,NOTE3;CLASS2-NOTE1,NOTE2,NOTE3;CLASS3-NOTE1,NOTE2,NOTE3
</code>```

I want to create a data frame to obtain:

```<code>NAMEOFTHESTUDENT1 CLASS1 NOTE1
NAMEOFTHESTUDENT1 CLASS1 NOTE2
NAMEOFTHESTUDENT1 CLASS1 NOTE3

NAMEOFTHESTUDENT1 CLASS2 NOTE1
NAMEOFTHESTUDENT1 CLASS2 NOTE2
NAMEOFTHESTUDENT1 CLASS2 NOTE3

NAMEOFTHESTUDENT1 CLASS3 NOTE1
NAMEOFTHESTUDENT1 CLASS3 NOTE2
NAMEOFTHESTUDENT1 CLASS3 NOTE3

NAMEOFTHESTUDENT2 CLASS1 NOTE1
NAMEOFTHESTUDENT2 CLASS1 NOTE2
NAMEOFTHESTUDENT2 CLASS1 NOTE3

NAMEOFTHESTUDENT2 CLASS2 NOTE1
NAMEOFTHESTUDENT2 CLASS2 NOTE2
NAMEOFTHESTUDENT2 CLASS2 NOTE3

NAMEOFTHESTUDENT2 CLASS3 NOTE1
NAMEOFTHESTUDENT2 CLASS3 NOTE2
NAMEOFTHESTUDENT2 CLASS3 NOTE3
</code>```

Can someone help me to do this?
I tried with a 'For' loop but every time the variable NAMEOFTHESTUDENT is shifting.

答:
Another option is to use a nested cSplit approach:

```<code>library(splitstackshape)
cSplit(
  cSplit(
    cSplit(
      dat, 'V2', sep = ';', direction = 'long'
    ),
    'V2', sep = '-', direction = 'wide'
  ),
  'V2_2', sep = ',', direction = 'long'
)
</code>```

which gives:

```<code>                   V1   V2_1  V2_2
 1: NAMEOFTHESTUDENT1 CLASS1 NOTE1
 2: NAMEOFTHESTUDENT1 CLASS1 NOTE2
 3: NAMEOFTHESTUDENT1 CLASS1 NOTE3
 4: NAMEOFTHESTUDENT1 CLASS2 NOTE1
 5: NAMEOFTHESTUDENT1 CLASS2 NOTE2
 6: NAMEOFTHESTUDENT1 CLASS2 NOTE3
 7: NAMEOFTHESTUDENT1 CLASS3 NOTE1
 8: NAMEOFTHESTUDENT1 CLASS3 NOTE2
 9: NAMEOFTHESTUDENT1 CLASS3 NOTE3
10: NAMEOFTHESTUDENT2 CLASS1 NOTE1
11: NAMEOFTHESTUDENT2 CLASS1 NOTE2
12: NAMEOFTHESTUDENT2 CLASS1 NOTE3
13: NAMEOFTHESTUDENT2 CLASS2 NOTE1
14: NAMEOFTHESTUDENT2 CLASS2 NOTE2
15: NAMEOFTHESTUDENT2 CLASS2 NOTE3
16: NAMEOFTHESTUDENT2 CLASS3 NOTE1
17: NAMEOFTHESTUDENT2 CLASS3 NOTE2
18: NAMEOFTHESTUDENT2 CLASS3 NOTE3
</code>```

Used data:

```<code>dat <- read.table(text = "NAMEOFTHESTUDENT1 CLASS1-NOTE1,NOTE2,NOTE3;CLASS2-NOTE1,NOTE2,NOTE3;CLASS3-NOTE1,NOTE2,NOTE3
NAMEOFTHESTUDENT2 CLASS1-NOTE1,NOTE2,NOTE3;CLASS2-NOTE1,NOTE2,NOTE3;CLASS3-NOTE1,NOTE2,NOTE3", header = FALSE, as.is = TRUE)
</code>```

Title: Data separation

Body:
I have a txt file which I want to upload to R, it looks like that:

NAMEOFTHESTUDENT1 CLASS1-NOTE1,NOTE2,NOTE3;CLASS2-NOTE1,NOTE2,NOTE3;CLASS3-NOTE1,NOTE2,NOTE3
NAMEOFTHESTUDENT2 CLASS1-NOTE1,NOTE2,NOTE3;CLASS2-NOTE1,NOTE2,NOTE3;CLASS3-NOTE1,NOTE2,NOTE3

I want to create a data frame to obtain:

NAMEOFTHESTUDENT1 CLASS1 NOTE1
NAMEOFTHESTUDENT1 CLASS1 NOTE2
NAMEOFTHESTUDENT1 CLASS1 NOTE3

NAMEOFTHESTUDENT1 CLASS2 NOTE1
NAMEOFTHESTUDENT1 CLASS2 NOTE2
NAMEOFTHESTUDENT1 CLASS2 NOTE3

NAMEOFTHESTUDENT1 CLASS3 NOTE1
NAMEOFTHESTUDENT1 CLASS3 NOTE2
NAMEOFTHESTUDENT1 CLASS3 NOTE3

NAMEOFTHESTUDENT2 CLASS1 NOTE1
NAMEOFTHESTUDENT2 CLASS1 NOTE2
NAMEOFTHESTUDENT2 CLASS1 NOTE3

NAMEOFTHESTUDENT2 CLASS2 NOTE1
NAMEOFTHESTUDENT2 CLASS2 NOTE2
NAMEOFTHESTUDENT2 CLASS2 NOTE3

NAMEOFTHESTUDENT2 CLASS3 NOTE1
NAMEOFTHESTUDENT2 CLASS3 NOTE2
NAMEOFTHESTUDENT2 CLASS3 NOTE3

Can someone help me to do this?
I tried with a 'For' loop but every time the variable NAMEOFTHESTUDENT is shifting.

Body:
Another option is to use a nested cSplit approach:

library(splitstackshape)
cSplit(
  cSplit(
    cSplit(
      dat, 'V2', sep = ';', direction = 'long'
    ),
    'V2', sep = '-', direction = 'wide'
  ),
  'V2_2', sep = ',', direction = 'long'
)

which gives:

                   V1   V2_1  V2_2
 1: NAMEOFTHESTUDENT1 CLASS1 NOTE1
 2: NAMEOFTHESTUDENT1 CLASS1 NOTE2
 3: NAMEOFTHESTUDENT1 CLASS1 NOTE3
 4: NAMEOFTHESTUDENT1 CLASS2 NOTE1
 5: NAMEOFTHESTUDENT1 CLASS2 NOTE2
 6: NAMEOFTHESTUDENT1 CLASS2 NOTE3
 7: NAMEOFTHESTUDENT1 CLASS3 NOTE1
 8: NAMEOFTHESTUDENT1 CLASS3 NOTE2
 9: NAMEOFTHESTUDENT1 CLASS3 NOTE3
10: NAMEOFTHESTUDENT2 CLASS1 NOTE1
11: NAMEOFTHESTUDENT2 CLASS1 NOTE2
12: NAMEOFTHESTUDENT2 CLASS1 NOTE3
13: NAMEOFTHESTUDENT2 CLASS2 NOTE1
14: NAMEOFTHESTUDENT2 CLASS2 NOTE2
15: NAMEOFTHESTUDENT2 CLASS2 NOTE3
16: NAMEOFTHESTUDENT2 CLASS3 NOTE1
17: NAMEOFTHESTUDENT2 CLASS3 NOTE2
18: NAMEOFTHESTUDENT2 CLASS3 NOTE3

Used data:

dat <- read.table(text = "NAMEOFTHESTUDENT1 CLASS1-NOTE1,NOTE2,NOTE3;CLASS2-NOTE1,NOTE2,NOTE3;CLASS3-NOTE1,NOTE2,NOTE3
NAMEOFTHESTUDENT2 CLASS1-NOTE1,NOTE2,NOTE3;CLASS2-NOTE1,NOTE2,NOTE3;CLASS3-NOTE1,NOTE2,NOTE3", header = FALSE, as.is = TRUE)


问:
Fit element's width to wrapped text
In the below snippet, notice how the paragraph element is actually wider than its wrapped content. Is it possible to make the paragraph's width to exactly equal text width? I don't want to set p width explicitly, because it needs to be responsive.

div {
  width: 110px;
}

p {
  background-color: #ff0;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div>
  <p>
    asda sdzxf vzfsdf   asdsdsdsddf dfsdf
  </p>
  </div></code>```

edit:

So I've managed to achieve the result I've wanted. Sorry if I wasn't precise enough with my question. Here it is:

div {
  background-color: #f0f;
  width: 10%;
  display: flex;
  align-items: baseline;
}

p {
  background-color: #ff0;
  display: inline;
}

i {
  display: inline-block;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div>

  <p>
    asda sdzxf vzfsdf asdsdsdsddf dfsdf
  </p>
  <i>icon</i>
</div></code>```

答:
I'm not sure exactly what you're asking for, I might be able to help if you make a preview in a snippet.

I think this is what you're looking for but not sure so if it's not, try to better explain your requirements.

You would probably have this contained which would control the layout/flow

#container {
  width: 50%;
}

div {
  width: auto;
  display: inline-block;
}

p {
  background-color: #ff0;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="container">
  <div>
    <p>
      asda sdzxf vzfsdf asdsdsdsddf dfsdf asda sdzxf vzfsdf asdsdsdsddf dda sdzxf vzfsdf asdsdsdsddf dfsdf asda sdzxf vzfsdf asdsdsdsddf dfsdf asda sdzxf vzfsdf asdsds
    </p>
  </div>
</div></code>```

Title: Fit element's width to wrapped text

Body:
In the below snippet, notice how the paragraph element is actually wider than its wrapped content. Is it possible to make the paragraph's width to exactly equal text width? I don't want to set p width explicitly, because it needs to be responsive.

div {
  width: 110px;
}

p {
  background-color: #ff0;
}

    asda sdzxf vzfsdf   asdsdsdsddf dfsdf

edit:

So I've managed to achieve the result I've wanted. Sorry if I wasn't precise enough with my question. Here it is:

div {
  background-color: #f0f;
  width: 10%;
  display: flex;
  align-items: baseline;
}

p {
  background-color: #ff0;
  display: inline;
}

i {
  display: inline-block;
}

    asda sdzxf vzfsdf asdsdsdsddf dfsdf

  icon

Body:
I'm not sure exactly what you're asking for, I might be able to help if you make a preview in a snippet.

I think this is what you're looking for but not sure so if it's not, try to better explain your requirements.

You would probably have this contained which would control the layout/flow

#container {
  width: 50%;
}

div {
  width: auto;
  display: inline-block;
}

p {
  background-color: #ff0;
}

<div id="container">
  <div>
    <p>
      asda sdzxf vzfsdf asdsdsdsddf dfsdf asda sdzxf vzfsdf asdsdsdsddf dda sdzxf vzfsdf asdsdsdsddf dfsdf asda sdzxf vzfsdf asdsdsdsddf dfsdf asda sdzxf vzfsdf asdsds
    </p>
  </div>
</div>


问:
LocalStorage is not working as expected in iphone/ipad with os 10
I am facing issue with localstorage in iphone/Ipad with os version 10 and above.

The scenario is like this.

First time When i open the application the localstorage key value is null . At that time i'm assigning value to that corresponding key.

second time When i open the application still localStorage key is null again assigning value to that corresponding key.

Third time when i open the application i'm getting value from localStorage . If i repeat above steps no.of time , everytime i'm able to get value from localstorage.

Here the problem is second time only with localStorage.

Below are the technologies that i'm using
IBM Mobile First V7.1
Cordova V3.7
Ionic V1.2.4 and angular 1.4

Please find below sample code that is working fine in iphone & ipad with os 9(below 10)

```<code>if(localStorage && $window.localStorage.getItem("isFirst") ==  "first"){
  alert("Data available");

}else{
 alert("LocalStorage is empty");
$window.localStorage.setItem("isFirst", "first");

}
</code>```

got "Data available" alet twice instead of one.

答:
LocalStorage on iOS has been known to be not predictable. Some LocalStorage find erased when restarting the app (without Cordova or MFP even), and some do not. iOS may erase LocalStorage when the device is running low on memory. But this isn't specific to iOS 10.

This is not an issue with MFP or Cordova, it probably is just how iOS works.

To persist data reliably and with encryption you can use JSONStore. More details here:

1) JSONStore Tutorial

2) Overview

Body:
I am facing issue with localstorage in iphone/Ipad with os version 10 and above.

The scenario is like this.

First time When i open the application the localstorage key value is null . At that time i'm assigning value to that corresponding key.

second time When i open the application still localStorage key is null again assigning value to that corresponding key.

Third time when i open the application i'm getting value from localStorage . If i repeat above steps no.of time , everytime i'm able to get value from localstorage.

Here the problem is second time only with localStorage.

Below are the technologies that i'm using
IBM Mobile First V7.1
Cordova V3.7
Ionic V1.2.4 and angular 1.4

Please find below sample code that is working fine in iphone & ipad with os 9(below 10)

if(localStorage && $window.localStorage.getItem("isFirst") ==  "first"){
  alert("Data available");

}else{
 alert("LocalStorage is empty");
$window.localStorage.setItem("isFirst", "first");

}

got "Data available" alet twice instead of one.


问:
annotate text on POSIXct x axis and Legend formating multiple vlines
I have this plot:

```<code>library(ggplot2)
library(scales)
date_brake = "1 min"

t1 = as.POSIXct("2015-01-01 12:30:34",tz="GMT")
t1 <- as.POSIXct(format(t1),tz="UTC")
#attr(t1,"tzone") <- "America/New_York"
t1_numeric = as.numeric(t1)

t2 = as.POSIXct("2015-01-01 12:33:10",tz="GMT")
t2 <- as.POSIXct(format(t2),tz="UTC")
#attr(t1,"tzone") <- "America/New_York"
t2_numeric = as.numeric(t2)

t3 = as.POSIXct("2015-01-01 12:34:34",tz="GMT")
t3 <- as.POSIXct(format(t3),tz="UTC")
#attr(t1,"tzone") <- "America/New_York"
t3_numeric = as.numeric(t3)

dat = data.frame(x = as.POSIXct(c("2015-01-01 12:30:31","2015-01-01 12:35:30"),tz="GMT"), y = c(30,10)  )
ggplot(dat, aes(x=x, y = y))+geom_line()+
  scale_x_datetime(date_labels = "%H:%M:%S", breaks= date_breaks(date_brake)) +
  geom_hline(aes(yintercept = 15,linetype ="dashed"),color = "green") +
  geom_hline(aes(yintercept = 25,linetype ="dashed"),color = "blue") +
  geom_vline(aes(xintercept =  t1_numeric, linetype = "dotted"   ), color = "red"   ) +
  geom_vline(aes(xintercept =  t2_numeric, linetype = "dotted"   ), color = "red"   ) +
  geom_vline(aes(xintercept =  t3_numeric, linetype = "dotted"   ), color = "red")
</code>```

I have 2 questions:

(1) How can I get the legend to show 3 legends:  a legend for the blue line that shows a blue dashed line with title "Blue line", a legend for the green line that shows a green dashed line with title "Green line" and a 3rd legend that shows a red dotted line with title "Times"

(2) I would like to annotate or put text on the plot by the t1_numeric, t2_numeric and t3_numeric positions so I tried this:

```<code>geom_text() +
  annotate("text", label = "t1", x = t1_numeric, y = 20, size = 8, colour = "red")+
  annotate("text", label = "t2", x = t2_numeric, y = 20, size = 8, colour = "red")+
  annotate("text", label = "t3", x = t3_numeric, y = 20, size = 8, colour = "red")
</code>```

I would like to put the text "t1" at x = t1_numeric y = 20
I would like to put the text "t2" at x = t2_numeric y = 20
I would like to put the text "t3" at x = t3_numeric y = 20

But I get this error:

```<code>Error: Invalid input: time_trans works with objects of class POSIXct only
</code>```

#####################  UPDATE: the proposed solution almost works but when there is a "group" I get an error:

```<code>Error: Insufficient values in manual scale. 5 needed but only 3 provided.

dat = data.frame(x = as.POSIXct(c("2015-01-01 12:30:31","2015-01-01 12:35:30"),tz="GMT"), y = c(30,10), group = c("A","B") )

dat.hlines = data.frame(y = c(15,25, NA, NA, NA),
                        label = c("Green Line", "Blue Line", "Times", "Times", "Times"),
                        x = c(NA, NA, t1, t2, t3),
                        label_2 = c(NA, NA, "t1", "t2", "t3"),
                        label_xpos = c(t1, t1, t1, t2, t3)) # whatever the value linked to "Green" and "Blue" lines, label_2 (NA) wont be shown

ggplot(dat, aes(x, y, group = group)) +
   geom_point(aes (color = as.factor(group))) +
  scale_x_datetime(date_labels = "%H:%M:%S", breaks= date_breaks(date_brake)) +
  geom_hline(data = dat.hlines, aes(yintercept = y, color = label), linetype = "dashed") +
  geom_vline(data = dat.hlines, aes(xintercept = x, color = label), linetype = "dotted") +
  scale_color_manual("Your title", values = c("Green Line" = "green", "Blue Line" = "blue", "Times" = "red")) +
  geom_text(data = dat.hlines, aes(label_xpos, label = label_2), y = 20, color = "red", hjust = -0.5)
</code>```

答:
A possible solution, creating a 2nd dataframe (dat.hlines) :

```<code>dat = data.frame(x = as.POSIXct(c("2015-01-01 12:30:31","2015-01-01 12:35:30"),tz="GMT"), y = c(30,10)  )

dat.hlines = data.frame(y = c(15,25, NA, NA, NA),
label = c("Green Line", "Blue Line", "Times", "Times", "Times"),
x = c(NA, NA, t1, t2, t3),
label_2 = c(NA, NA, "t1", "t2", "t3"),
label_xpos = c(t1, t1, t1, t2, t3)) # whatever the value linked to "Green" and "Blue" lines, label_2 (NA) wont be shown

ggplot(dat, aes(x, y)) +
  geom_line() +
  scale_x_datetime(date_labels = "%H:%M:%S", breaks= date_breaks(date_brake)) +
  geom_hline(data = dat.hlines, aes(yintercept = y, color = label), linetype = "dashed") +
  geom_vline(data = dat.hlines, aes(xintercept = x, color = label), linetype = "dotted") +
  scale_color_manual("Your title", values = c("Green Line" = "green", "Blue Line" = "blue", "Times" = "red")) +
  geom_text(data = dat.hlines, aes(label_xpos, label = label_2), y = 20, color = "red", hjust = -0.5)
</code>```

Body:
I have this plot:

library(ggplot2)
library(scales)
date_brake = "1 min"

t1 = as.POSIXct("2015-01-01 12:30:34",tz="GMT")
t1 <- as.POSIXct(format(t1),tz="UTC")
#attr(t1,"tzone") <- "America/New_York"
t1_numeric = as.numeric(t1)

t2 = as.POSIXct("2015-01-01 12:33:10",tz="GMT")
t2 <- as.POSIXct(format(t2),tz="UTC")
#attr(t1,"tzone") <- "America/New_York"
t2_numeric = as.numeric(t2)

t3 = as.POSIXct("2015-01-01 12:34:34",tz="GMT")
t3 <- as.POSIXct(format(t3),tz="UTC")
#attr(t1,"tzone") <- "America/New_York"
t3_numeric = as.numeric(t3)

dat = data.frame(x = as.POSIXct(c("2015-01-01 12:30:31","2015-01-01 12:35:30"),tz="GMT"), y = c(30,10)  )
ggplot(dat, aes(x=x, y = y))+geom_line()+
  scale_x_datetime(date_labels = "%H:%M:%S", breaks= date_breaks(date_brake)) +
  geom_hline(aes(yintercept = 15,linetype ="dashed"),color = "green") +
  geom_hline(aes(yintercept = 25,linetype ="dashed"),color = "blue") +
  geom_vline(aes(xintercept =  t1_numeric, linetype = "dotted"   ), color = "red"   ) +
  geom_vline(aes(xintercept =  t2_numeric, linetype = "dotted"   ), color = "red"   ) +
  geom_vline(aes(xintercept =  t3_numeric, linetype = "dotted"   ), color = "red")

I have 2 questions:

(1) How can I get the legend to show 3 legends:  a legend for the blue line that shows a blue dashed line with title "Blue line", a legend for the green line that shows a green dashed line with title "Green line" and a 3rd legend that shows a red dotted line with title "Times"

(2) I would like to annotate or put text on the plot by the t1_numeric, t2_numeric and t3_numeric positions so I tried this:

geom_text() +
  annotate("text", label = "t1", x = t1_numeric, y = 20, size = 8, colour = "red")+
  annotate("text", label = "t2", x = t2_numeric, y = 20, size = 8, colour = "red")+
  annotate("text", label = "t3", x = t3_numeric, y = 20, size = 8, colour = "red")

I would like to put the text "t1" at x = t1_numeric y = 20
I would like to put the text "t2" at x = t2_numeric y = 20
I would like to put the text "t3" at x = t3_numeric y = 20

But I get this error:

Error: Invalid input: time_trans works with objects of class POSIXct only

#####################  UPDATE: the proposed solution almost works but when there is a "group" I get an error:

Error: Insufficient values in manual scale. 5 needed but only 3 provided.

dat = data.frame(x = as.POSIXct(c("2015-01-01 12:30:31","2015-01-01 12:35:30"),tz="GMT"), y = c(30,10), group = c("A","B") )

dat.hlines = data.frame(y = c(15,25, NA, NA, NA),
                        label = c("Green Line", "Blue Line", "Times", "Times", "Times"),
                        x = c(NA, NA, t1, t2, t3),
                        label_2 = c(NA, NA, "t1", "t2", "t3"),
                        label_xpos = c(t1, t1, t1, t2, t3)) # whatever the value linked to "Green" and "Blue" lines, label_2 (NA) wont be shown

ggplot(dat, aes(x, y, group = group)) +
   geom_point(aes (color = as.factor(group))) +
  scale_x_datetime(date_labels = "%H:%M:%S", breaks= date_breaks(date_brake)) +
  geom_hline(data = dat.hlines, aes(yintercept = y, color = label), linetype = "dashed") +
  geom_vline(data = dat.hlines, aes(xintercept = x, color = label), linetype = "dotted") +
  scale_color_manual("Your title", values = c("Green Line" = "green", "Blue Line" = "blue", "Times" = "red")) +
  geom_text(data = dat.hlines, aes(label_xpos, label = label_2), y = 20, color = "red", hjust = -0.5)

Body:
A possible solution, creating a 2nd dataframe (dat.hlines) :

dat = data.frame(x = as.POSIXct(c("2015-01-01 12:30:31","2015-01-01 12:35:30"),tz="GMT"), y = c(30,10)  )

dat.hlines = data.frame(y = c(15,25, NA, NA, NA),
label = c("Green Line", "Blue Line", "Times", "Times", "Times"),
x = c(NA, NA, t1, t2, t3),
label_2 = c(NA, NA, "t1", "t2", "t3"),
label_xpos = c(t1, t1, t1, t2, t3)) # whatever the value linked to "Green" and "Blue" lines, label_2 (NA) wont be shown

ggplot(dat, aes(x, y)) +
  geom_line() +
  scale_x_datetime(date_labels = "%H:%M:%S", breaks= date_breaks(date_brake)) +
  geom_hline(data = dat.hlines, aes(yintercept = y, color = label), linetype = "dashed") +
  geom_vline(data = dat.hlines, aes(xintercept = x, color = label), linetype = "dotted") +
  scale_color_manual("Your title", values = c("Green Line" = "green", "Blue Line" = "blue", "Times" = "red")) +
  geom_text(data = dat.hlines, aes(label_xpos, label = label_2), y = 20, color = "red", hjust = -0.5)


问:
I can`t connect to database on my server it displays blank page
```<code><!Doctype html>
<html>
<head>
<title>Orders Database</title>
</head>
<body>
<?php
$con = mysql_connect('localhost','wrobell1_1','123');
$db = mysql_select_db('wrobell1_orders',$con);

if($con){
echo 'succefully connected'}
?>
</body>
</html>
</code>```

<p>What can be wrong? I put it on the server in public html folder and nothing displays </p>

答:
you miss ;

it should be

```<code>echo 'succefully connected';
</code>```

Body:
<!Doctype html>

<title>Orders Database</title>

<?php
$con = mysql_connect('localhost','wrobell1_1','123');
$db = mysql_select_db('wrobell1_orders',$con);

if($con){
echo 'succefully connected'}
?>

What can be wrong? I put it on the server in public html folder and nothing displays

Body:
you miss ;

it should be

echo 'succefully connected';