问:
Cannot show a html5 video dynamically with js
I have a table which looks like this:

```<code>+------------+---------+
|    Name    |  View   |
+------------+---------+
| 1.mp4      |    X    |
| 2.mp4      |    X    |
+------------+---------+
</code>```

X are view buttons.

When the user clicks on any of the view button, I want to show the corresponding video in a modal. I am using html5 video tag for that. In the video tag, I want to provide the src dynamically.

The src would be name of the video. I am using javascript for this.

HTML:

the X button:

```<code><a data-toggle="modal" data-id={{name}} href="#Modal" class="preview">X</a>
<!--{{name}} is 1.mp4-->
</code>```

modal:

```<code>...
<div class="modal-body">
<video width="548" height="455" controls>
<source id="vsrc" type="video/mp4">
Your browser does not support video playback.
</video>
</div>
...
</code>```

JS:

```<code>var videoName = $(this).data('id'); //This is correct
document.getElementById('vsrc').src = videoName;
</code>```

When I check the source code of the page, the src is correctly set,

```<code><source id="vsrc" type="video/mp4" src="1.mp4">
</code>```

But there is no video shown on the page, only an empty container and some disabled video control buttons are displayed.

I tried pasting this source code into the actual HTML page and it worked that way, I can't figure out why it doesn't work dynamically.

答:
Set the video source directly like this...

var vid = document.getElementById('vid');

vid.src = "http://clips.vorwaerts-gmbh.de/VfE_html5.mp4";
vid.play();```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="modal-body">
    <video id="vid" width="548" height="455" controls>
    Your browser does not support video playback.
    </video>
</div></code>```

Body:
I have a table which looks like this:

+------------+---------+
|    Name    |  View   |
+------------+---------+
| 1.mp4      |    X    |
| 2.mp4      |    X    |
+------------+---------+

X are view buttons.

When the user clicks on any of the view button, I want to show the corresponding video in a modal. I am using html5 video tag for that. In the video tag, I want to provide the src dynamically.

The src would be name of the video. I am using javascript for this.

HTML:

the X button:

X

modal:

...

<video width="548" height="455" controls>
<source id="vsrc" type="video/mp4">
Your browser does not support video playback.
</video>

...

JS:

var videoName = $(this).data('id'); //This is correct
document.getElementById('vsrc').src = videoName;

When I check the source code of the page, the src is correctly set,

<source id="vsrc" type="video/mp4" src="1.mp4">

But there is no video shown on the page, only an empty container and some disabled video control buttons are displayed.

I tried pasting this source code into the actual HTML page and it worked that way, I can't figure out why it doesn't work dynamically.

Body:
Set the video source directly like this...

var vid = document.getElementById('vid');

vid.src = "http://clips.vorwaerts-gmbh.de/VfE_html5.mp4";
vid.play();

<div class="modal-body">
    <video id="vid" width="548" height="455" controls>
    Your browser does not support video playback.
    </video>
</div>


来源: stackexchange

问:
Background image in columns of graph
I have cgi-script that draws a graph. Here is the code:

```<code>#!/usr/bin/perl -w

use CGI ':standard';
use GD::Graph::bars;
use strict;

my @data = (["Jan", "Feb", "Mar", "Apr", "May", "Jun",
             "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
            [23, 5, 2, 20, 11, 33, 7, 31, 77, 18, 65, 52]);

my $mygraph = GD::Graph::bars->new(500, 300);
$mygraph->set(
    x_label => 'Month',
    y_label => 'Number of Hits',
    title   => 'Number of Hits in Each Month in 2002',
    dclrs   => ['cyan']
) or warn $mygraph->error;

my $myimage = $mygraph->plot(\@data) or die $mygraph->error;

print "Content-type: image/png\n\n";
print $myimage->png;
</code>```

All the columns are cyan color. So...

Have you got any ideas how can I place image in columns instead of color?

I searched the web about it but nothing similar I couldn't find.
I would like to use only GD.pm without using additional modules such as ImageMagick.

答:
I don't know. You can have a background image for the entire graph by specifying the logo option.

```$mygraph->set(
    x_label => 'Month',
    y_label => 'Number of Hits',
    title   => 'Number of Hits in Each Month in 2002',
    dclrs   => ['cyan'],
    logo => 'mydog.png',
) or warn $mygraph->error;```

But I don't think you can put an image in only the columns.

ContentLicense: CC BY-SA 2.5

Title: Background image in columns of graph

Body:
I have cgi-script that draws a graph. Here is the code:

#!/usr/bin/perl -w

use CGI ':standard';
use GD::Graph::bars;
use strict;

my @data = (["Jan", "Feb", "Mar", "Apr", "May", "Jun",
             "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
            [23, 5, 2, 20, 11, 33, 7, 31, 77, 18, 65, 52]);

my $mygraph = GD::Graph::bars->new(500, 300);
$mygraph->set(
    x_label => 'Month',
    y_label => 'Number of Hits',
    title   => 'Number of Hits in Each Month in 2002',
    dclrs   => ['cyan']
) or warn $mygraph->error;

my $myimage = $mygraph->plot(\@data) or die $mygraph->error;

print "Content-type: image/png\n\n";
print $myimage->png;

All the columns are cyan color. So...

Have you got any ideas how can I place image in columns instead of color?

I searched the web about it but nothing similar I couldn't find.
I would like to use only GD.pm without using additional modules such as ImageMagick.

Body:
I don't know. You can have a background image for the entire graph by specifying the logo option.

$mygraph->set(
    x_label => 'Month',
    y_label => 'Number of Hits',
    title   => 'Number of Hits in Each Month in 2002',
    dclrs   => ['cyan'],
    logo => 'mydog.png',
) or warn $mygraph->error;

But I don't think you can put an image in only the columns.


问:
A typical operation on a generic function
I was recently learning generics in Java and a question came in my mind that Python programmers can relate to. All I did was to create a generic Java function which should return a string and take two parameters, "p1 and p2" of different (or similar) generic types. But the tricky thing is I want to return the value of p1 if p1 is of type String, else a general String message... A simple Python implementation of this code will be:

```<code>def func1(a, b):
    if type(a) == str:
        return a
    else:
        return 'bye'

func1(2, 5)             # Output: 'bye'
func1("hi", 5)          # Output: 'hi'
</code>```

I tried the same on a Java function, but it seems to give an error which by my observations can only be rectified if it is forcefully (rather unwantedly, since the obj1 is already checked for being a type of string)  typecasted into String:

```<code>public static <T, T2> String func3(T obj1, T2 obj2) {
    if (obj1.getClass().getSimpleName().equals("String")){
        return obj1;       // <--error    // (String)obj1; <-- is working
    }
    else {
        return "bye";
    }
}
</code>```

So, what is being wrong here? Is it somewhat related to the "ducktyping" feature of Python, and not possible in Java? Or am I using the wrong functions for getting the desired class name?

答:
It is related to the fact that Python is dynamically typed.

Although you checked the type of obj1 here:

```<code>if (obj1.getClass().getSimpleName()=="String"){
</code>```

The compiler forgets about this when it sees the return statement. It will insist that obj1 is of type T but not String, so obj1 can't be returned.

The solution for this is, as you pointed out, cast obj1 to String. Casting is like saying to the compiler, "I am sure this is a string!"

P.S.: You can check if an object is a string by simply doing:

```<code>if (obj1 instanceof String)
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I was recently learning generics in Java and a question came in my mind that Python programmers can relate to. All I did was to create a generic Java function which should return a string and take two parameters, "p1 and p2" of different (or similar) generic types. But the tricky thing is I want to return the value of p1 if p1 is of type String, else a general String message... A simple Python implementation of this code will be:

def func1(a, b):
    if type(a) == str:
        return a
    else:
        return 'bye'

func1(2, 5)             # Output: 'bye'
func1("hi", 5)          # Output: 'hi'

I tried the same on a Java function, but it seems to give an error which by my observations can only be rectified if it is forcefully (rather unwantedly, since the obj1 is already checked for being a type of string)  typecasted into String:

public static <T, T2> String func3(T obj1, T2 obj2) {
    if (obj1.getClass().getSimpleName().equals("String")){
        return obj1;       // <--error    // (String)obj1; <-- is working
    }
    else {
        return "bye";
    }
}

So, what is being wrong here? Is it somewhat related to the "ducktyping" feature of Python, and not possible in Java? Or am I using the wrong functions for getting the desired class name?

Body:
It is related to the fact that Python is dynamically typed.

Although you checked the type of obj1 here:

if (obj1.getClass().getSimpleName()=="String"){

The compiler forgets about this when it sees the return statement. It will insist that obj1 is of type T but not String, so obj1 can't be returned.

The solution for this is, as you pointed out, cast obj1 to String. Casting is like saying to the compiler, "I am sure this is a string!"

P.S.: You can check if an object is a string by simply doing:

if (obj1 instanceof String)


问:
multiple variable data on Form Laravel 5.4
need your help on this one..
how to pass a multiple variable data on form using larvel...
i got some sample but there's an error

```<code>ErrorException in UrlGenerationException.php line 17:
Missing required parameters for [Route: editeammember.post] [URI: editeammember/{idteam}/{idmember}]. (View: E:\wamp64\www\gplspring2017\resources\views\admin\editteammember.blade.php)
</code>```

Here's my form code:

```<code><form class="form-horizontal" role="form" method="POST" action="{{ route('editeammember.post', $member->gpl_team_id.'/'.$member->team_member_id) }}"></form>
</code>```

here's my controller

```<code>public function editteammember(Request $request, $idteam, $idmember)
    {
        $teams = DB::table('gpl_team')->where('gpl_team_id', $idteam)->get();

        $count = count($teams);

        if(!$count)
        {
            return redirect('404');
        }
        else
        {
            $member_image = $request->input('member_image');
            $member_summoner = $request->input('member_summoner');
            $member_name = $request->input('member_name');
            $member_role = $request->input('member_role');
            $updated_at = date("Y-m-d H:i:s");

            $this->validate(request(), [
                'member_image' => 'required|max:255',
                'member_summoner' => 'required|max:255',
                'member_name' => 'required|max:255',
                'member_role' => 'in:Top Lane, Jungle, Mid Lane, AD Carry, Support, Substitute',
                ]
            );

            DB::table('team_member')->where('team_member_id', $idmember)->where('gpl_team_id', $idteam)->update([
                ['member_pic' => $member_image, 'member_summoner' => $member_summoner, 'member_name' => $member_name, 'member_role' => $member_role, 'updated_at' => $updated_at, ]
            ]);

            return redirect()->back()->with('message', 'Member is successfully Updated!');
        }
    }
</code>```

hope you can help me... thank you

答:
pass your params as an array :

```<code>{{ route('editeammember.post', [$member->gpl_team_id, $member->team_member_id]) }}
</code>```

for more reference : route()

ContentLicense: CC BY-SA 3.0

Body:
need your help on this one..
how to pass a multiple variable data on form using larvel...
i got some sample but there's an error

ErrorException in UrlGenerationException.php line 17:
Missing required parameters for [Route: editeammember.post] [URI: editeammember/{idteam}/{idmember}]. (View: E:\wamp64\www\gplspring2017\resources\views\admin\editteammember.blade.php)

Here's my form code:

<form class="form-horizontal" role="form" method="POST" action="{{ route('editeammember.post', $member->gpl_team_id.'/'.$member->team_member_id) }}"></form>

here's my controller

public function editteammember(Request $request, $idteam, $idmember)
    {
        $teams = DB::table('gpl_team')->where('gpl_team_id', $idteam)->get();

        $count = count($teams);

        if(!$count)
        {
            return redirect('404');
        }
        else
        {
            $member_image = $request->input('member_image');
            $member_summoner = $request->input('member_summoner');
            $member_name = $request->input('member_name');
            $member_role = $request->input('member_role');
            $updated_at = date("Y-m-d H:i:s");

            $this->validate(request(), [
                'member_image' => 'required|max:255',
                'member_summoner' => 'required|max:255',
                'member_name' => 'required|max:255',
                'member_role' => 'in:Top Lane, Jungle, Mid Lane, AD Carry, Support, Substitute',
                ]
            );

            DB::table('team_member')->where('team_member_id', $idmember)->where('gpl_team_id', $idteam)->update([
                ['member_pic' => $member_image, 'member_summoner' => $member_summoner, 'member_name' => $member_name, 'member_role' => $member_role, 'updated_at' => $updated_at, ]
            ]);

            return redirect()->back()->with('message', 'Member is successfully Updated!');
        }
    }

hope you can help me... thank you

Body:
pass your params as an array :

{{ route('editeammember.post', [$member->gpl_team_id, $member->team_member_id]) }}

for more reference : route()


问:
How to Initialize adapter in RecycleVIew?
Before this i am using ListView and it is working fine. But i want to set the ListView in Horizontal. so i came to know that RecycleView is more reliable then listview.

am trying to work with Recycle View and getting error like

```<code> No adapter attached; skipping layout
</code>```

It means that the problem is in my adapter class i don't know what the code is required in my adapter class i just tried this way.

main.java

```<code>public class DynamicButon extends Fragment {
    public DynamicButon(){};
    JSONObject jsonobject;
    JSONArray ownerObj;
     private RecyclerView mRecyclerView;
private RecyclerView.LayoutManager mLayoutManager;

    ListViewAdapterDynamic mAdapter;
    ArrayList<HashMap<String, String>> arraylist;
    String uid = "0";
    SessionManager session;
    private static String url_visitor = "";
    JSONParser jParser = new JSONParser();
    ArrayList<String> itemwod = new ArrayList<String>();

    View view;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.activity_dynamic_buton, container, false);
        getActivity().setTitle("Complete Order");
        // listview = (ListView) view.findViewById(R.id.lvvisit);

        session = new SessionManager(getActivity());
        HashMap<String, String> user = session.getUserDetails();
        uid = user.get(SessionManager.KEY_ID);
        new DownloadJSON().execute();
        return view;
    }

    private class DownloadJSON extends AsyncTask<Void, Void, Void> {

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
          //  avi.show();
        }

        @Override
        protected Void doInBackground(Void... args) {
            try {
                arraylist = new ArrayList<HashMap<String, String>>();
                List<NameValuePair> params = new ArrayList<NameValuePair>();
                params.add(new BasicNameValuePair("username", uid));
                JSONObject json = jParser.makeHttpRequest(url_visitor, "GET", params);

                int success1 = Integer.parseInt(json.getString("success4"));
                Log.d("success4", json.toString());

                if (success1 == 0) {
                    Snackbar.make(view, "Not Data Found", Snackbar.LENGTH_LONG).show();
                }
                if (success1 == 1) {
                    ownerObj = json.getJSONArray("cy");

                    for (int i = 0; i < ownerObj.length(); i++) {
                        jsonobject = ownerObj.getJSONObject(i);

                        item.add(jsonobject.getString("company"));
                    }
                }
            } catch (Exception e) {
            }
            return null;
        }

        @Override
        protected void onPostExecute(Void args) {

 mRecyclerView = (RecyclerView)getActivity().findViewById(R.id.mylist);
        mLayoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
        mRecyclerView.setLayoutManager(mLayoutManager);

        mAdapter = new ListViewAdapterDynamic(getActivity(), itemwod);
        mRecyclerView.setAdapter(mAdapter);
        }
    }
}
</code>```

ListViewAdapter

```<code>import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;

