问:
Inner padding and border for a flex-box 2x2 grid
I have some issue with 2x2 that I tried to achive using flexbox. I'm trying to achieve something like this.

Every single grid should contain equal amount of padding. Also it's required to add borders only inside. (Within the grid, like a cross)

This is the code that I've come up with but it doesn't work properly.

HTML

```<code><div class="info-box">
<div class="info-item grid1"></div>
<div class="info-item grid2"></div>
<div class="info-item grid3"></div>
<div class="info-item grid4"></div>
</div>
</code>```

CSS

```<code>.info-box {
margin: 2rem auto 0 auto;
text-align: center;
display: flex;
flex-wrap: wrap;
flex-flow: row wrap;
flex-direction: column;
.info-item {
  flex: 1 1 calc(50%);
  background: $light;
  &:nth-child(odd) {
    flex: 0 0 50%;
  }
}
}
</code>```

How can I have some text inside those individual 4 grids and have some padding around it. Also I'm trying to add the border only inside. Can anyone help me?

答:
You can simply achieve the cross using border on the inner elements and padding on the container. Also no need to specify flex direction as in your case it should be row (the default value). Don't forget to add box-sizing: border-box to avoid any overflow issue.

So you may try something like this :

* {
  box-sizing: border-box;
}

.info-box {
  margin: 2rem auto 0 auto;
  text-align: center;
  display: flex;
  flex-wrap: wrap;
  border:1px solid;
  padding:50px;
}