import java.util.ArrayList;
import java.util.HashMap;

/**
 * Created by sachin on 3/15/2017.
 */

public class ListViewAdapterDynamic extends BaseAdapter {
    Context cntx;

    View view;

    ArrayList<String> itemwod = new ArrayList<String>();

    LayoutInflater inflater;
    ArrayList<HashMap<String, String>> data;
    HashMap<String, String> resultp = new HashMap<String, String>();

    public ListViewAdapterDynamic(Context context,
                                        ArrayList<String> o_parties
    ) {
        // TODO Auto-generated constructor stub
        cntx = context;
        itemwod = o_parties;
    }

    @Override
    public int getCount() {
        return itemwod.size();
    }

    @Override
    public Object getItem(int position) {
        return itemwod.get(position);
    }

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

    @SuppressWarnings("deprecation")
    public View getView(final int position, View convertView, ViewGroup parent) {

        Button cancel;

        inflater = (LayoutInflater) cntx
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        LayoutInflater inflater = LayoutInflater.from(cntx);

        convertView = inflater.inflate(R.layout.raw_dynamic, parent,
                false);

         cancel=(Button)convertView.findViewById(R.id.btn) ;
        cancel.setText(itemwod.get(position));
        return convertView;
    }

}
</code>```

Like this way i try but not working in ListViewAdapterDynamic i tried to implement

```<code>  RecyclerView.Adapter<MyViewHolder>
</code>```

then getting errors that's why i just kept extends Baseadapter what i did i listview.

答:
```<code>LinearLayoutManager layoutManager= new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL, false);
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mRecyclerView.setLayoutManager(layoutManager);
</code>```

use recylerview.

Body:
Before this i am using ListView and it is working fine. But i want to set the ListView in Horizontal. so i came to know that RecycleView is more reliable then listview.

am trying to work with Recycle View and getting error like

 No adapter attached; skipping layout

It means that the problem is in my adapter class i don't know what the code is required in my adapter class i just tried this way.

main.java

public class DynamicButon extends Fragment {
    public DynamicButon(){};
    JSONObject jsonobject;
    JSONArray ownerObj;
     private RecyclerView mRecyclerView;
private RecyclerView.LayoutManager mLayoutManager;

    ListViewAdapterDynamic mAdapter;
    ArrayList<HashMap<String, String>> arraylist;
    String uid = "0";
    SessionManager session;
    private static String url_visitor = "";
    JSONParser jParser = new JSONParser();
    ArrayList<String> itemwod = new ArrayList<String>();

    View view;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.activity_dynamic_buton, container, false);
        getActivity().setTitle("Complete Order");
        // listview = (ListView) view.findViewById(R.id.lvvisit);

        session = new SessionManager(getActivity());
        HashMap<String, String> user = session.getUserDetails();
        uid = user.get(SessionManager.KEY_ID);
        new DownloadJSON().execute();
        return view;
    }

    private class DownloadJSON extends AsyncTask<Void, Void, Void> {

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
          //  avi.show();
        }

        @Override
        protected Void doInBackground(Void... args) {
            try {
                arraylist = new ArrayList<HashMap<String, String>>();
                List<NameValuePair> params = new ArrayList<NameValuePair>();
                params.add(new BasicNameValuePair("username", uid));
                JSONObject json = jParser.makeHttpRequest(url_visitor, "GET", params);

                int success1 = Integer.parseInt(json.getString("success4"));
                Log.d("success4", json.toString());

                if (success1 == 0) {
                    Snackbar.make(view, "Not Data Found", Snackbar.LENGTH_LONG).show();
                }
                if (success1 == 1) {
                    ownerObj = json.getJSONArray("cy");

                    for (int i = 0; i < ownerObj.length(); i++) {
                        jsonobject = ownerObj.getJSONObject(i);

                        item.add(jsonobject.getString("company"));
                    }
                }
            } catch (Exception e) {
            }
            return null;
        }

        @Override
        protected void onPostExecute(Void args) {

 mRecyclerView = (RecyclerView)getActivity().findViewById(R.id.mylist);
        mLayoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
        mRecyclerView.setLayoutManager(mLayoutManager);

        mAdapter = new ListViewAdapterDynamic(getActivity(), itemwod);
        mRecyclerView.setAdapter(mAdapter);
        }
    }
}

ListViewAdapter

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;

import java.util.ArrayList;
import java.util.HashMap;

/**
 * Created by sachin on 3/15/2017.
 */

public class ListViewAdapterDynamic extends BaseAdapter {
    Context cntx;

    View view;

    ArrayList<String> itemwod = new ArrayList<String>();

    LayoutInflater inflater;
    ArrayList<HashMap<String, String>> data;
    HashMap<String, String> resultp = new HashMap<String, String>();

    public ListViewAdapterDynamic(Context context,
                                        ArrayList<String> o_parties
    ) {
        // TODO Auto-generated constructor stub
        cntx = context;
        itemwod = o_parties;
    }

    @Override
    public int getCount() {
        return itemwod.size();
    }

    @Override
    public Object getItem(int position) {
        return itemwod.get(position);
    }

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

    @SuppressWarnings("deprecation")
    public View getView(final int position, View convertView, ViewGroup parent) {

        Button cancel;

        inflater = (LayoutInflater) cntx
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        LayoutInflater inflater = LayoutInflater.from(cntx);

        convertView = inflater.inflate(R.layout.raw_dynamic, parent,
                false);

         cancel=(Button)convertView.findViewById(R.id.btn) ;
        cancel.setText(itemwod.get(position));
        return convertView;
    }

}

Like this way i try but not working in ListViewAdapterDynamic i tried to implement

  RecyclerView.Adapter<MyViewHolder>

then getting errors that's why i just kept extends Baseadapter what i did i listview.

Body:
LinearLayoutManager layoutManager= new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL, false);
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mRecyclerView.setLayoutManager(layoutManager);

use recylerview.


问:
Blend diagonal linear gradients
I have created this pattern, consisting of blue and red lines. But I can't find a way to blend the red and the blue lines (to something like dark purple if I'm correct) where they cross each-other (see third case). Any ideas? Using transparency doesn't help as I only want it where they cross.

div{
  width:50px; height:100px;
  border: solid 2px black;
  float:left;
  margin:10px;
  font-size:30px;
  font-weight:bold;
}

.caro-pattern1 {
  background-color:#2ECC40;
  background-image: linear-gradient(-45deg, blue 5%, transparent 5%, transparent 45%, blue 45%, blue 55%, transparent 55%, transparent 95%, blue 95% );
  background-size:50px 50px;
}
.caro-pattern2 {
  background-color:#2ECC40;
  background-image:
    linear-gradient(45deg, red 5%, transparent 5%, transparent 45%, red 45%, red 55%, transparent 55%, transparent 95%, red 95% );
  background-size:50px 50px;
}
.caro-pattern3 {
  background-color:#2ECC40;
  background-image:
    linear-gradient(45deg, red 5%, transparent 5%, transparent 45%, red 45%, red 55%, transparent 55%, transparent 95%, red 95% ),
    linear-gradient(-45deg, blue 5%, transparent 5%, transparent 45%, blue 45%, blue 55%, transparent 55%, transparent 95%, blue 95% );
  background-size:50px 50px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="caro-pattern1">1</div>
<div class="caro-pattern2">2</div>
<div class="caro-pattern3">3</div>  </code>```