.info-item {
  flex: 1 1 50%;
  min-height: 100px;
  padding:50px;
}
.grid1 {
  border-right:1px solid;
  border-bottom:1px solid;
}
.grid2 {
  border-bottom:1px solid;
  border-left:1px solid;
}
.grid3 {
  border-top:1px solid;
  border-right:1px solid;
}
.grid4 {
  border-left:1px solid;
  border-top:1px solid;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="info-box">
  <div class="info-item grid1">1</div>
  <div class="info-item grid2">2</div>
  <div class="info-item grid3">3</div>
  <div class="info-item grid4">4</div>
</div></code>```

Or another solution to avoid the use of border is using pseudo element like this :

* {
  box-sizing: border-box;
}

.info-box {
  margin: 2rem auto 0 auto;
  text-align: center;
  display: flex;
  flex-wrap: wrap;
  border:1px solid;
  padding:50px;
  position:relative;
}
.info-box:before {
  content:"";
  position:absolute;
  background:#000;
  width:2px;
  right:50%;
  margin-right:-1px;
  top:50px;
  bottom:50px;
}
.info-box:after {
  content:"";
  position:absolute;
  background:#000;
  height:2px;
  top:50%;
  margin-top:-1px;
  left:50px;
  right:50px;
}

.info-item {
  flex: 1 1 50%;
  min-height: 100px;
  padding:50px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="info-box">
  <div class="info-item grid1">1</div>
  <div class="info-item grid2">2</div>
  <div class="info-item grid3">3</div>
  <div class="info-item grid4">4</div>
</div></code>```

Body:
I have some issue with 2x2 that I tried to achive using flexbox. I'm trying to achieve something like this.

Every single grid should contain equal amount of padding. Also it's required to add borders only inside. (Within the grid, like a cross)

This is the code that I've come up with but it doesn't work properly.

HTML

CSS

.info-box {
margin: 2rem auto 0 auto;
text-align: center;
display: flex;
flex-wrap: wrap;
flex-flow: row wrap;
flex-direction: column;
.info-item {
  flex: 1 1 calc(50%);
  background: $light;
  &:nth-child(odd) {
    flex: 0 0 50%;
  }
}
}

How can I have some text inside those individual 4 grids and have some padding around it. Also I'm trying to add the border only inside. Can anyone help me?

Body:
You can simply achieve the cross using border on the inner elements and padding on the container. Also no need to specify flex direction as in your case it should be row (the default value). Don't forget to add box-sizing: border-box to avoid any overflow issue.

So you may try something like this :

* {
  box-sizing: border-box;
}

.info-box {
  margin: 2rem auto 0 auto;
  text-align: center;
  display: flex;
  flex-wrap: wrap;
  border:1px solid;
  padding:50px;
}

.info-item {
  flex: 1 1 50%;
  min-height: 100px;
  padding:50px;
}
.grid1 {
  border-right:1px solid;
  border-bottom:1px solid;
}
.grid2 {
  border-bottom:1px solid;
  border-left:1px solid;
}
.grid3 {
  border-top:1px solid;
  border-right:1px solid;
}
.grid4 {
  border-left:1px solid;
  border-top:1px solid;
}

<div class="info-box">
  <div class="info-item grid1">1</div>
  <div class="info-item grid2">2</div>
  <div class="info-item grid3">3</div>
  <div class="info-item grid4">4</div>
</div>

Or another solution to avoid the use of border is using pseudo element like this :

* {
  box-sizing: border-box;
}

.info-box {
  margin: 2rem auto 0 auto;
  text-align: center;
  display: flex;
  flex-wrap: wrap;
  border:1px solid;
  padding:50px;
  position:relative;
}
.info-box:before {
  content:"";
  position:absolute;
  background:#000;
  width:2px;
  right:50%;
  margin-right:-1px;
  top:50px;
  bottom:50px;
}
.info-box:after {
  content:"";
  position:absolute;
  background:#000;
  height:2px;
  top:50%;
  margin-top:-1px;
  left:50px;
  right:50px;
}

.info-item {
  flex: 1 1 50%;
  min-height: 100px;
  padding:50px;
}

<div class="info-box">
  <div class="info-item grid1">1</div>
  <div class="info-item grid2">2</div>
  <div class="info-item grid3">3</div>
  <div class="info-item grid4">4</div>
</div>


来源: stackexchange

问:
Intellij Scala classpath not found
I am trying to use json4s but I keep getting the error below when I compile. I thought the library would have the class internally. I am using json4s-ast_2.11-4.0.0-M1.jar, json4s-core_2.12.3.5.3.jar and json4s-jackson_2.9.1-3.0.0.jar.

```<code>Error:(64, 25) Symbol 'type org.json4s.JsonAST.JValue' is missing from the classpath.
This symbol is required by 'type org.json4s.JValue'.
Make sure that type JValue is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
A full rebuild may help if 'package.class' was compiled against an incompatible version of org.json4s.JsonAST.
</code>```

Imports:

```<code>import org.json4s.jackson.JsonMethods._
import org.json4s._
</code>```

build.sbt

```<code>scalaVersion := "2.12.4"
libraryDependencies += "org.json4s" %% "json4s-jackson" % "3.0.0"
libraryDependencies += "org.json4s" %% "json4s-ast" % "4.0.0-M1"
libraryDependencies += "org.json4s" %% "json4s-core" % "3.5.3"
</code>```

答:
You can't use libraries compiled for different versions of scala in other versions. You need to fix the versioning of your JSON4s. Look at:

http://www.scala-sbt.org/0.13/docs/Cross-Build.html#Using+Cross-Built+Libraries

ContentLicense: CC BY-SA 3.0

Title: Intellij Scala classpath not found

Body:
I am trying to use json4s but I keep getting the error below when I compile. I thought the library would have the class internally. I am using json4s-ast_2.11-4.0.0-M1.jar, json4s-core_2.12.3.5.3.jar and json4s-jackson_2.9.1-3.0.0.jar.

Error:(64, 25) Symbol 'type org.json4s.JsonAST.JValue' is missing from the classpath.
This symbol is required by 'type org.json4s.JValue'.
Make sure that type JValue is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
A full rebuild may help if 'package.class' was compiled against an incompatible version of org.json4s.JsonAST.

Imports:

import org.json4s.jackson.JsonMethods._
import org.json4s._

build.sbt

scalaVersion := "2.12.4"
libraryDependencies += "org.json4s" %% "json4s-jackson" % "3.0.0"
libraryDependencies += "org.json4s" %% "json4s-ast" % "4.0.0-M1"
libraryDependencies += "org.json4s" %% "json4s-core" % "3.5.3"


问:
Swift Straight Edge Detection of Live Camera Feed for iOS
I have a need to detect straight lines in an image. I know the straight lines will form a cross somewhere on my image, and I need to find those.

I would like to real time detect this cross and circle it on the screen while the user points his camera at it. So basically, I need to know where it is on the screen.

My question is with regard to Core Image or any other framework that would help solve this issue. I have looked in ARKit (I don't need to move around in a virtual environment) and Core Image detection (I see I can find a rectangle, face, or barcode. Would the rectangle work? It's sort of a straight line if it is a very skinny rectangle).

I'm new to working with these frameworks for, and I was wondering what you would recommend as a tool to detect the straight lines that would form the cross. Can it be done in Core Image?

答: The vision API can detect all sorts of features, but what you are asking for is a custom symbol.  For that you are going to have to train your own ML model (as in this stackoverflow thread).  You can then run your model over your image with CoreML.</p>


问:
How to add variable length array into a Vec?
What is equivalent of list of lists in Python for Rust?

For example:

```<code>a=[]
a.append([1,2])
a.append([1,2,3])
a.append([1,2,3,4])
a.append([1,2,3])
</code>```

I couldn’t find an example. I have tried with enums, Vector default types, but I couldn't add variable length array into another Vector.

I would like to have:

```<code>let mut v: Vec<[]> = vec![];
v.push((1,2));
v.push((1));
</code>```

答:
What have you tried? The straight translation of your example works:

```<code>fn main() {
    let mut a = vec![];
    a.push(vec![1, 2]);
    a.push(vec![1, 2, 3]);
    a.push(vec![1, 2, 3, 4]);
    a.push(vec![1, 2, 3]);
    println!("{:?}", a);
}
</code>```

Playground

ContentLicense: CC BY-SA 4.0

Body:
What is equivalent of list of lists in Python for Rust?

For example:

a=[]
a.append([1,2])
a.append([1,2,3])
a.append([1,2,3,4])
a.append([1,2,3])

I couldn’t find an example. I have tried with enums, Vector default types, but I couldn't add variable length array into another Vector.

I would like to have:

let mut v: Vec<[]> = vec![];
v.push((1,2));
v.push((1));

Body:
What have you tried? The straight translation of your example works:

fn main() {
    let mut a = vec![];
    a.push(vec![1, 2]);
    a.push(vec![1, 2, 3]);
    a.push(vec![1, 2, 3, 4]);
    a.push(vec![1, 2, 3]);
    println!("{:?}", a);
}

Playground


问:
Get slider value in back end as python
I am plotting a graph using matplotlib in python using Jupyter and I  want to make a slider below the graph,I mean parallel to X-axis (in same plot) which take the slider value in python code and update the graph on the basis of slider value.

Please help me.
Thanks in advance.

答:
One way to do this is by using the Jupyter Widgets extension. This includes the interact function.

Using pip you can install this as:

```<code>pip install ipywidgets
jupyter nbextension enable --py --sys-prefix widgetsnbextension
</code>```

Then you can create a plot, a function that updates that plot, and pass both as arguments to interact.

Here's a Jupyter cell that does it:

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

# Create some data to visualize
data_samples = 100
data_length = 500
data = np.zeros((data_samples, data_length))
for i in range(data_samples):
    data[i,:] = np.random.normal(0., 1+0.1*i, data_length)

# Define a function to update the plot
def update_plot(frame):
    binz, valz = np.histogram(data[frame,:], range=(-10.,10), bins=50)
    for count, patch in zip(binz, patches):
        patch.set_height(count)
    return

% matplotlib qt5
hist, bins, patches = plt.hist(data[0,:], range=(-10.,10), bins=50)
widget = interact(update_plot, frame=(0, data_samples-1))
plt.show()
</code>```

Caveat: I tested this with Python 3.5 and the qt5 backend.

Title: Get slider value in back end as python

Body:
One way to do this is by using the Jupyter Widgets extension. This includes the interact function.

Using pip you can install this as:

pip install ipywidgets
jupyter nbextension enable --py --sys-prefix widgetsnbextension

Then you can create a plot, a function that updates that plot, and pass both as arguments to interact.

Here's a Jupyter cell that does it:

import numpy as np
import matplotlib.pyplot as plt
from ipywidgets import interact

# Create some data to visualize
data_samples = 100
data_length = 500
data = np.zeros((data_samples, data_length))
for i in range(data_samples):
    data[i,:] = np.random.normal(0., 1+0.1*i, data_length)

# Define a function to update the plot
def update_plot(frame):
    binz, valz = np.histogram(data[frame,:], range=(-10.,10), bins=50)
    for count, patch in zip(binz, patches):
        patch.set_height(count)
    return

% matplotlib qt5
hist, bins, patches = plt.hist(data[0,:], range=(-10.,10), bins=50)
widget = interact(update_plot, frame=(0, data_samples-1))
plt.show()

Caveat: I tested this with Python 3.5 and the qt5 backend.


问:
How to know android.os.TransactionTooLarge or not
I am trying to pass data more than 1Mb here, data it may be possible bitmap or string so, android.os.TransactionTooLarge exception thrown by an application but below 24 API level it was a simple warning but >=24 API level it will create application crash so, how can I know this transaction is valid or not else have any API available which represents this transaction is valid or not?. Can I prior know the transaction is valid or not?

for example,

```<code>Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is too long string data...");
startActivity(sendIntent);
</code>```

答:
Its not api dependents, its a bundle restriction that you cannot transfer data above 1MB.

I am not sure about the data type you are talking about but you have to persist it and then share it(like some sort of url)

Body:
I am trying to pass data more than 1Mb here, data it may be possible bitmap or string so, android.os.TransactionTooLarge exception thrown by an application but below 24 API level it was a simple warning but >=24 API level it will create application crash so, how can I know this transaction is valid or not else have any API available which represents this transaction is valid or not?. Can I prior know the transaction is valid or not?

for example,

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is too long string data...");
startActivity(sendIntent);


问:
How to obtain an array from type TByteArray as part of a larger array from type TByteArray?
I define a large typed dynamic array aArray. And now want to have a second array bArray marking a certain area in aArray without beeing a copy!

```<code>type
  TByteArray = array of Byte;

implementation

procedure SomeCode;
var
  aArray : TByteArray;
  bArray : TByteArray;
begin
  setlength(aArray, 30);
  aArray[4] := 12;
  // here want to have bArray to hold 20 Bytes starting from Byte 5 in aArray
  if bArray[0] = aArray[4] then begin
    writeln('All OK');
  end;

end;
</code>```

答:
This is not possible. A dynamic array contains meta data located immediately before the first element of the array. That's not compatible with you wanting a dynamic array whose first element is in the middle of another array.

You will probably need to solve your problem using a pointer to the first element of the sub array.

Body:
I define a large typed dynamic array aArray. And now want to have a second array bArray marking a certain area in aArray without beeing a copy!

type
  TByteArray = array of Byte;

implementation

procedure SomeCode;
var
  aArray : TByteArray;
  bArray : TByteArray;
begin
  setlength(aArray, 30);
  aArray[4] := 12;
  // here want to have bArray to hold 20 Bytes starting from Byte 5 in aArray
  if bArray[0] = aArray[4] then begin
    writeln('All OK');
  end;

end;


问:
TextInputLayout setCounterEnables doesn't work - Android
I have a layout with a TextInputLayouts elements and I want to enable counter of characters. The problem is it's not working and I can't see the counter when I run the app.

Here is my layout:

```<code><?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorBackground"
    android:paddingLeft="@dimen/create_step_padding"
    android:paddingRight="@dimen/create_step_padding"
    android:paddingTop="@dimen/create_step_padding">

    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <!-- Shipper Text Area-->
        <android.support.design.widget.TextInputLayout
            android:id="@+id/shipper_layout"
            android:layout_width="0dp"
            android:layout_height="110dp"
            android:background="@drawable/text_area_background"
            android:paddingEnd="@dimen/text_input_layout_side_padding"
            android:paddingStart="@dimen/text_input_layout_side_padding"
            android:paddingTop="@dimen/text_input_layout_top_padding"
            app:counterEnabled="true"
            app:hintTextAppearance="@style/HintTextStyle"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent">

            <android.support.design.widget.TextInputEditText
                android:id="@+id/shipper_field"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@null"
                android:gravity="top|start"
                android:hint="@string/shipper_field"
                android:inputType="textMultiLine"
                android:lines="5"
                android:overScrollMode="always"
                android:scrollbarStyle="insideInset"
                android:scrollbars="vertical" />
        </android.support.design.widget.TextInputLayout>

        <!-- Consignee Text Area-->
        <android.support.design.widget.TextInputLayout
            android:id="@+id/consignee_layout"
            android:layout_width="0dp"
            android:layout_height="110dp"
            android:layout_marginTop="16dp"
            android:background="@drawable/text_area_background"
            android:paddingLeft="@dimen/text_input_layout_side_padding"
            android:paddingTop="@dimen/text_input_layout_top_padding"
            app:counterEnabled="true"
            app:hintTextAppearance="@style/HintTextStyle"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/shipper_layout">

            <android.support.design.widget.TextInputEditText
                android:id="@+id/consignee_field"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@null"
                android:gravity="top|start"
                android:hint="@string/consignee_field"
                android:inputType="textMultiLine"
                android:lines="5"
                android:overScrollMode="always"
                android:scrollbarStyle="insideInset"
                android:scrollbars="vertical" />
        </android.support.design.widget.TextInputLayout>

        <!-- Airport of Departure -->

        <!-- Airport of Destination -->

        <com.silverfix.dgdeditor.utils.views.AirportAutoCompleteEditText
            android:id="@+id/aodep_field"
            android:layout_width="217dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="8dp"
            android:layout_marginStart="8dp"
            android:ems="10"
            android:inputType="textPersonName"
            android:text="Name"
            app:layout_constraintBottom_toBottomOf="@+id/textView11"
            app:layout_constraintHorizontal_bias="0.512"
            app:layout_constraintLeft_toRightOf="@+id/textView11"
            app:layout_constraintRight_toRightOf="parent" />

        <com.silverfix.dgdeditor.utils.views.AirportAutoCompleteEditText
            android:id="@+id/aodes_field"
            android:layout_width="217dp"
            android:layout_height="wrap_content"
            android:ems="10"
            android:inputType="textPersonName"
            android:text="Name"
            app:layout_constraintBottom_toBottomOf="@+id/textView12"
            app:layout_constraintLeft_toLeftOf="@+id/aodep_field" />

        <TextView
            android:id="@+id/textView11"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="32dp"
            android:text="@string/aodep_field"
            android:textAppearance="@style/DefaultTextStyle"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/consignee_layout" />

        <TextView
            android:id="@+id/textView12"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="24dp"
            android:text="@string/aodes_field"
            android:textAppearance="@style/DefaultTextStyle"
            app:layout_constraintLeft_toLeftOf="@+id/textView11"
            app:layout_constraintTop_toBottomOf="@+id/textView11" />
    </android.support.constraint.ConstraintLayout>
</ScrollView>
</code>```

As you can see, I enabled app:counterEnabled in the TextInputLayouts.
Then I try to set the max chars inside my code.

Here is the code:

```<code>shipperTextArea = (TextInputLayout) rootView.findViewById(R.id.shipper_layout);
consigneeTextArea = (TextInputLayout) rootView.findViewById(R.id.consignee_layout);

shipperTextArea.setCounterMaxLength(60);
consigneeTextArea.setCounterMaxLength(60);
</code>```

答:
just set the counter in xml files, add this:

```<code><android.support.design.widget.TextInputLayout
    app:counterMaxLength="60"
    app:counterEnabled="true"
</code>```

i think that don't need to set in the java class.

Body:
I have a layout with a TextInputLayouts elements and I want to enable counter of characters. The problem is it's not working and I can't see the counter when I run the app.

Here is my layout:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorBackground"
    android:paddingLeft="@dimen/create_step_padding"
    android:paddingRight="@dimen/create_step_padding"
    android:paddingTop="@dimen/create_step_padding">

    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.TextInputLayout
            android:id="@+id/shipper_layout"
            android:layout_width="0dp"
            android:layout_height="110dp"
            android:background="@drawable/text_area_background"
            android:paddingEnd="@dimen/text_input_layout_side_padding"
            android:paddingStart="@dimen/text_input_layout_side_padding"
            android:paddingTop="@dimen/text_input_layout_top_padding"
            app:counterEnabled="true"
            app:hintTextAppearance="@style/HintTextStyle"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent">

            <android.support.design.widget.TextInputEditText
                android:id="@+id/shipper_field"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@null"
                android:gravity="top|start"
                android:hint="@string/shipper_field"
                android:inputType="textMultiLine"
                android:lines="5"
                android:overScrollMode="always"
                android:scrollbarStyle="insideInset"
                android:scrollbars="vertical" />
        </android.support.design.widget.TextInputLayout>

        <android.support.design.widget.TextInputLayout
            android:id="@+id/consignee_layout"
            android:layout_width="0dp"
            android:layout_height="110dp"
            android:layout_marginTop="16dp"
            android:background="@drawable/text_area_background"
            android:paddingLeft="@dimen/text_input_layout_side_padding"
            android:paddingTop="@dimen/text_input_layout_top_padding"
            app:counterEnabled="true"
            app:hintTextAppearance="@style/HintTextStyle"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/shipper_layout">

            <android.support.design.widget.TextInputEditText
                android:id="@+id/consignee_field"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@null"
                android:gravity="top|start"
                android:hint="@string/consignee_field"
                android:inputType="textMultiLine"
                android:lines="5"
                android:overScrollMode="always"
                android:scrollbarStyle="insideInset"
                android:scrollbars="vertical" />
        </android.support.design.widget.TextInputLayout>

        <com.silverfix.dgdeditor.utils.views.AirportAutoCompleteEditText
            android:id="@+id/aodep_field"
            android:layout_width="217dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="8dp"
            android:layout_marginStart="8dp"
            android:ems="10"
            android:inputType="textPersonName"
            android:text="Name"
            app:layout_constraintBottom_toBottomOf="@+id/textView11"
            app:layout_constraintHorizontal_bias="0.512"
            app:layout_constraintLeft_toRightOf="@+id/textView11"
            app:layout_constraintRight_toRightOf="parent" />

        <com.silverfix.dgdeditor.utils.views.AirportAutoCompleteEditText
            android:id="@+id/aodes_field"
            android:layout_width="217dp"
            android:layout_height="wrap_content"
            android:ems="10"
            android:inputType="textPersonName"
            android:text="Name"
            app:layout_constraintBottom_toBottomOf="@+id/textView12"
            app:layout_constraintLeft_toLeftOf="@+id/aodep_field" />

        <TextView
            android:id="@+id/textView11"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="32dp"
            android:text="@string/aodep_field"
            android:textAppearance="@style/DefaultTextStyle"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/consignee_layout" />

        <TextView
            android:id="@+id/textView12"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="24dp"
            android:text="@string/aodes_field"
            android:textAppearance="@style/DefaultTextStyle"
            app:layout_constraintLeft_toLeftOf="@+id/textView11"
            app:layout_constraintTop_toBottomOf="@+id/textView11" />
    </android.support.constraint.ConstraintLayout>
</ScrollView>

As you can see, I enabled app:counterEnabled in the TextInputLayouts.
Then I try to set the max chars inside my code.

Here is the code:

shipperTextArea = (TextInputLayout) rootView.findViewById(R.id.shipper_layout);
consigneeTextArea = (TextInputLayout) rootView.findViewById(R.id.consignee_layout);

shipperTextArea.setCounterMaxLength(60);
consigneeTextArea.setCounterMaxLength(60);

Body:
just set the counter in xml files, add this:

<android.support.design.widget.TextInputLayout
    app:counterMaxLength="60"
    app:counterEnabled="true"

i think that don't need to set in the java class.


问:
segment:offset in a constant

I'm trying to learn assembly. I've written this short real mode function that works as I want to.

```<code>getndrives:
        push    bx
        push    es
        push    si
            mov     bx,0040h
            mov     es,bx
            mov     si,0075h
            mov     al,byte [es:si]
        pop     si
        pop     es
        pop     bx
    ret
</code>```

I would like to have the segment:offset in a constant instead and eliminate the need to push/pop es+si. Something like

```<code>biosmem EQU 0040h:0075h
mov al,[biosmem]
</code>```

above code compiles but does not return the intended result.

答: The segment part of an address always uses a segment register. You can use a constant for the offset.</p>

Title: segment:offset in a constant

Body:
I'm trying to learn assembly. I've written this short real mode function that works as I want to.

getndrives:
        push    bx
        push    es
        push    si
            mov     bx,0040h
            mov     es,bx
            mov     si,0075h
            mov     al,byte [es:si]
        pop     si
        pop     es
        pop     bx
    ret

I would like to have the segment:offset in a constant instead and eliminate the need to push/pop es+si. Something like

biosmem EQU 0040h:0075h
mov al,[biosmem]

above code compiles but does not return the intended result.


问:
Unity: Scale a GameObject in world space
I am trying to achieve this:

This is a non-axis-aligned cube being scaled in world space in blender alongside the Z axis (Y in Unity). I want to achieve the same in Unity. I tried to find formulas for this but had no luck, I know that I can parent my object to another GameObject and scale the parent, but once I unparent my original GameObject the scale resets back and I need to scale the original GameObject. Any advise would be much appreciated.

答:
You can either unparent it, scale it and then reparent it back, or you can create game object that will hold both these objects separately so they all have their own scale.</p>

```<code>void Rescale(Transform obj, Vector3 newScale)
{
    if(obj.root != obj)
    {
        Transform parent = obj.parent;
        obj.SetParent(null);
        obj.localScale = newScale;
        obj.SetParent(parent, true);
    }
}
</code>```

Body:
You can either unparent it, scale it and then reparent it back, or you can create game object that will hold both these objects separately so they all have their own scale.

void Rescale(Transform obj, Vector3 newScale)
{
    if(obj.root != obj)
    {
        Transform parent = obj.parent;
        obj.SetParent(null);
        obj.localScale = newScale;
        obj.SetParent(parent, true);
    }
}


问:
SQL Server 2008 JOIN Question
I have four tables one is a master table that contains columns for EmployeeID, VendorID and DriverID

Then I have corresponding tables for each of these: employees, vendors and drivers
and they all have similar columns like first name, last name, etc.

So, I want to be able to pull all records from my master table and have the corresponding first name and last based on whether the master record is an employee, vendor or driver.

A row in the master table would like this for an employee

```<code>EmployeeID = 352
VendorID = 0
DriverID=0
</code>```

Vendor would look like

```<code>EmployeeID = 0
VendorID = 954
DriverID=0
</code>```

etc.

Help?

答:
I dont the reason why this design was required. But this should work even if a single row has both EmplyeeID and VendorID as not 0

SELECT 'employee' AS src, EmployeeID AS ID, FirstName, LastName
FROM mastertable
JOIN employee
ON mastertable.EmployeeID = employee.ID
where mastertable.EmployeeID != 0
UNION
SELECT 'vendor' AS src, VendorID AS ID, FirstName, LastName
FROM mastertable
JOIN vendor
ON mastertable.VendorID = vendor.ID
where mastertable.VendorID != 0
UNION
SELECT 'driver' AS src, DriverID AS ID, FirstName, LastName
FROM mastertable
JOIN driver
ON mastertable.DriverID = driver.ID
where mastertable.DriverID != 0

ContentLicense: CC BY-SA 2.5

Title: SQL Server 2008 JOIN Question

Body:
I have four tables one is a master table that contains columns for EmployeeID, VendorID and DriverID

Then I have corresponding tables for each of these: employees, vendors and drivers
and they all have similar columns like first name, last name, etc.

So, I want to be able to pull all records from my master table and have the corresponding first name and last based on whether the master record is an employee, vendor or driver.

A row in the master table would like this for an employee

EmployeeID = 352
VendorID = 0
DriverID=0

Vendor would look like

EmployeeID = 0
VendorID = 954
DriverID=0

etc.

Help?


问:
Check if an object is equal to array
I would like to check if an object has a child object array

for example

```<code>{
   "parent_category_id": "ABC",
   "parent_category_name": "ABC COMPANY",
   "place_id": 733,
   "industry": {
       "@nil": "true"
   }
   "street_id": 733
}
</code>```

How would you check if the "Industry" object would have a child array.
Like if "Industry" has a child array value of "@nil: true". Then alert Has Child

答:
```<code>Array.isArray(parentobj.industry)
</code>```

if you meant to check if it is an array or not

Title: Check if an object is equal to array

Body:
I would like to check if an object has a child object array

for example

{
   "parent_category_id": "ABC",
   "parent_category_name": "ABC COMPANY",
   "place_id": 733,
   "industry": {
       "@nil": "true"
   }
   "street_id": 733
}

How would you check if the "Industry" object would have a child array.
Like if "Industry" has a child array value of "@nil: true". Then alert Has Child

Body:
Array.isArray(parentobj.industry)

if you meant to check if it is an array or not


问:
Add more than one api in Azure Mobile App Service
Im Still new in Azure Mobile App Service, i have question about Azure Mobile App Service , Can we make 2 Api and publish it to Azure Mobile App Service. Example my App Service is http://netbackends.azurewebsites.net and i have 2 Web Api that i want to add in the App Service, for instance the web api is one for CRUD users data and the other one is for Payment. Can we do that in App service ? And make Endpoint for calling the Api, example http://netbackends.azurewebsites.net/CRUD or http://netbackends.azurewebsites.net/payment , or we only can have one Api in App service ?</p>

答:
And make Endpoint for calling the Api, example http://netbackends.azurewebsites.net/CRUD or http://netbackends.azurewebsites.net/payment

Sure, we could add the custom APIs as we want. The following is the demo how to add the custom API for a Mobile App. You also could refer to this book  to get more information.

1.Create mobile App with VS

2.Add the custom control

3.If we want to use the custom route path we could add the following code in the
Startup.MobileApp.cs file

```<code>config.MapHttpAttributeRoutes();
settings.SkipVersionCheck = true; //just for test
</code>```

Add mapped route in the control

Publish it to azure as mobile service and check the result.

Body:
And make Endpoint for calling the Api, example http://netbackends.azurewebsites.net/CRUD or http://netbackends.azurewebsites.net/payment

Sure, we could add the custom APIs as we want. The following is the demo how to add the custom API for a Mobile App. You also could refer to this book  to get more information.

1.Create mobile App with VS

2.Add the custom control

3.If we want to use the custom route path we could add the following code in the
Startup.MobileApp.cs file

config.MapHttpAttributeRoutes();
settings.SkipVersionCheck = true; //just for test

Add mapped route in the control

Publish it to azure as mobile service and check the result.


答:
If you simply want to check if an object has children and is not empty you can either do an IF statement like:

if (obj.industry) {}

or like this using the Object.getOwnPropertyNames(obj) method which will return the names of all properties within an object:

var obj = {
   "parent_category_id": "ABC",
   "parent_category_name": "ABC COMPANY",
   "place_id": 733,
   "industry": {
       "@nil": "true"
   },
   "street_id": 733
};
var names = Object.getOwnPropertyNames(obj.industry);

names.forEach(name => console.log('Property/Value ->', name, obj.industry[name]));```

Title: Check if an object is equal to array


问:
How can I get today's timestamp in PHP
I tried

```<code>$dtToday = DateTime::createFromFormat('Y-m-d', date('Y-m-d'));
</code>```

but when I output it

```<code>die($dtToday->format('d M Y g:i:s a'));
</code>```

I still get the time eg "22 Jan 2011 4:53:59 pm". Why is that?

UPDATE

Ah... many people misunderstood me, my bad, I forgot to point out the main point. I created the date with just the date portion, I don't want the time. So I'd expect something like

```<code>22 Jan 2011 12:00:00 am
</code>```

答:
You can do this by passing the current unix timestamp as the second parameter to the date function </p>

```<code>echo date("Y-m-d H:i:s",time());
</code>```

Title: How can I get today's timestamp in PHP

Body:
I tried

$dtToday = DateTime::createFromFormat('Y-m-d', date('Y-m-d'));

but when I output it

die($dtToday->format('d M Y g:i:s a'));

I still get the time eg "22 Jan 2011 4:53:59 pm". Why is that?

UPDATE

Ah... many people misunderstood me, my bad, I forgot to point out the main point. I created the date with just the date portion, I don't want the time. So I'd expect something like

22 Jan 2011 12:00:00 am

Body:
You can do this by passing the current unix timestamp as the second parameter to the date function

echo date("Y-m-d H:i:s",time());


问:
How to request more than one resource in SimPy
I would like to have processes requesting more than one resource from the shared resources pool.

For instance, with this code I can only request one resource:

```<code>def job(pool, total_requested):
    with pool.request() as request:
        yield request

if __name__ == "__main__":
    env = simpy.Environment()
    pool = simpy.Resource(env, RESOURCES)
    env.process(job(pool, 5))
    env.run()
</code>```

What if I would like to allocate 5 together.

Is there any other function for my purpose?

答:
You can maybe use Environment.all_of()

http://simpy.readthedocs.io/en/latest/topical_guides/events.html#waiting-for-multiple-events-at-once

Body:
I would like to have processes requesting more than one resource from the shared resources pool.

For instance, with this code I can only request one resource:

def job(pool, total_requested):
    with pool.request() as request:
        yield request

if __name__ == "__main__":
    env = simpy.Environment()
    pool = simpy.Resource(env, RESOURCES)
    env.process(job(pool, 5))
    env.run()

What if I would like to allocate 5 together.

Is there any other function for my purpose?


问:
Remove all object in a list with double quotes in C#
I have a list that contains object with double quotes like this: " " (note the space between the quotes). I try to remove all those objects from the list but when I escape the quotes it still doesn't work.

The object is imported from a txt file as one string containing all information and then turned to an array which I export to a list to later use RemoveAll from.

Text txt file looks like this when I import it:

```<code>"" "Myadress 6" "151 33 City" ""
</code>```

The imported result is stored in a string "importedData" and then I do like this to work with it:

```<code>string[] stringSeparators = new string[] { "\"" };
importedDataArray = importedData.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries);
var importedDataList = markupDataArray.ToList();
importedDataList.RemoveAll(item => item == "\" \"");
</code>```

I'm interested to keep those objects that actually containing something, not the one with " ".

Right now the list contains 6 object of which 4 of them looks like " ".

答:
Add simply a where clause condition in your line like that :</p>

```<code>var importedDataList = markupDataArray
     .Where(p => !string.IsNullOrWhiteSpace(item))
     .ToList();
</code>```

Body:
I have a list that contains object with double quotes like this: " " (note the space between the quotes). I try to remove all those objects from the list but when I escape the quotes it still doesn't work.

The object is imported from a txt file as one string containing all information and then turned to an array which I export to a list to later use RemoveAll from.

Text txt file looks like this when I import it:

"" "Myadress 6" "151 33 City" ""

The imported result is stored in a string "importedData" and then I do like this to work with it:

string[] stringSeparators = new string[] { "\"" };
importedDataArray = importedData.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries);
var importedDataList = markupDataArray.ToList();
importedDataList.RemoveAll(item => item == "\" \"");

I'm interested to keep those objects that actually containing something, not the one with " ".

Right now the list contains 6 object of which 4 of them looks like " ".

Body:
Add simply a where clause condition in your line like that :

var importedDataList = markupDataArray
     .Where(p => !string.IsNullOrWhiteSpace(item))
     .ToList();


问:
asp.net mvc 2. Adding to a viewModel's collection(client side)
I know that you can bind to a viewModel's collection on the client side like so:

```<code>    <%for(int i = 0; i < Model.contacts.Count; i ++){%>
        First Name: <%: Html.TextBoxFor(model => model.contacts[i].firstName) %>
        Last Name: <%: Html.TextBoxFor(model => model.contacts[i].lastName) %>
    <%}%>
</code>```

... this will allow the user to change the name info associated with this collection and when the form is posted to the receiving action the viewModel will have the respective changes.

     Given that I can edit a viewModel's collection from the client, is there a way I can add to a viewModel's collection from the client as well.   For example add a new contact into the viewModel's contacts List. I want to put a simple "Add contact" button in my page that will allow the user to add a contact to this list with out going back and forth to the server.  Am i trying to do something impossible.  I hope this makes sense.
   Thanks.

答:
You may checkout the following blog post from Steve Sanderson which exposes a nice approach to achieve what you are looking for. Also instead of writing the code you've shown in your question I would recommend you using Editor Templates and then simply replace it with:</p>