答:
You can experiment with the new background-blend-mode, which is currently in editor's draft for Compositing and blending Level 1.

References: background-blend-mode and mix-blend-mode.

Be advised though, that this is currently not supported by IE, Edge and Opera, with partial support in Safari. That leaves only Chrome and Firefox :(

Example Snippet:

div {
  width: 50px; height: 100px;
  border: solid 2px black;
  margin: 10px;
}

.caro-pattern3 {
  background-color: #2ECC40;
  background-image:
    linear-gradient(45deg, red 5%, transparent 5%, transparent 45%, red 45%, red 55%, transparent 55%, transparent 95%, red 95% ),
    linear-gradient(-45deg, blue 5%, transparent 5%, transparent 45%, blue 45%, blue 55%, transparent 55%, transparent 95%, blue 95% );
  background-size: 50px 50px;
 background-blend-mode: color, hard-light;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="caro-pattern3">3</div></code>```

Title: Blend diagonal linear gradients

Body:
I have created this pattern, consisting of blue and red lines. But I can't find a way to blend the red and the blue lines (to something like dark purple if I'm correct) where they cross each-other (see third case). Any ideas? Using transparency doesn't help as I only want it where they cross.

div{
  width:50px; height:100px;
  border: solid 2px black;
  float:left;
  margin:10px;
  font-size:30px;
  font-weight:bold;
}

.caro-pattern1 {
  background-color:#2ECC40;
  background-image: linear-gradient(-45deg, blue 5%, transparent 5%, transparent 45%, blue 45%, blue 55%, transparent 55%, transparent 95%, blue 95% );
  background-size:50px 50px;
}
.caro-pattern2 {
  background-color:#2ECC40;
  background-image:
    linear-gradient(45deg, red 5%, transparent 5%, transparent 45%, red 45%, red 55%, transparent 55%, transparent 95%, red 95% );
  background-size:50px 50px;
}
.caro-pattern3 {
  background-color:#2ECC40;
  background-image:
    linear-gradient(45deg, red 5%, transparent 5%, transparent 45%, red 45%, red 55%, transparent 55%, transparent 95%, red 95% ),
    linear-gradient(-45deg, blue 5%, transparent 5%, transparent 45%, blue 45%, blue 55%, transparent 55%, transparent 95%, blue 95% );
  background-size:50px 50px;
}

1

2

3

Body:
You can experiment with the new background-blend-mode, which is currently in editor's draft for Compositing and blending Level 1.

References: background-blend-mode and mix-blend-mode.

Be advised though, that this is currently not supported by IE, Edge and Opera, with partial support in Safari. That leaves only Chrome and Firefox :(

Example Snippet:

div {
  width: 50px; height: 100px;
  border: solid 2px black;
  margin: 10px;
}

.caro-pattern3 {
  background-color: #2ECC40;
  background-image:
    linear-gradient(45deg, red 5%, transparent 5%, transparent 45%, red 45%, red 55%, transparent 55%, transparent 95%, red 95% ),
    linear-gradient(-45deg, blue 5%, transparent 5%, transparent 45%, blue 45%, blue 55%, transparent 55%, transparent 95%, blue 95% );
  background-size: 50px 50px;
 background-blend-mode: color, hard-light;
}

<div class="caro-pattern3">3</div>


问:
Does Google Container Engine SDK/API exist?
I am planning to launch container cluster from an SDK/API. Presently, I am fine with any language, but I prefer NodeJS SDK. As far as I have seen, I could not find any Container engine SDK. Here is the NodeJS SDK for GCP which does not contain container engine. In fact it contains SDK only for very few GCP services.

I came across OAuth API for container engine but it involves human intervention to launch it. I am looking for service account based authentication for the SDK.

Are there container engine SDKs available ?

Update after discussion with Robert Lacok:

This is the code I tried to use for container APIs with API-key, it does not work. It expects Oauth 2 token, or some other credentials other than Service account. I tried API-key it didnt work. I dont know how to use Service account authentication with the API.

Here is my source code:

Here is the error:

I see a method for Application Default credentials. But I dont think so it will be useful for my use-case. I am trying to create container cluster from AWS Lambda. So, I cant use application default credentials. Is there any other options ?

答:
The API for Google Container Engine is very limited at the moment as all the features are in Alpha status and because they can change not many people are incorporating them into the SDKs they are developing.

These are the current available APIs: https://cloud.google.com/sdk/gcloud/reference/container/

And here is the Alpha APIs: https://cloud.google.com/sdk/gcloud/reference/alpha/container/


问:
perl script to convert the string EXP501.1-01.0 to EXP501_01
I want to convert the string

EXP501.1-01.0

to

EXP501_01

That means -01, -02, -03... are incremental and I want to append that same number which is in first string next to the _ of the second string (which will be parsed on the basis of the first string).

答:
```<code>    my $string = "EXP501.1-01.0";
    $short = substr($string, 0, -7);
    $new = substr($string,8,-2);
    my $str = $short . $new;
    $str =~ s/ - /_/g; # Replace all " - " with "_"
    $str =~ s/[^A-Za-z0-9]/_/g; # Replace all non-alphanumericals with "_"

    print $str . "\n";
</code>```


问:
Get the default value of a textarea using Jquery
How do i get the default value of a textarea using Jquery. I referred the following question
Default text on textarea jQuery?
but am getting undefined as the answer

HTML:

```<code><textarea id="comments">dsfdtert</textarea>
</code>```

Jquery:

```<code>$(document).ready(function(){
    alert($('#comments').data('defaultval'));
});
</code>```

see the fiddle : http://jsfiddle.net/Kritika/7cmEc/

答:
Expanding on Adeneo's answer as it didn't quite work out of the box i had this:

//saves the default value of the text area before we modify it.

```<code>var textAreaDefault = $('#mailMessage').data('default', $('#mailMessage').val());
</code>```

Then:

```<code>var defaults = $('#mailMessage').data('default');

textAreaDefault.val(defaults);
</code>```

I found having a value called default doesn't work as that's a reserved keyword.

Body:
How do i get the default value of a textarea using Jquery. I referred the following question
Default text on textarea jQuery?
but am getting undefined as the answer

HTML:

<textarea id="comments">dsfdtert</textarea>

Jquery:

$(document).ready(function(){
    alert($('#comments').data('defaultval'));
});

see the fiddle : http://jsfiddle.net/Kritika/7cmEc/

Body:
Expanding on Adeneo's answer as it didn't quite work out of the box i had this:

//saves the default value of the text area before we modify it.

var textAreaDefault = $('#mailMessage').data('default', $('#mailMessage').val());

Then:

var defaults = $('#mailMessage').data('default');

textAreaDefault.val(defaults);

I found having a value called default doesn't work as that's a reserved keyword.


问:
CASCADE Delete mysql
I'm creating a small 3-table database, essentially using it as a buffer for data, so it's using ENGINER = MEMORY. The database has the following structure:

I'm not that much into MySQL, so my question is: Is it possible to have a CASCADE DELETE, such that when I delete a MeassurementIteration, all MeassurementSet's and Meassurements that are coupled to the iteration will be deleted?

The code:

```<code>-- Last modification date: 2017-04-03 08:09:06.263

-- tables
-- Table: Meassurement
CREATE TABLE Meassurement (
    id int NOT NULL AUTO_INCREMENT,
    msWay varchar(75) NOT NULL,
    qosClass int NOT NULL,
    timeReceived timestamp NOT NULL,
    timeReceivedFarEnd timestamp NOT NULL,
    timeSent timestamp NOT NULL,
    timeSentFarEnd timestamp NULL,
    seq int NOT NULL,
    MeassurementSet_id int NOT NULL,
    CONSTRAINT Meassurement_pk PRIMARY KEY (id)
) ENGINE MEMORY COMMENT 'Contains data for a single meassurement';

-- Table: MeassurementIteration
CREATE TABLE MeassurementIteration (
    id int NOT NULL AUTO_INCREMENT,
    start timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    end timestamp NULL,
    active bool NOT NULL,
    CONSTRAINT MeassurementIteration_pk PRIMARY KEY (id)
);

-- Table: MeassurementSet
CREATE TABLE MeassurementSet (
    id int NOT NULL AUTO_INCREMENT,
    avgDelayRT double NULL,
    avgDelayTR double NULL,
    avgRTD double NULL,
    maxDelayRT double NULL,
    maxDelayTR double NULL,
    maxRTD double NULL,
    minRTD double NULL,
    minDelayRT double NULL,
    minDelayTR double NULL,
    qosClass int NOT NULL,
    stdDev double NULL,
    stdDevRT double NULL,
    stdDevTR double NULL,
    msWay varchar(75) NOT NULL,
    MeassurementIteration_id int NOT NULL,
    CONSTRAINT MeassurementSet_pk PRIMARY KEY (id)
) ENGINE MEMORY COMMENT 'Contains a set of meassurements specific to a qosclass and Meassurementway';

-- foreign keys
-- Reference: MeassurementSet_MeassurementIteration (table: MeassurementSet)
ALTER TABLE MeassurementSet
    ADD CONSTRAINT MeassurementSet_MeassurementIteration
    FOREIGN KEY MeassurementSet_MeassurementIteration (MeassurementIteration_id)
        REFERENCES MeassurementIteration (id) ON DELETE CASCADE;

-- Reference: Meassurement_MeassurementSet (table: Meassurement)
ALTER TABLE Meassurement
    ADD CONSTRAINT Meassurement_MeassurementSet
    FOREIGN KEY Meassurement_MeassurementSet (MeassurementSet_id)
        REFERENCES MeassurementSet (id) ON DELETE CASCADE;

-- End of file.
</code>```

Best regards.

答:
SELECT table_nameenter code here
FROM referential_constraints
WHERE constraint_schema = 'classicmodels'enter code here AND
      referenced_table_name = 'buildings' AND
      delete_rule = 'CASCADE'

Title: CASCADE Delete mysql

Body:
I'm creating a small 3-table database, essentially using it as a buffer for data, so it's using ENGINER = MEMORY. The database has the following structure:

I'm not that much into MySQL, so my question is: Is it possible to have a CASCADE DELETE, such that when I delete a MeassurementIteration, all MeassurementSet's and Meassurements that are coupled to the iteration will be deleted?

The code:

-- Last modification date: 2017-04-03 08:09:06.263

-- tables
-- Table: Meassurement
CREATE TABLE Meassurement (
    id int NOT NULL AUTO_INCREMENT,
    msWay varchar(75) NOT NULL,
    qosClass int NOT NULL,
    timeReceived timestamp NOT NULL,
    timeReceivedFarEnd timestamp NOT NULL,
    timeSent timestamp NOT NULL,
    timeSentFarEnd timestamp NULL,
    seq int NOT NULL,
    MeassurementSet_id int NOT NULL,
    CONSTRAINT Meassurement_pk PRIMARY KEY (id)
) ENGINE MEMORY COMMENT 'Contains data for a single meassurement';

-- Table: MeassurementIteration
CREATE TABLE MeassurementIteration (
    id int NOT NULL AUTO_INCREMENT,
    start timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    end timestamp NULL,
    active bool NOT NULL,
    CONSTRAINT MeassurementIteration_pk PRIMARY KEY (id)
);

-- Table: MeassurementSet
CREATE TABLE MeassurementSet (
    id int NOT NULL AUTO_INCREMENT,
    avgDelayRT double NULL,
    avgDelayTR double NULL,
    avgRTD double NULL,
    maxDelayRT double NULL,
    maxDelayTR double NULL,
    maxRTD double NULL,
    minRTD double NULL,
    minDelayRT double NULL,
    minDelayTR double NULL,
    qosClass int NOT NULL,
    stdDev double NULL,
    stdDevRT double NULL,
    stdDevTR double NULL,
    msWay varchar(75) NOT NULL,
    MeassurementIteration_id int NOT NULL,
    CONSTRAINT MeassurementSet_pk PRIMARY KEY (id)
) ENGINE MEMORY COMMENT 'Contains a set of meassurements specific to a qosclass and Meassurementway';

-- foreign keys
-- Reference: MeassurementSet_MeassurementIteration (table: MeassurementSet)
ALTER TABLE MeassurementSet
    ADD CONSTRAINT MeassurementSet_MeassurementIteration
    FOREIGN KEY MeassurementSet_MeassurementIteration (MeassurementIteration_id)
        REFERENCES MeassurementIteration (id) ON DELETE CASCADE;

-- Reference: Meassurement_MeassurementSet (table: Meassurement)
ALTER TABLE Meassurement
    ADD CONSTRAINT Meassurement_MeassurementSet
    FOREIGN KEY Meassurement_MeassurementSet (MeassurementSet_id)
        REFERENCES MeassurementSet (id) ON DELETE CASCADE;

-- End of file.

Best regards.


问:
MobileFirst - call adapter - ERR_CONNECTION_RESET
I have a problem with call MobileFirst adapter from my app.
If I use swagger docs or postman to test adapter method, it works.
Unfortunately from app preview, I receive message:

http://localhost:6015/mfp/api/adapters/ServiceAdapter/login?params=%5Btest%2C%20test123%5D net::ERR_CONNECTION_RESET

I don't understand why request to the adapter from my app is forwarded to the port 6015. During the tests (swagger and postman) I used 9080, maybe it is the problem, but I don't know how to change app target port from 6015 to 9080.

adapter xml:

```<code><mfp:adapter name="ServiceAdapter"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:mfp="http://www.ibm.com/mfp/integration"
         xmlns:http="http://www.ibm.com/mfp/integration/http">

<displayName>ServiceAdapter</displayName>
<description>ServiceAdapter</description>
<connectivity>
    <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
        <protocol>http</protocol>
        <domain>localhost</domain>
        <port>53873</port>
        <connectionTimeoutInMilliseconds>30000</connectionTimeoutInMilliseconds>
        <socketTimeoutInMilliseconds>30000</socketTimeoutInMilliseconds>
        <maxConcurrentConnectionsPerNode>50</maxConcurrentConnectionsPerNode>
    </connectionPolicy>
</connectivity>

<procedure name="login" secured="false" />
</code>```

implementation:

```<code>function login(login, pass) {
    path = 'token';
    var input = {
        method : 'post',
        returnedContentType : 'json',
        path : path,
        headers : {
            'Content-Type' : 'application/x-www-form-urlencoded'
        },
        body : {
            contentType : 'application/x-www-form-urlencoded',
            content : 'username=' + login + '&password=' + pass + '&grant_type=password'
        }
    };
    return MFP.Server.invokeHttp(input);
}
</code>```

and adapter call:

```<code>function Login() {
    var resourceRequest = new WLResourceRequest(
            "/adapters/ServiceAdapter/login",
            WLResourceRequest.GET
    );

    resourceRequest.setQueryParameter("params", "[" + $("#log").val() + ", " + $("#pass").val() + "]");
    resourceRequest.send().then(LoginSuccess, LoginFailure);
}
</code>```

edited 6.04.2017:

additionally, i've noticed, that at the moment of adapter calling, i get this error in console from previewCordova.js file. it looks like variable req.url is undefined:

```<code>C:\...\npm\node_modules\mfpdev-cli\node_modules\mdo-app-preview\lib\previewCordova.js:579
    if(!req.url.startsWith('/')) {
                ^
TypeError: undefined is not a function
    at Server.<anonymous> (C:\..\npm\node_modules\mfpdev-cli\node_modules\mdo-app-preview\lib\previewCordova.js:579:17)
    at Server.emit (events.js:110:17)
    at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:491:12)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:111:23)
    at Socket.socketOnData (_http_server.js:343:22)
    at Socket.emit (events.js:107:17)
    at readableAddChunk (_stream_readable.js:163:16)
    at Socket.Readable.push (_stream_readable.js:126:10)
    at TCP.onread (net.js:538:20)
</code>```

答:
Mobilefirst App Preview connects to MFP server via proxy which runs on port 6015 and the behavior which you facing is normal, its nothing to do with the port.

ERR_CONNECTION_RESET Error is caused due to browser & not from Mobilefirst Server.

Try making request with different browser and also try by clearing browsing data/cache.

Body:
I have a problem with call MobileFirst adapter from my app.
If I use swagger docs or postman to test adapter method, it works.
Unfortunately from app preview, I receive message:

http://localhost:6015/mfp/api/adapters/ServiceAdapter/login?params=%5Btest%2C%20test123%5D net::ERR_CONNECTION_RESET

I don't understand why request to the adapter from my app is forwarded to the port 6015. During the tests (swagger and postman) I used 9080, maybe it is the problem, but I don't know how to change app target port from 6015 to 9080.

adapter xml:

<mfp:adapter name="ServiceAdapter"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:mfp="http://www.ibm.com/mfp/integration"
         xmlns:http="http://www.ibm.com/mfp/integration/http">

<displayName>ServiceAdapter</displayName>
<description>ServiceAdapter</description>
<connectivity>
    <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
        <protocol>http</protocol>
        <domain>localhost</domain>
        <port>53873</port>
        <connectionTimeoutInMilliseconds>30000</connectionTimeoutInMilliseconds>
        <socketTimeoutInMilliseconds>30000</socketTimeoutInMilliseconds>
        <maxConcurrentConnectionsPerNode>50</maxConcurrentConnectionsPerNode>
    </connectionPolicy>
</connectivity>

<procedure name="login" secured="false" />

implementation:

function login(login, pass) {
    path = 'token';
    var input = {
        method : 'post',
        returnedContentType : 'json',
        path : path,
        headers : {
            'Content-Type' : 'application/x-www-form-urlencoded'
        },
        body : {
            contentType : 'application/x-www-form-urlencoded',
            content : 'username=' + login + '&password=' + pass + '&grant_type=password'
        }
    };
    return MFP.Server.invokeHttp(input);
}

and adapter call:

function Login() {
    var resourceRequest = new WLResourceRequest(
            "/adapters/ServiceAdapter/login",
            WLResourceRequest.GET
    );

    resourceRequest.setQueryParameter("params", "[" + $("#log").val() + ", " + $("#pass").val() + "]");
    resourceRequest.send().then(LoginSuccess, LoginFailure);
}

edited 6.04.2017:

additionally, i've noticed, that at the moment of adapter calling, i get this error in console from previewCordova.js file. it looks like variable req.url is undefined:

C:\...\npm\node_modules\mfpdev-cli\node_modules\mdo-app-preview\lib\previewCordova.js:579
    if(!req.url.startsWith('/')) {
                ^
TypeError: undefined is not a function
    at Server.<anonymous> (C:\..\npm\node_modules\mfpdev-cli\node_modules\mdo-app-preview\lib\previewCordova.js:579:17)
    at Server.emit (events.js:110:17)
    at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:491:12)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:111:23)
    at Socket.socketOnData (_http_server.js:343:22)
    at Socket.emit (events.js:107:17)
    at readableAddChunk (_stream_readable.js:163:16)
    at Socket.Readable.push (_stream_readable.js:126:10)
    at TCP.onread (net.js:538:20)


问:
Why does accessing globals work via import module, but not from module import var?
I've been reading and learning a ton about python, but all the import variations having different results is a tad confusing.

I was having an issue where a global variable I had imported was always the default value, even though I called a method in that module that manipulates it. I had imported it like so:

```<code>from fona import connect, disconnect, CON
</code>```

Where the first two are functions and the last the var. The first two either open or close the connection, to which I have access via the var CON. When I did it this way, CON would stay None, even though connect is initializing it successfully (I have a lot of verbose output to verify that). I messed around more and more and couldn't figure it out. Wrote a post very different to this one before I had one more idea.

```<code>import fona
</code>```

I then access everything via fona.connect/disco/CON. Then it works. I am struggling to fathom why and couldn't find any resources. What makes these imports different? I quite like from x import y as z, but it seems I cannot use that in this case.

答:
```<code>from fona import CON
</code>```

is pretty much the same* as:

```<code>import fona
CON = fona.CON
</code>```

Now, if fona changes internally so that fona.CON is replaced with a new value, this has no effect on your own variable. Just like if you say:

```<code>y = 1
x = y
y = 2
</code>```

x is still 1 even though y is now 2.

*except the latter leaves the name fona hanging around, the former does not.

Body:
I've been reading and learning a ton about python, but all the import variations having different results is a tad confusing.

I was having an issue where a global variable I had imported was always the default value, even though I called a method in that module that manipulates it. I had imported it like so:

from fona import connect, disconnect, CON

Where the first two are functions and the last the var. The first two either open or close the connection, to which I have access via the var CON. When I did it this way, CON would stay None, even though connect is initializing it successfully (I have a lot of verbose output to verify that). I messed around more and more and couldn't figure it out. Wrote a post very different to this one before I had one more idea.

import fona

I then access everything via fona.connect/disco/CON. Then it works. I am struggling to fathom why and couldn't find any resources. What makes these imports different? I quite like from x import y as z, but it seems I cannot use that in this case.

Body:
from fona import CON

is pretty much the same* as:

import fona
CON = fona.CON

Now, if fona changes internally so that fona.CON is replaced with a new value, this has no effect on your own variable. Just like if you say:

y = 1
x = y
y = 2

x is still 1 even though y is now 2.

*except the latter leaves the name fona hanging around, the former does not.


问:
UltraGrid VisiblePosition not change when column moved
I have a c# project and within this project I have a dialog with an ultragrid. The grid has 3 groups and each group have more than 4 columns. Columns of the Ultragrid

I can move the columns and change the order of the columns. Everything works fine. At the end i want to save the definition of the columns, if the column is hidden and the position of the column.

I iterate over the list of columns and save the column.Hidden property and the column.Header.VisiblePosition property. The problem is that the visiblePosition value doesn't match to the position in the grid, which you see in the UI.

I moved some columns to the left and right, but the visiblePosition is the same as the beginning. The UI shows the correct order of each column and the column position changed but the value of the property didn't change.

Maybe the problem exist because i use columnGroups.

Thank you

答:
UltraWinGrid has a two methods to solve this kind of problems.

They are the SaveAsXml and LoadFromXml from the DisplayLayout class.

You can use them to save and restore the layout of your grid.

For example, in the Dispose event of your form you can add a call to

```<code>public void SaveLayout(UltraGrid grd, string layoutFile)
{
    if (grd.DataSource != null)
        grd.DisplayLayout.SaveAsXml(layoutFile, PropertyCategories.All);
}
</code>```

While in the InitializeLayout event of your grid you could restore the layout with

```<code>public void LoadLayout(UltraGrid grd, string layoutFile)
{
    if (File.Exists(layoutFile))
        grd.DisplayLayout.LoadFromXml(layoutFile, PropertyCategories.All);
}
</code>```

Depending on your specific needs you can fine tune the PropertyCategories enum to choose only the property group you want to save/restore.

Body:
UltraWinGrid has a two methods to solve this kind of problems.

They are the SaveAsXml and LoadFromXml from the DisplayLayout class.

You can use them to save and restore the layout of your grid.

For example, in the Dispose event of your form you can add a call to

public void SaveLayout(UltraGrid grd, string layoutFile)
{
    if (grd.DataSource != null)
        grd.DisplayLayout.SaveAsXml(layoutFile, PropertyCategories.All);
}

While in the InitializeLayout event of your grid you could restore the layout with

public void LoadLayout(UltraGrid grd, string layoutFile)
{
    if (File.Exists(layoutFile))
        grd.DisplayLayout.LoadFromXml(layoutFile, PropertyCategories.All);
}

Depending on your specific needs you can fine tune the PropertyCategories enum to choose only the property group you want to save/restore.


问:
Checkbox Header and Text in One Label
I have been trying to get a suitable styling for the following (including vertical alignment):

input {
    vertical-align:bottom;
    top:-5px;
}
label {
    display:inline;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><label><input type="checkbox"><h6>Header Text</h6> and Label text in one line</label>
<label><input type="checkbox"><h6>Header Text</h6> and Label text in one line</label>
<label><input type="checkbox"><h6>Header Text</h6> and Label text in one line</label></code>```

The issue is, after I added the
 header tag, it just wouldn't go into one line anymore. However I really do need that
 in there. I initially thought the label width wasn't wide enough, and that caused it to drop down below, but even after adding a generous width to the label css, nothing changed.

Is there anything more I can do here?

答:
Header element take display:block by default to that you need to add display:inline-block for h6

input {
  vertical-align:middle;
}
label {
  display:block;
}
label h6{
  display: inline-block;
  vertical-align: middle;
  margin: 0;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><label><input type="checkbox"><h6>Header Text</h6> and Label text in one line</label>
<label><input type="checkbox"><h6>Header Text</h6> and Label text in one line</label>
<label><input type="checkbox"><h6>Header Text</h6> and Label text in one line</label></code>```

Title: Checkbox Header and Text in One Label

Body:
I have been trying to get a suitable styling for the following (including vertical alignment):

input {
    vertical-align:bottom;
    top:-5px;
}
label {
    display:inline;
}

<input type="checkbox">
Header Text
 and Label text in one line
<input type="checkbox">
Header Text
 and Label text in one line
<input type="checkbox">
Header Text
 and Label text in one line

The issue is, after I added the
 header tag, it just wouldn't go into one line anymore. However I really do need that
 in there. I initially thought the label width wasn't wide enough, and that caused it to drop down below, but even after adding a generous width to the label css, nothing changed.

Is there anything more I can do here?

Body:
Header element take display:block by default to that you need to add display:inline-block for h6

input {
  vertical-align:middle;
}
label {
  display:block;
}
label h6{
  display: inline-block;
  vertical-align: middle;
  margin: 0;
}

<label><input type="checkbox"><h6>Header Text</h6> and Label text in one line</label>
<label><input type="checkbox"><h6>Header Text</h6> and Label text in one line</label>
<label><input type="checkbox"><h6>Header Text</h6> and Label text in one line</label>


问:
STRESS array is empty in python scripting Abaqus
I wanted to extract stress on top surface of my model on each node but it can't be done normally. when I use this script:

```<code>odb = visualization.openOdb('My.odb')
frame=odb.steps['AStep'].frames[-1]

dispNode = odb.rootAssembly.nodeSets['UPPER']

STRESS= frame.fieldOutputs['S'].getSubset(region=dispNode).values
COORD= frame.fieldOutputs['COORD'].getSubset(region=dispNode).values

print(STRESS)
print(COORD[1].data)
</code>```

STRESS returns an empty array.

How can I edit my script to have stress and its corresponding coordinates??

答:
Your Code can't work, if you only calculated your stress values on the integration points. There are simply no values at the nodes, so if you request values at nodes you will get an empty array.

This is how it should work:

Extrapolate your integration point results to the nodes

Average your ElementNodal values. This is how that works: https://stackoverflow.com/a/43175485/4045774

Extract your node coordinates (deformed or undeformed)

get the node labels from your point set

With the node labels from your point set find the corresponding unique nodal values https://docs.scipy.org/doc/numpy/reference/generated/numpy.in1d.html

If you need a small example code, feel free to ask.

Body:
I wanted to extract stress on top surface of my model on each node but it can't be done normally. when I use this script:

odb = visualization.openOdb('My.odb')
frame=odb.steps['AStep'].frames[-1]

dispNode = odb.rootAssembly.nodeSets['UPPER']

STRESS= frame.fieldOutputs['S'].getSubset(region=dispNode).values
COORD= frame.fieldOutputs['COORD'].getSubset(region=dispNode).values

print(STRESS)
print(COORD[1].data)

STRESS returns an empty array.

How can I edit my script to have stress and its corresponding coordinates??


问:
Why demo Jquery plugin isn't working?
I downloaded the autocomplete plugin, just a complete plugin demo. The only thing that i need to do is upload the SQL file to my database and update the database login details:

```<code>/* Database setup information */
$dbhost = 'localhost:3307';  // Database Host
$dbuser = 'root';       // Database Username
$dbpass = '';           // Database Password
$dbname = 'itemsdb';      // Database Name
</code>```

When i take a look in the console then i getting some XML errors, every time i type something in the search field.

http://imgur.com/Z9QSeC7
This is the autocomplete plugin: https://www.freshdesignweb.com/downloads/jquery-autocomplete-p1.zip

答: You are trying to run this from your own folder, but not using a local webserver. The issue is explained in here - "Cross origin requests are only supported for HTTP." error when loading a local file</p>

Title: Why demo Jquery plugin isn't working?

Body:
I downloaded the autocomplete plugin, just a complete plugin demo. The only thing that i need to do is upload the SQL file to my database and update the database login details:

/* Database setup information */
$dbhost = 'localhost:3307';  // Database Host
$dbuser = 'root';       // Database Username
$dbpass = '';           // Database Password
$dbname = 'itemsdb';      // Database Name

When i take a look in the console then i getting some XML errors, every time i type something in the search field.

http://imgur.com/Z9QSeC7
This is the autocomplete plugin: https://www.freshdesignweb.com/downloads/jquery-autocomplete-p1.zip


答:
Use Recycle View with horizonatal orientation
follow this link https://developer.android.com/training/material/lists-cards.html

Title: How to Initialize adapter in RecycleVIew?


答:
try,

```<code>label{
  display: block;
}
input, h6{
  display: inline-block
  vertical-align: middle;
}
</code>```

remove top from input.

Title: Checkbox Header and Text in One Label

Body:
try,

label{
  display: block;
}
input, h6{
  display: inline-block
  vertical-align: middle;
}

remove top from input.


问:
VS2017 will not connect to TFS2012
When attempting to set up a connection to TFS:

It finds the correct server; however, the connect button is grayed out:

What am I doing wrong? Is VS2017 not compatible with TFS2012?

I am able to connect to it with VS2013 without any issues.

答:
If you select server-level, indeed the connect button is grayed out. You need to select collection-level and then should be able to connect.

Your screenshot looks like lacking of the collection info. This error is similar to Cannot connect to VSTS and TFS from VS 2017 RC

Thank you for your feedback! This issue has been fixed and it's
  available in VS2017 RC3 (26127). Thank you for helping us build a
  better Visual Studio!

Added a solution by Visual Studio Team · 02/01 19:56

You should make sure your vs version is later with VS2017RC3. And make sure you have enough permission to enter your collection.

Title: VS2017 will not connect to TFS2012


答:
Use RecyclerView instead of ListView. I bet you won't regret. Set LayoutManager to HORIZONTAL. Do as follow:

First ADD RecyclerView in xml:

```<code>  <android.support.v7.widget.RecyclerView
       android:id="@+id/recycler_view"
       android:layout_width="match_parent"
       android:layout_height="wrap_content" />
</code>```

In fragment

```<code>private RecyclerView mRecyclerView;
private RecyclerView.LayoutManager mLayoutManager;
</code>```

In onPostExecute():

```<code>mRecyclerView = (RecyclerView)getActivity().findViewById(R.id.recycler_view);
mLayoutManager = new LinearLayoutManager(
                this,
                LinearLayoutManager.HORIZONTAL,
                false
        );
mRecyclerView.setLayoutManager(mLayoutManager);
</code>```

Here is a simple tutorial you can follow for Horizontal RecyclerView.

Body:
Use RecyclerView instead of ListView. I bet you won't regret. Set LayoutManager to HORIZONTAL. Do as follow:

First ADD RecyclerView in xml:

  <android.support.v7.widget.RecyclerView
       android:id="@+id/recycler_view"
       android:layout_width="match_parent"
       android:layout_height="wrap_content" />

In fragment

private RecyclerView mRecyclerView;
private RecyclerView.LayoutManager mLayoutManager;

In onPostExecute():

mRecyclerView = (RecyclerView)getActivity().findViewById(R.id.recycler_view);
mLayoutManager = new LinearLayoutManager(
                this,
                LinearLayoutManager.HORIZONTAL,
                false
        );
mRecyclerView.setLayoutManager(mLayoutManager);

Here is a simple tutorial you can follow for Horizontal RecyclerView.


答:
Usually in Java you can check the type of an object using instanceof:

```<code> someObject instanceof Type
</code>```

is true if the object is a Type or a subclass of Type.

Otherwise, you can do something like this:

```<code> someObject.getClass().equals(Type.class)
</code>```

is true only if the object is a Type

In your case you can use both:

```<code>obj1 instanceof String
</code>```

or

```<code>obj1.getClass().equals(String.class)
</code>```

But I suggest the first solution as in Java is the most used.

In your case I would write a method like this:

```<code>public static String func3(T obj1, T2 obj2) {
    if(obj1 instanceof String) {
        return (String)obj1;
    }
    else {
        return "obj1 not a String";
    }
}
</code>```

Title: A typical operation on a generic function

Body:
I was recently learning generics in Java and a question came in my mind that Python programmers can relate to. All I did was to create a generic Java function which should return a string and take two parameters, "p1 and p2" of different (or similar) generic types. But the tricky thing is I want to return the value of p1 if p1 is of type String, else a general String message... A simple Python implementation of this code will be:

def func1(a, b):
    if type(a) == str:
        return a
    else:
        return 'bye'

func1(2, 5)             # Output: 'bye'
func1("hi", 5)          # Output: 'hi'

I tried the same on a Java function, but it seems to give an error which by my observations can only be rectified if it is forcefully (rather unwantedly, since the obj1 is already checked for being a type of string)  typecasted into String:

public static <T, T2> String func3(T obj1, T2 obj2) {
    if (obj1.getClass().getSimpleName().equals("String")){
        return obj1;       // <--error    // (String)obj1; <-- is working
    }
    else {
        return "bye";
    }
}

So, what is being wrong here? Is it somewhat related to the "ducktyping" feature of Python, and not possible in Java? Or am I using the wrong functions for getting the desired class name?

Body:
Usually in Java you can check the type of an object using instanceof:

 someObject instanceof Type

is true if the object is a Type or a subclass of Type.

Otherwise, you can do something like this:

 someObject.getClass().equals(Type.class)

is true only if the object is a Type

In your case you can use both:

obj1 instanceof String

or

obj1.getClass().equals(String.class)

But I suggest the first solution as in Java is the most used.

In your case I would write a method like this:

public static String func3(T obj1, T2 obj2) {
    if(obj1 instanceof String) {
        return (String)obj1;
    }
    else {
        return "obj1 not a String";
    }
}


问:
To Edit Confluence Page from Linux Machine
Do we have any free tools to edit the Confluence page from linux machine ? Appreciate the response.
Thanks.</p>

答:
What do you mean exactly by editing from Linux Machine? Are you looking to edit pages via terminal? If so - you can use Confluence REST API and curl to edit your pages:

```<code>curl -u admin:admin -X PUT -H 'Content-Type: application/json' -d'{"id":"3604482","type":"page","title":"new page","space":{"key":"TST"},"body":{"storage":{"value":"<p>This is the updated text for the new page</p>","representation":"storage"}},"version":{"number":2}}' http://URL:PORT/confluence/rest/api/content/3604482 | python -mjson.tool
</code>```

Above curl will edit the pages that already exist in Confluence. You can check REST API Examples here

Body:
What do you mean exactly by editing from Linux Machine? Are you looking to edit pages via terminal? If so - you can use Confluence REST API and curl to edit your pages:

curl -u admin:admin -X PUT -H 'Content-Type: application/json' -d'{"id":"3604482","type":"page","title":"new page","space":{"key":"TST"},"body":{"storage":{"value":"<p>This is the updated text for the new page</p>","representation":"storage"}},"version":{"number":2}}' http://URL:PORT/confluence/rest/api/content/3604482 | python -mjson.tool

Above curl will edit the pages that already exist in Confluence. You can check REST API Examples here


问:
Java dynamic binding and method overriding
Yesterday I had a two-hour technical phone interview (which I passed, woohoo!), but I completely muffed up the following question regarding dynamic binding in Java.  And it's doubly puzzling because I used to teach this concept to undergraduates when I was a TA a few years ago, so the prospect that I gave them misinformation is a little disturbing...

Here's the problem I was given:

```<code>/* What is the output of the following program? */

public class Test {

  public boolean equals( Test other ) {
    System.out.println( "Inside of Test.equals" );
    return false;
  }

  public static void main( String [] args ) {
    Object t1 = new Test();
    Object t2 = new Test();
    Test t3 = new Test();
    Object o1 = new Object();

    int count = 0;
    System.out.println( count++ );// prints 0
    t1.equals( t2 ) ;
    System.out.println( count++ );// prints 1
    t1.equals( t3 );
    System.out.println( count++ );// prints 2
    t3.equals( o1 );
    System.out.println( count++ );// prints 3
    t3.equals(t3);
    System.out.println( count++ );// prints 4
    t3.equals(t2);
  }
}
</code>```

I asserted that the output should have been two separate print statements from within the overridden equals() method: at t1.equals(t3) and t3.equals(t3).  The latter case is obvious enough, and with the former case, even though t1 has a reference of type Object, it is instantiated as type Test, so dynamic binding should call the overridden form of the method.

Apparently not.  My interviewer encouraged me to run the program myself, and lo and behold, there was only a single output from the overridden method: at the line t3.equals(t3).

My question then is, why?  As I mentioned already, even though t1 is a reference of type Object (so static binding would invoke Object's equals() method), dynamic binding should take care of invoking the most specific version of the method based on the instantiated type of the reference.  What am I missing?

答:
I will try to explain this through two examples which are the extended versions of some of the examples that I came across online.

```<code>public class Test {

    public boolean equals(Test other) {
        System.out.println("Inside of Test.equals");
        return false;
    }

    @Override
    public boolean equals(Object other) {
        System.out.println("Inside of Test.equals ot type Object");
        return false;
    }

    public static void main(String[] args) {
        Object t1 = new Test();
        Object t2 = new Test();
        Test t3 = new Test();
        Object o1 = new Object();

        int count = 0;
        System.out.println(count++); // prints 0
        o1.equals(t2);

        System.out.println("\n" + count++); // prints 1
        o1.equals(t3);

        System.out.println("\n" + count++);// prints 2
        t1.equals(t2);

        System.out.println("\n" + count++);// prints 3
        t1.equals(t3);

        System.out.println("\n" + count++);// prints 4
        t3.equals(o1);

        System.out.println("\n" + count++);// prints 5
        t3.equals(t3);

        System.out.println("\n" + count++);// prints 6
        t3.equals(t2);
    }
}
</code>```

Here, for lines with count values 0, 1, 2, and 3; we have reference of Object for o1 and t1 on the equals() method. Thus, at compile time, the equals() method from the Object.class file will be bounded.

However, even though reference of t1 is Object, it has intialization of Test class.

Object t1 = new Test();.

Therefore, at run-time it calls the public boolean equals(Object other) which is an

overridden method

.

Now, for count values as 4 and 6, it is again straightforward that t3 which has reference and initialization of Test is calling equals() method with parameter as Object references and is an

overloaded method

OK!

Again, to better understand what method the compiler will call, just
  click on the method and Eclipse will highlight the methods of similar
  types which it thinks will call at the compile time. If it doesn't get
  called at compile time then those methods are an example of method
  overridding.

OwnerDisplayName: Magsol

Body:
Yesterday I had a two-hour technical phone interview (which I passed, woohoo!), but I completely muffed up the following question regarding dynamic binding in Java.  And it's doubly puzzling because I used to teach this concept to undergraduates when I was a TA a few years ago, so the prospect that I gave them misinformation is a little disturbing...

Here's the problem I was given:

/* What is the output of the following program? */

public class Test {

  public boolean equals( Test other ) {
    System.out.println( "Inside of Test.equals" );
    return false;
  }

  public static void main( String [] args ) {
    Object t1 = new Test();
    Object t2 = new Test();
    Test t3 = new Test();
    Object o1 = new Object();

    int count = 0;
    System.out.println( count++ );// prints 0
    t1.equals( t2 ) ;
    System.out.println( count++ );// prints 1
    t1.equals( t3 );
    System.out.println( count++ );// prints 2
    t3.equals( o1 );
    System.out.println( count++ );// prints 3
    t3.equals(t3);
    System.out.println( count++ );// prints 4
    t3.equals(t2);
  }
}

I asserted that the output should have been two separate print statements from within the overridden equals() method: at t1.equals(t3) and t3.equals(t3).  The latter case is obvious enough, and with the former case, even though t1 has a reference of type Object, it is instantiated as type Test, so dynamic binding should call the overridden form of the method.

Apparently not.  My interviewer encouraged me to run the program myself, and lo and behold, there was only a single output from the overridden method: at the line t3.equals(t3).

My question then is, why?  As I mentioned already, even though t1 is a reference of type Object (so static binding would invoke Object's equals() method), dynamic binding should take care of invoking the most specific version of the method based on the instantiated type of the reference.  What am I missing?

Body:
I will try to explain this through two examples which are the extended versions of some of the examples that I came across online.

public class Test {

    public boolean equals(Test other) {
        System.out.println("Inside of Test.equals");
        return false;
    }

    @Override
    public boolean equals(Object other) {
        System.out.println("Inside of Test.equals ot type Object");
        return false;
    }

    public static void main(String[] args) {
        Object t1 = new Test();
        Object t2 = new Test();
        Test t3 = new Test();
        Object o1 = new Object();

        int count = 0;
        System.out.println(count++); // prints 0
        o1.equals(t2);

        System.out.println("\n" + count++); // prints 1
        o1.equals(t3);

        System.out.println("\n" + count++);// prints 2
        t1.equals(t2);

        System.out.println("\n" + count++);// prints 3
        t1.equals(t3);

        System.out.println("\n" + count++);// prints 4
        t3.equals(o1);

        System.out.println("\n" + count++);// prints 5
        t3.equals(t3);

        System.out.println("\n" + count++);// prints 6
        t3.equals(t2);
    }
}

Here, for lines with count values 0, 1, 2, and 3; we have reference of Object for o1 and t1 on the equals() method. Thus, at compile time, the equals() method from the Object.class file will be bounded.

However, even though reference of t1 is Object, it has intialization of Test class.

Object t1 = new Test();.

Therefore, at run-time it calls the public boolean equals(Object other) which is an

overridden method

.

Now, for count values as 4 and 6, it is again straightforward that t3 which has reference and initialization of Test is calling equals() method with parameter as Object references and is an

overloaded method

OK!

Again, to better understand what method the compiler will call, just
  click on the method and Eclipse will highlight the methods of similar
  types which it thinks will call at the compile time. If it doesn't get
  called at compile time then those methods are an example of method
  overridding.


问:
Result of linux 'ls -lisa' command
What is the meaning of the second column in ls -lisa command ?

```<code>ls -lisa
total 12
280187 0 -rw-rw-r--  2 embedded embedded    0 Apr  3 02:05 a.txt
</code>```

The total command means the number of allocated 512-Byte blocks.

The first column shows the I-Node number.(280187)

The 3rd column shows the permissions.(-rw-rw-r--)

The 4rd column shows the number of hard-links for the inode.(2)

The 5th column shows user and group.(embedded embedded)

The 6th column shows the size of the file.(0)

The 7th column shows the date of the last change(Apr  3 02:05)

The last column shows the name of the file(a.txt)

But i don't know for what the second column stands for?

答:
The second column is the result of the -s (--size) option, it represents the allocated size of the file, always a multiple of the allocation unit.
http://linuxcommand.org/lc3_man_pages/ls1.html</p>

Title: Result of linux 'ls -lisa' command

Body:
What is the meaning of the second column in ls -lisa command ?

ls -lisa
total 12
280187 0 -rw-rw-r--  2 embedded embedded    0 Apr  3 02:05 a.txt

The total command means the number of allocated 512-Byte blocks.

The first column shows the I-Node number.(280187)

The 3rd column shows the permissions.(-rw-rw-r--)

The 4rd column shows the number of hard-links for the inode.(2)

The 5th column shows user and group.(embedded embedded)

The 6th column shows the size of the file.(0)

The 7th column shows the date of the last change(Apr  3 02:05)

The last column shows the name of the file(a.txt)

But i don't know for what the second column stands for?


问:
Can "git pull --all" update all my local branches?
I often have at least 3 remote branches: master, staging and production. I have 3 local branches that track those remote branches.

Updating all my local branches is tedious:

```<code>git fetch --all
git rebase origin/master
git checkout staging
git rebase origin/staging
git checkout production
git rebase origin/production
</code>```

I'd love to be able to just do a "git pull -all", but I haven't been able to get it to work. It seems to do a "fetch --all", then updates (fast forward or merges) the current working branch, but not the other local branches.

I'm still stuck manually switching to each local branch and updating.

答:
The behavior you describe for pull --all is exactly as expected, though not necessarily useful. The option is passed along to git fetch, which then fetches all refs from all remotes, instead of just the needed one; pull then merges (or in your case, rebases) the appropriate single branch.

If you want to check out other branches, you're going to have to check them out. And yes, merging (and rebasing) absolutely require a work tree, so they cannot be done without checking out the other branches. You could wrap up your described steps into a script/alias if you like, though I'd suggest joining the commands with && so that should one of them fail, it won't try to plow on.

Body:
I often have at least 3 remote branches: master, staging and production. I have 3 local branches that track those remote branches.

Updating all my local branches is tedious:

git fetch --all
git rebase origin/master
git checkout staging
git rebase origin/staging
git checkout production
git rebase origin/production

I'd love to be able to just do a "git pull -all", but I haven't been able to get it to work. It seems to do a "fetch --all", then updates (fast forward or merges) the current working branch, but not the other local branches.

I'm still stuck manually switching to each local branch and updating.


问:
Validate only if the field is entered in Laravel 5.2
```<code>public function rules() {
        return [
            'num_of_devices' => 'integer'
        ];
}
</code>```

I want to validate an integer field if and only if the field is entered. But above rule validates it for integer even if the field is empty. I used somtimes, but no result. But when I var_dump($num_of_devices) it is string.I am using Laravel 5.2. I think It was working fine in 5.1.

答:
From version 5.3 you can use nullable

```<code>public function rules() {
        return [
            'num_of_devices' => 'nullable | integer'
        ];
}
</code>```

Body:
public function rules() {
        return [
            'num_of_devices' => 'integer'
        ];
}

I want to validate an integer field if and only if the field is entered. But above rule validates it for integer even if the field is empty. I used somtimes, but no result. But when I var_dump($num_of_devices) it is string.I am using Laravel 5.2. I think It was working fine in 5.1.

Body:
From version 5.3 you can use nullable

public function rules() {
        return [
            'num_of_devices' => 'nullable | integer'
        ];
}


问:
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Sum
Data for every month is there till December. I want to get a new column as "sum" , which will sum till the previous month. Means, now it is august. So, the sum should be placed till july as shown in first entry in "Sum" column below. </p>

```<code>Jan| Feb| Mar| Apr| May| Jun |Jul |Aug |Sum
21 | 28 | 26 | 31 | 54 | 67  |38  |29  |265
11 | 44 | 66 | 7  | 88 | 54  |90  |74  |
13 | 45 | 26 | 38 | 36 | 39  |67  |49  |
76 | 35 | 67 | 23 | 76 | 54  |35  |59  |
</code>```

答:
```<code>DECLARE @DATE date
SET @date = GETDATE()
SELECT LEFT(DATENAME(MM, @DATE), 3)
</code>```

Body:
Data for every month is there till December. I want to get a new column as "sum" , which will sum till the previous month. Means, now it is august. So, the sum should be placed till july as shown in first entry in "Sum" column below.

Jan| Feb| Mar| Apr| May| Jun |Jul |Aug |Sum
21 | 28 | 26 | 31 | 54 | 67  |38  |29  |265
11 | 44 | 66 | 7  | 88 | 54  |90  |74  |
13 | 45 | 26 | 38 | 36 | 39  |67  |49  |
76 | 35 | 67 | 23 | 76 | 54  |35  |59  |


问:
Share application "link" in Android
I want my application user to be able to share/recommend my app to other users. I use the ACTION_SEND intent. I add plain text saying something along the lines of: install this cool application. But I can't find a way to enable users to directly go to the install screen of market place for instance. All I can provide them with is a web link or some text.
In other words I am looking for a very direct way for android users to have my app installed.

Thanks for any help/pointers,

Thomas

答:
I know this question has been answered, but I would like to share an alternate solution:</p>

```<code>Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
String shareSubText = "WhatsApp - The Great Chat App";
String shareBodyText = "https://play.google.com/store/apps/details?id=com.whatsapp&hl=en";
shareIntent.putExtra(Intent.EXTRA_SUBJECT, shareSubText);
shareIntent.putExtra(Intent.EXTRA_TEXT, shareBodyText);
startActivity(Intent.createChooser(shareIntent, "Share With"));
</code>```

Title: Share application "link" in Android

Body:
I know this question has been answered, but I would like to share an alternate solution:

Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
String shareSubText = "WhatsApp - The Great Chat App";
String shareBodyText = "https://play.google.com/store/apps/details?id=com.whatsapp&hl=en";
shareIntent.putExtra(Intent.EXTRA_SUBJECT, shareSubText);
shareIntent.putExtra(Intent.EXTRA_TEXT, shareBodyText);
startActivity(Intent.createChooser(shareIntent, "Share With"));


问:
Dynamic Facebook Open Graph tags possible?
I'm dynamically changing my <meta property="og:image" content="#"> and <meta property="og:title" content="#"> tags using jQuery (below). When I view the code via 'inspect' in Chrome, the tags have successfully been changed.

HTML:

```<code><meta property="og:title" content="#">
<meta property="og:image" content="#">
</code>```

jQuery:

```<code>$("meta[property='og:title']").attr("content", data.name);
$("meta[property='og:image']").attr("content", data.thumbnail.url);
</code>```

But the Facebook debugger tool is still showing content="#" for each. I'm assuming this is because Facebook reads the source code, before Javascript has a chance to replace the content.

Is there a way around this?

Thank you.

答:
Try this it worked for me.</p>

```<code><?php

$params = array();
if(count($_GET) > 0) {
    $params = $_GET;
} else {
    $params = $_POST;
}
// defaults
if($params['type'] == "") $params['type'] = "restaurant";
if($params['locale'] == "") $params['locale'] = "en_US";
if($params['title'] == "") $params['title'] = "default title";
if($params['image'] == "") $params['image'] = "thumb";
if($params['description'] == "") $params['description'] = "default description";

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# MY_APP_NAME_SPACE: http://ogp.me/ns/fb/MY_APP_NAME_SPACE#">
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

        <!-- Open Graph meta tags -->
        <meta property="fb:app_id" content="MY_APP_ID" />
        <meta property="og:site_name" content="meta site name"/>
        <meta property="og:url" content="http://URL/index.php?type=<?php echo $params['type']; ?>&locale=<?php echo $params['locale']; ?>&title=<?php echo $params['title']; ?>&image=<?php echo $params['image']; ?>&description=<?php echo $params['description']; ?>"/>
        <meta property="og:type" content="MY_APP_NAME_SPACE:<?php echo $params['type']; ?>"/>
        <meta property="og:locale" content="<?php echo $params['locale']; ?>"/>
        <meta property="og:title" content="<?php echo $params['title']; ?>"/>
        <meta property="og:image" content="http://URL/img/<?php echo $params['image']; ?>.png"/>
        <meta property="og:description" content="<?php echo $params['description']; ?>"/>

    </head>
</html>
</code>```

Body:
I'm dynamically changing my <meta property="og:image" content="#"> and <meta property="og:title" content="#"> tags using jQuery (below). When I view the code via 'inspect' in Chrome, the tags have successfully been changed.

HTML:

<meta property="og:title" content="#">
<meta property="og:image" content="#">

jQuery:

$("meta[property='og:title']").attr("content", data.name);
$("meta[property='og:image']").attr("content", data.thumbnail.url);

But the Facebook debugger tool is still showing content="#" for each. I'm assuming this is because Facebook reads the source code, before Javascript has a chance to replace the content.

Is there a way around this?

Thank you.

Body:
Try this it worked for me.

<?php

$params = array();
if(count($_GET) > 0) {
    $params = $_GET;
} else {
    $params = $_POST;
}
// defaults
if($params['type'] == "") $params['type'] = "restaurant";
if($params['locale'] == "") $params['locale'] = "en_US";
if($params['title'] == "") $params['title'] = "default title";
if($params['image'] == "") $params['image'] = "thumb";
if($params['description'] == "") $params['description'] = "default description";

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# MY_APP_NAME_SPACE: http://ogp.me/ns/fb/MY_APP_NAME_SPACE#">
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

        <!-- Open Graph meta tags -->
        <meta property="fb:app_id" content="MY_APP_ID" />
        <meta property="og:site_name" content="meta site name"/>
        <meta property="og:url" content="http://URL/index.php?type=<?php echo $params['type']; ?>&locale=<?php echo $params['locale']; ?>&title=<?php echo $params['title']; ?>&image=<?php echo $params['image']; ?>&description=<?php echo $params['description']; ?>"/>
        <meta property="og:type" content="MY_APP_NAME_SPACE:<?php echo $params['type']; ?>"/>
        <meta property="og:locale" content="<?php echo $params['locale']; ?>"/>
        <meta property="og:title" content="<?php echo $params['title']; ?>"/>
        <meta property="og:image" content="http://URL/img/<?php echo $params['image']; ?>.png"/>
        <meta property="og:description" content="<?php echo $params['description']; ?>"/>

    </head>
</html>


问:
Two Different Types of Character Entities?
Clearly there are two different types of character entities in HTML/XML.

There are the ones that are specified by numbers, i.e. < and >

And then there are the ones that are specified by letters, < and >

Is there a specific name for each of these types of character entities, or are they just "character entities that are specified by numbers and character entities that are specified by letters?

答:
These are numeric character references (<) and character entities (<).

Character entities are defined as a sequence of character references - for instance, nbsp is defined as  .

When processed, character entities are converted to the corresponding character references.

By the way - a character entity can be defined as more than one character reference, though this has not been done in XML or HTML.

Body:
These are numeric character references (&#60;) and character entities (&lt;).

Character entities are defined as a sequence of character references - for instance, nbsp is defined as &#160;.

When processed, character entities are converted to the corresponding character references.

By the way - a character entity can be defined as more than one character reference, though this has not been done in XML or HTML.


问:
On Error Go To in a Loop
I am trying to create a loop that will look through a list of customers, and if there is a report for that customer, email that customer the report.

What I need is an On Error statement that will allow customers without reports to be skipped and allow the script to continue onto the next customer right up until the end of the customer list.

The On Error statement I have currently, gets stuck after all customers have been cycled through, and continues looping in the On Error statement.

Any help would be greatly appreciated!!!

```<code>sub test()

a = 2

Check:

  Do Until UniqueBuyer.Range("A" & a).Value = ""

 On Error GoTo ErrHandler:

    Sheets(UniqueBuyer.Range("A" & a).Value).Activate

        ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        FolderLocation & FolderName & "\" & _
        UniqueBuyer.Range("A" & a).Value & ".pdf" _
        , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
        :=Flase, OpenAfterPublish:=False
        PDFFile = FolderLocation & FolderName & "\" & _
        UniqueBuyer.Range("A" & a).Value & ".pdf"

            Set OutLookApp = CreateObject("Outlook.Application")
            Set OutlookMail = OutLookApp.createItem(0)
            CombinedEmail = ""
            'Clear variable - LK
            On Error Resume Next
            'Display email and specify To, Subject, etc
            With OutlookMail

                .Display
                c = 4
                Do Until UniqueBuyer.Cells(a, c).Value = ""
                AdditionalEmail = UniqueBuyer.Cells(a, c)
                CombinedEmail = CombinedEmail & ";" & AdditionalEmail
                .to = CombinedEmail
                c = c + 1
                Loop

                .cc = ""
                .BCC = ""
                .Subject = "Weekly Wooltrade Summary " & Left(Master.Range("X2"), 3)
                .Body = ""
                .Attachments.Add PDFFile
                '.Send

             End With

            On Error GoTo 0

a = a + 1

Loop
Exit Sub

ErrHandler:

a = a + 1
GoTo Check

 End Sub
</code>```

答:
the On Error GoTo way is hardly the one to go: you'd better check for any possible error and handle it

furthermore you'd also better instantiate one Outlook Application only for all needed emails

finally there were some typos (Flase -> False)

here's a possible (commented) refactoring of your code for what above:

```<code>Option Explicit

Sub test()
    Dim UniqueBuyer As Worksheet, Master As Worksheet
    Dim FolderLocation As String, FolderName As String, PDFFile As String
    Dim OutLookApp As Object
    Dim cell As Range

    FolderLocation = "C:\Users\...\" '<--| change it to your actual folder location
    FolderName = "Test" '<--| change it to your actual folder name

    Set UniqueBuyer = Worksheets("UniqueBuyer") '<--| change "UniqueBuyer" to your actual Unique Buyer sheet name
    Set Master = Worksheets("Master") '<--| change "Master" to your actual Master sheet name

    Set OutLookApp = CreateObject("Outlook.Application") '<--| set one Outlook application outside the loop

    With UniqueBuyer '<--| reference your "Unique Buyer" sheet
        For Each cell In .Range("A2", .Cells(.Rows.Count, 1).End(xlUp)).SpecialCells(xlCellTypeConstants, xlTextValues) '<--| loop through its column A cells with constant (i.e. not from formulas) text content from row 2 down to last not empty one
            PDFFile = FolderLocation & FolderName & "\" & cell.Value & ".pdf" '<--| build your PDF file name
            With .Range(cell.Offset(, 3), cell.Offset(, 3).End(xlToRight)) '<--| reference current buyer cells from column 4 rightwards
                If WorksheetFunction.CountA(.Cells) > 0 Then '<--| if any not-blank cells in referenced ones
                    If OKSheetAndExportToPDF(cell.Value, PDFFile) Then '<--| if successfully found current buyer sheet and exported it to PDF
                        'Display email and specify To, Subject, etc
                        With OutLookApp.createItem(0) '<--| create a new mail item and reference it
                            .Display
                            .to = GetCombinedEmails(.SpecialCells(xlCellTypeConstants, xlTextValues)) '<--| get emails string from currently referenced cells with some constant text value
                            .cc = ""
                            .BCC = ""
                            .Subject = "Weekly Wooltrade Summary " & Left(Master.Range("X2"), 3)
                            .Body = ""
                            .Attachments.Add PDFFile
                            '.Send
                        End With
                    End If
                End If
            End With
        Next
    End With

    Set OutLookApp = Nothing
End Sub

Function GetCombinedEmails(rng As Range) As String
    Dim cell As Range
    With rng
        If .Count = 1 Then
            GetCombinedEmails = .Value
        Else
            GetCombinedEmails = Join(Application.Transpose(Application.Transpose(.Value)), ";") '<--| join all found consecutive email addresses in one string
        End If
    End With
End Function

Function OKSheetAndExportToPDF(shtName As String, PDFFile As String) As Boolean
    On Error GoTo ExitFunction
    With Worksheets(shtName)
        .ExportAsFixedFormat Type:=xlTypePDF, _
            Filename:=PDFFile, _
            Quality:=xlQualityStandard, _
            IncludeDocProperties:=True, _
            IgnorePrintAreas:=False, _
            OpenAfterPublish:=False
        OKSheetAndExportToPDF = True
    End With
ExitFunction:
End Function
</code>```

Title: On Error Go To in a Loop

Body:
I am trying to create a loop that will look through a list of customers, and if there is a report for that customer, email that customer the report.

What I need is an On Error statement that will allow customers without reports to be skipped and allow the script to continue onto the next customer right up until the end of the customer list.

The On Error statement I have currently, gets stuck after all customers have been cycled through, and continues looping in the On Error statement.

Any help would be greatly appreciated!!!

sub test()

a = 2

Check:

  Do Until UniqueBuyer.Range("A" & a).Value = ""

 On Error GoTo ErrHandler:

    Sheets(UniqueBuyer.Range("A" & a).Value).Activate

        ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        FolderLocation & FolderName & "\" & _
        UniqueBuyer.Range("A" & a).Value & ".pdf" _
        , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
        :=Flase, OpenAfterPublish:=False
        PDFFile = FolderLocation & FolderName & "\" & _
        UniqueBuyer.Range("A" & a).Value & ".pdf"

            Set OutLookApp = CreateObject("Outlook.Application")
            Set OutlookMail = OutLookApp.createItem(0)
            CombinedEmail = ""
            'Clear variable - LK
            On Error Resume Next
            'Display email and specify To, Subject, etc
            With OutlookMail

                .Display
                c = 4
                Do Until UniqueBuyer.Cells(a, c).Value = ""
                AdditionalEmail = UniqueBuyer.Cells(a, c)
                CombinedEmail = CombinedEmail & ";" & AdditionalEmail
                .to = CombinedEmail
                c = c + 1
                Loop

                .cc = ""
                .BCC = ""
                .Subject = "Weekly Wooltrade Summary " & Left(Master.Range("X2"), 3)
                .Body = ""
                .Attachments.Add PDFFile
                '.Send

             End With

            On Error GoTo 0

a = a + 1

Loop
Exit Sub

ErrHandler:

a = a + 1
GoTo Check

 End Sub

Body:
the On Error GoTo way is hardly the one to go: you'd better check for any possible error and handle it

furthermore you'd also better instantiate one Outlook Application only for all needed emails

finally there were some typos (Flase -> False)

here's a possible (commented) refactoring of your code for what above:

Option Explicit

Sub test()
    Dim UniqueBuyer As Worksheet, Master As Worksheet
    Dim FolderLocation As String, FolderName As String, PDFFile As String
    Dim OutLookApp As Object
    Dim cell As Range

    FolderLocation = "C:\Users\...\" '<--| change it to your actual folder location
    FolderName = "Test" '<--| change it to your actual folder name

    Set UniqueBuyer = Worksheets("UniqueBuyer") '<--| change "UniqueBuyer" to your actual Unique Buyer sheet name
    Set Master = Worksheets("Master") '<--| change "Master" to your actual Master sheet name

    Set OutLookApp = CreateObject("Outlook.Application") '<--| set one Outlook application outside the loop

    With UniqueBuyer '<--| reference your "Unique Buyer" sheet
        For Each cell In .Range("A2", .Cells(.Rows.Count, 1).End(xlUp)).SpecialCells(xlCellTypeConstants, xlTextValues) '<--| loop through its column A cells with constant (i.e. not from formulas) text content from row 2 down to last not empty one
            PDFFile = FolderLocation & FolderName & "\" & cell.Value & ".pdf" '<--| build your PDF file name
            With .Range(cell.Offset(, 3), cell.Offset(, 3).End(xlToRight)) '<--| reference current buyer cells from column 4 rightwards
                If WorksheetFunction.CountA(.Cells) > 0 Then '<--| if any not-blank cells in referenced ones
                    If OKSheetAndExportToPDF(cell.Value, PDFFile) Then '<--| if successfully found current buyer sheet and exported it to PDF
                        'Display email and specify To, Subject, etc
                        With OutLookApp.createItem(0) '<--| create a new mail item and reference it
                            .Display
                            .to = GetCombinedEmails(.SpecialCells(xlCellTypeConstants, xlTextValues)) '<--| get emails string from currently referenced cells with some constant text value
                            .cc = ""
                            .BCC = ""
                            .Subject = "Weekly Wooltrade Summary " & Left(Master.Range("X2"), 3)
                            .Body = ""
                            .Attachments.Add PDFFile
                            '.Send
                        End With
                    End If
                End If
            End With
        Next
    End With

    Set OutLookApp = Nothing
End Sub

Function GetCombinedEmails(rng As Range) As String
    Dim cell As Range
    With rng
        If .Count = 1 Then
            GetCombinedEmails = .Value
        Else
            GetCombinedEmails = Join(Application.Transpose(Application.Transpose(.Value)), ";") '<--| join all found consecutive email addresses in one string
        End If
    End With
End Function

Function OKSheetAndExportToPDF(shtName As String, PDFFile As String) As Boolean
    On Error GoTo ExitFunction
    With Worksheets(shtName)
        .ExportAsFixedFormat Type:=xlTypePDF, _
            Filename:=PDFFile, _
            Quality:=xlQualityStandard, _
            IncludeDocProperties:=True, _
            IgnorePrintAreas:=False, _
            OpenAfterPublish:=False
        OKSheetAndExportToPDF = True
    End With
ExitFunction:
End Function