```<code><%= Html.EditorFor(x => x.contacts) %>
</code>```

Body:
I know that you can bind to a viewModel's collection on the client side like so:

    <%for(int i = 0; i < Model.contacts.Count; i ++){%>
        First Name: <%: Html.TextBoxFor(model => model.contacts[i].firstName) %>
        Last Name: <%: Html.TextBoxFor(model => model.contacts[i].lastName) %>
    <%}%>

... this will allow the user to change the name info associated with this collection and when the form is posted to the receiving action the viewModel will have the respective changes.

     Given that I can edit a viewModel's collection from the client, is there a way I can add to a viewModel's collection from the client as well.   For example add a new contact into the viewModel's contacts List. I want to put a simple "Add contact" button in my page that will allow the user to add a contact to this list with out going back and forth to the server.  Am i trying to do something impossible.  I hope this makes sense.
   Thanks.

Body:
You may checkout the following blog post from Steve Sanderson which exposes a nice approach to achieve what you are looking for. Also instead of writing the code you've shown in your question I would recommend you using Editor Templates and then simply replace it with:

<%= Html.EditorFor(x => x.contacts) %>


问:
Needless Argument in Ruby optparser
I am facing issue with following code for parsing command line options

```<code>#!/usr/bin/env ruby
require 'optparse'

options = {:username=>nil}
optparse = OptionParser.new do|opts|
    # Define the options, and what they d
    opts.on( "--username", "Cassandra username" ) do |username|
        options[:username] = username
    end

    opts.on( '--password', 'Cassandra password' ) do |password|
        options[:password] = password
    end

    opts.on( '--keyspace', 'Cassandra keyspace' ) do |keyspace|
        options[:keyspace] = keyspace
    end
end
puts ARGV

optparse.parse!(ARGV)

puts options
</code>```

When I run this code from commandline as

```<code>./testopt.rb --username=uuuuu --password=xxxxxx --keyspace=test
</code>```

I get following output

```<code>--username=uuuuu
--password=xxxxxx
--keyspace=test
./testopt.rb:25:in `<main>': needless argument: --username=uuuuu (OptionParser::NeedlessArgument)
</code>```

What am missing?
I am in ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]

Thanks in advance

答:
Although @mudasobwas answer is not wrong in itself, you can have "option=value" parsing by specifying the option like in the example below (mmh, tested with ruby 2.3.1 only).

Key is to use opts.on('--username=USER',... vs. opts.on('--username',... .

```<code>#!/usr/bin/env ruby
require 'optparse'

options = {:username=>nil}
optparse = OptionParser.new do|opts|
    # Define the options, and what they do
    opts.on( "--username=USER", 'Cassandra username' ) do |username|
        options[:username] = username
    end

    opts.on( '--password=PASSWORD', 'Cassandra password' ) do |password|
        options[:password] = password
    end

    opts.on( '--keyspace=KEY', 'Cassandra keyspace' ) do |keyspace|
        options[:keyspace] = keyspace
    end
end
puts ARGV

optparse.parse!(ARGV)

puts options
</code>```

You do not loose the ability to pass the value without the equal-sign using this approach and have it converted to string:

```<code>➜  ~  /tmp/op.rb --username myuser
--username
myuser
{:username=>"myuser"}
➜  ~  /tmp/op.rb --username=myuser
--username=myuser
{:username=>"myuser"}
</code>```

Title: Needless Argument in Ruby optparser

Body:
I am facing issue with following code for parsing command line options

#!/usr/bin/env ruby
require 'optparse'

options = {:username=>nil}
optparse = OptionParser.new do|opts|
    # Define the options, and what they d
    opts.on( "--username", "Cassandra username" ) do |username|
        options[:username] = username
    end

    opts.on( '--password', 'Cassandra password' ) do |password|
        options[:password] = password
    end

    opts.on( '--keyspace', 'Cassandra keyspace' ) do |keyspace|
        options[:keyspace] = keyspace
    end
end
puts ARGV

optparse.parse!(ARGV)

puts options

When I run this code from commandline as

./testopt.rb --username=uuuuu --password=xxxxxx --keyspace=test

I get following output

--username=uuuuu
--password=xxxxxx
--keyspace=test
./testopt.rb:25:in `': needless argument: --username=uuuuu (OptionParser::NeedlessArgument)

What am missing?
I am in ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]

Thanks in advance

Body:
Although @mudasobwas answer is not wrong in itself, you can have "option=value" parsing by specifying the option like in the example below (mmh, tested with ruby 2.3.1 only).

Key is to use opts.on('--username=USER',... vs. opts.on('--username',... .

#!/usr/bin/env ruby
require 'optparse'

options = {:username=>nil}
optparse = OptionParser.new do|opts|
    # Define the options, and what they do
    opts.on( "--username=USER", 'Cassandra username' ) do |username|
        options[:username] = username
    end

    opts.on( '--password=PASSWORD', 'Cassandra password' ) do |password|
        options[:password] = password
    end

    opts.on( '--keyspace=KEY', 'Cassandra keyspace' ) do |keyspace|
        options[:keyspace] = keyspace
    end
end
puts ARGV

optparse.parse!(ARGV)

puts options

You do not loose the ability to pass the value without the equal-sign using this approach and have it converted to string:

➜  ~  /tmp/op.rb --username myuser
--username
myuser
{:username=>"myuser"}
➜  ~  /tmp/op.rb --username=myuser
--username=myuser
{:username=>"myuser"}


问:
Bootstrap Modal sitting behind backdrop
So I'm having nearly the exact same problem as @Jamescoo was but I think that my issue is coming from the fact that I have already positioned a couple of DIVs to create a sliding nav panel.

Here's my exact setup replicated:  http://jsfiddle.net/ZBQ8U/2/

BONUS: Feel free to grab the code for the sliding panel if you'd like :)

The z-indexes shouldn't conflict and their values would show that they are stacking correctly, but visually they are not.

Once you click the 'Open Modal' button the

 covers everything! (you'll have to re-run the code to reset it)

I don't know quite how to remedy this one...Any ideas?

答:
i encountred this problem, and after investigating my css, the main container (direct child of the body) had:

```<code>position: relative
z-index: 1
</code>```

the backdrop worked well after i removed those two properties. You may also encounter this problem if the main wraper have a position: fixed

Title: Bootstrap Modal sitting behind backdrop

Body:
i encountred this problem, and after investigating my css, the main container (direct child of the body) had:

position: relative
z-index: 1

the backdrop worked well after i removed those two properties. You may also encounter this problem if the main wraper have a position: fixed


问:
problem with GZIP CKEditor
i want to gzip ckeditor.js  and i changed extension from js to php and added this line to ckeditor.js.php file

```<code><?php
ob_start ("ob_gzhandler");
header("Content-type: text/javascript; charset: UTF-8");
header("Cache-Control: must-revalidate");
$offset = 60 * 60 ;
$ExpStr = "Expires: " .
gmdate("D, d M Y H:i:s",
time() + $offset) . " GMT";
header($ExpStr);
?>
</code>```

this code work for other .js files but this error appear for ckeditor.js.php page:

```<code>Error: CKEditor not found.This sample assumes that CKEditor (not included with CKFinder) is installed inthe "/ckeditor/" path. If you have it installed in a different place, just editthis file, changing the wrong paths in the <head> (line 5) and the "BasePath"value (line 32).
</code>```

i found ckeditor_php5.php and change
* $CKEditor->basePath = '/ckeditor/'; to  $CKEditor->basePath = '/ckeditor/ckeditor.js.php'; but it doesnt work.

答:
If you want to compress static resources it's better to do it via apache mod_deflate. PHP is slow and shouldn't be used for compressing static resources because processing will keep happening no matter how many times the file is requested. Also mod_deflate will handle cases where the client does not support gzip.

In addition in your example you have to modify possibly more than one place in the original code. That means than upgrading ckeditor will be harder later on.

Title: problem with GZIP CKEditor

Body:
i want to gzip ckeditor.js  and i changed extension from js to php and added this line to ckeditor.js.php file

<?php
ob_start ("ob_gzhandler");
header("Content-type: text/javascript; charset: UTF-8");
header("Cache-Control: must-revalidate");
$offset = 60 * 60 ;
$ExpStr = "Expires: " .
gmdate("D, d M Y H:i:s",
time() + $offset) . " GMT";
header($ExpStr);
?>

this code work for other .js files but this error appear for ckeditor.js.php page:

Error: CKEditor not found.This sample assumes that CKEditor (not included with CKFinder) is installed inthe "/ckeditor/" path. If you have it installed in a different place, just editthis file, changing the wrong paths in the  (line 5) and the "BasePath"value (line 32).

i found ckeditor_php5.php and change
* $CKEditor->basePath = '/ckeditor/'; to  $CKEditor->basePath = '/ckeditor/ckeditor.js.php'; but it doesnt work.


问:
window.location.href doesn't redirect
I know this is a question much discussed but I can't figure out why it does not work for me.

This is my function:

```<code>function ShowComments(){

 alert("fired");
 var movieShareId = document.getElementById('movieId');
 //alert("found div" + movieShareId.textContent || movieShareId.innerText);
 //alert("redirect location: /comments.aspx?id=" + movieShareId.textContent || movieShareId.innerText + "/");
 window.location.href = "/comments.aspx?id=" + movieShareId.textContent || movieShareId.innerText + "/";
 var newLocation = window.location;
 //alert("full location: " + window.location);

}
</code>```

If I have the alerts uncommented or if I have Mozilla's bugzilla open it works fine, otherwise it does not redirect to the other page.

Any ideas why?

答:
From this answer,

window.location.href not working

you just need to add

```<code>return false;
</code>```

at the bottom of your function

Title: window.location.href doesn't redirect

Body:
I know this is a question much discussed but I can't figure out why it does not work for me.

This is my function:

function ShowComments(){

 alert("fired");
 var movieShareId = document.getElementById('movieId');
 //alert("found div" + movieShareId.textContent || movieShareId.innerText);
 //alert("redirect location: /comments.aspx?id=" + movieShareId.textContent || movieShareId.innerText + "/");
 window.location.href = "/comments.aspx?id=" + movieShareId.textContent || movieShareId.innerText + "/";
 var newLocation = window.location;
 //alert("full location: " + window.location);

}

If I have the alerts uncommented or if I have Mozilla's bugzilla open it works fine, otherwise it does not redirect to the other page.

Any ideas why?

Body:
From this answer,

window.location.href not working

you just need to add

return false;

at the bottom of your function


问:
Clear PHP session on tab close?
I'm trying to logout each time the user closes it's tab. I've saw all similar questions, but I still haven't found anything that works.

Here's what I've done:

```<code><script type="text/javascript">
    $(document).ready(function() {
        $(window).bind("beforeunload", function() {
            confirm("Do you really want to logout?") && $.ajax({
                type: "GET",
                url: "/admin/account/logout"
            })
        })
    });
</script>
</code>```

I've tried without the confirm, but it still doesn't work. I'm absolutely sure that it can be done, since my bank's website has the same functionality.

EDIT:
Without the confirm it does fire the logout ajax, but even when I browse trough the pages. Which reminds me, that my bank's website uses something like AngularJS, which is not exactly a true link-browsing system, right? Maybe that's why it works there?

答: The beforeunload is fired every time you say your browser to unload current html. It's happens even if you click on a link. When you cosle a tab, you also close the enviroment where  that page's js was executed. I don't think it can be done natively.

Title: Clear PHP session on tab close?

Body:
I'm trying to logout each time the user closes it's tab. I've saw all similar questions, but I still haven't found anything that works.

Here's what I've done:

I've tried without the confirm, but it still doesn't work. I'm absolutely sure that it can be done, since my bank's website has the same functionality.

EDIT:
Without the confirm it does fire the logout ajax, but even when I browse trough the pages. Which reminds me, that my bank's website uses something like AngularJS, which is not exactly a true link-browsing system, right? Maybe that's why it works there?


答:
Is it using UTC, or something?

I have a PHP version that gives me an error whenever I do something date related without first using date_default_timezone_set. Maybe that'll help you.

Title: How can I get today's timestamp in PHP


问:
Javascript Regular Expression for hashtags with emoji
I want to make Regular Expression for hashtags allowing English, number, underbar and all unicode emojis

and this is what I got so far

```<code>(\#[a-zA-Z0-9_\uD83C-\uDBFF\uDC00-\uDFFF]+)
</code>```

it does work for some emojis but not all emojis like 826 or so

And I found this regex to match all unicode emojis but I don't know how to combine them together..

```<code>(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|[\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|[\ud83c[\ude32-\ude3a]|[\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])
</code>```

so I want to know either a full regular expression for english, number and all unicode emojis or combining those two regex.

thanks in advance

-- Edited --

with @Wiktor Stribiżew help, I found shorter way to do it

```<code>#(?:\w|[_]|[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|[\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|[\ud83c[\ude32-\ude3a]|[\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])+
</code>```

Body:
I want to make Regular Expression for hashtags allowing English, number, underbar and all unicode emojis

and this is what I got so far

(\#[a-zA-Z0-9_\uD83C-\uDBFF\uDC00-\uDFFF]+)

it does work for some emojis but not all emojis like 826 or so

And I found this regex to match all unicode emojis but I don't know how to combine them together..

(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|[\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|[\ud83c[\ude32-\ude3a]|[\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])

so I want to know either a full regular expression for english, number and all unicode emojis or combining those two regex.

thanks in advance

-- Edited --

with @Wiktor Stribiżew help, I found shorter way to do it

#(?:\w|[_]|[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|[\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|[\ud83c[\ude32-\ude3a]|[\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])+

Body:
You may use the following regex that matches 1 or more word chars (with the \w+ subpattern, 1+ ASCII digits, letters or/and _) or any of the emojis listed in  the Emoji Keyboard/Display Test Data for UTR #51 (Version: 11.0) file:

/#(?:\w|\uD83D(?:[\uDC76\uDC66\uDC67](?:\uD83C[\uDFFB-\uDFFF])?|\uDC68(?:(?:\uD83C(?:[\uDFFB-\uDFFF](?:\u200D(?:\u2695\uFE0F?|\uD83C[\uDF93\uDFEB\uDF3E\uDF73\uDFED\uDFA4\uDFA8]|\u2696\uFE0F?|\uD83D[\uDD27\uDCBC\uDD2C\uDCBB\uDE80\uDE92]|\u2708\uFE0F?|\uD83E[\uDDB0-\uDDB3]))?)|\u200D(?:\u2695\uFE0F?|\uD83C[\uDF93\uDFEB\uDF3E\uDF73\uDFED\uDFA4\uDFA8]|\u2696\uFE0F?|\uD83D(?:\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uDC68\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|[\uDD27\uDCBC\uDD2C\uDCBB\uDE80\uDE92])|\u2708\uFE0F?|\uD83E[\uDDB0-\uDDB3]|\u2764(?:\uFE0F\u200D\uD83D(?:\uDC8B\u200D\uD83D\uDC68|\uDC68)|\u200D\uD83D(?:\uDC8B\u200D\uD83D\uDC68|\uDC68)))))?|\uDC69(?:(?:\uD83C(?:[\uDFFB-\uDFFF](?:\u200D(?:\u2695\uFE0F?|\uD83C[\uDF93\uDFEB\uDF3E\uDF73\uDFED\uDFA4\uDFA8]|\u2696\uFE0F?|\uD83D[\uDD27\uDCBC\uDD2C\uDCBB\uDE80\uDE92]|\u2708\uFE0F?|\uD83E[\uDDB0-\uDDB3]))?)|\u200D(?:\u2695\uFE0F?|\uD83C[\uDF93\uDFEB\uDF3E\uDF73\uDFED\uDFA4\uDFA8]|\u2696\uFE0F?|\uD83D(?:\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|[\uDD27\uDCBC\uDD2C\uDCBB\uDE80\uDE92])|\u2708\uFE0F?|\uD83E[\uDDB0-\uDDB3]|\u2764(?:\uFE0F\u200D\uD83D(?:\uDC8B\u200D\uD83D[\uDC68\uDC69]|[\uDC68\uDC69])|\u200D\uD83D(?:\uDC8B\u200D\uD83D[\uDC68\uDC69]|[\uDC68\uDC69])))))?|[\uDC74\uDC75](?:\uD83C[\uDFFB-\uDFFF])?|\uDC6E(?:(?:\uD83C(?:[\uDFFB-\uDFFF](?:\u200D(?:[\u2642\u2640]\uFE0F?))?)|\u200D(?:[\u2642\u2640]\uFE0F?)))?|\uDD75(?:(?:\uFE0F(?:\u200D(?:[\u2642\u2640]\uFE0F?))?|\uD83C(?:[\uDFFB-\uDFFF](?:\u200D(?:[\u2642\u2640]\uFE0F?))?)|\u200D(?:[\u2642\u2640]\uFE0F?)))?|[\uDC82\uDC77](?:(?:\uD83C(?:[\uDFFB-\uDFFF](?:\u200D(?:[\u2642\u2640]\uFE0F?))?)|\u200D(?:[\u2642\u2640]\uFE0F?)))?|\uDC78(?:\uD83C[\uDFFB-\uDFFF])?|\uDC73(?:(?:\uD83C(?:[\uDFFB-\uDFFF](?:\u200D(?:[\u2642\u2640]\uFE0F?))?)|\u200D(?:[\u2642\u2640]\uFE0F?)))?|\uDC72(?:\uD83C[\uDFFB-\uDFFF])?|\uDC71(?:(?:\uD83C(?:[\uDFFB-\uDFFF](?:\u200D(?:[\u2642\u2640]\uFE0F?))?)|\u200D(?:[\u2642\u2640]\uFE0F?)))?|[\uDC70\uDC7C](?:\uD83C[\uDFFB-\uDFFF])?|[\uDE4D\uDE4E\uDE45\uDE46\uDC81\uDE4B\uDE47\uDC86\uDC87\uDEB6](?:(?:\uD83C(?:[\uDFFB-\uDFFF](?:\u200D(?:[\u2642\u2640]\uFE0F?))?)|\u200D(?:[\u2642\u2640]\uFE0F?)))?|[\uDC83\uDD7A](?:\uD83C[\uDFFB-\uDFFF])?|\uDC6F(?:\u200D(?:[\u2642\u2640]\uFE0F?))?|[\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|\uDD74(?:(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F))?|\uDDE3\uFE0F?|[\uDEA3\uDEB4\uDEB5](?:(?:\uD83C(?:[\uDFFB-\uDFFF](?:\u200D(?:[\u2642\u2640]\uFE0F?))?)|\u200D(?:[\u2642\u2640]\uFE0F?)))?|[\uDCAA\uDC48\uDC49\uDC46\uDD95\uDC47\uDD96](?:\uD83C[\uDFFB-\uDFFF])?|\uDD90(?:(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F))?|[\uDC4C-\uDC4E\uDC4A\uDC4B\uDC4F\uDC50\uDE4C\uDE4F\uDC85\uDC42\uDC43](?:\uD83C[\uDFFB-\uDFFF])?|\uDC41(?:(?:\uFE0F(?:\u200D\uD83D\uDDE8\uFE0F?)?|\u200D\uD83D\uDDE8\uFE0F?))?|[\uDDE8\uDDEF\uDD73\uDD76\uDECD\uDC3F\uDD4A\uDD77\uDD78\uDDFA\uDEE3\uDEE4\uDEE2\u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DD03\uDD04\uDD19-\uDD1D\uDED0\uDD4E\uDD2F\uDD00-\uDD02\uDD3C\uDD3D\uDD05\uDD06\uDCF6\uDCF3\uDCF4\uDD31\uDCDB\uDD30\uDD1F\uDCAF\uDD20-\uDD24\uDD36-\uDD3B\uDCA0\uDD18\uDD32-\uDD35\uDEA9])|\uD83E(?:[\uDDD2\uDDD1\uDDD3](?:\uD83C[\uDFFB-\uDFFF])?|[\uDDB8\uDDB9](?:\u200D(?:[\u2640\u2642]\uFE0F?))?|[\uDD34\uDDD5\uDDD4\uDD35\uDD30\uDD31\uDD36](?:\uD83C[\uDFFB-\uDFFF])?|[\uDDD9-\uDDDD](?:(?:\uD83C(?:[\uDFFB-\uDFFF](?:\u200D(?:[\u2640\u2642]\uFE0F?))?)|\u200D(?:[\u2640\u2642]\uFE0F?)))?|[\uDDDE\uDDDF](?:\u200D(?:[\u2640\u2642]\uFE0F?))?|[\uDD26\uDD37](?:(?:\uD83C(?:[\uDFFB-\uDFFF](?:\u200D(?:[\u2642\u2640]\uFE0F?))?)|\u200D(?:[\u2642\u2640]\uFE0F?)))?|[\uDDD6-\uDDD8](?:(?:\uD83C(?:[\uDFFB-\uDFFF](?:\u200D(?:[\u2640\u2642]\uFE0F?))?)|\u200D(?:[\u2640\u2642]\uFE0F?)))?|\uDD38(?:(?:\uD83C(?:[\uDFFB-\uDFFF](?:\u200D(?:[\u2642\u2640]\uFE0F?))?)|\u200D(?:[\u2642\u2640]\uFE0F?)))?|\uDD3C(?:\u200D(?:[\u2642\u2640]\uFE0F?))?|[\uDD3D\uDD3E\uDD39](?:(?:\uD83C(?:[\uDFFB-\uDFFF](?:\u200D(?:[\u2642\u2640]\uFE0F?))?)|\u200D(?:[\u2642\u2640]\uFE0F?)))?|[\uDD33\uDDB5\uDDB6\uDD1E\uDD18\uDD19\uDD1B\uDD1C\uDD1A\uDD1F\uDD32](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD23\uDD70\uDD17\uDD29\uDD14\uDD28\u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?))?|\uD83C(?:[\uDFFB-\uDFFF](?:\u200D(?:[\u2642\u2640]\uFE0F?))?)|\u200D(?:[\u2642\u2640]\uFE0F?)))?|[\uDFC4\uDFCA](?:(?:\uD83C(?:[\uDFFB-\uDFFF](?:\u200D(?:[\u2642\u2640]\uFE0F?))?)|\u200D(?:[\u2642\u2640]\uFE0F?)))?|\uDFCB(?:(?:\uFE0F(?:\u200D(?:[\u2642\u2640]\uFE0F?))?|\uD83C(?:[\uDFFB-\uDFFF](?:\u200D(?:[\u2642\u2640]\uFE0F?))?)|\u200D(?:[\u2642\u2640]\uFE0F?)))?|[\uDFCE\uDFCD\uDFF5\uDF36\uDF7D\uDFD4-\uDFD6\uDFDC-\uDFDF\uDFDB\uDFD7\uDFD8\uDFDA\uDFD9\uDF21\uDF24-\uDF2C\uDF97\uDF9F\uDF96\uDF99-\uDF9B\uDF9E\uDFF7\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37]\uFE0F?|\uDFF4(?:(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67\uDB40\uDC7F|\uDC73\uDB40\uDC63\uDB40\uDC74\uDB40\uDC7F|\uDC77\uDB40\uDC6C\uDB40\uDC73\uDB40\uDC7F)))?|\uDFF3(?:(?:\uFE0F(?:\u200D\uD83C\uDF08)?|\u200D\uD83C\uDF08))?|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uD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D\u270C](?:(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F))?|[\u270B\u270A](?:\uD83C[\uDFFB-\uDFFF])?|\u270D(?:(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F))?|[\u2764\u2763\u26D1\u2618\u26F0\u26E9\u2668\u26F4\u2708\u23F1\u23F2\u2600\u2601\u26C8\u2602\u26F1\u2744\u2603\u2604\u26F8\u2660\u2665\u2666\u2663\u260E\u2328\u2709\u270F\u2712\u2702\u26CF\u2692\u2694\u2699\u2696\u26D3\u2697\u26B0\u26B1\u26A0\u2622\u2623\u2B06\u2197\u27A1\u2198\u2B07\u2199\u2B05\u2196\u2195\u2194\u21A9\u21AA\u2934\u2935\u269B\u267E\u2721\u2638\u262F\u271D\u2626\u262A\u262E\u25B6\u23ED\u23EF\u25C0\u23EE\u23F8-\u23FA\u23CF\u2640\u2642\u2695\u267B\u269C\u2611\u2714\u2716\u303D\u2733\u2734\u2747\u203C\u2049\u3030\u00A9\u00AE\u2122]\uFE0F?|[\u0023\u002A\u0030-\u0039](?:\uFE0F\u20E3|\u20E3)|[\u2139\u24C2\u3297\u3299\u25AA\u25AB\u25FB\u25FC]\uFE0F?|[\u2615\u26EA\u26F2\u26FA\u26FD\u2693\u26F5\u231B\u23F3\u231A\u23F0\u2B50\u26C5\u2614\u26A1\u26C4\u2728\u26BD\u26BE\u26F3\u267F\u26D4\u2648-\u2653\u26CE\u23E9-\u23EC\u2B55\u2705\u274C\u274E\u2795-\u2797\u27B0\u27BF\u2753-\u2755\u2757\u25FD\u25FE\u2B1B\u2B1C\u26AA\u26AB])+/g

See the regex demo

Details

# - a # char

(?: - start of the alternation group

\w - a word char (ASCII letter/digit/_)

| - or

<emoji_unicode_codes> - emoji matching regex (built dynamically using a regex trie approach and condensed to some extent)

)+ - one or more occurrences of the chars in the alternation group.


问:
Round of experiance in years months
I am saving employees work experiance for example as 5.14 n all when I display it, it should show me as 6.2yrs of experiance;

How can I calculate it in PHP or laravel framework?

答:
If you mean 6.14 to round up to 6.2.

You can use the the following function of PHP:

```<code>function round_up($e)
{
    $e = explode(".", $e);
    $e[1] = ceil($e[1] / 10);
    return implode(".", $e);
}
</code>```

With the ceil() function you can round up to the next highest integer value. See the docs.

If you mean 5.14 to round up to 6.2 (as in 14 months). You can use the following function:

```<code>function round_up($e)
{
    $e = explode(".", $e);
    $e[0] = $e[0] + round($e[1] / 12);
    $e[1] = $e[1]%12;
    return implode(".", $e);
}
</code>```

Title: Round of experiance in years months

Body:
If you mean 6.14 to round up to 6.2.

You can use the the following function of PHP:

function round_up($e)
{
    $e = explode(".", $e);
    $e[1] = ceil($e[1] / 10);
    return implode(".", $e);
}

With the ceil() function you can round up to the next highest integer value. See the docs.

If you mean 5.14 to round up to 6.2 (as in 14 months). You can use the following function:

function round_up($e)
{
    $e = explode(".", $e);
    $e[0] = $e[0] + round($e[1] / 12);
    $e[1] = $e[1]%12;
    return implode(".", $e);
}


问:
Terrain and satellite view using MapKit
i am new to Mapkit View .i want to display when i give lat,lang without destination.
is it possible to display maps through terrain,satelite view in mapkit?anny tutorial
link?i have seen some examples with accessing google map API(html file).is it neccessary?</p>

答:
You can set any of the following Map Type for MapView

```<code>map.mapType = MKMapType.hybrid
map.mapType = MKMapType.hybridFlyover
map.mapType = MKMapType.mutedStandard
map.mapType = MKMapType.satellite
map.mapType = MKMapType.satelliteFlyover
map.mapType = MKMapType.standard
</code>```

Hybrid - A satellite image of the area with road and road name information layered on top.

Standard - A street map that shows the position of all roads and some road names..

Satellite - Satellite imagery of the area.

HybridFlyover - A hybrid satellite image with flyover data where available.

SatelliteFlyover - A satellite image of the area with flyover data where available.

MutedStandard - A street map where your data is emphasized over the underlying map details.

hybrid , satellite , standard are available for iOS 3 and above

hybridFlyover , satelliteFlyover are available for iOS 9 and above

mutedStandard are available for iOS 11 and above

Title: Terrain and satellite view using MapKit

Body:
You can set any of the following Map Type for MapView

map.mapType = MKMapType.hybrid
map.mapType = MKMapType.hybridFlyover
map.mapType = MKMapType.mutedStandard
map.mapType = MKMapType.satellite
map.mapType = MKMapType.satelliteFlyover
map.mapType = MKMapType.standard

Hybrid - A satellite image of the area with road and road name information layered on top.

Standard - A street map that shows the position of all roads and some road names..

Satellite - Satellite imagery of the area.

HybridFlyover - A hybrid satellite image with flyover data where available.

SatelliteFlyover - A satellite image of the area with flyover data where available.

MutedStandard - A street map where your data is emphasized over the underlying map details.

hybrid , satellite , standard are available for iOS 3 and above

hybridFlyover , satelliteFlyover are available for iOS 9 and above

mutedStandard are available for iOS 11 and above


问:
Sql query searching for the first three letters
My Sql query is not correct. I want to create a query that searches for companies whose first three characters are equal to the given parameter

```<code>@NamedNativeQuery(
    name="Company.retrieveNameCompanyForFirstThreeChar",
    query =" SELECT SUBSTRING(company_name, 1, 3) AS keyword from companies
    WHERE = :KEYWORD",
    resultClass = Company.class
)
</code>```

My error:

org.springframework.dao.InvalidDataAccessResourceUsageException:
  could not extract ResultSet; SQL [n/a]; nested exception is
  org.hibernate.exception.SQLGrammarException: could not extract
  ResultSet

答:
There is subtring function provided by mysql. </p>

```<code>SELECT company_name FROM companies WHERE SUBSTRING(company_name FROM 1 FOR 3) = :KEYWORD;
</code>```

Body:
My Sql query is not correct. I want to create a query that searches for companies whose first three characters are equal to the given parameter

@NamedNativeQuery(
    name="Company.retrieveNameCompanyForFirstThreeChar",
    query =" SELECT SUBSTRING(company_name, 1, 3) AS keyword from companies
    WHERE = :KEYWORD",
    resultClass = Company.class
)

My error:

org.springframework.dao.InvalidDataAccessResourceUsageException:
  could not extract ResultSet; SQL [n/a]; nested exception is
  org.hibernate.exception.SQLGrammarException: could not extract
  ResultSet

Body:
There is subtring function provided by mysql.

SELECT company_name FROM companies WHERE SUBSTRING(company_name FROM 1 FOR 3) = :KEYWORD;


问:
Chrome Browser API (for a browser extension)
I have problem with using the Chrome API the api call i'm using is chrome.storage.sync.get and i was using this to try and get a variable in memory  and when returning the variable it returns [object Object] in the Chrome console which should'nt happen it should return a number depending on what found there
Here is my code

```<code>//Get index variable
 chrome.storage.sync.get("index_value", function (data1)
 {
 Get_value(data1)
 });
 function Get_value(value)
 {
    index = value;
    console.log("Fetched index value is" + value);
 }
</code>```

More information:

The variable in memory is just a decimal number e.g 1

I am using the chrome.storage.sync.set API call to save the variable

The variable name is index

The variable index keeps track of array locations e.g array[index]

答:
According to the API doc chrome.storage.sync.get always returns an object and it should contain a property with your index_value!?

So this should get your index_value:

```<code>chrome.storage.sync.get("index_value", function (data1)
 {
 console.log(data1.index_value);
 });
</code>```

Also to clarify you only see [object Object] in your console log because you do string concatenation instead of logging the object by itself like this:

```<code>console.log("Fetched index value is", value);
</code>```

That will display the expandable object in your console, notice the , instead of + so you log two values instead of a single string.

Body:
I have problem with using the Chrome API the api call i'm using is chrome.storage.sync.get and i was using this to try and get a variable in memory  and when returning the variable it returns [object Object] in the Chrome console which should'nt happen it should return a number depending on what found there
Here is my code

//Get index variable
 chrome.storage.sync.get("index_value", function (data1)
 {
 Get_value(data1)
 });
 function Get_value(value)
 {
    index = value;
    console.log("Fetched index value is" + value);
 }

More information:

The variable in memory is just a decimal number e.g 1

I am using the chrome.storage.sync.set API call to save the variable

The variable name is index

The variable index keeps track of array locations e.g array[index]

Body:
According to the API doc chrome.storage.sync.get always returns an object and it should contain a property with your index_value!?

So this should get your index_value:

chrome.storage.sync.get("index_value", function (data1)
 {
 console.log(data1.index_value);
 });

Also to clarify you only see [object Object] in your console log because you do string concatenation instead of logging the object by itself like this:

console.log("Fetched index value is", value);

That will display the expandable object in your console, notice the , instead of + so you log two values instead of a single string.


问:
JMeter Get Body Data before Sending
for example i have http body data like this

```<code>{
  "signature" : "${signatureCreate}",
  "paramA"  : "1A02",
  "paramB"  : "aaa",
  "paramC"  : "asass"
}
</code>```

how could i get all params (paramA, paramB, paramC) in my BeanShell Preprocessor? i have to get all these 3, encrypt it, and put it back in "signature" param

i also tries using JSR223 PreProcessor like this (only to try to get the paramA value, but still no luck)

```<code>def body = new groovy.json.JsonSlurper().parseText(sampler.getArguments().getArgument(0).getValue())
vars.put("signatureCreate", body.paramA);
</code>```

thanks in advance

答:
Your code should work fine (given you choose Groovy in the "Language" dropdown), just add Debug Sampler and View Results Tree listener to your Test Plan, you will be able to see signature variable value in the "Response Data" tab of the Debug Sampler

More information: How to Debug your Apache JMeter Script

Title: JMeter Get Body Data before Sending

Body:
for example i have http body data like this

{
  "signature" : "${signatureCreate}",
  "paramA"  : "1A02",
  "paramB"  : "aaa",
  "paramC"  : "asass"
}

how could i get all params (paramA, paramB, paramC) in my BeanShell Preprocessor? i have to get all these 3, encrypt it, and put it back in "signature" param

i also tries using JSR223 PreProcessor like this (only to try to get the paramA value, but still no luck)

def body = new groovy.json.JsonSlurper().parseText(sampler.getArguments().getArgument(0).getValue())
vars.put("signatureCreate", body.paramA);

thanks in advance


问:
How to pass a string from C to swift?
I am using OpenSSL as a library in swift. Since it's in C, I need to pass some data from C language back to swift. The data was an array, but after some research I have learned that I cannot pass an array from C to swift. One way I can think of it is to change the array into a string, an then pass the string back to swift.
In C I wrote:

```<code>char teststring()
{
    char c[]={"H","E","L","L","O"};
    printf(c);
    return c;
}
</code>```

In Swift I wrote:

```<code>teststring()
</code>```

The result is that it only prints H.
What did I do wrong with it? It there a easier way to pass an array from C back to Swift?

答:
You might want to change

```<code>char c[]={"H","E","L","L","O"};
</code>```

to

```<code>char c[]={'H','E','L','L','O','\0'};
</code>```

Or

```<code>char c[]="HELLO";
</code>```

By char c[]={"H","E","L","L","O"}; an array of strings is getting declared, rather than an array of characters.
There is a difference between a string and a char.

A string literal enclosed within a double quotes represents a set of characters. So, "H" seems to represent a single character to you, but internally it contains an additional character with 'H' and the very necessary '\0' which is terminating character in C. That was possibly the reason that you were getting a H printed on your console as output.

This is because as per C11 standard - Section: 6.4.5 String literals which states,

A character string literal is a sequence of zero or more multibyte characters enclosed in double-quotes, as in "xyz". A UTF-8 string literal is the same, except prefixed by u8. A wide string literal is the same, except prefixed by the letter L, u, or U.

Additionally, section: 6.4.4.4 Character constants states that,

An integer character constant is a sequence of one or more multibyte characters enclosed in single-quotes, as in 'x'. A wide character constant is the same, except prefixed by the letter L, u, or U. With a few exceptions detailed later, the elements of the sequence are any members of the source character set; they are mapped in an implementation-defined manner to members of the execution character set.

Also,

```<code>char teststring()
</code>```

means that teststring is supposed to return a char, and you are returning c which is now a string. So either change it to return a pointer to char i.e

```<code>char* teststring()
</code>```

Or, return a char like return c[0];

Title: How to pass a string from C to swift?

Body:
I am using OpenSSL as a library in swift. Since it's in C, I need to pass some data from C language back to swift. The data was an array, but after some research I have learned that I cannot pass an array from C to swift. One way I can think of it is to change the array into a string, an then pass the string back to swift.
In C I wrote:

char teststring()
{
    char c[]={"H","E","L","L","O"};
    printf(c);
    return c;
}

In Swift I wrote:

teststring()

The result is that it only prints H.
What did I do wrong with it? It there a easier way to pass an array from C back to Swift?

Body:
You might want to change

char c[]={"H","E","L","L","O"};

to

char c[]={'H','E','L','L','O','\0'};

Or

char c[]="HELLO";

By char c[]={"H","E","L","L","O"}; an array of strings is getting declared, rather than an array of characters.
There is a difference between a string and a char.

A string literal enclosed within a double quotes represents a set of characters. So, "H" seems to represent a single character to you, but internally it contains an additional character with 'H' and the very necessary '\0' which is terminating character in C. That was possibly the reason that you were getting a H printed on your console as output.

This is because as per C11 standard - Section: 6.4.5 String literals which states,

A character string literal is a sequence of zero or more multibyte characters enclosed in double-quotes, as in "xyz". A UTF-8 string literal is the same, except prefixed by u8. A wide string literal is the same, except prefixed by the letter L, u, or U.

Additionally, section: 6.4.4.4 Character constants states that,

An integer character constant is a sequence of one or more multibyte characters enclosed in single-quotes, as in 'x'. A wide character constant is the same, except prefixed by the letter L, u, or U. With a few exceptions detailed later, the elements of the sequence are any members of the source character set; they are mapped in an implementation-defined manner to members of the execution character set.

Also,

char teststring()

means that teststring is supposed to return a char, and you are returning c which is now a string. So either change it to return a pointer to char i.e

char* teststring()

Or, return a char like return c[0];


问:
When to use method over computed property setter and vice versa?
When using Vue.js, when should you use a method or a computed property setter? There seems to be little distinction in the documentation, or numerous articles. Usually articles present computed property setters as little more than a footnote.

Given that both methods and setters accept parameters, is there a particular reason you'd use one or the other? As far as I can see methods would be all you need.

Edit:

This is literally not a repost because the linked SO answer contains the word setter once and only in vague passing:

computed properties are converted into a property of the Vue with a getter and sometimes a setter.

Great, so how does this elaborate on the subject of this post, when to use a SETTER vs a method?

答:
Computed properties are cached so they can benefit you when it comes to performance. They do not work like methods, as they do not accept arguments.

I use them mostly to modify existing data or make it easier to access nested data.

The part about caching is something that can end up being a hassle. They will always cache unless their direct dependencies change. Properties within computed properties that are within controls blocks will usually not update the computed property(not seen as a direct dependency).

This is something you need to be aware of.

When using things like large v-for lists you will want to to take advantage of the caching ability of computed properties since unlike with a method you won't have to perform the logic inside of it over and over, unless the direct dependencies of the computed property change.


问:
Disabling Swapping of a Redis Instance on AWS's ElastiCache
We are trying to disable swapping RAM to the disk for a Redis instance managed by AWS's Elasticache - but couldn't find the right property to do so.

We also cannot find a way to SSH it and turn off swapping from the kernerl, can you please help ?

答:
It is not possible to connect to Elasticache via SSH.

Are you sure that you are having issues with Redis swapping to disk, or the host running out of memory and crashing (I've seen this happen with the default configuration)? If so, the guidance is to leave about 25% of the system memory available for host processes - http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/redis-memory-management.html


问:
Response.Redirect with POST instead of Get?
We have the requirement to take a form submission and save some data, then redirect the user to a page offsite, but in redirecting, we need to "submit" a form with POST, not GET.

I was hoping there was an easy way to accomplish this, but I'm starting to think there isn't.  I think I must now create a simple other page, with just the form that I want, redirect to it, populate the form variables, then do a body.onload call to a script that merely calls document.forms[0].submit();

Can anyone tell me if there is an alternative?  We might need to tweak this later in the project, and it might get sort of complicated, so if there was an easy we could do this all non-other page dependent that would be fantastic.

Anyway, thanks for any and all responses.

答:
Here's what I'd do :

Put the data in a standard form (with no runat="server" attribute) and set the action of the form to post to the target off-site page.
Before submitting I would submit the data to my server using an XmlHttpRequest and analyze the response. If the response means you should go ahead with the offsite POSTing then I (the JavaScript) would proceed with the post otherwise I would redirect to a page on my site

OwnerDisplayName: Matt Dawdy

OwnerDisplayName: Andrei Rinea


问:
I'm using vim editor and my escape button stopped working. I've some unsaved data and I'm in insert mode. How can I still save my data?

Getting my content saved.

I want my content saved or written without using the escape button.

I'm worried as my data will not be saved.

答: Try Ctrl+[, which is equivalent to Escape in most terminals.


答: <C-c> and <C-[> can both be used instead of <Esc>.

Title: I'm using vim editor and my escape button stopped working. I've some unsaved data and I'm in insert mode. How can I still save my data?

Body:
Getting my content saved.

I want my content saved or written without using the escape button.

I'm worried as my data will not be saved.


问:
Group by with MAX in SQL
I am trying to retrieve the max(CRN) with a group by function to retrieve duplicate records aside from CRN but it is not working:
below is my select statement:

```<code>    select max(CRN), TERM, SUBJECT, COURSE, SCH, R_KEY, R_PERC
    from database
     group by        TERM, SUBJECT, COURSE, SCH, R_KEY, R_PERC
</code>```

Below is my input file:

```<code>CRN  TERM   SUBJECT COURSE  SCH   R_KEY R_PERC
10607      10   DGRG    230  K  36714   37
10607      10   DGRG    230  K  36715   38
11658      10   MATH    101  E  213162  100
11658      10   MATH    101  L  182471  100
12811      10   MHRM    310  L  32951   50
12811      10   MHRM    310  L  130923  50
12879      10   MHRM    310  L  32738   50
12879      10   MHRM    310  L  32951   50
12912      10   MHRM    310  L  120641  50
12912      10   MHRM    310  L  121008  50
</code>```

I am expecting the same below output as (above input) because I have  different "R_PERC" or "R_KEY":

```<code>CRN  TERM   SUBJECT COURSE  SCH   R_KEY R_PERC
10607      10   DGRG    230  K  36714   37
10607      10   DGRG    230  K  36715   38
11658      10   MATH    101  E  213162  100
11658      10   MATH    101  L  182471  100
12811      10   MHRM    310  L  32951   50
12811      10   MHRM    310  L  130923  50
12879      10   MHRM    310  L  32738   50
12879      10   MHRM    310  L  32951   50
12912      10   MHRM    310  L  120641  50
12912      10   MHRM    310  L  121008  50
</code>```

But my actual output is only one record for CRN 12811 as below, noting that the output would be similar for all CRNs (meaning one record only) if we include above input file in a much bigger file record:

```<code>CRN  TERM   SUBJECT COURSE  SCH   R_KEY R_PERC
10607      10   DGRG    230  K  36714   37
10607      10   DGRG    230  K  36715   38
11658      10   MATH    101  E  213162  100
11658      10   MATH    101  L  182471  100
12811      10   MHRM    310  L  32951   50

12879      10   MHRM    310  L  32738   50
12879      10   MHRM    310  L  32951   50
12912      10   MHRM    310  L  120641  50
12912      10   MHRM    310  L  121008  50
</code>```

Title: Group by with MAX in SQL

Body:
I am trying to retrieve the max(CRN) with a group by function to retrieve duplicate records aside from CRN but it is not working:
below is my select statement:

    select max(CRN), TERM, SUBJECT, COURSE, SCH, R_KEY, R_PERC
    from database
     group by        TERM, SUBJECT, COURSE, SCH, R_KEY, R_PERC

Below is my input file:

CRN  TERM   SUBJECT COURSE  SCH   R_KEY R_PERC
10607      10   DGRG    230  K  36714   37
10607      10   DGRG    230  K  36715   38
11658      10   MATH    101  E  213162  100
11658      10   MATH    101  L  182471  100
12811      10   MHRM    310  L  32951   50
12811      10   MHRM    310  L  130923  50
12879      10   MHRM    310  L  32738   50
12879      10   MHRM    310  L  32951   50
12912      10   MHRM    310  L  120641  50
12912      10   MHRM    310  L  121008  50

I am expecting the same below output as (above input) because I have  different "R_PERC" or "R_KEY":

CRN  TERM   SUBJECT COURSE  SCH   R_KEY R_PERC
10607      10   DGRG    230  K  36714   37
10607      10   DGRG    230  K  36715   38
11658      10   MATH    101  E  213162  100
11658      10   MATH    101  L  182471  100
12811      10   MHRM    310  L  32951   50
12811      10   MHRM    310  L  130923  50
12879      10   MHRM    310  L  32738   50
12879      10   MHRM    310  L  32951   50
12912      10   MHRM    310  L  120641  50
12912      10   MHRM    310  L  121008  50

But my actual output is only one record for CRN 12811 as below, noting that the output would be similar for all CRNs (meaning one record only) if we include above input file in a much bigger file record:

CRN  TERM   SUBJECT COURSE  SCH   R_KEY R_PERC
10607      10   DGRG    230  K  36714   37
10607      10   DGRG    230  K  36715   38
11658      10   MATH    101  E  213162  100
11658      10   MATH    101  L  182471  100
12811      10   MHRM    310  L  32951   50

12879      10   MHRM    310  L  32738   50
12879      10   MHRM    310  L  32951   50
12912      10   MHRM    310  L  120641  50
12912      10   MHRM    310  L  121008  50

Body:
Include the count:

+----------+----------+------+---------+--------+------+--------+--------+
| max(CRN) | count(*) | TERM | SUBJECT | COURSE | SCH  | R_KEY  | R_PERC |
+----------+----------+------+---------+--------+------+--------+--------+
|    10607 |        1 |   10 | DGRG    |    230 | K    |  36714 |     37 |
|    10607 |        1 |   10 | DGRG    |    230 | K    |  36715 |     38 |
|    11658 |        1 |   10 | MATH    |    101 | E    | 213162 |    100 |
|    11658 |        1 |   10 | MATH    |    101 | L    | 182471 |    100 |
|    12879 |        1 |   10 | MHRM    |    310 | L    |  32738 |     50 |
|    12879 |        2 |   10 | MHRM    |    310 | L    |  32951 |     50 | <-- your 12811 record is included in here, because both records have the same R_KEY
|    12912 |        1 |   10 | MHRM    |    310 | L    | 120641 |     50 |
|    12912 |        1 |   10 | MHRM    |    310 | L    | 121008 |     50 |
|    12811 |        1 |   10 | MHRM    |    310 | L    | 130923 |     50 |
+----------+----------+------+---------+--------+------+--------+--------+

These two records get grouped:

+-------+------+---------+--------+------+-------+--------+
| CRN   | TERM | SUBJECT | COURSE | SCH  | R_KEY | R_PERC |
+-------+------+---------+--------+------+-------+--------+
| 12811 |   10 | MHRM    |    310 | L    | 32951 |     50 |
| 12879 |   10 | MHRM    |    310 | L    | 32951 |     50 |
+-------+------+---------+--------+------+-------+--------+


问:
Kotlin Intent error
I have the following code and am getting an error with the Intent. It is because of the this I am fairly certain.

```<code>listView.onItemClickListener = object : OnItemClickListener {
            override
            fun onItemClick(parent: AdapterView<*>, view: View,
                            position: Int, id: Long) {
                val intent = Intent(this, MyActivity::class.java)
                startActivity(intent)
            }

        }
</code>```

答:
It has two solutions you can use either:

```<code>val intent = Intent(this@YourActivity, MyActivity::class.java)
                startActivity(intent)
</code>```

or :

```<code> val intent = Intent(applicationContext, MyActivity::class.java)
                    startActivity(intent)
</code>```

Title: Kotlin Intent error

Body:
I have the following code and am getting an error with the Intent. It is because of the this I am fairly certain.

listView.onItemClickListener = object : OnItemClickListener {
            override
            fun onItemClick(parent: AdapterView<*>, view: View,
                            position: Int, id: Long) {
                val intent = Intent(this, MyActivity::class.java)
                startActivity(intent)
            }

        }

Body:
It has two solutions you can use either:

val intent = Intent(this@YourActivity, MyActivity::class.java)
                startActivity(intent)

or :

 val intent = Intent(applicationContext, MyActivity::class.java)
                    startActivity(intent)